Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/init.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 24 | #include <linux/string.h> |
| 25 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | #include "dvb_frontend.h" |
| 28 | #include "dvb_dummy_fe.h" |
| 29 | |
| 30 | |
| 31 | struct dvb_dummy_fe_state { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Mauro Carvalho Chehab | d53b510 | 2011-12-26 10:10:42 -0300 | [diff] [blame^] | 71 | static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe, |
| 72 | struct dtv_frontend_properties *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | { |
| 74 | return 0; |
| 75 | } |
| 76 | |
Mauro Carvalho Chehab | d53b510 | 2011-12-26 10:10:42 -0300 | [diff] [blame^] | 77 | static int dvb_dummy_fe_set_frontend(struct dvb_frontend *fe) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | { |
Patrick Boettcher | bccd700 | 2008-08-30 12:15:54 -0300 | [diff] [blame] | 79 | if (fe->ops.tuner_ops.set_params) { |
Mauro Carvalho Chehab | 14d24d1 | 2011-12-24 12:24:33 -0300 | [diff] [blame] | 80 | fe->ops.tuner_ops.set_params(fe); |
Patrick Boettcher | bccd700 | 2008-08-30 12:15:54 -0300 | [diff] [blame] | 81 | if (fe->ops.i2c_gate_ctrl) |
| 82 | fe->ops.i2c_gate_ctrl(fe, 0); |
Andrew de Quincey | 089e980 | 2006-04-18 17:47:10 -0300 | [diff] [blame] | 83 | } |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | static int dvb_dummy_fe_sleep(struct dvb_frontend* fe) |
| 89 | { |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | static int dvb_dummy_fe_init(struct dvb_frontend* fe) |
| 94 | { |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) |
| 99 | { |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) |
| 104 | { |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | static void dvb_dummy_fe_release(struct dvb_frontend* fe) |
| 109 | { |
Johannes Stezenbach | b874270 | 2005-05-16 21:54:31 -0700 | [diff] [blame] | 110 | struct dvb_dummy_fe_state* state = fe->demodulator_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | kfree(state); |
| 112 | } |
| 113 | |
| 114 | static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops; |
| 115 | |
| 116 | struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void) |
| 117 | { |
| 118 | struct dvb_dummy_fe_state* state = NULL; |
| 119 | |
| 120 | /* allocate memory for the internal state */ |
Matthias Schwarzott | 084e24a | 2009-08-10 22:51:01 -0300 | [diff] [blame] | 121 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | if (state == NULL) goto error; |
| 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | /* create dvb_frontend */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 125 | memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | state->frontend.demodulator_priv = state; |
| 127 | return &state->frontend; |
| 128 | |
| 129 | error: |
| 130 | kfree(state); |
| 131 | return NULL; |
| 132 | } |
| 133 | |
| 134 | static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops; |
| 135 | |
Hans Verkuil | d45b9b8 | 2008-09-04 03:33:43 -0300 | [diff] [blame] | 136 | struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
| 138 | struct dvb_dummy_fe_state* state = NULL; |
| 139 | |
| 140 | /* allocate memory for the internal state */ |
Matthias Schwarzott | 084e24a | 2009-08-10 22:51:01 -0300 | [diff] [blame] | 141 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | if (state == NULL) goto error; |
| 143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | /* create dvb_frontend */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 145 | memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | state->frontend.demodulator_priv = state; |
| 147 | return &state->frontend; |
| 148 | |
| 149 | error: |
Jesper Juhl | 2ea7533 | 2005-11-07 01:01:31 -0800 | [diff] [blame] | 150 | kfree(state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | return NULL; |
| 152 | } |
| 153 | |
| 154 | static struct dvb_frontend_ops dvb_dummy_fe_qam_ops; |
| 155 | |
Hans Verkuil | d45b9b8 | 2008-09-04 03:33:43 -0300 | [diff] [blame] | 156 | struct dvb_frontend *dvb_dummy_fe_qam_attach(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
| 158 | struct dvb_dummy_fe_state* state = NULL; |
| 159 | |
| 160 | /* allocate memory for the internal state */ |
Matthias Schwarzott | 084e24a | 2009-08-10 22:51:01 -0300 | [diff] [blame] | 161 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | if (state == NULL) goto error; |
| 163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | /* create dvb_frontend */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 165 | memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | state->frontend.demodulator_priv = state; |
| 167 | return &state->frontend; |
| 168 | |
| 169 | error: |
Jesper Juhl | 2ea7533 | 2005-11-07 01:01:31 -0800 | [diff] [blame] | 170 | kfree(state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | return NULL; |
| 172 | } |
| 173 | |
| 174 | static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = { |
Mauro Carvalho Chehab | d53b510 | 2011-12-26 10:10:42 -0300 | [diff] [blame^] | 175 | .delsys = { SYS_DVBT }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | .info = { |
| 177 | .name = "Dummy DVB-T", |
| 178 | .type = FE_OFDM, |
| 179 | .frequency_min = 0, |
| 180 | .frequency_max = 863250000, |
| 181 | .frequency_stepsize = 62500, |
| 182 | .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | |
| 183 | FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | |
| 184 | FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | |
| 185 | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | |
| 186 | FE_CAN_TRANSMISSION_MODE_AUTO | |
| 187 | FE_CAN_GUARD_INTERVAL_AUTO | |
| 188 | FE_CAN_HIERARCHY_AUTO, |
| 189 | }, |
| 190 | |
| 191 | .release = dvb_dummy_fe_release, |
| 192 | |
| 193 | .init = dvb_dummy_fe_init, |
| 194 | .sleep = dvb_dummy_fe_sleep, |
| 195 | |
Mauro Carvalho Chehab | d53b510 | 2011-12-26 10:10:42 -0300 | [diff] [blame^] | 196 | .set_frontend = dvb_dummy_fe_set_frontend, |
| 197 | .get_frontend = dvb_dummy_fe_get_frontend, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
| 199 | .read_status = dvb_dummy_fe_read_status, |
| 200 | .read_ber = dvb_dummy_fe_read_ber, |
| 201 | .read_signal_strength = dvb_dummy_fe_read_signal_strength, |
| 202 | .read_snr = dvb_dummy_fe_read_snr, |
| 203 | .read_ucblocks = dvb_dummy_fe_read_ucblocks, |
| 204 | }; |
| 205 | |
| 206 | static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = { |
Mauro Carvalho Chehab | d53b510 | 2011-12-26 10:10:42 -0300 | [diff] [blame^] | 207 | .delsys = { SYS_DVBC_ANNEX_A }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | .info = { |
| 209 | .name = "Dummy DVB-C", |
| 210 | .type = FE_QAM, |
| 211 | .frequency_stepsize = 62500, |
| 212 | .frequency_min = 51000000, |
| 213 | .frequency_max = 858000000, |
| 214 | .symbol_rate_min = (57840000/2)/64, /* SACLK/64 == (XIN/2)/64 */ |
| 215 | .symbol_rate_max = (57840000/2)/4, /* SACLK/4 */ |
| 216 | .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 | |
| 217 | FE_CAN_QAM_128 | FE_CAN_QAM_256 | |
| 218 | FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO |
| 219 | }, |
| 220 | |
| 221 | .release = dvb_dummy_fe_release, |
| 222 | |
| 223 | .init = dvb_dummy_fe_init, |
| 224 | .sleep = dvb_dummy_fe_sleep, |
| 225 | |
Mauro Carvalho Chehab | d53b510 | 2011-12-26 10:10:42 -0300 | [diff] [blame^] | 226 | .set_frontend = dvb_dummy_fe_set_frontend, |
| 227 | .get_frontend = dvb_dummy_fe_get_frontend, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | .read_status = dvb_dummy_fe_read_status, |
| 230 | .read_ber = dvb_dummy_fe_read_ber, |
| 231 | .read_signal_strength = dvb_dummy_fe_read_signal_strength, |
| 232 | .read_snr = dvb_dummy_fe_read_snr, |
| 233 | .read_ucblocks = dvb_dummy_fe_read_ucblocks, |
| 234 | }; |
| 235 | |
| 236 | static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = { |
Mauro Carvalho Chehab | d53b510 | 2011-12-26 10:10:42 -0300 | [diff] [blame^] | 237 | .delsys = { SYS_DVBS }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | .info = { |
| 239 | .name = "Dummy DVB-S", |
| 240 | .type = FE_QPSK, |
| 241 | .frequency_min = 950000, |
| 242 | .frequency_max = 2150000, |
| 243 | .frequency_stepsize = 250, /* kHz for QPSK frontends */ |
| 244 | .frequency_tolerance = 29500, |
| 245 | .symbol_rate_min = 1000000, |
| 246 | .symbol_rate_max = 45000000, |
| 247 | .caps = FE_CAN_INVERSION_AUTO | |
| 248 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | |
| 249 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | |
| 250 | FE_CAN_QPSK |
| 251 | }, |
| 252 | |
| 253 | .release = dvb_dummy_fe_release, |
| 254 | |
| 255 | .init = dvb_dummy_fe_init, |
| 256 | .sleep = dvb_dummy_fe_sleep, |
| 257 | |
Mauro Carvalho Chehab | d53b510 | 2011-12-26 10:10:42 -0300 | [diff] [blame^] | 258 | .set_frontend = dvb_dummy_fe_set_frontend, |
| 259 | .get_frontend = dvb_dummy_fe_get_frontend, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
| 261 | .read_status = dvb_dummy_fe_read_status, |
| 262 | .read_ber = dvb_dummy_fe_read_ber, |
| 263 | .read_signal_strength = dvb_dummy_fe_read_signal_strength, |
| 264 | .read_snr = dvb_dummy_fe_read_snr, |
| 265 | .read_ucblocks = dvb_dummy_fe_read_ucblocks, |
| 266 | |
| 267 | .set_voltage = dvb_dummy_fe_set_voltage, |
| 268 | .set_tone = dvb_dummy_fe_set_tone, |
| 269 | }; |
| 270 | |
| 271 | MODULE_DESCRIPTION("DVB DUMMY Frontend"); |
| 272 | MODULE_AUTHOR("Emard"); |
| 273 | MODULE_LICENSE("GPL"); |
| 274 | |
| 275 | EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach); |
| 276 | EXPORT_SYMBOL(dvb_dummy_fe_qam_attach); |
| 277 | EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach); |