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