ALSA: emu10k1: remove runtime 64-bit divisions
PATCH 1/1 ALSA: emu10k1: remove runtime 64-bit divisions
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.
---
--- sound/pci/emu10k1/emufx.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
sound/pci/emu10k1/emufx.c +12 -6
@@ -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,
Signature · 1 line
2.40.0.152.g15d061e6df
Le 17/05/2023 à 18:48, Oswald Buddenhagen a écrit :
Quoted 8 lines
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 <[email protected]>
Quoted 76 lines
---
Cc Christophe Leroy <[email protected]>Cc Naresh Kamboju <[email protected]>--- sound/pci/emu10k1/emufx.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)sound/pci/emu10k1/emufx.c +12
-6@@ -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,
Takashi Iwai
AppliedQuoted 10 lines · Oswald Buddenhagen
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 <[email protected]>
Quoted 5 lines
---
Cc Christophe Leroy <[email protected]>Cc Naresh Kamboju <[email protected]>---
Thanks, applied now.
Takashi