13a137f81SMauro Carvalho Chehab // SPDX-License-Identifier: GPL-2.0-or-later 23a137f81SMauro Carvalho Chehab /* 33a137f81SMauro Carvalho Chehab * Driver for Dummy Frontend 43a137f81SMauro Carvalho Chehab * 53a137f81SMauro Carvalho Chehab * Written by Emard <emard@softhome.net> 63a137f81SMauro Carvalho Chehab */ 73a137f81SMauro Carvalho Chehab 83a137f81SMauro Carvalho Chehab #include <linux/module.h> 93a137f81SMauro Carvalho Chehab #include <linux/init.h> 103a137f81SMauro Carvalho Chehab #include <linux/string.h> 113a137f81SMauro Carvalho Chehab #include <linux/slab.h> 123a137f81SMauro Carvalho Chehab 133a137f81SMauro Carvalho Chehab #include <media/dvb_frontend.h> 14*94ab24a2SMauro Carvalho Chehab #include "ddbridge-dummy-fe.h" 153a137f81SMauro Carvalho Chehab 163a137f81SMauro Carvalho Chehab 17*94ab24a2SMauro Carvalho Chehab struct ddbridge_dummy_fe_state { 183a137f81SMauro Carvalho Chehab struct dvb_frontend frontend; 193a137f81SMauro Carvalho Chehab }; 203a137f81SMauro Carvalho Chehab 213a137f81SMauro Carvalho Chehab 22*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_read_status(struct dvb_frontend *fe, 233a137f81SMauro Carvalho Chehab enum fe_status *status) 243a137f81SMauro Carvalho Chehab { 253a137f81SMauro Carvalho Chehab *status = FE_HAS_SIGNAL 263a137f81SMauro Carvalho Chehab | FE_HAS_CARRIER 273a137f81SMauro Carvalho Chehab | FE_HAS_VITERBI 283a137f81SMauro Carvalho Chehab | FE_HAS_SYNC 293a137f81SMauro Carvalho Chehab | FE_HAS_LOCK; 303a137f81SMauro Carvalho Chehab 313a137f81SMauro Carvalho Chehab return 0; 323a137f81SMauro Carvalho Chehab } 333a137f81SMauro Carvalho Chehab 34*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_read_ber(struct dvb_frontend *fe, u32 *ber) 353a137f81SMauro Carvalho Chehab { 363a137f81SMauro Carvalho Chehab *ber = 0; 373a137f81SMauro Carvalho Chehab return 0; 383a137f81SMauro Carvalho Chehab } 393a137f81SMauro Carvalho Chehab 40*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_read_signal_strength(struct dvb_frontend *fe, 413a137f81SMauro Carvalho Chehab u16 *strength) 423a137f81SMauro Carvalho Chehab { 433a137f81SMauro Carvalho Chehab *strength = 0; 443a137f81SMauro Carvalho Chehab return 0; 453a137f81SMauro Carvalho Chehab } 463a137f81SMauro Carvalho Chehab 47*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_read_snr(struct dvb_frontend *fe, u16 *snr) 483a137f81SMauro Carvalho Chehab { 493a137f81SMauro Carvalho Chehab *snr = 0; 503a137f81SMauro Carvalho Chehab return 0; 513a137f81SMauro Carvalho Chehab } 523a137f81SMauro Carvalho Chehab 53*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 543a137f81SMauro Carvalho Chehab { 553a137f81SMauro Carvalho Chehab *ucblocks = 0; 563a137f81SMauro Carvalho Chehab return 0; 573a137f81SMauro Carvalho Chehab } 583a137f81SMauro Carvalho Chehab 593a137f81SMauro Carvalho Chehab /* 603a137f81SMauro Carvalho Chehab * Should only be implemented if it actually reads something from the hardware. 613a137f81SMauro Carvalho Chehab * Also, it should check for the locks, in order to avoid report wrong data 623a137f81SMauro Carvalho Chehab * to userspace. 633a137f81SMauro Carvalho Chehab */ 64*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_get_frontend(struct dvb_frontend *fe, 653a137f81SMauro Carvalho Chehab struct dtv_frontend_properties *p) 663a137f81SMauro Carvalho Chehab { 673a137f81SMauro Carvalho Chehab return 0; 683a137f81SMauro Carvalho Chehab } 693a137f81SMauro Carvalho Chehab 70*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_set_frontend(struct dvb_frontend *fe) 713a137f81SMauro Carvalho Chehab { 723a137f81SMauro Carvalho Chehab if (fe->ops.tuner_ops.set_params) { 733a137f81SMauro Carvalho Chehab fe->ops.tuner_ops.set_params(fe); 743a137f81SMauro Carvalho Chehab if (fe->ops.i2c_gate_ctrl) 753a137f81SMauro Carvalho Chehab fe->ops.i2c_gate_ctrl(fe, 0); 763a137f81SMauro Carvalho Chehab } 773a137f81SMauro Carvalho Chehab 783a137f81SMauro Carvalho Chehab return 0; 793a137f81SMauro Carvalho Chehab } 803a137f81SMauro Carvalho Chehab 81*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_sleep(struct dvb_frontend *fe) 823a137f81SMauro Carvalho Chehab { 833a137f81SMauro Carvalho Chehab return 0; 843a137f81SMauro Carvalho Chehab } 853a137f81SMauro Carvalho Chehab 86*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_init(struct dvb_frontend *fe) 873a137f81SMauro Carvalho Chehab { 883a137f81SMauro Carvalho Chehab return 0; 893a137f81SMauro Carvalho Chehab } 903a137f81SMauro Carvalho Chehab 91*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_set_tone(struct dvb_frontend *fe, 923a137f81SMauro Carvalho Chehab enum fe_sec_tone_mode tone) 933a137f81SMauro Carvalho Chehab { 943a137f81SMauro Carvalho Chehab return 0; 953a137f81SMauro Carvalho Chehab } 963a137f81SMauro Carvalho Chehab 97*94ab24a2SMauro Carvalho Chehab static int ddbridge_dummy_fe_set_voltage(struct dvb_frontend *fe, 983a137f81SMauro Carvalho Chehab enum fe_sec_voltage voltage) 993a137f81SMauro Carvalho Chehab { 1003a137f81SMauro Carvalho Chehab return 0; 1013a137f81SMauro Carvalho Chehab } 1023a137f81SMauro Carvalho Chehab 103*94ab24a2SMauro Carvalho Chehab static void ddbridge_dummy_fe_release(struct dvb_frontend *fe) 1043a137f81SMauro Carvalho Chehab { 105*94ab24a2SMauro Carvalho Chehab struct ddbridge_dummy_fe_state *state = fe->demodulator_priv; 1063a137f81SMauro Carvalho Chehab 1073a137f81SMauro Carvalho Chehab kfree(state); 1083a137f81SMauro Carvalho Chehab } 1093a137f81SMauro Carvalho Chehab 110*94ab24a2SMauro Carvalho Chehab static const struct dvb_frontend_ops ddbridge_dummy_fe_ofdm_ops; 1113a137f81SMauro Carvalho Chehab 112*94ab24a2SMauro Carvalho Chehab struct dvb_frontend *ddbridge_dummy_fe_ofdm_attach(void) 1133a137f81SMauro Carvalho Chehab { 114*94ab24a2SMauro Carvalho Chehab struct ddbridge_dummy_fe_state *state = NULL; 1153a137f81SMauro Carvalho Chehab 1163a137f81SMauro Carvalho Chehab /* allocate memory for the internal state */ 117*94ab24a2SMauro Carvalho Chehab state = kzalloc(sizeof(struct ddbridge_dummy_fe_state), GFP_KERNEL); 1183a137f81SMauro Carvalho Chehab if (!state) 1193a137f81SMauro Carvalho Chehab return NULL; 1203a137f81SMauro Carvalho Chehab 1213a137f81SMauro Carvalho Chehab /* create dvb_frontend */ 1223a137f81SMauro Carvalho Chehab memcpy(&state->frontend.ops, 123*94ab24a2SMauro Carvalho Chehab &ddbridge_dummy_fe_ofdm_ops, 1243a137f81SMauro Carvalho Chehab sizeof(struct dvb_frontend_ops)); 1253a137f81SMauro Carvalho Chehab 1263a137f81SMauro Carvalho Chehab state->frontend.demodulator_priv = state; 1273a137f81SMauro Carvalho Chehab return &state->frontend; 1283a137f81SMauro Carvalho Chehab } 129*94ab24a2SMauro Carvalho Chehab EXPORT_SYMBOL(ddbridge_dummy_fe_ofdm_attach); 1303a137f81SMauro Carvalho Chehab 131*94ab24a2SMauro Carvalho Chehab static const struct dvb_frontend_ops ddbridge_dummy_fe_qpsk_ops; 1323a137f81SMauro Carvalho Chehab 133*94ab24a2SMauro Carvalho Chehab struct dvb_frontend *ddbridge_dummy_fe_qpsk_attach(void) 1343a137f81SMauro Carvalho Chehab { 135*94ab24a2SMauro Carvalho Chehab struct ddbridge_dummy_fe_state *state = NULL; 1363a137f81SMauro Carvalho Chehab 1373a137f81SMauro Carvalho Chehab /* allocate memory for the internal state */ 138*94ab24a2SMauro Carvalho Chehab state = kzalloc(sizeof(struct ddbridge_dummy_fe_state), GFP_KERNEL); 1393a137f81SMauro Carvalho Chehab if (!state) 1403a137f81SMauro Carvalho Chehab return NULL; 1413a137f81SMauro Carvalho Chehab 1423a137f81SMauro Carvalho Chehab /* create dvb_frontend */ 1433a137f81SMauro Carvalho Chehab memcpy(&state->frontend.ops, 144*94ab24a2SMauro Carvalho Chehab &ddbridge_dummy_fe_qpsk_ops, 1453a137f81SMauro Carvalho Chehab sizeof(struct dvb_frontend_ops)); 1463a137f81SMauro Carvalho Chehab 1473a137f81SMauro Carvalho Chehab state->frontend.demodulator_priv = state; 1483a137f81SMauro Carvalho Chehab return &state->frontend; 1493a137f81SMauro Carvalho Chehab } 150*94ab24a2SMauro Carvalho Chehab EXPORT_SYMBOL(ddbridge_dummy_fe_qpsk_attach); 1513a137f81SMauro Carvalho Chehab 152*94ab24a2SMauro Carvalho Chehab static const struct dvb_frontend_ops ddbridge_dummy_fe_qam_ops; 1533a137f81SMauro Carvalho Chehab 154*94ab24a2SMauro Carvalho Chehab struct dvb_frontend *ddbridge_dummy_fe_qam_attach(void) 1553a137f81SMauro Carvalho Chehab { 156*94ab24a2SMauro Carvalho Chehab struct ddbridge_dummy_fe_state *state = NULL; 1573a137f81SMauro Carvalho Chehab 1583a137f81SMauro Carvalho Chehab /* allocate memory for the internal state */ 159*94ab24a2SMauro Carvalho Chehab state = kzalloc(sizeof(struct ddbridge_dummy_fe_state), GFP_KERNEL); 1603a137f81SMauro Carvalho Chehab if (!state) 1613a137f81SMauro Carvalho Chehab return NULL; 1623a137f81SMauro Carvalho Chehab 1633a137f81SMauro Carvalho Chehab /* create dvb_frontend */ 1643a137f81SMauro Carvalho Chehab memcpy(&state->frontend.ops, 165*94ab24a2SMauro Carvalho Chehab &ddbridge_dummy_fe_qam_ops, 1663a137f81SMauro Carvalho Chehab sizeof(struct dvb_frontend_ops)); 1673a137f81SMauro Carvalho Chehab 1683a137f81SMauro Carvalho Chehab state->frontend.demodulator_priv = state; 1693a137f81SMauro Carvalho Chehab return &state->frontend; 1703a137f81SMauro Carvalho Chehab } 171*94ab24a2SMauro Carvalho Chehab EXPORT_SYMBOL(ddbridge_dummy_fe_qam_attach); 1723a137f81SMauro Carvalho Chehab 173*94ab24a2SMauro Carvalho Chehab static const struct dvb_frontend_ops ddbridge_dummy_fe_ofdm_ops = { 1743a137f81SMauro Carvalho Chehab .delsys = { SYS_DVBT }, 1753a137f81SMauro Carvalho Chehab .info = { 176*94ab24a2SMauro Carvalho Chehab .name = "ddbridge dummy DVB-T", 1773a137f81SMauro Carvalho Chehab .frequency_min_hz = 0, 1783a137f81SMauro Carvalho Chehab .frequency_max_hz = 863250 * kHz, 1793a137f81SMauro Carvalho Chehab .frequency_stepsize_hz = 62500, 1803a137f81SMauro Carvalho Chehab .caps = FE_CAN_FEC_1_2 | 1813a137f81SMauro Carvalho Chehab FE_CAN_FEC_2_3 | 1823a137f81SMauro Carvalho Chehab FE_CAN_FEC_3_4 | 1833a137f81SMauro Carvalho Chehab FE_CAN_FEC_4_5 | 1843a137f81SMauro Carvalho Chehab FE_CAN_FEC_5_6 | 1853a137f81SMauro Carvalho Chehab FE_CAN_FEC_6_7 | 1863a137f81SMauro Carvalho Chehab FE_CAN_FEC_7_8 | 1873a137f81SMauro Carvalho Chehab FE_CAN_FEC_8_9 | 1883a137f81SMauro Carvalho Chehab FE_CAN_FEC_AUTO | 1893a137f81SMauro Carvalho Chehab FE_CAN_QAM_16 | 1903a137f81SMauro Carvalho Chehab FE_CAN_QAM_64 | 1913a137f81SMauro Carvalho Chehab FE_CAN_QAM_AUTO | 1923a137f81SMauro Carvalho Chehab FE_CAN_TRANSMISSION_MODE_AUTO | 1933a137f81SMauro Carvalho Chehab FE_CAN_GUARD_INTERVAL_AUTO | 1943a137f81SMauro Carvalho Chehab FE_CAN_HIERARCHY_AUTO, 1953a137f81SMauro Carvalho Chehab }, 1963a137f81SMauro Carvalho Chehab 197*94ab24a2SMauro Carvalho Chehab .release = ddbridge_dummy_fe_release, 1983a137f81SMauro Carvalho Chehab 199*94ab24a2SMauro Carvalho Chehab .init = ddbridge_dummy_fe_init, 200*94ab24a2SMauro Carvalho Chehab .sleep = ddbridge_dummy_fe_sleep, 2013a137f81SMauro Carvalho Chehab 202*94ab24a2SMauro Carvalho Chehab .set_frontend = ddbridge_dummy_fe_set_frontend, 203*94ab24a2SMauro Carvalho Chehab .get_frontend = ddbridge_dummy_fe_get_frontend, 2043a137f81SMauro Carvalho Chehab 205*94ab24a2SMauro Carvalho Chehab .read_status = ddbridge_dummy_fe_read_status, 206*94ab24a2SMauro Carvalho Chehab .read_ber = ddbridge_dummy_fe_read_ber, 207*94ab24a2SMauro Carvalho Chehab .read_signal_strength = ddbridge_dummy_fe_read_signal_strength, 208*94ab24a2SMauro Carvalho Chehab .read_snr = ddbridge_dummy_fe_read_snr, 209*94ab24a2SMauro Carvalho Chehab .read_ucblocks = ddbridge_dummy_fe_read_ucblocks, 2103a137f81SMauro Carvalho Chehab }; 2113a137f81SMauro Carvalho Chehab 212*94ab24a2SMauro Carvalho Chehab static const struct dvb_frontend_ops ddbridge_dummy_fe_qam_ops = { 2133a137f81SMauro Carvalho Chehab .delsys = { SYS_DVBC_ANNEX_A }, 2143a137f81SMauro Carvalho Chehab .info = { 215*94ab24a2SMauro Carvalho Chehab .name = "ddbridge dummy DVB-C", 2163a137f81SMauro Carvalho Chehab .frequency_min_hz = 51 * MHz, 2173a137f81SMauro Carvalho Chehab .frequency_max_hz = 858 * MHz, 2183a137f81SMauro Carvalho Chehab .frequency_stepsize_hz = 62500, 2193a137f81SMauro Carvalho Chehab /* symbol_rate_min: SACLK/64 == (XIN/2)/64 */ 2203a137f81SMauro Carvalho Chehab .symbol_rate_min = (57840000 / 2) / 64, 2213a137f81SMauro Carvalho Chehab .symbol_rate_max = (57840000 / 2) / 4, /* SACLK/4 */ 2223a137f81SMauro Carvalho Chehab .caps = FE_CAN_QAM_16 | 2233a137f81SMauro Carvalho Chehab FE_CAN_QAM_32 | 2243a137f81SMauro Carvalho Chehab FE_CAN_QAM_64 | 2253a137f81SMauro Carvalho Chehab FE_CAN_QAM_128 | 2263a137f81SMauro Carvalho Chehab FE_CAN_QAM_256 | 2273a137f81SMauro Carvalho Chehab FE_CAN_FEC_AUTO | 2283a137f81SMauro Carvalho Chehab FE_CAN_INVERSION_AUTO 2293a137f81SMauro Carvalho Chehab }, 2303a137f81SMauro Carvalho Chehab 231*94ab24a2SMauro Carvalho Chehab .release = ddbridge_dummy_fe_release, 2323a137f81SMauro Carvalho Chehab 233*94ab24a2SMauro Carvalho Chehab .init = ddbridge_dummy_fe_init, 234*94ab24a2SMauro Carvalho Chehab .sleep = ddbridge_dummy_fe_sleep, 2353a137f81SMauro Carvalho Chehab 236*94ab24a2SMauro Carvalho Chehab .set_frontend = ddbridge_dummy_fe_set_frontend, 237*94ab24a2SMauro Carvalho Chehab .get_frontend = ddbridge_dummy_fe_get_frontend, 2383a137f81SMauro Carvalho Chehab 239*94ab24a2SMauro Carvalho Chehab .read_status = ddbridge_dummy_fe_read_status, 240*94ab24a2SMauro Carvalho Chehab .read_ber = ddbridge_dummy_fe_read_ber, 241*94ab24a2SMauro Carvalho Chehab .read_signal_strength = ddbridge_dummy_fe_read_signal_strength, 242*94ab24a2SMauro Carvalho Chehab .read_snr = ddbridge_dummy_fe_read_snr, 243*94ab24a2SMauro Carvalho Chehab .read_ucblocks = ddbridge_dummy_fe_read_ucblocks, 2443a137f81SMauro Carvalho Chehab }; 2453a137f81SMauro Carvalho Chehab 246*94ab24a2SMauro Carvalho Chehab static const struct dvb_frontend_ops ddbridge_dummy_fe_qpsk_ops = { 2473a137f81SMauro Carvalho Chehab .delsys = { SYS_DVBS }, 2483a137f81SMauro Carvalho Chehab .info = { 249*94ab24a2SMauro Carvalho Chehab .name = "ddbridge dummy DVB-S", 2503a137f81SMauro Carvalho Chehab .frequency_min_hz = 950 * MHz, 2513a137f81SMauro Carvalho Chehab .frequency_max_hz = 2150 * MHz, 2523a137f81SMauro Carvalho Chehab .frequency_stepsize_hz = 250 * kHz, 2533a137f81SMauro Carvalho Chehab .frequency_tolerance_hz = 29500 * kHz, 2543a137f81SMauro Carvalho Chehab .symbol_rate_min = 1000000, 2553a137f81SMauro Carvalho Chehab .symbol_rate_max = 45000000, 2563a137f81SMauro Carvalho Chehab .caps = FE_CAN_INVERSION_AUTO | 2573a137f81SMauro Carvalho Chehab FE_CAN_FEC_1_2 | 2583a137f81SMauro Carvalho Chehab FE_CAN_FEC_2_3 | 2593a137f81SMauro Carvalho Chehab FE_CAN_FEC_3_4 | 2603a137f81SMauro Carvalho Chehab FE_CAN_FEC_5_6 | 2613a137f81SMauro Carvalho Chehab FE_CAN_FEC_7_8 | 2623a137f81SMauro Carvalho Chehab FE_CAN_FEC_AUTO | 2633a137f81SMauro Carvalho Chehab FE_CAN_QPSK 2643a137f81SMauro Carvalho Chehab }, 2653a137f81SMauro Carvalho Chehab 266*94ab24a2SMauro Carvalho Chehab .release = ddbridge_dummy_fe_release, 2673a137f81SMauro Carvalho Chehab 268*94ab24a2SMauro Carvalho Chehab .init = ddbridge_dummy_fe_init, 269*94ab24a2SMauro Carvalho Chehab .sleep = ddbridge_dummy_fe_sleep, 2703a137f81SMauro Carvalho Chehab 271*94ab24a2SMauro Carvalho Chehab .set_frontend = ddbridge_dummy_fe_set_frontend, 272*94ab24a2SMauro Carvalho Chehab .get_frontend = ddbridge_dummy_fe_get_frontend, 2733a137f81SMauro Carvalho Chehab 274*94ab24a2SMauro Carvalho Chehab .read_status = ddbridge_dummy_fe_read_status, 275*94ab24a2SMauro Carvalho Chehab .read_ber = ddbridge_dummy_fe_read_ber, 276*94ab24a2SMauro Carvalho Chehab .read_signal_strength = ddbridge_dummy_fe_read_signal_strength, 277*94ab24a2SMauro Carvalho Chehab .read_snr = ddbridge_dummy_fe_read_snr, 278*94ab24a2SMauro Carvalho Chehab .read_ucblocks = ddbridge_dummy_fe_read_ucblocks, 2793a137f81SMauro Carvalho Chehab 280*94ab24a2SMauro Carvalho Chehab .set_voltage = ddbridge_dummy_fe_set_voltage, 281*94ab24a2SMauro Carvalho Chehab .set_tone = ddbridge_dummy_fe_set_tone, 2823a137f81SMauro Carvalho Chehab }; 2833a137f81SMauro Carvalho Chehab 284*94ab24a2SMauro Carvalho Chehab MODULE_DESCRIPTION("ddbridge dummy Frontend"); 2853a137f81SMauro Carvalho Chehab MODULE_AUTHOR("Emard"); 2863a137f81SMauro Carvalho Chehab MODULE_LICENSE("GPL"); 287