diff options
| -rw-r--r-- | sound/pci/es1968.c | 95 |
1 files changed, 24 insertions, 71 deletions
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index faf9138970ae..75c5e0ed6955 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c | |||
| @@ -2591,96 +2591,48 @@ static int __devinit snd_es1968_input_register(struct es1968 *chip) | |||
| 2591 | #define STR_WREN 0x0100 /* GPIO8 */ | 2591 | #define STR_WREN 0x0100 /* GPIO8 */ |
| 2592 | #define STR_MOST 0x0200 /* GPIO9 */ | 2592 | #define STR_MOST 0x0200 /* GPIO9 */ |
| 2593 | 2593 | ||
| 2594 | static void snd_es1968_tea575x_write(struct snd_tea575x *tea, unsigned int val) | 2594 | static void snd_es1968_tea575x_set_pins(struct snd_tea575x *tea, u8 pins) |
| 2595 | { | 2595 | { |
| 2596 | struct es1968 *chip = tea->private_data; | 2596 | struct es1968 *chip = tea->private_data; |
| 2597 | unsigned long io = chip->io_port + GPIO_DATA; | 2597 | unsigned long io = chip->io_port + GPIO_DATA; |
| 2598 | u16 l, bits; | 2598 | u16 val = 0; |
| 2599 | u16 omask, odir; | ||
| 2600 | 2599 | ||
| 2601 | omask = inw(io + IO_MASK); | 2600 | val |= (pins & TEA575X_DATA) ? STR_DATA : 0; |
| 2602 | odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN); | 2601 | val |= (pins & TEA575X_CLK) ? STR_CLK : 0; |
| 2603 | outw(odir | STR_DATA, io + IO_DIR); | 2602 | val |= (pins & TEA575X_WREN) ? STR_WREN : 0; |
| 2604 | outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK); | ||
| 2605 | udelay(16); | ||
| 2606 | 2603 | ||
| 2607 | for (l = 25; l; l--) { | 2604 | outw(val, io); |
| 2608 | bits = ((val >> 18) & STR_DATA) | STR_WREN; | ||
| 2609 | val <<= 1; /* shift data */ | ||
| 2610 | outw(bits, io); /* start strobe */ | ||
| 2611 | udelay(2); | ||
| 2612 | outw(bits | STR_CLK, io); /* HI level */ | ||
| 2613 | udelay(2); | ||
| 2614 | outw(bits, io); /* LO level */ | ||
| 2615 | udelay(4); | ||
| 2616 | } | ||
| 2617 | |||
| 2618 | if (!tea->mute) | ||
| 2619 | outw(0, io); | ||
| 2620 | |||
| 2621 | udelay(4); | ||
| 2622 | outw(omask, io + IO_MASK); | ||
| 2623 | outw(odir, io + IO_DIR); | ||
| 2624 | msleep(125); | ||
| 2625 | } | 2605 | } |
| 2626 | 2606 | ||
| 2627 | static unsigned int snd_es1968_tea575x_read(struct snd_tea575x *tea) | 2607 | static u8 snd_es1968_tea575x_get_pins(struct snd_tea575x *tea) |
| 2628 | { | 2608 | { |
| 2629 | struct es1968 *chip = tea->private_data; | 2609 | struct es1968 *chip = tea->private_data; |
| 2630 | unsigned long io = chip->io_port + GPIO_DATA; | 2610 | unsigned long io = chip->io_port + GPIO_DATA; |
| 2631 | u16 l, rdata; | 2611 | u16 val = inw(io); |
| 2632 | u32 data = 0; | ||
| 2633 | u16 omask; | ||
| 2634 | |||
| 2635 | omask = inw(io + IO_MASK); | ||
| 2636 | outw(~(STR_CLK | STR_WREN), io + IO_MASK); | ||
| 2637 | outw(0, io); | ||
| 2638 | udelay(16); | ||
| 2639 | |||
| 2640 | for (l = 24; l--;) { | ||
| 2641 | outw(STR_CLK, io); /* HI state */ | ||
| 2642 | udelay(2); | ||
| 2643 | if (!l) | ||
| 2644 | tea->tuned = inw(io) & STR_MOST ? 0 : 1; | ||
| 2645 | outw(0, io); /* LO state */ | ||
| 2646 | udelay(2); | ||
| 2647 | data <<= 1; /* shift data */ | ||
| 2648 | rdata = inw(io); | ||
| 2649 | if (!l) | ||
| 2650 | tea->stereo = (rdata & STR_MOST) ? 0 : 1; | ||
| 2651 | else if (l && rdata & STR_DATA) | ||
| 2652 | data++; | ||
| 2653 | udelay(2); | ||
| 2654 | } | ||
| 2655 | |||
| 2656 | if (tea->mute) | ||
| 2657 | outw(STR_WREN, io); | ||
| 2658 | |||
| 2659 | udelay(4); | ||
| 2660 | outw(omask, io + IO_MASK); | ||
| 2661 | 2612 | ||
| 2662 | return data & 0x3ffe; | 2613 | return (val & STR_DATA) ? TEA575X_DATA : 0 | |
| 2614 | (val & STR_MOST) ? TEA575X_MOST : 0; | ||
| 2663 | } | 2615 | } |
| 2664 | 2616 | ||
| 2665 | static void snd_es1968_tea575x_mute(struct snd_tea575x *tea, unsigned int mute) | 2617 | static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output) |
| 2666 | { | 2618 | { |
| 2667 | struct es1968 *chip = tea->private_data; | 2619 | struct es1968 *chip = tea->private_data; |
| 2668 | unsigned long io = chip->io_port + GPIO_DATA; | 2620 | unsigned long io = chip->io_port + GPIO_DATA; |
| 2669 | u16 omask; | 2621 | u16 odir = inw(io + IO_DIR); |
| 2670 | 2622 | ||
| 2671 | omask = inw(io + IO_MASK); | 2623 | if (output) { |
| 2672 | outw(~STR_WREN, io + IO_MASK); | 2624 | outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK); |
| 2673 | tea->mute = mute; | 2625 | outw(odir | STR_DATA | STR_CLK | STR_WREN, io + IO_DIR); |
| 2674 | outw(tea->mute ? STR_WREN : 0, io); | 2626 | } else { |
| 2675 | udelay(4); | 2627 | outw(~(STR_CLK | STR_WREN | STR_DATA | STR_MOST), io + IO_MASK); |
| 2676 | outw(omask, io + IO_MASK); | 2628 | outw((odir & ~(STR_DATA | STR_MOST)) | STR_CLK | STR_WREN, io + IO_DIR); |
| 2677 | msleep(125); | 2629 | } |
| 2678 | } | 2630 | } |
| 2679 | 2631 | ||
| 2680 | static struct snd_tea575x_ops snd_es1968_tea_ops = { | 2632 | static struct snd_tea575x_ops snd_es1968_tea_ops = { |
| 2681 | .write = snd_es1968_tea575x_write, | 2633 | .set_pins = snd_es1968_tea575x_set_pins, |
| 2682 | .read = snd_es1968_tea575x_read, | 2634 | .get_pins = snd_es1968_tea575x_get_pins, |
| 2683 | .mute = snd_es1968_tea575x_mute, | 2635 | .set_direction = snd_es1968_tea575x_set_direction, |
| 2684 | }; | 2636 | }; |
| 2685 | #endif | 2637 | #endif |
| 2686 | 2638 | ||
| @@ -2845,7 +2797,8 @@ static int __devinit snd_es1968_create(struct snd_card *card, | |||
| 2845 | chip->tea.freq_fixup = 10700; | 2797 | chip->tea.freq_fixup = 10700; |
| 2846 | chip->tea.private_data = chip; | 2798 | chip->tea.private_data = chip; |
| 2847 | chip->tea.ops = &snd_es1968_tea_ops; | 2799 | chip->tea.ops = &snd_es1968_tea_ops; |
| 2848 | snd_tea575x_init(&chip->tea); | 2800 | if (!snd_tea575x_init(&chip->tea)) |
| 2801 | printk(KERN_INFO "es1968: detected TEA575x radio\n"); | ||
| 2849 | #endif | 2802 | #endif |
| 2850 | 2803 | ||
| 2851 | *chip_ret = chip; | 2804 | *chip_ret = chip; |
