Steven Toth | 265a651 | 2008-04-18 21:34:00 -0300 | [diff] [blame^] | 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 | |
| 25 | #define _dbg(level, fmt, arg...)\ |
| 26 | do {\ |
| 27 | if (debug >= level) \ |
| 28 | printk(KERN_DEBUG DRIVER_NAME "/0: " fmt, ## arg);\ |
| 29 | } while (0) |
| 30 | |
| 31 | struct au0828_board au0828_boards[] = { |
| 32 | [AU0828_BOARD_UNKNOWN] = { |
| 33 | .name = "Unknown board", |
| 34 | }, |
| 35 | [AU0828_BOARD_HAUPPAUGE_HVR850] = { |
| 36 | .name = "Hauppauge HVR850", |
| 37 | }, |
| 38 | [AU0828_BOARD_HAUPPAUGE_HVR950Q] = { |
| 39 | .name = "Hauppauge HVR950Q", |
| 40 | }, |
| 41 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { |
| 42 | .name = "DViCO FusionHDTV USB", |
| 43 | }, |
| 44 | }; |
| 45 | const unsigned int au0828_bcount = ARRAY_SIZE(au0828_boards); |
| 46 | |
| 47 | /* Tuner callback function for au0828 boards. Currently only needed |
| 48 | * for HVR1500Q, which has an xc5000 tuner. |
| 49 | */ |
| 50 | int au0828_tuner_callback(void *priv, int command, int arg) |
| 51 | { |
| 52 | struct au0828_dev *dev = priv; |
| 53 | |
| 54 | switch(dev->board) { |
| 55 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
| 56 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: |
| 57 | case AU0828_BOARD_DVICO_FUSIONHDTV7: |
| 58 | if(command == 0) { |
| 59 | /* Tuner Reset Command from xc5000 */ |
| 60 | /* Drive the tuner into reset and out */ |
| 61 | au0828_clear(dev, REG_001, 2); |
| 62 | mdelay(200); |
| 63 | au0828_set(dev, REG_001, 2); |
| 64 | mdelay(50); |
| 65 | return 0; |
| 66 | } |
| 67 | else { |
| 68 | printk(KERN_ERR |
| 69 | "%s(): Unknown command.\n", __FUNCTION__); |
| 70 | return -EINVAL; |
| 71 | } |
| 72 | break; |
| 73 | } |
| 74 | |
| 75 | return 0; /* Should never be here */ |
| 76 | } |
| 77 | |
| 78 | /* |
| 79 | * The bridge has between 8 and 12 gpios. |
| 80 | * Regs 1 and 0 deal with output enables. |
| 81 | * Regs 3 and 2 * deal with direction. |
| 82 | */ |
| 83 | void au0828_gpio_setup(struct au0828_dev *dev) |
| 84 | { |
| 85 | switch(dev->board) { |
| 86 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
| 87 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: |
| 88 | /* GPIO's |
| 89 | * 4 - CS5340 |
| 90 | * 5 - AU8522 Demodulator |
| 91 | * 6 - eeprom W/P |
| 92 | * 9 - XC5000 Tuner |
| 93 | */ |
| 94 | |
| 95 | /* Into reset */ |
| 96 | au0828_write(dev, REG_003, 0x02); |
| 97 | au0828_write(dev, REG_002, 0x88 | 0x20); |
| 98 | au0828_write(dev, REG_001, 0x0); |
| 99 | au0828_write(dev, REG_000, 0x0); |
| 100 | msleep(100); |
| 101 | |
| 102 | /* Out of reset */ |
| 103 | au0828_write(dev, REG_003, 0x02); |
| 104 | au0828_write(dev, REG_001, 0x02); |
| 105 | au0828_write(dev, REG_002, 0x88 | 0x20); |
| 106 | au0828_write(dev, REG_000, 0x88 | 0x20 | 0x40); |
| 107 | msleep(250); |
| 108 | break; |
| 109 | case AU0828_BOARD_DVICO_FUSIONHDTV7: |
| 110 | /* GPIO's |
| 111 | * 6 - ? |
| 112 | * 8 - AU8522 Demodulator |
| 113 | * 9 - XC5000 Tuner |
| 114 | */ |
| 115 | |
| 116 | /* Into reset */ |
| 117 | au0828_write(dev, REG_003, 0x02); |
| 118 | au0828_write(dev, REG_002, 0xa0); |
| 119 | au0828_write(dev, REG_001, 0x0); |
| 120 | au0828_write(dev, REG_000, 0x0); |
| 121 | msleep(100); |
| 122 | |
| 123 | /* Out of reset */ |
| 124 | au0828_write(dev, REG_003, 0x02); |
| 125 | au0828_write(dev, REG_002, 0xa0); |
| 126 | au0828_write(dev, REG_001, 0x02); |
| 127 | au0828_write(dev, REG_000, 0xa0); |
| 128 | msleep(250); |
| 129 | break; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | /* table of devices that work with this driver */ |
| 134 | struct usb_device_id au0828_usb_id_table [] = { |
| 135 | { USB_DEVICE(0x2040, 0x7200), |
| 136 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
| 137 | { USB_DEVICE(0x2040, 0x7240), |
| 138 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 }, |
| 139 | { USB_DEVICE(0x0fe9, 0xd620), |
| 140 | .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 }, |
| 141 | { }, |
| 142 | }; |
| 143 | |
| 144 | MODULE_DEVICE_TABLE(usb, au0828_usb_id_table); |