// SPDX-License-Identifier: GPL-2.0-or-later /* bttv-cards.c this file has configuration information - card-specific stuff like the big tvcards array for the most part Copyright (C) 1996,97,98 Ralph Metzler ([email protected]) & Marcus Metzler ([email protected]) (c) 1999-2001 Gerd Knorr <[email protected]> */ #define pr_fmt(fmt) … #include <linux/delay.h> #include <linux/module.h> #include <linux/kmod.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/vmalloc.h> #include <linux/firmware.h> #include <net/checksum.h> #include <asm/unaligned.h> #include <asm/io.h> #include "bttvp.h" #include <media/v4l2-common.h> #include <media/i2c/tvaudio.h> #include "bttv-audio-hook.h" /* fwd decl */ static void boot_msp34xx(struct bttv *btv, int pin); static void hauppauge_eeprom(struct bttv *btv); static void avermedia_eeprom(struct bttv *btv); static void osprey_eeprom(struct bttv *btv, const u8 ee[256]); static void modtec_eeprom(struct bttv *btv); static void init_PXC200(struct bttv *btv); static void init_RTV24(struct bttv *btv); static void init_PCI8604PW(struct bttv *btv); static void rv605_muxsel(struct bttv *btv, unsigned int input); static void eagle_muxsel(struct bttv *btv, unsigned int input); static void xguard_muxsel(struct bttv *btv, unsigned int input); static void ivc120_muxsel(struct bttv *btv, unsigned int input); static void gvc1100_muxsel(struct bttv *btv, unsigned int input); static void PXC200_muxsel(struct bttv *btv, unsigned int input); static void picolo_tetra_muxsel(struct bttv *btv, unsigned int input); static void picolo_tetra_init(struct bttv *btv); static void tibetCS16_muxsel(struct bttv *btv, unsigned int input); static void tibetCS16_init(struct bttv *btv); static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input); static void kodicom4400r_init(struct bttv *btv); static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input); static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input); static void geovision_muxsel(struct bttv *btv, unsigned int input); static void phytec_muxsel(struct bttv *btv, unsigned int input); static void gv800s_muxsel(struct bttv *btv, unsigned int input); static void gv800s_init(struct bttv *btv); static void td3116_muxsel(struct bttv *btv, unsigned int input); static int terratec_active_radio_upgrade(struct bttv *btv); static int tea575x_init(struct bttv *btv); static void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256]); static int pvr_boot(struct bttv *btv); /* config variables */ static unsigned int triton1; static unsigned int vsfx; static unsigned int latency = …; static unsigned int card[BTTV_MAX] = …; static unsigned int pll[BTTV_MAX] = …; static unsigned int tuner[BTTV_MAX] = …; static unsigned int svhs[BTTV_MAX] = …; static unsigned int remote[BTTV_MAX] = …; static unsigned int audiodev[BTTV_MAX]; static unsigned int saa6588[BTTV_MAX]; static struct bttv *master[BTTV_MAX] = …; static unsigned int autoload = …; static unsigned int gpiomask = …; static unsigned int audioall = …; static unsigned int audiomux[5] = …; /* insmod options */ module_param(triton1, int, 0444); module_param(vsfx, int, 0444); module_param(latency, int, 0444); module_param(gpiomask, int, 0444); module_param(audioall, int, 0444); module_param(autoload, int, 0444); module_param_array(…); module_param_array(…); module_param_array(…); module_param_array(…); module_param_array(…); module_param_array(…); module_param_array(…); MODULE_PARM_DESC(…) …; MODULE_PARM_DESC(…) …; MODULE_PARM_DESC(…) …; MODULE_PARM_DESC(…) …; MODULE_PARM_DESC(…) …; MODULE_PARM_DESC(…) …; MODULE_PARM_DESC(…) …; MODULE_PARM_DESC(…) …; MODULE_PARM_DESC(…) …; MODULE_FIRMWARE(…) …; /* I2C addresses list */ #define I2C_ADDR_TDA7432 … #define I2C_ADDR_MSP3400 … #define I2C_ADDR_MSP3400_ALT … /* ----------------------------------------------------------------------- */ /* list of card IDs for bt878+ cards */ static struct CARD { … } cards[] = …; /* ----------------------------------------------------------------------- */ /* array with description for bt848 / bt878 tv/grabber cards */ struct tvcard bttv_tvcards[] = …; static const unsigned int bttv_num_tvcards = …; /* ----------------------------------------------------------------------- */ static unsigned char eeprom_data[256]; /* * identify card */ void bttv_idcard(struct bttv *btv) { … } /* * (most) board specific initialisations goes here */ /* Some Modular Technology cards have an eeprom, but no subsystem ID */ static void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256]) { … } static void flyvideo_gpio(struct bttv *btv) { … } static int miro_tunermap[] = …; static int miro_fmtuner[] = …; static void miro_pinnacle_gpio(struct bttv *btv) { … } /* GPIO21 L: Buffer aktiv, H: Buffer inaktiv */ #define LM1882_SYNC_DRIVE … static void init_ids_eagle(struct bttv *btv) { … } /* Muxsel helper for the IDS Eagle. * the eagles does not use the standard muxsel-bits but * has its own multiplexer */ static void eagle_muxsel(struct bttv *btv, unsigned int input) { … } static void gvc1100_muxsel(struct bttv *btv, unsigned int input) { … } /* LMLBT4x initialization - to allow access to GPIO bits for sensors input and alarms output GPIObit | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | assignment | TI | O3|INx| O2| O1|IN4|IN3|IN2|IN1| | | IN - sensor inputs, INx - sensor inputs and TI XORed together O1,O2,O3 - alarm outputs (relays) OUT ENABLE 1 1 0 . 1 1 0 0 . 0 0 0 0 = 0x6C0 */ static void init_lmlbt4x(struct bttv *btv) { … } static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input) { … } static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input) { … } static void geovision_muxsel(struct bttv *btv, unsigned int input) { … } /* * The TD3116 has 2 74HC4051 muxes wired to the MUX0 input of a bt878. * The first 74HC4051 has the lower 8 inputs, the second one the higher 8. * The muxes are controlled via a 74HC373 latch which is connected to * GPIOs 0-7. GPIO 18 is connected to the LE signal of the latch. * Q0 of the latch is connected to the Enable (~E) input of the first * 74HC4051. Q1 - Q3 are connected to S0 - S2 of the same 74HC4051. * Q4 - Q7 are connected to the second 74HC4051 in the same way. */ static void td3116_latch_value(struct bttv *btv, u32 value) { … } static void td3116_muxsel(struct bttv *btv, unsigned int input) { … } /* ----------------------------------------------------------------------- */ static void bttv_reset_audio(struct bttv *btv) { … } /* initialization part one -- before registering i2c bus */ void bttv_init_card1(struct bttv *btv) { … } /* initialization part two -- after registering i2c bus */ void bttv_init_card2(struct bttv *btv) { … } /* initialize the tuner */ void bttv_init_tuner(struct bttv *btv) { … } /* ----------------------------------------------------------------------- */ static void modtec_eeprom(struct bttv *btv) { … } static void hauppauge_eeprom(struct bttv *btv) { … } /* ----------------------------------------------------------------------- */ static void bttv_tea575x_set_pins(struct snd_tea575x *tea, u8 pins) { … } static u8 bttv_tea575x_get_pins(struct snd_tea575x *tea) { … } static void bttv_tea575x_set_direction(struct snd_tea575x *tea, bool output) { … } static const struct snd_tea575x_ops bttv_tea_ops = …; static int tea575x_init(struct bttv *btv) { … } /* ----------------------------------------------------------------------- */ static int terratec_active_radio_upgrade(struct bttv *btv) { … } /* ----------------------------------------------------------------------- */ /* * minimal bootstrap for the WinTV/PVR -- upload altera firmware. * * The hcwamc.rbf firmware file is on the Hauppauge driver CD. Have * a look at Pvr/pvr45xxx.EXE (self-extracting zip archive, can be * unpacked with unzip). */ #define PVR_GPIO_DELAY … #define BTTV_ALT_DATA … #define BTTV_ALT_DCLK … #define BTTV_ALT_NCONFIG … static int pvr_altera_load(struct bttv *btv, const u8 *micro, u32 microlen) { … } static int pvr_boot(struct bttv *btv) { … } /* ----------------------------------------------------------------------- */ /* some osprey specific stuff */ static void osprey_eeprom(struct bttv *btv, const u8 ee[256]) { … } /* ----------------------------------------------------------------------- */ /* AVermedia specific stuff, from bktr_card.c */ static int tuner_0_table[] = …; static int tuner_1_table[] = …; static void avermedia_eeprom(struct bttv *btv) { … } /* * For Voodoo TV/FM and Voodoo 200. These cards' tuners use a TDA9880 * analog demod, which is not I2C controlled like the newer and more common * TDA9887 series. Instead it has two tri-state input pins, S0 and S1, * that control the IF for the video and audio. Apparently, bttv GPIO * 0x10000 is connected to S0. S0 low selects a 38.9 MHz VIF for B/G/D/K/I * (i.e., PAL) while high selects 45.75 MHz for M/N (i.e., NTSC). */ u32 bttv_tda9880_setnorm(struct bttv *btv, u32 gpiobits) { … } /* * reset/enable the MSP on some Hauppauge cards * Thanks to Kyösti Mälkki ([email protected])! * * Hauppauge: pin 5 * Voodoo: pin 20 */ static void boot_msp34xx(struct bttv *btv, int pin) { … } /* ----------------------------------------------------------------------- */ /* Imagenation L-Model PXC200 Framegrabber */ /* This is basically the same procedure as * used by Alessandro Rubini in his pxc200 * driver, but using BTTV functions */ static void init_PXC200(struct bttv *btv) { … } /* ----------------------------------------------------------------------- */ /* * The Adlink RTV-24 (aka Angelo) has some special initialisation to unlock * it. This apparently involves the following procedure for each 878 chip: * * 1) write 0x00C3FEFF to the GPIO_OUT_EN register * * 2) write to GPIO_DATA * - 0x0E * - sleep 1ms * - 0x10 + 0x0E * - sleep 10ms * - 0x0E * read from GPIO_DATA into buf (uint_32) * - if ( data>>18 & 0x01 != 0) || ( buf>>19 & 0x01 != 1 ) * error. ERROR_CPLD_Check_Failed stop. * * 3) write to GPIO_DATA * - write 0x4400 + 0x0E * - sleep 10ms * - write 0x4410 + 0x0E * - sleep 1ms * - write 0x0E * read from GPIO_DATA into buf (uint_32) * - if ( buf>>18 & 0x01 ) || ( buf>>19 & 0x01 != 0 ) * error. ERROR_CPLD_Check_Failed. */ /* ----------------------------------------------------------------------- */ static void init_RTV24 (struct bttv *btv) { … } /* ----------------------------------------------------------------------- */ /* * The PCI-8604PW contains a CPLD, probably an ispMACH 4A, that filters * the PCI REQ signals coming from the four BT878 chips. After power * up, the CPLD does not forward requests to the bus, which prevents * the BT878 from fetching RISC instructions from memory. While the * CPLD is connected to most of the GPIOs of PCI device 0xD, only * five appear to play a role in unlocking the REQ signal. The following * sequence has been determined by trial and error without access to the * original driver. * * Eight GPIOs of device 0xC are provided on connector CN4 (4 in, 4 out). * Devices 0xE and 0xF do not appear to have anything connected to their * GPIOs. * * The correct GPIO_OUT_EN value might have some more bits set. It should * be possible to derive it from a boundary scan of the CPLD. Its JTAG * pins are routed to test points. * */ /* ----------------------------------------------------------------------- */ static void init_PCI8604PW(struct bttv *btv) { … } /* RemoteVision MX (rv605) muxsel helper [Miguel Freitas] * * This is needed because rv605 don't use a normal multiplex, but a crosspoint * switch instead (CD22M3494E). This IC can have multiple active connections * between Xn (input) and Yn (output) pins. We need to clear any existing * connection prior to establish a new one, pulsing the STROBE pin. * * The board hardwire Y0 (xpoint) to MUX1 and MUXOUT to Yin. * GPIO pins are wired as: * GPIO[0:3] - AX[0:3] (xpoint) - P1[0:3] (microcontroller) * GPIO[4:6] - AY[0:2] (xpoint) - P1[4:6] (microcontroller) * GPIO[7] - DATA (xpoint) - P1[7] (microcontroller) * GPIO[8] - - P3[5] (microcontroller) * GPIO[9] - RESET (xpoint) - P3[6] (microcontroller) * GPIO[10] - STROBE (xpoint) - P3[7] (microcontroller) * GPINTR - - P3[4] (microcontroller) * * The microcontroller is a 80C32 like. It should be possible to change xpoint * configuration either directly (as we are doing) or using the microcontroller * which is also wired to I2C interface. I have no further info on the * microcontroller features, one would need to disassembly the firmware. * note: the vendor refused to give any information on this product, all * that stuff was found using a multimeter! :) */ static void rv605_muxsel(struct bttv *btv, unsigned int input) { … } /* Tibet Systems 'Progress DVR' CS16 muxsel helper [Chris Fanning] * * The CS16 (available on eBay cheap) is a PCI board with four Fusion * 878A chips, a PCI bridge, an Atmel microcontroller, four sync separator * chips, ten eight input analog multiplexors, a not chip and a few * other components. * * 16 inputs on a secondary bracket are provided and can be selected * from each of the four capture chips. Two of the eight input * multiplexors are used to select from any of the 16 input signals. * * Unsupported hardware capabilities: * . A video output monitor on the secondary bracket can be selected from * one of the 878A chips. * . Another passthrough but I haven't spent any time investigating it. * . Digital I/O (logic level connected to GPIO) is available from an * onboard header. * * The on chip input mux should always be set to 2. * GPIO[16:19] - Video input selection * GPIO[0:3] - Video output monitor select (only available from one 878A) * GPIO[?:?] - Digital I/O. * * There is an ATMEL microcontroller with an 8031 core on board. I have not * determined what function (if any) it provides. With the microcontroller * and sync separator chips a guess is that it might have to do with video * switching and maybe some digital I/O. */ static void tibetCS16_muxsel(struct bttv *btv, unsigned int input) { … } static void tibetCS16_init(struct bttv *btv) { … } /* * The following routines for the Kodicom-4400r get a little mind-twisting. * There is a "master" controller and three "slave" controllers, together * an analog switch which connects any of 16 cameras to any of the BT87A's. * The analog switch is controlled by the "master", but the detection order * of the four BT878A chips is in an order which I just don't understand. * The "master" is actually the second controller to be detected. The * logic on the board uses logical numbers for the 4 controllers, but * those numbers are different from the detection sequence. When working * with the analog switch, we need to "map" from the detection sequence * over to the board's logical controller number. This mapping sequence * is {3, 0, 2, 1}, i.e. the first controller to be detected is logical * unit 3, the second (which is the master) is logical unit 0, etc. * We need to maintain the status of the analog switch (which of the 16 * cameras is connected to which of the 4 controllers) in sw_status array. */ /* * First a routine to set the analog switch, which controls which camera * is routed to which controller. The switch comprises an X-address * (gpio bits 0-3, representing the camera, ranging from 0-15), and a * Y-address (gpio bits 4-6, representing the controller, ranging from 0-3). * A data value (gpio bit 7) of '1' enables the switch, and '0' disables * the switch. A STROBE bit (gpio bit 8) latches the data value into the * specified address. The idea is to set the address and data, then bring * STROBE high, and finally bring STROBE back to low. */ static void kodicom4400r_write(struct bttv *btv, unsigned char xaddr, unsigned char yaddr, unsigned char data) { … } /* * Next the mux select. Both the "master" and "slave" 'cards' (controllers) * use this routine. The routine finds the "master" for the card, maps * the controller number from the detected position over to the logical * number, writes the appropriate data to the analog switch, and housekeeps * the local copy of the switch information. The parameter 'input' is the * requested camera number (0 - 15). */ static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input) { … } /* * During initialisation, we need to reset the analog switch. We * also preset the switch to map the 4 connectors on the card to the * *user's* (see above description of kodicom4400r_muxsel) channels * 0 through 3 */ static void kodicom4400r_init(struct bttv *btv) { … } /* The Grandtec X-Guard framegrabber card uses two Dual 4-channel * video multiplexers to provide up to 16 video inputs. These * multiplexers are controlled by the lower 8 GPIO pins of the * bt878. The multiplexers probably Pericom PI5V331Q or similar. * xxx0 is pin xxx of multiplexer U5, * yyy1 is pin yyy of multiplexer U2 */ #define ENA0 … #define ENB0 … #define ENA1 … #define ENB1 … #define IN10 … #define IN00 … #define IN11 … #define IN01 … static void xguard_muxsel(struct bttv *btv, unsigned int input) { … } static void picolo_tetra_init(struct bttv *btv) { … } static void picolo_tetra_muxsel (struct bttv* btv, unsigned int input) { … } /* * ivc120_muxsel [Added by Alan Garfield <[email protected]>] * * The IVC120G security card has 4 i2c controlled TDA8540 matrix * switchers to provide 16 channels to MUX0. The TDA8540's have * 4 independent outputs and as such the IVC120G also has the * optional "Monitor Out" bus. This allows the card to be looking * at one input while the monitor is looking at another. * * Since I've couldn't be bothered figuring out how to add an * independent muxsel for the monitor bus, I've just set it to * whatever the card is looking at. * * OUT0 of the TDA8540's is connected to MUX0 (0x03) * OUT1 of the TDA8540's is connected to "Monitor Out" (0x0C) * * TDA8540_ALT3 IN0-3 = Channel 13 - 16 (0x03) * TDA8540_ALT4 IN0-3 = Channel 1 - 4 (0x03) * TDA8540_ALT5 IN0-3 = Channel 5 - 8 (0x03) * TDA8540_ALT6 IN0-3 = Channel 9 - 12 (0x03) * */ /* All 7 possible sub-ids for the TDA8540 Matrix Switcher */ #define I2C_TDA8540 … #define I2C_TDA8540_ALT1 … #define I2C_TDA8540_ALT2 … #define I2C_TDA8540_ALT3 … #define I2C_TDA8540_ALT4 … #define I2C_TDA8540_ALT5 … #define I2C_TDA8540_ALT6 … static void ivc120_muxsel(struct bttv *btv, unsigned int input) { … } /* PXC200 muxsel helper * [email protected] * another transplant * from Alessandro Rubini ([email protected]) * * There are 4 kinds of cards: * PXC200L which is bt848 * PXC200F which is bt848 with PIC controlling mux * PXC200AL which is bt878 * PXC200AF which is bt878 with PIC controlling mux */ #define PX_CFG_PXC200F … #define PX_FLAG_PXC200A … #define PX_I2C_PIC … #define PX_PXC200A_CARDID … #define PX_I2C_CMD_CFG … static void PXC200_muxsel(struct bttv *btv, unsigned int input) { … } static void phytec_muxsel(struct bttv *btv, unsigned int input) { … } /* * GeoVision GV-800(S) functions * Bruno Christo <[email protected]> */ /* This is a function to control the analog switch, which determines which * camera is routed to which controller. The switch comprises an X-address * (gpio bits 0-3, representing the camera, ranging from 0-15), and a * Y-address (gpio bits 4-6, representing the controller, ranging from 0-3). * A data value (gpio bit 18) of '1' enables the switch, and '0' disables * the switch. A STROBE bit (gpio bit 17) latches the data value into the * specified address. There is also a chip select (gpio bit 16). * The idea is to set the address and chip select together, bring * STROBE high, write the data, and finally bring STROBE back to low. */ static void gv800s_write(struct bttv *btv, unsigned char xaddr, unsigned char yaddr, unsigned char data) { … } /* * GeoVision GV-800(S) muxsel * * Each of the 4 cards (controllers) use this function. * The controller using this function selects the input through the GPIO pins * of the "master" card. A pointer to this card is stored in master[btv->c.nr]. * * The parameter 'input' is the requested camera number (0-4) on the controller. * The map array has the address of each input. Note that the addresses in the * array are in the sequence the original GeoVision driver uses, that is, set * every controller to input 0, then to input 1, 2, 3, repeat. This means that * the physical "camera 1" connector corresponds to controller 0 input 0, * "camera 2" corresponds to controller 1 input 0, and so on. * * After getting the input address, the function then writes the appropriate * data to the analog switch, and housekeeps the local copy of the switch * information. */ static void gv800s_muxsel(struct bttv *btv, unsigned int input) { … } /* GeoVision GV-800(S) "master" chip init */ static void gv800s_init(struct bttv *btv) { … } /* ----------------------------------------------------------------------- */ /* motherboard chipset specific stuff */ void __init bttv_check_chipset(void) { … } int bttv_handle_chipset(struct bttv *btv) { … }