1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for the Auvitek USB bridge
5 * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org>
9 #include "au0828-cards.h"
11 #include "media/tuner.h"
12 #include "media/v4l2-common.h"
14 static void hvr950q_cs5340_audio(void *priv
, int enable
)
16 /* Because the HVR-950q shares an i2s bus between the cs5340 and the
17 au8522, we need to hold cs5340 in reset when using the au8522 */
18 struct au0828_dev
*dev
= priv
;
20 au0828_set(dev
, REG_000
, 0x10);
22 au0828_clear(dev
, REG_000
, 0x10);
26 * WARNING: There's a quirks table at sound/usb/quirks-table.h
27 * that should also be updated every time a new device with V4L2 support
30 struct au0828_board au0828_boards
[] = {
31 [AU0828_BOARD_UNKNOWN
] = {
32 .name
= "Unknown board",
34 .tuner_addr
= ADDR_UNSET
,
36 [AU0828_BOARD_HAUPPAUGE_HVR850
] = {
37 .name
= "Hauppauge HVR850",
38 .tuner_type
= TUNER_XC5000
,
42 .i2c_clk_divider
= AU0828_I2C_CLK_250KHZ
,
45 .type
= AU0828_VMUX_TELEVISION
,
46 .vmux
= AU8522_COMPOSITE_CH4_SIF
,
47 .amux
= AU8522_AUDIO_SIF
,
50 .type
= AU0828_VMUX_COMPOSITE
,
51 .vmux
= AU8522_COMPOSITE_CH1
,
52 .amux
= AU8522_AUDIO_NONE
,
53 .audio_setup
= hvr950q_cs5340_audio
,
56 .type
= AU0828_VMUX_SVIDEO
,
57 .vmux
= AU8522_SVIDEO_CH13
,
58 .amux
= AU8522_AUDIO_NONE
,
59 .audio_setup
= hvr950q_cs5340_audio
,
63 [AU0828_BOARD_HAUPPAUGE_HVR950Q
] = {
64 .name
= "Hauppauge HVR950Q",
65 .tuner_type
= TUNER_XC5000
,
69 .i2c_clk_divider
= AU0828_I2C_CLK_250KHZ
,
72 .type
= AU0828_VMUX_TELEVISION
,
73 .vmux
= AU8522_COMPOSITE_CH4_SIF
,
74 .amux
= AU8522_AUDIO_SIF
,
77 .type
= AU0828_VMUX_COMPOSITE
,
78 .vmux
= AU8522_COMPOSITE_CH1
,
79 .amux
= AU8522_AUDIO_NONE
,
80 .audio_setup
= hvr950q_cs5340_audio
,
83 .type
= AU0828_VMUX_SVIDEO
,
84 .vmux
= AU8522_SVIDEO_CH13
,
85 .amux
= AU8522_AUDIO_NONE
,
86 .audio_setup
= hvr950q_cs5340_audio
,
90 [AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL
] = {
91 .name
= "Hauppauge HVR950Q rev xxF8",
92 .tuner_type
= TUNER_XC5000
,
94 .i2c_clk_divider
= AU0828_I2C_CLK_250KHZ
,
96 [AU0828_BOARD_DVICO_FUSIONHDTV7
] = {
97 .name
= "DViCO FusionHDTV USB",
98 .tuner_type
= TUNER_XC5000
,
100 .i2c_clk_divider
= AU0828_I2C_CLK_250KHZ
,
102 [AU0828_BOARD_HAUPPAUGE_WOODBURY
] = {
103 .name
= "Hauppauge Woodbury",
104 .tuner_type
= TUNER_NXP_TDA18271
,
106 .i2c_clk_divider
= AU0828_I2C_CLK_250KHZ
,
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);
133 pr_err("%s(): Unknown command.\n", __func__
);
139 return 0; /* Should never be here */
142 static void hauppauge_eeprom(struct au0828_dev
*dev
, u8
*eeprom_data
)
146 tveeprom_hauppauge_analog(&tv
, eeprom_data
);
147 dev
->board
.tuner_type
= tv
.tuner_type
;
149 /* Make sure we support the board model */
151 case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */
152 case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
153 case 72101: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
154 case 72201: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
155 case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
156 case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
157 case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */
158 case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
159 case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */
160 case 72261: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
161 case 72271: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
162 case 72281: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */
163 case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */
164 case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */
167 pr_warn("%s: warning: unknown hauppauge model #%d\n",
172 pr_info("%s: hauppauge eeprom: model=%d\n",
176 void au0828_card_analog_fe_setup(struct au0828_dev
*dev
);
178 void au0828_card_setup(struct au0828_dev
*dev
)
180 static u8 eeprom
[256];
182 dprintk(1, "%s()\n", __func__
);
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 au0828_card_analog_fe_setup(dev
);
202 void au0828_card_analog_fe_setup(struct au0828_dev
*dev
)
204 #ifdef CONFIG_VIDEO_AU0828_V4L2
205 struct tuner_setup tun_setup
;
206 struct v4l2_subdev
*sd
;
207 unsigned int mode_mask
= T_ANALOG_TV
;
209 if (AUVI_INPUT(0).type
!= AU0828_VMUX_UNDEFINED
) {
210 /* Load the analog demodulator driver (note this would need to
211 be abstracted out if we ever need to support a different
213 sd
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
, &dev
->i2c_adap
,
214 "au8522", 0x8e >> 1, NULL
);
216 pr_err("analog subdev registration failed\n");
220 if (dev
->board
.tuner_type
!= TUNER_ABSENT
&& dev
->board
.has_analog
) {
221 /* Load the tuner module, which does the attach */
222 sd
= v4l2_i2c_new_subdev(&dev
->v4l2_dev
, &dev
->i2c_adap
,
223 "tuner", dev
->board
.tuner_addr
, NULL
);
225 pr_err("tuner subdev registration fail\n");
227 tun_setup
.mode_mask
= mode_mask
;
228 tun_setup
.type
= dev
->board
.tuner_type
;
229 tun_setup
.addr
= dev
->board
.tuner_addr
;
230 tun_setup
.tuner_callback
= au0828_tuner_callback
;
231 v4l2_device_call_all(&dev
->v4l2_dev
, 0, tuner
, s_type_addr
,
238 * The bridge has between 8 and 12 gpios.
239 * Regs 1 and 0 deal with output enables.
240 * Regs 3 and 2 deal with direction.
242 void au0828_gpio_setup(struct au0828_dev
*dev
)
244 dprintk(1, "%s()\n", __func__
);
246 switch (dev
->boardnr
) {
247 case AU0828_BOARD_HAUPPAUGE_HVR850
:
248 case AU0828_BOARD_HAUPPAUGE_HVR950Q
:
249 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL
:
250 case AU0828_BOARD_HAUPPAUGE_WOODBURY
:
253 * 5 - AU8522 Demodulator
259 /* Set relevant GPIOs as outputs (leave the EEPROM W/P
260 as an input since we will never touch it and it has
262 au0828_write(dev
, REG_003
, 0x02);
263 au0828_write(dev
, REG_002
, 0x80 | 0x20 | 0x10);
266 au0828_write(dev
, REG_001
, 0x0);
267 au0828_write(dev
, REG_000
, 0x0);
270 /* Bring power supply out of reset */
271 au0828_write(dev
, REG_000
, 0x80);
274 /* Bring xc5000 and au8522 out of reset (leave the
275 cs5340 in reset until needed) */
276 au0828_write(dev
, REG_001
, 0x02); /* xc5000 */
277 au0828_write(dev
, REG_000
, 0x80 | 0x20); /* PS + au8522 */
281 case AU0828_BOARD_DVICO_FUSIONHDTV7
:
284 * 8 - AU8522 Demodulator
289 au0828_write(dev
, REG_003
, 0x02);
290 au0828_write(dev
, REG_002
, 0xa0);
291 au0828_write(dev
, REG_001
, 0x0);
292 au0828_write(dev
, REG_000
, 0x0);
296 au0828_write(dev
, REG_003
, 0x02);
297 au0828_write(dev
, REG_002
, 0xa0);
298 au0828_write(dev
, REG_001
, 0x02);
299 au0828_write(dev
, REG_000
, 0xa0);
305 /* table of devices that work with this driver */
306 struct usb_device_id au0828_usb_id_table
[] = {
307 { USB_DEVICE(0x2040, 0x7200),
308 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
309 { USB_DEVICE(0x2040, 0x7240),
310 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR850
},
311 { USB_DEVICE(0x0fe9, 0xd620),
312 .driver_info
= AU0828_BOARD_DVICO_FUSIONHDTV7
},
313 { USB_DEVICE(0x2040, 0x7210),
314 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
315 { USB_DEVICE(0x2040, 0x7217),
316 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
317 { USB_DEVICE(0x2040, 0x721b),
318 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
319 { USB_DEVICE(0x2040, 0x721e),
320 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
321 { USB_DEVICE(0x2040, 0x721f),
322 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
323 { USB_DEVICE(0x2040, 0x7280),
324 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
325 { USB_DEVICE(0x0fd9, 0x0008),
326 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
327 { USB_DEVICE(0x2040, 0x7201),
328 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL
},
329 { USB_DEVICE(0x2040, 0x7211),
330 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL
},
331 { USB_DEVICE(0x2040, 0x7281),
332 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL
},
333 { USB_DEVICE(0x05e1, 0x0480),
334 .driver_info
= AU0828_BOARD_HAUPPAUGE_WOODBURY
},
335 { USB_DEVICE(0x2040, 0x8200),
336 .driver_info
= AU0828_BOARD_HAUPPAUGE_WOODBURY
},
337 { USB_DEVICE(0x2040, 0x7260),
338 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
339 { USB_DEVICE(0x2040, 0x7213),
340 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
341 { USB_DEVICE(0x2040, 0x7270),
342 .driver_info
= AU0828_BOARD_HAUPPAUGE_HVR950Q
},
346 MODULE_DEVICE_TABLE(usb
, au0828_usb_id_table
);