From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai 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 Message-ID: References: <1364745152-1762-1-git-send-email-eldad@fogrefinery.com> <1364745152-1762-8-git-send-email-eldad@fogrefinery.com> 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 653212650D7 for ; Tue, 2 Apr 2013 10:46:47 +0200 (CEST) In-Reply-To: <1364745152-1762-8-git-send-email-eldad@fogrefinery.com> 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: Eldad Zack Cc: alsa-devel@alsa-project.org, Daniel Mack , Clemens Ladisch List-Id: alsa-devel@alsa-project.org 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 > --- > 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