spandsp 0.0.6
|
00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * private/v17rx.h - ITU V.17 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: v17rx.h,v 1.2.4.1 2009/12/24 16:52:30 steveu Exp $ 00026 */ 00027 00028 #if !defined(_SPANDSP_PRIVATE_V17RX_H_) 00029 #define _SPANDSP_PRIVATE_V17RX_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 V17_EQUALIZER_PRE_LEN 8 00035 /*! Samples after the target position in the equalizer buffer */ 00036 #define V17_EQUALIZER_POST_LEN 8 00037 00038 /*! The number of taps in the pulse shaping/bandpass filter */ 00039 #define V17_RX_FILTER_STEPS 27 00040 00041 /* We can store more trellis depth that we look back over, so that we can push out a group 00042 of symbols in one go, giving greater processing efficiency, at the expense of a bit more 00043 latency through the modem. */ 00044 /* Right now we don't take advantage of this optimisation. */ 00045 /*! The depth of the trellis buffer */ 00046 #define V17_TRELLIS_STORAGE_DEPTH 16 00047 /*! How far we look back into history for trellis decisions */ 00048 #define V17_TRELLIS_LOOKBACK_DEPTH 16 00049 00050 /*! 00051 V.17 modem receive side descriptor. This defines the working state for a 00052 single instance of a V.17 modem receiver. 00053 */ 00054 struct v17_rx_state_s 00055 { 00056 /*! \brief The bit rate of the modem. Valid values are 7200 9600, 12000 and 14400. */ 00057 int bit_rate; 00058 /*! \brief The callback function used to put each bit received. */ 00059 put_bit_func_t put_bit; 00060 /*! \brief A user specified opaque pointer passed to the put_but routine. */ 00061 void *put_bit_user_data; 00062 00063 /*! \brief The callback function used to report modem status changes. */ 00064 modem_rx_status_func_t status_handler; 00065 /*! \brief A user specified opaque pointer passed to the status function. */ 00066 void *status_user_data; 00067 00068 /*! \brief A callback function which may be enabled to report every symbol's 00069 constellation position. */ 00070 qam_report_handler_t qam_report; 00071 /*! \brief A user specified opaque pointer passed to the qam_report callback 00072 routine. */ 00073 void *qam_user_data; 00074 00075 /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ 00076 #if defined(SPANDSP_USE_FIXED_POINT) 00077 int16_t rrc_filter[V17_RX_FILTER_STEPS]; 00078 #else 00079 float rrc_filter[V17_RX_FILTER_STEPS]; 00080 #endif 00081 /*! \brief Current offset into the RRC pulse shaping filter buffer. */ 00082 int rrc_filter_step; 00083 00084 /*! \brief The state of the differential decoder */ 00085 int diff; 00086 /*! \brief The register for the data scrambler. */ 00087 uint32_t scramble_reg; 00088 /*! \brief Scrambler tap */ 00089 //int scrambler_tap; 00090 00091 /*! \brief TRUE if the short training sequence is to be used. */ 00092 int short_train; 00093 /*! \brief The section of the training data we are currently in. */ 00094 int training_stage; 00095 /*! \brief A count of how far through the current training step we are. */ 00096 int training_count; 00097 /*! \brief A measure of how much mismatch there is between the real constellation, 00098 and the decoded symbol positions. */ 00099 float training_error; 00100 /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ 00101 int16_t last_sample; 00102 /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.17 signal. */ 00103 int signal_present; 00104 /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ 00105 int carrier_drop_pending; 00106 /*! \brief A count of the current consecutive samples below the carrier off threshold. */ 00107 int low_samples; 00108 /*! \brief A highest magnitude sample seen. */ 00109 int16_t high_sample; 00110 00111 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ 00112 uint32_t carrier_phase; 00113 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ 00114 int32_t carrier_phase_rate; 00115 /*! \brief The carrier update rate saved for reuse when using short training. */ 00116 int32_t carrier_phase_rate_save; 00117 #if defined(SPANDSP_USE_FIXED_POINTx) 00118 /*! \brief The proportional part of the carrier tracking filter. */ 00119 float carrier_track_p; 00120 /*! \brief The integral part of the carrier tracking filter. */ 00121 float carrier_track_i; 00122 #else 00123 /*! \brief The proportional part of the carrier tracking filter. */ 00124 float carrier_track_p; 00125 /*! \brief The integral part of the carrier tracking filter. */ 00126 float carrier_track_i; 00127 #endif 00128 00129 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ 00130 power_meter_t power; 00131 /*! \brief The power meter level at which carrier on is declared. */ 00132 int32_t carrier_on_power; 00133 /*! \brief The power meter level at which carrier off is declared. */ 00134 int32_t carrier_off_power; 00135 00136 /*! \brief Current read offset into the equalizer buffer. */ 00137 int eq_step; 00138 /*! \brief Current write offset into the equalizer buffer. */ 00139 int eq_put_step; 00140 /*! \brief Symbol counter to the next equalizer update. */ 00141 int eq_skip; 00142 00143 /*! \brief The current half of the baud. */ 00144 int baud_half; 00145 00146 #if defined(SPANDSP_USE_FIXED_POINTx) 00147 /*! \brief The scaling factor accessed by the AGC algorithm. */ 00148 float agc_scaling; 00149 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ 00150 float agc_scaling_save; 00151 00152 /*! \brief The current delta factor for updating the equalizer coefficients. */ 00153 float eq_delta; 00154 /*! \brief The adaptive equalizer coefficients. */ 00155 complexi16_t eq_coeff[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; 00156 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ 00157 complexi16_t eq_coeff_save[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; 00158 /*! \brief The equalizer signal buffer. */ 00159 complexi16_t eq_buf[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; 00160 00161 /*! Low band edge filter for symbol sync. */ 00162 int32_t symbol_sync_low[2]; 00163 /*! High band edge filter for symbol sync. */ 00164 int32_t symbol_sync_high[2]; 00165 /*! DC filter for symbol sync. */ 00166 int32_t symbol_sync_dc_filter[2]; 00167 /*! Baud phase for symbol sync. */ 00168 int32_t baud_phase; 00169 #else 00170 /*! \brief The scaling factor accessed by the AGC algorithm. */ 00171 float agc_scaling; 00172 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ 00173 float agc_scaling_save; 00174 00175 /*! \brief The current delta factor for updating the equalizer coefficients. */ 00176 float eq_delta; 00177 /*! \brief The adaptive equalizer coefficients. */ 00178 complexf_t eq_coeff[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; 00179 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ 00180 complexf_t eq_coeff_save[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; 00181 /*! \brief The equalizer signal buffer. */ 00182 complexf_t eq_buf[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; 00183 00184 /*! Low band edge filter for symbol sync. */ 00185 float symbol_sync_low[2]; 00186 /*! High band edge filter for symbol sync. */ 00187 float symbol_sync_high[2]; 00188 /*! DC filter for symbol sync. */ 00189 float symbol_sync_dc_filter[2]; 00190 /*! Baud phase for symbol sync. */ 00191 float baud_phase; 00192 #endif 00193 00194 /*! \brief The total symbol timing correction since the carrier came up. 00195 This is only for performance analysis purposes. */ 00196 int total_baud_timing_correction; 00197 00198 /*! \brief Starting phase angles for the coarse carrier aquisition step. */ 00199 int32_t start_angles[2]; 00200 /*! \brief History list of phase angles for the coarse carrier aquisition step. */ 00201 int32_t angles[16]; 00202 /*! \brief A pointer to the current constellation. */ 00203 #if defined(SPANDSP_USE_FIXED_POINTx) 00204 const complexi16_t *constellation; 00205 #else 00206 const complexf_t *constellation; 00207 #endif 00208 /*! \brief A pointer to the current space map. There is a space map for 00209 each trellis state. */ 00210 int space_map; 00211 /*! \brief The number of bits in each symbol at the current bit rate. */ 00212 int bits_per_symbol; 00213 00214 /*! \brief Current pointer to the trellis buffers */ 00215 int trellis_ptr; 00216 /*! \brief The trellis. */ 00217 int full_path_to_past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8]; 00218 /*! \brief The trellis. */ 00219 int past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8]; 00220 /*! \brief Euclidean distances (actually the squares of the distances) 00221 from the last states of the trellis. */ 00222 #if defined(SPANDSP_USE_FIXED_POINTx) 00223 uint32_t distances[8]; 00224 #else 00225 float distances[8]; 00226 #endif 00227 /*! \brief Error and flow logging control */ 00228 logging_state_t logging; 00229 }; 00230 00231 #endif 00232 /*- End of file ------------------------------------------------------------*/