From: Ondrej Zary <linux@rainbow-software.org>
To: alsa-devel@alsa-project.org
Cc: Kernel development list <linux-kernel@vger.kernel.org>,
linux-media@vger.kernel.org
Subject: [PATCH 2/3] es1968: convert TEA575x support to new interface
Date: Mon, 9 May 2011 23:39:37 +0200 [thread overview]
Message-ID: <201105092339.42319.linux@rainbow-software.org> (raw)
Use common functions to access TEA575x tuner - remove original read/write
functions and provide new pin manipulation functions instead.
Tested with SF64-PCE2 card.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
--- linux-2.6.39-rc2-/sound/pci/es1968.c 2011-05-06 22:46:24.000000000 +0200
+++ linux-2.6.39-rc2/sound/pci/es1968.c 2011-05-09 23:25:06.000000000 +0200
@@ -2591,96 +2591,48 @@ static int __devinit snd_es1968_input_re
#define STR_WREN 0x0100 /* GPIO8 */
#define STR_MOST 0x0200 /* GPIO9 */
-static void snd_es1968_tea575x_write(struct snd_tea575x *tea, unsigned int val)
+static void snd_es1968_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
{
struct es1968 *chip = tea->private_data;
unsigned long io = chip->io_port + GPIO_DATA;
- u16 l, bits;
- u16 omask, odir;
+ u16 val = 0;
- 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);
+ val |= (pins & TEA575X_DATA) ? STR_DATA : 0;
+ val |= (pins & TEA575X_CLK) ? STR_CLK : 0;
+ val |= (pins & TEA575X_WREN) ? STR_WREN : 0;
- udelay(4);
- outw(omask, io + IO_MASK);
- outw(odir, io + IO_DIR);
- msleep(125);
+ outw(val, io);
}
-static unsigned int snd_es1968_tea575x_read(struct snd_tea575x *tea)
+static u8 snd_es1968_tea575x_get_pins(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);
- }
+ u16 val = inw(io);
- if (tea->mute)
- outw(STR_WREN, io);
-
- udelay(4);
- outw(omask, io + IO_MASK);
-
- return data & 0x3ffe;
+ return (val & STR_DATA) ? TEA575X_DATA : 0 |
+ (val & STR_MOST) ? TEA575X_MOST : 0;
}
-static void snd_es1968_tea575x_mute(struct snd_tea575x *tea, unsigned int mute)
+static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output)
{
struct es1968 *chip = tea->private_data;
unsigned long io = chip->io_port + GPIO_DATA;
- u16 omask;
+ u16 odir = inw(io + IO_DIR);
- 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);
+ if (output) {
+ outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK);
+ outw(odir | STR_DATA | STR_CLK | STR_WREN, io + IO_DIR);
+ } else {
+ outw(~(STR_CLK | STR_WREN | STR_DATA | STR_MOST), io + IO_MASK);
+ outw((odir & ~(STR_DATA | STR_MOST)) | STR_CLK | STR_WREN, io + IO_DIR);
+ }
}
static struct snd_tea575x_ops snd_es1968_tea_ops = {
- .write = snd_es1968_tea575x_write,
- .read = snd_es1968_tea575x_read,
- .mute = snd_es1968_tea575x_mute,
+ .set_pins = snd_es1968_tea575x_set_pins,
+ .get_pins = snd_es1968_tea575x_get_pins,
+ .set_direction = snd_es1968_tea575x_set_direction,
};
#endif
@@ -2845,7 +2797,8 @@ static int __devinit snd_es1968_create(s
chip->tea.freq_fixup = 10700;
chip->tea.private_data = chip;
chip->tea.ops = &snd_es1968_tea_ops;
- snd_tea575x_init(&chip->tea);
+ if (!snd_tea575x_init(&chip->tea))
+ printk(KERN_INFO "es1968: detected TEA575x radio\n");
#endif
*chip_ret = chip;
--
Ondrej Zary
WARNING: multiple messages have this Message-ID (diff)
From: Ondrej Zary <linux@rainbow-software.org>
To: alsa-devel@alsa-project.org
Cc: linux-media@vger.kernel.org,
"Kernel development list" <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] es1968: convert TEA575x support to new interface
Date: Mon, 9 May 2011 23:39:37 +0200 [thread overview]
Message-ID: <201105092339.42319.linux@rainbow-software.org> (raw)
Use common functions to access TEA575x tuner - remove original read/write
functions and provide new pin manipulation functions instead.
Tested with SF64-PCE2 card.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
--- linux-2.6.39-rc2-/sound/pci/es1968.c 2011-05-06 22:46:24.000000000 +0200
+++ linux-2.6.39-rc2/sound/pci/es1968.c 2011-05-09 23:25:06.000000000 +0200
@@ -2591,96 +2591,48 @@ static int __devinit snd_es1968_input_re
#define STR_WREN 0x0100 /* GPIO8 */
#define STR_MOST 0x0200 /* GPIO9 */
-static void snd_es1968_tea575x_write(struct snd_tea575x *tea, unsigned int val)
+static void snd_es1968_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
{
struct es1968 *chip = tea->private_data;
unsigned long io = chip->io_port + GPIO_DATA;
- u16 l, bits;
- u16 omask, odir;
+ u16 val = 0;
- 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);
+ val |= (pins & TEA575X_DATA) ? STR_DATA : 0;
+ val |= (pins & TEA575X_CLK) ? STR_CLK : 0;
+ val |= (pins & TEA575X_WREN) ? STR_WREN : 0;
- udelay(4);
- outw(omask, io + IO_MASK);
- outw(odir, io + IO_DIR);
- msleep(125);
+ outw(val, io);
}
-static unsigned int snd_es1968_tea575x_read(struct snd_tea575x *tea)
+static u8 snd_es1968_tea575x_get_pins(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);
- }
+ u16 val = inw(io);
- if (tea->mute)
- outw(STR_WREN, io);
-
- udelay(4);
- outw(omask, io + IO_MASK);
-
- return data & 0x3ffe;
+ return (val & STR_DATA) ? TEA575X_DATA : 0 |
+ (val & STR_MOST) ? TEA575X_MOST : 0;
}
-static void snd_es1968_tea575x_mute(struct snd_tea575x *tea, unsigned int mute)
+static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output)
{
struct es1968 *chip = tea->private_data;
unsigned long io = chip->io_port + GPIO_DATA;
- u16 omask;
+ u16 odir = inw(io + IO_DIR);
- 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);
+ if (output) {
+ outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK);
+ outw(odir | STR_DATA | STR_CLK | STR_WREN, io + IO_DIR);
+ } else {
+ outw(~(STR_CLK | STR_WREN | STR_DATA | STR_MOST), io + IO_MASK);
+ outw((odir & ~(STR_DATA | STR_MOST)) | STR_CLK | STR_WREN, io + IO_DIR);
+ }
}
static struct snd_tea575x_ops snd_es1968_tea_ops = {
- .write = snd_es1968_tea575x_write,
- .read = snd_es1968_tea575x_read,
- .mute = snd_es1968_tea575x_mute,
+ .set_pins = snd_es1968_tea575x_set_pins,
+ .get_pins = snd_es1968_tea575x_get_pins,
+ .set_direction = snd_es1968_tea575x_set_direction,
};
#endif
@@ -2845,7 +2797,8 @@ static int __devinit snd_es1968_create(s
chip->tea.freq_fixup = 10700;
chip->tea.private_data = chip;
chip->tea.ops = &snd_es1968_tea_ops;
- snd_tea575x_init(&chip->tea);
+ if (!snd_tea575x_init(&chip->tea))
+ printk(KERN_INFO "es1968: detected TEA575x radio\n");
#endif
*chip_ret = chip;
--
Ondrej Zary
next reply other threads:[~2011-05-09 21:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-09 21:39 Ondrej Zary [this message]
2011-05-09 21:39 ` [PATCH 2/3] es1968: convert TEA575x support to new interface Ondrej Zary
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=201105092339.42319.linux@rainbow-software.org \
--to=linux@rainbow-software.org \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
/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.