Commit 72587173 authored by Ondrej Zary's avatar Ondrej Zary Committed by Takashi Iwai

ALSA: es1968: convert TEA575x support to new interface

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: default avatarOndrej Zary <linux@rainbow-software.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 14219d06
...@@ -2591,96 +2591,48 @@ static int __devinit snd_es1968_input_register(struct es1968 *chip) ...@@ -2591,96 +2591,48 @@ static int __devinit snd_es1968_input_register(struct es1968 *chip)
#define STR_WREN 0x0100 /* GPIO8 */ #define STR_WREN 0x0100 /* GPIO8 */
#define STR_MOST 0x0200 /* GPIO9 */ #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; struct es1968 *chip = tea->private_data;
unsigned long io = chip->io_port + GPIO_DATA; unsigned long io = chip->io_port + GPIO_DATA;
u16 l, bits; u16 val = 0;
u16 omask, odir;
omask = inw(io + IO_MASK); val |= (pins & TEA575X_DATA) ? STR_DATA : 0;
odir = (inw(io + IO_DIR) & ~STR_DATA) | (STR_CLK | STR_WREN); val |= (pins & TEA575X_CLK) ? STR_CLK : 0;
outw(odir | STR_DATA, io + IO_DIR); val |= (pins & TEA575X_WREN) ? STR_WREN : 0;
outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK);
udelay(16);
for (l = 25; l; l--) { outw(val, io);
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) static u8 snd_es1968_tea575x_get_pins(struct snd_tea575x *tea)
{ {
struct es1968 *chip = tea->private_data; struct es1968 *chip = tea->private_data;
unsigned long io = chip->io_port + GPIO_DATA; unsigned long io = chip->io_port + GPIO_DATA;
u16 l, rdata; u16 val = inw(io);
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; 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; struct es1968 *chip = tea->private_data;
unsigned long io = chip->io_port + GPIO_DATA; unsigned long io = chip->io_port + GPIO_DATA;
u16 omask; u16 odir = inw(io + IO_DIR);
omask = inw(io + IO_MASK); if (output) {
outw(~STR_WREN, io + IO_MASK); outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK);
tea->mute = mute; outw(odir | STR_DATA | STR_CLK | STR_WREN, io + IO_DIR);
outw(tea->mute ? STR_WREN : 0, io); } else {
udelay(4); outw(~(STR_CLK | STR_WREN | STR_DATA | STR_MOST), io + IO_MASK);
outw(omask, io + IO_MASK); outw((odir & ~(STR_DATA | STR_MOST)) | STR_CLK | STR_WREN, io + IO_DIR);
msleep(125); }
} }
static struct snd_tea575x_ops snd_es1968_tea_ops = { static struct snd_tea575x_ops snd_es1968_tea_ops = {
.write = snd_es1968_tea575x_write, .set_pins = snd_es1968_tea575x_set_pins,
.read = snd_es1968_tea575x_read, .get_pins = snd_es1968_tea575x_get_pins,
.mute = snd_es1968_tea575x_mute, .set_direction = snd_es1968_tea575x_set_direction,
}; };
#endif #endif
...@@ -2845,7 +2797,8 @@ static int __devinit snd_es1968_create(struct snd_card *card, ...@@ -2845,7 +2797,8 @@ static int __devinit snd_es1968_create(struct snd_card *card,
chip->tea.freq_fixup = 10700; chip->tea.freq_fixup = 10700;
chip->tea.private_data = chip; chip->tea.private_data = chip;
chip->tea.ops = &snd_es1968_tea_ops; 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 #endif
*chip_ret = chip; *chip_ret = chip;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment