blob: da177e745e5ed82f5fe94e55000400c16658af03 [file] [log] [blame]
Patrick Boettcherb7f54912006-09-19 12:51:37 -03001/* Linux driver for devices based on the DiBcom DiB0700 USB bridge
2 *
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.
6 *
7 * Copyright (C) 2005-6 DiBcom, SA
8 */
9#include "dib0700.h"
10
11#include "dib3000mc.h"
12#include "dib7000m.h"
13#include "mt2060.h"
14
15/* Hauppauge Nova-T 500
16 * has a LNA on GPIO0 which is enabled by setting 1 */
17static struct mt2060_config bristol_mt2060_config[2] = {
18 {
19 .i2c_address = 0x60,
20 .clock_out = 1,
21 }, {
22 .i2c_address = 0x61,
23 }
24};
25
26static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
27 .band_caps = BAND_VHF | BAND_UHF,
Patrick Boettcher6958eff2006-09-19 12:51:40 -030028 .setup = (0 << 15) | (0 << 14) | (0 << 13) | (0 << 12) | (29 << 0),
Patrick Boettcherb7f54912006-09-19 12:51:37 -030029
Patrick Boettcher6958eff2006-09-19 12:51:40 -030030 .agc1_max = 42598,
31 .agc1_min = 17694,
32 .agc2_max = 45875,
33 .agc2_min = 0,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030034
Patrick Boettcher6958eff2006-09-19 12:51:40 -030035 .agc1_pt1 = 0,
36 .agc1_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030037
Patrick Boettcher6958eff2006-09-19 12:51:40 -030038 .agc1_slope1 = 0,
39 .agc1_slope2 = 69,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030040
41 .agc2_pt1 = 0,
Patrick Boettcher6958eff2006-09-19 12:51:40 -030042 .agc2_pt2 = 59,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030043
Patrick Boettcher6958eff2006-09-19 12:51:40 -030044 .agc2_slope1 = 111,
45 .agc2_slope2 = 28,
Patrick Boettcherb7f54912006-09-19 12:51:37 -030046};
47
48static struct dib3000mc_config bristol_dib3000mc_config[2] = {
49 { .agc = &bristol_dib3000p_mt2060_agc_config,
50 .max_time = 0x196,
51 .ln_adc_level = 0x1cc7,
52 .output_mpeg2_in_188_bytes = 1,
53 },
54 { .agc = &bristol_dib3000p_mt2060_agc_config,
55 .max_time = 0x196,
56 .ln_adc_level = 0x1cc7,
57 .output_mpeg2_in_188_bytes = 1,
58 }
59};
60
61static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
62{
Patrick Boettcher6958eff2006-09-19 12:51:40 -030063 struct dib0700_state *st = adap->dev->priv;
Patrick Boettcherb7f54912006-09-19 12:51:37 -030064 if (adap->id == 0) {
65 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
66 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
67 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
68 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
69
Patrick Boettcher6958eff2006-09-19 12:51:40 -030070 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); msleep(10); // LNA
71
Patrick Boettcherb7f54912006-09-19 12:51:37 -030072 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
73 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
74 return -ENODEV;
75 }
76 }
Patrick Boettcher6958eff2006-09-19 12:51:40 -030077 st->mt2060_if1[adap->id] = 1220;
78 return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
79 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -030080}
81
82static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
83{
84 struct dib0700_state *st = adap->dev->priv;
85 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
Patrick Boettcher6958eff2006-09-19 12:51:40 -030086 return dvb_attach(mt2060_attach,adap->fe, tun_i2c, &bristol_mt2060_config[adap->id],
87 st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0;
Patrick Boettcherb7f54912006-09-19 12:51:37 -030088}
89
90/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
91static struct mt2060_config stk7000p_mt2060_config = {
92 0x60
93};
94
95static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
96{
97 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
98 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
99 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
100 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
101 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
102
103// adap->fe = dib7000m_attach(&adap->dev->i2c_adap, &stk7700p_dib7000m_config, 18);
104 return 0;
105}
106
107static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
108{
109// tun_i2c = dib7000m_get_tuner_i2c_master(adap->fe, 1);
110// return mt2060_attach(adap->fe, tun_i2c, &stk3000p_mt2060_config, if1);
111 return 0;
112}
113
114struct usb_device_id dib0700_usb_id_table[] = {
115 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
116 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
117 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
118 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
119 { } /* Terminating entry */
120};
121MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
122
123#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
124 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
125 .usb_ctrl = DEVICE_SPECIFIC, \
126 .firmware = "dvb-usb-dib0700-01.fw", \
127 .download_firmware = dib0700_download_firmware, \
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300128 .no_reconnect = 1, \
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300129 .size_of_priv = sizeof(struct dib0700_state), \
Patrick Boettcher6958eff2006-09-19 12:51:40 -0300130 .i2c_algo = &dib0700_i2c_algo, \
131 .identify_state = dib0700_identify_state
Patrick Boettcherb7f54912006-09-19 12:51:37 -0300132
133#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
134 .streaming_ctrl = dib0700_streaming_ctrl, \
135 .stream = { \
136 .type = USB_BULK, \
137 .count = 4, \
138 .endpoint = ep, \
139 .u = { \
140 .bulk = { \
141 .buffersize = 39480, \
142 } \
143 } \
144 }
145
146struct dvb_usb_device_properties dib0700_devices[] = {
147 {
148 DIB0700_DEFAULT_DEVICE_PROPERTIES,
149
150 .num_adapters = 1,
151 .adapter = {
152 {
153 .frontend_attach = stk7700p_frontend_attach,
154 .tuner_attach = stk7700p_tuner_attach,
155
156 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
157 },
158 },
159
160 .num_device_descs = 3,
161 .devices = {
162 { "DiBcom STK7700P reference design",
163 { &dib0700_usb_id_table[0], NULL },
164 { NULL },
165 },
166 { "Hauppauge Nova-T Stick",
167 { &dib0700_usb_id_table[2], NULL },
168 { NULL },
169 },
170 { "AVerMedia AVerTV DVB-T Volar",
171 { &dib0700_usb_id_table[3], NULL },
172 { NULL },
173 },
174 }
175 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
176
177 .num_adapters = 2,
178 .adapter = {
179 {
180 .frontend_attach = bristol_frontend_attach,
181 .tuner_attach = bristol_tuner_attach,
182
183 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
184 }, {
185 .frontend_attach = bristol_frontend_attach,
186 .tuner_attach = bristol_tuner_attach,
187
188 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
189 }
190 },
191
192 .num_device_descs = 1,
193 .devices = {
194 { "Hauppauge Nova-T 500 Dual DVB-T",
195 { &dib0700_usb_id_table[1], NULL },
196 { NULL },
197 },
198 }
199 }
200};
201
202int dib0700_device_count = ARRAY_SIZE(dib0700_devices);