From: Takashi Iwai <tiwai@suse.de>
To: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Cc: Jorge <jorge.sanjuan@codethink.co.uk>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [alsa-devel] [PATCH 4/4] ALSA: usb: add UAC3 BADD profiles support
Date: Thu, 19 Apr 2018 12:19:15 +0200 [thread overview]
Message-ID: <s5ha7tzzefw.wl-tiwai@suse.de> (raw)
In-Reply-To: <1523658266-2259-5-git-send-email-ruslan.bilovol@gmail.com>
On Sat, 14 Apr 2018 00:24:26 +0200,
Ruslan Bilovol wrote:
>
> +static void build_feature_ctl_badd(struct usb_mixer_interface *mixer,
> + unsigned int ctl_mask, int control, int unitid,
> + const struct usbmix_name_map *badd_map)
> +{
....
> + kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval);
> +
> + if (!kctl) {
> + usb_audio_err(mixer->chip, "cannot malloc kcontrol\n");
No need for error message after malloc failure. The kernel is already
chatty about it.
> +static int snd_usb_mixer_controls_badd(struct usb_mixer_interface *mixer,
> + int ctrlif)
> +{
> + struct usb_device *dev = mixer->chip->dev;
> + struct usb_interface_assoc_descriptor *assoc;
> + int badd_profile = mixer->chip->badd_profile;
> + const struct usbmix_ctl_map *map;
> + int p_chmask = 0, c_chmask = 0, st_chmask = 0;
> + int i;
> +
> + assoc = usb_ifnum_to_if(dev, ctrlif)->intf_assoc;
> +
> + /* Detect BADD capture/playback channels from AS EP descriptors */
> + for (i = 0; i < assoc->bInterfaceCount; i++) {
> + int intf = assoc->bFirstInterface + i;
> +
> + if (intf != ctrlif) {
In this case, it's better to skip like
if (intf == ctrlif)
continue;
so that we can save an indentation for the whole long block.
> + switch (badd_profile) {
> + default:
> + return -EINVAL;
> + case UAC3_FUNCTION_SUBCLASS_GENERIC_IO:
> + /*
> + * BAIF, BAOF or combination of both
> + * IN: Mono or Stereo cfg, Mono alt possible
> + * OUT: Mono or Stereo cfg, Mono alt possible
> + */
> + /* c_chmask := DYNAMIC */
> + /* p_chmask := DYNAMIC */
> + if (!c_chmask && !p_chmask) {
> + usb_audio_err(mixer->chip,
> + "BADD GENERIC_IO profile: no channels?\n");
> + return -EINVAL;
> + }
> + break;
Maybe we can simplify the whole switch/case with a table lookup.
For example,
for (f = uac3_func_tables; f->name; f++) {
if (badd_profile == f->subclass)
break;
}
if (!f->name)
return -EINVAL;
if (!uac3_func_has_valid_channels(mixer, f, c_chmask, p_chmask))
return -EINVAL;
st_chmask = f->st_chmask;
and in uac3_func_has_valid_channels(),
static bool uac3_func_has_valid_channels()
{
if ((f->c_chmask < 0 && !c_chmask) ||
(f->c_chmask >= 0 && f->c_chmask != c_chmask)) {
usb_audio_warn(mixer->chip, "BAAD %s c_chmask mismatch",
f->name);
return false;
}
if ((f->p_chmask < 0 && !p_chmask) ||
(f->p_chmask >= 0 && f->p_chmask != p_chmask)) {
usb_audio_warn(mixer->chip, "BAAD %s p_chmask mismatch",
f->name);
return false;
}
return true;
}
thanks,
Takashi
next prev parent reply other threads:[~2018-04-19 10:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-13 22:24 [PATCH 0/4] USB Audio Device Class 3.0 BADD profiles support Ruslan Bilovol
2018-04-13 22:24 ` [PATCH 1/4] ALSA: usb: stream: refactor audio interface parsing Ruslan Bilovol
2018-04-19 9:55 ` [alsa-devel] " Takashi Iwai
2018-04-23 19:48 ` Ruslan Bilovol
2018-04-13 22:24 ` [PATCH 2/4] include: usb: audio-v3: add BADD-specific values Ruslan Bilovol
2018-04-13 22:24 ` [PATCH 3/4] ALSA: usb: Only get AudioControl header for UAC1 class Ruslan Bilovol
2018-04-13 22:24 ` [PATCH 4/4] ALSA: usb: add UAC3 BADD profiles support Ruslan Bilovol
2018-04-14 17:55 ` Jorge Sanjuan
2018-04-18 0:41 ` Ruslan Bilovol
2018-04-16 9:05 ` kbuild test robot, Dan Carpenter
2018-04-19 9:42 ` [alsa-devel] " Andrew Chant
2018-04-23 19:47 ` Ruslan Bilovol
2018-04-19 10:19 ` Takashi Iwai [this message]
2018-04-24 7:51 ` Ruslan Bilovol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5ha7tzzefw.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=gregkh@linuxfoundation.org \
--cc=jorge.sanjuan@codethink.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=ruslan.bilovol@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox