Commit ece11c9b authored by Krzysztof Helt's avatar Krzysztof Helt Committed by Jaroslav Kysela

ALSA: wss_lib: use wss constants instead of ad1848 ones

Use wss constants for mode.
Move ad1848 hardware constants to the wss.h.
Move mixer tlv macros into the ad1848_lib.c from the ad1848.h.

Drop the MODE_RUNNING spurious IRQ guard on AD1848 as it doesn not seem
to be needed.
Signed-off-by: default avatarKrzysztof Helt <krzysztof.h1@wp.pl>
Reviewed-by: default avatarRene Herman <rene.herman@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 241b3ee7
...@@ -106,24 +106,6 @@ ...@@ -106,24 +106,6 @@
#define AD1848_CALIB_IN_PROGRESS 0x20 /* auto calibrate in progress */ #define AD1848_CALIB_IN_PROGRESS 0x20 /* auto calibrate in progress */
#define AD1848_DMA_REQUEST 0x10 /* DMA request in progress */ #define AD1848_DMA_REQUEST 0x10 /* DMA request in progress */
/* defines for codec.mode */
#define AD1848_MODE_NONE 0x0000
#define AD1848_MODE_PLAY 0x0001
#define AD1848_MODE_CAPTURE 0x0002
#define AD1848_MODE_TIMER 0x0004
#define AD1848_MODE_OPEN (AD1848_MODE_PLAY|AD1848_MODE_CAPTURE|AD1848_MODE_TIMER)
#define AD1848_MODE_RUNNING 0x0010
/* defines for codec.hardware */
#define AD1848_HW_DETECT 0x0000 /* let AD1848 driver detect chip */
#define AD1848_HW_AD1847 0x0001 /* AD1847 chip */
#define AD1848_HW_AD1848 0x0002 /* AD1848 chip */
#define AD1848_HW_CS4248 0x0003 /* CS4248 chip */
#define AD1848_HW_CMI8330 0x0004 /* CMI8330 chip */
#define AD1848_HW_THINKPAD 0x0005 /* Thinkpad 360/750/755 */
/* IBM Thinkpad specific stuff */ /* IBM Thinkpad specific stuff */
#define AD1848_THINKPAD_CTL_PORT1 0x15e8 #define AD1848_THINKPAD_CTL_PORT1 0x15e8
#define AD1848_THINKPAD_CTL_PORT2 0x15e9 #define AD1848_THINKPAD_CTL_PORT2 0x15e9
...@@ -167,26 +149,12 @@ struct ad1848_mix_elem { ...@@ -167,26 +149,12 @@ struct ad1848_mix_elem {
.type = AD1848_MIX_SINGLE, \ .type = AD1848_MIX_SINGLE, \
.private_value = AD1848_MIXVAL_SINGLE(reg, shift, mask, invert) } .private_value = AD1848_MIXVAL_SINGLE(reg, shift, mask, invert) }
#define AD1848_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \
{ .name = xname, \
.index = xindex, \
.type = AD1848_MIX_SINGLE, \
.private_value = AD1848_MIXVAL_SINGLE(reg, shift, mask, invert), \
.tlv = xtlv }
#define AD1848_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ #define AD1848_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
{ .name = xname, \ { .name = xname, \
.index = xindex, \ .index = xindex, \
.type = AD1848_MIX_DOUBLE, \ .type = AD1848_MIX_DOUBLE, \
.private_value = AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert) } .private_value = AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert) }
#define AD1848_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \
{ .name = xname, \
.index = xindex, \
.type = AD1848_MIX_DOUBLE, \
.private_value = AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert), \
.tlv = xtlv }
int snd_ad1848_add_ctl_elem(struct snd_wss *chip, int snd_ad1848_add_ctl_elem(struct snd_wss *chip,
const struct ad1848_mix_elem *c); const struct ad1848_mix_elem *c);
......
...@@ -55,6 +55,12 @@ ...@@ -55,6 +55,12 @@
#define WSS_HW_CS4237B 0x0402 /* CS4237B - SRS 3D */ #define WSS_HW_CS4237B 0x0402 /* CS4237B - SRS 3D */
#define WSS_HW_CS4238B 0x0403 /* CS4238B - QSOUND 3D */ #define WSS_HW_CS4238B 0x0403 /* CS4238B - QSOUND 3D */
#define WSS_HW_CS4239 0x0404 /* CS4239 - Crystal Clear (tm) stereo enhancement */ #define WSS_HW_CS4239 0x0404 /* CS4239 - Crystal Clear (tm) stereo enhancement */
#define WSS_HW_AD1848_MASK 0x0800 /* AD1848 serie (half duplex) */
#define WSS_HW_AD1847 0x0801 /* AD1847 chip */
#define WSS_HW_AD1848 0x0802 /* AD1848 chip */
#define WSS_HW_CS4248 0x0803 /* CS4248 chip */
#define WSS_HW_CMI8330 0x0804 /* CMI8330 chip */
#define WSS_HW_THINKPAD 0x0805 /* Thinkpad 360/750/755 */
/* compatible, but clones */ /* compatible, but clones */
#define WSS_HW_INTERWAVE 0x1000 /* InterWave chip */ #define WSS_HW_INTERWAVE 0x1000 /* InterWave chip */
#define WSS_HW_OPL3SA2 0x1101 /* OPL3-SA2 chip, similar to cs4231 */ #define WSS_HW_OPL3SA2 0x1101 /* OPL3-SA2 chip, similar to cs4231 */
......
...@@ -96,7 +96,7 @@ static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n) ...@@ -96,7 +96,7 @@ static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n)
return -EINVAL; return -EINVAL;
error = snd_ad1848_create(card, port[n], irq[n], dma1[n], error = snd_ad1848_create(card, port[n], irq[n], dma1[n],
thinkpad[n] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, &chip); thinkpad[n] ? WSS_HW_THINKPAD : WSS_HW_DETECT, &chip);
if (error < 0) if (error < 0)
goto out; goto out;
......
...@@ -283,14 +283,12 @@ static int snd_ad1848_trigger(struct snd_wss *chip, unsigned char what, ...@@ -283,14 +283,12 @@ static int snd_ad1848_trigger(struct snd_wss *chip, unsigned char what,
return 0; return 0;
} }
snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] |= what); snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] |= what);
chip->mode |= AD1848_MODE_RUNNING;
} else if (cmd == SNDRV_PCM_TRIGGER_STOP) { } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
if (!(chip->image[AD1848_IFACE_CTRL] & what)) { if (!(chip->image[AD1848_IFACE_CTRL] & what)) {
spin_unlock(&chip->reg_lock); spin_unlock(&chip->reg_lock);
return 0; return 0;
} }
snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] &= ~what); snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] &= ~what);
chip->mode &= ~AD1848_MODE_RUNNING;
} else { } else {
result = -EINVAL; result = -EINVAL;
} }
...@@ -378,7 +376,7 @@ static int snd_ad1848_open(struct snd_wss *chip, unsigned int mode) ...@@ -378,7 +376,7 @@ static int snd_ad1848_open(struct snd_wss *chip, unsigned int mode)
{ {
unsigned long flags; unsigned long flags;
if (chip->mode & AD1848_MODE_OPEN) if (chip->mode & WSS_MODE_OPEN)
return -EAGAIN; return -EAGAIN;
snd_ad1848_mce_down(chip); snd_ad1848_mce_down(chip);
...@@ -570,11 +568,9 @@ static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id) ...@@ -570,11 +568,9 @@ static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id)
{ {
struct snd_wss *chip = dev_id; struct snd_wss *chip = dev_id;
if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream && if ((chip->mode & WSS_MODE_PLAY) && chip->playback_substream)
(chip->mode & AD1848_MODE_RUNNING))
snd_pcm_period_elapsed(chip->playback_substream); snd_pcm_period_elapsed(chip->playback_substream);
if ((chip->mode & AD1848_MODE_CAPTURE) && chip->capture_substream && if ((chip->mode & WSS_MODE_RECORD) && chip->capture_substream)
(chip->mode & AD1848_MODE_RUNNING))
snd_pcm_period_elapsed(chip->capture_substream); snd_pcm_period_elapsed(chip->capture_substream);
outb(0, AD1848P(chip, STATUS)); /* clear global interrupt bit */ outb(0, AD1848P(chip, STATUS)); /* clear global interrupt bit */
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -690,19 +686,19 @@ static int snd_ad1848_probe(struct snd_wss *chip) ...@@ -690,19 +686,19 @@ static int snd_ad1848_probe(struct snd_wss *chip)
} }
if (id != 1) if (id != 1)
return -ENODEV; /* no valid device found */ return -ENODEV; /* no valid device found */
if (chip->hardware == AD1848_HW_DETECT) { if (chip->hardware == WSS_HW_DETECT) {
if (ad1847) { if (ad1847) {
chip->hardware = AD1848_HW_AD1847; chip->hardware = WSS_HW_AD1847;
} else { } else {
chip->hardware = AD1848_HW_AD1848; chip->hardware = WSS_HW_AD1848;
rev = snd_ad1848_in(chip, AD1848_MISC_INFO); rev = snd_ad1848_in(chip, AD1848_MISC_INFO);
if (rev & 0x80) { if (rev & 0x80) {
chip->hardware = AD1848_HW_CS4248; chip->hardware = WSS_HW_CS4248;
} else if ((rev & 0x0f) == 0x0a) { } else if ((rev & 0x0f) == 0x0a) {
snd_ad1848_out(chip, AD1848_MISC_INFO, 0x40); snd_ad1848_out(chip, AD1848_MISC_INFO, 0x40);
for (i = 0; i < 16; ++i) { for (i = 0; i < 16; ++i) {
if (snd_ad1848_in(chip, i) != snd_ad1848_in(chip, i + 16)) { if (snd_ad1848_in(chip, i) != snd_ad1848_in(chip, i + 16)) {
chip->hardware = AD1848_HW_CMI8330; chip->hardware = WSS_HW_CMI8330;
break; break;
} }
} }
...@@ -782,7 +778,8 @@ static int snd_ad1848_playback_open(struct snd_pcm_substream *substream) ...@@ -782,7 +778,8 @@ static int snd_ad1848_playback_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
int err; int err;
if ((err = snd_ad1848_open(chip, AD1848_MODE_PLAY)) < 0) err = snd_ad1848_open(chip, WSS_MODE_PLAY);
if (err < 0)
return err; return err;
chip->playback_substream = substream; chip->playback_substream = substream;
runtime->hw = snd_ad1848_playback; runtime->hw = snd_ad1848_playback;
...@@ -798,7 +795,8 @@ static int snd_ad1848_capture_open(struct snd_pcm_substream *substream) ...@@ -798,7 +795,8 @@ static int snd_ad1848_capture_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
int err; int err;
if ((err = snd_ad1848_open(chip, AD1848_MODE_CAPTURE)) < 0) err = snd_ad1848_open(chip, WSS_MODE_RECORD);
if (err < 0)
return err; return err;
chip->capture_substream = substream; chip->capture_substream = substream;
runtime->hw = snd_ad1848_capture; runtime->hw = snd_ad1848_capture;
...@@ -812,7 +810,7 @@ static int snd_ad1848_playback_close(struct snd_pcm_substream *substream) ...@@ -812,7 +810,7 @@ static int snd_ad1848_playback_close(struct snd_pcm_substream *substream)
{ {
struct snd_wss *chip = snd_pcm_substream_chip(substream); struct snd_wss *chip = snd_pcm_substream_chip(substream);
chip->mode &= ~AD1848_MODE_PLAY; chip->mode &= ~WSS_MODE_PLAY;
chip->playback_substream = NULL; chip->playback_substream = NULL;
snd_ad1848_close(chip); snd_ad1848_close(chip);
return 0; return 0;
...@@ -822,7 +820,7 @@ static int snd_ad1848_capture_close(struct snd_pcm_substream *substream) ...@@ -822,7 +820,7 @@ static int snd_ad1848_capture_close(struct snd_pcm_substream *substream)
{ {
struct snd_wss *chip = snd_pcm_substream_chip(substream); struct snd_wss *chip = snd_pcm_substream_chip(substream);
chip->mode &= ~AD1848_MODE_CAPTURE; chip->mode &= ~WSS_MODE_RECORD;
chip->capture_substream = NULL; chip->capture_substream = NULL;
snd_ad1848_close(chip); snd_ad1848_close(chip);
return 0; return 0;
...@@ -903,9 +901,9 @@ int snd_ad1848_create(struct snd_card *card, ...@@ -903,9 +901,9 @@ int snd_ad1848_create(struct snd_card *card,
chip->dma1 = dma; chip->dma1 = dma;
chip->dma2 = dma; chip->dma2 = dma;
if (hardware == AD1848_HW_THINKPAD) { if (hardware == WSS_HW_THINKPAD) {
chip->thinkpad_flag = 1; chip->thinkpad_flag = 1;
chip->hardware = AD1848_HW_DETECT; /* reset */ chip->hardware = WSS_HW_DETECT; /* reset */
snd_ad1848_thinkpad_twiddle(chip, 1); snd_ad1848_thinkpad_twiddle(chip, 1);
} }
...@@ -1214,6 +1212,20 @@ static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); ...@@ -1214,6 +1212,20 @@ static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
#define AD1848_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \
{ .name = xname, \
.index = xindex, \
.type = AD1848_MIX_SINGLE, \
.private_value = AD1848_MIXVAL_SINGLE(reg, shift, mask, invert), \
.tlv = xtlv }
#define AD1848_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \
{ .name = xname, \
.index = xindex, \
.type = AD1848_MIX_DOUBLE, \
.private_value = AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert), \
.tlv = xtlv }
static struct ad1848_mix_elem snd_ad1848_controls[] = { static struct ad1848_mix_elem snd_ad1848_controls[] = {
AD1848_DOUBLE("PCM Playback Switch", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 7, 7, 1, 1), AD1848_DOUBLE("PCM Playback Switch", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 7, 7, 1, 1),
AD1848_DOUBLE_TLV("PCM Playback Volume", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 0, 0, 63, 1, AD1848_DOUBLE_TLV("PCM Playback Volume", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 0, 0, 63, 1,
......
...@@ -465,12 +465,12 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev) ...@@ -465,12 +465,12 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
wssport[dev] + 4, wssport[dev] + 4,
wssirq[dev], wssirq[dev],
wssdma[dev], wssdma[dev],
AD1848_HW_DETECT, WSS_HW_DETECT,
&acard->wss)) < 0) { &acard->wss)) < 0) {
snd_printk(KERN_ERR PFX "(AD1848) device busy??\n"); snd_printk(KERN_ERR PFX "(AD1848) device busy??\n");
return err; return err;
} }
if (acard->wss->hardware != AD1848_HW_CMI8330) { if (acard->wss->hardware != WSS_HW_CMI8330) {
snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n"); snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -775,7 +775,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) ...@@ -775,7 +775,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
#else #else
if ((error = snd_ad1848_create(card, chip->wss_base + 4, if ((error = snd_ad1848_create(card, chip->wss_base + 4,
chip->irq, chip->dma1, chip->irq, chip->dma1,
AD1848_HW_DETECT, &codec)) < 0) WSS_HW_DETECT, &codec)) < 0)
return error; return error;
if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0) if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0)
return error; return error;
......
...@@ -549,7 +549,7 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev) ...@@ -549,7 +549,7 @@ static int __devinit snd_sc6000_probe(struct device *devptr, unsigned int dev)
goto err_unmap2; goto err_unmap2;
err = snd_ad1848_create(card, mss_port[dev] + 4, xirq, xdma, err = snd_ad1848_create(card, mss_port[dev] + 4, xirq, xdma,
AD1848_HW_DETECT, &chip); WSS_HW_DETECT, &chip);
if (err < 0) if (err < 0)
goto err_unmap2; goto err_unmap2;
card->private_data = chip; card->private_data = chip;
......
...@@ -265,7 +265,7 @@ static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev) ...@@ -265,7 +265,7 @@ static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev)
if ((err = snd_ad1848_create(card, wssport[dev] + 4, if ((err = snd_ad1848_create(card, wssport[dev] + 4,
xirq, xdma1, xirq, xdma1,
AD1848_HW_DETECT, &chip)) < 0) WSS_HW_DETECT, &chip)) < 0)
goto _err; goto _err;
card->private_data = chip; card->private_data = 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