aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-09-06 22:02:23 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-22 10:01:16 -0400
commit54ac005adcda1a9e4566df6fa87acd4a1c135b80 (patch)
tree050092a071dd0e11ee25d8fd171e0cce81757dbd /drivers/media/video
parent55b70a0300b873c0ec7ea6e33752af56f41250ce (diff)
V4L/DVB (6185): cx88-alsa: Add mute controls, change control names
Add two mute controls. One mutes everything, the other just mutes the analog pass-through output. Rename the existing volume control. The controls are now: Playback Volume Playback Switch Capture Switch These names might seem odd, but I believe they are more correct. The previous "Capture Volume" control didn't actually effect the volume of the captured audio. Instead it controls the volume of the analog pass-thought output. It appears that pass-through controls like this are usually considered to be in the playback direction, not capture. For example, "CAPTURE feedback Playback Volume" is the name used for a control that appears to have the same effect in the ca0106 driver. We only have one volume control, so we can omit the "CAPTURE feedback" part. If someone where to add PCM playback support to the driver, then this would be the volume control. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c80
1 files changed, 67 insertions, 13 deletions
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 141dadf7cf1b..6cf8609588a5 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -82,6 +82,7 @@ typedef struct cx88_audio_dev snd_cx88_card_t;
82 82
83 83
84 84
85
85/**************************************************************************** 86/****************************************************************************
86 Module global static vars 87 Module global static vars
87 ****************************************************************************/ 88 ****************************************************************************/
@@ -545,8 +546,8 @@ static int __devinit snd_cx88_pcm(snd_cx88_card_t *chip, int device, char *name)
545/**************************************************************************** 546/****************************************************************************
546 CONTROL INTERFACE 547 CONTROL INTERFACE
547 ****************************************************************************/ 548 ****************************************************************************/
548static int snd_cx88_capture_volume_info(struct snd_kcontrol *kcontrol, 549static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_info *info) 550 struct snd_ctl_elem_info *info)
550{ 551{
551 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 552 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
552 info->count = 2; 553 info->count = 2;
@@ -556,9 +557,8 @@ static int snd_cx88_capture_volume_info(struct snd_kcontrol *kcontrol,
556 return 0; 557 return 0;
557} 558}
558 559
559/* OK - TODO: test it */ 560static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol,
560static int snd_cx88_capture_volume_get(struct snd_kcontrol *kcontrol, 561 struct snd_ctl_elem_value *value)
561 struct snd_ctl_elem_value *value)
562{ 562{
563 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 563 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
564 struct cx88_core *core=chip->core; 564 struct cx88_core *core=chip->core;
@@ -573,8 +573,8 @@ static int snd_cx88_capture_volume_get(struct snd_kcontrol *kcontrol,
573} 573}
574 574
575/* OK - TODO: test it */ 575/* OK - TODO: test it */
576static int snd_cx88_capture_volume_put(struct snd_kcontrol *kcontrol, 576static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
577 struct snd_ctl_elem_value *value) 577 struct snd_ctl_elem_value *value)
578{ 578{
579 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); 579 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
580 struct cx88_core *core=chip->core; 580 struct cx88_core *core=chip->core;
@@ -605,14 +605,62 @@ static int snd_cx88_capture_volume_put(struct snd_kcontrol *kcontrol,
605 return changed; 605 return changed;
606} 606}
607 607
608static struct snd_kcontrol_new snd_cx88_capture_volume = { 608static struct snd_kcontrol_new snd_cx88_volume = {
609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
610 .name = "Capture Volume", 610 .name = "Playback Volume",
611 .info = snd_cx88_capture_volume_info, 611 .info = snd_cx88_volume_info,
612 .get = snd_cx88_capture_volume_get, 612 .get = snd_cx88_volume_get,
613 .put = snd_cx88_capture_volume_put, 613 .put = snd_cx88_volume_put,
614}; 614};
615 615
616static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol,
617 struct snd_ctl_elem_value *value)
618{
619 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
620 struct cx88_core *core = chip->core;
621 u32 bit = kcontrol->private_value;
622
623 value->value.integer.value[0] = !(cx_read(AUD_VOL_CTL) & bit);
624 return 0;
625}
626
627static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_value *value)
629{
630 snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol);
631 struct cx88_core *core = chip->core;
632 u32 bit = kcontrol->private_value;
633 int ret = 0;
634 u32 vol;
635
636 spin_lock_irq(&chip->reg_lock);
637 vol = cx_read(AUD_VOL_CTL);
638 if (value->value.integer.value[0] != !(vol & bit)) {
639 vol ^= bit;
640 cx_write(AUD_VOL_CTL, vol);
641 ret = 1;
642 }
643 spin_unlock_irq(&chip->reg_lock);
644 return ret;
645}
646
647static struct snd_kcontrol_new snd_cx88_dac_switch = {
648 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
649 .name = "Playback Switch",
650 .info = snd_ctl_boolean_mono_info,
651 .get = snd_cx88_switch_get,
652 .put = snd_cx88_switch_put,
653 .private_value = (1<<8),
654};
655
656static struct snd_kcontrol_new snd_cx88_source_switch = {
657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
658 .name = "Capture Switch",
659 .info = snd_ctl_boolean_mono_info,
660 .get = snd_cx88_switch_get,
661 .put = snd_cx88_switch_put,
662 .private_value = (1<<6),
663};
616 664
617/**************************************************************************** 665/****************************************************************************
618 Basic Flow for Sound Devices 666 Basic Flow for Sound Devices
@@ -762,7 +810,13 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
762 if (err < 0) 810 if (err < 0)
763 goto error; 811 goto error;
764 812
765 err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_capture_volume, chip)); 813 err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_volume, chip));
814 if (err < 0)
815 goto error;
816 err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_dac_switch, chip));
817 if (err < 0)
818 goto error;
819 err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_source_switch, chip));
766 if (err < 0) 820 if (err < 0)
767 goto error; 821 goto error;
768 822