From: Ondrej Zary <linux@rainbow-software.org>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Takashi Iwai <tiwai@suse.de>,
alsa-devel@alsa-project.org, linux-media@vger.kernel.org,
jirislaby@gmail.com,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: [RFC PATCH 3/3] es1968: add radio (tea575x tuner) support
Date: Sat, 19 Mar 2011 16:33:14 +0100 [thread overview]
Message-ID: <201103191633.17611.linux@rainbow-software.org> (raw)
In-Reply-To: <33b29bfb135fbe2ddcba88d342d67526.squirrel@webmail.xs4all.nl>
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>
diff -urp linux-2.6.38-rc4-orig/sound/pci/es1968.c linux-2.6.38-rc4/sound/pci/es1968.c
--- linux-2.6.38-rc4-orig/sound/pci/es1968.c 2011-02-08 01:03:55.000000000 +0100
+++ linux-2.6.38-rc4/sound/pci/es1968.c 2011-03-18 22:51:48.000000000 +0100
@@ -112,6 +112,10 @@
#include <sound/ac97_codec.h>
#include <sound/initval.h>
+#ifdef CONFIG_SND_ES1968_RADIO
+#include <sound/tea575x-tuner.h>
+#endif
+
#define CARD_NAME "ESS Maestro1/2"
#define DRIVER_NAME "ES1968"
@@ -553,6 +557,10 @@ struct es1968 {
spinlock_t ac97_lock;
struct tasklet_struct hwvol_tq;
#endif
+
+#ifdef CONFIG_SND_ES1968_RADIO
+ struct snd_tea575x tea;
+#endif
};
static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id);
@@ -2571,6 +2579,111 @@ static int __devinit snd_es1968_input_re
}
#endif /* CONFIG_SND_ES1968_INPUT */
+#ifdef CONFIG_SND_ES1968_RADIO
+#define GPIO_DATA 0x60
+#define IO_MASK 4 /* mask register offset from GPIO_DATA
+ bits 1=unmask write to given bit */
+#define IO_DIR 8 /* direction register offset from GPIO_DATA
+ bits 0/1=read/write direction */
+/* mask bits for GPIO lines */
+#define STR_DATA 0x0040 /* GPIO6 */
+#define STR_CLK 0x0080 /* GPIO7 */
+#define STR_WREN 0x0100 /* GPIO8 */
+#define STR_MOST 0x0200 /* GPIO9 */
+
+static void snd_es1968_tea575x_write(struct snd_tea575x *tea, unsigned int val)
+{
+ struct es1968 *chip = tea->private_data;
+ unsigned long io = chip->io_port + GPIO_DATA;
+ u16 l, bits;
+ u16 omask, odir;
+
+ omask = inw(io + IO_MASK);
+ odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN);
+ outw(odir | STR_DATA, io + IO_DIR);
+ outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK);
+ udelay(16);
+
+ for (l = 25; l; l--) {
+ bits = ((val >> 18) & STR_DATA) | STR_WREN;
+ val <<= 1; /* shift data */
+ outw(bits, io); /* start strobe */
+ udelay(2);
+ outw(bits | STR_CLK, io); /* HI level */
+ udelay(2);
+ outw(bits, io); /* LO level */
+ udelay(4);
+ }
+
+ if (!tea->mute)
+ outw(0, io);
+
+ udelay(4);
+ outw(omask, io + IO_MASK);
+ outw(odir, io + IO_DIR);
+ msleep(125);
+}
+
+static unsigned int snd_es1968_tea575x_read(struct snd_tea575x *tea)
+{
+ struct es1968 *chip = tea->private_data;
+ unsigned long io = chip->io_port + GPIO_DATA;
+ u16 l, rdata;
+ u32 data = 0;
+ u16 omask;
+
+ omask = inw(io + IO_MASK);
+ outw(~(STR_CLK | STR_WREN), io + IO_MASK);
+ outw(0, io);
+ udelay(16);
+
+ for (l = 24; l--;) {
+ outw(STR_CLK, io); /* HI state */
+ udelay(2);
+ if (!l)
+ tea->tuned = inw(io) & STR_MOST ? 0 : 1;
+ outw(0, io); /* LO state */
+ udelay(2);
+ data <<= 1; /* shift data */
+ rdata = inw(io);
+ if (!l)
+ tea->stereo = (rdata & STR_MOST) ? 0 : 1;
+ else if (l && rdata & STR_DATA)
+ data++;
+ udelay(2);
+ }
+
+ if (tea->mute)
+ outw(STR_WREN, io);
+
+ udelay(4);
+ outw(omask, io + IO_MASK);
+
+ return data & 0x3ffe;
+}
+
+static void snd_es1968_tea575x_mute(struct snd_tea575x *tea, unsigned int mute)
+{
+ struct es1968 *chip = tea->private_data;
+ unsigned long io = chip->io_port + GPIO_DATA;
+ u16 omask;
+
+ omask = inw(io + IO_MASK);
+ outw(~STR_WREN, io + IO_MASK);
+ tea->mute = mute;
+ outw(tea->mute ? STR_WREN : 0, io);
+ udelay(4);
+ outw(omask, io + IO_MASK);
+ msleep(125);
+}
+
+static struct snd_tea575x_ops snd_es1968_tea_ops = {
+ .write = snd_es1968_tea575x_write,
+ .read = snd_es1968_tea575x_read,
+ .mute = snd_es1968_tea575x_mute,
+};
+#endif
+
static int snd_es1968_free(struct es1968 *chip)
{
#ifdef CONFIG_SND_ES1968_INPUT
@@ -2585,6 +2698,10 @@ static int snd_es1968_free(struct es1968
outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */
}
+#ifdef CONFIG_SND_ES1968_RADIO
+ snd_tea575x_exit(&chip->tea);
+#endif
+
if (chip->irq >= 0)
free_irq(chip->irq, chip);
snd_es1968_free_gameport(chip);
@@ -2723,6 +2840,14 @@ static int __devinit snd_es1968_create(s
snd_card_set_dev(card, &pci->dev);
+#ifdef CONFIG_SND_ES1968_RADIO
+ chip->tea.card = card;
+ chip->tea.freq_fixup = 10700;
+ chip->tea.private_data = chip;
+ chip->tea.ops = &snd_es1968_tea_ops;
+ snd_tea575x_init(&chip->tea);
+#endif
+
*chip_ret = chip;
return 0;
diff -urp linux-2.6.38-rc4-orig/sound/pci/Kconfig linux-2.6.38-rc4/sound/pci/Kconfig
--- linux-2.6.38-rc4-orig/sound/pci/Kconfig 2011-02-08 01:03:55.000000000 +0100
+++ linux-2.6.38-rc4/sound/pci/Kconfig 2011-03-13 00:01:26.000000000 +0100
@@ -528,6 +528,14 @@ config SND_ES1968_INPUT
If you say N the buttons will directly control the master volume.
It is recommended to say Y.
+config SND_ES1968_RADIO
+ bool "Enable TEA5757 radio tuner support for es1968"
+ depends on SND_ES1968
+ depends on VIDEO_V4L2=y || VIDEO_V4L2=SND_ES1968
+ help
+ Say Y here to include support for TEA5757 radio tuner integrated on
+ some MediaForte cards (e.g. SF64-PCE2).
+
config SND_FM801
tristate "ForteMedia FM801"
select SND_OPL3_LIB
@@ -549,10 +557,10 @@ config SND_FM801_TEA575X_BOOL
FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media
Forte SF256-PCS-02) into the snd-fm801 driver.
-config SND_FM801_TEA575X
+config SND_TEA575X
tristate
- depends on SND_FM801_TEA575X_BOOL
- default SND_FM801
+ depends on SND_FM801_TEA575X_BOOL || SND_ES1968_RADIO
+ default SND_FM801 || SND_ES1968
source "sound/pci/hda/Kconfig"
diff -urp linux-2.6.38-rc4-orig/sound/i2c/other/Makefile linux-2.6.38-rc4/sound/i2c/other/Makefile
--- linux-2.6.38-rc4-orig/sound/i2c/other/Makefile 2011-02-08 01:03:55.000000000 +0100
+++ linux-2.6.38-rc4/sound/i2c/other/Makefile 2011-03-12 23:59:37.000000000 +0100
@@ -14,4 +14,4 @@ snd-tea575x-tuner-objs := tea575x-tuner.
obj-$(CONFIG_SND_PDAUDIOCF) += snd-ak4117.o
obj-$(CONFIG_SND_ICE1712) += snd-ak4xxx-adda.o
obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o snd-ak4113.o snd-ak4xxx-adda.o snd-pt2258.o
-obj-$(CONFIG_SND_FM801_TEA575X) += snd-tea575x-tuner.o
+obj-$(CONFIG_SND_TEA575X) += snd-tea575x-tuner.o
--
Ondrej Zary
WARNING: multiple messages have this Message-ID (diff)
From: Ondrej Zary <linux@rainbow-software.org>
To: "Hans Verkuil" <hverkuil@xs4all.nl>
Cc: "Takashi Iwai" <tiwai@suse.de>,
jirislaby@gmail.com, alsa-devel@alsa-project.org,
"Kernel development list" <linux-kernel@vger.kernel.org>,
linux-media@vger.kernel.org
Subject: [RFC PATCH 3/3] es1968: add radio (tea575x tuner) support
Date: Sat, 19 Mar 2011 16:33:14 +0100 [thread overview]
Message-ID: <201103191633.17611.linux@rainbow-software.org> (raw)
In-Reply-To: <33b29bfb135fbe2ddcba88d342d67526.squirrel@webmail.xs4all.nl>
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>
diff -urp linux-2.6.38-rc4-orig/sound/pci/es1968.c linux-2.6.38-rc4/sound/pci/es1968.c
--- linux-2.6.38-rc4-orig/sound/pci/es1968.c 2011-02-08 01:03:55.000000000 +0100
+++ linux-2.6.38-rc4/sound/pci/es1968.c 2011-03-18 22:51:48.000000000 +0100
@@ -112,6 +112,10 @@
#include <sound/ac97_codec.h>
#include <sound/initval.h>
+#ifdef CONFIG_SND_ES1968_RADIO
+#include <sound/tea575x-tuner.h>
+#endif
+
#define CARD_NAME "ESS Maestro1/2"
#define DRIVER_NAME "ES1968"
@@ -553,6 +557,10 @@ struct es1968 {
spinlock_t ac97_lock;
struct tasklet_struct hwvol_tq;
#endif
+
+#ifdef CONFIG_SND_ES1968_RADIO
+ struct snd_tea575x tea;
+#endif
};
static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id);
@@ -2571,6 +2579,111 @@ static int __devinit snd_es1968_input_re
}
#endif /* CONFIG_SND_ES1968_INPUT */
+#ifdef CONFIG_SND_ES1968_RADIO
+#define GPIO_DATA 0x60
+#define IO_MASK 4 /* mask register offset from GPIO_DATA
+ bits 1=unmask write to given bit */
+#define IO_DIR 8 /* direction register offset from GPIO_DATA
+ bits 0/1=read/write direction */
+/* mask bits for GPIO lines */
+#define STR_DATA 0x0040 /* GPIO6 */
+#define STR_CLK 0x0080 /* GPIO7 */
+#define STR_WREN 0x0100 /* GPIO8 */
+#define STR_MOST 0x0200 /* GPIO9 */
+
+static void snd_es1968_tea575x_write(struct snd_tea575x *tea, unsigned int val)
+{
+ struct es1968 *chip = tea->private_data;
+ unsigned long io = chip->io_port + GPIO_DATA;
+ u16 l, bits;
+ u16 omask, odir;
+
+ omask = inw(io + IO_MASK);
+ odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN);
+ outw(odir | STR_DATA, io + IO_DIR);
+ outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK);
+ udelay(16);
+
+ for (l = 25; l; l--) {
+ bits = ((val >> 18) & STR_DATA) | STR_WREN;
+ val <<= 1; /* shift data */
+ outw(bits, io); /* start strobe */
+ udelay(2);
+ outw(bits | STR_CLK, io); /* HI level */
+ udelay(2);
+ outw(bits, io); /* LO level */
+ udelay(4);
+ }
+
+ if (!tea->mute)
+ outw(0, io);
+
+ udelay(4);
+ outw(omask, io + IO_MASK);
+ outw(odir, io + IO_DIR);
+ msleep(125);
+}
+
+static unsigned int snd_es1968_tea575x_read(struct snd_tea575x *tea)
+{
+ struct es1968 *chip = tea->private_data;
+ unsigned long io = chip->io_port + GPIO_DATA;
+ u16 l, rdata;
+ u32 data = 0;
+ u16 omask;
+
+ omask = inw(io + IO_MASK);
+ outw(~(STR_CLK | STR_WREN), io + IO_MASK);
+ outw(0, io);
+ udelay(16);
+
+ for (l = 24; l--;) {
+ outw(STR_CLK, io); /* HI state */
+ udelay(2);
+ if (!l)
+ tea->tuned = inw(io) & STR_MOST ? 0 : 1;
+ outw(0, io); /* LO state */
+ udelay(2);
+ data <<= 1; /* shift data */
+ rdata = inw(io);
+ if (!l)
+ tea->stereo = (rdata & STR_MOST) ? 0 : 1;
+ else if (l && rdata & STR_DATA)
+ data++;
+ udelay(2);
+ }
+
+ if (tea->mute)
+ outw(STR_WREN, io);
+
+ udelay(4);
+ outw(omask, io + IO_MASK);
+
+ return data & 0x3ffe;
+}
+
+static void snd_es1968_tea575x_mute(struct snd_tea575x *tea, unsigned int mute)
+{
+ struct es1968 *chip = tea->private_data;
+ unsigned long io = chip->io_port + GPIO_DATA;
+ u16 omask;
+
+ omask = inw(io + IO_MASK);
+ outw(~STR_WREN, io + IO_MASK);
+ tea->mute = mute;
+ outw(tea->mute ? STR_WREN : 0, io);
+ udelay(4);
+ outw(omask, io + IO_MASK);
+ msleep(125);
+}
+
+static struct snd_tea575x_ops snd_es1968_tea_ops = {
+ .write = snd_es1968_tea575x_write,
+ .read = snd_es1968_tea575x_read,
+ .mute = snd_es1968_tea575x_mute,
+};
+#endif
+
static int snd_es1968_free(struct es1968 *chip)
{
#ifdef CONFIG_SND_ES1968_INPUT
@@ -2585,6 +2698,10 @@ static int snd_es1968_free(struct es1968
outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */
}
+#ifdef CONFIG_SND_ES1968_RADIO
+ snd_tea575x_exit(&chip->tea);
+#endif
+
if (chip->irq >= 0)
free_irq(chip->irq, chip);
snd_es1968_free_gameport(chip);
@@ -2723,6 +2840,14 @@ static int __devinit snd_es1968_create(s
snd_card_set_dev(card, &pci->dev);
+#ifdef CONFIG_SND_ES1968_RADIO
+ chip->tea.card = card;
+ chip->tea.freq_fixup = 10700;
+ chip->tea.private_data = chip;
+ chip->tea.ops = &snd_es1968_tea_ops;
+ snd_tea575x_init(&chip->tea);
+#endif
+
*chip_ret = chip;
return 0;
diff -urp linux-2.6.38-rc4-orig/sound/pci/Kconfig linux-2.6.38-rc4/sound/pci/Kconfig
--- linux-2.6.38-rc4-orig/sound/pci/Kconfig 2011-02-08 01:03:55.000000000 +0100
+++ linux-2.6.38-rc4/sound/pci/Kconfig 2011-03-13 00:01:26.000000000 +0100
@@ -528,6 +528,14 @@ config SND_ES1968_INPUT
If you say N the buttons will directly control the master volume.
It is recommended to say Y.
+config SND_ES1968_RADIO
+ bool "Enable TEA5757 radio tuner support for es1968"
+ depends on SND_ES1968
+ depends on VIDEO_V4L2=y || VIDEO_V4L2=SND_ES1968
+ help
+ Say Y here to include support for TEA5757 radio tuner integrated on
+ some MediaForte cards (e.g. SF64-PCE2).
+
config SND_FM801
tristate "ForteMedia FM801"
select SND_OPL3_LIB
@@ -549,10 +557,10 @@ config SND_FM801_TEA575X_BOOL
FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media
Forte SF256-PCS-02) into the snd-fm801 driver.
-config SND_FM801_TEA575X
+config SND_TEA575X
tristate
- depends on SND_FM801_TEA575X_BOOL
- default SND_FM801
+ depends on SND_FM801_TEA575X_BOOL || SND_ES1968_RADIO
+ default SND_FM801 || SND_ES1968
source "sound/pci/hda/Kconfig"
diff -urp linux-2.6.38-rc4-orig/sound/i2c/other/Makefile linux-2.6.38-rc4/sound/i2c/other/Makefile
--- linux-2.6.38-rc4-orig/sound/i2c/other/Makefile 2011-02-08 01:03:55.000000000 +0100
+++ linux-2.6.38-rc4/sound/i2c/other/Makefile 2011-03-12 23:59:37.000000000 +0100
@@ -14,4 +14,4 @@ snd-tea575x-tuner-objs := tea575x-tuner.
obj-$(CONFIG_SND_PDAUDIOCF) += snd-ak4117.o
obj-$(CONFIG_SND_ICE1712) += snd-ak4xxx-adda.o
obj-$(CONFIG_SND_ICE1724) += snd-ak4114.o snd-ak4113.o snd-ak4xxx-adda.o snd-pt2258.o
-obj-$(CONFIG_SND_FM801_TEA575X) += snd-tea575x-tuner.o
+obj-$(CONFIG_SND_TEA575X) += snd-tea575x-tuner.o
--
Ondrej Zary
next prev parent reply other threads:[~2011-03-19 15:33 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-12 18:19 radio-maestro broken (conflicts with snd-es1968) Ondrej Zary
2011-03-12 18:52 ` Hans Verkuil
2011-03-14 9:53 ` Takashi Iwai
2011-03-14 9:53 ` [alsa-devel] " Takashi Iwai
2011-03-14 9:59 ` Hans Verkuil
2011-03-14 9:59 ` [alsa-devel] " Hans Verkuil
2011-03-14 10:08 ` Takashi Iwai
2011-03-14 10:08 ` [alsa-devel] " Takashi Iwai
2011-03-14 10:28 ` Ondrej Zary
2011-03-14 10:28 ` [alsa-devel] " Ondrej Zary
2011-03-14 10:29 ` Takashi Iwai
2011-03-14 11:57 ` Hans Verkuil
2011-03-14 11:57 ` [alsa-devel] " Hans Verkuil
2011-03-19 15:32 ` [RFC PATCH 1/3] tea575x-tuner: various improvements Ondrej Zary
2011-03-21 11:48 ` Takashi Iwai
2011-03-21 11:48 ` Takashi Iwai
2011-03-22 18:39 ` Mauro Carvalho Chehab
2011-03-22 19:02 ` Hans Verkuil
2011-03-22 19:02 ` Hans Verkuil
2011-03-25 21:40 ` Ondrej Zary
2011-03-26 10:19 ` Hans Verkuil
2011-03-26 10:19 ` Hans Verkuil
2011-03-29 19:25 ` Ondrej Zary
2011-03-29 19:25 ` Ondrej Zary
2011-03-29 19:39 ` Hans Verkuil
2011-03-29 19:39 ` Hans Verkuil
2011-03-19 15:33 ` [RFC PATCH 2/3] tea575x-tuner: remove dev_nr Ondrej Zary
2011-03-19 15:33 ` Ondrej Zary
2011-03-19 15:33 ` Ondrej Zary [this message]
2011-03-19 15:33 ` [RFC PATCH 3/3] es1968: add radio (tea575x tuner) support Ondrej Zary
2011-03-19 16:23 ` [RFC PATCH 4/3] remove radio-maestro Ondrej Zary
2011-03-19 16:23 ` Ondrej Zary
2011-03-22 18:44 ` Mauro Carvalho Chehab
2011-03-23 7:13 ` Takashi Iwai
2011-03-22 19:03 ` Hans Verkuil
2011-03-22 19:03 ` Hans Verkuil
2011-03-14 9:46 ` radio-maestro broken (conflicts with snd-es1968) Takashi Iwai
2011-03-14 9:46 ` [alsa-devel] " Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201103191633.17611.linux@rainbow-software.org \
--to=linux@rainbow-software.org \
--cc=alsa-devel@alsa-project.org \
--cc=hverkuil@xs4all.nl \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.