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_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 #if defined(SPANDSP_USE_FIXED_POINT) 00065 /*! \brief The scaling factor assessed by the AGC algorithm. */ 00066 int16_t agc_scaling; 00067 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ 00068 int16_t agc_scaling_save; 00069 00070 /*! \brief The current delta factor for updating the equalizer coefficients. */ 00071 int16_t eq_delta; 00072 /*! \brief The adaptive equalizer coefficients. */ 00073 complexi16_t eq_coeff[V29_EQUALIZER_LEN]; 00074 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ 00075 complexi16_t eq_coeff_save[V29_EQUALIZER_LEN]; 00076 /*! \brief The equalizer signal buffer. */ 00077 complexi16_t eq_buf[V29_EQUALIZER_LEN]; 00078 00079 /*! Low band edge filter for symbol sync. */ 00080 int32_t symbol_sync_low[2]; 00081 /*! High band edge filter for symbol sync. */ 00082 int32_t symbol_sync_high[2]; 00083 /*! DC filter for symbol sync. */ 00084 int32_t symbol_sync_dc_filter[2]; 00085 /*! Baud phase for symbol sync. */ 00086 int32_t baud_phase; 00087 00088 /*! \brief A measure of how much mismatch there is between the real constellation, 00089 and the decoded symbol positions. */ 00090 int32_t training_error; 00091 00092 /*! \brief The proportional part of the carrier tracking filter. */ 00093 int32_t carrier_track_p; 00094 /*! \brief The integral part of the carrier tracking filter. */ 00095 int32_t carrier_track_i; 00096 /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ 00097 int16_t rrc_filter[V29_RX_FILTER_STEPS]; 00098 #else 00099 /*! \brief The scaling factor assessed by the AGC algorithm. */ 00100 float agc_scaling; 00101 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ 00102 float agc_scaling_save; 00103 00104 /*! \brief The current delta factor for updating the equalizer coefficients. */ 00105 float eq_delta; 00106 /*! \brief The adaptive equalizer coefficients. */ 00107 complexf_t eq_coeff[V29_EQUALIZER_LEN]; 00108 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ 00109 complexf_t eq_coeff_save[V29_EQUALIZER_LEN]; 00110 /*! \brief The equalizer signal buffer. */ 00111 complexf_t eq_buf[V29_EQUALIZER_LEN]; 00112 00113 /*! Low band edge filter for symbol sync. */ 00114 float symbol_sync_low[2]; 00115 /*! High band edge filter for symbol sync. */ 00116 float symbol_sync_high[2]; 00117 /*! DC filter for symbol sync. */ 00118 float symbol_sync_dc_filter[2]; 00119 /*! Baud phase for symbol sync. */ 00120 float baud_phase; 00121 00122 /*! \brief A measure of how much mismatch there is between the real constellation, 00123 and the decoded symbol positions. */ 00124 float training_error; 00125 00126 /*! \brief The proportional part of the carrier tracking filter. */ 00127 float carrier_track_p; 00128 /*! \brief The integral part of the carrier tracking filter. */ 00129 float carrier_track_i; 00130 /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ 00131 float rrc_filter[V29_RX_FILTER_STEPS]; 00132 #endif 00133 /*! \brief Current offset into the RRC pulse shaping filter buffer. */ 00134 int rrc_filter_step; 00135 00136 /*! \brief The register for the data scrambler. */ 00137 uint32_t scramble_reg; 00138 /*! \brief The register for the training scrambler. */ 00139 uint8_t training_scramble_reg; 00140 /*! \brief The current step in the table of CD constellation positions. */ 00141 int training_cd; 00142 /*! \brief TRUE if the previous trained values are to be reused. */ 00143 int old_train; 00144 /*! \brief The section of the training data we are currently in. */ 00145 int training_stage; 00146 /*! \brief A count of how far through the current training step we are. */ 00147 int training_count; 00148 /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ 00149 int16_t last_sample; 00150 /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.29 signal. */ 00151 int signal_present; 00152 /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ 00153 int carrier_drop_pending; 00154 /*! \brief A count of the current consecutive samples below the carrier off threshold. */ 00155 int low_samples; 00156 /*! \brief A highest magnitude sample seen. */ 00157 int16_t high_sample; 00158 00159 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ 00160 uint32_t carrier_phase; 00161 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ 00162 int32_t carrier_phase_rate; 00163 /*! \brief The carrier update rate saved for reuse when using short training. */ 00164 int32_t carrier_phase_rate_save; 00165 00166 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ 00167 power_meter_t power; 00168 /*! \brief The power meter level at which carrier on is declared. */ 00169 int32_t carrier_on_power; 00170 /*! \brief The power meter level at which carrier off is declared. */ 00171 int32_t carrier_off_power; 00172 00173 /*! \brief Current read offset into the equalizer buffer. */ 00174 int eq_step; 00175 /*! \brief Current write offset into the equalizer buffer. */ 00176 int eq_put_step; 00177 /*! \brief Symbol counter to the next equalizer update. */ 00178 int eq_skip; 00179 00180 /*! \brief The current half of the baud. */ 00181 int baud_half; 00182 00183 /*! \brief The total symbol timing correction since the carrier came up. 00184 This is only for performance analysis purposes. */ 00185 int total_baud_timing_correction; 00186 00187 /*! \brief Starting phase angles for the coarse carrier aquisition step. */ 00188 int32_t start_angles[2]; 00189 /*! \brief History list of phase angles for the coarse carrier aquisition step. */ 00190 int32_t angles[16]; 00191 00192 /*! \brief The position of the current symbol in the constellation, used for 00193 differential decoding. */ 00194 int constellation_state; 00195 00196 /*! \brief Error and flow logging control */ 00197 logging_state_t logging; 00198 }; 00199 00200 #endif 00201 /*- End of file ------------------------------------------------------------*/
1.6.1