Re: [PATCH] ALSA: emu10k1: remove runtime 64-bit divisions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Le 17/05/2023 à 18:48, Oswald Buddenhagen a écrit :
> 32-bit platforms don't like these. As we're actually dealing with
> constants, factor out the calculations and pass them in as additional
> arguments. To keep the call sites clean, wrap the actual functions in
> macros which generate the arguments.
> 
> Fixes: bb5ceb43b7bf ("ALSA: emu10k1: fix non-zero mixer control defaults in highres mode")
> Fixes: 1298bc978afb ("ALSA: emu10k1: enable bit-exact playback, part 1: DSP attenuation")
> Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@xxxxxx>

Reported-by: Linux Kernel Functional Testing <lkft@xxxxxxxxxx>
Reported-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>

> 
> ---
> 
> Cc: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
> Cc: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>
> ---
>   sound/pci/emu10k1/emufx.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
> index f64b2b4eb348..e9855d37fa5c 100644
> --- a/sound/pci/emu10k1/emufx.c
> +++ b/sound/pci/emu10k1/emufx.c
> @@ -1144,50 +1144,56 @@ static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu,
>   #define SND_EMU10K1_PLAYBACK_CHANNELS	8
>   #define SND_EMU10K1_CAPTURE_CHANNELS	4
>   
> +#define HR_VAL(v) ((v) * 0x80000000LL / 100 - 1)
> +
>   static void
> -snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
> -			       const char *name, int gpr, int defval)
> +snd_emu10k1_init_mono_control2(struct snd_emu10k1_fx8010_control_gpr *ctl,
> +			       const char *name, int gpr, int defval, int defval_hr)
>   {
>   	ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
>   	strcpy(ctl->id.name, name);
>   	ctl->vcount = ctl->count = 1;
>   	if (high_res_gpr_volume) {
>   		ctl->min = -1;
>   		ctl->max = 0x7fffffff;
>   		ctl->tlv = snd_emu10k1_db_linear;
>   		ctl->translation = EMU10K1_GPR_TRANSLATION_NEGATE;
> -		defval = defval * 0x80000000LL / 100 - 1;
> +		defval = defval_hr;
>   	} else {
>   		ctl->min = 0;
>   		ctl->max = 100;
>   		ctl->tlv = snd_emu10k1_db_scale1;
>   		ctl->translation = EMU10K1_GPR_TRANSLATION_NEG_TABLE100;
>   	}
>   	ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
>   }
> +#define snd_emu10k1_init_mono_control(ctl, name, gpr, defval) \
> +	snd_emu10k1_init_mono_control2(ctl, name, gpr, defval, HR_VAL(defval))
>   
>   static void
> -snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
> -				 const char *name, int gpr, int defval)
> +snd_emu10k1_init_stereo_control2(struct snd_emu10k1_fx8010_control_gpr *ctl,
> +				 const char *name, int gpr, int defval, int defval_hr)
>   {
>   	ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
>   	strcpy(ctl->id.name, name);
>   	ctl->vcount = ctl->count = 2;
>   	if (high_res_gpr_volume) {
>   		ctl->min = -1;
>   		ctl->max = 0x7fffffff;
>   		ctl->tlv = snd_emu10k1_db_linear;
>   		ctl->translation = EMU10K1_GPR_TRANSLATION_NEGATE;
> -		defval = defval * 0x80000000LL / 100 - 1;
> +		defval = defval_hr;
>   	} else {
>   		ctl->min = 0;
>   		ctl->max = 100;
>   		ctl->tlv = snd_emu10k1_db_scale1;
>   		ctl->translation = EMU10K1_GPR_TRANSLATION_NEG_TABLE100;
>   	}
>   	ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
>   	ctl->gpr[1] = gpr + 1; ctl->value[1] = defval;
>   }
> +#define snd_emu10k1_init_stereo_control(ctl, name, gpr, defval) \
> +	snd_emu10k1_init_stereo_control2(ctl, name, gpr, defval, HR_VAL(defval))
>   
>   static void
>   snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl,




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux