Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / media / dvb-frontends / dvb_dummy_fe.c
blob9ff1ebaa5e044acb1ad2fa00eb7cab845e3bace5
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Driver for Dummy Frontend
5 * Written by Emard <emard@softhome.net>
6 */
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
26 | FE_HAS_CARRIER
27 | FE_HAS_VITERBI
28 | FE_HAS_SYNC
29 | FE_HAS_LOCK;
31 return 0;
34 static int dvb_dummy_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
36 *ber = 0;
37 return 0;
40 static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend *fe,
41 u16 *strength)
43 *strength = 0;
44 return 0;
47 static int dvb_dummy_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
49 *snr = 0;
50 return 0;
53 static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
55 *ucblocks = 0;
56 return 0;
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
62 * to userspace.
64 static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe,
65 struct dtv_frontend_properties *p)
67 return 0;
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);
78 return 0;
81 static int dvb_dummy_fe_sleep(struct dvb_frontend *fe)
83 return 0;
86 static int dvb_dummy_fe_init(struct dvb_frontend *fe)
88 return 0;
91 static int dvb_dummy_fe_set_tone(struct dvb_frontend *fe,
92 enum fe_sec_tone_mode tone)
94 return 0;
97 static int dvb_dummy_fe_set_voltage(struct dvb_frontend *fe,
98 enum fe_sec_voltage voltage)
100 return 0;
103 static void dvb_dummy_fe_release(struct dvb_frontend *fe)
105 struct dvb_dummy_fe_state *state = fe->demodulator_priv;
107 kfree(state);
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);
118 if (!state)
119 return NULL;
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);
139 if (!state)
140 return NULL;
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);
160 if (!state)
161 return NULL;
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 },
175 .info = {
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 |
181 FE_CAN_FEC_2_3 |
182 FE_CAN_FEC_3_4 |
183 FE_CAN_FEC_4_5 |
184 FE_CAN_FEC_5_6 |
185 FE_CAN_FEC_6_7 |
186 FE_CAN_FEC_7_8 |
187 FE_CAN_FEC_8_9 |
188 FE_CAN_FEC_AUTO |
189 FE_CAN_QAM_16 |
190 FE_CAN_QAM_64 |
191 FE_CAN_QAM_AUTO |
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 },
214 .info = {
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 |
223 FE_CAN_QAM_32 |
224 FE_CAN_QAM_64 |
225 FE_CAN_QAM_128 |
226 FE_CAN_QAM_256 |
227 FE_CAN_FEC_AUTO |
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 },
248 .info = {
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 |
257 FE_CAN_FEC_1_2 |
258 FE_CAN_FEC_2_3 |
259 FE_CAN_FEC_3_4 |
260 FE_CAN_FEC_5_6 |
261 FE_CAN_FEC_7_8 |
262 FE_CAN_FEC_AUTO |
263 FE_CAN_QPSK
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");