1 /* Linux driver for devices based on the DiBcom DiB0700 USB bridge
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation, version 2.
7 * Copyright (C) 2005-6 DiBcom, SA
11 #include "dib3000mc.h"
15 static int force_lna_activation;
16 module_param(force_lna_activation, int, 0644);
17 MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
18 "if applicable for the device (default: 0=automatic/off).");
20 /* Hauppauge Nova-T 500
21 * has a LNA on GPIO0 which is enabled by setting 1 */
22 static struct mt2060_config bristol_mt2060_config[2] = {
31 static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
32 .band_caps = BAND_VHF | BAND_UHF,
33 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
53 static struct dib3000mc_config bristol_dib3000mc_config[2] = {
54 { .agc = &bristol_dib3000p_mt2060_agc_config,
56 .ln_adc_level = 0x1cc7,
57 .output_mpeg2_in_188_bytes = 1,
59 { .agc = &bristol_dib3000p_mt2060_agc_config,
61 .ln_adc_level = 0x1cc7,
62 .output_mpeg2_in_188_bytes = 1,
66 static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
68 struct dib0700_state *st = adap->dev->priv;
70 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
71 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
72 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
73 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
75 if (force_lna_activation)
76 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
78 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
80 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
81 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
85 st->mt2060_if1[adap->id] = 1220;
86 return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
87 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
90 static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
92 struct dib0700_state *st = adap->dev->priv;
93 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
94 return dvb_attach(mt2060_attach,adap->fe, tun_i2c, &bristol_mt2060_config[adap->id],
95 st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0;
98 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
100 static struct mt2060_config stk7000p_mt2060_config = {
105 static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
107 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
108 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
109 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
110 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
111 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
113 // adap->fe = dib7000m_attach(&adap->dev->i2c_adap, &stk7700p_dib7000m_config, 18);
117 static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
119 // tun_i2c = dib7000m_get_tuner_i2c_master(adap->fe, 1);
120 // return mt2060_attach(adap->fe, tun_i2c, &stk3000p_mt2060_config, if1);
124 struct usb_device_id dib0700_usb_id_table[] = {
125 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
126 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
127 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
128 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
129 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
130 { } /* Terminating entry */
132 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
134 #define DIB0700_DEFAULT_DEVICE_PROPERTIES \
135 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
136 .usb_ctrl = DEVICE_SPECIFIC, \
137 .firmware = "dvb-usb-dib0700-01.fw", \
138 .download_firmware = dib0700_download_firmware, \
140 .size_of_priv = sizeof(struct dib0700_state), \
141 .i2c_algo = &dib0700_i2c_algo, \
142 .identify_state = dib0700_identify_state
144 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
145 .streaming_ctrl = dib0700_streaming_ctrl, \
152 .buffersize = 39480, \
157 struct dvb_usb_device_properties dib0700_devices[] = {
159 DIB0700_DEFAULT_DEVICE_PROPERTIES,
164 .frontend_attach = stk7700p_frontend_attach,
165 .tuner_attach = stk7700p_tuner_attach,
167 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
171 .num_device_descs = 3,
173 { "DiBcom STK7700P reference design",
174 { &dib0700_usb_id_table[0], NULL },
177 { "Hauppauge Nova-T Stick",
178 { &dib0700_usb_id_table[3], NULL },
181 { "AVerMedia AVerTV DVB-T Volar",
182 { &dib0700_usb_id_table[4], NULL },
186 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
191 .frontend_attach = bristol_frontend_attach,
192 .tuner_attach = bristol_tuner_attach,
194 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
196 .frontend_attach = bristol_frontend_attach,
197 .tuner_attach = bristol_tuner_attach,
199 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
203 .num_device_descs = 1,
205 { "Hauppauge Nova-T 500 Dual DVB-T",
206 { &dib0700_usb_id_table[1], &dib0700_usb_id_table[2], NULL },
213 int dib0700_device_count = ARRAY_SIZE(dib0700_devices);