[alsa-devel] [PATCH 4/6] bebob: Use different labels for digital input/output interfaces

Takashi Iwai tiwai at suse.de
Mon Jul 21 11:58:12 CEST 2014


At Mon, 21 Jul 2014 11:10:03 +0900,
Takashi Sakamoto wrote:
> 
> This commit use different labels for control elements of digital input/output
> interfaces to correct my misunderstanding about M-Audio Firewire 1814 and
> ProjectMix I/O.
> 
> According to user manuals for these two models, they have two modes for
> digital input; one is S/PDIF in both of optical and coaxial interfaces,
> another is ADAT in optical interface only.
> 
> But in current implementation, a control element for digital input uses
> reduced labels which a control element for digital output uses because of my
> misunderstanding that optical interface is not available for digital input
> with S/PDIF mode.
> 
> Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
> ---
>  sound/firewire/bebob/bebob_maudio.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c
> index 008ff2c..f2277ce 100644
> --- a/sound/firewire/bebob/bebob_maudio.c
> +++ b/sound/firewire/bebob/bebob_maudio.c
> @@ -440,8 +440,8 @@ static struct snd_kcontrol_new special_sync_ctl = {
>  	.get	= special_sync_ctl_get,
>  };
>  
> -/* Digital interface control for special firmware */
> -static char *const special_dig_iface_labels[] = {
> +/* Digital input interface control for special firmware */
> +static char *const special_dig_in_iface_labels[] = {
>  	"S/PDIF Optical", "S/PDIF Coaxial", "ADAT Optical"
>  };
>  static int special_dig_in_iface_ctl_info(struct snd_kcontrol *kctl,
> @@ -449,13 +449,13 @@ static int special_dig_in_iface_ctl_info(struct snd_kcontrol *kctl,
>  {
>  	einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
>  	einf->count = 1;
> -	einf->value.enumerated.items = ARRAY_SIZE(special_dig_iface_labels);
> +	einf->value.enumerated.items = ARRAY_SIZE(special_dig_in_iface_labels);
>  
>  	if (einf->value.enumerated.item >= einf->value.enumerated.items)
>  		einf->value.enumerated.item = einf->value.enumerated.items - 1;
>  
>  	strcpy(einf->value.enumerated.name,
> -	       special_dig_iface_labels[einf->value.enumerated.item]);
> +	       special_dig_in_iface_labels[einf->value.enumerated.item]);
>  
>  	return 0;
>  }
> @@ -498,6 +498,8 @@ static int special_dig_in_iface_ctl_set(struct snd_kcontrol *kctl,
>  	int err;
>  
>  	id = uval->value.enumerated.item[0];
> +	if (id >= ARRAY_SIZE(special_dig_in_iface_labels))
> +		return 0;

This should return an error.

>  
>  	/* decode user value */
>  	dig_in_fmt = (id >> 1) & 0x01;
> @@ -537,18 +539,22 @@ static struct snd_kcontrol_new special_dig_in_iface_ctl = {
>  	.put	= special_dig_in_iface_ctl_set
>  };
>  
> +/* Digital output interface control for special firmware */
> +static char *const special_dig_out_iface_labels[] = {
> +	"S/PDIF Optical and Coaxial", "ADAT Optical"
> +};
>  static int special_dig_out_iface_ctl_info(struct snd_kcontrol *kctl,
>  					  struct snd_ctl_elem_info *einf)
>  {
>  	einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
>  	einf->count = 1;
> -	einf->value.enumerated.items = ARRAY_SIZE(special_dig_iface_labels) - 1;
> +	einf->value.enumerated.items = ARRAY_SIZE(special_dig_out_iface_labels);
>  
>  	if (einf->value.enumerated.item >= einf->value.enumerated.items)
>  		einf->value.enumerated.item = einf->value.enumerated.items - 1;
>  
>  	strcpy(einf->value.enumerated.name,
> -	       special_dig_iface_labels[einf->value.enumerated.item + 1]);
> +	       special_dig_out_iface_labels[einf->value.enumerated.item]);
>  
>  	return 0;
>  }
> @@ -571,6 +577,8 @@ static int special_dig_out_iface_ctl_set(struct snd_kcontrol *kctl,
>  	int err;
>  
>  	id = uval->value.enumerated.item[0];
> +	if (id >= ARRAY_SIZE(special_dig_out_iface_labels))
> +		return 0;

Ditto.


thanks,

Takashi


>  
>  	mutex_lock(&bebob->mutex);
>  
> -- 
> 1.9.1
> 


More information about the Alsa-devel mailing list