aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2009-12-10 14:40:18 -0500
committerTakashi Iwai <tiwai@suse.de>2009-12-11 08:43:16 -0500
commitb2e8d7dab9d82be3851b8cbcc1ab64b1b2575844 (patch)
treefc64d981ba7577232cd6aeaf8fdcb7eb2009da11 /sound/isa
parent14ff3e78304e3f7fe18f950c3aa0686e6800b3fb (diff)
ALSA: opti93x: move controls definitions to opti93x driver
Move OPTi93x controls definitions to the opti93x driver from the common wss-lib library module. These controls are used only by the opti93x driver. Also, fix capture source names. They are the same as opl3sa2 names. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa')
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c85
-rw-r--r--sound/isa/wss/wss_lib.c80
2 files changed, 100 insertions, 65 deletions
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 106be6e471f7..ea4a67120468 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -33,6 +33,7 @@
33#include <asm/io.h> 33#include <asm/io.h>
34#include <asm/dma.h> 34#include <asm/dma.h>
35#include <sound/core.h> 35#include <sound/core.h>
36#include <sound/tlv.h>
36#include <sound/wss.h> 37#include <sound/wss.h>
37#include <sound/mpu401.h> 38#include <sound/mpu401.h>
38#include <sound/opl3.h> 39#include <sound/opl3.h>
@@ -546,6 +547,85 @@ __skip_mpu:
546 547
547#ifdef OPTi93X 548#ifdef OPTi93X
548 549
550static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
551
552static struct snd_kcontrol_new snd_opti93x_controls[] = {
553WSS_DOUBLE("Master Playback Switch", 0,
554 OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
555WSS_DOUBLE_TLV("Master Playback Volume", 0,
556 OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1,
557 db_scale_6bit),
558WSS_DOUBLE("PCM Playback Volume", 0,
559 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1),
560WSS_DOUBLE("FM Playback Volume", 0,
561 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1),
562WSS_DOUBLE("Line Playback Switch", 0,
563 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
564WSS_DOUBLE("Line Playback Volume", 0,
565 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1),
566WSS_DOUBLE("Mic Playback Switch", 0,
567 OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1),
568WSS_DOUBLE("Mic Playback Volume", 0,
569 OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1),
570WSS_DOUBLE("CD Playback Volume", 0,
571 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1),
572WSS_DOUBLE("Aux Playback Switch", 0,
573 OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1),
574WSS_DOUBLE("Aux Playback Volume", 0,
575 OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1),
576};
577
578static int __devinit snd_opti93x_mixer(struct snd_wss *chip)
579{
580 struct snd_card *card;
581 unsigned int idx;
582 struct snd_ctl_elem_id id1, id2;
583 int err;
584
585 if (snd_BUG_ON(!chip || !chip->pcm))
586 return -EINVAL;
587
588 card = chip->card;
589
590 strcpy(card->mixername, chip->pcm->name);
591
592 memset(&id1, 0, sizeof(id1));
593 memset(&id2, 0, sizeof(id2));
594 id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
595 /* reassign AUX0 switch to CD */
596 strcpy(id1.name, "Aux Playback Switch");
597 strcpy(id2.name, "CD Playback Switch");
598 err = snd_ctl_rename_id(card, &id1, &id2);
599 if (err < 0) {
600 snd_printk(KERN_ERR "Cannot rename opti93x control\n");
601 return err;
602 }
603 /* reassign AUX1 switch to FM */
604 strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
605 strcpy(id2.name, "FM Playback Switch");
606 err = snd_ctl_rename_id(card, &id1, &id2);
607 if (err < 0) {
608 snd_printk(KERN_ERR "Cannot rename opti93x control\n");
609 return err;
610 }
611 /* remove AUX1 volume */
612 strcpy(id1.name, "Aux Playback Volume"); id1.index = 1;
613 snd_ctl_remove_id(card, &id1);
614
615 /* Replace WSS volume controls with OPTi93x volume controls */
616 id1.index = 0;
617 for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) {
618 strcpy(id1.name, snd_opti93x_controls[idx].name);
619 snd_ctl_remove_id(card, &id1);
620
621 err = snd_ctl_add(card,
622 snd_ctl_new1(&snd_opti93x_controls[idx], chip));
623 if (err < 0)
624 return err;
625 }
626 return 0;
627}
628
549static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) 629static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id)
550{ 630{
551 struct snd_wss *codec = dev_id; 631 struct snd_wss *codec = dev_id;
@@ -752,6 +832,11 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
752 error = snd_wss_mixer(codec); 832 error = snd_wss_mixer(codec);
753 if (error < 0) 833 if (error < 0)
754 return error; 834 return error;
835#ifdef OPTi93X
836 error = snd_opti93x_mixer(codec);
837 if (error < 0)
838 return error;
839#endif
755#ifdef CS4231 840#ifdef CS4231
756 error = snd_wss_timer(codec, 0, &timer); 841 error = snd_wss_timer(codec, 0, &timer);
757 if (error < 0) 842 if (error < 0)
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c
index 5b9d6c18bc45..9191b32d9130 100644
--- a/sound/isa/wss/wss_lib.c
+++ b/sound/isa/wss/wss_lib.c
@@ -2014,6 +2014,7 @@ static int snd_wss_info_mux(struct snd_kcontrol *kcontrol,
2014 case WSS_HW_INTERWAVE: 2014 case WSS_HW_INTERWAVE:
2015 ptexts = gusmax_texts; 2015 ptexts = gusmax_texts;
2016 break; 2016 break;
2017 case WSS_HW_OPTI93X:
2017 case WSS_HW_OPL3SA2: 2018 case WSS_HW_OPL3SA2:
2018 ptexts = opl3sa_texts; 2019 ptexts = opl3sa_texts;
2019 break; 2020 break;
@@ -2246,54 +2247,12 @@ WSS_SINGLE("Beep Bypass Playback Switch", 0,
2246 CS4231_MONO_CTRL, 5, 1, 0), 2247 CS4231_MONO_CTRL, 5, 1, 0),
2247}; 2248};
2248 2249
2249static struct snd_kcontrol_new snd_opti93x_controls[] = {
2250WSS_DOUBLE("Master Playback Switch", 0,
2251 OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
2252WSS_DOUBLE_TLV("Master Playback Volume", 0,
2253 OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1,
2254 db_scale_6bit),
2255WSS_DOUBLE("PCM Playback Switch", 0,
2256 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
2257WSS_DOUBLE("PCM Playback Volume", 0,
2258 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1),
2259WSS_DOUBLE("FM Playback Switch", 0,
2260 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
2261WSS_DOUBLE("FM Playback Volume", 0,
2262 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1),
2263WSS_DOUBLE("Line Playback Switch", 0,
2264 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
2265WSS_DOUBLE("Line Playback Volume", 0,
2266 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1),
2267WSS_DOUBLE("Mic Playback Switch", 0,
2268 OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1),
2269WSS_DOUBLE("Mic Playback Volume", 0,
2270 OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1),
2271WSS_DOUBLE("Mic Boost", 0,
2272 CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0),
2273WSS_DOUBLE("CD Playback Switch", 0,
2274 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1),
2275WSS_DOUBLE("CD Playback Volume", 0,
2276 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1),
2277WSS_DOUBLE("Aux Playback Switch", 0,
2278 OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1),
2279WSS_DOUBLE("Aux Playback Volume", 0,
2280 OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1),
2281WSS_DOUBLE("Capture Volume", 0,
2282 CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0),
2283{
2284 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2285 .name = "Capture Source",
2286 .info = snd_wss_info_mux,
2287 .get = snd_wss_get_mux,
2288 .put = snd_wss_put_mux,
2289}
2290};
2291
2292int snd_wss_mixer(struct snd_wss *chip) 2250int snd_wss_mixer(struct snd_wss *chip)
2293{ 2251{
2294 struct snd_card *card; 2252 struct snd_card *card;
2295 unsigned int idx; 2253 unsigned int idx;
2296 int err; 2254 int err;
2255 int count = ARRAY_SIZE(snd_wss_controls);
2297 2256
2298 if (snd_BUG_ON(!chip || !chip->pcm)) 2257 if (snd_BUG_ON(!chip || !chip->pcm))
2299 return -EINVAL; 2258 return -EINVAL;
@@ -2302,28 +2261,19 @@ int snd_wss_mixer(struct snd_wss *chip)
2302 2261
2303 strcpy(card->mixername, chip->pcm->name); 2262 strcpy(card->mixername, chip->pcm->name);
2304 2263
2305 if (chip->hardware == WSS_HW_OPTI93X) 2264 /* Use only the first 11 entries on AD1848 */
2306 for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { 2265 if (chip->hardware & WSS_HW_AD1848_MASK)
2307 err = snd_ctl_add(card, 2266 count = 11;
2308 snd_ctl_new1(&snd_opti93x_controls[idx], 2267 /* There is no loopback on OPTI93X */
2309 chip)); 2268 else if (chip->hardware == WSS_HW_OPTI93X)
2310 if (err < 0) 2269 count = 9;
2311 return err; 2270
2312 } 2271 for (idx = 0; idx < count; idx++) {
2313 else { 2272 err = snd_ctl_add(card,
2314 int count = ARRAY_SIZE(snd_wss_controls); 2273 snd_ctl_new1(&snd_wss_controls[idx],
2315 2274 chip));
2316 /* Use only the first 11 entries on AD1848 */ 2275 if (err < 0)
2317 if (chip->hardware & WSS_HW_AD1848_MASK) 2276 return err;
2318 count = 11;
2319
2320 for (idx = 0; idx < count; idx++) {
2321 err = snd_ctl_add(card,
2322 snd_ctl_new1(&snd_wss_controls[idx],
2323 chip));
2324 if (err < 0)
2325 return err;
2326 }
2327 } 2277 }
2328 return 0; 2278 return 0;
2329} 2279}