[PATCH] dvb: frontend: add ALPS TDED4 PLL
[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/moduleparam.h>
24 #include <linux/init.h>
25
26 #include "dvb_frontend.h"
27 #include "dvb_dummy_fe.h"
28
29
30 struct dvb_dummy_fe_state {
31         struct dvb_frontend_ops ops;
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         return 0;
79 }
80
81 static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
82 {
83         return 0;
84 }
85
86 static int dvb_dummy_fe_init(struct dvb_frontend* fe)
87 {
88         return 0;
89 }
90
91 static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
92 {
93         return 0;
94 }
95
96 static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
97 {
98         return 0;
99 }
100
101 static void dvb_dummy_fe_release(struct dvb_frontend* fe)
102 {
103         struct dvb_dummy_fe_state* state = fe->demodulator_priv;
104         kfree(state);
105 }
106
107 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
108
109 struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
110 {
111         struct dvb_dummy_fe_state* state = NULL;
112
113         /* allocate memory for the internal state */
114         state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
115         if (state == NULL) goto error;
116
117         /* setup the state */
118         memcpy(&state->ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
119
120         /* create dvb_frontend */
121         state->frontend.ops = &state->ops;
122         state->frontend.demodulator_priv = state;
123         return &state->frontend;
124
125 error:
126         kfree(state);
127         return NULL;
128 }
129
130 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
131
132 struct dvb_frontend* dvb_dummy_fe_qpsk_attach()
133 {
134         struct dvb_dummy_fe_state* state = NULL;
135
136         /* allocate memory for the internal state */
137         state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
138         if (state == NULL) goto error;
139
140         /* setup the state */
141         memcpy(&state->ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
142
143         /* create dvb_frontend */
144         state->frontend.ops = &state->ops;
145         state->frontend.demodulator_priv = state;
146         return &state->frontend;
147
148 error:
149         if (state) kfree(state);
150         return NULL;
151 }
152
153 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
154
155 struct dvb_frontend* dvb_dummy_fe_qam_attach()
156 {
157         struct dvb_dummy_fe_state* state = NULL;
158
159         /* allocate memory for the internal state */
160         state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
161         if (state == NULL) goto error;
162
163         /* setup the state */
164         memcpy(&state->ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
165
166         /* create dvb_frontend */
167         state->frontend.ops = &state->ops;
168         state->frontend.demodulator_priv = state;
169         return &state->frontend;
170
171 error:
172         if (state) kfree(state);
173         return NULL;
174 }
175
176 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
177
178         .info = {
179                 .name                   = "Dummy DVB-T",
180                 .type                   = FE_OFDM,
181                 .frequency_min          = 0,
182                 .frequency_max          = 863250000,
183                 .frequency_stepsize     = 62500,
184                 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
185                                 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
186                                 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
187                                 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
188                                 FE_CAN_TRANSMISSION_MODE_AUTO |
189                                 FE_CAN_GUARD_INTERVAL_AUTO |
190                                 FE_CAN_HIERARCHY_AUTO,
191         },
192
193         .release = dvb_dummy_fe_release,
194
195         .init = dvb_dummy_fe_init,
196         .sleep = dvb_dummy_fe_sleep,
197
198         .set_frontend = dvb_dummy_fe_set_frontend,
199         .get_frontend = dvb_dummy_fe_get_frontend,
200
201         .read_status = dvb_dummy_fe_read_status,
202         .read_ber = dvb_dummy_fe_read_ber,
203         .read_signal_strength = dvb_dummy_fe_read_signal_strength,
204         .read_snr = dvb_dummy_fe_read_snr,
205         .read_ucblocks = dvb_dummy_fe_read_ucblocks,
206 };
207
208 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
209
210         .info = {
211                 .name                   = "Dummy DVB-C",
212                 .type                   = FE_QAM,
213                 .frequency_stepsize     = 62500,
214                 .frequency_min          = 51000000,
215                 .frequency_max          = 858000000,
216                 .symbol_rate_min        = (57840000/2)/64,     /* SACLK/64 == (XIN/2)/64 */
217                 .symbol_rate_max        = (57840000/2)/4,      /* SACLK/4 */
218                 .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
219                         FE_CAN_QAM_128 | FE_CAN_QAM_256 |
220                         FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
221         },
222
223         .release = dvb_dummy_fe_release,
224
225         .init = dvb_dummy_fe_init,
226         .sleep = dvb_dummy_fe_sleep,
227
228         .set_frontend = dvb_dummy_fe_set_frontend,
229         .get_frontend = dvb_dummy_fe_get_frontend,
230
231         .read_status = dvb_dummy_fe_read_status,
232         .read_ber = dvb_dummy_fe_read_ber,
233         .read_signal_strength = dvb_dummy_fe_read_signal_strength,
234         .read_snr = dvb_dummy_fe_read_snr,
235         .read_ucblocks = dvb_dummy_fe_read_ucblocks,
236 };
237
238 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
239
240         .info = {
241                 .name                   = "Dummy DVB-S",
242                 .type                   = FE_QPSK,
243                 .frequency_min          = 950000,
244                 .frequency_max          = 2150000,
245                 .frequency_stepsize     = 250,           /* kHz for QPSK frontends */
246                 .frequency_tolerance    = 29500,
247                 .symbol_rate_min        = 1000000,
248                 .symbol_rate_max        = 45000000,
249                 .caps = FE_CAN_INVERSION_AUTO |
250                         FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
251                         FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
252                         FE_CAN_QPSK
253         },
254
255         .release = dvb_dummy_fe_release,
256
257         .init = dvb_dummy_fe_init,
258         .sleep = dvb_dummy_fe_sleep,
259
260         .set_frontend = dvb_dummy_fe_set_frontend,
261         .get_frontend = dvb_dummy_fe_get_frontend,
262
263         .read_status = dvb_dummy_fe_read_status,
264         .read_ber = dvb_dummy_fe_read_ber,
265         .read_signal_strength = dvb_dummy_fe_read_signal_strength,
266         .read_snr = dvb_dummy_fe_read_snr,
267         .read_ucblocks = dvb_dummy_fe_read_ucblocks,
268
269         .set_voltage = dvb_dummy_fe_set_voltage,
270         .set_tone = dvb_dummy_fe_set_tone,
271 };
272
273 MODULE_DESCRIPTION("DVB DUMMY Frontend");
274 MODULE_AUTHOR("Emard");
275 MODULE_LICENSE("GPL");
276
277 EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
278 EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
279 EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);