All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] dummy: allow disabling mixer controls
@ 2012-10-20 22:09 Clemens Ladisch
  2012-10-21  7:24 ` Raymond Yau
  2012-10-21  8:21 ` Takashi Iwai
  0 siblings, 2 replies; 7+ messages in thread
From: Clemens Ladisch @ 2012-10-20 22:09 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

The following changes since commit a0d271cbfed1dd50278c6b06bead3d00ba0a88f9:

  Linux 3.6 (2012-09-30 16:47:46 -0700)

are available in the git repository at:
  git://git.alsa-project.org/alsa-kprivate.git dummy-ctl-inactive

----------------------------------------------------------------
Quite a few mixer applications do not handle deactivated controls
correctly.  This patch adds such controls to snd-dummy to make
crash^H^H^H^H^Htesting these apps easier.
----------------------------------------------------------------
Clemens Ladisch (1):
      ALSA: dummy: allow disabling mixer controls

 sound/drivers/dummy.c |   73 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 54bb664..4f522cf 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -134,6 +134,9 @@ struct snd_dummy {
 	spinlock_t mixer_lock;
 	int mixer_volume[MIXER_ADDR_LAST+1][2];
 	int capture_source[MIXER_ADDR_LAST+1][2];
+	int iobox;
+	struct snd_kcontrol *cd_volume_ctl;
+	struct snd_kcontrol *cd_switch_ctl;
 	const struct dummy_timer_ops *timer_ops;
 };

@@ -817,6 +820,57 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
 	return change;
 }

+static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_info *info)
+{
+	const char *const names[] = { "None", "CD Player" };
+
+	return snd_ctl_enum_info(info, 1, 2, names);
+}
+
+static int snd_dummy_iobox_get(struct snd_kcontrol *kcontrol,
+			       struct snd_ctl_elem_value *value)
+{
+	struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
+
+	value->value.enumerated.item[0] = dummy->iobox;
+	return 0;
+}
+
+static int snd_dummy_iobox_put(struct snd_kcontrol *kcontrol,
+			       struct snd_ctl_elem_value *value)
+{
+	struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
+	int changed;
+
+	if (value->value.enumerated.item[0] > 1)
+		return -EINVAL;
+
+	changed = value->value.enumerated.item[0] != dummy->iobox;
+	if (changed) {
+		dummy->iobox = value->value.enumerated.item[0];
+
+		if (dummy->iobox) {
+			dummy->cd_volume_ctl->vd[0].access &=
+				~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
+			dummy->cd_switch_ctl->vd[0].access &=
+				~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
+		} else {
+			dummy->cd_volume_ctl->vd[0].access |=
+				SNDRV_CTL_ELEM_ACCESS_INACTIVE;
+			dummy->cd_switch_ctl->vd[0].access |=
+				SNDRV_CTL_ELEM_ACCESS_INACTIVE;
+		}
+
+		snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
+			       &dummy->cd_volume_ctl->id);
+		snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
+			       &dummy->cd_switch_ctl->id);
+	}
+
+	return changed;
+}
+
 static struct snd_kcontrol_new snd_dummy_controls[] = {
 DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
 DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
@@ -827,22 +881,37 @@ DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_LINE),
 DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
 DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
 DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
-DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD)
+DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD),
+{
+	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+	.name  = "External I/O Box",
+	.info  = snd_dummy_iobox_info,
+	.get   = snd_dummy_iobox_get,
+	.put   = snd_dummy_iobox_put,
+},
 };

 static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
 {
 	struct snd_card *card = dummy->card;
+	struct snd_kcontrol *kcontrol;
 	unsigned int idx;
 	int err;

 	spin_lock_init(&dummy->mixer_lock);
 	strcpy(card->mixername, "Dummy Mixer");
+	dummy->iobox = 1;

 	for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
-		err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy));
+		kcontrol = snd_ctl_new1(&snd_dummy_controls[idx], dummy);
+		err = snd_ctl_add(card, kcontrol);
 		if (err < 0)
 			return err;
+		if (!strcmp(kcontrol->id.name, "CD Volume"))
+			dummy->cd_volume_ctl = kcontrol;
+		else if (!strcmp(kcontrol->id.name, "CD Capture Switch"))
+			dummy->cd_switch_ctl = kcontrol;
+
 	}
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] dummy: allow disabling mixer controls
  2012-10-20 22:09 [GIT PULL] dummy: allow disabling mixer controls Clemens Ladisch
@ 2012-10-21  7:24 ` Raymond Yau
  2012-10-21  8:22   ` Takashi Iwai
  2012-10-21 11:12   ` Clemens Ladisch
  2012-10-21  8:21 ` Takashi Iwai
  1 sibling, 2 replies; 7+ messages in thread
From: Raymond Yau @ 2012-10-21  7:24 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Takashi Iwai, alsa-devel

2012-10-21 上午6:11 於 "Clemens Ladisch" <clemens@ladisch.de> 寫道:
>
> The following changes since commit
a0d271cbfed1dd50278c6b06bead3d00ba0a88f9:
>
>   Linux 3.6 (2012-09-30 16:47:46 -0700)
>
> are available in the git repository at:
>   git://git.alsa-project.org/alsa-kprivate.git dummy-ctl-inactive
>
> ----------------------------------------------------------------
> Quite a few mixer applications do not handle deactivated controls
> correctly.  This patch adds such controls to snd-dummy to make
> crash^H^H^H^H^Htesting these apps easier.
> ----------------------------------------------------------------

what is the meaning of deactivated control ?

amixer still can change the value of the deactivated cd volume control if
write access is no disabled

> Clemens Ladisch (1):
>       ALSA: dummy: allow disabling mixer controls
>
>  sound/drivers/dummy.c |   73
+++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 71 insertions(+), 2 deletions(-)
>
> diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
> index 54bb664..4f522cf 100644
> --- a/sound/drivers/dummy.c
> +++ b/sound/drivers/dummy.c
> @@ -134,6 +134,9 @@ struct snd_dummy {
>         spinlock_t mixer_lock;
>         int mixer_volume[MIXER_ADDR_LAST+1][2];
>         int capture_source[MIXER_ADDR_LAST+1][2];
> +       int iobox;
> +       struct snd_kcontrol *cd_volume_ctl;
> +       struct snd_kcontrol *cd_switch_ctl;
>         const struct dummy_timer_ops *timer_ops;
>  };
>
> @@ -817,6 +820,57 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol
*kcontrol, struct snd_ctl_el
>         return change;
>  }
>
> +static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
> +                               struct snd_ctl_elem_info *info)
> +{
> +       const char *const names[] = { "None", "CD Player" };
> +
> +       return snd_ctl_enum_info(info, 1, 2, names);
> +}
> +
> +static int snd_dummy_iobox_get(struct snd_kcontrol *kcontrol,
> +                              struct snd_ctl_elem_value *value)
> +{
> +       struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
> +
> +       value->value.enumerated.item[0] = dummy->iobox;
> +       return 0;
> +}
> +
> +static int snd_dummy_iobox_put(struct snd_kcontrol *kcontrol,
> +                              struct snd_ctl_elem_value *value)
> +{
> +       struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
> +       int changed;
> +
> +       if (value->value.enumerated.item[0] > 1)
> +               return -EINVAL;
> +
> +       changed = value->value.enumerated.item[0] != dummy->iobox;
> +       if (changed) {
> +               dummy->iobox = value->value.enumerated.item[0];
> +
> +               if (dummy->iobox) {
> +                       dummy->cd_volume_ctl->vd[0].access &=
> +                               ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +                       dummy->cd_switch_ctl->vd[0].access &=
> +                               ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +               } else {
> +                       dummy->cd_volume_ctl->vd[0].access |=
> +                               SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +                       dummy->cd_switch_ctl->vd[0].access |=
> +                               SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +               }
> +
> +               snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
> +                              &dummy->cd_volume_ctl->id);
> +               snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
> +                              &dummy->cd_switch_ctl->id);
> +       }
> +
> +       return changed;
> +}
> +
>  static struct snd_kcontrol_new snd_dummy_controls[] = {
>  DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
>  DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
> @@ -827,22 +881,37 @@ DUMMY_CAPSRC("Line Capture Switch", 0,
MIXER_ADDR_LINE),
>  DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
>  DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
>  DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
> -DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD)
> +DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD),
> +{
> +       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> +       .name  = "External I/O Box",
> +       .info  = snd_dummy_iobox_info,
> +       .get   = snd_dummy_iobox_get,
> +       .put   = snd_dummy_iobox_put,
> +},
>  };
>
>  static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
>  {
>         struct snd_card *card = dummy->card;
> +       struct snd_kcontrol *kcontrol;
>         unsigned int idx;
>         int err;
>
>         spin_lock_init(&dummy->mixer_lock);
>         strcpy(card->mixername, "Dummy Mixer");
> +       dummy->iobox = 1;
>
>         for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
> -               err = snd_ctl_add(card,
snd_ctl_new1(&snd_dummy_controls[idx], dummy));
> +               kcontrol = snd_ctl_new1(&snd_dummy_controls[idx], dummy);
> +               err = snd_ctl_add(card, kcontrol);
>                 if (err < 0)
>                         return err;
> +               if (!strcmp(kcontrol->id.name, "CD Volume"))
> +                       dummy->cd_volume_ctl = kcontrol;
> +               else if (!strcmp(kcontrol->id.name, "CD Capture Switch"))
> +                       dummy->cd_switch_ctl = kcontrol;
> +
>         }
>         return 0;
>  }
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] dummy: allow disabling mixer controls
  2012-10-20 22:09 [GIT PULL] dummy: allow disabling mixer controls Clemens Ladisch
  2012-10-21  7:24 ` Raymond Yau
@ 2012-10-21  8:21 ` Takashi Iwai
  1 sibling, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2012-10-21  8:21 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

At Sun, 21 Oct 2012 00:09:40 +0200,
Clemens Ladisch wrote:
> 
> The following changes since commit a0d271cbfed1dd50278c6b06bead3d00ba0a88f9:
> 
>   Linux 3.6 (2012-09-30 16:47:46 -0700)
> 
> are available in the git repository at:
>   git://git.alsa-project.org/alsa-kprivate.git dummy-ctl-inactive
> 
> ----------------------------------------------------------------
> Quite a few mixer applications do not handle deactivated controls
> correctly.  This patch adds such controls to snd-dummy to make
> crash^H^H^H^H^Htesting these apps easier.

Pulled now.  Thanks.


Takashi

> ----------------------------------------------------------------
> Clemens Ladisch (1):
>       ALSA: dummy: allow disabling mixer controls
> 
>  sound/drivers/dummy.c |   73 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 71 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
> index 54bb664..4f522cf 100644
> --- a/sound/drivers/dummy.c
> +++ b/sound/drivers/dummy.c
> @@ -134,6 +134,9 @@ struct snd_dummy {
>  	spinlock_t mixer_lock;
>  	int mixer_volume[MIXER_ADDR_LAST+1][2];
>  	int capture_source[MIXER_ADDR_LAST+1][2];
> +	int iobox;
> +	struct snd_kcontrol *cd_volume_ctl;
> +	struct snd_kcontrol *cd_switch_ctl;
>  	const struct dummy_timer_ops *timer_ops;
>  };
> 
> @@ -817,6 +820,57 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
>  	return change;
>  }
> 
> +static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
> +				struct snd_ctl_elem_info *info)
> +{
> +	const char *const names[] = { "None", "CD Player" };
> +
> +	return snd_ctl_enum_info(info, 1, 2, names);
> +}
> +
> +static int snd_dummy_iobox_get(struct snd_kcontrol *kcontrol,
> +			       struct snd_ctl_elem_value *value)
> +{
> +	struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
> +
> +	value->value.enumerated.item[0] = dummy->iobox;
> +	return 0;
> +}
> +
> +static int snd_dummy_iobox_put(struct snd_kcontrol *kcontrol,
> +			       struct snd_ctl_elem_value *value)
> +{
> +	struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
> +	int changed;
> +
> +	if (value->value.enumerated.item[0] > 1)
> +		return -EINVAL;
> +
> +	changed = value->value.enumerated.item[0] != dummy->iobox;
> +	if (changed) {
> +		dummy->iobox = value->value.enumerated.item[0];
> +
> +		if (dummy->iobox) {
> +			dummy->cd_volume_ctl->vd[0].access &=
> +				~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +			dummy->cd_switch_ctl->vd[0].access &=
> +				~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +		} else {
> +			dummy->cd_volume_ctl->vd[0].access |=
> +				SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +			dummy->cd_switch_ctl->vd[0].access |=
> +				SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> +		}
> +
> +		snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
> +			       &dummy->cd_volume_ctl->id);
> +		snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
> +			       &dummy->cd_switch_ctl->id);
> +	}
> +
> +	return changed;
> +}
> +
>  static struct snd_kcontrol_new snd_dummy_controls[] = {
>  DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
>  DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
> @@ -827,22 +881,37 @@ DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_LINE),
>  DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
>  DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
>  DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
> -DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD)
> +DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD),
> +{
> +	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> +	.name  = "External I/O Box",
> +	.info  = snd_dummy_iobox_info,
> +	.get   = snd_dummy_iobox_get,
> +	.put   = snd_dummy_iobox_put,
> +},
>  };
> 
>  static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
>  {
>  	struct snd_card *card = dummy->card;
> +	struct snd_kcontrol *kcontrol;
>  	unsigned int idx;
>  	int err;
> 
>  	spin_lock_init(&dummy->mixer_lock);
>  	strcpy(card->mixername, "Dummy Mixer");
> +	dummy->iobox = 1;
> 
>  	for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
> -		err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy));
> +		kcontrol = snd_ctl_new1(&snd_dummy_controls[idx], dummy);
> +		err = snd_ctl_add(card, kcontrol);
>  		if (err < 0)
>  			return err;
> +		if (!strcmp(kcontrol->id.name, "CD Volume"))
> +			dummy->cd_volume_ctl = kcontrol;
> +		else if (!strcmp(kcontrol->id.name, "CD Capture Switch"))
> +			dummy->cd_switch_ctl = kcontrol;
> +
>  	}
>  	return 0;
>  }
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] dummy: allow disabling mixer controls
  2012-10-21  7:24 ` Raymond Yau
@ 2012-10-21  8:22   ` Takashi Iwai
  2012-10-24  3:45     ` Raymond Yau
  2012-10-21 11:12   ` Clemens Ladisch
  1 sibling, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2012-10-21  8:22 UTC (permalink / raw)
  To: Raymond Yau; +Cc: alsa-devel, Clemens Ladisch

At Sun, 21 Oct 2012 15:24:56 +0800,
Raymond Yau wrote:
> 
> 2012-10-21 上午6:11 於 "Clemens Ladisch" <clemens@ladisch.de> 寫道:
> >
> > The following changes since commit
> a0d271cbfed1dd50278c6b06bead3d00ba0a88f9:
> >
> >   Linux 3.6 (2012-09-30 16:47:46 -0700)
> >
> > are available in the git repository at:
> >   git://git.alsa-project.org/alsa-kprivate.git dummy-ctl-inactive
> >
> > ----------------------------------------------------------------
> > Quite a few mixer applications do not handle deactivated controls
> > correctly.  This patch adds such controls to snd-dummy to make
> > crash^H^H^H^H^Htesting these apps easier.
> > ----------------------------------------------------------------
> 
> what is the meaning of deactivated control ?
> 
> amixer still can change the value of the deactivated cd volume control if
> write access is no disabled

If so, that should be checked rather in the core code...


Takashi

> > Clemens Ladisch (1):
> >       ALSA: dummy: allow disabling mixer controls
> >
> >  sound/drivers/dummy.c |   73
> +++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 files changed, 71 insertions(+), 2 deletions(-)
> >
> > diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
> > index 54bb664..4f522cf 100644
> > --- a/sound/drivers/dummy.c
> > +++ b/sound/drivers/dummy.c
> > @@ -134,6 +134,9 @@ struct snd_dummy {
> >         spinlock_t mixer_lock;
> >         int mixer_volume[MIXER_ADDR_LAST+1][2];
> >         int capture_source[MIXER_ADDR_LAST+1][2];
> > +       int iobox;
> > +       struct snd_kcontrol *cd_volume_ctl;
> > +       struct snd_kcontrol *cd_switch_ctl;
> >         const struct dummy_timer_ops *timer_ops;
> >  };
> >
> > @@ -817,6 +820,57 @@ static int snd_dummy_capsrc_put(struct snd_kcontrol
> *kcontrol, struct snd_ctl_el
> >         return change;
> >  }
> >
> > +static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
> > +                               struct snd_ctl_elem_info *info)
> > +{
> > +       const char *const names[] = { "None", "CD Player" };
> > +
> > +       return snd_ctl_enum_info(info, 1, 2, names);
> > +}
> > +
> > +static int snd_dummy_iobox_get(struct snd_kcontrol *kcontrol,
> > +                              struct snd_ctl_elem_value *value)
> > +{
> > +       struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
> > +
> > +       value->value.enumerated.item[0] = dummy->iobox;
> > +       return 0;
> > +}
> > +
> > +static int snd_dummy_iobox_put(struct snd_kcontrol *kcontrol,
> > +                              struct snd_ctl_elem_value *value)
> > +{
> > +       struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
> > +       int changed;
> > +
> > +       if (value->value.enumerated.item[0] > 1)
> > +               return -EINVAL;
> > +
> > +       changed = value->value.enumerated.item[0] != dummy->iobox;
> > +       if (changed) {
> > +               dummy->iobox = value->value.enumerated.item[0];
> > +
> > +               if (dummy->iobox) {
> > +                       dummy->cd_volume_ctl->vd[0].access &=
> > +                               ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> > +                       dummy->cd_switch_ctl->vd[0].access &=
> > +                               ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> > +               } else {
> > +                       dummy->cd_volume_ctl->vd[0].access |=
> > +                               SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> > +                       dummy->cd_switch_ctl->vd[0].access |=
> > +                               SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> > +               }
> > +
> > +               snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
> > +                              &dummy->cd_volume_ctl->id);
> > +               snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
> > +                              &dummy->cd_switch_ctl->id);
> > +       }
> > +
> > +       return changed;
> > +}
> > +
> >  static struct snd_kcontrol_new snd_dummy_controls[] = {
> >  DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
> >  DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
> > @@ -827,22 +881,37 @@ DUMMY_CAPSRC("Line Capture Switch", 0,
> MIXER_ADDR_LINE),
> >  DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
> >  DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
> >  DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
> > -DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD)
> > +DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD),
> > +{
> > +       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> > +       .name  = "External I/O Box",
> > +       .info  = snd_dummy_iobox_info,
> > +       .get   = snd_dummy_iobox_get,
> > +       .put   = snd_dummy_iobox_put,
> > +},
> >  };
> >
> >  static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
> >  {
> >         struct snd_card *card = dummy->card;
> > +       struct snd_kcontrol *kcontrol;
> >         unsigned int idx;
> >         int err;
> >
> >         spin_lock_init(&dummy->mixer_lock);
> >         strcpy(card->mixername, "Dummy Mixer");
> > +       dummy->iobox = 1;
> >
> >         for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
> > -               err = snd_ctl_add(card,
> snd_ctl_new1(&snd_dummy_controls[idx], dummy));
> > +               kcontrol = snd_ctl_new1(&snd_dummy_controls[idx], dummy);
> > +               err = snd_ctl_add(card, kcontrol);
> >                 if (err < 0)
> >                         return err;
> > +               if (!strcmp(kcontrol->id.name, "CD Volume"))
> > +                       dummy->cd_volume_ctl = kcontrol;
> > +               else if (!strcmp(kcontrol->id.name, "CD Capture Switch"))
> > +                       dummy->cd_switch_ctl = kcontrol;
> > +
> >         }
> >         return 0;
> >  }
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] dummy: allow disabling mixer controls
  2012-10-21  7:24 ` Raymond Yau
  2012-10-21  8:22   ` Takashi Iwai
@ 2012-10-21 11:12   ` Clemens Ladisch
  2012-10-21 12:22     ` Raymond Yau
  1 sibling, 1 reply; 7+ messages in thread
From: Clemens Ladisch @ 2012-10-21 11:12 UTC (permalink / raw)
  To: Raymond Yau; +Cc: Takashi Iwai, alsa-devel

Raymond Yau wrote:
> 2012-10-21 上午6:11 於 "Clemens Ladisch" <clemens@ladisch.de> 寫道:
>> Quite a few mixer applications do not handle deactivated controls
>> correctly.
>
> what is the meaning of deactivated control ?

A control where writes do not have an (immediate) effect.

> amixer still can change the value of the deactivated cd volume control if
> write access is no disabled

Yes, when write access is enabled, the control can be written to.
This is necessary for "alsactl (re)store".

Alsamixer displays such controls as gray and read-only because changing
them would not make sense at the moment, but allowing changes would
actually be possible (if confusing).


Regards,
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] dummy: allow disabling mixer controls
  2012-10-21 11:12   ` Clemens Ladisch
@ 2012-10-21 12:22     ` Raymond Yau
  0 siblings, 0 replies; 7+ messages in thread
From: Raymond Yau @ 2012-10-21 12:22 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Takashi Iwai, alsa-devel

2012-10-21 下午7:13 於 "Clemens Ladisch" <clemens@ladisch.de> 寫道:
>
> Raymond Yau wrote:
> > 2012-10-21 上午6:11 於 "Clemens Ladisch" <clemens@ladisch.de> 寫道:
> >> Quite a few mixer applications do not handle deactivated controls
> >> correctly.
> >
> > what is the meaning of deactivated control ?
>
> A control where writes do not have an (immediate) effect.

why do you not implement this kind of control by disable/enable the write
access ?

>
> > amixer still can change the value of the deactivated cd volume control
if
> > write access is no disabled
>
> Yes, when write access is enabled, the control can be written to.
> This is necessary for "alsactl (re)store".

if the control can be write when the driver is loaded, the write access of
the control can be disable/enable instead of using active/inactive

>
> Alsamixer displays such controls as gray and read-only because changing
> them would not make sense at the moment, but allowing changes would
> actually be possible (if confusing).

alsamixer can also display non writable control in different color
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [GIT PULL] dummy: allow disabling mixer controls
  2012-10-21  8:22   ` Takashi Iwai
@ 2012-10-24  3:45     ` Raymond Yau
  0 siblings, 0 replies; 7+ messages in thread
From: Raymond Yau @ 2012-10-24  3:45 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Clemens Ladisch

2012-10-21 下午4:22 於 "Takashi Iwai" <tiwai@suse.de> 寫道:
>
> At Sun, 21 Oct 2012 15:24:56 +0800,
> Raymond Yau wrote:
> >
> > 2012-10-21 上午6:11 於 "Clemens Ladisch" <clemens@ladisch.de> 寫道:
> > >
> > > The following changes since commit
> > a0d271cbfed1dd50278c6b06bead3d00ba0a88f9:
> > >
> > >   Linux 3.6 (2012-09-30 16:47:46 -0700)
> > >
> > > are available in the git repository at:
> > >   git://git.alsa-project.org/alsa-kprivate.git dummy-ctl-inactive
> > >
> > > ----------------------------------------------------------------
> > > Quite a few mixer applications do not handle deactivated controls
> > > correctly.  This patch adds such controls to snd-dummy to make
> > > crash^H^H^H^H^Htesting these apps easier.
> > > ----------------------------------------------------------------
> >
> > what is the meaning of deactivated control ?
> >
> > amixer still can change the value of the deactivated cd volume control
if
> > write access is no disabled
>
> If so, that should be checked rather in the core code...

the other problem is that the simple mixer api does not  provide any
function to know whether the cd playback volume control or the  cd playback
switch control is active or inactive so alsamixer disable both controls

>
>
> Takashi
>
> > > Clemens Ladisch (1):
> > >       ALSA: dummy: allow disabling mixer controls
> > >
> > >  sound/drivers/dummy.c |   73
> > +++++++++++++++++++++++++++++++++++++++++++++++-
> > >  1 files changed, 71 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
> > > index 54bb664..4f522cf 100644
> > > --- a/sound/drivers/dummy.c
> > > +++ b/sound/drivers/dummy.c
> > > @@ -134,6 +134,9 @@ struct snd_dummy {
> > >         spinlock_t mixer_lock;
> > >         int mixer_volume[MIXER_ADDR_LAST+1][2];
> > >         int capture_source[MIXER_ADDR_LAST+1][2];
> > > +       int iobox;
> > > +       struct snd_kcontrol *cd_volume_ctl;
> > > +       struct snd_kcontrol *cd_switch_ctl;
> > >         const struct dummy_timer_ops *timer_ops;
> > >  };
> > >
> > > @@ -817,6 +820,57 @@ static int snd_dummy_capsrc_put(struct
snd_kcontrol
> > *kcontrol, struct snd_ctl_el
> > >         return change;
> > >  }
> > >
> > > +static int snd_dummy_iobox_info(struct snd_kcontrol *kcontrol,
> > > +                               struct snd_ctl_elem_info *info)
> > > +{
> > > +       const char *const names[] = { "None", "CD Player" };
> > > +
> > > +       return snd_ctl_enum_info(info, 1, 2, names);
> > > +}
> > > +
> > > +static int snd_dummy_iobox_get(struct snd_kcontrol *kcontrol,
> > > +                              struct snd_ctl_elem_value *value)
> > > +{
> > > +       struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
> > > +
> > > +       value->value.enumerated.item[0] = dummy->iobox;
> > > +       return 0;
> > > +}
> > > +
> > > +static int snd_dummy_iobox_put(struct snd_kcontrol *kcontrol,
> > > +                              struct snd_ctl_elem_value *value)
> > > +{
> > > +       struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
> > > +       int changed;
> > > +
> > > +       if (value->value.enumerated.item[0] > 1)
> > > +               return -EINVAL;
> > > +
> > > +       changed = value->value.enumerated.item[0] != dummy->iobox;
> > > +       if (changed) {
> > > +               dummy->iobox = value->value.enumerated.item[0];
> > > +
> > > +               if (dummy->iobox) {
> > > +                       dummy->cd_volume_ctl->vd[0].access &=
> > > +                               ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> > > +                       dummy->cd_switch_ctl->vd[0].access &=
> > > +                               ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> > > +               } else {
> > > +                       dummy->cd_volume_ctl->vd[0].access |=
> > > +                               SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> > > +                       dummy->cd_switch_ctl->vd[0].access |=
> > > +                               SNDRV_CTL_ELEM_ACCESS_INACTIVE;
> > > +               }
> > > +
> > > +               snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
> > > +                              &dummy->cd_volume_ctl->id);
> > > +               snd_ctl_notify(dummy->card, SNDRV_CTL_EVENT_MASK_INFO,
> > > +                              &dummy->cd_switch_ctl->id);
> > > +       }
> > > +
> > > +       return changed;
> > > +}
> > > +
> > >  static struct snd_kcontrol_new snd_dummy_controls[] = {
> > >  DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
> > >  DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
> > > @@ -827,22 +881,37 @@ DUMMY_CAPSRC("Line Capture Switch", 0,
> > MIXER_ADDR_LINE),
> > >  DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
> > >  DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
> > >  DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
> > > -DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD)
> > > +DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD),
> > > +{
> > > +       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> > > +       .name  = "External I/O Box",
> > > +       .info  = snd_dummy_iobox_info,
> > > +       .get   = snd_dummy_iobox_get,
> > > +       .put   = snd_dummy_iobox_put,
> > > +},
> > >  };
> > >
> > >  static int __devinit snd_card_dummy_new_mixer(struct snd_dummy
*dummy)
> > >  {
> > >         struct snd_card *card = dummy->card;
> > > +       struct snd_kcontrol *kcontrol;
> > >         unsigned int idx;
> > >         int err;
> > >
> > >         spin_lock_init(&dummy->mixer_lock);
> > >         strcpy(card->mixername, "Dummy Mixer");
> > > +       dummy->iobox = 1;
> > >
> > >         for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
> > > -               err = snd_ctl_add(card,
> > snd_ctl_new1(&snd_dummy_controls[idx], dummy));
> > > +               kcontrol = snd_ctl_new1(&snd_dummy_controls[idx],
dummy);
> > > +               err = snd_ctl_add(card, kcontrol);
> > >                 if (err < 0)
> > >                         return err;
> > > +               if (!strcmp(kcontrol->id.name, "CD Volume"))
> > > +                       dummy->cd_volume_ctl = kcontrol;
> > > +               else if (!strcmp(kcontrol->id.name, "CD Capture
Switch"))
> > > +                       dummy->cd_switch_ctl = kcontrol;
> > > +
> > >         }
> > >         return 0;
> > >  }
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-10-24  3:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-20 22:09 [GIT PULL] dummy: allow disabling mixer controls Clemens Ladisch
2012-10-21  7:24 ` Raymond Yau
2012-10-21  8:22   ` Takashi Iwai
2012-10-24  3:45     ` Raymond Yau
2012-10-21 11:12   ` Clemens Ladisch
2012-10-21 12:22     ` Raymond Yau
2012-10-21  8:21 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.