V4L/DVB (6906): tda18271: rename tda18271_calc_* functions to tda18271_lookup_*
[linux-2.6] / drivers / media / dvb / frontends / dvb_dummy_fe.c
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 static int dvb_dummy_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
72 {
73         return 0;
74 }
75
76 static int dvb_dummy_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
77 {
78         if (fe->ops->tuner_ops->set_params) {
79                 fe->ops->tuner_ops->set_params(fe, p);
80                 if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0);
81         }
82
83         return 0;
84 }
85
86 static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
87 {
88         return 0;
89 }
90
91 static int dvb_dummy_fe_init(struct dvb_frontend* fe)
92 {
93         return 0;
94 }
95
96 static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
97 {
98         return 0;
99 }
100
101 static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
102 {
103         return 0;
104 }
105
106 static void dvb_dummy_fe_release(struct dvb_frontend* fe)
107 {
108         struct dvb_dummy_fe_state* state = fe->demodulator_priv;
109         kfree(state);
110 }
111
112 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
113
114 struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
115 {
116         struct dvb_dummy_fe_state* state = NULL;
117
118         /* allocate memory for the internal state */
119         state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
120         if (state == NULL) goto error;
121
122         /* create dvb_frontend */
123         memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
124         state->frontend.demodulator_priv = state;
125         return &state->frontend;
126
127 error:
128         kfree(state);
129         return NULL;
130 }
131
132 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
133
134 struct dvb_frontend* dvb_dummy_fe_qpsk_attach()
135 {
136         struct dvb_dummy_fe_state* state = NULL;
137
138         /* allocate memory for the internal state */
139         state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
140         if (state == NULL) goto error;
141
142         /* create dvb_frontend */
143         memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
144         state->frontend.demodulator_priv = state;
145         return &state->frontend;
146
147 error:
148         kfree(state);
149         return NULL;
150 }
151
152 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
153
154 struct dvb_frontend* dvb_dummy_fe_qam_attach()
155 {
156         struct dvb_dummy_fe_state* state = NULL;
157
158         /* allocate memory for the internal state */
159         state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
160         if (state == NULL) goto error;
161
162         /* create dvb_frontend */
163         memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
164         state->frontend.demodulator_priv = state;
165         return &state->frontend;
166
167 error:
168         kfree(state);
169         return NULL;
170 }
171
172 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
173
174         .info = {
175                 .name                   = "Dummy DVB-T",
176                 .type                   = FE_OFDM,
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
206         .info = {
207                 .name                   = "Dummy DVB-C",
208                 .type                   = FE_QAM,
209                 .frequency_stepsize     = 62500,
210                 .frequency_min          = 51000000,
211                 .frequency_max          = 858000000,
212                 .symbol_rate_min        = (57840000/2)/64,     /* SACLK/64 == (XIN/2)/64 */
213                 .symbol_rate_max        = (57840000/2)/4,      /* SACLK/4 */
214                 .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
215                         FE_CAN_QAM_128 | FE_CAN_QAM_256 |
216                         FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
217         },
218
219         .release = dvb_dummy_fe_release,
220
221         .init = dvb_dummy_fe_init,
222         .sleep = dvb_dummy_fe_sleep,
223
224         .set_frontend = dvb_dummy_fe_set_frontend,
225         .get_frontend = dvb_dummy_fe_get_frontend,
226
227         .read_status = dvb_dummy_fe_read_status,
228         .read_ber = dvb_dummy_fe_read_ber,
229         .read_signal_strength = dvb_dummy_fe_read_signal_strength,
230         .read_snr = dvb_dummy_fe_read_snr,
231         .read_ucblocks = dvb_dummy_fe_read_ucblocks,
232 };
233
234 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
235
236         .info = {
237                 .name                   = "Dummy DVB-S",
238                 .type                   = FE_QPSK,
239                 .frequency_min          = 950000,
240                 .frequency_max          = 2150000,
241                 .frequency_stepsize     = 250,           /* kHz for QPSK frontends */
242                 .frequency_tolerance    = 29500,
243                 .symbol_rate_min        = 1000000,
244                 .symbol_rate_max        = 45000000,
245                 .caps = FE_CAN_INVERSION_AUTO |
246                         FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
247                         FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
248                         FE_CAN_QPSK
249         },
250
251         .release = dvb_dummy_fe_release,
252
253         .init = dvb_dummy_fe_init,
254         .sleep = dvb_dummy_fe_sleep,
255
256         .set_frontend = dvb_dummy_fe_set_frontend,
257         .get_frontend = dvb_dummy_fe_get_frontend,
258
259         .read_status = dvb_dummy_fe_read_status,
260         .read_ber = dvb_dummy_fe_read_ber,
261         .read_signal_strength = dvb_dummy_fe_read_signal_strength,
262         .read_snr = dvb_dummy_fe_read_snr,
263         .read_ucblocks = dvb_dummy_fe_read_ucblocks,
264
265         .set_voltage = dvb_dummy_fe_set_voltage,
266         .set_tone = dvb_dummy_fe_set_tone,
267 };
268
269 MODULE_DESCRIPTION("DVB DUMMY Frontend");
270 MODULE_AUTHOR("Emard");
271 MODULE_LICENSE("GPL");
272
273 EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
274 EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
275 EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);