[alsa-devel] [PATCH 07/10] ALSA: usb-audio: UAC2: try to find and switch to valid clock
Takashi Iwai
tiwai at suse.de
Tue Apr 2 10:46:47 CEST 2013
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 at 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
More information about the Alsa-devel
mailing list