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 "ddbridge-dummy-fe.h"
16 struct ddbridge_dummy_fe_state {
17 struct dvb_frontend frontend;
20 static int ddbridge_dummy_fe_read_status(struct dvb_frontend *fe,
21 enum fe_status *status)
23 *status = FE_HAS_SIGNAL
32 static int ddbridge_dummy_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
38 static int ddbridge_dummy_fe_read_signal_strength(struct dvb_frontend *fe,
45 static int ddbridge_dummy_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
51 static int ddbridge_dummy_fe_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
58 * Should only be implemented if it actually reads something from the hardware.
59 * Also, it should check for the locks, in order to avoid report wrong data
62 static int ddbridge_dummy_fe_get_frontend(struct dvb_frontend *fe,
63 struct dtv_frontend_properties *p)
68 static int ddbridge_dummy_fe_set_frontend(struct dvb_frontend *fe)
70 if (fe->ops.tuner_ops.set_params) {
71 fe->ops.tuner_ops.set_params(fe);
72 if (fe->ops.i2c_gate_ctrl)
73 fe->ops.i2c_gate_ctrl(fe, 0);
79 static int ddbridge_dummy_fe_sleep(struct dvb_frontend *fe)
84 static int ddbridge_dummy_fe_init(struct dvb_frontend *fe)
89 static void ddbridge_dummy_fe_release(struct dvb_frontend *fe)
91 struct ddbridge_dummy_fe_state *state = fe->demodulator_priv;
96 static const struct dvb_frontend_ops ddbridge_dummy_fe_qam_ops;
98 struct dvb_frontend *ddbridge_dummy_fe_qam_attach(void)
100 struct ddbridge_dummy_fe_state *state = NULL;
102 /* allocate memory for the internal state */
103 state = kzalloc(sizeof(struct ddbridge_dummy_fe_state), GFP_KERNEL);
107 /* create dvb_frontend */
108 memcpy(&state->frontend.ops,
109 &ddbridge_dummy_fe_qam_ops,
110 sizeof(struct dvb_frontend_ops));
112 state->frontend.demodulator_priv = state;
113 return &state->frontend;
115 EXPORT_SYMBOL_GPL(ddbridge_dummy_fe_qam_attach);
117 static const struct dvb_frontend_ops ddbridge_dummy_fe_qam_ops = {
118 .delsys = { SYS_DVBC_ANNEX_A },
120 .name = "ddbridge dummy DVB-C",
121 .frequency_min_hz = 51 * MHz,
122 .frequency_max_hz = 858 * MHz,
123 .frequency_stepsize_hz = 62500,
124 /* symbol_rate_min: SACLK/64 == (XIN/2)/64 */
125 .symbol_rate_min = (57840000 / 2) / 64,
126 .symbol_rate_max = (57840000 / 2) / 4, /* SACLK/4 */
127 .caps = FE_CAN_QAM_16 |
133 FE_CAN_INVERSION_AUTO
136 .release = ddbridge_dummy_fe_release,
138 .init = ddbridge_dummy_fe_init,
139 .sleep = ddbridge_dummy_fe_sleep,
141 .set_frontend = ddbridge_dummy_fe_set_frontend,
142 .get_frontend = ddbridge_dummy_fe_get_frontend,
144 .read_status = ddbridge_dummy_fe_read_status,
145 .read_ber = ddbridge_dummy_fe_read_ber,
146 .read_signal_strength = ddbridge_dummy_fe_read_signal_strength,
147 .read_snr = ddbridge_dummy_fe_read_snr,
148 .read_ucblocks = ddbridge_dummy_fe_read_ucblocks,
151 MODULE_DESCRIPTION("ddbridge dummy Frontend");
152 MODULE_AUTHOR("Emard");
153 MODULE_LICENSE("GPL");