bttv-cards.c (0c49cd295d42d0032af11d55e2140dbec11dc8d0) bttv-cards.c (1b500373157c7c4da2765e3416834e86224373d6)
1/*
2
3 bttv-cards.c
4
5 this file has configuration informations - card-specific stuff
6 like the big tvcards array for the most part
7
8 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)

--- 70 unchanged lines hidden (view full) ---

79static void phytec_muxsel(struct bttv *btv, unsigned int input);
80
81static void gv800s_muxsel(struct bttv *btv, unsigned int input);
82static void gv800s_init(struct bttv *btv);
83
84static void td3116_muxsel(struct bttv *btv, unsigned int input);
85
86static int terratec_active_radio_upgrade(struct bttv *btv);
1/*
2
3 bttv-cards.c
4
5 this file has configuration informations - card-specific stuff
6 like the big tvcards array for the most part
7
8 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)

--- 70 unchanged lines hidden (view full) ---

79static void phytec_muxsel(struct bttv *btv, unsigned int input);
80
81static void gv800s_muxsel(struct bttv *btv, unsigned int input);
82static void gv800s_init(struct bttv *btv);
83
84static void td3116_muxsel(struct bttv *btv, unsigned int input);
85
86static int terratec_active_radio_upgrade(struct bttv *btv);
87static int tea5757_read(struct bttv *btv);
88static int tea5757_write(struct bttv *btv, int value);
87static int tea575x_init(struct bttv *btv);
89static void identify_by_eeprom(struct bttv *btv,
90 unsigned char eeprom_data[256]);
91static int pvr_boot(struct bttv *btv);
92
93/* config variables */
94static unsigned int triton1;
95static unsigned int vsfx;
96static unsigned int latency = UNSET;

--- 2983 unchanged lines hidden (view full) ---

3080 gpio = gpio_read();
3081 id = ((gpio>>10) & 63) -1;
3082 msp = bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx");
3083 if (id < 32) {
3084 btv->tuner_type = miro_tunermap[id];
3085 if (0 == (gpio & 0x20)) {
3086 btv->has_radio = 1;
3087 if (!miro_fmtuner[id]) {
88static void identify_by_eeprom(struct bttv *btv,
89 unsigned char eeprom_data[256]);
90static int pvr_boot(struct bttv *btv);
91
92/* config variables */
93static unsigned int triton1;
94static unsigned int vsfx;
95static unsigned int latency = UNSET;

--- 2983 unchanged lines hidden (view full) ---

3079 gpio = gpio_read();
3080 id = ((gpio>>10) & 63) -1;
3081 msp = bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx");
3082 if (id < 32) {
3083 btv->tuner_type = miro_tunermap[id];
3084 if (0 == (gpio & 0x20)) {
3085 btv->has_radio = 1;
3086 if (!miro_fmtuner[id]) {
3088 btv->has_matchbox = 1;
3089 btv->mbox_we = (1<<6);
3090 btv->mbox_most = (1<<7);
3091 btv->mbox_clk = (1<<8);
3092 btv->mbox_data = (1<<9);
3093 btv->mbox_mask = (1<<6)|(1<<7)|(1<<8)|(1<<9);
3087 btv->has_tea575x = 1;
3088 btv->tea_gpio.wren = 6;
3089 btv->tea_gpio.most = 7;
3090 btv->tea_gpio.clk = 8;
3091 btv->tea_gpio.data = 9;
3092 tea575x_init(btv);
3094 }
3095 } else {
3096 btv->has_radio = 0;
3097 }
3098 if (-1 != msp) {
3099 if (btv->c.type == BTTV_BOARD_MIRO)
3100 btv->c.type = BTTV_BOARD_MIROPRO;
3101 if (btv->c.type == BTTV_BOARD_PINNACLE)
3102 btv->c.type = BTTV_BOARD_PINNACLEPRO;
3103 }
3104 pr_info("%d: miro: id=%d tuner=%d radio=%s stereo=%s\n",
3105 btv->c.nr, id+1, btv->tuner_type,
3106 !btv->has_radio ? "no" :
3093 }
3094 } else {
3095 btv->has_radio = 0;
3096 }
3097 if (-1 != msp) {
3098 if (btv->c.type == BTTV_BOARD_MIRO)
3099 btv->c.type = BTTV_BOARD_MIROPRO;
3100 if (btv->c.type == BTTV_BOARD_PINNACLE)
3101 btv->c.type = BTTV_BOARD_PINNACLEPRO;
3102 }
3103 pr_info("%d: miro: id=%d tuner=%d radio=%s stereo=%s\n",
3104 btv->c.nr, id+1, btv->tuner_type,
3105 !btv->has_radio ? "no" :
3107 (btv->has_matchbox ? "matchbox" : "fmtuner"),
3106 (btv->has_tea575x ? "tea575x" : "fmtuner"),
3108 (-1 == msp) ? "no" : "yes");
3109 } else {
3110 /* new cards with microtune tuner */
3111 id = 63 - id;
3112 btv->has_radio = 0;
3113 switch (id) {
3114 case 1:
3115 info = "PAL / mono";

--- 261 unchanged lines hidden (view full) ---

3377 case BTTV_BOARD_PXC200:
3378 init_PXC200(btv);
3379 break;
3380 case BTTV_BOARD_PICOLO_TETRA_CHIP:
3381 picolo_tetra_init(btv);
3382 break;
3383 case BTTV_BOARD_VHX:
3384 btv->has_radio = 1;
3107 (-1 == msp) ? "no" : "yes");
3108 } else {
3109 /* new cards with microtune tuner */
3110 id = 63 - id;
3111 btv->has_radio = 0;
3112 switch (id) {
3113 case 1:
3114 info = "PAL / mono";

--- 261 unchanged lines hidden (view full) ---

3376 case BTTV_BOARD_PXC200:
3377 init_PXC200(btv);
3378 break;
3379 case BTTV_BOARD_PICOLO_TETRA_CHIP:
3380 picolo_tetra_init(btv);
3381 break;
3382 case BTTV_BOARD_VHX:
3383 btv->has_radio = 1;
3385 btv->has_matchbox = 1;
3386 btv->mbox_we = 0x20;
3387 btv->mbox_most = 0;
3388 btv->mbox_clk = 0x08;
3389 btv->mbox_data = 0x10;
3390 btv->mbox_mask = 0x38;
3384 btv->has_tea575x = 1;
3385 btv->tea_gpio.wren = 5;
3386 btv->tea_gpio.most = 6;
3387 btv->tea_gpio.clk = 3;
3388 btv->tea_gpio.data = 4;
3389 tea575x_init(btv);
3391 break;
3392 case BTTV_BOARD_VOBIS_BOOSTAR:
3393 case BTTV_BOARD_TERRATV:
3394 terratec_active_radio_upgrade(btv);
3395 break;
3396 case BTTV_BOARD_MAGICTVIEW061:
3397 if (btv->cardid == 0x3002144f) {
3398 btv->has_radio=1;

--- 341 unchanged lines hidden (view full) ---

3740 btv->c.type = BTTV_BOARD_HAUPPAUGE_IMPACTVCB;
3741 }
3742
3743 /* The 61334 needs the msp3410 to do the radio demod to get sound */
3744 if (tv.model == 61334)
3745 btv->radio_uses_msp_demodulator = 1;
3746}
3747
3390 break;
3391 case BTTV_BOARD_VOBIS_BOOSTAR:
3392 case BTTV_BOARD_TERRATV:
3393 terratec_active_radio_upgrade(btv);
3394 break;
3395 case BTTV_BOARD_MAGICTVIEW061:
3396 if (btv->cardid == 0x3002144f) {
3397 btv->has_radio=1;

--- 341 unchanged lines hidden (view full) ---

3739 btv->c.type = BTTV_BOARD_HAUPPAUGE_IMPACTVCB;
3740 }
3741
3742 /* The 61334 needs the msp3410 to do the radio demod to get sound */
3743 if (tv.model == 61334)
3744 btv->radio_uses_msp_demodulator = 1;
3745}
3746
3748static int terratec_active_radio_upgrade(struct bttv *btv)
3747/* ----------------------------------------------------------------------- */
3748
3749static void bttv_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
3749{
3750{
3750 int freq;
3751 struct bttv *btv = tea->private_data;
3752 struct bttv_tea575x_gpio gpio = btv->tea_gpio;
3753 u16 val = 0;
3751
3754
3755 val |= (pins & TEA575X_DATA) ? (1 << gpio.data) : 0;
3756 val |= (pins & TEA575X_CLK) ? (1 << gpio.clk) : 0;
3757 val |= (pins & TEA575X_WREN) ? (1 << gpio.wren) : 0;
3758
3759 gpio_bits((1 << gpio.data) | (1 << gpio.clk) | (1 << gpio.wren), val);
3760 if (btv->mbox_ior) {
3761 /* IOW and CSEL active */
3762 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
3763 udelay(5);
3764 /* all inactive */
3765 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3766 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3767 }
3768}
3769
3770static u8 bttv_tea575x_get_pins(struct snd_tea575x *tea)
3771{
3772 struct bttv *btv = tea->private_data;
3773 struct bttv_tea575x_gpio gpio = btv->tea_gpio;
3774 u8 ret = 0;
3775 u16 val;
3776
3777 if (btv->mbox_ior) {
3778 /* IOR and CSEL active */
3779 gpio_bits(btv->mbox_ior | btv->mbox_csel, 0);
3780 udelay(5);
3781 }
3782 val = gpio_read();
3783 if (btv->mbox_ior) {
3784 /* all inactive */
3785 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
3786 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
3787 }
3788
3789 if (val & (1 << gpio.data))
3790 ret |= TEA575X_DATA;
3791 if (val & (1 << gpio.most))
3792 ret |= TEA575X_MOST;
3793
3794 return ret;
3795}
3796
3797static void bttv_tea575x_set_direction(struct snd_tea575x *tea, bool output)
3798{
3799 struct bttv *btv = tea->private_data;
3800 struct bttv_tea575x_gpio gpio = btv->tea_gpio;
3801 u32 mask = (1 << gpio.clk) | (1 << gpio.wren) | (1 << gpio.data) |
3802 (1 << gpio.most);
3803
3804 if (output)
3805 gpio_inout(mask, (1 << gpio.data) | (1 << gpio.clk) |
3806 (1 << gpio.wren));
3807 else
3808 gpio_inout(mask, (1 << gpio.clk) | (1 << gpio.wren));
3809}
3810
3811static struct snd_tea575x_ops bttv_tea_ops = {
3812 .set_pins = bttv_tea575x_set_pins,
3813 .get_pins = bttv_tea575x_get_pins,
3814 .set_direction = bttv_tea575x_set_direction,
3815};
3816
3817static int tea575x_init(struct bttv *btv)
3818{
3819 btv->tea.private_data = btv;
3820 btv->tea.ops = &bttv_tea_ops;
3821 if (!snd_tea575x_hw_init(&btv->tea)) {
3822 pr_info("%d: detected TEA575x radio\n", btv->c.nr);
3823 btv->tea.mute = false;
3824 return 0;
3825 }
3826
3827 btv->has_tea575x = 0;
3828 btv->has_radio = 0;
3829
3830 return -ENODEV;
3831}
3832
3833/* ----------------------------------------------------------------------- */
3834
3835static int terratec_active_radio_upgrade(struct bttv *btv)
3836{
3752 btv->has_radio = 1;
3837 btv->has_radio = 1;
3753 btv->has_matchbox = 1;
3754 btv->mbox_we = 0x10;
3755 btv->mbox_most = 0x20;
3756 btv->mbox_clk = 0x08;
3757 btv->mbox_data = 0x04;
3758 btv->mbox_mask = 0x3c;
3838 btv->has_tea575x = 1;
3839 btv->tea_gpio.wren = 4;
3840 btv->tea_gpio.most = 5;
3841 btv->tea_gpio.clk = 3;
3842 btv->tea_gpio.data = 2;
3759
3760 btv->mbox_iow = 1 << 8;
3761 btv->mbox_ior = 1 << 9;
3762 btv->mbox_csel = 1 << 10;
3763
3843
3844 btv->mbox_iow = 1 << 8;
3845 btv->mbox_ior = 1 << 9;
3846 btv->mbox_csel = 1 << 10;
3847
3764 freq=88000/62.5;
3765 tea5757_write(btv, 5 * freq + 0x358); /* write 0x1ed8 */
3766 if (0x1ed8 == tea5757_read(btv)) {
3848 if (!tea575x_init(btv)) {
3767 pr_info("%d: Terratec Active Radio Upgrade found\n", btv->c.nr);
3849 pr_info("%d: Terratec Active Radio Upgrade found\n", btv->c.nr);
3768 btv->has_radio = 1;
3769 btv->has_saa6588 = 1;
3770 btv->has_matchbox = 1;
3771 } else {
3772 btv->has_radio = 0;
3773 btv->has_matchbox = 0;
3850 btv->has_saa6588 = 1;
3774 }
3851 }
3852
3775 return 0;
3776}
3777
3778
3779/* ----------------------------------------------------------------------- */
3780
3781/*
3782 * minimal bootstrap for the WinTV/PVR -- upload altera firmware.

--- 504 unchanged lines hidden (view full) ---

4287 pr_err("PCI-8604PW invalid transition %i -> %i\n",
4288 state >> 4, state & 7);
4289 return;
4290 }
4291 state &= 7;
4292 }
4293}
4294
3853 return 0;
3854}
3855
3856
3857/* ----------------------------------------------------------------------- */
3858
3859/*
3860 * minimal bootstrap for the WinTV/PVR -- upload altera firmware.

--- 504 unchanged lines hidden (view full) ---

4365 pr_err("PCI-8604PW invalid transition %i -> %i\n",
4366 state >> 4, state & 7);
4367 return;
4368 }
4369 state &= 7;
4370 }
4371}
4372
4295
4296
4297/* ----------------------------------------------------------------------- */
4298/* Miro Pro radio stuff -- the tea5757 is connected to some GPIO ports */
4299/*
4300 * Copyright (c) 1999 Csaba Halasz <qgehali@uni-miskolc.hu>
4301 * This code is placed under the terms of the GNU General Public License
4302 *
4303 * Brutally hacked by Dan Sheridan <dan.sheridan@contact.org.uk> djs52 8/3/00
4304 */
4305
4306static void bus_low(struct bttv *btv, int bit)
4307{
4308 if (btv->mbox_ior) {
4309 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
4310 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
4311 udelay(5);
4312 }
4313
4314 gpio_bits(bit,0);
4315 udelay(5);
4316
4317 if (btv->mbox_ior) {
4318 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
4319 udelay(5);
4320 }
4321}
4322
4323static void bus_high(struct bttv *btv, int bit)
4324{
4325 if (btv->mbox_ior) {
4326 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
4327 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
4328 udelay(5);
4329 }
4330
4331 gpio_bits(bit,bit);
4332 udelay(5);
4333
4334 if (btv->mbox_ior) {
4335 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
4336 udelay(5);
4337 }
4338}
4339
4340static int bus_in(struct bttv *btv, int bit)
4341{
4342 if (btv->mbox_ior) {
4343 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
4344 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
4345 udelay(5);
4346
4347 gpio_bits(btv->mbox_iow | btv->mbox_csel, 0);
4348 udelay(5);
4349 }
4350 return gpio_read() & (bit);
4351}
4352
4353/* TEA5757 register bits */
4354#define TEA_FREQ 0:14
4355#define TEA_BUFFER 15:15
4356
4357#define TEA_SIGNAL_STRENGTH 16:17
4358
4359#define TEA_PORT1 18:18
4360#define TEA_PORT0 19:19
4361
4362#define TEA_BAND 20:21
4363#define TEA_BAND_FM 0
4364#define TEA_BAND_MW 1
4365#define TEA_BAND_LW 2
4366#define TEA_BAND_SW 3
4367
4368#define TEA_MONO 22:22
4369#define TEA_ALLOW_STEREO 0
4370#define TEA_FORCE_MONO 1
4371
4372#define TEA_SEARCH_DIRECTION 23:23
4373#define TEA_SEARCH_DOWN 0
4374#define TEA_SEARCH_UP 1
4375
4376#define TEA_STATUS 24:24
4377#define TEA_STATUS_TUNED 0
4378#define TEA_STATUS_SEARCHING 1
4379
4380/* Low-level stuff */
4381static int tea5757_read(struct bttv *btv)
4382{
4383 unsigned long timeout;
4384 int value = 0;
4385 int i;
4386
4387 /* better safe than sorry */
4388 gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we);
4389
4390 if (btv->mbox_ior) {
4391 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
4392 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
4393 udelay(5);
4394 }
4395
4396 if (bttv_gpio)
4397 bttv_gpio_tracking(btv,"tea5757 read");
4398
4399 bus_low(btv,btv->mbox_we);
4400 bus_low(btv,btv->mbox_clk);
4401
4402 udelay(10);
4403 timeout= jiffies + msecs_to_jiffies(1000);
4404
4405 /* wait for DATA line to go low; error if it doesn't */
4406 while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout))
4407 schedule();
4408 if (bus_in(btv,btv->mbox_data)) {
4409 pr_warn("%d: tea5757: read timeout\n", btv->c.nr);
4410 return -1;
4411 }
4412
4413 dprintk("%d: tea5757:", btv->c.nr);
4414 for (i = 0; i < 24; i++) {
4415 udelay(5);
4416 bus_high(btv,btv->mbox_clk);
4417 udelay(5);
4418 dprintk_cont("%c",
4419 bus_in(btv, btv->mbox_most) == 0 ? 'T' : '-');
4420 bus_low(btv,btv->mbox_clk);
4421 value <<= 1;
4422 value |= (bus_in(btv,btv->mbox_data) == 0)?0:1; /* MSB first */
4423 dprintk_cont("%c",
4424 bus_in(btv, btv->mbox_most) == 0 ? 'S' : 'M');
4425 }
4426 dprintk_cont("\n");
4427 dprintk("%d: tea5757: read 0x%X\n", btv->c.nr, value);
4428 return value;
4429}
4430
4431static int tea5757_write(struct bttv *btv, int value)
4432{
4433 int i;
4434 int reg = value;
4435
4436 gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we | btv->mbox_data);
4437
4438 if (btv->mbox_ior) {
4439 gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel,
4440 btv->mbox_ior | btv->mbox_iow | btv->mbox_csel);
4441 udelay(5);
4442 }
4443 if (bttv_gpio)
4444 bttv_gpio_tracking(btv,"tea5757 write");
4445
4446 dprintk("%d: tea5757: write 0x%X\n", btv->c.nr, value);
4447 bus_low(btv,btv->mbox_clk);
4448 bus_high(btv,btv->mbox_we);
4449 for (i = 0; i < 25; i++) {
4450 if (reg & 0x1000000)
4451 bus_high(btv,btv->mbox_data);
4452 else
4453 bus_low(btv,btv->mbox_data);
4454 reg <<= 1;
4455 bus_high(btv,btv->mbox_clk);
4456 udelay(10);
4457 bus_low(btv,btv->mbox_clk);
4458 udelay(10);
4459 }
4460 bus_low(btv,btv->mbox_we); /* unmute !!! */
4461 return 0;
4462}
4463
4464void tea5757_set_freq(struct bttv *btv, unsigned short freq)
4465{
4466 dprintk("tea5757_set_freq %d\n",freq);
4467 tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */
4468}
4469
4470/* RemoteVision MX (rv605) muxsel helper [Miguel Freitas]
4471 *
4472 * This is needed because rv605 don't use a normal multiplex, but a crosspoint
4473 * switch instead (CD22M3494E). This IC can have multiple active connections
4474 * between Xn (input) and Yn (output) pins. We need to clear any existing
4475 * connection prior to establish a new one, pulsing the STROBE pin.
4476 *
4477 * The board hardwire Y0 (xpoint) to MUX1 and MUXOUT to Yin.

--- 565 unchanged lines hidden (view full) ---

5043 if (vsfx)
5044 command |= BT878_EN_VSFX;
5045 pci_write_config_byte(btv->c.pci, BT878_DEVCTRL, command);
5046 }
5047 if (UNSET != latency)
5048 pci_write_config_byte(btv->c.pci, PCI_LATENCY_TIMER, latency);
5049 return 0;
5050}
4373/* RemoteVision MX (rv605) muxsel helper [Miguel Freitas]
4374 *
4375 * This is needed because rv605 don't use a normal multiplex, but a crosspoint
4376 * switch instead (CD22M3494E). This IC can have multiple active connections
4377 * between Xn (input) and Yn (output) pins. We need to clear any existing
4378 * connection prior to establish a new one, pulsing the STROBE pin.
4379 *
4380 * The board hardwire Y0 (xpoint) to MUX1 and MUXOUT to Yin.

--- 565 unchanged lines hidden (view full) ---

4946 if (vsfx)
4947 command |= BT878_EN_VSFX;
4948 pci_write_config_byte(btv->c.pci, BT878_DEVCTRL, command);
4949 }
4950 if (UNSET != latency)
4951 pci_write_config_byte(btv->c.pci, PCI_LATENCY_TIMER, latency);
4952 return 0;
4953}
5051
5052
5053/*
5054 * Local variables:
5055 * c-basic-offset: 8
5056 * End:
5057 */