[alsa-devel] [PATCH 08/10] ALSA: usb-audio: UAC2: auto clock selection module param

Takashi Iwai tiwai at suse.de
Tue Apr 2 10:51:03 CEST 2013


At Sun, 31 Mar 2013 17:52:30 +0200,
Eldad Zack wrote:
> 
> Add a module param to disable auto clock selection.
> This is provided for users that expect the audio stream to
> fail when the clock source is invalid (e.g., the word clock
> was unintentionally disconnected).
> 
> Signed-off-by: Eldad Zack <eldad at fogrefinery.com>
> ---
>  sound/usb/card.c     | 4 ++++
>  sound/usb/clock.c    | 2 +-
>  sound/usb/usbaudio.h | 1 +
>  3 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/usb/card.c b/sound/usb/card.c
> index 314e8a2..dfbf317 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
> @@ -82,6 +82,7 @@ static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
>  static int nrpacks = 8;		/* max. number of packets per urb */
>  static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
>  static bool ignore_ctl_error;
> +static bool noautoclk;
>  
>  module_param_array(index, int, NULL, 0444);
>  MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
> @@ -100,6 +101,8 @@ MODULE_PARM_DESC(device_setup, "Specific device setup (if needed).");
>  module_param(ignore_ctl_error, bool, 0444);
>  MODULE_PARM_DESC(ignore_ctl_error,
>  		 "Ignore errors from USB controller for mixer interfaces.");
> +module_param(noautoclk, bool, 0444);
> +MODULE_PARM_DESC(noautoclk, "Disables auto-clock selection for UAC2 devices.");

Don't use "no" for a boolean option.  You can pass "yes" or "no" as an
option value, so it can confuse easily by passing noautoclk=yes.  See?

It's fine to use internally an inverted boolean, of course, though.
But the exposed option should be less confusing.

In addition, you don't have to use abbreviation.
The option autoclock or auto_clock should be better than autoclk.


Takashi

>  
>  /*
>   * we keep the snd_usb_audio_t instances by ourselves for merging
> @@ -354,6 +357,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
>  	chip->card = card;
>  	chip->setup = device_setup[idx];
>  	chip->nrpacks = nrpacks;
> +	chip->noautoclk = noautoclk;
>  	chip->probing = 1;
>  
>  	chip->usb_id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
> diff --git a/sound/usb/clock.c b/sound/usb/clock.c
> index 6b79e25..e3075ca 100644
> --- a/sound/usb/clock.c
> +++ b/sound/usb/clock.c
> @@ -216,7 +216,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
>  		cur = ret;
>  		ret = __uac_clock_find_source(chip, selector->baCSourceID[ret - 1],
>  					       visited, validate);
> -		if (!validate || ret > 0)
> +		if (!validate || ret > 0 || chip->noautoclk)
>  			return ret;
>  
>  		/* The current clock source is invalid, try others. */
> diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
> index 1ac3fd9..4852eb0 100644
> --- a/sound/usb/usbaudio.h
> +++ b/sound/usb/usbaudio.h
> @@ -56,6 +56,7 @@ struct snd_usb_audio {
>  
>  	int setup;			/* from the 'device_setup' module param */
>  	int nrpacks;			/* from the 'nrpacks' module param */
> +	bool noautoclk;			/* from the 'noautoclk' module param */
>  
>  	struct usb_host_interface *ctrl_intf;	/* the audio control interface */
>  };
> -- 
> 1.8.1.5
> 


More information about the Alsa-devel mailing list