2 * TTUSB DEC Frontend Driver
4 * Copyright (C) 2003-2004 Alex Woods <linux-dvb@giblets.org>
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.
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 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "dvb_frontend.h"
23 #include "ttusbdecfe.h"
26 #define LOF_HI 10600000
27 #define LOF_LO 9750000
29 struct ttusbdecfe_state {
31 struct dvb_frontend_ops ops;
33 /* configuration settings */
34 const struct ttusbdecfe_config* config;
36 struct dvb_frontend frontend;
43 static int ttusbdecfe_read_status(struct dvb_frontend* fe, fe_status_t* status)
45 *status = FE_HAS_SIGNAL | FE_HAS_VITERBI |
46 FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK;
51 static int ttusbdecfe_dvbt_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
53 struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
54 u8 b[] = { 0x00, 0x00, 0x00, 0x03,
55 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x01,
57 0x00, 0x00, 0x00, 0xff,
58 0x00, 0x00, 0x00, 0xff };
60 u32 freq = htonl(p->frequency / 1000);
61 memcpy(&b[4], &freq, sizeof (u32));
62 state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL);
67 static int ttusbdecfe_dvbs_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
69 struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
71 u8 b[] = { 0x00, 0x00, 0x00, 0x01,
72 0x00, 0x00, 0x00, 0x00,
73 0x00, 0x00, 0x00, 0x01,
74 0x00, 0x00, 0x00, 0x00,
75 0x00, 0x00, 0x00, 0x00,
76 0x00, 0x00, 0x00, 0x00,
77 0x00, 0x00, 0x00, 0x00,
78 0x00, 0x00, 0x00, 0x00,
79 0x00, 0x00, 0x00, 0x00,
80 0x00, 0x00, 0x00, 0x00 };
86 freq = htonl(p->frequency +
87 (state->hi_band ? LOF_HI : LOF_LO));
88 memcpy(&b[4], &freq, sizeof(u32));
89 sym_rate = htonl(p->u.qam.symbol_rate);
90 memcpy(&b[12], &sym_rate, sizeof(u32));
91 band = htonl(state->hi_band ? LOF_HI : LOF_LO);
92 memcpy(&b[24], &band, sizeof(u32));
93 lnb_voltage = htonl(state->voltage);
94 memcpy(&b[28], &lnb_voltage, sizeof(u32));
96 state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL);
101 static int ttusbdecfe_dvbs_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd)
103 struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
104 u8 b[] = { 0x00, 0xff, 0x00, 0x00,
105 0x00, 0x00, 0x00, 0x00,
108 memcpy(&b[4], cmd->msg, cmd->msg_len);
110 state->config->send_command(fe, 0x72,
111 sizeof(b) - (6 - cmd->msg_len), b,
118 static int ttusbdecfe_dvbs_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
120 struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
122 state->hi_band = (SEC_TONE_ON == tone);
128 static int ttusbdecfe_dvbs_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
130 struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
146 static void ttusbdecfe_release(struct dvb_frontend* fe)
148 struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
152 static struct dvb_frontend_ops ttusbdecfe_dvbt_ops;
154 struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* config)
156 struct ttusbdecfe_state* state = NULL;
158 /* allocate memory for the internal state */
159 state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
163 /* setup the state */
164 state->config = config;
165 memcpy(&state->ops, &ttusbdecfe_dvbt_ops, sizeof(struct dvb_frontend_ops));
167 /* create dvb_frontend */
168 state->frontend.ops = &state->ops;
169 state->frontend.demodulator_priv = state;
170 return &state->frontend;
173 static struct dvb_frontend_ops ttusbdecfe_dvbs_ops;
175 struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* config)
177 struct ttusbdecfe_state* state = NULL;
179 /* allocate memory for the internal state */
180 state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
184 /* setup the state */
185 state->config = config;
188 memcpy(&state->ops, &ttusbdecfe_dvbs_ops, sizeof(struct dvb_frontend_ops));
190 /* create dvb_frontend */
191 state->frontend.ops = &state->ops;
192 state->frontend.demodulator_priv = state;
193 return &state->frontend;
196 static struct dvb_frontend_ops ttusbdecfe_dvbt_ops = {
199 .name = "TechnoTrend/Hauppauge DEC2000-t Frontend",
201 .frequency_min = 51000000,
202 .frequency_max = 858000000,
203 .frequency_stepsize = 62500,
204 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
205 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
206 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
207 FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
208 FE_CAN_HIERARCHY_AUTO,
211 .release = ttusbdecfe_release,
213 .set_frontend = ttusbdecfe_dvbt_set_frontend,
215 .read_status = ttusbdecfe_read_status,
218 static struct dvb_frontend_ops ttusbdecfe_dvbs_ops = {
221 .name = "TechnoTrend/Hauppauge DEC3000-s Frontend",
223 .frequency_min = 950000,
224 .frequency_max = 2150000,
225 .frequency_stepsize = 125,
226 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
227 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
228 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
229 FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
230 FE_CAN_HIERARCHY_AUTO,
233 .release = ttusbdecfe_release,
235 .set_frontend = ttusbdecfe_dvbs_set_frontend,
237 .read_status = ttusbdecfe_read_status,
239 .diseqc_send_master_cmd = ttusbdecfe_dvbs_diseqc_send_master_cmd,
240 .set_voltage = ttusbdecfe_dvbs_set_voltage,
241 .set_tone = ttusbdecfe_dvbs_set_tone,
244 MODULE_DESCRIPTION("TTUSB DEC DVB-T/S Demodulator driver");
245 MODULE_AUTHOR("Alex Woods/Andrew de Quincey");
246 MODULE_LICENSE("GPL");
248 EXPORT_SYMBOL(ttusbdecfe_dvbt_attach);
249 EXPORT_SYMBOL(ttusbdecfe_dvbs_attach);