ALSA: emu10k1: various improvements to the DSP-based mixer code
Subsystems (2)
v2 cover ALSA: emu10k1: various improvements to the DSP-based mixer code
Oswald Buddenhagen (7):
ALSA: emu10k1: polish audigy GPR allocation
ALSA: emu10k1: fix non-zero mixer control defaults in highres mode
ALSA: emu10k1: validate min/max values of translated controls
ALSA: emu10k1: omit non-applicable mixer controls for E-MU cards
ALSA: emu10k1: skip mic capture PCM for cards without AC97 codec
ALSA: emu10k1: enable bit-exact playback, part 1: DSP attenuation
ALSA: emu10k1: enable bit-exact playback, part 2: voice attenuation
Documentation/sound/cards/audigy-mixer.rst | 2 +- Documentation/sound/cards/sb-live-mixer.rst | 2 +- include/sound/emu10k1.h | 9 +- include/uapi/sound/emu10k1.h | 8 +- sound/pci/emu10k1/emu10k1.c | 8 +- sound/pci/emu10k1/emufx.c | 491 +++++++++++--------- sound/pci/emu10k1/emumixer.c | 15 +- sound/pci/emu10k1/emupcm.c | 4 +- 8 files changed, 291 insertions(+), 248 deletions(-)
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 1/7 ALSA: emu10k1: polish audigy GPR allocation
- Pull ahead all fixed allocations, so we don't rely on the semi- dynamic ones not crossing the arbitrarily determined limit
- Use an enum for the fixed allocations
- Stop arbitrarily wasting registers on unexplained "reservations"
- Don't reserve two regs for the master volume control - it's mono
---
v2: rebased out patch concerning assertions
--- sound/pci/emu10k1/emufx.c | 69 +++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 32 deletions(-)
sound/pci/emu10k1/emufx.c +37 -32
@@ -1202,18 +1202,31 @@ static void snd_emu10k1_audigy_dsp_convert_32_to_2x16(A_OP (icode, ptr, iMAC3, reg_out,A_GPR (tmp),A_GPR (tmp),A_C_80000000 ); } +#define ENUM_GPR (name, size) name, name ## _dummy = name + (size) - 1 +/* * initial DSP configuration for Audigy */ static int _snd_emu10k1_audigy_init_efx (struct snd_emu10k1 *emu) { -int err, z, gpr, nctl; -int bit_shifter16; -const int playback =10 ; -const int capture = playback +SND_EMU10K1_PLAYBACK_CHANNELS ;/* we reserve 10 voices */ -const int stereo_mix = capture +2 ; -const int tmp =0x88 ; +int err, z, nctl; +enum { + ENUM_GPR(playback, SND_EMU10K1_PLAYBACK_CHANNELS), + ENUM_GPR(stereo_mix, 2), + ENUM_GPR(capture, 2), + ENUM_GPR(bit_shifter16, 1), +// The fixed allocation of these breaks the pattern, but why not. +// Splitting these into left/right is questionable, as it will break +// down for center/lfe. But it works for stereo/quadro, so whatever. + ENUM_GPR(bass_gpr, 2 * 5), // two sides, five coefficients + ENUM_GPR(treble_gpr, 2 * 5), + ENUM_GPR(bass_tmp, SND_EMU10K1_PLAYBACK_CHANNELS * 4), // four delay stages + ENUM_GPR(treble_tmp, SND_EMU10K1_PLAYBACK_CHANNELS * 4), + ENUM_GPR(tmp, 3), + num_static_gprs + }; +int gpr = num_static_gprs;u32 ptr, ptr_skip;struct snd_emu10k1_fx8010_code *icode =NULL ;struct snd_emu10k1_fx8010_control_gpr *controls =NULL , *ctl;
@@ -1248,9 +1261,7 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)strcpy (icode->name,"Audigy DSP code for ALSA" ); ptr =0 ; nctl =0 ; - gpr = stereo_mix +10 ; - bit_shifter16 = gpr; - gpr_map[gpr++] =0x00008000 ; + gpr_map[bit_shifter16] =0x00008000 ;#if 1 /* PCM front Playback Volume (independent from stereo mix)
@@ -1492,15 +1503,11 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) ctl->max =40 ; ctl->value[0 ] = ctl->value[1 ] =20 ; ctl->translation =EMU10K1_GPR_TRANSLATION_TREBLE ; - -#define BASS_GPR 0x8c -#define TREBLE_GPR 0x96 -for (z =0 ; z <5 ; z++) {int j;for (j =0 ; j <2 ; j++) { - controls[nctl +0 ].gpr[z *2 + j] =BASS_GPR + z *2 + j; - controls[nctl +1 ].gpr[z *2 + j] =TREBLE_GPR + z *2 + j; + controls[nctl +0 ].gpr[z *2 + j] = bass_gpr + z *2 + j; + controls[nctl +1 ].gpr[z *2 + j] = treble_gpr + z *2 + j; } } nctl +=2 ;
@@ -1513,40 +1520,37 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))for (z =0 ; z <4 ; z++) {/* front/rear/center-lfe/side */ int j, k, l, d;for (j =0 ; j <2 ; j++) {/* left/right */ - k =0xb0 + (z *8 ) + (j *4 ); - l =0xe0 + (z *8 ) + (j *4 ); + k = bass_tmp + (z *8 ) + (j *4 ); + l = treble_tmp + (z *8 ) + (j *4 ); d = playback + z *2 + j; -A_OP (icode, &ptr, iMAC0,A_C_00000000 ,A_C_00000000 ,A_GPR (d),A_GPR (BASS_GPR +0 + j)); -A_OP (icode, &ptr, iMACMV,A_GPR (k+1 ),A_GPR (k),A_GPR (k+1 ),A_GPR (BASS_GPR +4 + j)); -A_OP (icode, &ptr, iMACMV,A_GPR (k),A_GPR (d),A_GPR (k),A_GPR (BASS_GPR +2 + j)); -A_OP (icode, &ptr, iMACMV,A_GPR (k+3 ),A_GPR (k+2 ),A_GPR (k+3 ),A_GPR (BASS_GPR +8 + j)); -A_OP (icode, &ptr, iMAC0,A_GPR (k+2 ),A_GPR_ACCU ,A_GPR (k+2 ),A_GPR (BASS_GPR +6 + j)); +A_OP (icode, &ptr, iMAC0,A_C_00000000 ,A_C_00000000 ,A_GPR (d),A_GPR (bass_gpr +0 + j)); +A_OP (icode, &ptr, iMACMV,A_GPR (k+1 ),A_GPR (k),A_GPR (k+1 ),A_GPR (bass_gpr +4 + j)); +A_OP (icode, &ptr, iMACMV,A_GPR (k),A_GPR (d),A_GPR (k),A_GPR (bass_gpr +2 + j)); +A_OP (icode, &ptr, iMACMV,A_GPR (k+3 ),A_GPR (k+2 ),A_GPR (k+3 ),A_GPR (bass_gpr +8 + j)); +A_OP (icode, &ptr, iMAC0,A_GPR (k+2 ),A_GPR_ACCU ,A_GPR (k+2 ),A_GPR (bass_gpr +6 + j));A_OP (icode, &ptr, iACC3,A_GPR (k+2 ),A_GPR (k+2 ),A_GPR (k+2 ),A_C_00000000 ); -A_OP (icode, &ptr, iMAC0,A_C_00000000 ,A_C_00000000 ,A_GPR (k+2 ),A_GPR (TREBLE_GPR +0 + j)); -A_OP (icode, &ptr, iMACMV,A_GPR (l+1 ),A_GPR (l),A_GPR (l+1 ),A_GPR (TREBLE_GPR +4 + j)); -A_OP (icode, &ptr, iMACMV,A_GPR (l),A_GPR (k+2 ),A_GPR (l),A_GPR (TREBLE_GPR +2 + j)); -A_OP (icode, &ptr, iMACMV,A_GPR (l+3 ),A_GPR (l+2 ),A_GPR (l+3 ),A_GPR (TREBLE_GPR +8 + j)); -A_OP (icode, &ptr, iMAC0,A_GPR (l+2 ),A_GPR_ACCU ,A_GPR (l+2 ),A_GPR (TREBLE_GPR +6 + j)); +A_OP (icode, &ptr, iMAC0,A_C_00000000 ,A_C_00000000 ,A_GPR (k+2 ),A_GPR (treble_gpr +0 + j)); +A_OP (icode, &ptr, iMACMV,A_GPR (l+1 ),A_GPR (l),A_GPR (l+1 ),A_GPR (treble_gpr +4 + j)); +A_OP (icode, &ptr, iMACMV,A_GPR (l),A_GPR (k+2 ),A_GPR (l),A_GPR (treble_gpr +2 + j)); +A_OP (icode, &ptr, iMACMV,A_GPR (l+3 ),A_GPR (l+2 ),A_GPR (l+3 ),A_GPR (treble_gpr +8 + j)); +A_OP (icode, &ptr, iMAC0,A_GPR (l+2 ),A_GPR_ACCU ,A_GPR (l+2 ),A_GPR (treble_gpr +6 + j));A_OP (icode, &ptr, iMACINT0,A_GPR (l+2 ),A_C_00000000 ,A_GPR (l+2 ),A_C_00000010 );A_OP (icode, &ptr, iACC3,A_GPR (d),A_GPR (l+2 ),A_C_00000000 ,A_C_00000000 );if (z ==2 )/* center */ break ; } } gpr_map[gpr++] = ptr - ptr_skip; -#undef BASS_GPR -#undef TREBLE_GPR -/* Master volume (will be renamed later) */ for (z =0 ; z <8 ; z++)A_OP (icode, &ptr, iMAC0,A_GPR (playback+z),A_C_00000000 ,A_GPR (gpr),A_GPR (playback+z));snd_emu10k1_init_mono_control (&controls[nctl++],"Wave Master Playback Volume" , gpr,0 ); - gpr +=2 ; + gpr++;/* analog speakers */ A_PUT_STEREO_OUTPUT (A_EXTOUT_AFRONT_L ,A_EXTOUT_AFRONT_R , playback);
@@ -1668,11 +1672,12 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))* ok, set up done.. */ -if (gpr > tmp) { +if (gpr >512 ) {snd_BUG (); err = -EIO ; goto __err; } +/* clear remaining instruction memory */ while (ptr <0x400 )A_OP (icode, &ptr,0x0f ,0xc0 ,0xc0 ,0xcf ,0xc0 );
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 2/7 ALSA: emu10k1: fix non-zero mixer control defaults in highres mode
In reply to Oswald BuddenhagenThe default value needs to be scaled.
--- sound/pci/emu10k1/emufx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/pci/emu10k1/emufx.c +5 -3
@@ -1116,40 +1116,42 @@ snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl, ctl->id.iface = (__force int )SNDRV_CTL_ELEM_IFACE_MIXER ;strcpy (ctl->id.name, name); ctl->vcount = ctl->count =1 ; - ctl->gpr[0 ] = gpr +0 ; ctl->value[0 ] = defval;if (high_res_gpr_volume) { ctl->min =0 ; ctl->max =0x7fffffff ; ctl->tlv = snd_emu10k1_db_linear; ctl->translation =EMU10K1_GPR_TRANSLATION_NONE ; + defval = defval *0x7fffffffLL /100 ; }else { ctl->min =0 ; ctl->max =100 ; ctl->tlv = snd_emu10k1_db_scale1; ctl->translation =EMU10K1_GPR_TRANSLATION_TABLE100 ; } + ctl->gpr[0 ] = gpr +0 ; ctl->value[0 ] = defval; }static void snd_emu10k1_init_stereo_control (struct snd_emu10k1_fx8010_control_gpr *ctl,const char *name,int gpr,int defval) { ctl->id.iface = (__force int )SNDRV_CTL_ELEM_IFACE_MIXER ;strcpy (ctl->id.name, name); ctl->vcount = ctl->count =2 ; - ctl->gpr[0 ] = gpr +0 ; ctl->value[0 ] = defval; - ctl->gpr[1 ] = gpr +1 ; ctl->value[1 ] = defval;if (high_res_gpr_volume) { ctl->min =0 ; ctl->max =0x7fffffff ; ctl->tlv = snd_emu10k1_db_linear; ctl->translation =EMU10K1_GPR_TRANSLATION_NONE ; + defval = defval *0x7fffffffLL /100 ; }else { ctl->min =0 ; ctl->max =100 ; ctl->tlv = snd_emu10k1_db_scale1; ctl->translation =EMU10K1_GPR_TRANSLATION_TABLE100 ; } + ctl->gpr[0 ] = gpr +0 ; ctl->value[0 ] = defval; + ctl->gpr[1 ] = gpr +1 ; ctl->value[1 ] = defval; } static void
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 3/7 ALSA: emu10k1: validate min/max values of translated controls
In reply to Oswald BuddenhagenUser space could pass arbitrary ranges, which were uncritically accepted. This could lead to table lookups out of range.
I don't think that this is a security issue, as it only allowed someone with CAP_SYS_ADMIN to crash the kernel, but still.
Setting an invalid translation mode will also be rejected now. That did no harm, but it's still better to detect errors.
--- sound/pci/emu10k1/emufx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
sound/pci/emu10k1/emufx.c +26 -0
@@ -769,6 +769,32 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, err = -EINVAL ; goto __error; } +switch (gctl->translation) { +case EMU10K1_GPR_TRANSLATION_NONE : +break ; +case EMU10K1_GPR_TRANSLATION_TABLE100 : +if (gctl->min !=0 || gctl->max !=100 ) { + err = -EINVAL ; + goto __error; + } +break ; +case EMU10K1_GPR_TRANSLATION_BASS : +case EMU10K1_GPR_TRANSLATION_TREBLE : +if (gctl->min !=0 || gctl->max !=40 ) { + err = -EINVAL ; + goto __error; + } +break ; +case EMU10K1_GPR_TRANSLATION_ONOFF : +if (gctl->min !=0 || gctl->max !=1 ) { + err = -EINVAL ; + goto __error; + } +break ; +default : + err = -EINVAL ; + goto __error; + } }for (i =0 ; i < icode->gpr_list_control_count; i++) {/* FIXME: we need to check the WRITE access */
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 4/7 ALSA: emu10k1: omit non-applicable mixer controls for E-MU cards
In reply to Oswald BuddenhagenThe E-MU cards don't try very hard to be Sound Blasters. All sound I/O goes through the Hana FPGA, thus making the regular extin/out controls useless. Still showing them just serves to clutter up the interface and confuse the user.
--- sound/pci/emu10k1/emufx.c | 241 +++++++++++++++++++------------------- 1 file changed, 120 insertions(+), 121 deletions(-)
sound/pci/emu10k1/emufx.c +120 -121
@@ -1379,87 +1379,88 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))snd_emu10k1_init_stereo_control (&controls[nctl++],"EMU Capture Volume" , gpr,0 ); gpr_map[gpr +2 ] =0x00000000 ; gpr +=3 ; + }else { +/* AC'97 Playback Volume - used only for mic (renamed later) */ +A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_AC97_L ); +A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_AC97_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++],"AMic Playback Volume" , gpr,0 ); + gpr +=2 ; +/* AC'97 Capture Volume - used only for mic */ +A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_AC97_L ); +A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_AC97_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++],"Mic Capture Volume" , gpr,0 ); + gpr +=2 ; + +/* mic capture buffer */ +A_OP (icode, &ptr, iINTERP,A_EXTOUT (A_EXTOUT_MIC_CAP ),A_EXTIN (A_EXTIN_AC97_L ),A_C_40000000 ,A_EXTIN (A_EXTIN_AC97_R )); + +/* Audigy CD Playback Volume */ +A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_SPDIF_CD_L ); +A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_SPDIF_CD_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++], + emu->card_capabilities->ac97_chip ?"Audigy CD Playback Volume" :"CD Playback Volume" , + gpr,0 ); + gpr +=2 ; +/* Audigy CD Capture Volume */ +A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_SPDIF_CD_L ); +A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_SPDIF_CD_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++], + emu->card_capabilities->ac97_chip ?"Audigy CD Capture Volume" :"CD Capture Volume" , + gpr,0 ); + gpr +=2 ; + +/* Optical SPDIF Playback Volume */ +A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_OPT_SPDIF_L ); +A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_OPT_SPDIF_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++],SNDRV_CTL_NAME_IEC958 ("Optical " ,PLAYBACK ,VOLUME ), gpr,0 ); + gpr +=2 ; +/* Optical SPDIF Capture Volume */ +A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_OPT_SPDIF_L ); +A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_OPT_SPDIF_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++],SNDRV_CTL_NAME_IEC958 ("Optical " ,CAPTURE ,VOLUME ), gpr,0 ); + gpr +=2 ; + +/* Line2 Playback Volume */ +A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_LINE2_L ); +A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_LINE2_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++], + emu->card_capabilities->ac97_chip ?"Line2 Playback Volume" :"Line Playback Volume" , + gpr,0 ); + gpr +=2 ; +/* Line2 Capture Volume */ +A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_LINE2_L ); +A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_LINE2_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++], + emu->card_capabilities->ac97_chip ?"Line2 Capture Volume" :"Line Capture Volume" , + gpr,0 ); + gpr +=2 ; + +/* Philips ADC Playback Volume */ +A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_ADC_L ); +A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_ADC_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++],"Analog Mix Playback Volume" , gpr,0 ); + gpr +=2 ; +/* Philips ADC Capture Volume */ +A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_ADC_L ); +A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_ADC_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++],"Analog Mix Capture Volume" , gpr,0 ); + gpr +=2 ; + +/* Aux2 Playback Volume */ +A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_AUX2_L ); +A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_AUX2_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++], + emu->card_capabilities->ac97_chip ?"Aux2 Playback Volume" :"Aux Playback Volume" , + gpr,0 ); + gpr +=2 ; +/* Aux2 Capture Volume */ +A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_AUX2_L ); +A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_AUX2_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++], + emu->card_capabilities->ac97_chip ?"Aux2 Capture Volume" :"Aux Capture Volume" , + gpr,0 ); + gpr +=2 ; } -/* AC'97 Playback Volume - used only for mic (renamed later) */ -A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_AC97_L ); -A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_AC97_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++],"AMic Playback Volume" , gpr,0 ); - gpr +=2 ; -/* AC'97 Capture Volume - used only for mic */ -A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_AC97_L ); -A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_AC97_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++],"Mic Capture Volume" , gpr,0 ); - gpr +=2 ; - -/* mic capture buffer */ -A_OP (icode, &ptr, iINTERP,A_EXTOUT (A_EXTOUT_MIC_CAP ),A_EXTIN (A_EXTIN_AC97_L ),A_C_40000000 ,A_EXTIN (A_EXTIN_AC97_R )); - -/* Audigy CD Playback Volume */ -A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_SPDIF_CD_L ); -A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_SPDIF_CD_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++], - emu->card_capabilities->ac97_chip ?"Audigy CD Playback Volume" :"CD Playback Volume" , - gpr,0 ); - gpr +=2 ; -/* Audigy CD Capture Volume */ -A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_SPDIF_CD_L ); -A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_SPDIF_CD_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++], - emu->card_capabilities->ac97_chip ?"Audigy CD Capture Volume" :"CD Capture Volume" , - gpr,0 ); - gpr +=2 ; - -/* Optical SPDIF Playback Volume */ -A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_OPT_SPDIF_L ); -A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_OPT_SPDIF_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++],SNDRV_CTL_NAME_IEC958 ("Optical " ,PLAYBACK ,VOLUME ), gpr,0 ); - gpr +=2 ; -/* Optical SPDIF Capture Volume */ -A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_OPT_SPDIF_L ); -A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_OPT_SPDIF_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++],SNDRV_CTL_NAME_IEC958 ("Optical " ,CAPTURE ,VOLUME ), gpr,0 ); - gpr +=2 ; - -/* Line2 Playback Volume */ -A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_LINE2_L ); -A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_LINE2_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++], - emu->card_capabilities->ac97_chip ?"Line2 Playback Volume" :"Line Playback Volume" , - gpr,0 ); - gpr +=2 ; -/* Line2 Capture Volume */ -A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_LINE2_L ); -A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_LINE2_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++], - emu->card_capabilities->ac97_chip ?"Line2 Capture Volume" :"Line Capture Volume" , - gpr,0 ); - gpr +=2 ; - -/* Philips ADC Playback Volume */ -A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_ADC_L ); -A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_ADC_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++],"Analog Mix Playback Volume" , gpr,0 ); - gpr +=2 ; -/* Philips ADC Capture Volume */ -A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_ADC_L ); -A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_ADC_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++],"Analog Mix Capture Volume" , gpr,0 ); - gpr +=2 ; - -/* Aux2 Playback Volume */ -A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_AUX2_L ); -A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_AUX2_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++], - emu->card_capabilities->ac97_chip ?"Aux2 Playback Volume" :"Aux Playback Volume" , - gpr,0 ); - gpr +=2 ; -/* Aux2 Capture Volume */ -A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_AUX2_L ); -A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_AUX2_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++], - emu->card_capabilities->ac97_chip ?"Aux2 Capture Volume" :"Aux Capture Volume" , - gpr,0 ); - gpr +=2 ;/* Stereo Mix Front Playback Volume */ A_OP (icode, &ptr, iMAC0,A_GPR (playback),A_GPR (playback),A_GPR (gpr),A_GPR (stereo_mix));
@@ -1580,60 +1581,58 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))snd_emu10k1_init_mono_control (&controls[nctl++],"Wave Master Playback Volume" , gpr,0 ); gpr++; -/* analog speakers */ -A_PUT_STEREO_OUTPUT (A_EXTOUT_AFRONT_L ,A_EXTOUT_AFRONT_R , playback); -A_PUT_STEREO_OUTPUT (A_EXTOUT_AREAR_L ,A_EXTOUT_AREAR_R , playback+2 ); -A_PUT_OUTPUT (A_EXTOUT_ACENTER , playback+4 ); -A_PUT_OUTPUT (A_EXTOUT_ALFE , playback+5 ); -if (emu->card_capabilities->spk71) -A_PUT_STEREO_OUTPUT (A_EXTOUT_ASIDE_L ,A_EXTOUT_ASIDE_R , playback+6 ); - -/* headphone */ -A_PUT_STEREO_OUTPUT (A_EXTOUT_HEADPHONE_L ,A_EXTOUT_HEADPHONE_R , playback); - -/* digital outputs */ -/* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */ if (emu->card_capabilities->emu_model) {/* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */ dev_info (emu->card->dev,"EMU outputs on\n" );for (z =0 ; z <8 ; z++) {if (emu->card_capabilities->ca0108_chip) {A_OP (icode, &ptr, iACC3,A3_EMU32OUT (z),A_GPR (playback + z),A_C_00000000 ,A_C_00000000 ); }else {A_OP (icode, &ptr, iACC3,A_EMU32OUTL (z),A_GPR (playback + z),A_C_00000000 ,A_C_00000000 ); } } - } + }else { +/* analog speakers */ +A_PUT_STEREO_OUTPUT (A_EXTOUT_AFRONT_L ,A_EXTOUT_AFRONT_R , playback); +A_PUT_STEREO_OUTPUT (A_EXTOUT_AREAR_L ,A_EXTOUT_AREAR_R , playback+2 ); +A_PUT_OUTPUT (A_EXTOUT_ACENTER , playback+4 ); +A_PUT_OUTPUT (A_EXTOUT_ALFE , playback+5 ); +if (emu->card_capabilities->spk71) +A_PUT_STEREO_OUTPUT (A_EXTOUT_ASIDE_L ,A_EXTOUT_ASIDE_R , playback+6 ); -/* IEC958 Optical Raw Playback Switch */ - gpr_map[gpr++] =0 ; - gpr_map[gpr++] =0x1008 ; - gpr_map[gpr++] =0xffff0000 ; -for (z =0 ; z <2 ; z++) { -A_OP (icode, &ptr, iMAC0,A_GPR (tmp +2 ),A_FXBUS (FXBUS_PT_LEFT + z),A_C_00000000 ,A_C_00000000 ); -A_OP (icode, &ptr, iSKIP,A_GPR_COND ,A_GPR_COND ,A_GPR (gpr -2 ),A_C_00000001 ); -A_OP (icode, &ptr, iACC3,A_GPR (tmp +2 ),A_C_00000000 ,A_C_00010000 ,A_GPR (tmp +2 )); -A_OP (icode, &ptr, iANDXOR,A_GPR (tmp +2 ),A_GPR (tmp +2 ),A_GPR (gpr -1 ),A_C_00000000 ); -A_SWITCH (icode, &ptr, tmp +0 , tmp +2 , gpr + z); -A_SWITCH_NEG (icode, &ptr, tmp +1 , gpr + z); -A_SWITCH (icode, &ptr, tmp +1 , playback + z, tmp +1 ); -if ((z==1 ) && (emu->card_capabilities->spdif_bug)) { -/* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */ -dev_info (emu->card->dev, -"Installing spdif_bug patch: %s\n" , - emu->card_capabilities->name); -A_OP (icode, &ptr, iACC3,A_EXTOUT (A_EXTOUT_FRONT_L + z),A_GPR (gpr -3 ),A_C_00000000 ,A_C_00000000 ); -A_OP (icode, &ptr, iACC3,A_GPR (gpr -3 ),A_GPR (tmp +0 ),A_GPR (tmp +1 ),A_C_00000000 ); - }else { -A_OP (icode, &ptr, iACC3,A_EXTOUT (A_EXTOUT_FRONT_L + z),A_GPR (tmp +0 ),A_GPR (tmp +1 ),A_C_00000000 ); +/* headphone */ +A_PUT_STEREO_OUTPUT (A_EXTOUT_HEADPHONE_L ,A_EXTOUT_HEADPHONE_R , playback); + +/* IEC958 Optical Raw Playback Switch */ + gpr_map[gpr++] =0 ; + gpr_map[gpr++] =0x1008 ; + gpr_map[gpr++] =0xffff0000 ; +for (z =0 ; z <2 ; z++) { +A_OP (icode, &ptr, iMAC0,A_GPR (tmp +2 ),A_FXBUS (FXBUS_PT_LEFT + z),A_C_00000000 ,A_C_00000000 ); +A_OP (icode, &ptr, iSKIP,A_GPR_COND ,A_GPR_COND ,A_GPR (gpr -2 ),A_C_00000001 ); +A_OP (icode, &ptr, iACC3,A_GPR (tmp +2 ),A_C_00000000 ,A_C_00010000 ,A_GPR (tmp +2 )); +A_OP (icode, &ptr, iANDXOR,A_GPR (tmp +2 ),A_GPR (tmp +2 ),A_GPR (gpr -1 ),A_C_00000000 ); +A_SWITCH (icode, &ptr, tmp +0 , tmp +2 , gpr + z); +A_SWITCH_NEG (icode, &ptr, tmp +1 , gpr + z); +A_SWITCH (icode, &ptr, tmp +1 , playback + z, tmp +1 ); +if ((z==1 ) && (emu->card_capabilities->spdif_bug)) { +/* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */ +dev_info (emu->card->dev, +"Installing spdif_bug patch: %s\n" , + emu->card_capabilities->name); +A_OP (icode, &ptr, iACC3,A_EXTOUT (A_EXTOUT_FRONT_L + z),A_GPR (gpr -3 ),A_C_00000000 ,A_C_00000000 ); +A_OP (icode, &ptr, iACC3,A_GPR (gpr -3 ),A_GPR (tmp +0 ),A_GPR (tmp +1 ),A_C_00000000 ); + }else { +A_OP (icode, &ptr, iACC3,A_EXTOUT (A_EXTOUT_FRONT_L + z),A_GPR (tmp +0 ),A_GPR (tmp +1 ),A_C_00000000 ); + } } +snd_emu10k1_init_stereo_onoff_control (controls + nctl++,SNDRV_CTL_NAME_IEC958 ("Optical Raw " ,PLAYBACK ,SWITCH ), gpr,0 ); + gpr +=2 ; + +A_PUT_STEREO_OUTPUT (A_EXTOUT_REAR_L ,A_EXTOUT_REAR_R , playback+2 ); +A_PUT_OUTPUT (A_EXTOUT_CENTER , playback+4 ); +A_PUT_OUTPUT (A_EXTOUT_LFE , playback+5 ); } -snd_emu10k1_init_stereo_onoff_control (controls + nctl++,SNDRV_CTL_NAME_IEC958 ("Optical Raw " ,PLAYBACK ,SWITCH ), gpr,0 ); - gpr +=2 ; - -A_PUT_STEREO_OUTPUT (A_EXTOUT_REAR_L ,A_EXTOUT_REAR_R , playback+2 ); -A_PUT_OUTPUT (A_EXTOUT_CENTER , playback+4 ); -A_PUT_OUTPUT (A_EXTOUT_LFE , playback+5 );/* ADC buffer */ #ifdef EMU10K1_CAPTURE_DIGITAL_OUT
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 5/7 ALSA: emu10k1: skip mic capture PCM for cards without AC97 codec
In reply to Oswald BuddenhagenThe microphone capture device is a feature of the AC97 codec, so its availability should be coupled to the presence of that codec.
--- sound/pci/emu10k1/emu10k1.c | 8 +++++--- sound/pci/emu10k1/emufx.c | 26 ++++++++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-)
sound/pci/emu10k1/emu10k1.c +5 -3
@@ -107,9 +107,11 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci, err =snd_emu10k1_pcm (emu,0 );if (err <0 )return err; - err =snd_emu10k1_pcm_mic (emu,1 ); -if (err <0 ) -return err; +if (emu->card_capabilities->ac97_chip) { + err =snd_emu10k1_pcm_mic (emu,1 ); +if (err <0 ) +return err; + } err =snd_emu10k1_pcm_efx (emu,2 );if (err <0 )return err;
sound/pci/emu10k1/emufx.c +14 -12
@@ -1380,19 +1380,21 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) gpr_map[gpr +2 ] =0x00000000 ; gpr +=3 ; }else { -/* AC'97 Playback Volume - used only for mic (renamed later) */ -A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_AC97_L ); -A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_AC97_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++],"AMic Playback Volume" , gpr,0 ); - gpr +=2 ; -/* AC'97 Capture Volume - used only for mic */ -A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_AC97_L ); -A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_AC97_R ); -snd_emu10k1_init_stereo_control (&controls[nctl++],"Mic Capture Volume" , gpr,0 ); - gpr +=2 ; +if (emu->card_capabilities->ac97_chip) { +/* AC'97 Playback Volume - used only for mic (renamed later) */ +A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_AC97_L ); +A_ADD_VOLUME_IN (stereo_mix+1 , gpr+1 ,A_EXTIN_AC97_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++],"AMic Playback Volume" , gpr,0 ); + gpr +=2 ; +/* AC'97 Capture Volume - used only for mic */ +A_ADD_VOLUME_IN (capture, gpr,A_EXTIN_AC97_L ); +A_ADD_VOLUME_IN (capture+1 , gpr+1 ,A_EXTIN_AC97_R ); +snd_emu10k1_init_stereo_control (&controls[nctl++],"Mic Capture Volume" , gpr,0 ); + gpr +=2 ; -/* mic capture buffer */ -A_OP (icode, &ptr, iINTERP,A_EXTOUT (A_EXTOUT_MIC_CAP ),A_EXTIN (A_EXTIN_AC97_L ),A_C_40000000 ,A_EXTIN (A_EXTIN_AC97_R )); +/* mic capture buffer */ +A_OP (icode, &ptr, iINTERP,A_EXTOUT (A_EXTOUT_MIC_CAP ),A_EXTIN (A_EXTIN_AC97_L ),A_C_40000000 ,A_EXTIN (A_EXTIN_AC97_R )); + }/* Audigy CD Playback Volume */ A_ADD_VOLUME_IN (stereo_mix, gpr,A_EXTIN_SPDIF_CD_L );
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 6/7 ALSA: emu10k1: enable bit-exact playback, part 1: DSP attenuation
In reply to Oswald BuddenhagenFractional multiplication with the maximal value 2^31-1 causes some tiny distortion. Instead, we want to multiply with the full 2^31. The catch is of course that this cannot be represented in the DSP's signed 32 bit registers.
One way to deal with this is to encode 1.0 as a negative number and special-case it. As a matter of fact, the SbLive! code path already contained such code, though the controls never actually exercised it.
A more efficient approach is to use negative values, which actually extend to -2^31. Accordingly, for all the volume adjustments we now use the MAC1 instruction which negates the X operand.
The range of the controls in highres mode is extended downwards, so -1 is the new zero/mute. At maximal excursion, real zero is not mute any more, but I don't think anyone will notice this behavior change. ;-)
That also required making the min/max/values in the control structs signed. This technically changes the user space interface, but it seems implausible that someone would notice - the numbers were actually treated as if they were signed anyway (and in the actual mixer iface they _are_). And without this change, the min value didn't even make sense in the first place (and no-one noticed, because it was always 0).
--- include/sound/emu10k1.h | 6 +- include/uapi/sound/emu10k1.h | 8 ++- sound/pci/emu10k1/emufx.c | 119 +++++++++++++++++------------------ 3 files changed, 64 insertions(+), 69 deletions(-)
include/sound/emu10k1.h +3 -3
@@ -1511,9 +1511,9 @@ struct snd_emu10k1_fx8010_ctl {unsigned int vcount;unsigned int count;/* count of GPR (1..16) */ unsigned short gpr[32 ];/* GPR number(s) */ -unsigned int value[32 ]; -unsigned int min;/* minimum range */ -unsigned int max;/* maximum range */ +int value[32 ]; +int min;/* minimum range */ +int max;/* maximum range */ unsigned int translation;/* translation type (EMU10K1_GPR_TRANSLATION*) */ struct snd_kcontrol *kcontrol; };
include/uapi/sound/emu10k1.h +5 -3
@@ -308,6 +308,8 @@ struct snd_emu10k1_fx8010_info {#define EMU10K1_GPR_TRANSLATION_BASS 2#define EMU10K1_GPR_TRANSLATION_TREBLE 3#define EMU10K1_GPR_TRANSLATION_ONOFF 4 +#define EMU10K1_GPR_TRANSLATION_NEGATE 5 +#define EMU10K1_GPR_TRANSLATION_NEG_TABLE100 6enum emu10k1_ctl_elem_iface {EMU10K1_CTL_ELEM_IFACE_MIXER =2 ,/* virtual mixer device */
@@ -328,9 +330,9 @@ struct snd_emu10k1_fx8010_control_gpr {unsigned int vcount;/* visible count */ unsigned int count;/* count of GPR (1..16) */ unsigned short gpr[32 ];/* GPR number(s) */ -unsigned int value[32 ];/* initial values */ -unsigned int min;/* minimum range */ -unsigned int max;/* maximum range */ +int value[32 ];/* initial values */ +int min;/* minimum range */ +int max;/* maximum range */ unsigned int translation;/* translation type (EMU10K1_GPR_TRANSLATION*) */ const unsigned int *tlv; };
sound/pci/emu10k1/emufx.c +56 -63
293 lines not on this page · raw message
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH v2 7/7 ALSA: emu10k1: enable bit-exact playback, part 2: voice attenuation
In reply to Oswald BuddenhagenThe voice volume is a raw fractional multiplier that can't actually represent 1.0. To still enable real pass-through, we now set the volume to 0.5 (which results in no loss of precision, as the FX bus provides fractional values) and scale up the samples in DSP code.
To maintain backwards compatibility with existing configuration files, we rescale the values in the mixer controls. The range is extended upwards from 0xffff to 0x1fffd, which actually introduces the possibility of specifying an amplification.
There is still a minor incompatibility with user space, namely if someone loaded custom DSP code. They'll just get half the volume, so this doesn't seem like a big deal.
--- Documentation/sound/cards/audigy-mixer.rst | 2 +- Documentation/sound/cards/sb-live-mixer.rst | 2 +- include/sound/emu10k1.h | 3 +++ sound/pci/emu10k1/emufx.c | 30 ++++++++++++--------- sound/pci/emu10k1/emumixer.c | 15 ++++++----- sound/pci/emu10k1/emupcm.c | 4 +-- 6 files changed, 34 insertions(+), 22 deletions(-)
Documentation/sound/cards/audigy-mixer.rst +1 -1
@@ -227,7 +227,7 @@ PCM stream related controls name='EMU10K1 PCM Volume',index 0-31 ------------------------------------ -Channel volume attenuation in range 0-0xffff. The maximum value (no +Channel volume attenuation in range 0-0x1fffd. The middle value (no attenuation) is default. The channel mapping for three values is as follows:
Documentation/sound/cards/sb-live-mixer.rst +1 -1
@@ -258,7 +258,7 @@ PCM stream related controls ``name='EMU10K1 PCM Volume',index 0-31`` ---------------------------------------- -Channel volume attenuation in range 0-0xffff. The maximum value (no +Channel volume attenuation in range 0-0x1fffd. The middle value (no attenuation) is default. The channel mapping for three values is as follows:
include/sound/emu10k1.h +3 -0
@@ -396,6 +396,7 @@#define PTRX_FXSENDAMOUNT_B_MASK 0x000000ff/* Linear level of channel output sent to FX send bus B */ #define PTRX_FXSENDAMOUNT_B 0x08000001 +// Note: the volumes are raw multpliers, so real 100% is impossible. #define CVCF 0x02/* Current volume and filter cutoff register */ #define CVCF_CURRENTVOL_MASK 0xffff0000/* Current linear volume of specified channel */ #define CVCF_CURRENTVOL 0x10100002
@@ -1480,6 +1481,8 @@ struct snd_emu10k1_pcm_mixer {/* mono, left, right x 8 sends (4 on emu10k1) */ unsigned char send_routing[3 ][8 ];unsigned char send_volume[3 ][8 ]; +// 0x8000 is neutral. The mixer code rescales it to 0xffff to maintain +// backwards compatibility with user space. unsigned short attn[3 ];struct snd_emu10k1_pcm *epcm; };
sound/pci/emu10k1/emufx.c +18 -12
@@ -1361,7 +1361,13 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)A_OP (icode, &ptr, iMAC1,A_GPR (capture+1 ),A_GPR (capture+1 ),A_GPR (gpr+1 ),A_FXBUS (FXBUS_MIDI_RIGHT ));snd_emu10k1_init_stereo_control (&controls[nctl++],"Synth Capture Volume" , gpr,0 ); gpr +=2 ; - + +// We need to double the volume, as we configure the voices for half volume, +// which is necessary for bit-identical reproduction. + {static_assert (stereo_mix == playback +SND_EMU10K1_PLAYBACK_CHANNELS ); } +for (z =0 ; z <SND_EMU10K1_PLAYBACK_CHANNELS +2 ; z++) +A_OP (icode, &ptr, iACC3,A_GPR (playback + z),A_GPR (playback + z),A_GPR (playback + z),A_C_00000000 ); +/* * inputs */
@@ -1826,18 +1832,18 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)/* * Process FX Buses */ -OP (icode, &ptr, iMACINT0,GPR (0 ),C_00000000 ,FXBUS (FXBUS_PCM_LEFT ),C_00000004 ); -OP (icode, &ptr, iMACINT0,GPR (1 ),C_00000000 ,FXBUS (FXBUS_PCM_RIGHT ),C_00000004 ); -OP (icode, &ptr, iMACINT0,GPR (2 ),C_00000000 ,FXBUS (FXBUS_MIDI_LEFT ),C_00000004 ); -OP (icode, &ptr, iMACINT0,GPR (3 ),C_00000000 ,FXBUS (FXBUS_MIDI_RIGHT ),C_00000004 ); -OP (icode, &ptr, iMACINT0,GPR (4 ),C_00000000 ,FXBUS (FXBUS_PCM_LEFT_REAR ),C_00000004 ); -OP (icode, &ptr, iMACINT0,GPR (5 ),C_00000000 ,FXBUS (FXBUS_PCM_RIGHT_REAR ),C_00000004 ); -OP (icode, &ptr, iMACINT0,GPR (6 ),C_00000000 ,FXBUS (FXBUS_PCM_CENTER ),C_00000004 ); -OP (icode, &ptr, iMACINT0,GPR (7 ),C_00000000 ,FXBUS (FXBUS_PCM_LFE ),C_00000004 ); +OP (icode, &ptr, iMACINT0,GPR (0 ),C_00000000 ,FXBUS (FXBUS_PCM_LEFT ),C_00000008 ); +OP (icode, &ptr, iMACINT0,GPR (1 ),C_00000000 ,FXBUS (FXBUS_PCM_RIGHT ),C_00000008 ); +OP (icode, &ptr, iMACINT0,GPR (2 ),C_00000000 ,FXBUS (FXBUS_MIDI_LEFT ),C_00000008 ); +OP (icode, &ptr, iMACINT0,GPR (3 ),C_00000000 ,FXBUS (FXBUS_MIDI_RIGHT ),C_00000008 ); +OP (icode, &ptr, iMACINT0,GPR (4 ),C_00000000 ,FXBUS (FXBUS_PCM_LEFT_REAR ),C_00000008 ); +OP (icode, &ptr, iMACINT0,GPR (5 ),C_00000000 ,FXBUS (FXBUS_PCM_RIGHT_REAR ),C_00000008 ); +OP (icode, &ptr, iMACINT0,GPR (6 ),C_00000000 ,FXBUS (FXBUS_PCM_CENTER ),C_00000008 ); +OP (icode, &ptr, iMACINT0,GPR (7 ),C_00000000 ,FXBUS (FXBUS_PCM_LFE ),C_00000008 );OP (icode, &ptr, iMACINT0,GPR (8 ),C_00000000 ,C_00000000 ,C_00000000 );/* S/PDIF left */ OP (icode, &ptr, iMACINT0,GPR (9 ),C_00000000 ,C_00000000 ,C_00000000 );/* S/PDIF right */ -OP (icode, &ptr, iMACINT0,GPR (10 ),C_00000000 ,FXBUS (FXBUS_PCM_LEFT_FRONT ),C_00000004 ); -OP (icode, &ptr, iMACINT0,GPR (11 ),C_00000000 ,FXBUS (FXBUS_PCM_RIGHT_FRONT ),C_00000004 ); +OP (icode, &ptr, iMACINT0,GPR (10 ),C_00000000 ,FXBUS (FXBUS_PCM_LEFT_FRONT ),C_00000008 ); +OP (icode, &ptr, iMACINT0,GPR (11 ),C_00000000 ,FXBUS (FXBUS_PCM_RIGHT_FRONT ),C_00000008 );/* Raw S/PDIF PCM */ ipcm->substream =0 ;
@@ -1931,7 +1937,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)/* Wave Center/LFE Playback Volume */ OP (icode, &ptr, iACC3,GPR (tmp +0 ),FXBUS (FXBUS_PCM_LEFT ),FXBUS (FXBUS_PCM_RIGHT ),C_00000000 ); -OP (icode, &ptr, iMACINT0,GPR (tmp +0 ),C_00000000 ,GPR (tmp +0 ),C_00000002 ); +OP (icode, &ptr, iMACINT0,GPR (tmp +0 ),C_00000000 ,GPR (tmp +0 ),C_00000004 );VOLUME (icode, &ptr, playback +4 , tmp +0 , gpr);snd_emu10k1_init_mono_control (controls + i++,"Wave Center Playback Volume" , gpr++,0 );VOLUME (icode, &ptr, playback +5 , tmp +0 , gpr);
sound/pci/emu10k1/emumixer.c +9 -6
@@ -1352,7 +1352,7 @@ static int snd_emu10k1_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_e uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; uinfo->count =3 ; uinfo->value.integer.min =0 ; - uinfo->value.integer.max =0xffff ; + uinfo->value.integer.max =0x1fffd ;return 0 ; }
@@ -1365,7 +1365,7 @@ static int snd_emu10k1_attn_get(struct snd_kcontrol *kcontrol,int idx;for (idx =0 ; idx <3 ; idx++) - ucontrol->value.integer.value[idx] = mix->attn[idx]; + ucontrol->value.integer.value[idx] = mix->attn[idx] *0xffffU /0x8000U ;return 0 ; }
@@ -1380,7 +1380,8 @@ static int snd_emu10k1_attn_put(struct snd_kcontrol *kcontrol,spin_lock_irqsave (&emu->reg_lock, flags);for (idx =0 ; idx <3 ; idx++) { - val = ucontrol->value.integer.value[idx] &0xffff ; +unsigned uval = ucontrol->value.integer.value[idx] &0x1ffff ; + val = uval *0x8000U /0xffffU ;if (mix->attn[idx] != val) { mix->attn[idx] = val; change =1 ;
@@ -1547,32 +1548,34 @@ static int snd_emu10k1_efx_attn_info(struct snd_kcontrol *kcontrol, struct snd_c uinfo->type =SNDRV_CTL_ELEM_TYPE_INTEGER ; uinfo->count =1 ; uinfo->value.integer.min =0 ; - uinfo->value.integer.max =0xffff ; + uinfo->value.integer.max =0x1fffd ;return 0 ; }static int snd_emu10k1_efx_attn_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol);struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx (kcontrol, &ucontrol->id)]; - ucontrol->value.integer.value[0 ] = mix->attn[0 ]; + ucontrol->value.integer.value[0 ] = mix->attn[0 ] *0xffffU /0x8000U ;return 0 ; }static int snd_emu10k1_efx_attn_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {unsigned long flags;struct snd_emu10k1 *emu =snd_kcontrol_chip (kcontrol);int ch =snd_ctl_get_ioffidx (kcontrol, &ucontrol->id);struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];int change =0 , val; +unsigned uval;spin_lock_irqsave (&emu->reg_lock, flags); - val = ucontrol->value.integer.value[0 ] &0xffff ; + uval = ucontrol->value.integer.value[0 ] &0x1ffff ; + val = uval *0x8000U /0xffffU ;if (mix->attn[0 ] != val) { mix->attn[0 ] = val; change =1 ;
sound/pci/emu10k1/emupcm.c +2 -2
@@ -1049,7 +1049,7 @@ static int snd_emu10k1_efx_playback_open(struct snd_pcm_substream *substream) mix->send_routing[0 ][0 ] = i;memset (&mix->send_volume,0 ,sizeof (mix->send_volume)); mix->send_volume[0 ][0 ] =255 ; - mix->attn[0 ] =0xffff ; + mix->attn[0 ] =0x8000 ; mix->epcm = epcm;snd_emu10k1_pcm_efx_mixer_notify (emu, i,1 ); }
@@ -1098,7 +1098,7 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream)memset (&mix->send_volume,0 ,sizeof (mix->send_volume)); mix->send_volume[0 ][0 ] = mix->send_volume[0 ][1 ] = mix->send_volume[1 ][0 ] = mix->send_volume[2 ][1 ] =255 ; - mix->attn[0 ] = mix->attn[1 ] = mix->attn[2 ] =0xffff ; + mix->attn[0 ] = mix->attn[1 ] = mix->attn[2 ] =0x8000 ; mix->epcm = epcm;snd_emu10k1_pcm_mixer_notify (emu, substream->number,1 );return 0 ;
Signature · 1 line
2.40.0.152.g15d061e6df
Takashi Iwai
AppliedQuoted 10 lines · Oswald Buddenhagen
Oswald Buddenhagen (7):
ALSA: emu10k1: polish audigy GPR allocation
ALSA: emu10k1: fix non-zero mixer control defaults in highres mode
ALSA: emu10k1: validate min/max values of translated controls
ALSA: emu10k1: omit non-applicable mixer controls for E-MU cards
ALSA: emu10k1: skip mic capture PCM for cards without AC97 codec
ALSA: emu10k1: enable bit-exact playback, part 1: DSP attenuation
ALSA: emu10k1: enable bit-exact playback, part 2: voice attenuation
Applied all seven patches now. Thanks.
Takashi
Quoted 2 lines
Applied all seven patches now. Thanks.
the last patch ("enable bit-exact playback, part 2: voice attenuation") seems to have got lost.
regards
Quoted 5 lines · Oswald Buddenhagen
Quoted 3 lines
Applied all seven patches now. Thanks.
the last patch ("enable bit-exact playback, part 2: voice attenuation") seems to have got lost.
On indeed, it slipped due to git-am didn't accept it cleanly. Now applied manually and pushed out.
Thanks for spotting!
Takashi