Commit | Line | Data |
---|---|---|
265a6510 ST |
1 | /* |
2 | * Driver for the Auvitek USB bridge | |
3 | * | |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.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 | * | |
15 | * GNU General Public License for more details. | |
16 | * | |
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. | |
20 | */ | |
21 | ||
22 | #include "au0828.h" | |
23 | #include "au0828-cards.h" | |
24 | ||
265a6510 ST |
25 | struct au0828_board au0828_boards[] = { |
26 | [AU0828_BOARD_UNKNOWN] = { | |
27 | .name = "Unknown board", | |
28 | }, | |
29 | [AU0828_BOARD_HAUPPAUGE_HVR850] = { | |
30 | .name = "Hauppauge HVR850", | |
31 | }, | |
32 | [AU0828_BOARD_HAUPPAUGE_HVR950Q] = { | |
33 | .name = "Hauppauge HVR950Q", | |
34 | }, | |
59d27521 MK |
35 | [AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL] = { |
36 | .name = "Hauppauge HVR950Q rev xxF8", | |
37 | }, | |
265a6510 ST |
38 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { |
39 | .name = "DViCO FusionHDTV USB", | |
40 | }, | |
8e8bd229 MK |
41 | [AU0828_BOARD_HAUPPAUGE_WOODBURY] = { |
42 | .name = "Hauppauge Woodbury", | |
43 | }, | |
265a6510 | 44 | }; |
265a6510 ST |
45 | |
46 | /* Tuner callback function for au0828 boards. Currently only needed | |
47 | * for HVR1500Q, which has an xc5000 tuner. | |
48 | */ | |
49 | int au0828_tuner_callback(void *priv, int command, int arg) | |
50 | { | |
51 | struct au0828_dev *dev = priv; | |
52 | ||
f07e8e4b | 53 | dprintk(1, "%s()\n", __func__); |
bc3c613c | 54 | |
18d73c58 | 55 | switch (dev->board) { |
265a6510 ST |
56 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
57 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | |
59d27521 | 58 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: |
265a6510 | 59 | case AU0828_BOARD_DVICO_FUSIONHDTV7: |
a9c36aad | 60 | if (command == 0) { |
265a6510 ST |
61 | /* Tuner Reset Command from xc5000 */ |
62 | /* Drive the tuner into reset and out */ | |
63 | au0828_clear(dev, REG_001, 2); | |
64 | mdelay(200); | |
65 | au0828_set(dev, REG_001, 2); | |
66 | mdelay(50); | |
67 | return 0; | |
18d73c58 | 68 | } else { |
265a6510 | 69 | printk(KERN_ERR |
f07e8e4b | 70 | "%s(): Unknown command.\n", __func__); |
265a6510 ST |
71 | return -EINVAL; |
72 | } | |
73 | break; | |
74 | } | |
75 | ||
76 | return 0; /* Should never be here */ | |
77 | } | |
78 | ||
28930fa9 ST |
79 | static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data) |
80 | { | |
81 | struct tveeprom tv; | |
82 | ||
83 | tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data); | |
84 | ||
85 | /* Make sure we support the board model */ | |
a9c36aad | 86 | switch (tv.model) { |
104fe9a2 | 87 | case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */ |
28930fa9 | 88 | case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ |
104fe9a2 MK |
89 | case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ |
90 | case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ | |
91 | case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ | |
92 | case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and basic analog video */ | |
805caff5 | 93 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ |
104fe9a2 | 94 | case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ |
28930fa9 ST |
95 | break; |
96 | default: | |
f07e8e4b MK |
97 | printk(KERN_WARNING "%s: warning: " |
98 | "unknown hauppauge model #%d\n", __func__, tv.model); | |
28930fa9 ST |
99 | break; |
100 | } | |
101 | ||
f07e8e4b MK |
102 | printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n", |
103 | __func__, tv.model); | |
28930fa9 ST |
104 | } |
105 | ||
28930fa9 ST |
106 | void au0828_card_setup(struct au0828_dev *dev) |
107 | { | |
28930fa9 ST |
108 | static u8 eeprom[256]; |
109 | ||
f07e8e4b | 110 | dprintk(1, "%s()\n", __func__); |
bc3c613c | 111 | |
28930fa9 ST |
112 | if (dev->i2c_rc == 0) { |
113 | dev->i2c_client.addr = 0xa0 >> 1; | |
114 | tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom)); | |
115 | } | |
116 | ||
18d73c58 | 117 | switch (dev->board) { |
28930fa9 ST |
118 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
119 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | |
59d27521 | 120 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: |
8e8bd229 | 121 | case AU0828_BOARD_HAUPPAUGE_WOODBURY: |
28930fa9 ST |
122 | if (dev->i2c_rc == 0) |
123 | hauppauge_eeprom(dev, eeprom+0xa0); | |
124 | break; | |
125 | } | |
126 | } | |
127 | ||
265a6510 ST |
128 | /* |
129 | * The bridge has between 8 and 12 gpios. | |
130 | * Regs 1 and 0 deal with output enables. | |
a9c36aad | 131 | * Regs 3 and 2 deal with direction. |
265a6510 ST |
132 | */ |
133 | void au0828_gpio_setup(struct au0828_dev *dev) | |
134 | { | |
f07e8e4b | 135 | dprintk(1, "%s()\n", __func__); |
bc3c613c | 136 | |
18d73c58 | 137 | switch (dev->board) { |
265a6510 ST |
138 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
139 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | |
59d27521 | 140 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: |
8e8bd229 | 141 | case AU0828_BOARD_HAUPPAUGE_WOODBURY: |
265a6510 ST |
142 | /* GPIO's |
143 | * 4 - CS5340 | |
144 | * 5 - AU8522 Demodulator | |
145 | * 6 - eeprom W/P | |
146 | * 9 - XC5000 Tuner | |
147 | */ | |
148 | ||
149 | /* Into reset */ | |
150 | au0828_write(dev, REG_003, 0x02); | |
151 | au0828_write(dev, REG_002, 0x88 | 0x20); | |
152 | au0828_write(dev, REG_001, 0x0); | |
153 | au0828_write(dev, REG_000, 0x0); | |
154 | msleep(100); | |
155 | ||
156 | /* Out of reset */ | |
157 | au0828_write(dev, REG_003, 0x02); | |
158 | au0828_write(dev, REG_001, 0x02); | |
159 | au0828_write(dev, REG_002, 0x88 | 0x20); | |
160 | au0828_write(dev, REG_000, 0x88 | 0x20 | 0x40); | |
161 | msleep(250); | |
162 | break; | |
163 | case AU0828_BOARD_DVICO_FUSIONHDTV7: | |
164 | /* GPIO's | |
165 | * 6 - ? | |
166 | * 8 - AU8522 Demodulator | |
167 | * 9 - XC5000 Tuner | |
168 | */ | |
169 | ||
170 | /* Into reset */ | |
171 | au0828_write(dev, REG_003, 0x02); | |
172 | au0828_write(dev, REG_002, 0xa0); | |
173 | au0828_write(dev, REG_001, 0x0); | |
174 | au0828_write(dev, REG_000, 0x0); | |
175 | msleep(100); | |
176 | ||
177 | /* Out of reset */ | |
178 | au0828_write(dev, REG_003, 0x02); | |
179 | au0828_write(dev, REG_002, 0xa0); | |
180 | au0828_write(dev, REG_001, 0x02); | |
181 | au0828_write(dev, REG_000, 0xa0); | |
182 | msleep(250); | |
183 | break; | |
184 | } | |
185 | } | |
186 | ||
187 | /* table of devices that work with this driver */ | |
188 | struct usb_device_id au0828_usb_id_table [] = { | |
189 | { USB_DEVICE(0x2040, 0x7200), | |
190 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | |
191 | { USB_DEVICE(0x2040, 0x7240), | |
192 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 }, | |
193 | { USB_DEVICE(0x0fe9, 0xd620), | |
194 | .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 }, | |
104fe9a2 MK |
195 | { USB_DEVICE(0x2040, 0x7210), |
196 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | |
197 | { USB_DEVICE(0x2040, 0x7217), | |
198 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | |
199 | { USB_DEVICE(0x2040, 0x721b), | |
200 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | |
201 | { USB_DEVICE(0x2040, 0x721f), | |
202 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | |
203 | { USB_DEVICE(0x2040, 0x7280), | |
204 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | |
205 | { USB_DEVICE(0x0fd9, 0x0008), | |
206 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | |
59d27521 MK |
207 | { USB_DEVICE(0x2040, 0x7201), |
208 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, | |
209 | { USB_DEVICE(0x2040, 0x7211), | |
210 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, | |
211 | { USB_DEVICE(0x2040, 0x7281), | |
212 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, | |
8e8bd229 MK |
213 | { USB_DEVICE(0x2040, 0x8200), |
214 | .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY }, | |
265a6510 ST |
215 | { }, |
216 | }; | |
217 | ||
218 | MODULE_DEVICE_TABLE(usb, au0828_usb_id_table); |