All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 2/6] ALSA: usb-audio: Avoid superfluous usb_set_interface() calls
Date: Wed,  2 May 2018 16:11:12 +0200	[thread overview]
Message-ID: <20180502141116.31966-3-tiwai@suse.de> (raw)
In-Reply-To: <20180502141116.31966-1-tiwai@suse.de>

This is a preliminary change for the upcoming quirk implementation.

Currently USB-audio driver tries to call usb_set_interface() whenever
the format change with interface/altset modification happens.  In this
patch, the check is replaced with the comparison of cur_altsetting and
the targeted altsetting pointer, so that the driver may skip the
unnecessary function calls.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/pcm.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index ad39b3cca247..ae7d8a0a0a0a 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -499,7 +499,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
 	iface = usb_ifnum_to_if(dev, fmt->iface);
 	if (WARN_ON(!iface))
 		return -EINVAL;
-	alts = &iface->altsetting[fmt->altset_idx];
+	alts = usb_altnum_to_altsetting(iface, fmt->altsetting);
 	altsd = get_iface_desc(alts);
 	if (WARN_ON(altsd->bAlternateSetting != fmt->altsetting))
 		return -EINVAL;
@@ -521,9 +521,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
 	}
 
 	/* set interface */
-	if (subs->interface != fmt->iface ||
-	    subs->altset_idx != fmt->altset_idx) {
-
+	if (iface->cur_altsetting != alts) {
 		err = snd_usb_select_mode_quirk(subs, fmt);
 		if (err < 0)
 			return -EIO;
@@ -537,12 +535,11 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
 		}
 		dev_dbg(&dev->dev, "setting usb interface %d:%d\n",
 			fmt->iface, fmt->altsetting);
-		subs->interface = fmt->iface;
-		subs->altset_idx = fmt->altset_idx;
-
 		snd_usb_set_interface_quirk(dev);
 	}
 
+	subs->interface = fmt->iface;
+	subs->altset_idx = fmt->altset_idx;
 	subs->data_endpoint = snd_usb_add_endpoint(subs->stream->chip,
 						   alts, fmt->endpoint, subs->direction,
 						   SND_USB_ENDPOINT_TYPE_DATA);
-- 
2.16.3

  parent reply	other threads:[~2018-05-02 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 14:11 [PATCH 0/6] usb-audio: quirks for Dell WD15 dock and some extensions Takashi Iwai
2018-05-02 14:11 ` [PATCH 1/6] ALSA: usb-audio: Initialize Dell Dock playback volumes Takashi Iwai
2018-05-02 14:11 ` Takashi Iwai [this message]
2018-05-02 14:11 ` [PATCH 3/6] ALSA: usb-audio: Add keep_iface flag Takashi Iwai
2018-05-02 14:11 ` [PATCH 4/6] ALSA: usb-audio: Add "Keep Interface" control Takashi Iwai
2018-05-02 14:11 ` [PATCH 5/6] ALSA: usb-audio: Allow to override the longname string Takashi Iwai
2018-05-02 14:11 ` [PATCH 6/6] ALSA: usb-audio: Give proper vendor/product name for Dell WD15 Dock Takashi Iwai

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=20180502141116.31966-3-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /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 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.