1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include "au0828.h"
23#include "au0828-cards.h"
24#include "au8522.h"
25#include "media/tuner.h"
26#include "media/v4l2-common.h"
27
28static void hvr950q_cs5340_audio(void *priv, int enable)
29{
30
31
32 struct au0828_dev *dev = priv;
33 if (enable == 1)
34 au0828_set(dev, REG_000, 0x10);
35 else
36 au0828_clear(dev, REG_000, 0x10);
37}
38
39struct au0828_board au0828_boards[] = {
40 [AU0828_BOARD_UNKNOWN] = {
41 .name = "Unknown board",
42 .tuner_type = UNSET,
43 .tuner_addr = ADDR_UNSET,
44 },
45 [AU0828_BOARD_HAUPPAUGE_HVR850] = {
46 .name = "Hauppauge HVR850",
47 .tuner_type = TUNER_XC5000,
48 .tuner_addr = 0x61,
49 .i2c_clk_divider = AU0828_I2C_CLK_20KHZ,
50 .input = {
51 {
52 .type = AU0828_VMUX_TELEVISION,
53 .vmux = AU8522_COMPOSITE_CH4_SIF,
54 .amux = AU8522_AUDIO_SIF,
55 },
56 {
57 .type = AU0828_VMUX_COMPOSITE,
58 .vmux = AU8522_COMPOSITE_CH1,
59 .amux = AU8522_AUDIO_NONE,
60 .audio_setup = hvr950q_cs5340_audio,
61 },
62 {
63 .type = AU0828_VMUX_SVIDEO,
64 .vmux = AU8522_SVIDEO_CH13,
65 .amux = AU8522_AUDIO_NONE,
66 .audio_setup = hvr950q_cs5340_audio,
67 },
68 },
69 },
70 [AU0828_BOARD_HAUPPAUGE_HVR950Q] = {
71 .name = "Hauppauge HVR950Q",
72 .tuner_type = TUNER_XC5000,
73 .tuner_addr = 0x61,
74
75
76
77
78
79
80 .i2c_clk_divider = AU0828_I2C_CLK_20KHZ,
81 .input = {
82 {
83 .type = AU0828_VMUX_TELEVISION,
84 .vmux = AU8522_COMPOSITE_CH4_SIF,
85 .amux = AU8522_AUDIO_SIF,
86 },
87 {
88 .type = AU0828_VMUX_COMPOSITE,
89 .vmux = AU8522_COMPOSITE_CH1,
90 .amux = AU8522_AUDIO_NONE,
91 .audio_setup = hvr950q_cs5340_audio,
92 },
93 {
94 .type = AU0828_VMUX_SVIDEO,
95 .vmux = AU8522_SVIDEO_CH13,
96 .amux = AU8522_AUDIO_NONE,
97 .audio_setup = hvr950q_cs5340_audio,
98 },
99 },
100 },
101 [AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL] = {
102 .name = "Hauppauge HVR950Q rev xxF8",
103 .tuner_type = UNSET,
104 .tuner_addr = ADDR_UNSET,
105 .i2c_clk_divider = AU0828_I2C_CLK_250KHZ,
106 },
107 [AU0828_BOARD_DVICO_FUSIONHDTV7] = {
108 .name = "DViCO FusionHDTV USB",
109 .tuner_type = UNSET,
110 .tuner_addr = ADDR_UNSET,
111 .i2c_clk_divider = AU0828_I2C_CLK_20KHZ,
112 },
113 [AU0828_BOARD_HAUPPAUGE_WOODBURY] = {
114 .name = "Hauppauge Woodbury",
115 .tuner_type = UNSET,
116 .tuner_addr = ADDR_UNSET,
117 .i2c_clk_divider = AU0828_I2C_CLK_250KHZ,
118 },
119};
120
121
122
123
124int au0828_tuner_callback(void *priv, int component, int command, int arg)
125{
126 struct au0828_dev *dev = priv;
127
128 dprintk(1, "%s()\n", __func__);
129
130 switch (dev->boardnr) {
131 case AU0828_BOARD_HAUPPAUGE_HVR850:
132 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
133 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
134 case AU0828_BOARD_DVICO_FUSIONHDTV7:
135 if (command == 0) {
136
137
138 au0828_clear(dev, REG_001, 2);
139 mdelay(10);
140 au0828_set(dev, REG_001, 2);
141 mdelay(10);
142 return 0;
143 } else {
144 printk(KERN_ERR
145 "%s(): Unknown command.\n", __func__);
146 return -EINVAL;
147 }
148 break;
149 }
150
151 return 0;
152}
153
154static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)
155{
156 struct tveeprom tv;
157
158 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data);
159 dev->board.tuner_type = tv.tuner_type;
160
161
162 switch (tv.model) {
163 case 72000:
164 case 72001:
165 case 72101:
166 case 72201:
167 case 72211:
168 case 72221:
169 case 72231:
170 case 72241:
171 case 72251:
172 case 72261:
173 case 72271:
174 case 72281:
175 case 72301:
176 case 72500:
177 break;
178 default:
179 printk(KERN_WARNING "%s: warning: "
180 "unknown hauppauge model #%d\n", __func__, tv.model);
181 break;
182 }
183
184 printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
185 __func__, tv.model);
186}
187
188void au0828_card_analog_fe_setup(struct au0828_dev *dev);
189
190void au0828_card_setup(struct au0828_dev *dev)
191{
192 static u8 eeprom[256];
193
194 dprintk(1, "%s()\n", __func__);
195
196 dev->board = au0828_boards[dev->boardnr];
197
198 if (dev->i2c_rc == 0) {
199 dev->i2c_client.addr = 0xa0 >> 1;
200 tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom));
201 }
202
203 switch (dev->boardnr) {
204 case AU0828_BOARD_HAUPPAUGE_HVR850:
205 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
206 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
207 case AU0828_BOARD_HAUPPAUGE_WOODBURY:
208 if (dev->i2c_rc == 0)
209 hauppauge_eeprom(dev, eeprom+0xa0);
210 break;
211 }
212
213 au0828_card_analog_fe_setup(dev);
214}
215
216void au0828_card_analog_fe_setup(struct au0828_dev *dev)
217{
218#ifdef CONFIG_VIDEO_AU0828_V4L2
219 struct tuner_setup tun_setup;
220 struct v4l2_subdev *sd;
221 unsigned int mode_mask = T_ANALOG_TV;
222
223 if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {
224
225
226
227 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
228 "au8522", 0x8e >> 1, NULL);
229 if (sd == NULL)
230 printk(KERN_ERR "analog subdev registration failed\n");
231 }
232
233
234 if (dev->board.tuner_type != TUNER_ABSENT) {
235
236 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
237 "tuner", dev->board.tuner_addr, NULL);
238 if (sd == NULL)
239 printk(KERN_ERR "tuner subdev registration fail\n");
240
241 tun_setup.mode_mask = mode_mask;
242 tun_setup.type = dev->board.tuner_type;
243 tun_setup.addr = dev->board.tuner_addr;
244 tun_setup.tuner_callback = au0828_tuner_callback;
245 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr,
246 &tun_setup);
247 }
248#endif
249}
250
251
252
253
254
255
256void au0828_gpio_setup(struct au0828_dev *dev)
257{
258 dprintk(1, "%s()\n", __func__);
259
260 switch (dev->boardnr) {
261 case AU0828_BOARD_HAUPPAUGE_HVR850:
262 case AU0828_BOARD_HAUPPAUGE_HVR950Q:
263 case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
264 case AU0828_BOARD_HAUPPAUGE_WOODBURY:
265
266
267
268
269
270
271
272
273
274
275
276 au0828_write(dev, REG_003, 0x02);
277 au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10);
278
279
280 au0828_write(dev, REG_001, 0x0);
281 au0828_write(dev, REG_000, 0x0);
282 msleep(50);
283
284
285 au0828_write(dev, REG_000, 0x80);
286 msleep(50);
287
288
289
290 au0828_write(dev, REG_001, 0x02);
291 au0828_write(dev, REG_000, 0x80 | 0x20);
292
293 msleep(250);
294 break;
295 case AU0828_BOARD_DVICO_FUSIONHDTV7:
296
297
298
299
300
301
302
303 au0828_write(dev, REG_003, 0x02);
304 au0828_write(dev, REG_002, 0xa0);
305 au0828_write(dev, REG_001, 0x0);
306 au0828_write(dev, REG_000, 0x0);
307 msleep(100);
308
309
310 au0828_write(dev, REG_003, 0x02);
311 au0828_write(dev, REG_002, 0xa0);
312 au0828_write(dev, REG_001, 0x02);
313 au0828_write(dev, REG_000, 0xa0);
314 msleep(250);
315 break;
316 }
317}
318
319
320struct usb_device_id au0828_usb_id_table[] = {
321 { USB_DEVICE(0x2040, 0x7200),
322 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
323 { USB_DEVICE(0x2040, 0x7240),
324 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 },
325 { USB_DEVICE(0x0fe9, 0xd620),
326 .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 },
327 { USB_DEVICE(0x2040, 0x7210),
328 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
329 { USB_DEVICE(0x2040, 0x7217),
330 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
331 { USB_DEVICE(0x2040, 0x721b),
332 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
333 { USB_DEVICE(0x2040, 0x721e),
334 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
335 { USB_DEVICE(0x2040, 0x721f),
336 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
337 { USB_DEVICE(0x2040, 0x7280),
338 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
339 { USB_DEVICE(0x0fd9, 0x0008),
340 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
341 { USB_DEVICE(0x2040, 0x7201),
342 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
343 { USB_DEVICE(0x2040, 0x7211),
344 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
345 { USB_DEVICE(0x2040, 0x7281),
346 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
347 { USB_DEVICE(0x05e1, 0x0480),
348 .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY },
349 { USB_DEVICE(0x2040, 0x8200),
350 .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY },
351 { USB_DEVICE(0x2040, 0x7260),
352 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
353 { USB_DEVICE(0x2040, 0x7213),
354 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
355 { USB_DEVICE(0x2040, 0x7270),
356 .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
357 { },
358};
359
360MODULE_DEVICE_TABLE(usb, au0828_usb_id_table);
361