V4L/DVB (4651): Adding another USB product ID for Nova-T 500
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / media / dvb / dvb-usb / dib0700_devices.c
CommitLineData
b7f54910
PB
1/* 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,
6958effe 28 .setup = (0 << 15) | (0 << 14) | (0 << 13) | (0 << 12) | (29 << 0),
b7f54910 29
6958effe
PB
30 .agc1_max = 42598,
31 .agc1_min = 17694,
32 .agc2_max = 45875,
33 .agc2_min = 0,
b7f54910 34
6958effe
PB
35 .agc1_pt1 = 0,
36 .agc1_pt2 = 59,
b7f54910 37
6958effe
PB
38 .agc1_slope1 = 0,
39 .agc1_slope2 = 69,
b7f54910
PB
40
41 .agc2_pt1 = 0,
6958effe 42 .agc2_pt2 = 59,
b7f54910 43
6958effe
PB
44 .agc2_slope1 = 111,
45 .agc2_slope2 = 28,
b7f54910
PB
46};
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{
6958effe 63 struct dib0700_state *st = adap->dev->priv;
b7f54910
PB
64 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
6958effe
PB
70 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); msleep(10); // LNA
71
b7f54910
PB
72 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 }
6958effe
PB
77 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;
b7f54910
PB
80}
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);
6958effe
PB
86 return dvb_attach(mt2060_attach,adap->fe, tun_i2c, &bristol_mt2060_config[adap->id],
87 st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0;
b7f54910
PB
88}
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) },
d535cfa7 117 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
b7f54910
PB
118 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
119 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
120 { } /* Terminating entry */
121};
122MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
123
124#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
125 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
126 .usb_ctrl = DEVICE_SPECIFIC, \
127 .firmware = "dvb-usb-dib0700-01.fw", \
128 .download_firmware = dib0700_download_firmware, \
6958effe 129 .no_reconnect = 1, \
b7f54910 130 .size_of_priv = sizeof(struct dib0700_state), \
6958effe
PB
131 .i2c_algo = &dib0700_i2c_algo, \
132 .identify_state = dib0700_identify_state
b7f54910
PB
133
134#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
135 .streaming_ctrl = dib0700_streaming_ctrl, \
136 .stream = { \
137 .type = USB_BULK, \
138 .count = 4, \
139 .endpoint = ep, \
140 .u = { \
141 .bulk = { \
142 .buffersize = 39480, \
143 } \
144 } \
145 }
146
147struct dvb_usb_device_properties dib0700_devices[] = {
148 {
149 DIB0700_DEFAULT_DEVICE_PROPERTIES,
150
151 .num_adapters = 1,
152 .adapter = {
153 {
154 .frontend_attach = stk7700p_frontend_attach,
155 .tuner_attach = stk7700p_tuner_attach,
156
157 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
158 },
159 },
160
161 .num_device_descs = 3,
162 .devices = {
163 { "DiBcom STK7700P reference design",
164 { &dib0700_usb_id_table[0], NULL },
165 { NULL },
166 },
167 { "Hauppauge Nova-T Stick",
d535cfa7 168 { &dib0700_usb_id_table[3], NULL },
b7f54910
PB
169 { NULL },
170 },
171 { "AVerMedia AVerTV DVB-T Volar",
d535cfa7 172 { &dib0700_usb_id_table[4], NULL },
b7f54910
PB
173 { NULL },
174 },
175 }
176 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
177
178 .num_adapters = 2,
179 .adapter = {
180 {
181 .frontend_attach = bristol_frontend_attach,
182 .tuner_attach = bristol_tuner_attach,
183
184 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
185 }, {
186 .frontend_attach = bristol_frontend_attach,
187 .tuner_attach = bristol_tuner_attach,
188
189 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
190 }
191 },
192
193 .num_device_descs = 1,
194 .devices = {
195 { "Hauppauge Nova-T 500 Dual DVB-T",
d535cfa7 196 { &dib0700_usb_id_table[1], &dib0700_usb_id_table[2], NULL },
b7f54910
PB
197 { NULL },
198 },
199 }
200 }
201};
202
203int dib0700_device_count = ARRAY_SIZE(dib0700_devices);