aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorOlivier DANET <odanet@caramail.com>2007-07-25 13:42:54 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:03:14 -0400
commit54d75ebaa02809f24a16624e32706af3bf97588e (patch)
tree2ca1bd9734ebc62531614c4b6fd008621c869734 /drivers/media/dvb
parent59a00adbd30ed5d3a97ac41ad9e4b040a111eea8 (diff)
V4L/DVB (5914): Add initial support for Dual-DVB-T stick
Add initial support for Dual-DVB-T stick based on DiB7700 and MT2266 - Microtune MT2266 driver. - Preliminary support for these dual tuner devices : - Pinnacle Dual DVB-T diversity - Terratec Cinergy DT USB XS diversity - Hauppauge Nova TD USB Signed-off-by: Olivier DANET <odanet@caramail.com> Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig1
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700.h4
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c262
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h5
-rw-r--r--drivers/media/dvb/frontends/Kconfig7
-rw-r--r--drivers/media/dvb/frontends/Makefile1
-rw-r--r--drivers/media/dvb/frontends/dib7000p.c5
-rw-r--r--drivers/media/dvb/frontends/dib7000p.h2
-rw-r--r--drivers/media/dvb/frontends/mt2266.c288
-rw-r--r--drivers/media/dvb/frontends/mt2266.h37
11 files changed, 609 insertions, 5 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 40e41f2f5afe..dec03ee32e1a 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -74,6 +74,7 @@ config DVB_USB_DIB0700
74 select DVB_DIB7000M 74 select DVB_DIB7000M
75 select DVB_DIB3000MC 75 select DVB_DIB3000MC
76 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE 76 select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
77 select DVB_TUNER_MT2266 if !DVB_FE_CUSTOMISE
77 help 78 help
78 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The 79 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The
79 USB bridge is also present in devices having the DiB7700 DVB-T-USB 80 USB bridge is also present in devices having the DiB7700 DVB-T-USB
diff --git a/drivers/media/dvb/dvb-usb/dib0700.h b/drivers/media/dvb/dvb-usb/dib0700.h
index cda3adea24fb..74ae6c24087e 100644
--- a/drivers/media/dvb/dvb-usb/dib0700.h
+++ b/drivers/media/dvb/dvb-usb/dib0700.h
@@ -35,12 +35,13 @@ extern int dvb_usb_dib0700_debug;
35struct dib0700_state { 35struct dib0700_state {
36 u8 channel_state; 36 u8 channel_state;
37 u16 mt2060_if1[2]; 37 u16 mt2060_if1[2];
38 38 u8 rc_toggle;
39 u8 is_dib7000pc; 39 u8 is_dib7000pc;
40}; 40};
41 41
42extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val); 42extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val);
43extern int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3); 43extern int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3);
44extern int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen);
44extern int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw); 45extern int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw);
45extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff); 46extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);
46extern struct i2c_algorithm dib0700_i2c_algo; 47extern struct i2c_algorithm dib0700_i2c_algo;
@@ -50,5 +51,4 @@ extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device
50extern int dib0700_device_count; 51extern int dib0700_device_count;
51extern struct dvb_usb_device_properties dib0700_devices[]; 52extern struct dvb_usb_device_properties dib0700_devices[];
52extern struct usb_device_id dib0700_usb_id_table[]; 53extern struct usb_device_id dib0700_usb_id_table[];
53
54#endif 54#endif
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index dddf164f269a..8a1ea114deb0 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -32,7 +32,7 @@ static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
32} 32}
33 33
34/* expecting tx buffer: request data[0] ... data[n] (n <= 4) */ 34/* expecting tx buffer: request data[0] ... data[n] (n <= 4) */
35static int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen) 35int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
36{ 36{
37 u16 index, value; 37 u16 index, value;
38 int status; 38 int status;
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 2208757d9017..122d9d4b4baa 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -12,6 +12,7 @@
12#include "dib7000m.h" 12#include "dib7000m.h"
13#include "dib7000p.h" 13#include "dib7000p.h"
14#include "mt2060.h" 14#include "mt2060.h"
15#include "mt2266.h"
15 16
16static int force_lna_activation; 17static int force_lna_activation;
17module_param(force_lna_activation, int, 0644); 18module_param(force_lna_activation, int, 0644);
@@ -96,6 +97,228 @@ static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
96 st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0; 97 st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0;
97} 98}
98 99
100/* STK7700D: Pinnacle Dual DVB-T Diversity */
101
102static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config = {
103 BAND_UHF/* | BAND_VHF*/,
104 0xE64, // setup
105 2372, // inv_gain
106 21, // time_stabiliz
107
108 0, // alpha_level
109 118, // thlock
110
111 0, // wbd_inv
112 0, // wbd_ref
113 0, // wbd_sel
114 0, // wbd_alpha
115
116 65535, // agc1_max
117 0, // agc1_min
118 65535, // agc2_max
119 23592, // agc2_min
120 0, // agc1_pt1
121 128, // agc1_pt2
122 128, // agc1_pt3
123 128, // agc1_slope1
124 0, // agc1_slope2
125 128, // agc2_pt1
126 253, // agc2_pt2
127 81, // agc2_slope1
128 0, // agc2_slope2
129
130 17, // alpha_mant
131 27, // alpha_exp
132
133 23, // beta_mant
134 51, // beta_exp
135
136 0, // perform_agc_softsplit : 1 en vrai!
137};
138
139static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
140 60000, 30000, // internal, sampling
141 1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
142 0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
143 (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
144 0, // ifreq
145 20452225, // timf
146};
147
148static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
149 { .output_mpeg2_in_188_bytes = 1,
150 .hostbus_diversity = 1,
151 .tuner_is_baseband = 1,
152
153 .agc = &stk7700d_7000p_mt2266_agc_config,
154 .bw = &stk7700d_mt2266_pll_config,
155
156 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
157 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
158 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
159 },
160 { .output_mpeg2_in_188_bytes = 1,
161 .hostbus_diversity = 1,
162 .tuner_is_baseband = 1,
163
164 .agc = &stk7700d_7000p_mt2266_agc_config,
165 .bw = &stk7700d_mt2266_pll_config,
166
167 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS,
168 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES,
169 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS,
170 }
171};
172
173static struct mt2266_config stk7700d_mt2266_config[2] = {
174 { .i2c_address = 0x60
175 },
176 { .i2c_address = 0x60
177 }
178};
179
180static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap)
181{
182 if (adap->id == 0) {
183 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
184 msleep(10);
185 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
186 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
187 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
188 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
189 msleep(10);
190 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
191 msleep(10);
192 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
193 dib7000p_i2c_enumeration(&adap->dev->i2c_adap,2,18,stk7700d_dib7000p_mt2266_config);
194 }
195
196 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap,0x80+(adap->id << 1),
197 &stk7700d_dib7000p_mt2266_config[adap->id]);
198
199 return adap->fe == NULL ? -ENODEV : 0;
200}
201
202static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
203{
204 struct i2c_adapter *tun_i2c;
205 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
206 return dvb_attach(mt2266_attach, adap->fe, tun_i2c,
207 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;;
208}
209
210#define DEFAULT_RC_INTERVAL 150
211
212static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
213
214int stk7700d_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
215{
216 u8 key[4];
217 int i;
218 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
219 struct dib0700_state *st = d->priv;
220 *event = 0;
221 *state = REMOTE_NO_KEY_PRESSED;
222 i=dib0700_ctrl_rd(d,rc_request,2,key,4);
223 if (i<=0) {
224 err("stk7700d:RC Query Failed\n");
225 return 0;
226 }
227 if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0;
228 if (key[1]!=st->rc_toggle) {
229 for (i=0;i<d->props.rc_key_map_size; i++) {
230 if (keymap[i].custom == key[2] && keymap[i].data == key[3]) {
231 *event = keymap[i].event;
232 *state = REMOTE_KEY_PRESSED;
233 st->rc_toggle=key[1];
234 return 0;
235 }
236 }
237 err("stk7700d:Unknown remote controller key : %2X %2X\n",(int)key[2],(int)key[3]);
238 }
239 return 0;
240}
241
242#define KEY_MAP_SIZE (25+48)
243
244struct dvb_usb_rc_key stk7700d_rc_keys[] = {
245 /* Key codes for the tiny Pinnacle remote*/
246 { 0x07, 0x00, KEY_MUTE },
247 { 0x07, 0x01, KEY_MENU }, // Pinnacle logo
248 { 0x07, 0x39, KEY_POWER },
249 { 0x07, 0x03, KEY_VOLUMEUP },
250 { 0x07, 0x09, KEY_VOLUMEDOWN },
251 { 0x07, 0x06, KEY_CHANNELUP },
252 { 0x07, 0x0c, KEY_CHANNELDOWN },
253 { 0x07, 0x0f, KEY_1 },
254 { 0x07, 0x15, KEY_2 },
255 { 0x07, 0x10, KEY_3 },
256 { 0x07, 0x18, KEY_4 },
257 { 0x07, 0x1b, KEY_5 },
258 { 0x07, 0x1e, KEY_6 },
259 { 0x07, 0x11, KEY_7 },
260 { 0x07, 0x21, KEY_8 },
261 { 0x07, 0x12, KEY_9 },
262 { 0x07, 0x27, KEY_0 },
263 { 0x07, 0x24, KEY_SCREEN }, // 'Square' key
264 { 0x07, 0x2a, KEY_TEXT }, // 'T' key
265 { 0x07, 0x2d, KEY_REWIND },
266 { 0x07, 0x30, KEY_PLAY },
267 { 0x07, 0x33, KEY_FASTFORWARD },
268 { 0x07, 0x36, KEY_RECORD },
269 { 0x07, 0x3c, KEY_STOP },
270 { 0x07, 0x3f, KEY_CANCEL }, // '?' key
271 /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */
272 { 0xeb, 0x01, KEY_POWER },
273 { 0xeb, 0x02, KEY_1 },
274 { 0xeb, 0x03, KEY_2 },
275 { 0xeb, 0x04, KEY_3 },
276 { 0xeb, 0x05, KEY_4 },
277 { 0xeb, 0x06, KEY_5 },
278 { 0xeb, 0x07, KEY_6 },
279 { 0xeb, 0x08, KEY_7 },
280 { 0xeb, 0x09, KEY_8 },
281 { 0xeb, 0x0a, KEY_9 },
282 { 0xeb, 0x0b, KEY_VIDEO },
283 { 0xeb, 0x0c, KEY_0 },
284 { 0xeb, 0x0d, KEY_REFRESH },
285 { 0xeb, 0x0f, KEY_EPG },
286 { 0xeb, 0x10, KEY_UP },
287 { 0xeb, 0x11, KEY_LEFT },
288 { 0xeb, 0x12, KEY_OK },
289 { 0xeb, 0x13, KEY_RIGHT },
290 { 0xeb, 0x14, KEY_DOWN },
291 { 0xeb, 0x16, KEY_INFO },
292 { 0xeb, 0x17, KEY_RED },
293 { 0xeb, 0x18, KEY_GREEN },
294 { 0xeb, 0x19, KEY_YELLOW },
295 { 0xeb, 0x1a, KEY_BLUE },
296 { 0xeb, 0x1b, KEY_CHANNELUP },
297 { 0xeb, 0x1c, KEY_VOLUMEUP },
298 { 0xeb, 0x1d, KEY_MUTE },
299 { 0xeb, 0x1e, KEY_VOLUMEDOWN },
300 { 0xeb, 0x1f, KEY_CHANNELDOWN },
301 { 0xeb, 0x40, KEY_PAUSE },
302 { 0xeb, 0x41, KEY_HOME },
303 { 0xeb, 0x42, KEY_MENU }, /* DVD Menu */
304 { 0xeb, 0x43, KEY_SUBTITLE },
305 { 0xeb, 0x44, KEY_TEXT }, /* Teletext */
306 { 0xeb, 0x45, KEY_DELETE },
307 { 0xeb, 0x46, KEY_TV },
308 { 0xeb, 0x47, KEY_DVD },
309 { 0xeb, 0x48, KEY_STOP },
310 { 0xeb, 0x49, KEY_VIDEO },
311 { 0xeb, 0x4a, KEY_AUDIO }, /* Music */
312 { 0xeb, 0x4b, KEY_SCREEN }, /* Pic */
313 { 0xeb, 0x4c, KEY_PLAY },
314 { 0xeb, 0x4d, KEY_BACK },
315 { 0xeb, 0x4e, KEY_REWIND },
316 { 0xeb, 0x4f, KEY_FASTFORWARD },
317 { 0xeb, 0x54, KEY_PREVIOUS },
318 { 0xeb, 0x58, KEY_RECORD },
319 { 0xeb, 0x5c, KEY_NEXT }
320 };
321
99/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */ 322/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
100static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = { 323static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
101 BAND_UHF | BAND_VHF, // band_caps 324 BAND_UHF | BAND_VHF, // band_caps
@@ -280,6 +503,9 @@ struct usb_device_id dib0700_usb_id_table[] = {
280 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) }, 503 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) },
281 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) }, 504 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) },
282 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) }, 505 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) },
506 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) },
507 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) },
508 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) },
283 { } /* Terminating entry */ 509 { } /* Terminating entry */
284}; 510};
285MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 511MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -372,6 +598,42 @@ struct dvb_usb_device_properties dib0700_devices[] = {
372 { NULL }, 598 { NULL },
373 }, 599 },
374 } 600 }
601 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
602
603 .num_adapters = 2,
604 .adapter = {
605 {
606 .frontend_attach = stk7700d_frontend_attach,
607 .tuner_attach = stk7700d_tuner_attach,
608
609 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
610 }, {
611 .frontend_attach = stk7700d_frontend_attach,
612 .tuner_attach = stk7700d_tuner_attach,
613
614 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
615 }
616 },
617
618 .num_device_descs = 3,
619 .devices = {
620 { "Pinnacle PCTV 2000e",
621 { &dib0700_usb_id_table[11], NULL },
622 { NULL },
623 },
624 { "Terratec Cinergy DT XS Diversity",
625 { &dib0700_usb_id_table[12], NULL },
626 { NULL },
627 },
628 { "Haupauge Nova-TD Stick",
629 { &dib0700_usb_id_table[13], NULL },
630 { NULL },
631 },
632 },
633 .rc_interval = DEFAULT_RC_INTERVAL,
634 .rc_key_map = stk7700d_rc_keys,
635 .rc_key_map_size = KEY_MAP_SIZE,
636 .rc_query = stk7700d_rc_query
375 } 637 }
376}; 638};
377 639
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 78ea3b566ffc..2e38be3aa45b 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -12,7 +12,7 @@
12/* Vendor IDs */ 12/* Vendor IDs */
13#define USB_VID_ADSTECH 0x06e1 13#define USB_VID_ADSTECH 0x06e1
14#define USB_VID_AFATECH 0x15a4 14#define USB_VID_AFATECH 0x15a4
15#define USB_VID_ALCOR_MICRO 0x058f 15#define USB_VID_ALCOR_MICRO 0x058f
16#define USB_VID_ALINK 0x05e3 16#define USB_VID_ALINK 0x05e3
17#define USB_VID_ANCHOR 0x0547 17#define USB_VID_ANCHOR 0x0547
18#define USB_VID_ANUBIS_ELECTRONIC 0x10fd 18#define USB_VID_ANUBIS_ELECTRONIC 0x10fd
@@ -116,8 +116,11 @@
116#define USB_PID_HAUPPAUGE_NOVA_T_500_2 0x9950 116#define USB_PID_HAUPPAUGE_NOVA_T_500_2 0x9950
117#define USB_PID_HAUPPAUGE_NOVA_T_STICK 0x7050 117#define USB_PID_HAUPPAUGE_NOVA_T_STICK 0x7050
118#define USB_PID_HAUPPAUGE_NOVA_T_STICK_2 0x7060 118#define USB_PID_HAUPPAUGE_NOVA_T_STICK_2 0x7060
119#define USB_PID_HAUPPAUGE_NOVA_TD_STICK 0x9580
119#define USB_PID_AVERMEDIA_VOLAR 0xa807 120#define USB_PID_AVERMEDIA_VOLAR 0xa807
120#define USB_PID_AVERMEDIA_VOLAR_2 0xb808 121#define USB_PID_AVERMEDIA_VOLAR_2 0xb808
122#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
123#define USB_PID_PINNACLE_PCTV2000E 0x022c
121#define USB_PID_NEBULA_DIGITV 0x0201 124#define USB_PID_NEBULA_DIGITV 0x0201
122#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 125#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820
123#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500 126#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index ff448761dcef..ba70ad0c3f05 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -322,6 +322,13 @@ config DVB_TUNER_MT2060
322 help 322 help
323 A driver for the silicon IF tuner MT2060 from Microtune. 323 A driver for the silicon IF tuner MT2060 from Microtune.
324 324
325config DVB_TUNER_MT2266
326 tristate "Microtune MT2266 silicon tuner"
327 depends on I2C
328 default m if DVB_FE_CUSTOMISE
329 help
330 A driver for the silicon baseband tuner MT2266 from Microtune.
331
325comment "Miscellaneous devices" 332comment "Miscellaneous devices"
326 depends on DVB_CORE 333 depends on DVB_CORE
327 334
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index 156b062e02c4..217265ca2849 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -40,5 +40,6 @@ obj-$(CONFIG_DVB_TDA10086) += tda10086.o
40obj-$(CONFIG_DVB_TDA826X) += tda826x.o 40obj-$(CONFIG_DVB_TDA826X) += tda826x.o
41obj-$(CONFIG_DVB_TDA827X) += tda827x.o 41obj-$(CONFIG_DVB_TDA827X) += tda827x.o
42obj-$(CONFIG_DVB_TUNER_MT2060) += mt2060.o 42obj-$(CONFIG_DVB_TUNER_MT2060) += mt2060.o
43obj-$(CONFIG_DVB_TUNER_MT2266) += mt2266.o
43obj-$(CONFIG_DVB_TUNER_QT1010) += qt1010.o 44obj-$(CONFIG_DVB_TUNER_QT1010) += qt1010.o
44obj-$(CONFIG_DVB_TUA6100) += tua6100.o 45obj-$(CONFIG_DVB_TUA6100) += tua6100.o
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c
index aece458cfe12..c24189fcbc89 100644
--- a/drivers/media/dvb/frontends/dib7000p.c
+++ b/drivers/media/dvb/frontends/dib7000p.c
@@ -112,6 +112,11 @@ static int dib7000p_set_output_mode(struct dib7000p_state *state, int mode)
112 break; 112 break;
113 } 113 }
114 114
115 if (state->cfg.hostbus_diversity) {
116 ret |= dib7000p_write_word(state, 204, 1); // Diversity ?
117 ret |= dib7000p_write_word(state, 205, 0); // Diversity ?
118 }
119
115 if (state->cfg.output_mpeg2_in_188_bytes) 120 if (state->cfg.output_mpeg2_in_188_bytes)
116 smo_mode |= (1 << 5) ; 121 smo_mode |= (1 << 5) ;
117 122
diff --git a/drivers/media/dvb/frontends/dib7000p.h b/drivers/media/dvb/frontends/dib7000p.h
index 79465cf1aced..94829c1ed054 100644
--- a/drivers/media/dvb/frontends/dib7000p.h
+++ b/drivers/media/dvb/frontends/dib7000p.h
@@ -35,7 +35,7 @@ struct dib7000p_config {
35extern struct dvb_frontend * dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg); 35extern struct dvb_frontend * dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg);
36extern struct i2c_adapter * dib7000p_get_i2c_master(struct dvb_frontend *, enum dibx000_i2c_interface, int); 36extern struct i2c_adapter * dib7000p_get_i2c_master(struct dvb_frontend *, enum dibx000_i2c_interface, int);
37extern int dib7000pc_detection(struct i2c_adapter *i2c_adap); 37extern int dib7000pc_detection(struct i2c_adapter *i2c_adap);
38 38extern int dib7000p_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib7000p_config cfg[]);
39/* TODO 39/* TODO
40extern INT dib7000p_set_gpio(struct dibDemod *demod, UCHAR num, UCHAR dir, UCHAR val); 40extern INT dib7000p_set_gpio(struct dibDemod *demod, UCHAR num, UCHAR dir, UCHAR val);
41extern INT dib7000p_enable_vbg_voltage(struct dibDemod *demod); 41extern INT dib7000p_enable_vbg_voltage(struct dibDemod *demod);
diff --git a/drivers/media/dvb/frontends/mt2266.c b/drivers/media/dvb/frontends/mt2266.c
new file mode 100644
index 000000000000..145135778bce
--- /dev/null
+++ b/drivers/media/dvb/frontends/mt2266.c
@@ -0,0 +1,288 @@
1/*
2 * Driver for Microtune MT2266 "Direct conversion low power broadband tuner"
3 *
4 * Copyright (c) 2007 Olivier DANET <odanet@caramail.com>
5 *
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.
10 *
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.
15 */
16
17#include <linux/module.h>
18#include <linux/moduleparam.h>
19#include <linux/delay.h>
20#include <linux/dvb/frontend.h>
21#include <linux/i2c.h>
22
23#include "dvb_frontend.h"
24#include "mt2266.h"
25
26#define I2C_ADDRESS 0x60
27
28#define REG_PART_REV 0
29#define REG_TUNE 1
30#define REG_BAND 6
31#define REG_BANDWIDTH 8
32#define REG_LOCK 0x12
33
34#define PART_REV 0x85
35
36struct mt2266_priv {
37 struct mt2266_config *cfg;
38 struct i2c_adapter *i2c;
39
40 u32 frequency;
41 u32 bandwidth;
42};
43
44/* Here, frequencies are expressed in kiloHertz to avoid 32 bits overflows */
45
46static int debug;
47module_param(debug, int, 0644);
48MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
49
50#define dprintk(args...) do { if (debug) {printk(KERN_DEBUG "MT2266: " args); printk("\n"); }} while (0)
51
52// Reads a single register
53static int mt2266_readreg(struct mt2266_priv *priv, u8 reg, u8 *val)
54{
55 struct i2c_msg msg[2] = {
56 { .addr = priv->cfg->i2c_address, .flags = 0, .buf = &reg, .len = 1 },
57 { .addr = priv->cfg->i2c_address, .flags = I2C_M_RD, .buf = val, .len = 1 },
58 };
59 if (i2c_transfer(priv->i2c, msg, 2) != 2) {
60 printk(KERN_WARNING "MT2266 I2C read failed\n");
61 return -EREMOTEIO;
62 }
63 return 0;
64}
65
66// Writes a single register
67static int mt2266_writereg(struct mt2266_priv *priv, u8 reg, u8 val)
68{
69 u8 buf[2] = { reg, val };
70 struct i2c_msg msg = {
71 .addr = priv->cfg->i2c_address, .flags = 0, .buf = buf, .len = 2
72 };
73 if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
74 printk(KERN_WARNING "MT2266 I2C write failed\n");
75 return -EREMOTEIO;
76 }
77 return 0;
78}
79
80// Writes a set of consecutive registers
81static int mt2266_writeregs(struct mt2266_priv *priv,u8 *buf, u8 len)
82{
83 struct i2c_msg msg = {
84 .addr = priv->cfg->i2c_address, .flags = 0, .buf = buf, .len = len
85 };
86 if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
87 printk(KERN_WARNING "MT2266 I2C write failed (len=%i)\n",(int)len);
88 return -EREMOTEIO;
89 }
90 return 0;
91}
92
93// Initialisation sequences
94static u8 mt2266_init1[] = {
95 REG_TUNE,
96 0x00, 0x00, 0x28, 0x00, 0x52, 0x99, 0x3f };
97
98static u8 mt2266_init2[] = {
99 0x17, 0x6d, 0x71, 0x61, 0xc0, 0xbf, 0xff, 0xdc, 0x00, 0x0a,
100 0xd4, 0x03, 0x64, 0x64, 0x64, 0x64, 0x22, 0xaa, 0xf2, 0x1e, 0x80, 0x14, 0x01, 0x01, 0x01, 0x01,
101 0x01, 0x01, 0x7f, 0x5e, 0x3f, 0xff, 0xff, 0xff, 0x00, 0x77, 0x0f, 0x2d };
102
103static u8 mt2266_init_8mhz[] = {
104 REG_BANDWIDTH,
105 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 };
106
107static u8 mt2266_init_7mhz[] = {
108 REG_BANDWIDTH,
109 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32 };
110
111static u8 mt2266_init_6mhz[] = {
112 REG_BANDWIDTH,
113 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7 };
114
115#define FREF 30000 // Quartz oscillator 30 MHz
116
117static int mt2266_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
118{
119 struct mt2266_priv *priv;
120 int ret=0;
121 u32 freq;
122 u32 tune;
123 u8 lnaband;
124 u8 b[10];
125 int i;
126
127 priv = fe->tuner_priv;
128
129 mt2266_writereg(priv,0x17,0x6d);
130 mt2266_writereg(priv,0x1c,0xff);
131
132 freq = params->frequency / 1000; // Hz -> kHz
133 priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0;
134 priv->frequency = freq * 1000;
135 tune=2 * freq * (8192/16) / (FREF/16);
136
137 if (freq <= 495000) lnaband = 0xEE; else
138 if (freq <= 525000) lnaband = 0xDD; else
139 if (freq <= 550000) lnaband = 0xCC; else
140 if (freq <= 580000) lnaband = 0xBB; else
141 if (freq <= 605000) lnaband = 0xAA; else
142 if (freq <= 630000) lnaband = 0x99; else
143 if (freq <= 655000) lnaband = 0x88; else
144 if (freq <= 685000) lnaband = 0x77; else
145 if (freq <= 710000) lnaband = 0x66; else
146 if (freq <= 735000) lnaband = 0x55; else
147 if (freq <= 765000) lnaband = 0x44; else
148 if (freq <= 802000) lnaband = 0x33; else
149 if (freq <= 840000) lnaband = 0x22; else lnaband = 0x11;
150
151 msleep(100);
152 mt2266_writeregs(priv,(params->u.ofdm.bandwidth==BANDWIDTH_6_MHZ)?mt2266_init_6mhz:
153 (params->u.ofdm.bandwidth==BANDWIDTH_7_MHZ)?mt2266_init_7mhz:
154 mt2266_init_8mhz,sizeof(mt2266_init_8mhz));
155
156 b[0] = REG_TUNE;
157 b[1] = (tune >> 8) & 0x1F;
158 b[2] = tune & 0xFF;
159 b[3] = tune >> 13;
160 mt2266_writeregs(priv,b,4);
161
162 dprintk("set_parms: tune=%d band=%d\n",(int)tune,(int)lnaband);
163 dprintk("set_parms: [1..3]: %2x %2x %2x",(int)b[1],(int)b[2],(int)b[3]);
164
165 b[0] = 0x05;
166 b[1] = 0x62;
167 b[2] = lnaband;
168 mt2266_writeregs(priv,b,3);
169
170 //Waits for pll lock or timeout
171 i = 0;
172 do {
173 mt2266_readreg(priv,REG_LOCK,b);
174 if ((b[0] & 0x40)==0x40)
175 break;
176 msleep(10);
177 i++;
178 } while (i<10);
179 dprintk("Lock when i=%i\n",(int)i);
180 return ret;
181}
182
183static void mt2266_calibrate(struct mt2266_priv *priv)
184{
185 mt2266_writereg(priv,0x11,0x03);
186 mt2266_writereg(priv,0x11,0x01);
187
188 mt2266_writeregs(priv,mt2266_init1,sizeof(mt2266_init1));
189 mt2266_writeregs(priv,mt2266_init2,sizeof(mt2266_init2));
190
191 mt2266_writereg(priv,0x33,0x5e);
192 mt2266_writereg(priv,0x10,0x10);
193 mt2266_writereg(priv,0x10,0x00);
194
195 mt2266_writeregs(priv,mt2266_init_8mhz,sizeof(mt2266_init_8mhz));
196
197 msleep(25);
198 mt2266_writereg(priv,0x17,0x6d);
199 mt2266_writereg(priv,0x1c,0x00);
200 msleep(75);
201 mt2266_writereg(priv,0x17,0x6d);
202 mt2266_writereg(priv,0x1c,0xff);
203}
204
205static int mt2266_get_frequency(struct dvb_frontend *fe, u32 *frequency)
206{
207 struct mt2266_priv *priv = fe->tuner_priv;
208 *frequency = priv->frequency;
209 return 0;
210}
211
212static int mt2266_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
213{
214 struct mt2266_priv *priv = fe->tuner_priv;
215 *bandwidth = priv->bandwidth;
216 return 0;
217}
218
219static int mt2266_init(struct dvb_frontend *fe)
220{
221 struct mt2266_priv *priv = fe->tuner_priv;
222 mt2266_writereg(priv,0x17,0x6d);
223 mt2266_writereg(priv,0x1c,0xff);
224 return 0;
225}
226
227static int mt2266_sleep(struct dvb_frontend *fe)
228{
229 struct mt2266_priv *priv = fe->tuner_priv;
230 mt2266_writereg(priv,0x17,0x6d);
231 mt2266_writereg(priv,0x1c,0x00);
232 return 0;
233}
234
235static int mt2266_release(struct dvb_frontend *fe)
236{
237 kfree(fe->tuner_priv);
238 fe->tuner_priv = NULL;
239 return 0;
240}
241
242static const struct dvb_tuner_ops mt2266_tuner_ops = {
243 .info = {
244 .name = "Microtune MT2266",
245 .frequency_min = 470000000,
246 .frequency_max = 860000000,
247 .frequency_step = 50000,
248 },
249 .release = mt2266_release,
250 .init = mt2266_init,
251 .sleep = mt2266_sleep,
252 .set_params = mt2266_set_params,
253 .get_frequency = mt2266_get_frequency,
254 .get_bandwidth = mt2266_get_bandwidth
255};
256
257struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg)
258{
259 struct mt2266_priv *priv = NULL;
260 u8 id = 0;
261
262 priv = kzalloc(sizeof(struct mt2266_priv), GFP_KERNEL);
263 if (priv == NULL)
264 return NULL;
265
266 priv->cfg = cfg;
267 priv->i2c = i2c;
268
269 if (mt2266_readreg(priv,0,&id) != 0) {
270 kfree(priv);
271 return NULL;
272 }
273 if (id != PART_REV) {
274 kfree(priv);
275 return NULL;
276 }
277 printk(KERN_INFO "MT2266: successfully identified\n");
278 memcpy(&fe->ops.tuner_ops, &mt2266_tuner_ops, sizeof(struct dvb_tuner_ops));
279
280 fe->tuner_priv = priv;
281 mt2266_calibrate(priv);
282 return fe;
283}
284EXPORT_SYMBOL(mt2266_attach);
285
286MODULE_AUTHOR("Olivier DANET");
287MODULE_DESCRIPTION("Microtune MT2266 silicon tuner driver");
288MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/mt2266.h b/drivers/media/dvb/frontends/mt2266.h
new file mode 100644
index 000000000000..f31dd613ad37
--- /dev/null
+++ b/drivers/media/dvb/frontends/mt2266.h
@@ -0,0 +1,37 @@
1/*
2 * Driver for Microtune MT2266 "Direct conversion low power broadband tuner"
3 *
4 * Copyright (c) 2007 Olivier DANET <odanet@caramail.com>
5 *
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.
10 *
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.
15 */
16
17#ifndef MT2266_H
18#define MT2266_H
19
20struct dvb_frontend;
21struct i2c_adapter;
22
23struct mt2266_config {
24 u8 i2c_address;
25};
26
27#if defined(CONFIG_DVB_TUNER_MT2266) || (defined(CONFIG_DVB_TUNER_MT2266_MODULE) && defined(MODULE))
28extern struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg);
29#else
30static inline struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg)
31{
32 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
33 return NULL;
34}
35#endif // CONFIG_DVB_TUNER_MT2266
36
37#endif