aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Zary <linux@rainbow-software.org>2011-03-19 11:33:14 -0400
committerTakashi Iwai <tiwai@suse.de>2011-03-21 07:44:14 -0400
commit1872f589951caee1afd7cd2ea6729ac892de9ddf (patch)
tree11acde5b1d3e360141828014d6d9ec865816073d
parentf8960d61bc8ba945b07a4de1288aac5d52f8607b (diff)
ALSA: es1968: add radio (tea575x tuner) support
Add TEA5757 radio tuner support to es1968 driver. This is found at least on MediaForte SF64-PCE2 sound cards. Signed-off-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/i2c/other/Makefile2
-rw-r--r--sound/pci/Kconfig14
-rw-r--r--sound/pci/es1968.c125
3 files changed, 137 insertions, 4 deletions
diff --git a/sound/i2c/other/Makefile b/sound/i2c/other/Makefile
index 2dad40f3f622..c95d8f1aae87 100644
--- a/sound/i2c/other/Makefile
+++ b/sound/i2c/other/Makefile
@@ -14,4 +14,4 @@ snd-tea575x-tuner-objs := tea575x-tuner.o
14obj-$(CONFIG_SND_PDAUDIOCF) += snd-ak4117.o 14obj-$(CONFIG_SND_PDAUDIOCF) += snd-ak4117.o
15obj-$(CONFIG_SND_ICE1712) += snd-ak4xxx-adda.o 15obj-$(CONFIG_SND_ICE1712) += snd-ak4xxx-adda.o
16obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o snd-ak4113.o snd-ak4xxx-adda.o snd-pt2258.o 16obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o snd-ak4113.o snd-ak4xxx-adda.o snd-pt2258.o
17obj-$(CONFIG_SND_FM801_TEA575X) += snd-tea575x-tuner.o 17obj-$(CONFIG_SND_TEA575X) += snd-tea575x-tuner.o
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 389cd7931668..f9f533fccccf 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -534,6 +534,14 @@ config SND_ES1968_INPUT
534 If you say N the buttons will directly control the master volume. 534 If you say N the buttons will directly control the master volume.
535 It is recommended to say Y. 535 It is recommended to say Y.
536 536
537config SND_ES1968_RADIO
538 bool "Enable TEA5757 radio tuner support for es1968"
539 depends on SND_ES1968
540 depends on VIDEO_V4L2=y || VIDEO_V4L2=SND_ES1968
541 help
542 Say Y here to include support for TEA5757 radio tuner integrated on
543 some MediaForte cards (e.g. SF64-PCE2).
544
537config SND_FM801 545config SND_FM801
538 tristate "ForteMedia FM801" 546 tristate "ForteMedia FM801"
539 select SND_OPL3_LIB 547 select SND_OPL3_LIB
@@ -555,10 +563,10 @@ config SND_FM801_TEA575X_BOOL
555 FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media 563 FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media
556 Forte SF256-PCS-02) into the snd-fm801 driver. 564 Forte SF256-PCS-02) into the snd-fm801 driver.
557 565
558config SND_FM801_TEA575X 566config SND_TEA575X
559 tristate 567 tristate
560 depends on SND_FM801_TEA575X_BOOL 568 depends on SND_FM801_TEA575X_BOOL || SND_ES1968_RADIO
561 default SND_FM801 569 default SND_FM801 || SND_ES1968
562 570
563source "sound/pci/hda/Kconfig" 571source "sound/pci/hda/Kconfig"
564 572
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 7c17f45d876d..faf9138970ae 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -112,6 +112,10 @@
112#include <sound/ac97_codec.h> 112#include <sound/ac97_codec.h>
113#include <sound/initval.h> 113#include <sound/initval.h>
114 114
115#ifdef CONFIG_SND_ES1968_RADIO
116#include <sound/tea575x-tuner.h>
117#endif
118
115#define CARD_NAME "ESS Maestro1/2" 119#define CARD_NAME "ESS Maestro1/2"
116#define DRIVER_NAME "ES1968" 120#define DRIVER_NAME "ES1968"
117 121
@@ -553,6 +557,10 @@ struct es1968 {
553 spinlock_t ac97_lock; 557 spinlock_t ac97_lock;
554 struct tasklet_struct hwvol_tq; 558 struct tasklet_struct hwvol_tq;
555#endif 559#endif
560
561#ifdef CONFIG_SND_ES1968_RADIO
562 struct snd_tea575x tea;
563#endif
556}; 564};
557 565
558static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id); 566static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id);
@@ -2571,6 +2579,111 @@ static int __devinit snd_es1968_input_register(struct es1968 *chip)
2571} 2579}
2572#endif /* CONFIG_SND_ES1968_INPUT */ 2580#endif /* CONFIG_SND_ES1968_INPUT */
2573 2581
2582#ifdef CONFIG_SND_ES1968_RADIO
2583#define GPIO_DATA 0x60
2584#define IO_MASK 4 /* mask register offset from GPIO_DATA
2585 bits 1=unmask write to given bit */
2586#define IO_DIR 8 /* direction register offset from GPIO_DATA
2587 bits 0/1=read/write direction */
2588/* mask bits for GPIO lines */
2589#define STR_DATA 0x0040 /* GPIO6 */
2590#define STR_CLK 0x0080 /* GPIO7 */
2591#define STR_WREN 0x0100 /* GPIO8 */
2592#define STR_MOST 0x0200 /* GPIO9 */
2593
2594static void snd_es1968_tea575x_write(struct snd_tea575x *tea, unsigned int val)
2595{
2596 struct es1968 *chip = tea->private_data;
2597 unsigned long io = chip->io_port + GPIO_DATA;
2598 u16 l, bits;
2599 u16 omask, odir;
2600
2601 omask = inw(io + IO_MASK);
2602 odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN);
2603 outw(odir | STR_DATA, io + IO_DIR);
2604 outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK);
2605 udelay(16);
2606
2607 for (l = 25; l; l--) {
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}
2626
2627static unsigned int snd_es1968_tea575x_read(struct snd_tea575x *tea)
2628{
2629 struct es1968 *chip = tea->private_data;
2630 unsigned long io = chip->io_port + GPIO_DATA;
2631 u16 l, rdata;
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
2662 return data & 0x3ffe;
2663}
2664
2665static void snd_es1968_tea575x_mute(struct snd_tea575x *tea, unsigned int mute)
2666{
2667 struct es1968 *chip = tea->private_data;
2668 unsigned long io = chip->io_port + GPIO_DATA;
2669 u16 omask;
2670
2671 omask = inw(io + IO_MASK);
2672 outw(~STR_WREN, io + IO_MASK);
2673 tea->mute = mute;
2674 outw(tea->mute ? STR_WREN : 0, io);
2675 udelay(4);
2676 outw(omask, io + IO_MASK);
2677 msleep(125);
2678}
2679
2680static struct snd_tea575x_ops snd_es1968_tea_ops = {
2681 .write = snd_es1968_tea575x_write,
2682 .read = snd_es1968_tea575x_read,
2683 .mute = snd_es1968_tea575x_mute,
2684};
2685#endif
2686
2574static int snd_es1968_free(struct es1968 *chip) 2687static int snd_es1968_free(struct es1968 *chip)
2575{ 2688{
2576#ifdef CONFIG_SND_ES1968_INPUT 2689#ifdef CONFIG_SND_ES1968_INPUT
@@ -2585,6 +2698,10 @@ static int snd_es1968_free(struct es1968 *chip)
2585 outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */ 2698 outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */
2586 } 2699 }
2587 2700
2701#ifdef CONFIG_SND_ES1968_RADIO
2702 snd_tea575x_exit(&chip->tea);
2703#endif
2704
2588 if (chip->irq >= 0) 2705 if (chip->irq >= 0)
2589 free_irq(chip->irq, chip); 2706 free_irq(chip->irq, chip);
2590 snd_es1968_free_gameport(chip); 2707 snd_es1968_free_gameport(chip);
@@ -2723,6 +2840,14 @@ static int __devinit snd_es1968_create(struct snd_card *card,
2723 2840
2724 snd_card_set_dev(card, &pci->dev); 2841 snd_card_set_dev(card, &pci->dev);
2725 2842
2843#ifdef CONFIG_SND_ES1968_RADIO
2844 chip->tea.card = card;
2845 chip->tea.freq_fixup = 10700;
2846 chip->tea.private_data = chip;
2847 chip->tea.ops = &snd_es1968_tea_ops;
2848 snd_tea575x_init(&chip->tea);
2849#endif
2850
2726 *chip_ret = chip; 2851 *chip_ret = chip;
2727 2852
2728 return 0; 2853 return 0;