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 | }, | |
35 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { | |
36 | .name = "DViCO FusionHDTV USB", | |
37 | }, | |
38 | }; | |
39 | const unsigned int au0828_bcount = ARRAY_SIZE(au0828_boards); | |
40 | ||
41 | /* Tuner callback function for au0828 boards. Currently only needed | |
42 | * for HVR1500Q, which has an xc5000 tuner. | |
43 | */ | |
44 | int au0828_tuner_callback(void *priv, int command, int arg) | |
45 | { | |
46 | struct au0828_dev *dev = priv; | |
47 | ||
bc3c613c ST |
48 | dprintk(1, "%s()\n", __FUNCTION__); |
49 | ||
265a6510 ST |
50 | switch(dev->board) { |
51 | case AU0828_BOARD_HAUPPAUGE_HVR850: | |
52 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | |
53 | case AU0828_BOARD_DVICO_FUSIONHDTV7: | |
54 | if(command == 0) { | |
55 | /* Tuner Reset Command from xc5000 */ | |
56 | /* Drive the tuner into reset and out */ | |
57 | au0828_clear(dev, REG_001, 2); | |
58 | mdelay(200); | |
59 | au0828_set(dev, REG_001, 2); | |
60 | mdelay(50); | |
61 | return 0; | |
62 | } | |
63 | else { | |
64 | printk(KERN_ERR | |
65 | "%s(): Unknown command.\n", __FUNCTION__); | |
66 | return -EINVAL; | |
67 | } | |
68 | break; | |
69 | } | |
70 | ||
71 | return 0; /* Should never be here */ | |
72 | } | |
73 | ||
28930fa9 ST |
74 | static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data) |
75 | { | |
76 | struct tveeprom tv; | |
77 | ||
78 | tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data); | |
79 | ||
80 | /* Make sure we support the board model */ | |
81 | switch (tv.model) | |
82 | { | |
83 | case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ | |
84 | break; | |
85 | default: | |
86 | printk("%s: warning: unknown hauppauge model #%d\n", __FUNCTION__, tv.model); | |
87 | break; | |
88 | } | |
89 | ||
90 | printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n", __FUNCTION__, tv.model); | |
91 | } | |
92 | ||
93 | ||
94 | void au0828_card_setup(struct au0828_dev *dev) | |
95 | { | |
28930fa9 ST |
96 | static u8 eeprom[256]; |
97 | ||
bc3c613c ST |
98 | dprintk(1, "%s()\n", __FUNCTION__); |
99 | ||
28930fa9 ST |
100 | if (dev->i2c_rc == 0) { |
101 | dev->i2c_client.addr = 0xa0 >> 1; | |
102 | tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom)); | |
103 | } | |
104 | ||
105 | switch(dev->board) { | |
106 | case AU0828_BOARD_HAUPPAUGE_HVR850: | |
107 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | |
108 | if (dev->i2c_rc == 0) | |
109 | hauppauge_eeprom(dev, eeprom+0xa0); | |
110 | break; | |
111 | } | |
112 | } | |
113 | ||
265a6510 ST |
114 | /* |
115 | * The bridge has between 8 and 12 gpios. | |
116 | * Regs 1 and 0 deal with output enables. | |
117 | * Regs 3 and 2 * deal with direction. | |
118 | */ | |
119 | void au0828_gpio_setup(struct au0828_dev *dev) | |
120 | { | |
bc3c613c ST |
121 | dprintk(1, "%s()\n", __FUNCTION__); |
122 | ||
265a6510 ST |
123 | switch(dev->board) { |
124 | case AU0828_BOARD_HAUPPAUGE_HVR850: | |
125 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | |
126 | /* GPIO's | |
127 | * 4 - CS5340 | |
128 | * 5 - AU8522 Demodulator | |
129 | * 6 - eeprom W/P | |
130 | * 9 - XC5000 Tuner | |
131 | */ | |
132 | ||
133 | /* Into reset */ | |
134 | au0828_write(dev, REG_003, 0x02); | |
135 | au0828_write(dev, REG_002, 0x88 | 0x20); | |
136 | au0828_write(dev, REG_001, 0x0); | |
137 | au0828_write(dev, REG_000, 0x0); | |
138 | msleep(100); | |
139 | ||
140 | /* Out of reset */ | |
141 | au0828_write(dev, REG_003, 0x02); | |
142 | au0828_write(dev, REG_001, 0x02); | |
143 | au0828_write(dev, REG_002, 0x88 | 0x20); | |
144 | au0828_write(dev, REG_000, 0x88 | 0x20 | 0x40); | |
145 | msleep(250); | |
146 | break; | |
147 | case AU0828_BOARD_DVICO_FUSIONHDTV7: | |
148 | /* GPIO's | |
149 | * 6 - ? | |
150 | * 8 - AU8522 Demodulator | |
151 | * 9 - XC5000 Tuner | |
152 | */ | |
153 | ||
154 | /* Into reset */ | |
155 | au0828_write(dev, REG_003, 0x02); | |
156 | au0828_write(dev, REG_002, 0xa0); | |
157 | au0828_write(dev, REG_001, 0x0); | |
158 | au0828_write(dev, REG_000, 0x0); | |
159 | msleep(100); | |
160 | ||
161 | /* Out of reset */ | |
162 | au0828_write(dev, REG_003, 0x02); | |
163 | au0828_write(dev, REG_002, 0xa0); | |
164 | au0828_write(dev, REG_001, 0x02); | |
165 | au0828_write(dev, REG_000, 0xa0); | |
166 | msleep(250); | |
167 | break; | |
168 | } | |
169 | } | |
170 | ||
171 | /* table of devices that work with this driver */ | |
172 | struct usb_device_id au0828_usb_id_table [] = { | |
173 | { USB_DEVICE(0x2040, 0x7200), | |
174 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | |
175 | { USB_DEVICE(0x2040, 0x7240), | |
176 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 }, | |
177 | { USB_DEVICE(0x0fe9, 0xd620), | |
178 | .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 }, | |
179 | { }, | |
180 | }; | |
181 | ||
182 | MODULE_DEVICE_TABLE(usb, au0828_usb_id_table); |