From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH 4/6] bebob: Use different labels for digital input/output interfaces Date: Mon, 21 Jul 2014 11:58:12 +0200 Message-ID: References: <1405831835-26499-1-git-send-email-weiyj_lk@163.com> <1405908605-8105-1-git-send-email-o-takashi@sakamocchi.jp> <1405908605-8105-5-git-send-email-o-takashi@sakamocchi.jp> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 9B9B5265141 for ; Mon, 21 Jul 2014 11:58:13 +0200 (CEST) In-Reply-To: <1405908605-8105-5-git-send-email-o-takashi@sakamocchi.jp> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Takashi Sakamoto Cc: alsa-devel@alsa-project.org, clemens@ladisch.de, darrena092@gmail.com, ffado-devel@lists.sf.net List-Id: alsa-devel@alsa-project.org 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 > --- > 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 >