blob: a4cbcae7967d6a12963b1102e34297ea373cbc78 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Driver for Dummy Frontend
3 *
4 * Written by Emard <emard@softhome.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
17
18#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/init.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080020#include <linux/string.h>
21#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Mauro Carvalho Chehabfada1932017-12-28 13:03:51 -050023#include <media/dvb_frontend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include "dvb_dummy_fe.h"
25
26
27struct dvb_dummy_fe_state {
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 struct dvb_frontend frontend;
29};
30
31
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -030032static int dvb_dummy_fe_read_status(struct dvb_frontend *fe,
33 enum fe_status *status)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034{
35 *status = FE_HAS_SIGNAL
36 | FE_HAS_CARRIER
37 | FE_HAS_VITERBI
38 | FE_HAS_SYNC
39 | FE_HAS_LOCK;
40
41 return 0;
42}
43
44static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
45{
46 *ber = 0;
47 return 0;
48}
49
50static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
51{
52 *strength = 0;
53 return 0;
54}
55
56static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
57{
58 *snr = 0;
59 return 0;
60}
61
62static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
63{
64 *ucblocks = 0;
65 return 0;
66}
67
Mauro Carvalho Chehab7c61d802011-12-30 11:30:21 -030068/*
Mauro Carvalho Chehab7e3e68b2016-02-04 12:58:30 -020069 * Should only be implemented if it actually reads something from the hardware.
70 * Also, it should check for the locks, in order to avoid report wrong data
71 * to userspace.
Mauro Carvalho Chehab7c61d802011-12-30 11:30:21 -030072 */
Mauro Carvalho Chehab7e3e68b2016-02-04 12:58:30 -020073static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe,
74 struct dtv_frontend_properties *p)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
76 return 0;
77}
78
Mauro Carvalho Chehabd53b5102011-12-26 10:10:42 -030079static int dvb_dummy_fe_set_frontend(struct dvb_frontend *fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080{
Patrick Boettcherbccd7002008-08-30 12:15:54 -030081 if (fe->ops.tuner_ops.set_params) {
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -030082 fe->ops.tuner_ops.set_params(fe);
Patrick Boettcherbccd7002008-08-30 12:15:54 -030083 if (fe->ops.i2c_gate_ctrl)
84 fe->ops.i2c_gate_ctrl(fe, 0);
Andrew de Quincey089e9802006-04-18 17:47:10 -030085 }
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 return 0;
88}
89
90static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
91{
92 return 0;
93}
94
95static int dvb_dummy_fe_init(struct dvb_frontend* fe)
96{
97 return 0;
98}
99
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300100static int dvb_dummy_fe_set_tone(struct dvb_frontend *fe,
101 enum fe_sec_tone_mode tone)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102{
103 return 0;
104}
105
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300106static int dvb_dummy_fe_set_voltage(struct dvb_frontend *fe,
107 enum fe_sec_voltage voltage)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108{
109 return 0;
110}
111
112static void dvb_dummy_fe_release(struct dvb_frontend* fe)
113{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700114 struct dvb_dummy_fe_state* state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 kfree(state);
116}
117
Max Kellermannbd336e62016-08-09 18:32:21 -0300118static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
121{
122 struct dvb_dummy_fe_state* state = NULL;
123
124 /* allocate memory for the internal state */
Matthias Schwarzott084e24a2009-08-10 22:51:01 -0300125 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Peter Senna Tschudin3f037422012-09-12 08:56:04 -0300126 if (!state)
127 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 /* create dvb_frontend */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300130 memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 state->frontend.demodulator_priv = state;
132 return &state->frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133}
134
Max Kellermannbd336e62016-08-09 18:32:21 -0300135static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
Hans Verkuild45b9b82008-09-04 03:33:43 -0300137struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138{
139 struct dvb_dummy_fe_state* state = NULL;
140
141 /* allocate memory for the internal state */
Matthias Schwarzott084e24a2009-08-10 22:51:01 -0300142 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Peter Senna Tschudin3f037422012-09-12 08:56:04 -0300143 if (!state)
144 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 /* create dvb_frontend */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300147 memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 state->frontend.demodulator_priv = state;
149 return &state->frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150}
151
Max Kellermannbd336e62016-08-09 18:32:21 -0300152static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Hans Verkuild45b9b82008-09-04 03:33:43 -0300154struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155{
156 struct dvb_dummy_fe_state* state = NULL;
157
158 /* allocate memory for the internal state */
Matthias Schwarzott084e24a2009-08-10 22:51:01 -0300159 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Peter Senna Tschudin3f037422012-09-12 08:56:04 -0300160 if (!state)
161 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 /* create dvb_frontend */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300164 memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 state->frontend.demodulator_priv = state;
166 return &state->frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167}
168
Max Kellermannbd336e62016-08-09 18:32:21 -0300169static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
Mauro Carvalho Chehabd53b5102011-12-26 10:10:42 -0300170 .delsys = { SYS_DVBT },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 .info = {
172 .name = "Dummy DVB-T",
Mauro Carvalho Chehabf1b1eab2018-07-05 18:59:36 -0400173 .frequency_min_hz = 0,
174 .frequency_max_hz = 863250 * kHz,
175 .frequency_stepsize_hz = 62500,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
177 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
178 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
179 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
180 FE_CAN_TRANSMISSION_MODE_AUTO |
181 FE_CAN_GUARD_INTERVAL_AUTO |
182 FE_CAN_HIERARCHY_AUTO,
183 },
184
185 .release = dvb_dummy_fe_release,
186
187 .init = dvb_dummy_fe_init,
188 .sleep = dvb_dummy_fe_sleep,
189
Mauro Carvalho Chehabd53b5102011-12-26 10:10:42 -0300190 .set_frontend = dvb_dummy_fe_set_frontend,
191 .get_frontend = dvb_dummy_fe_get_frontend,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
193 .read_status = dvb_dummy_fe_read_status,
194 .read_ber = dvb_dummy_fe_read_ber,
195 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
196 .read_snr = dvb_dummy_fe_read_snr,
197 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
198};
199
Max Kellermannbd336e62016-08-09 18:32:21 -0300200static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
Mauro Carvalho Chehabd53b5102011-12-26 10:10:42 -0300201 .delsys = { SYS_DVBC_ANNEX_A },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 .info = {
203 .name = "Dummy DVB-C",
Mauro Carvalho Chehabf1b1eab2018-07-05 18:59:36 -0400204 .frequency_min_hz = 51 * MHz,
205 .frequency_max_hz = 858 * MHz,
206 .frequency_stepsize_hz = 62500,
207 .symbol_rate_min = (57840000 / 2) / 64, /* SACLK/64 == (XIN/2)/64 */
208 .symbol_rate_max = (57840000 / 2) / 4, /* SACLK/4 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
210 FE_CAN_QAM_128 | FE_CAN_QAM_256 |
211 FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
212 },
213
214 .release = dvb_dummy_fe_release,
215
216 .init = dvb_dummy_fe_init,
217 .sleep = dvb_dummy_fe_sleep,
218
Mauro Carvalho Chehabd53b5102011-12-26 10:10:42 -0300219 .set_frontend = dvb_dummy_fe_set_frontend,
220 .get_frontend = dvb_dummy_fe_get_frontend,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222 .read_status = dvb_dummy_fe_read_status,
223 .read_ber = dvb_dummy_fe_read_ber,
224 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
225 .read_snr = dvb_dummy_fe_read_snr,
226 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
227};
228
Max Kellermannbd336e62016-08-09 18:32:21 -0300229static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
Mauro Carvalho Chehabd53b5102011-12-26 10:10:42 -0300230 .delsys = { SYS_DVBS },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 .info = {
232 .name = "Dummy DVB-S",
Mauro Carvalho Chehabf1b1eab2018-07-05 18:59:36 -0400233 .frequency_min_hz = 950 * MHz,
234 .frequency_max_hz = 2150 * MHz,
235 .frequency_stepsize_hz = 250 * kHz,
236 .frequency_tolerance_hz = 29500 * kHz,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 .symbol_rate_min = 1000000,
238 .symbol_rate_max = 45000000,
239 .caps = FE_CAN_INVERSION_AUTO |
240 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
241 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
242 FE_CAN_QPSK
243 },
244
245 .release = dvb_dummy_fe_release,
246
247 .init = dvb_dummy_fe_init,
248 .sleep = dvb_dummy_fe_sleep,
249
Mauro Carvalho Chehabd53b5102011-12-26 10:10:42 -0300250 .set_frontend = dvb_dummy_fe_set_frontend,
251 .get_frontend = dvb_dummy_fe_get_frontend,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
253 .read_status = dvb_dummy_fe_read_status,
254 .read_ber = dvb_dummy_fe_read_ber,
255 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
256 .read_snr = dvb_dummy_fe_read_snr,
257 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
258
259 .set_voltage = dvb_dummy_fe_set_voltage,
260 .set_tone = dvb_dummy_fe_set_tone,
261};
262
263MODULE_DESCRIPTION("DVB DUMMY Frontend");
264MODULE_AUTHOR("Emard");
265MODULE_LICENSE("GPL");
266
267EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
268EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
269EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);