1 /* 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. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= 20 */ 21 22 #include <linux/module.h> 23 #include <linux/init.h> 24 #include <linux/string.h> 25 #include <linux/slab.h> 26 27 #include "dvb_frontend.h" 28 #include "dvb_dummy_fe.h" 29 30 31 struct dvb_dummy_fe_state { 32 struct dvb_frontend frontend; 33 }; 34 35 36 static int dvb_dummy_fe_read_status(struct dvb_frontend *fe, 37 enum fe_status *status) 38 { 39 *status = FE_HAS_SIGNAL 40 | FE_HAS_CARRIER 41 | FE_HAS_VITERBI 42 | FE_HAS_SYNC 43 | FE_HAS_LOCK; 44 45 return 0; 46 } 47 48 static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber) 49 { 50 *ber = 0; 51 return 0; 52 } 53 54 static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength) 55 { 56 *strength = 0; 57 return 0; 58 } 59 60 static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr) 61 { 62 *snr = 0; 63 return 0; 64 } 65 66 static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 67 { 68 *ucblocks = 0; 69 return 0; 70 } 71 72 /* 73 * Should only be implemented if it actually reads something from the hardware. 74 * Also, it should check for the locks, in order to avoid report wrong data 75 * to userspace. 76 */ 77 static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe, 78 struct dtv_frontend_properties *p) 79 { 80 return 0; 81 } 82 83 static int dvb_dummy_fe_set_frontend(struct dvb_frontend *fe) 84 { 85 if (fe->ops.tuner_ops.set_params) { 86 fe->ops.tuner_ops.set_params(fe); 87 if (fe->ops.i2c_gate_ctrl) 88 fe->ops.i2c_gate_ctrl(fe, 0); 89 } 90 91 return 0; 92 } 93 94 static int dvb_dummy_fe_sleep(struct dvb_frontend* fe) 95 { 96 return 0; 97 } 98 99 static int dvb_dummy_fe_init(struct dvb_frontend* fe) 100 { 101 return 0; 102 } 103 104 static int dvb_dummy_fe_set_tone(struct dvb_frontend *fe, 105 enum fe_sec_tone_mode tone) 106 { 107 return 0; 108 } 109 110 static int dvb_dummy_fe_set_voltage(struct dvb_frontend *fe, 111 enum fe_sec_voltage voltage) 112 { 113 return 0; 114 } 115 116 static void dvb_dummy_fe_release(struct dvb_frontend* fe) 117 { 118 struct dvb_dummy_fe_state* state = fe->demodulator_priv; 119 kfree(state); 120 } 121 122 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops; 123 124 struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void) 125 { 126 struct dvb_dummy_fe_state* state = NULL; 127 128 /* allocate memory for the internal state */ 129 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 130 if (!state) 131 return NULL; 132 133 /* create dvb_frontend */ 134 memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops)); 135 state->frontend.demodulator_priv = state; 136 return &state->frontend; 137 } 138 139 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops; 140 141 struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void) 142 { 143 struct dvb_dummy_fe_state* state = NULL; 144 145 /* allocate memory for the internal state */ 146 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 147 if (!state) 148 return NULL; 149 150 /* create dvb_frontend */ 151 memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops)); 152 state->frontend.demodulator_priv = state; 153 return &state->frontend; 154 } 155 156 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops; 157 158 struct dvb_frontend *dvb_dummy_fe_qam_attach(void) 159 { 160 struct dvb_dummy_fe_state* state = NULL; 161 162 /* allocate memory for the internal state */ 163 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 164 if (!state) 165 return NULL; 166 167 /* create dvb_frontend */ 168 memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops)); 169 state->frontend.demodulator_priv = state; 170 return &state->frontend; 171 } 172 173 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = { 174 .delsys = { SYS_DVBT }, 175 .info = { 176 .name = "Dummy DVB-T", 177 .frequency_min = 0, 178 .frequency_max = 863250000, 179 .frequency_stepsize = 62500, 180 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 181 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | 182 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | 183 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | 184 FE_CAN_TRANSMISSION_MODE_AUTO | 185 FE_CAN_GUARD_INTERVAL_AUTO | 186 FE_CAN_HIERARCHY_AUTO, 187 }, 188 189 .release = dvb_dummy_fe_release, 190 191 .init = dvb_dummy_fe_init, 192 .sleep = dvb_dummy_fe_sleep, 193 194 .set_frontend = dvb_dummy_fe_set_frontend, 195 .get_frontend = dvb_dummy_fe_get_frontend, 196 197 .read_status = dvb_dummy_fe_read_status, 198 .read_ber = dvb_dummy_fe_read_ber, 199 .read_signal_strength = dvb_dummy_fe_read_signal_strength, 200 .read_snr = dvb_dummy_fe_read_snr, 201 .read_ucblocks = dvb_dummy_fe_read_ucblocks, 202 }; 203 204 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = { 205 .delsys = { SYS_DVBC_ANNEX_A }, 206 .info = { 207 .name = "Dummy DVB-C", 208 .frequency_stepsize = 62500, 209 .frequency_min = 51000000, 210 .frequency_max = 858000000, 211 .symbol_rate_min = (57840000/2)/64, /* SACLK/64 == (XIN/2)/64 */ 212 .symbol_rate_max = (57840000/2)/4, /* SACLK/4 */ 213 .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 | 214 FE_CAN_QAM_128 | FE_CAN_QAM_256 | 215 FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO 216 }, 217 218 .release = dvb_dummy_fe_release, 219 220 .init = dvb_dummy_fe_init, 221 .sleep = dvb_dummy_fe_sleep, 222 223 .set_frontend = dvb_dummy_fe_set_frontend, 224 .get_frontend = dvb_dummy_fe_get_frontend, 225 226 .read_status = dvb_dummy_fe_read_status, 227 .read_ber = dvb_dummy_fe_read_ber, 228 .read_signal_strength = dvb_dummy_fe_read_signal_strength, 229 .read_snr = dvb_dummy_fe_read_snr, 230 .read_ucblocks = dvb_dummy_fe_read_ucblocks, 231 }; 232 233 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = { 234 .delsys = { SYS_DVBS }, 235 .info = { 236 .name = "Dummy DVB-S", 237 .frequency_min = 950000, 238 .frequency_max = 2150000, 239 .frequency_stepsize = 250, /* kHz for QPSK frontends */ 240 .frequency_tolerance = 29500, 241 .symbol_rate_min = 1000000, 242 .symbol_rate_max = 45000000, 243 .caps = FE_CAN_INVERSION_AUTO | 244 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 245 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 246 FE_CAN_QPSK 247 }, 248 249 .release = dvb_dummy_fe_release, 250 251 .init = dvb_dummy_fe_init, 252 .sleep = dvb_dummy_fe_sleep, 253 254 .set_frontend = dvb_dummy_fe_set_frontend, 255 .get_frontend = dvb_dummy_fe_get_frontend, 256 257 .read_status = dvb_dummy_fe_read_status, 258 .read_ber = dvb_dummy_fe_read_ber, 259 .read_signal_strength = dvb_dummy_fe_read_signal_strength, 260 .read_snr = dvb_dummy_fe_read_snr, 261 .read_ucblocks = dvb_dummy_fe_read_ucblocks, 262 263 .set_voltage = dvb_dummy_fe_set_voltage, 264 .set_tone = dvb_dummy_fe_set_tone, 265 }; 266 267 MODULE_DESCRIPTION("DVB DUMMY Frontend"); 268 MODULE_AUTHOR("Emard"); 269 MODULE_LICENSE("GPL"); 270 271 EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach); 272 EXPORT_SYMBOL(dvb_dummy_fe_qam_attach); 273 EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach); 274