spandsp  0.0.6
private/v29rx.h
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * private/v29rx.h - ITU V.29 modem receive part
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2003 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 2.1,
14  * as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 #if !defined(_SPANDSP_PRIVATE_V29RX_H_)
27 #define _SPANDSP_PRIVATE_V29RX_H_
28 
29 /* Target length for the equalizer is about 63 taps, to deal with the worst stuff
30  in V.56bis. */
31 /*! The length of the equalizer buffer */
32 #define V29_EQUALIZER_LEN 33
33 /*! Samples before the target position in the equalizer buffer */
34 #define V29_EQUALIZER_PRE_LEN 16
35 
36 /*! The number of taps in the pulse shaping/bandpass filter */
37 #define V29_RX_FILTER_STEPS 27
38 
39 /*!
40  V.29 modem receive side descriptor. This defines the working state for a
41  single instance of a V.29 modem receiver.
42 */
44 {
45  /*! \brief The bit rate of the modem. Valid values are 4800, 7200 and 9600. */
46  int bit_rate;
47  /*! \brief The callback function used to put each bit received. */
49  /*! \brief A user specified opaque pointer passed to the put_bit routine. */
51 
52  /*! \brief The callback function used to report modem status changes. */
54  /*! \brief A user specified opaque pointer passed to the status function. */
56 
57  /*! \brief A callback function which may be enabled to report every symbol's
58  constellation position. */
59  qam_report_handler_t qam_report;
60  /*! \brief A user specified opaque pointer passed to the qam_report callback
61  routine. */
63 
64 #if defined(SPANDSP_USE_FIXED_POINT)
65  /*! \brief The scaling factor accessed by the AGC algorithm. */
66  int16_t agc_scaling;
67  /*! \brief The previous value of agc_scaling, needed to reuse old training. */
68  int16_t agc_scaling_save;
69 
70  /*! \brief The current delta factor for updating the equalizer coefficients. */
71  int16_t eq_delta;
72  /*! \brief The adaptive equalizer coefficients. */
73  complexi16_t eq_coeff[V29_EQUALIZER_LEN];
74  /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
75  complexi16_t eq_coeff_save[V29_EQUALIZER_LEN];
76  /*! \brief The equalizer signal buffer. */
77  complexi16_t eq_buf[V29_EQUALIZER_LEN];
78 
79  /*! Low band edge filter for symbol sync. */
80  int32_t symbol_sync_low[2];
81  /*! High band edge filter for symbol sync. */
82  int32_t symbol_sync_high[2];
83  /*! DC filter for symbol sync. */
84  int32_t symbol_sync_dc_filter[2];
85  /*! Baud phase for symbol sync. */
86  int32_t baud_phase;
87 
88  /*! \brief A measure of how much mismatch there is between the real constellation,
89  and the decoded symbol positions. */
90  float training_error;
91 
92  /*! \brief The proportional part of the carrier tracking filter. */
93  int32_t carrier_track_p;
94  /*! \brief The integral part of the carrier tracking filter. */
95  int32_t carrier_track_i;
96  /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
97  int16_t rrc_filter[V29_RX_FILTER_STEPS];
98 #else
99  /*! \brief The scaling factor accessed by the AGC algorithm. */
100  float agc_scaling;
101  /*! \brief The previous value of agc_scaling, needed to reuse old training. */
103 
104  /*! \brief The current delta factor for updating the equalizer coefficients. */
105  float eq_delta;
106  /*! \brief The adaptive equalizer coefficients. */
107  complexf_t eq_coeff[V29_EQUALIZER_LEN];
108  /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
109  complexf_t eq_coeff_save[V29_EQUALIZER_LEN];
110  /*! \brief The equalizer signal buffer. */
111  complexf_t eq_buf[V29_EQUALIZER_LEN];
112 
113  /*! Low band edge filter for symbol sync. */
114  float symbol_sync_low[2];
115  /*! High band edge filter for symbol sync. */
116  float symbol_sync_high[2];
117  /*! DC filter for symbol sync. */
118  float symbol_sync_dc_filter[2];
119  /*! Baud phase for symbol sync. */
120  float baud_phase;
121 
122  /*! \brief A measure of how much mismatch there is between the real constellation,
123  and the decoded symbol positions. */
125 
126  /*! \brief The proportional part of the carrier tracking filter. */
128  /*! \brief The integral part of the carrier tracking filter. */
130  /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
131  float rrc_filter[V29_RX_FILTER_STEPS];
132 #endif
133  /*! \brief Current offset into the RRC pulse shaping filter buffer. */
135 
136  /*! \brief The register for the data scrambler. */
137  uint32_t scramble_reg;
138  /*! \brief The register for the training scrambler. */
140  /*! \brief The current step in the table of CD constellation positions. */
142  /*! \brief TRUE if the previous trained values are to be reused. */
144  /*! \brief The section of the training data we are currently in. */
146  /*! \brief A count of how far through the current training step we are. */
148  /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */
149  int16_t last_sample;
150  /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.29 signal. */
152  /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */
154  /*! \brief A count of the current consecutive samples below the carrier off threshold. */
156  /*! \brief A highest magnitude sample seen. */
157  int16_t high_sample;
158 
159  /*! \brief The current phase of the carrier (i.e. the DDS parameter). */
160  uint32_t carrier_phase;
161  /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */
163  /*! \brief The carrier update rate saved for reuse when using short training. */
165 
166  /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */
168  /*! \brief The power meter level at which carrier on is declared. */
170  /*! \brief The power meter level at which carrier off is declared. */
172 
173  /*! \brief Current read offset into the equalizer buffer. */
174  int eq_step;
175  /*! \brief Current write offset into the equalizer buffer. */
177  /*! \brief Symbol counter to the next equalizer update. */
178  int eq_skip;
179 
180  /*! \brief The current half of the baud. */
182 
183  /*! \brief The total symbol timing correction since the carrier came up.
184  This is only for performance analysis purposes. */
186 
187  /*! \brief Starting phase angles for the coarse carrier aquisition step. */
188  int32_t start_angles[2];
189  /*! \brief History list of phase angles for the coarse carrier aquisition step. */
190  int32_t angles[16];
191 
192  /*! \brief The position of the current symbol in the constellation, used for
193  differential decoding. */
195 
196  /*! \brief Error and flow logging control */
198 };
199 
200 #endif
201 /*- End of file ------------------------------------------------------------*/
int32_t carrier_on_power
The power meter level at which carrier on is declared.
Definition: private/v29rx.h:169
int32_t start_angles[2]
Starting phase angles for the coarse carrier aquisition step.
Definition: private/v29rx.h:188
complexf_t eq_buf[33]
The equalizer signal buffer.
Definition: private/v29rx.h:111
int training_stage
The section of the training data we are currently in.
Definition: private/v29rx.h:145
Definition: complex.h:88
Definition: private/v29rx.h:43
int carrier_drop_pending
Whether or not a carrier drop was detected and the signal delivery is pending.
Definition: private/v29rx.h:153
uint8_t training_scramble_reg
The register for the training scrambler.
Definition: private/v29rx.h:139
int32_t carrier_off_power
The power meter level at which carrier off is declared.
Definition: private/v29rx.h:171
float agc_scaling_save
The previous value of agc_scaling, needed to reuse old training.
Definition: private/v29rx.h:102
int total_baud_timing_correction
The total symbol timing correction since the carrier came up. This is only for performance analysis p...
Definition: private/v29rx.h:185
uint32_t carrier_phase
The current phase of the carrier (i.e. the DDS parameter).
Definition: private/v29rx.h:160
float symbol_sync_low[2]
Definition: private/v29rx.h:114
float carrier_track_p
The proportional part of the carrier tracking filter.
Definition: private/v29rx.h:127
float symbol_sync_high[2]
Definition: private/v29rx.h:116
int constellation_state
The position of the current symbol in the constellation, used for differential decoding.
Definition: private/v29rx.h:194
complexf_t eq_coeff_save[33]
A saved set of adaptive equalizer coefficients for use after restarts.
Definition: private/v29rx.h:109
int eq_step
Current read offset into the equalizer buffer.
Definition: private/v29rx.h:174
int rrc_filter_step
Current offset into the RRC pulse shaping filter buffer.
Definition: private/v29rx.h:134
int training_count
A count of how far through the current training step we are.
Definition: private/v29rx.h:147
int eq_put_step
Current write offset into the equalizer buffer.
Definition: private/v29rx.h:176
void * put_bit_user_data
A user specified opaque pointer passed to the put_bit routine.
Definition: private/v29rx.h:50
int16_t high_sample
A highest magnitude sample seen.
Definition: private/v29rx.h:157
float symbol_sync_dc_filter[2]
Definition: private/v29rx.h:118
void(* put_bit_func_t)(void *user_data, int bit)
Definition: async.h:105
float carrier_track_i
The integral part of the carrier tracking filter.
Definition: private/v29rx.h:129
int eq_skip
Symbol counter to the next equalizer update.
Definition: private/v29rx.h:178
void(* modem_status_func_t)(void *user_data, int status)
Definition: async.h:114
int32_t carrier_phase_rate
The update rate for the phase of the carrier (i.e. the DDS increment).
Definition: private/v29rx.h:162
int32_t angles[16]
History list of phase angles for the coarse carrier aquisition step.
Definition: private/v29rx.h:190
void * qam_user_data
A user specified opaque pointer passed to the qam_report callback routine.
Definition: private/v29rx.h:62
complexf_t eq_coeff[33]
The adaptive equalizer coefficients.
Definition: private/v29rx.h:107
float agc_scaling
The scaling factor accessed by the AGC algorithm.
Definition: private/v29rx.h:100
int training_cd
The current step in the table of CD constellation positions.
Definition: private/v29rx.h:141
int bit_rate
The bit rate of the modem. Valid values are 4800, 7200 and 9600.
Definition: private/v29rx.h:46
Definition: complex.h:42
float rrc_filter[27]
The root raised cosine (RRC) pulse shaping filter buffer.
Definition: private/v29rx.h:131
float training_error
A measure of how much mismatch there is between the real constellation, and the decoded symbol positi...
Definition: private/v29rx.h:124
Definition: private/logging.h:33
int signal_present
>0 if a signal above the minimum is present. It may or may not be a V.29 signal.
Definition: private/v29rx.h:151
int low_samples
A count of the current consecutive samples below the carrier off threshold.
Definition: private/v29rx.h:155
int baud_half
The current half of the baud.
Definition: private/v29rx.h:181
modem_status_func_t status_handler
The callback function used to report modem status changes.
Definition: private/v29rx.h:53
int16_t last_sample
The value of the last signal sample, using the a simple HPF for signal power estimation.
Definition: private/v29rx.h:149
float eq_delta
The current delta factor for updating the equalizer coefficients.
Definition: private/v29rx.h:105
void * status_user_data
A user specified opaque pointer passed to the status function.
Definition: private/v29rx.h:55
put_bit_func_t put_bit
The callback function used to put each bit received.
Definition: private/v29rx.h:48
int old_train
TRUE if the previous trained values are to be reused.
Definition: private/v29rx.h:143
Definition: power_meter.h:48
logging_state_t logging
Error and flow logging control.
Definition: private/v29rx.h:197
float baud_phase
Definition: private/v29rx.h:120
uint32_t scramble_reg
The register for the data scrambler.
Definition: private/v29rx.h:137
qam_report_handler_t qam_report
A callback function which may be enabled to report every symbol&#39;s constellation position.
Definition: private/v29rx.h:59
power_meter_t power
A power meter, to measure the HPF&#39;ed signal power in the channel.
Definition: private/v29rx.h:167
int32_t carrier_phase_rate_save
The carrier update rate saved for reuse when using short training.
Definition: private/v29rx.h:164