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*/
43 struct v29_rx_state_s
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. */
48 put_bit_func_t put_bit;
49 /*! \brief A user specified opaque pointer passed to the put_bit routine. */
50 void *put_bit_user_data;
51
52 /*! \brief The callback function used to report modem status changes. */
53 modem_status_func_t status_handler;
54 /*! \brief A user specified opaque pointer passed to the status function. */
55 void *status_user_data;
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. */
62 void *qam_user_data;
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. */
102 float agc_scaling_save;
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. */
124 float training_error;
125
126 /*! \brief The proportional part of the carrier tracking filter. */
127 float carrier_track_p;
128 /*! \brief The integral part of the carrier tracking filter. */
129 float carrier_track_i;
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. */
134 int rrc_filter_step;
135
136 /*! \brief The register for the data scrambler. */
137 uint32_t scramble_reg;
138 /*! \brief The register for the training scrambler. */
139 uint8_t training_scramble_reg;
140 /*! \brief The current step in the table of CD constellation positions. */
141 int training_cd;
142 /*! \brief TRUE if the previous trained values are to be reused. */
143 int old_train;
144 /*! \brief The section of the training data we are currently in. */
145 int training_stage;
146 /*! \brief A count of how far through the current training step we are. */
147 int training_count;
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. */
151 int signal_present;
152 /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */
153 int carrier_drop_pending;
154 /*! \brief A count of the current consecutive samples below the carrier off threshold. */
155 int low_samples;
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). */
162 int32_t carrier_phase_rate;
163 /*! \brief The carrier update rate saved for reuse when using short training. */
164 int32_t carrier_phase_rate_save;
165
166 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */
167 power_meter_t power;
168 /*! \brief The power meter level at which carrier on is declared. */
169 int32_t carrier_on_power;
170 /*! \brief The power meter level at which carrier off is declared. */
171 int32_t carrier_off_power;
172
173 /*! \brief Current read offset into the equalizer buffer. */
174 int eq_step;
175 /*! \brief Current write offset into the equalizer buffer. */
176 int eq_put_step;
177 /*! \brief Symbol counter to the next equalizer update. */
178 int eq_skip;
179
180 /*! \brief The current half of the baud. */
181 int baud_half;
182
183 /*! \brief The total symbol timing correction since the carrier came up.
184 This is only for performance analysis purposes. */
185 int total_baud_timing_correction;
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. */
194 int constellation_state;
195
196 /*! \brief Error and flow logging control */
197 logging_state_t logging;
198};
199
200#endif
201/*- End of file ------------------------------------------------------------*/
modem_status_func_t
void(* modem_status_func_t)(void *user_data, int status)
Definition async.h:114
put_bit_func_t
void(* put_bit_func_t)(void *user_data, int bit)
Definition async.h:105
logging_state_t
struct logging_state_s logging_state_t
Definition logging.h:75
complexf_t
Definition complex.h:43
complexi16_t
Definition complex.h:89
power_meter_t
Definition power_meter.h:49
v29_rx_state_s
Definition private/v29rx.h:44
v29_rx_state_s::eq_skip
int eq_skip
Symbol counter to the next equalizer update.
Definition private/v29rx.h:178
v29_rx_state_s::carrier_track_p
float carrier_track_p
The proportional part of the carrier tracking filter.
Definition private/v29rx.h:127
v29_rx_state_s::status_handler
modem_status_func_t status_handler
The callback function used to report modem status changes.
Definition private/v29rx.h:53
v29_rx_state_s::carrier_phase
uint32_t carrier_phase
The current phase of the carrier (i.e. the DDS parameter).
Definition private/v29rx.h:160
v29_rx_state_s::status_user_data
void * status_user_data
A user specified opaque pointer passed to the status function.
Definition private/v29rx.h:55
v29_rx_state_s::baud_phase
float baud_phase
Definition private/v29rx.h:120
v29_rx_state_s::carrier_on_power
int32_t carrier_on_power
The power meter level at which carrier on is declared.
Definition private/v29rx.h:169
v29_rx_state_s::eq_delta
float eq_delta
The current delta factor for updating the equalizer coefficients.
Definition private/v29rx.h:105
v29_rx_state_s::baud_half
int baud_half
The current half of the baud.
Definition private/v29rx.h:181
v29_rx_state_s::low_samples
int low_samples
A count of the current consecutive samples below the carrier off threshold.
Definition private/v29rx.h:155
v29_rx_state_s::carrier_track_i
float carrier_track_i
The integral part of the carrier tracking filter.
Definition private/v29rx.h:129
v29_rx_state_s::carrier_off_power
int32_t carrier_off_power
The power meter level at which carrier off is declared.
Definition private/v29rx.h:171
v29_rx_state_s::training_scramble_reg
uint8_t training_scramble_reg
The register for the training scrambler.
Definition private/v29rx.h:139
v29_rx_state_s::put_bit
put_bit_func_t put_bit
The callback function used to put each bit received.
Definition private/v29rx.h:48
v29_rx_state_s::old_train
int old_train
TRUE if the previous trained values are to be reused.
Definition private/v29rx.h:143
v29_rx_state_s::training_count
int training_count
A count of how far through the current training step we are.
Definition private/v29rx.h:147
v29_rx_state_s::eq_coeff
complexf_t eq_coeff[33]
The adaptive equalizer coefficients.
Definition private/v29rx.h:107
v29_rx_state_s::total_baud_timing_correction
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
v29_rx_state_s::carrier_drop_pending
int carrier_drop_pending
Whether or not a carrier drop was detected and the signal delivery is pending.
Definition private/v29rx.h:153
v29_rx_state_s::angles
int32_t angles[16]
History list of phase angles for the coarse carrier aquisition step.
Definition private/v29rx.h:190
v29_rx_state_s::logging
logging_state_t logging
Error and flow logging control.
Definition private/v29rx.h:197
v29_rx_state_s::eq_coeff_save
complexf_t eq_coeff_save[33]
A saved set of adaptive equalizer coefficients for use after restarts.
Definition private/v29rx.h:109
v29_rx_state_s::high_sample
int16_t high_sample
A highest magnitude sample seen.
Definition private/v29rx.h:157
v29_rx_state_s::carrier_phase_rate
int32_t carrier_phase_rate
The update rate for the phase of the carrier (i.e. the DDS increment).
Definition private/v29rx.h:162
v29_rx_state_s::qam_user_data
void * qam_user_data
A user specified opaque pointer passed to the qam_report callback routine.
Definition private/v29rx.h:62
v29_rx_state_s::training_stage
int training_stage
The section of the training data we are currently in.
Definition private/v29rx.h:145
v29_rx_state_s::rrc_filter
float rrc_filter[27]
The root raised cosine (RRC) pulse shaping filter buffer.
Definition private/v29rx.h:131
v29_rx_state_s::scramble_reg
uint32_t scramble_reg
The register for the data scrambler.
Definition private/v29rx.h:137
v29_rx_state_s::bit_rate
int bit_rate
The bit rate of the modem. Valid values are 4800, 7200 and 9600.
Definition private/v29rx.h:46
v29_rx_state_s::constellation_state
int constellation_state
The position of the current symbol in the constellation, used for differential decoding.
Definition private/v29rx.h:194
v29_rx_state_s::rrc_filter_step
int rrc_filter_step
Current offset into the RRC pulse shaping filter buffer.
Definition private/v29rx.h:134
v29_rx_state_s::symbol_sync_low
float symbol_sync_low[2]
Definition private/v29rx.h:114
v29_rx_state_s::qam_report
qam_report_handler_t qam_report
A callback function which may be enabled to report every symbol's constellation position.
Definition private/v29rx.h:59
v29_rx_state_s::eq_step
int eq_step
Current read offset into the equalizer buffer.
Definition private/v29rx.h:174
v29_rx_state_s::power
power_meter_t power
A power meter, to measure the HPF'ed signal power in the channel.
Definition private/v29rx.h:167
v29_rx_state_s::signal_present
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
v29_rx_state_s::start_angles
int32_t start_angles[2]
Starting phase angles for the coarse carrier aquisition step.
Definition private/v29rx.h:188
v29_rx_state_s::last_sample
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
v29_rx_state_s::put_bit_user_data
void * put_bit_user_data
A user specified opaque pointer passed to the put_bit routine.
Definition private/v29rx.h:50
v29_rx_state_s::carrier_phase_rate_save
int32_t carrier_phase_rate_save
The carrier update rate saved for reuse when using short training.
Definition private/v29rx.h:164
v29_rx_state_s::symbol_sync_high
float symbol_sync_high[2]
Definition private/v29rx.h:116
v29_rx_state_s::eq_buf
complexf_t eq_buf[33]
The equalizer signal buffer.
Definition private/v29rx.h:111
v29_rx_state_s::symbol_sync_dc_filter
float symbol_sync_dc_filter[2]
Definition private/v29rx.h:118
v29_rx_state_s::eq_put_step
int eq_put_step
Current write offset into the equalizer buffer.
Definition private/v29rx.h:176
v29_rx_state_s::agc_scaling_save
float agc_scaling_save
The previous value of agc_scaling, needed to reuse old training.
Definition private/v29rx.h:102
v29_rx_state_s::training_cd
int training_cd
The current step in the table of CD constellation positions.
Definition private/v29rx.h:141
v29_rx_state_s::agc_scaling
float agc_scaling
The scaling factor accessed by the AGC algorithm.
Definition private/v29rx.h:100
v29_rx_state_s::training_error
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