[alsa-devel] [PATCH v2 04/13] ALSA: dice: cache stream formats at current mode of sampling transmission frequency

Takashi Iwai tiwai at suse.de
Mon Apr 30 17:10:13 CEST 2018


On Sun, 29 Apr 2018 08:50:23 +0200,
Takashi Sakamoto wrote:
> 
> In former commits, proxy structure get members for cache of stream
> formats. This commit fills the cache with stream formats at current mode
> of sampling transmission frequency.
> 
> Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
> ---
>  sound/firewire/dice/dice-stream.c | 76 +++++++++++++++++++++++++++++++++++++++
>  sound/firewire/dice/dice.c        |  4 +++
>  sound/firewire/dice/dice.h        |  3 ++
>  3 files changed, 83 insertions(+)
> 
> diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c
> index 928a255bfc35..2a9f0cd994a5 100644
> --- a/sound/firewire/dice/dice-stream.c
> +++ b/sound/firewire/dice/dice-stream.c
> @@ -30,6 +30,24 @@ const unsigned int snd_dice_rates[SND_DICE_RATES_COUNT] = {
>  	[6] = 192000,
>  };
>  
> +int snd_dice_stream_get_rate_mode(struct snd_dice *dice, unsigned int rate,
> +				  unsigned int *mode)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(snd_dice_rates); i++) {
> +		if (!(dice->clock_caps & BIT(i)))
> +			continue;
> +		if (snd_dice_rates[i] != rate)
> +			continue;
> +
> +		*mode = (i - 1) / 2;

What if i=0?  It'll be a negative value?


thanks,

Takashi


More information about the Alsa-devel mailing list