private/v17rx.h

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

Generated on Tue Aug 4 03:36:12 2009 for spandsp by  doxygen 1.5.9