00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * private/v27ter_rx.h - ITU V.27ter 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_V27TER_RX_H_) 00027 #define _SPANDSP_PRIVATE_V27TER_RX_H_ 00028 00029 /* Target length for the equalizer is about 43 taps for 4800bps and 32 taps for 2400bps 00030 to deal with the worst stuff in V.56bis. */ 00031 /*! The length of the equalizer buffer. Must be a power of 2 */ 00032 #define V27TER_EQUALIZER_LEN 32 00033 /*! Samples before the target central position in the equalizer buffer */ 00034 #define V27TER_EQUALIZER_PRE_LEN 16 00035 00036 /*! The number of taps in the 4800bps pulse shaping/bandpass filter */ 00037 #define V27TER_RX_4800_FILTER_STEPS 27 00038 /*! The number of taps in the 2400bps pulse shaping/bandpass filter */ 00039 #define V27TER_RX_2400_FILTER_STEPS 27 00040 00041 #if V27TER_RX_4800_FILTER_STEPS > V27TER_RX_2400_FILTER_STEPS 00042 #define V27TER_RX_FILTER_STEPS V27TER_RX_4800_FILTER_STEPS 00043 #else 00044 #define V27TER_RX_FILTER_STEPS V27TER_RX_2400_FILTER_STEPS 00045 #endif 00046 00047 /*! 00048 V.27ter modem receive side descriptor. This defines the working state for a 00049 single instance of a V.27ter modem receiver. 00050 */ 00051 struct v27ter_rx_state_s 00052 { 00053 /*! \brief The bit rate of the modem. Valid values are 2400 and 4800. */ 00054 int bit_rate; 00055 /*! \brief The callback function used to put each bit received. */ 00056 put_bit_func_t put_bit; 00057 /*! \brief A user specified opaque pointer passed to the put_bit routine. */ 00058 void *put_bit_user_data; 00059 00060 /*! \brief The callback function used to report modem status changes. */ 00061 modem_status_func_t status_handler; 00062 /*! \brief A user specified opaque pointer passed to the status function. */ 00063 void *status_user_data; 00064 00065 /*! \brief A callback function which may be enabled to report every symbol's 00066 constellation position. */ 00067 qam_report_handler_t qam_report; 00068 /*! \brief A user specified opaque pointer passed to the qam_report callback 00069 routine. */ 00070 void *qam_user_data; 00071 00072 #if defined(SPANDSP_USE_FIXED_POINT) 00073 /*! \brief The scaling factor assessed by the AGC algorithm. */ 00074 int16_t agc_scaling; 00075 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ 00076 int16_t agc_scaling_save; 00077 00078 /*! \brief The current delta factor for updating the equalizer coefficients. */ 00079 int16_t eq_delta; 00080 /*! \brief The adaptive equalizer coefficients. */ 00081 complexi16_t eq_coeff[V27TER_EQUALIZER_LEN]; 00082 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ 00083 complexi16_t eq_coeff_save[V27TER_EQUALIZER_LEN]; 00084 /*! \brief The equalizer signal buffer. */ 00085 complexi16_t eq_buf[V27TER_EQUALIZER_LEN]; 00086 00087 /*! \brief A measure of how much mismatch there is between the real constellation, 00088 and the decoded symbol positions. */ 00089 int32_t training_error; 00090 00091 /*! \brief The proportional part of the carrier tracking filter. */ 00092 int32_t carrier_track_p; 00093 /*! \brief The integral part of the carrier tracking filter. */ 00094 int32_t carrier_track_i; 00095 /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ 00096 int16_t rrc_filter[V27TER_RX_FILTER_STEPS]; 00097 #else 00098 /*! \brief The scaling factor assessed by the AGC algorithm. */ 00099 float agc_scaling; 00100 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ 00101 float agc_scaling_save; 00102 00103 /*! \brief The current delta factor for updating the equalizer coefficients. */ 00104 float eq_delta; 00105 /*! \brief The adaptive equalizer coefficients. */ 00106 complexf_t eq_coeff[V27TER_EQUALIZER_LEN]; 00107 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ 00108 complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN]; 00109 /*! \brief The equalizer signal buffer. */ 00110 complexf_t eq_buf[V27TER_EQUALIZER_LEN]; 00111 00112 /*! \brief A measure of how much mismatch there is between the real constellation, 00113 and the decoded symbol positions. */ 00114 float training_error; 00115 00116 /*! \brief The proportional part of the carrier tracking filter. */ 00117 float carrier_track_p; 00118 /*! \brief The integral part of the carrier tracking filter. */ 00119 float carrier_track_i; 00120 /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ 00121 float rrc_filter[V27TER_RX_FILTER_STEPS]; 00122 #endif 00123 /*! \brief Current offset into the RRC pulse shaping filter buffer. */ 00124 int rrc_filter_step; 00125 00126 /*! \brief The register for the training and data scrambler. */ 00127 uint32_t scramble_reg; 00128 /*! \brief A counter for the number of consecutive bits of repeating pattern through 00129 the scrambler. */ 00130 int scrambler_pattern_count; 00131 /*! \brief The current step in the table of BC constellation positions. */ 00132 int training_bc; 00133 /*! \brief TRUE if the previous trained values are to be reused. */ 00134 int old_train; 00135 /*! \brief The section of the training data we are currently in. */ 00136 int training_stage; 00137 /*! \brief A count of how far through the current training step we are. */ 00138 int training_count; 00139 /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ 00140 int16_t last_sample; 00141 /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.27ter signal. */ 00142 int signal_present; 00143 /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ 00144 int carrier_drop_pending; 00145 /*! \brief A count of the current consecutive samples below the carrier off threshold. */ 00146 int low_samples; 00147 /*! \brief A highest magnitude sample seen. */ 00148 int16_t high_sample; 00149 00150 /*! \brief The position of the current symbol in the constellation, used for 00151 differential decoding. */ 00152 int constellation_state; 00153 00154 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ 00155 uint32_t carrier_phase; 00156 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ 00157 int32_t carrier_phase_rate; 00158 /*! \brief The carrier update rate saved for reuse when using short training. */ 00159 int32_t carrier_phase_rate_save; 00160 00161 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ 00162 power_meter_t power; 00163 /*! \brief The power meter level at which carrier on is declared. */ 00164 int32_t carrier_on_power; 00165 /*! \brief The power meter level at which carrier off is declared. */ 00166 int32_t carrier_off_power; 00167 00168 /*! \brief Current read offset into the equalizer buffer. */ 00169 int eq_step; 00170 /*! \brief Current write offset into the equalizer buffer. */ 00171 int eq_put_step; 00172 /*! \brief Symbol counter to the next equalizer update. */ 00173 int eq_skip; 00174 00175 /*! \brief The current half of the baud. */ 00176 int baud_half; 00177 00178 /*! \brief Integration variable for damping the Gardner algorithm tests. */ 00179 int gardner_integrate; 00180 /*! \brief Current step size of Gardner algorithm integration. */ 00181 int gardner_step; 00182 /*! \brief The total symbol timing correction since the carrier came up. 00183 This is only for performance analysis purposes. */ 00184 int total_baud_timing_correction; 00185 00186 /*! \brief Starting phase angles for the coarse carrier aquisition step. */ 00187 int32_t start_angles[2]; 00188 /*! \brief History list of phase angles for the coarse carrier aquisition step. */ 00189 int32_t angles[16]; 00190 /*! \brief Error and flow logging control */ 00191 logging_state_t logging; 00192 }; 00193 00194 #endif 00195 /*- End of file ------------------------------------------------------------*/
1.6.1