V4L/DVB (8734): Initial support for AME DTV-5100 USB2.0 DVB-T
[pandora-kernel.git] / drivers / media / dvb / dvb-usb / dtv5100-fe.c
1 /*
2  * DVB USB Linux driver for AME DTV-5100 USB2.0 DVB-T
3  *
4  * Copyright (C) 2008  Antoine Jacquet <royale@zerezo.com>
5  * http://royale.zerezo.com/dtv5100/
6  *
7  * Inspired by dvb_dummy_fe.c
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 #include "dvb-usb.h"
25 #include "qt1010_priv.h"
26
27 struct dtv5100_fe_state {
28         struct dvb_frontend frontend;
29 };
30
31 static int dtv5100_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
32 {
33         *status = FE_HAS_SIGNAL
34                 | FE_HAS_CARRIER
35                 | FE_HAS_VITERBI
36                 | FE_HAS_SYNC
37                 | FE_HAS_LOCK;
38
39         return 0;
40 }
41
42 static int dtv5100_fe_read_ber(struct dvb_frontend* fe, u32* ber)
43 {
44         *ber = 0;
45         return 0;
46 }
47
48 static int dtv5100_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
49 {
50         *strength = 0;
51         return 0;
52 }
53
54 static int dtv5100_fe_read_snr(struct dvb_frontend* fe, u16* snr)
55 {
56         *snr = 0;
57         return 0;
58 }
59
60 static int dtv5100_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
61 {
62         *ucblocks = 0;
63         return 0;
64 }
65
66 static int dtv5100_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
67 {
68         return 0;
69 }
70
71 static int dtv5100_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
72 {
73         if (fe->ops.tuner_ops.set_params) {
74                 fe->ops.tuner_ops.set_params(fe, p);
75                 if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
76         }
77
78         return 0;
79 }
80
81 static int dtv5100_fe_sleep(struct dvb_frontend* fe)
82 {
83         return 0;
84 }
85
86 static int dtv5100_fe_init(struct dvb_frontend* fe)
87 {
88         return 0;
89 }
90
91 static void dtv5100_fe_release(struct dvb_frontend* fe)
92 {
93         struct dtv5100_fe_state* state = fe->demodulator_priv;
94         kfree(state);
95 }
96
97 static struct dvb_frontend_ops dtv5100_fe_ops;
98
99 struct dvb_frontend* dtv5100_fe_attach(void)
100 {
101         struct dtv5100_fe_state* state = NULL;
102
103         /* allocate memory for the internal state */
104         state = kmalloc(sizeof(struct dtv5100_fe_state), GFP_KERNEL);
105         if (state == NULL) goto error;
106
107         /* create dvb_frontend */
108         memcpy(&state->frontend.ops, &dtv5100_fe_ops, sizeof(struct dvb_frontend_ops));
109         state->frontend.demodulator_priv = state;
110         return &state->frontend;
111
112 error:
113         kfree(state);
114         return NULL;
115 }
116
117 static struct dvb_frontend_ops dtv5100_fe_ops = {
118
119         .info = {
120                 .name                   = "Dummy DVB-T",
121                 .type                   = FE_OFDM,
122                 .frequency_min          = QT1010_MIN_FREQ,
123                 .frequency_max          = QT1010_MAX_FREQ,
124                 .frequency_stepsize     = QT1010_STEP,
125                 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
126                                 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
127                                 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
128                                 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
129                                 FE_CAN_TRANSMISSION_MODE_AUTO |
130                                 FE_CAN_GUARD_INTERVAL_AUTO |
131                                 FE_CAN_HIERARCHY_AUTO,
132         },
133
134         .release = dtv5100_fe_release,
135
136         .init = dtv5100_fe_init,
137         .sleep = dtv5100_fe_sleep,
138
139         .set_frontend = dtv5100_fe_set_frontend,
140         .get_frontend = dtv5100_fe_get_frontend,
141
142         .read_status = dtv5100_fe_read_status,
143         .read_ber = dtv5100_fe_read_ber,
144         .read_signal_strength = dtv5100_fe_read_signal_strength,
145         .read_snr = dtv5100_fe_read_snr,
146         .read_ucblocks = dtv5100_fe_read_ucblocks,
147 };