1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for Dummy Frontend
5 * Written by Emard <emard@softhome.net>
8 #include <linux/module.h>
9 #include <linux/init.h>
10 #include <linux/string.h>
11 #include <linux/slab.h>
13 #include <media/dvb_frontend.h>
14 #include "dvb_dummy_fe.h"
17 struct dvb_dummy_fe_state
{
18 struct dvb_frontend frontend
;
22 static int dvb_dummy_fe_read_status(struct dvb_frontend
*fe
,
23 enum fe_status
*status
)
25 *status
= FE_HAS_SIGNAL
34 static int dvb_dummy_fe_read_ber(struct dvb_frontend
*fe
, u32
*ber
)
40 static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend
*fe
,
47 static int dvb_dummy_fe_read_snr(struct dvb_frontend
*fe
, u16
*snr
)
53 static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend
*fe
, u32
*ucblocks
)
60 * Should only be implemented if it actually reads something from the hardware.
61 * Also, it should check for the locks, in order to avoid report wrong data
64 static int dvb_dummy_fe_get_frontend(struct dvb_frontend
*fe
,
65 struct dtv_frontend_properties
*p
)
70 static int dvb_dummy_fe_set_frontend(struct dvb_frontend
*fe
)
72 if (fe
->ops
.tuner_ops
.set_params
) {
73 fe
->ops
.tuner_ops
.set_params(fe
);
74 if (fe
->ops
.i2c_gate_ctrl
)
75 fe
->ops
.i2c_gate_ctrl(fe
, 0);
81 static int dvb_dummy_fe_sleep(struct dvb_frontend
*fe
)
86 static int dvb_dummy_fe_init(struct dvb_frontend
*fe
)
91 static int dvb_dummy_fe_set_tone(struct dvb_frontend
*fe
,
92 enum fe_sec_tone_mode tone
)
97 static int dvb_dummy_fe_set_voltage(struct dvb_frontend
*fe
,
98 enum fe_sec_voltage voltage
)
103 static void dvb_dummy_fe_release(struct dvb_frontend
*fe
)
105 struct dvb_dummy_fe_state
*state
= fe
->demodulator_priv
;
110 static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops
;
112 struct dvb_frontend
*dvb_dummy_fe_ofdm_attach(void)
114 struct dvb_dummy_fe_state
*state
= NULL
;
116 /* allocate memory for the internal state */
117 state
= kzalloc(sizeof(struct dvb_dummy_fe_state
), GFP_KERNEL
);
121 /* create dvb_frontend */
122 memcpy(&state
->frontend
.ops
,
123 &dvb_dummy_fe_ofdm_ops
,
124 sizeof(struct dvb_frontend_ops
));
126 state
->frontend
.demodulator_priv
= state
;
127 return &state
->frontend
;
129 EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach
);
131 static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops
;
133 struct dvb_frontend
*dvb_dummy_fe_qpsk_attach(void)
135 struct dvb_dummy_fe_state
*state
= NULL
;
137 /* allocate memory for the internal state */
138 state
= kzalloc(sizeof(struct dvb_dummy_fe_state
), GFP_KERNEL
);
142 /* create dvb_frontend */
143 memcpy(&state
->frontend
.ops
,
144 &dvb_dummy_fe_qpsk_ops
,
145 sizeof(struct dvb_frontend_ops
));
147 state
->frontend
.demodulator_priv
= state
;
148 return &state
->frontend
;
150 EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach
);
152 static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops
;
154 struct dvb_frontend
*dvb_dummy_fe_qam_attach(void)
156 struct dvb_dummy_fe_state
*state
= NULL
;
158 /* allocate memory for the internal state */
159 state
= kzalloc(sizeof(struct dvb_dummy_fe_state
), GFP_KERNEL
);
163 /* create dvb_frontend */
164 memcpy(&state
->frontend
.ops
,
165 &dvb_dummy_fe_qam_ops
,
166 sizeof(struct dvb_frontend_ops
));
168 state
->frontend
.demodulator_priv
= state
;
169 return &state
->frontend
;
171 EXPORT_SYMBOL(dvb_dummy_fe_qam_attach
);
173 static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops
= {
174 .delsys
= { SYS_DVBT
},
176 .name
= "Dummy DVB-T",
177 .frequency_min_hz
= 0,
178 .frequency_max_hz
= 863250 * kHz
,
179 .frequency_stepsize_hz
= 62500,
180 .caps
= FE_CAN_FEC_1_2
|
192 FE_CAN_TRANSMISSION_MODE_AUTO
|
193 FE_CAN_GUARD_INTERVAL_AUTO
|
194 FE_CAN_HIERARCHY_AUTO
,
197 .release
= dvb_dummy_fe_release
,
199 .init
= dvb_dummy_fe_init
,
200 .sleep
= dvb_dummy_fe_sleep
,
202 .set_frontend
= dvb_dummy_fe_set_frontend
,
203 .get_frontend
= dvb_dummy_fe_get_frontend
,
205 .read_status
= dvb_dummy_fe_read_status
,
206 .read_ber
= dvb_dummy_fe_read_ber
,
207 .read_signal_strength
= dvb_dummy_fe_read_signal_strength
,
208 .read_snr
= dvb_dummy_fe_read_snr
,
209 .read_ucblocks
= dvb_dummy_fe_read_ucblocks
,
212 static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops
= {
213 .delsys
= { SYS_DVBC_ANNEX_A
},
215 .name
= "Dummy DVB-C",
216 .frequency_min_hz
= 51 * MHz
,
217 .frequency_max_hz
= 858 * MHz
,
218 .frequency_stepsize_hz
= 62500,
219 /* symbol_rate_min: SACLK/64 == (XIN/2)/64 */
220 .symbol_rate_min
= (57840000 / 2) / 64,
221 .symbol_rate_max
= (57840000 / 2) / 4, /* SACLK/4 */
222 .caps
= FE_CAN_QAM_16
|
228 FE_CAN_INVERSION_AUTO
231 .release
= dvb_dummy_fe_release
,
233 .init
= dvb_dummy_fe_init
,
234 .sleep
= dvb_dummy_fe_sleep
,
236 .set_frontend
= dvb_dummy_fe_set_frontend
,
237 .get_frontend
= dvb_dummy_fe_get_frontend
,
239 .read_status
= dvb_dummy_fe_read_status
,
240 .read_ber
= dvb_dummy_fe_read_ber
,
241 .read_signal_strength
= dvb_dummy_fe_read_signal_strength
,
242 .read_snr
= dvb_dummy_fe_read_snr
,
243 .read_ucblocks
= dvb_dummy_fe_read_ucblocks
,
246 static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops
= {
247 .delsys
= { SYS_DVBS
},
249 .name
= "Dummy DVB-S",
250 .frequency_min_hz
= 950 * MHz
,
251 .frequency_max_hz
= 2150 * MHz
,
252 .frequency_stepsize_hz
= 250 * kHz
,
253 .frequency_tolerance_hz
= 29500 * kHz
,
254 .symbol_rate_min
= 1000000,
255 .symbol_rate_max
= 45000000,
256 .caps
= FE_CAN_INVERSION_AUTO
|
266 .release
= dvb_dummy_fe_release
,
268 .init
= dvb_dummy_fe_init
,
269 .sleep
= dvb_dummy_fe_sleep
,
271 .set_frontend
= dvb_dummy_fe_set_frontend
,
272 .get_frontend
= dvb_dummy_fe_get_frontend
,
274 .read_status
= dvb_dummy_fe_read_status
,
275 .read_ber
= dvb_dummy_fe_read_ber
,
276 .read_signal_strength
= dvb_dummy_fe_read_signal_strength
,
277 .read_snr
= dvb_dummy_fe_read_snr
,
278 .read_ucblocks
= dvb_dummy_fe_read_ucblocks
,
280 .set_voltage
= dvb_dummy_fe_set_voltage
,
281 .set_tone
= dvb_dummy_fe_set_tone
,
284 MODULE_DESCRIPTION("DVB DUMMY Frontend");
285 MODULE_AUTHOR("Emard");
286 MODULE_LICENSE("GPL");