2 * Driver for the Auvitek USB bridge
4 * Copyright (c) 2008 Steven Toth <stoth@linuxtv.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
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "au0828-cards.h"
25 #include "media/tuner.h"
26 #include "media/v4l2-common.h"
28 void hvr950q_cs5340_audio(void *priv, int enable)
30 /* Because the HVR-950q shares an i2s bus between the cs5340 and the
31 au8522, we need to hold cs5340 in reset when using the au8522 */
32 struct au0828_dev *dev = priv;
34 au0828_set(dev, REG_000, 0x10);
36 au0828_clear(dev, REG_000, 0x10);
39 struct au0828_board au0828_boards[] = {
40 [AU0828_BOARD_UNKNOWN] = {
41 .name = "Unknown board",
43 .tuner_addr = ADDR_UNSET,
45 [AU0828_BOARD_HAUPPAUGE_HVR850] = {
46 .name = "Hauppauge HVR850",
47 .tuner_type = TUNER_XC5000,
51 .type = AU0828_VMUX_TELEVISION,
52 .vmux = AU8522_COMPOSITE_CH4_SIF,
53 .amux = AU8522_AUDIO_SIF,
56 .type = AU0828_VMUX_COMPOSITE,
57 .vmux = AU8522_COMPOSITE_CH1,
58 .amux = AU8522_AUDIO_NONE,
59 .audio_setup = hvr950q_cs5340_audio,
62 .type = AU0828_VMUX_SVIDEO,
63 .vmux = AU8522_SVIDEO_CH13,
64 .amux = AU8522_AUDIO_NONE,
65 .audio_setup = hvr950q_cs5340_audio,
69 [AU0828_BOARD_HAUPPAUGE_HVR950Q] = {
70 .name = "Hauppauge HVR950Q",
71 .tuner_type = TUNER_XC5000,
75 .type = AU0828_VMUX_TELEVISION,
76 .vmux = AU8522_COMPOSITE_CH4_SIF,
77 .amux = AU8522_AUDIO_SIF,
80 .type = AU0828_VMUX_COMPOSITE,
81 .vmux = AU8522_COMPOSITE_CH1,
82 .amux = AU8522_AUDIO_NONE,
83 .audio_setup = hvr950q_cs5340_audio,
86 .type = AU0828_VMUX_SVIDEO,
87 .vmux = AU8522_SVIDEO_CH13,
88 .amux = AU8522_AUDIO_NONE,
89 .audio_setup = hvr950q_cs5340_audio,
93 [AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL] = {
94 .name = "Hauppauge HVR950Q rev xxF8",
96 .tuner_addr = ADDR_UNSET,
98 [AU0828_BOARD_DVICO_FUSIONHDTV7] = {
99 .name = "DViCO FusionHDTV USB",
101 .tuner_addr = ADDR_UNSET,
103 [AU0828_BOARD_HAUPPAUGE_WOODBURY] = {
104 .name = "Hauppauge Woodbury",
106 .tuner_addr = ADDR_UNSET,
110 /* Tuner callback function for au0828 boards. Currently only needed
111 * for HVR1500Q, which has an xc5000 tuner.
113 int au0828_tuner_callback(void *priv, int component, int command, int arg)
115 struct au0828_dev *dev = priv;
117 dprintk(1, "%s()\n", __func__);
119 switch (dev->boardnr) {
120 case AU0828_BOARD_HAUPPAUGE_HVR850:
121 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
122 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
123 case AU0828_BOARD_DVICO_FUSIONHDTV7:
125 /* Tuner Reset Command from xc5000 */
126 /* Drive the tuner into reset and out */
127 au0828_clear(dev, REG_001, 2);
129 au0828_set(dev, REG_001, 2);
134 "%s(): Unknown command.\n", __func__);
140 return 0; /* Should never be here */
143 static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)
147 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data);
148 dev->board.tuner_type = tv.tuner_type;
150 /* Make sure we support the board model */
152 case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */
153 case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
154 case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
155 case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
156 case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
157 case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
158 case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
159 case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */
160 case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */
163 printk(KERN_WARNING "%s: warning: "
164 "unknown hauppauge model #%d\n", __func__, tv.model);
168 printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
172 void au0828_card_setup(struct au0828_dev *dev)
174 static u8 eeprom[256];
175 struct tuner_setup tun_setup;
176 struct v4l2_subdev *sd;
177 unsigned int mode_mask = T_ANALOG_TV |
180 dprintk(1, "%s()\n", __func__);
182 memcpy(&dev->board, &au0828_boards[dev->boardnr], sizeof(dev->board));
184 if (dev->i2c_rc == 0) {
185 dev->i2c_client.addr = 0xa0 >> 1;
186 tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom));
189 switch (dev->boardnr) {
190 case AU0828_BOARD_HAUPPAUGE_HVR850:
191 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
192 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
193 case AU0828_BOARD_HAUPPAUGE_WOODBURY:
194 if (dev->i2c_rc == 0)
195 hauppauge_eeprom(dev, eeprom+0xa0);
199 if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {
200 /* Load the analog demodulator driver (note this would need to
201 be abstracted out if we ever need to support a different
203 sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "au8522", "au8522",
206 printk(KERN_ERR "analog subdev registration failed\n");
210 if (dev->board.tuner_type != TUNER_ABSENT) {
211 /* Load the tuner module, which does the attach */
212 sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner",
213 dev->board.tuner_addr);
215 printk(KERN_ERR "tuner subdev registration fail\n");
217 tun_setup.mode_mask = mode_mask;
218 tun_setup.type = dev->board.tuner_type;
219 tun_setup.addr = dev->board.tuner_addr;
220 tun_setup.tuner_callback = au0828_tuner_callback;
221 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr,
227 * The bridge has between 8 and 12 gpios.
228 * Regs 1 and 0 deal with output enables.
229 * Regs 3 and 2 deal with direction.
231 void au0828_gpio_setup(struct au0828_dev *dev)
233 dprintk(1, "%s()\n", __func__);
235 switch (dev->boardnr) {
236 case AU0828_BOARD_HAUPPAUGE_HVR850:
237 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
238 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
239 case AU0828_BOARD_HAUPPAUGE_WOODBURY:
242 * 5 - AU8522 Demodulator
249 au0828_write(dev, REG_003, 0x02);
250 au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10);
251 au0828_write(dev, REG_001, 0x0);
252 au0828_write(dev, REG_000, 0x0);
255 /* Out of reset (leave the cs5340 in reset until needed) */
256 au0828_write(dev, REG_003, 0x02);
257 au0828_write(dev, REG_001, 0x02);
258 au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10);
259 au0828_write(dev, REG_000, 0x80 | 0x40 | 0x20);
263 case AU0828_BOARD_DVICO_FUSIONHDTV7:
266 * 8 - AU8522 Demodulator
271 au0828_write(dev, REG_003, 0x02);
272 au0828_write(dev, REG_002, 0xa0);
273 au0828_write(dev, REG_001, 0x0);
274 au0828_write(dev, REG_000, 0x0);
278 au0828_write(dev, REG_003, 0x02);
279 au0828_write(dev, REG_002, 0xa0);
280 au0828_write(dev, REG_001, 0x02);
281 au0828_write(dev, REG_000, 0xa0);
287 /* table of devices that work with this driver */
288 struct usb_device_id au0828_usb_id_table[] = {
289 { USB_DEVICE(0x2040, 0x7200),
290 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
291 { USB_DEVICE(0x2040, 0x7240),
292 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 },
293 { USB_DEVICE(0x0fe9, 0xd620),
294 .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 },
295 { USB_DEVICE(0x2040, 0x7210),
296 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
297 { USB_DEVICE(0x2040, 0x7217),
298 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
299 { USB_DEVICE(0x2040, 0x721b),
300 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
301 { USB_DEVICE(0x2040, 0x721e),
302 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
303 { USB_DEVICE(0x2040, 0x721f),
304 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
305 { USB_DEVICE(0x2040, 0x7280),
306 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
307 { USB_DEVICE(0x0fd9, 0x0008),
308 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
309 { USB_DEVICE(0x2040, 0x7201),
310 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
311 { USB_DEVICE(0x2040, 0x7211),
312 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
313 { USB_DEVICE(0x2040, 0x7281),
314 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
315 { USB_DEVICE(0x2040, 0x8200),
316 .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY },
320 MODULE_DEVICE_TABLE(usb, au0828_usb_id_table);