spandsp 3.0.0
private/v17rx.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * private/v17rx.h - ITU V.17 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_V17RX_H_)
27#define _SPANDSP_PRIVATE_V17RX_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 V17_EQUALIZER_LEN 33
33
34/*! Samples before the target position in the equalizer buffer */
35#define V17_EQUALIZER_PRE_LEN 16
36
37/*! The number of taps in the pulse shaping/bandpass filter */
38#define V17_RX_FILTER_STEPS 27
39
40/* We can store more trellis depth that we look back over, so that we can push out a group
41 of symbols in one go, giving greater processing efficiency, at the expense of a bit more
42 latency through the modem. */
43/* Right now we don't take advantage of this optimisation. */
44/*! The depth of the trellis buffer */
45#define V17_TRELLIS_STORAGE_DEPTH 16
46/*! How far we look back into history for trellis decisions */
47#define V17_TRELLIS_LOOKBACK_DEPTH 16
48
49/*!
50 V.17 modem receive side descriptor. This defines the working state for a
51 single instance of a V.17 modem receiver.
52*/
54{
55 /*! \brief The bit rate of the modem. Valid values are 7200 9600, 12000 and 14400. */
57 /*! \brief The callback function used to put each bit received. */
59 /*! \brief A user specified opaque pointer passed to the put_but routine. */
61
62 /*! \brief The callback function used to report modem status changes. */
64 /*! \brief A user specified opaque pointer passed to the status function. */
66
67 /*! \brief A callback function which may be enabled to report every symbol's
68 constellation position. */
69 qam_report_handler_t qam_report;
70 /*! \brief A user specified opaque pointer passed to the qam_report callback
71 routine. */
73
74#if defined(SPANDSP_USE_FIXED_POINTx)
75 /*! \brief The scaling factor assessed by the AGC algorithm. */
76 int16_t agc_scaling;
77 /*! \brief The previous value of agc_scaling, needed to reuse old training. */
78 int16_t agc_scaling_save;
79
80 /*! \brief The current delta factor for updating the equalizer coefficients. */
81 int16_t eq_delta;
82 /*! \brief The adaptive equalizer coefficients. */
83 complexi16_t eq_coeff[V17_EQUALIZER_LEN];
84 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
85 complexi16_t eq_coeff_save[V17_EQUALIZER_LEN];
86 /*! \brief The equalizer signal buffer. */
87 complexi16_t eq_buf[V17_EQUALIZER_LEN];
88
89 /*! \brief A measure of how much mismatch there is between the real constellation,
90 and the decoded symbol positions. */
91 int64_t training_error;
92
93 /*! \brief The proportional part of the carrier tracking filter. */
94 int32_t carrier_track_p;
95 /*! \brief The integral part of the carrier tracking filter. */
96 int32_t carrier_track_i;
97 /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
98 int16_t rrc_filter[V17_RX_FILTER_STEPS];
99
100 /*! \brief A pointer to the current constellation. */
102#else
103 /*! \brief The scaling factor assessed by the AGC algorithm. */
105 /*! \brief The previous value of agc_scaling, needed to reuse old training. */
107
108 /*! \brief The current delta factor for updating the equalizer coefficients. */
109 float eq_delta;
110 /*! \brief The adaptive equalizer coefficients. */
111 complexf_t eq_coeff[V17_EQUALIZER_LEN];
112 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
113 complexf_t eq_coeff_save[V17_EQUALIZER_LEN];
114 /*! \brief The equalizer signal buffer. */
115 complexf_t eq_buf[V17_EQUALIZER_LEN];
116
117 /*! \brief A measure of how much mismatch there is between the real constellation,
118 and the decoded symbol positions. */
120
121 /*! \brief The proportional part of the carrier tracking filter. */
123 /*! \brief The integral part of the carrier tracking filter. */
125 /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
126 float rrc_filter[V17_RX_FILTER_STEPS];
127
128 /*! \brief A pointer to the current constellation. */
130#endif
131 godard_ted_state_t godard;
132
133 /*! \brief Current offset into the RRC pulse shaping filter buffer. */
135
136 /*! \brief The current state of the differential decoder */
137 int diff;
138 /*! \brief The register for the data scrambler. */
139 uint32_t scramble_reg;
140 /*! \brief Scrambler tap */
142
143 /*! \brief True if the short training sequence is to be used. */
145 /*! \brief The section of the training data we are currently in. */
147 /*! \brief A count of how far through the current training step we are. */
149 /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */
150 int16_t last_sample;
151 /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.17 signal. */
153 /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */
155 /*! \brief A count of the current consecutive samples below the carrier off threshold. */
157 /*! \brief A highest magnitude sample seen. */
158 int16_t high_sample;
159
160 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */
162 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */
164 /*! \brief The carrier update rate saved for reuse when using short training. */
166
167 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */
168 power_meter_t power;
169 /*! \brief The power meter level at which carrier on is declared. */
171 /*! \brief The power meter level at which carrier off is declared. */
173
174 /*! \brief Current read offset into the equalizer buffer. */
176 /*! \brief Current write offset into the equalizer buffer. */
178 /*! \brief Symbol count to the next equalizer update. */
180
181 /*! \brief The current half of the baud. */
183
184 /*! \brief The previous symbol phase angles for the coarse carrier aquisition step. */
185 int32_t last_angles[2];
186 /*! \brief History list of phase angle differences for the coarse carrier aquisition step. */
187 int32_t diff_angles[16];
188
189 /*! \brief A pointer to the current space map. There is a space map for
190 each trellis state. */
192 /*! \brief The number of bits in each symbol at the current bit rate. */
194
195 /*! \brief Current pointer to the trellis buffers */
197 /*! \brief The trellis. */
198 int full_path_to_past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8];
199 /*! \brief The trellis. */
200 int past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8];
201#if defined(SPANDSP_USE_FIXED_POINTx)
202 /*! \brief Euclidean distances (actually the squares of the distances)
203 from the last states of the trellis. */
204 uint32_t distances[8];
205#else
206 /*! \brief Euclidean distances (actually the squares of the distances)
207 from the last states of the trellis. */
208 float distances[8];
209#endif
210 /*! \brief Error and flow logging control */
212};
213
214#endif
215/*- End of file ------------------------------------------------------------*/
void(* span_modem_status_func_t)(void *user_data, int status)
Definition async.h:131
void(* span_put_bit_func_t)(void *user_data, int bit)
Definition async.h:123
struct logging_state_s logging_state_t
Definition logging.h:72
Definition complex.h:43
Definition complex.h:89
Definition private/v17rx.h:54
qam_report_handler_t qam_report
A callback function which may be enabled to report every symbol's constellation position.
Definition private/v17rx.h:69
span_put_bit_func_t put_bit
The callback function used to put each bit received.
Definition private/v17rx.h:58
complexf_t eq_coeff_save[33]
A saved set of adaptive equalizer coefficients for use after restarts.
Definition private/v17rx.h:113
int32_t carrier_off_power
The power meter level at which carrier off is declared.
Definition private/v17rx.h:172
int32_t carrier_phase_rate_save
The carrier update rate saved for reuse when using short training.
Definition private/v17rx.h:165
int space_map
A pointer to the current space map. There is a space map for each trellis state.
Definition private/v17rx.h:191
int signal_present
>0 if a signal above the minimum is present. It may or may not be a V.17 signal.
Definition private/v17rx.h:152
int low_samples
A count of the current consecutive samples below the carrier off threshold.
Definition private/v17rx.h:156
float training_error
A measure of how much mismatch there is between the real constellation, and the decoded symbol positi...
Definition private/v17rx.h:119
int eq_put_step
Current write offset into the equalizer buffer.
Definition private/v17rx.h:177
logging_state_t logging
Error and flow logging control.
Definition private/v17rx.h:211
power_meter_t power
A power meter, to measure the HPF'ed signal power in the channel.
Definition private/v17rx.h:168
uint32_t scramble_reg
The register for the data scrambler.
Definition private/v17rx.h:139
int trellis_ptr
Current pointer to the trellis buffers.
Definition private/v17rx.h:196
void * put_bit_user_data
A user specified opaque pointer passed to the put_but routine.
Definition private/v17rx.h:60
int carrier_drop_pending
Whether or not a carrier drop was detected and the signal delivery is pending.
Definition private/v17rx.h:154
uint32_t carrier_phase
The current phase of the carrier (i.e. the DDS parameter).
Definition private/v17rx.h:161
int training_count
A count of how far through the current training step we are.
Definition private/v17rx.h:148
float distances[8]
Euclidean distances (actually the squares of the distances) from the last states of the trellis.
Definition private/v17rx.h:208
int rrc_filter_step
Current offset into the RRC pulse shaping filter buffer.
Definition private/v17rx.h:134
int32_t carrier_phase_rate
The update rate for the phase of the carrier (i.e. the DDS increment).
Definition private/v17rx.h:163
int scrambler_tap
Scrambler tap.
Definition private/v17rx.h:141
float agc_scaling_save
The previous value of agc_scaling, needed to reuse old training.
Definition private/v17rx.h:106
int diff
The current state of the differential decoder.
Definition private/v17rx.h:137
complexf_t eq_coeff[33]
The adaptive equalizer coefficients.
Definition private/v17rx.h:111
int32_t diff_angles[16]
History list of phase angle differences for the coarse carrier aquisition step.
Definition private/v17rx.h:187
int bit_rate
The bit rate of the modem. Valid values are 7200 9600, 12000 and 14400.
Definition private/v17rx.h:56
const complexf_t * constellation
A pointer to the current constellation.
Definition private/v17rx.h:129
float carrier_track_i
The integral part of the carrier tracking filter.
Definition private/v17rx.h:124
int32_t last_angles[2]
The previous symbol phase angles for the coarse carrier aquisition step.
Definition private/v17rx.h:185
int baud_half
The current half of the baud.
Definition private/v17rx.h:182
float carrier_track_p
The proportional part of the carrier tracking filter.
Definition private/v17rx.h:122
int16_t high_sample
A highest magnitude sample seen.
Definition private/v17rx.h:158
int past_state_locations[16][8]
The trellis.
Definition private/v17rx.h:200
float rrc_filter[27]
The root raised cosine (RRC) pulse shaping filter buffer.
Definition private/v17rx.h:126
float agc_scaling
The scaling factor assessed by the AGC algorithm.
Definition private/v17rx.h:104
int eq_step
Current read offset into the equalizer buffer.
Definition private/v17rx.h:175
int32_t carrier_on_power
The power meter level at which carrier on is declared.
Definition private/v17rx.h:170
int full_path_to_past_state_locations[16][8]
The trellis.
Definition private/v17rx.h:198
span_modem_status_func_t status_handler
The callback function used to report modem status changes.
Definition private/v17rx.h:63
void * qam_user_data
A user specified opaque pointer passed to the qam_report callback routine.
Definition private/v17rx.h:72
int eq_skip
Symbol count to the next equalizer update.
Definition private/v17rx.h:179
void * status_user_data
A user specified opaque pointer passed to the status function.
Definition private/v17rx.h:65
int16_t last_sample
The value of the last signal sample, using the a simple HPF for signal power estimation.
Definition private/v17rx.h:150
bool short_train
True if the short training sequence is to be used.
Definition private/v17rx.h:144
int bits_per_symbol
The number of bits in each symbol at the current bit rate.
Definition private/v17rx.h:193
int training_stage
The section of the training data we are currently in.
Definition private/v17rx.h:146
complexf_t eq_buf[33]
The equalizer signal buffer.
Definition private/v17rx.h:115
float eq_delta
The current delta factor for updating the equalizer coefficients.
Definition private/v17rx.h:109