Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Eldad Zack <eldad@fogrefinery.com>
Cc: alsa-devel@alsa-project.org, Daniel Mack <zonque@gmail.com>,
	Clemens Ladisch <clemens@ladisch.de>
Subject: Re: [PATCH 07/10] ALSA: usb-audio: UAC2: try to find and switch to valid clock
Date: Tue, 02 Apr 2013 10:46:47 +0200	[thread overview]
Message-ID: <s5hvc858glk.wl%tiwai@suse.de> (raw)
In-Reply-To: <1364745152-1762-8-git-send-email-eldad@fogrefinery.com>

At Sun, 31 Mar 2013 17:52:29 +0200,
Eldad Zack wrote:
> 
> If a selector is available on a device, it may be pointing to a
> clock source which is currently invalid.
> If there is a valid clock source which can be selected, switch
> to it.
> 
> Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
> ---
>  sound/usb/clock.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 63 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/usb/clock.c b/sound/usb/clock.c
> index 08fa345..6b79e25 100644
> --- a/sound/usb/clock.c
> +++ b/sound/usb/clock.c
> @@ -99,6 +99,40 @@ static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_i
>  	return buf;
>  }
>  
> +static int uac_clock_selector_set_val(struct snd_usb_audio *chip, int selector_id,
> +					unsigned char pin)
> +{
> +	unsigned char buf;
> +	int ret;
> +
> +	ret = snd_usb_ctl_msg(chip->dev, usb_sndctrlpipe(chip->dev, 0),
> +			      UAC2_CS_CUR,
> +			      USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
> +			      UAC2_CX_CLOCK_SELECTOR << 8,
> +			      snd_usb_ctrl_intf(chip) | (selector_id << 8),
> +			      &pin, sizeof(pin));
> +
> +	if (ret < 0)
> +		return ret;
> +
> +	if (ret != sizeof(pin)) {
> +		snd_printk(KERN_ERR
> +			"usb-audio:%d: setting selector (id %d) unexpected length %d\n",
> +			chip->dev->devnum, selector_id, ret);
> +		return -EINVAL;
> +	}
> +
> +	buf = uac_clock_selector_get_val(chip, selector_id);
> +	if (buf != pin) {


uac_clock_selector_get_val() returns an int with a negative value,
so it's safer to compare it as an int.



Takashi

  reply	other threads:[~2013-04-02  8:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-31 15:52 [PATCH 00/10] UAC2: Automatic clock switching Eldad Zack
2013-03-31 15:52 ` [PATCH 01/10] ALSA: usb-audio: convert list_for_each to entry variant Eldad Zack
2013-03-31 15:52 ` [PATCH 02/10] ALSA: usb-audio: neaten MODULE_DEVICE_TABLE placement Eldad Zack
2013-03-31 15:52 ` [PATCH 03/10] ALSA: usb-audio: neaten EXPORT_SYMBOLS placement Eldad Zack
2013-03-31 15:52 ` [PATCH 04/10] ALSA: usb-audio: spelling correction Eldad Zack
2013-03-31 15:52 ` [PATCH 05/10] ALSA: usb-audio: use endianness macros Eldad Zack
2013-03-31 16:06   ` Clemens Ladisch
2013-03-31 17:15     ` Eldad Zack
2013-03-31 17:30       ` Clemens Ladisch
2013-04-05 18:36         ` Eldad Zack
2013-03-31 15:52 ` [PATCH 06/10] ALSA: usb-audio: UAC2: do clock validity check earlier Eldad Zack
2013-04-01  8:16   ` Torstein Hegge
2013-04-01 22:36     ` Eldad Zack
2013-04-02  8:38   ` Takashi Iwai
2013-03-31 15:52 ` [PATCH 07/10] ALSA: usb-audio: UAC2: try to find and switch to valid clock Eldad Zack
2013-04-02  8:46   ` Takashi Iwai [this message]
2013-04-02 20:20     ` Eldad Zack
2013-03-31 15:52 ` [PATCH 08/10] ALSA: usb-audio: UAC2: auto clock selection module param Eldad Zack
2013-04-02  8:51   ` Takashi Iwai
2013-04-02 20:27     ` Eldad Zack
2013-03-31 15:52 ` [PATCH 09/10] ALSA: usb-audio: show err in set_sample_rate_v2 debug Eldad Zack
2013-03-31 15:52 ` [PATCH 10/10] ALSA: usb-audio: UAC2: support read-only freq control Eldad Zack
2013-04-01  8:17   ` Torstein Hegge
2013-04-01 22:45     ` Eldad Zack

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=s5hvc858glk.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=eldad@fogrefinery.com \
    --cc=zonque@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