Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Driver for the Auvitek USB bridge |
| 3 | * |
Steven Toth | 6d89761 | 2008-09-03 17:12:12 -0300 | [diff] [blame] | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 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 | |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 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 | }, |
Michael Krufky | 59d2752 | 2008-07-09 00:23:08 -0300 | [diff] [blame] | 35 | [AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL] = { |
| 36 | .name = "Hauppauge HVR950Q rev xxF8", |
| 37 | }, |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 38 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { |
| 39 | .name = "DViCO FusionHDTV USB", |
| 40 | }, |
Michael Krufky | 8e8bd22 | 2008-09-03 16:46:36 -0300 | [diff] [blame] | 41 | [AU0828_BOARD_HAUPPAUGE_WOODBURY] = { |
| 42 | .name = "Hauppauge Woodbury", |
| 43 | }, |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 44 | }; |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 45 | |
| 46 | /* Tuner callback function for au0828 boards. Currently only needed |
| 47 | * for HVR1500Q, which has an xc5000 tuner. |
| 48 | */ |
Michael Krufky | d7cba04 | 2008-09-12 13:31:45 -0300 | [diff] [blame] | 49 | int au0828_tuner_callback(void *priv, int component, int command, int arg) |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 50 | { |
| 51 | struct au0828_dev *dev = priv; |
| 52 | |
Michael Krufky | f07e8e4 | 2008-04-18 21:42:30 -0300 | [diff] [blame] | 53 | dprintk(1, "%s()\n", __func__); |
Steven Toth | bc3c613 | 2008-04-18 21:39:11 -0300 | [diff] [blame] | 54 | |
Mauro Carvalho Chehab | 18d73c5 | 2008-04-18 22:12:52 -0300 | [diff] [blame] | 55 | switch (dev->board) { |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 56 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
| 57 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: |
Michael Krufky | 59d2752 | 2008-07-09 00:23:08 -0300 | [diff] [blame] | 58 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 59 | case AU0828_BOARD_DVICO_FUSIONHDTV7: |
Steven Toth | a9c36aa | 2008-04-17 21:41:28 -0300 | [diff] [blame] | 60 | if (command == 0) { |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 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; |
Mauro Carvalho Chehab | 18d73c5 | 2008-04-18 22:12:52 -0300 | [diff] [blame] | 68 | } else { |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 69 | printk(KERN_ERR |
Michael Krufky | f07e8e4 | 2008-04-18 21:42:30 -0300 | [diff] [blame] | 70 | "%s(): Unknown command.\n", __func__); |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 71 | return -EINVAL; |
| 72 | } |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | return 0; /* Should never be here */ |
| 77 | } |
| 78 | |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 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 */ |
Steven Toth | a9c36aa | 2008-04-17 21:41:28 -0300 | [diff] [blame] | 86 | switch (tv.model) { |
Michael Krufky | 104fe9a | 2008-06-13 03:29:43 -0300 | [diff] [blame] | 87 | case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */ |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 88 | case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ |
Michael Krufky | 104fe9a | 2008-06-13 03:29:43 -0300 | [diff] [blame] | 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 */ |
Michael Krufky | a636da6 | 2008-10-15 17:00:31 -0300 | [diff] [blame] | 93 | case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ |
Steven Toth | 805caff | 2008-04-17 21:47:11 -0300 | [diff] [blame] | 94 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ |
Michael Krufky | 104fe9a | 2008-06-13 03:29:43 -0300 | [diff] [blame] | 95 | case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 96 | break; |
| 97 | default: |
Michael Krufky | f07e8e4 | 2008-04-18 21:42:30 -0300 | [diff] [blame] | 98 | printk(KERN_WARNING "%s: warning: " |
| 99 | "unknown hauppauge model #%d\n", __func__, tv.model); |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 100 | break; |
| 101 | } |
| 102 | |
Michael Krufky | f07e8e4 | 2008-04-18 21:42:30 -0300 | [diff] [blame] | 103 | printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n", |
| 104 | __func__, tv.model); |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 105 | } |
| 106 | |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 107 | void au0828_card_setup(struct au0828_dev *dev) |
| 108 | { |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 109 | static u8 eeprom[256]; |
| 110 | |
Michael Krufky | f07e8e4 | 2008-04-18 21:42:30 -0300 | [diff] [blame] | 111 | dprintk(1, "%s()\n", __func__); |
Steven Toth | bc3c613 | 2008-04-18 21:39:11 -0300 | [diff] [blame] | 112 | |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 113 | if (dev->i2c_rc == 0) { |
| 114 | dev->i2c_client.addr = 0xa0 >> 1; |
| 115 | tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom)); |
| 116 | } |
| 117 | |
Mauro Carvalho Chehab | 18d73c5 | 2008-04-18 22:12:52 -0300 | [diff] [blame] | 118 | switch (dev->board) { |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 119 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
| 120 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: |
Michael Krufky | 59d2752 | 2008-07-09 00:23:08 -0300 | [diff] [blame] | 121 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: |
Michael Krufky | 8e8bd22 | 2008-09-03 16:46:36 -0300 | [diff] [blame] | 122 | case AU0828_BOARD_HAUPPAUGE_WOODBURY: |
Steven Toth | 28930fa | 2008-03-29 19:53:07 -0300 | [diff] [blame] | 123 | if (dev->i2c_rc == 0) |
| 124 | hauppauge_eeprom(dev, eeprom+0xa0); |
| 125 | break; |
| 126 | } |
| 127 | } |
| 128 | |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 129 | /* |
| 130 | * The bridge has between 8 and 12 gpios. |
| 131 | * Regs 1 and 0 deal with output enables. |
Steven Toth | a9c36aa | 2008-04-17 21:41:28 -0300 | [diff] [blame] | 132 | * Regs 3 and 2 deal with direction. |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 133 | */ |
| 134 | void au0828_gpio_setup(struct au0828_dev *dev) |
| 135 | { |
Michael Krufky | f07e8e4 | 2008-04-18 21:42:30 -0300 | [diff] [blame] | 136 | dprintk(1, "%s()\n", __func__); |
Steven Toth | bc3c613 | 2008-04-18 21:39:11 -0300 | [diff] [blame] | 137 | |
Mauro Carvalho Chehab | 18d73c5 | 2008-04-18 22:12:52 -0300 | [diff] [blame] | 138 | switch (dev->board) { |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 139 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
| 140 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: |
Michael Krufky | 59d2752 | 2008-07-09 00:23:08 -0300 | [diff] [blame] | 141 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: |
Michael Krufky | 8e8bd22 | 2008-09-03 16:46:36 -0300 | [diff] [blame] | 142 | case AU0828_BOARD_HAUPPAUGE_WOODBURY: |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 143 | /* GPIO's |
| 144 | * 4 - CS5340 |
| 145 | * 5 - AU8522 Demodulator |
| 146 | * 6 - eeprom W/P |
| 147 | * 9 - XC5000 Tuner |
| 148 | */ |
| 149 | |
| 150 | /* Into reset */ |
| 151 | au0828_write(dev, REG_003, 0x02); |
| 152 | au0828_write(dev, REG_002, 0x88 | 0x20); |
| 153 | au0828_write(dev, REG_001, 0x0); |
| 154 | au0828_write(dev, REG_000, 0x0); |
| 155 | msleep(100); |
| 156 | |
| 157 | /* Out of reset */ |
| 158 | au0828_write(dev, REG_003, 0x02); |
| 159 | au0828_write(dev, REG_001, 0x02); |
| 160 | au0828_write(dev, REG_002, 0x88 | 0x20); |
| 161 | au0828_write(dev, REG_000, 0x88 | 0x20 | 0x40); |
| 162 | msleep(250); |
| 163 | break; |
| 164 | case AU0828_BOARD_DVICO_FUSIONHDTV7: |
| 165 | /* GPIO's |
| 166 | * 6 - ? |
| 167 | * 8 - AU8522 Demodulator |
| 168 | * 9 - XC5000 Tuner |
| 169 | */ |
| 170 | |
| 171 | /* Into reset */ |
| 172 | au0828_write(dev, REG_003, 0x02); |
| 173 | au0828_write(dev, REG_002, 0xa0); |
| 174 | au0828_write(dev, REG_001, 0x0); |
| 175 | au0828_write(dev, REG_000, 0x0); |
| 176 | msleep(100); |
| 177 | |
| 178 | /* Out of reset */ |
| 179 | au0828_write(dev, REG_003, 0x02); |
| 180 | au0828_write(dev, REG_002, 0xa0); |
| 181 | au0828_write(dev, REG_001, 0x02); |
| 182 | au0828_write(dev, REG_000, 0xa0); |
| 183 | msleep(250); |
| 184 | break; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /* table of devices that work with this driver */ |
Steven Toth | a8eb912 | 2008-10-16 20:19:41 -0300 | [diff] [blame] | 189 | struct usb_device_id au0828_usb_id_table[] = { |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 190 | { USB_DEVICE(0x2040, 0x7200), |
| 191 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
| 192 | { USB_DEVICE(0x2040, 0x7240), |
| 193 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 }, |
| 194 | { USB_DEVICE(0x0fe9, 0xd620), |
| 195 | .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 }, |
Michael Krufky | 104fe9a | 2008-06-13 03:29:43 -0300 | [diff] [blame] | 196 | { USB_DEVICE(0x2040, 0x7210), |
| 197 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
| 198 | { USB_DEVICE(0x2040, 0x7217), |
| 199 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
| 200 | { USB_DEVICE(0x2040, 0x721b), |
| 201 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
Michael Krufky | a636da6 | 2008-10-15 17:00:31 -0300 | [diff] [blame] | 202 | { USB_DEVICE(0x2040, 0x721e), |
| 203 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
Michael Krufky | 104fe9a | 2008-06-13 03:29:43 -0300 | [diff] [blame] | 204 | { USB_DEVICE(0x2040, 0x721f), |
| 205 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
| 206 | { USB_DEVICE(0x2040, 0x7280), |
| 207 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
| 208 | { USB_DEVICE(0x0fd9, 0x0008), |
| 209 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
Michael Krufky | 59d2752 | 2008-07-09 00:23:08 -0300 | [diff] [blame] | 210 | { USB_DEVICE(0x2040, 0x7201), |
| 211 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, |
| 212 | { USB_DEVICE(0x2040, 0x7211), |
| 213 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, |
| 214 | { USB_DEVICE(0x2040, 0x7281), |
| 215 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, |
Michael Krufky | 8e8bd22 | 2008-09-03 16:46:36 -0300 | [diff] [blame] | 216 | { USB_DEVICE(0x2040, 0x8200), |
| 217 | .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY }, |
Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame] | 218 | { }, |
| 219 | }; |
| 220 | |
| 221 | MODULE_DEVICE_TABLE(usb, au0828_usb_id_table); |