aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/ad1848
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2008-07-31 15:05:44 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-06 09:39:51 -0400
commitece11c9b6db5b96179df8eb9cdc54c78953a4c0f (patch)
tree21c5ebf03d9750fc1c4a4551f84031e969e422b8 /sound/isa/ad1848
parent241b3ee70d2d69e88d5c144ce938b1887cd6d3fc (diff)
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: Krzysztof Helt <krzysztof.h1@wp.pl> Reviewed-by: Rene Herman <rene.herman@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/isa/ad1848')
-rw-r--r--sound/isa/ad1848/ad1848.c2
-rw-r--r--sound/isa/ad1848/ad1848_lib.c48
2 files changed, 31 insertions, 19 deletions
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
index 74db24ae6509..40de24b280d3 100644
--- a/sound/isa/ad1848/ad1848.c
+++ b/sound/isa/ad1848/ad1848.c
@@ -96,7 +96,7 @@ static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n)
96 return -EINVAL; 96 return -EINVAL;
97 97
98 error = snd_ad1848_create(card, port[n], irq[n], dma1[n], 98 error = snd_ad1848_create(card, port[n], irq[n], dma1[n],
99 thinkpad[n] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, &chip); 99 thinkpad[n] ? WSS_HW_THINKPAD : WSS_HW_DETECT, &chip);
100 if (error < 0) 100 if (error < 0)
101 goto out; 101 goto out;
102 102
diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
index e25fadffdb55..5aa8f6dae75b 100644
--- a/sound/isa/ad1848/ad1848_lib.c
+++ b/sound/isa/ad1848/ad1848_lib.c
@@ -283,14 +283,12 @@ static int snd_ad1848_trigger(struct snd_wss *chip, unsigned char what,
283 return 0; 283 return 0;
284 } 284 }
285 snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] |= what); 285 snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] |= what);
286 chip->mode |= AD1848_MODE_RUNNING;
287 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { 286 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
288 if (!(chip->image[AD1848_IFACE_CTRL] & what)) { 287 if (!(chip->image[AD1848_IFACE_CTRL] & what)) {
289 spin_unlock(&chip->reg_lock); 288 spin_unlock(&chip->reg_lock);
290 return 0; 289 return 0;
291 } 290 }
292 snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] &= ~what); 291 snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] &= ~what);
293 chip->mode &= ~AD1848_MODE_RUNNING;
294 } else { 292 } else {
295 result = -EINVAL; 293 result = -EINVAL;
296 } 294 }
@@ -378,7 +376,7 @@ static int snd_ad1848_open(struct snd_wss *chip, unsigned int mode)
378{ 376{
379 unsigned long flags; 377 unsigned long flags;
380 378
381 if (chip->mode & AD1848_MODE_OPEN) 379 if (chip->mode & WSS_MODE_OPEN)
382 return -EAGAIN; 380 return -EAGAIN;
383 381
384 snd_ad1848_mce_down(chip); 382 snd_ad1848_mce_down(chip);
@@ -570,11 +568,9 @@ static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id)
570{ 568{
571 struct snd_wss *chip = dev_id; 569 struct snd_wss *chip = dev_id;
572 570
573 if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream && 571 if ((chip->mode & WSS_MODE_PLAY) && chip->playback_substream)
574 (chip->mode & AD1848_MODE_RUNNING))
575 snd_pcm_period_elapsed(chip->playback_substream); 572 snd_pcm_period_elapsed(chip->playback_substream);
576 if ((chip->mode & AD1848_MODE_CAPTURE) && chip->capture_substream && 573 if ((chip->mode & WSS_MODE_RECORD) && chip->capture_substream)
577 (chip->mode & AD1848_MODE_RUNNING))
578 snd_pcm_period_elapsed(chip->capture_substream); 574 snd_pcm_period_elapsed(chip->capture_substream);
579 outb(0, AD1848P(chip, STATUS)); /* clear global interrupt bit */ 575 outb(0, AD1848P(chip, STATUS)); /* clear global interrupt bit */
580 return IRQ_HANDLED; 576 return IRQ_HANDLED;
@@ -690,19 +686,19 @@ static int snd_ad1848_probe(struct snd_wss *chip)
690 } 686 }
691 if (id != 1) 687 if (id != 1)
692 return -ENODEV; /* no valid device found */ 688 return -ENODEV; /* no valid device found */
693 if (chip->hardware == AD1848_HW_DETECT) { 689 if (chip->hardware == WSS_HW_DETECT) {
694 if (ad1847) { 690 if (ad1847) {
695 chip->hardware = AD1848_HW_AD1847; 691 chip->hardware = WSS_HW_AD1847;
696 } else { 692 } else {
697 chip->hardware = AD1848_HW_AD1848; 693 chip->hardware = WSS_HW_AD1848;
698 rev = snd_ad1848_in(chip, AD1848_MISC_INFO); 694 rev = snd_ad1848_in(chip, AD1848_MISC_INFO);
699 if (rev & 0x80) { 695 if (rev & 0x80) {
700 chip->hardware = AD1848_HW_CS4248; 696 chip->hardware = WSS_HW_CS4248;
701 } else if ((rev & 0x0f) == 0x0a) { 697 } else if ((rev & 0x0f) == 0x0a) {
702 snd_ad1848_out(chip, AD1848_MISC_INFO, 0x40); 698 snd_ad1848_out(chip, AD1848_MISC_INFO, 0x40);
703 for (i = 0; i < 16; ++i) { 699 for (i = 0; i < 16; ++i) {
704 if (snd_ad1848_in(chip, i) != snd_ad1848_in(chip, i + 16)) { 700 if (snd_ad1848_in(chip, i) != snd_ad1848_in(chip, i + 16)) {
705 chip->hardware = AD1848_HW_CMI8330; 701 chip->hardware = WSS_HW_CMI8330;
706 break; 702 break;
707 } 703 }
708 } 704 }
@@ -782,7 +778,8 @@ static int snd_ad1848_playback_open(struct snd_pcm_substream *substream)
782 struct snd_pcm_runtime *runtime = substream->runtime; 778 struct snd_pcm_runtime *runtime = substream->runtime;
783 int err; 779 int err;
784 780
785 if ((err = snd_ad1848_open(chip, AD1848_MODE_PLAY)) < 0) 781 err = snd_ad1848_open(chip, WSS_MODE_PLAY);
782 if (err < 0)
786 return err; 783 return err;
787 chip->playback_substream = substream; 784 chip->playback_substream = substream;
788 runtime->hw = snd_ad1848_playback; 785 runtime->hw = snd_ad1848_playback;
@@ -798,7 +795,8 @@ static int snd_ad1848_capture_open(struct snd_pcm_substream *substream)
798 struct snd_pcm_runtime *runtime = substream->runtime; 795 struct snd_pcm_runtime *runtime = substream->runtime;
799 int err; 796 int err;
800 797
801 if ((err = snd_ad1848_open(chip, AD1848_MODE_CAPTURE)) < 0) 798 err = snd_ad1848_open(chip, WSS_MODE_RECORD);
799 if (err < 0)
802 return err; 800 return err;
803 chip->capture_substream = substream; 801 chip->capture_substream = substream;
804 runtime->hw = snd_ad1848_capture; 802 runtime->hw = snd_ad1848_capture;
@@ -812,7 +810,7 @@ static int snd_ad1848_playback_close(struct snd_pcm_substream *substream)
812{ 810{
813 struct snd_wss *chip = snd_pcm_substream_chip(substream); 811 struct snd_wss *chip = snd_pcm_substream_chip(substream);
814 812
815 chip->mode &= ~AD1848_MODE_PLAY; 813 chip->mode &= ~WSS_MODE_PLAY;
816 chip->playback_substream = NULL; 814 chip->playback_substream = NULL;
817 snd_ad1848_close(chip); 815 snd_ad1848_close(chip);
818 return 0; 816 return 0;
@@ -822,7 +820,7 @@ static int snd_ad1848_capture_close(struct snd_pcm_substream *substream)
822{ 820{
823 struct snd_wss *chip = snd_pcm_substream_chip(substream); 821 struct snd_wss *chip = snd_pcm_substream_chip(substream);
824 822
825 chip->mode &= ~AD1848_MODE_CAPTURE; 823 chip->mode &= ~WSS_MODE_RECORD;
826 chip->capture_substream = NULL; 824 chip->capture_substream = NULL;
827 snd_ad1848_close(chip); 825 snd_ad1848_close(chip);
828 return 0; 826 return 0;
@@ -903,9 +901,9 @@ int snd_ad1848_create(struct snd_card *card,
903 chip->dma1 = dma; 901 chip->dma1 = dma;
904 chip->dma2 = dma; 902 chip->dma2 = dma;
905 903
906 if (hardware == AD1848_HW_THINKPAD) { 904 if (hardware == WSS_HW_THINKPAD) {
907 chip->thinkpad_flag = 1; 905 chip->thinkpad_flag = 1;
908 chip->hardware = AD1848_HW_DETECT; /* reset */ 906 chip->hardware = WSS_HW_DETECT; /* reset */
909 snd_ad1848_thinkpad_twiddle(chip, 1); 907 snd_ad1848_thinkpad_twiddle(chip, 1);
910 } 908 }
911 909
@@ -1214,6 +1212,20 @@ static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
1214static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); 1212static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
1215static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); 1213static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
1216 1214
1215#define AD1848_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \
1216{ .name = xname, \
1217 .index = xindex, \
1218 .type = AD1848_MIX_SINGLE, \
1219 .private_value = AD1848_MIXVAL_SINGLE(reg, shift, mask, invert), \
1220 .tlv = xtlv }
1221
1222#define AD1848_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \
1223{ .name = xname, \
1224 .index = xindex, \
1225 .type = AD1848_MIX_DOUBLE, \
1226 .private_value = AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert), \
1227 .tlv = xtlv }
1228
1217static struct ad1848_mix_elem snd_ad1848_controls[] = { 1229static struct ad1848_mix_elem snd_ad1848_controls[] = {
1218AD1848_DOUBLE("PCM Playback Switch", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 7, 7, 1, 1), 1230AD1848_DOUBLE("PCM Playback Switch", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 7, 7, 1, 1),
1219AD1848_DOUBLE_TLV("PCM Playback Volume", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 0, 0, 63, 1, 1231AD1848_DOUBLE_TLV("PCM Playback Volume", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 0, 0, 63, 1,