00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * private/v29rx.h - ITU V.29 modem receive part 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2003 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 #if !defined(_SPANDSP_PRIVATE_V29RX_H_) 00027 #define _SPANDSP_PRIVATE_V29RX_H_ 00028 00029 /* Target length for the equalizer is about 63 taps, to deal with the worst stuff 00030 in V.56bis. */ 00031 /*! The length of the equalizer buffer */ 00032 #define V29_EQUALIZER_LEN 33 00033 /*! Samples before the target position in the equalizer buffer */ 00034 #define V29_EQUALIZER_PRE_LEN 16 00035 00036 /*! The number of taps in the pulse shaping/bandpass filter */ 00037 #define V29_RX_FILTER_STEPS 27 00038 00039 /*! 00040 V.29 modem receive side descriptor. This defines the working state for a 00041 single instance of a V.29 modem receiver. 00042 */ 00043 struct v29_rx_state_s 00044 { 00045 /*! \brief The bit rate of the modem. Valid values are 4800, 7200 and 9600. */ 00046 int bit_rate; 00047 /*! \brief The callback function used to put each bit received. */ 00048 put_bit_func_t put_bit; 00049 /*! \brief A user specified opaque pointer passed to the put_bit routine. */ 00050 void *put_bit_user_data; 00051 00052 /*! \brief The callback function used to report modem status changes. */ 00053 modem_rx_status_func_t status_handler; 00054 /*! \brief A user specified opaque pointer passed to the status function. */ 00055 void *status_user_data; 00056 00057 /*! \brief A callback function which may be enabled to report every symbol's 00058 constellation position. */ 00059 qam_report_handler_t qam_report; 00060 /*! \brief A user specified opaque pointer passed to the qam_report callback 00061 routine. */ 00062 void *qam_user_data; 00063 00064 /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ 00065 #if defined(SPANDSP_USE_FIXED_POINT) 00066 int16_t rrc_filter[V29_RX_FILTER_STEPS]; 00067 #else 00068 float rrc_filter[V29_RX_FILTER_STEPS]; 00069 #endif 00070 /*! \brief Current offset into the RRC pulse shaping filter buffer. */ 00071 int rrc_filter_step; 00072 00073 /*! \brief The register for the data scrambler. */ 00074 uint32_t scramble_reg; 00075 /*! \brief The register for the training scrambler. */ 00076 uint8_t training_scramble_reg; 00077 /*! \brief The current step in the table of CD constellation positions. */ 00078 int training_cd; 00079 /*! \brief TRUE if the previous trained values are to be reused. */ 00080 int old_train; 00081 /*! \brief The section of the training data we are currently in. */ 00082 int training_stage; 00083 /*! \brief A count of how far through the current training step we are. */ 00084 int training_count; 00085 /*! \brief A measure of how much mismatch there is between the real constellation, 00086 and the decoded symbol positions. */ 00087 float training_error; 00088 /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ 00089 int16_t last_sample; 00090 /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.29 signal. */ 00091 int signal_present; 00092 /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ 00093 int carrier_drop_pending; 00094 /*! \brief A count of the current consecutive samples below the carrier off threshold. */ 00095 int low_samples; 00096 /*! \brief A highest magnitude sample seen. */ 00097 int16_t high_sample; 00098 00099 /*! \brief The position of the current symbol in the constellation, used for 00100 differential decoding. */ 00101 int constellation_state; 00102 00103 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ 00104 uint32_t carrier_phase; 00105 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ 00106 int32_t carrier_phase_rate; 00107 /*! \brief The carrier update rate saved for reuse when using short training. */ 00108 int32_t carrier_phase_rate_save; 00109 #if defined(SPANDSP_USE_FIXED_POINT) 00110 /*! \brief The proportional part of the carrier tracking filter. */ 00111 int32_t carrier_track_p; 00112 /*! \brief The integral part of the carrier tracking filter. */ 00113 int32_t carrier_track_i; 00114 #else 00115 /*! \brief The proportional part of the carrier tracking filter. */ 00116 float carrier_track_p; 00117 /*! \brief The integral part of the carrier tracking filter. */ 00118 float carrier_track_i; 00119 #endif 00120 00121 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ 00122 power_meter_t power; 00123 /*! \brief The power meter level at which carrier on is declared. */ 00124 int32_t carrier_on_power; 00125 /*! \brief The power meter level at which carrier off is declared. */ 00126 int32_t carrier_off_power; 00127 00128 /*! \brief Current read offset into the equalizer buffer. */ 00129 int eq_step; 00130 /*! \brief Current write offset into the equalizer buffer. */ 00131 int eq_put_step; 00132 /*! \brief Symbol counter to the next equalizer update. */ 00133 int eq_skip; 00134 00135 /*! \brief The current half of the baud. */ 00136 int baud_half; 00137 00138 #if defined(SPANDSP_USE_FIXED_POINT) 00139 /*! \brief The scaling factor accessed by the AGC algorithm. */ 00140 int16_t agc_scaling; 00141 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ 00142 int16_t agc_scaling_save; 00143 00144 /*! \brief The current delta factor for updating the equalizer coefficients. */ 00145 int16_t eq_delta; 00146 /*! \brief The adaptive equalizer coefficients. */ 00147 complexi16_t eq_coeff[V29_EQUALIZER_LEN]; 00148 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ 00149 complexi16_t eq_coeff_save[V29_EQUALIZER_LEN]; 00150 /*! \brief The equalizer signal buffer. */ 00151 complexi16_t eq_buf[V29_EQUALIZER_LEN]; 00152 00153 /*! Low band edge filter for symbol sync. */ 00154 int32_t symbol_sync_low[2]; 00155 /*! High band edge filter for symbol sync. */ 00156 int32_t symbol_sync_high[2]; 00157 /*! DC filter for symbol sync. */ 00158 int32_t symbol_sync_dc_filter[2]; 00159 /*! Baud phase for symbol sync. */ 00160 int32_t baud_phase; 00161 #else 00162 /*! \brief The scaling factor accessed by the AGC algorithm. */ 00163 float agc_scaling; 00164 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ 00165 float agc_scaling_save; 00166 00167 /*! \brief The current delta factor for updating the equalizer coefficients. */ 00168 float eq_delta; 00169 /*! \brief The adaptive equalizer coefficients. */ 00170 complexf_t eq_coeff[V29_EQUALIZER_LEN]; 00171 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ 00172 complexf_t eq_coeff_save[V29_EQUALIZER_LEN]; 00173 /*! \brief The equalizer signal buffer. */ 00174 complexf_t eq_buf[V29_EQUALIZER_LEN]; 00175 00176 /*! Low band edge filter for symbol sync. */ 00177 float symbol_sync_low[2]; 00178 /*! High band edge filter for symbol sync. */ 00179 float symbol_sync_high[2]; 00180 /*! DC filter for symbol sync. */ 00181 float symbol_sync_dc_filter[2]; 00182 /*! Baud phase for symbol sync. */ 00183 float baud_phase; 00184 #endif 00185 00186 /*! \brief The total symbol timing correction since the carrier came up. 00187 This is only for performance analysis purposes. */ 00188 int total_baud_timing_correction; 00189 00190 /*! \brief Starting phase angles for the coarse carrier aquisition step. */ 00191 int32_t start_angles[2]; 00192 /*! \brief History list of phase angles for the coarse carrier aquisition step. */ 00193 int32_t angles[16]; 00194 /*! \brief Error and flow logging control */ 00195 logging_state_t logging; 00196 }; 00197 00198 #endif 00199 /*- End of file ------------------------------------------------------------*/