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