Path: blob/master/drivers/media/video/au0828/au0828-cards.c
17984 views
/*1* Driver for the Auvitek USB bridge2*3* Copyright (c) 2008 Steven Toth <[email protected]>4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13*14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.19*/2021#include "au0828.h"22#include "au0828-cards.h"23#include "au8522.h"24#include "media/tuner.h"25#include "media/v4l2-common.h"2627void hvr950q_cs5340_audio(void *priv, int enable)28{29/* Because the HVR-950q shares an i2s bus between the cs5340 and the30au8522, we need to hold cs5340 in reset when using the au8522 */31struct au0828_dev *dev = priv;32if (enable == 1)33au0828_set(dev, REG_000, 0x10);34else35au0828_clear(dev, REG_000, 0x10);36}3738struct au0828_board au0828_boards[] = {39[AU0828_BOARD_UNKNOWN] = {40.name = "Unknown board",41.tuner_type = UNSET,42.tuner_addr = ADDR_UNSET,43},44[AU0828_BOARD_HAUPPAUGE_HVR850] = {45.name = "Hauppauge HVR850",46.tuner_type = TUNER_XC5000,47.tuner_addr = 0x61,48.i2c_clk_divider = AU0828_I2C_CLK_30KHZ,49.input = {50{51.type = AU0828_VMUX_TELEVISION,52.vmux = AU8522_COMPOSITE_CH4_SIF,53.amux = AU8522_AUDIO_SIF,54},55{56.type = AU0828_VMUX_COMPOSITE,57.vmux = AU8522_COMPOSITE_CH1,58.amux = AU8522_AUDIO_NONE,59.audio_setup = hvr950q_cs5340_audio,60},61{62.type = AU0828_VMUX_SVIDEO,63.vmux = AU8522_SVIDEO_CH13,64.amux = AU8522_AUDIO_NONE,65.audio_setup = hvr950q_cs5340_audio,66},67},68},69[AU0828_BOARD_HAUPPAUGE_HVR950Q] = {70.name = "Hauppauge HVR950Q",71.tuner_type = TUNER_XC5000,72.tuner_addr = 0x61,73/* The au0828 hardware i2c implementation does not properly74support the xc5000's i2c clock stretching. So we need to75lower the clock frequency enough where the 15us clock76stretch fits inside of a normal clock cycle, or else the77au0828 fails to set the STOP bit. A 30 KHz clock puts the78clock pulse width at 18us */79.i2c_clk_divider = AU0828_I2C_CLK_30KHZ,80.input = {81{82.type = AU0828_VMUX_TELEVISION,83.vmux = AU8522_COMPOSITE_CH4_SIF,84.amux = AU8522_AUDIO_SIF,85},86{87.type = AU0828_VMUX_COMPOSITE,88.vmux = AU8522_COMPOSITE_CH1,89.amux = AU8522_AUDIO_NONE,90.audio_setup = hvr950q_cs5340_audio,91},92{93.type = AU0828_VMUX_SVIDEO,94.vmux = AU8522_SVIDEO_CH13,95.amux = AU8522_AUDIO_NONE,96.audio_setup = hvr950q_cs5340_audio,97},98},99},100[AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL] = {101.name = "Hauppauge HVR950Q rev xxF8",102.tuner_type = UNSET,103.tuner_addr = ADDR_UNSET,104.i2c_clk_divider = AU0828_I2C_CLK_250KHZ,105},106[AU0828_BOARD_DVICO_FUSIONHDTV7] = {107.name = "DViCO FusionHDTV USB",108.tuner_type = UNSET,109.tuner_addr = ADDR_UNSET,110.i2c_clk_divider = AU0828_I2C_CLK_250KHZ,111},112[AU0828_BOARD_HAUPPAUGE_WOODBURY] = {113.name = "Hauppauge Woodbury",114.tuner_type = UNSET,115.tuner_addr = ADDR_UNSET,116.i2c_clk_divider = AU0828_I2C_CLK_250KHZ,117},118};119120/* Tuner callback function for au0828 boards. Currently only needed121* for HVR1500Q, which has an xc5000 tuner.122*/123int au0828_tuner_callback(void *priv, int component, int command, int arg)124{125struct au0828_dev *dev = priv;126127dprintk(1, "%s()\n", __func__);128129switch (dev->boardnr) {130case AU0828_BOARD_HAUPPAUGE_HVR850:131case AU0828_BOARD_HAUPPAUGE_HVR950Q:132case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:133case AU0828_BOARD_DVICO_FUSIONHDTV7:134if (command == 0) {135/* Tuner Reset Command from xc5000 */136/* Drive the tuner into reset and out */137au0828_clear(dev, REG_001, 2);138mdelay(10);139au0828_set(dev, REG_001, 2);140mdelay(10);141return 0;142} else {143printk(KERN_ERR144"%s(): Unknown command.\n", __func__);145return -EINVAL;146}147break;148}149150return 0; /* Should never be here */151}152153static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)154{155struct tveeprom tv;156157tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data);158dev->board.tuner_type = tv.tuner_type;159160/* Make sure we support the board model */161switch (tv.model) {162case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */163case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */164case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */165case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */166case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */167case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */168case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */169case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */170case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */171break;172default:173printk(KERN_WARNING "%s: warning: "174"unknown hauppauge model #%d\n", __func__, tv.model);175break;176}177178printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",179__func__, tv.model);180}181182void au0828_card_setup(struct au0828_dev *dev)183{184static u8 eeprom[256];185struct tuner_setup tun_setup;186struct v4l2_subdev *sd;187unsigned int mode_mask = T_ANALOG_TV;188189dprintk(1, "%s()\n", __func__);190191memcpy(&dev->board, &au0828_boards[dev->boardnr], sizeof(dev->board));192193if (dev->i2c_rc == 0) {194dev->i2c_client.addr = 0xa0 >> 1;195tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom));196}197198switch (dev->boardnr) {199case AU0828_BOARD_HAUPPAUGE_HVR850:200case AU0828_BOARD_HAUPPAUGE_HVR950Q:201case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:202case AU0828_BOARD_HAUPPAUGE_WOODBURY:203if (dev->i2c_rc == 0)204hauppauge_eeprom(dev, eeprom+0xa0);205break;206}207208if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {209/* Load the analog demodulator driver (note this would need to210be abstracted out if we ever need to support a different211demod) */212sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,213"au8522", 0x8e >> 1, NULL);214if (sd == NULL)215printk(KERN_ERR "analog subdev registration failed\n");216}217218/* Setup tuners */219if (dev->board.tuner_type != TUNER_ABSENT) {220/* Load the tuner module, which does the attach */221sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,222"tuner", dev->board.tuner_addr, NULL);223if (sd == NULL)224printk(KERN_ERR "tuner subdev registration fail\n");225226tun_setup.mode_mask = mode_mask;227tun_setup.type = dev->board.tuner_type;228tun_setup.addr = dev->board.tuner_addr;229tun_setup.tuner_callback = au0828_tuner_callback;230v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr,231&tun_setup);232}233}234235/*236* The bridge has between 8 and 12 gpios.237* Regs 1 and 0 deal with output enables.238* Regs 3 and 2 deal with direction.239*/240void au0828_gpio_setup(struct au0828_dev *dev)241{242dprintk(1, "%s()\n", __func__);243244switch (dev->boardnr) {245case AU0828_BOARD_HAUPPAUGE_HVR850:246case AU0828_BOARD_HAUPPAUGE_HVR950Q:247case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:248case AU0828_BOARD_HAUPPAUGE_WOODBURY:249/* GPIO's250* 4 - CS5340251* 5 - AU8522 Demodulator252* 6 - eeprom W/P253* 7 - power supply254* 9 - XC5000 Tuner255*/256257/* Into reset */258au0828_write(dev, REG_003, 0x02);259au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10);260au0828_write(dev, REG_001, 0x0);261au0828_write(dev, REG_000, 0x0);262msleep(100);263264/* Out of reset (leave the cs5340 in reset until needed) */265au0828_write(dev, REG_003, 0x02);266au0828_write(dev, REG_001, 0x02);267au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10);268au0828_write(dev, REG_000, 0x80 | 0x40 | 0x20);269270msleep(250);271break;272case AU0828_BOARD_DVICO_FUSIONHDTV7:273/* GPIO's274* 6 - ?275* 8 - AU8522 Demodulator276* 9 - XC5000 Tuner277*/278279/* Into reset */280au0828_write(dev, REG_003, 0x02);281au0828_write(dev, REG_002, 0xa0);282au0828_write(dev, REG_001, 0x0);283au0828_write(dev, REG_000, 0x0);284msleep(100);285286/* Out of reset */287au0828_write(dev, REG_003, 0x02);288au0828_write(dev, REG_002, 0xa0);289au0828_write(dev, REG_001, 0x02);290au0828_write(dev, REG_000, 0xa0);291msleep(250);292break;293}294}295296/* table of devices that work with this driver */297struct usb_device_id au0828_usb_id_table[] = {298{ USB_DEVICE(0x2040, 0x7200),299.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },300{ USB_DEVICE(0x2040, 0x7240),301.driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 },302{ USB_DEVICE(0x0fe9, 0xd620),303.driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 },304{ USB_DEVICE(0x2040, 0x7210),305.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },306{ USB_DEVICE(0x2040, 0x7217),307.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },308{ USB_DEVICE(0x2040, 0x721b),309.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },310{ USB_DEVICE(0x2040, 0x721e),311.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },312{ USB_DEVICE(0x2040, 0x721f),313.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },314{ USB_DEVICE(0x2040, 0x7280),315.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },316{ USB_DEVICE(0x0fd9, 0x0008),317.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },318{ USB_DEVICE(0x2040, 0x7201),319.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },320{ USB_DEVICE(0x2040, 0x7211),321.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },322{ USB_DEVICE(0x2040, 0x7281),323.driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },324{ USB_DEVICE(0x2040, 0x8200),325.driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY },326{ },327};328329MODULE_DEVICE_TABLE(usb, au0828_usb_id_table);330331332