Fixes and Improvements for CS35L41 HDA
v2 cover Fixes and Improvements for CS35L41 HDA
Fixes issue in calibration, where return codes were misinterpreted. Enable High Pass filter to reduce pops and clicks.
Add improvement to ensure firmware and tuning files are always loaded together. This ensure the firmware is alsways running with valid coefficients.
Stefan Binding (2):
ALSA: hda: cs35l41: Ensure firmware/tuning pairs are always loaded
ALSA: hda: cs35l41: Enable Amp High Pass Filter
Vitaly Rodionov (1):
ALSA: hda: cs35l41: Correct error condition handling
sound/pci/hda/cs35l41_hda.c | 109 ++++++++++++++++----------------- sound/pci/hda/hda_cs_dsp_ctl.c | 4 +- 2 files changed, 56 insertions(+), 57 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/3 ALSA: hda: cs35l41: Correct error condition handling
From: Vitaly Rodionov <[email protected]>
Function cs_dsp_coeff_write_ctrl() can return 3 possible values:
0 - no change, 1 - value has changed and -1 - error, so positive value is not an error.
--- sound/pci/hda/hda_cs_dsp_ctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/hda_cs_dsp_ctl.c +2 -2
@@ -218,10 +218,10 @@ int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type, cs_ctl =cs_dsp_get_ctl (dsp, name, type, alg); ret =cs_dsp_coeff_write_ctrl (cs_ctl,0 , buf, len);mutex_unlock (&dsp->pwr_lock); -if (ret) +if (ret <0 )return ret; -if (cs_ctl->flags &WMFW_CTL_FLAG_SYS ) +if (ret ==0 || (cs_ctl->flags &WMFW_CTL_FLAG_SYS ))return 0 ; ctl = cs_ctl->priv;
Signature · 1 line
2.34.1
Re: [PATCH v2 1/3] ALSA: hda: cs35l41: Correct error condition handling
Quoted 20 lines · Stefan Binding
From: Vitaly Rodionov <[email protected]>
Function
cs_dsp_coeff_write_ctrl()can return 3 possible values:
0 - no change, 1 - value has changed and -1 - error, so positive value is not an error.Fixes 7406bdbc4fb8 ("ASoC: wm_adsp: Return whether changed when writing controls")Signed-off-by Vitaly Rodionov <[email protected]>Signed-off-by Stefan Binding <[email protected]>--- sound/pci/hda/hda_cs_dsp_ctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)sound/pci/hda/hda_cs_dsp_ctl.c +0
-0@@ -218,10 +218,10 @@ int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type, cs_ctl =cs_dsp_get_ctl (dsp, name, type, alg); ret =cs_dsp_coeff_write_ctrl (cs_ctl,0 , buf, len);
sound/pci/hda/hda_cs_dsp_ctl.c int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type, · line 227
Quoted 10 lines
sound/pci/hda/hda_cs_dsp_ctl.c +2
-2mutex_unlock (&dsp->pwr_lock); -if (ret) +if (ret <0 )return ret; -if (cs_ctl->flags &WMFW_CTL_FLAG_SYS ) +if (ret ==0 || (cs_ctl->flags &WMFW_CTL_FLAG_SYS ))return 0 ; ctl = cs_ctl->priv;
Hi Takashi
Could you queue this patch as a bugfix for 6.2 please? The cs_dsp patch to return 1 for changed has gone into 6.2 but we missed that this hda_cs_dsp code would break.
Re: [PATCH v2 1/3] ALSA: hda: cs35l41: Correct error condition handling
Quoted 33 lines · Richard Fitzgerald
Quoted 18 lines · Stefan Binding
From: Vitaly Rodionov <[email protected]>
Function
cs_dsp_coeff_write_ctrl()can return 3 possible values:
0 - no change, 1 - value has changed and -1 - error, so positive value is not an error.Fixes 7406bdbc4fb8 ("ASoC: wm_adsp: Return whether changed when writing controls")Signed-off-by Vitaly Rodionov <[email protected]>Signed-off-by Stefan Binding <[email protected]>--- sound/pci/hda/hda_cs_dsp_ctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)sound/pci/hda/hda_cs_dsp_ctl.c +0
-0sound/pci/hda/hda_cs_dsp_ctl.c int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type, · line 226
Quoted 10 lines
sound/pci/hda/hda_cs_dsp_ctl.c +2
-1@@ -218,10 +218,10 @@ int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type, cs_ctl =cs_dsp_get_ctl (dsp, name, type, alg); ret =cs_dsp_coeff_write_ctrl (cs_ctl,0 , buf, len);mutex_unlock (&dsp->pwr_lock); -if (ret) +if (ret <0 )return ret; - if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) +if (ret ==0 || (cs_ctl->flags &WMFW_CTL_FLAG_SYS ))return 0 ; ctl = cs_ctl->priv;Hi Takashi
Quoted 3 lines
Could you queue this patch as a bugfix for 6.2 please? The
cs_dsppatch to return 1 for changed has gone into 6.2 but we missed that thishda_cs_dspcode would break.
Could you just request the cherry-pick of the necessary fix commits via [email protected] (with Cc to Greg / Sasha)?
I've been still traveling in this week, so it's better for you doing that by yourself.
thanks,
Takashi
PATCH v2 2/3 ALSA: hda: cs35l41: Ensure firmware/tuning pairs are always loaded
In reply to Stefan BindingTo ensure firmware for cs35l41 is correctly running, it is necessary that a corresponding tuning file is also loaded. Without both, the firmware may not be performing correctly
Ensure that if we load the firmware, we have also loaded the correct tuning file. Otherwise, fall back to default firmware and tuning. If default tuning is also missing, then disable DSP firmware.
--- sound/pci/hda/cs35l41_hda.c | 103 ++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 52 deletions(-)
sound/pci/hda/cs35l41_hda.c +51 -52
@@ -178,11 +178,10 @@ static int cs35l41_request_firmware_files_spkid(struct cs35l41_hda *cs35l41, cs35l41->speaker_id, "wmfw");if (!ret) {/* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ -cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, -CS35L41_FIRMWARE_ROOT , - cs35l41->acpi_subsystem_id, cs35l41->amp_name, - cs35l41->speaker_id,"bin" ); -return 0 ; +return cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, +CS35L41_FIRMWARE_ROOT , + cs35l41->acpi_subsystem_id, cs35l41->amp_name, + cs35l41->speaker_id,"bin" ); }/* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */
@@ -191,10 +190,10 @@ static int cs35l41_request_firmware_files_spkid(struct cs35l41_hda *cs35l41, cs35l41->amp_name, -1, "wmfw");if (!ret) {/* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ -cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, -CS35L41_FIRMWARE_ROOT , cs35l41->acpi_subsystem_id, - cs35l41->amp_name, cs35l41->speaker_id,"bin" ); -return 0 ; +return cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, +CS35L41_FIRMWARE_ROOT , + cs35l41->acpi_subsystem_id, cs35l41->amp_name, + cs35l41->speaker_id,"bin" ); }/* try cirrus/part-dspN-fwtype-sub<-spkidN>.wmfw */
@@ -209,11 +208,10 @@ static int cs35l41_request_firmware_files_spkid(struct cs35l41_hda *cs35l41, cs35l41->amp_name, cs35l41->speaker_id, "bin");if (ret)/* try cirrus/part-dspN-fwtype-sub<-spkidN>.bin */ -cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, -CS35L41_FIRMWARE_ROOT , - cs35l41->acpi_subsystem_id, -NULL , cs35l41->speaker_id,"bin" ); -return 0 ; +return cs35l41_request_firmware_file (cs35l41, coeff_firmware, + coeff_filename,CS35L41_FIRMWARE_ROOT , + cs35l41->acpi_subsystem_id,NULL , + cs35l41->speaker_id,"bin" ); }/* try cirrus/part-dspN-fwtype-sub.wmfw */
@@ -224,29 +222,16 @@ static int cs35l41_request_firmware_files_spkid(struct cs35l41_hda *cs35l41,/* try cirrus/part-dspN-fwtype-sub<-spkidN><-ampname>.bin */ ret =cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename,CS35L41_FIRMWARE_ROOT , - cs35l41->acpi_subsystem_id, - cs35l41->amp_name, cs35l41->speaker_id,"bin" ); + cs35l41->acpi_subsystem_id, cs35l41->amp_name, + cs35l41->speaker_id,"bin" );if (ret)/* try cirrus/part-dspN-fwtype-sub<-spkidN>.bin */ -cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, -CS35L41_FIRMWARE_ROOT , - cs35l41->acpi_subsystem_id, -NULL , cs35l41->speaker_id,"bin" ); -return 0 ; - } - -/* fallback try cirrus/part-dspN-fwtype.wmfw */ - ret =cs35l41_request_firmware_file (cs35l41, wmfw_firmware, wmfw_filename, -CS35L41_FIRMWARE_ROOT ,NULL ,NULL ,-1 ,"wmfw" ); -if (!ret) { -/* fallback try cirrus/part-dspN-fwtype.bin */ -cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, -CS35L41_FIRMWARE_ROOT ,NULL ,NULL ,-1 ,"bin" ); -return 0 ; +return cs35l41_request_firmware_file (cs35l41, coeff_firmware, + coeff_filename,CS35L41_FIRMWARE_ROOT , + cs35l41->acpi_subsystem_id,NULL , + cs35l41->speaker_id,"bin" ); } -dev_warn (cs35l41->dev,"Failed to request firmware\n" ); -return ret; }
@@ -258,9 +243,12 @@ static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41, {int ret; -if (cs35l41->speaker_id >-1 ) -return cs35l41_request_firmware_files_spkid (cs35l41, wmfw_firmware, wmfw_filename, - coeff_firmware, coeff_filename); +if (cs35l41->speaker_id >-1 ) { + ret =cs35l41_request_firmware_files_spkid (cs35l41, wmfw_firmware, wmfw_filename, + coeff_firmware, coeff_filename); + goto out; + + }/* try cirrus/part-dspN-fwtype-sub<-ampname>.wmfw */ ret = cs35l41_request_firmware_file(cs35l41, wmfw_firmware, wmfw_filename,
@@ -268,10 +256,11 @@ static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41, cs35l41->amp_name, -1, "wmfw");if (!ret) {/* try cirrus/part-dspN-fwtype-sub<-ampname>.bin */ -cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, -CS35L41_FIRMWARE_ROOT , cs35l41->acpi_subsystem_id, - cs35l41->amp_name,-1 ,"bin" ); -return 0 ; + ret =cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, +CS35L41_FIRMWARE_ROOT , + cs35l41->acpi_subsystem_id, cs35l41->amp_name, +-1 ,"bin" ); + goto out; }/* try cirrus/part-dspN-fwtype-sub.wmfw */
@@ -286,25 +275,35 @@ static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41, cs35l41->amp_name, -1, "bin");if (ret)/* try cirrus/part-dspN-fwtype-sub.bin */ -cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, -CS35L41_FIRMWARE_ROOT , - cs35l41->acpi_subsystem_id, -NULL ,-1 ,"bin" ); -return 0 ; + ret =cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, +CS35L41_FIRMWARE_ROOT , + cs35l41->acpi_subsystem_id,NULL ,-1 , +"bin" ); } +out: +if (!ret) +return 0 ; + +/* Handle fallback */ +dev_warn (cs35l41->dev,"Falling back to default firmware.\n" ); + +release_firmware (*wmfw_firmware); +kfree (*wmfw_filename); +/* fallback try cirrus/part-dspN-fwtype.wmfw */ ret =cs35l41_request_firmware_file (cs35l41, wmfw_firmware, wmfw_filename,CS35L41_FIRMWARE_ROOT ,NULL ,NULL ,-1 ,"wmfw" ); -if (!ret) { +if (!ret)/* fallback try cirrus/part-dspN-fwtype.bin */ -cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, -CS35L41_FIRMWARE_ROOT ,NULL ,NULL ,-1 ,"bin" ); -return 0 ; - } - -dev_warn (cs35l41->dev,"Failed to request firmware\n" ); + ret =cs35l41_request_firmware_file (cs35l41, coeff_firmware, coeff_filename, +CS35L41_FIRMWARE_ROOT ,NULL ,NULL ,-1 ,"bin" ); +if (ret) { +release_firmware (*wmfw_firmware); +kfree (*wmfw_filename); +dev_warn (cs35l41->dev,"Unable to find firmware and tuning\n" ); + }return ret; }
Signature · 1 line
2.34.1
PATCH v2 3/3 ALSA: hda: cs35l41: Enable Amp High Pass Filter
In reply to Stefan BindingThis helps smooth out pops and clicks in the amps.
--- sound/pci/hda/cs35l41_hda.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/pci/hda/cs35l41_hda.c +3 -3
@@ -58,7 +58,7 @@ static const struct reg_sequence cs35l41_hda_config[] = { { CS35L41_DSP1_RX3_SRC, 0x00000018 }, // DSP1RX3 SRC = VMON { CS35L41_DSP1_RX4_SRC, 0x00000019 }, // DSP1RX4 SRC = IMON { CS35L41_DSP1_RX5_SRC, 0x00000020 }, // DSP1RX5 SRC = ERRVOL - { CS35L41_AMP_DIG_VOL_CTRL, 0x00000000 }, // AMP_VOL_PCM 0.0 dB + { CS35L41_AMP_DIG_VOL_CTRL, 0x00008000 }, // AMP_HPF_PCM_EN = 1, AMP_VOL_PCM 0.0 dB { CS35L41_AMP_GAIN_CTRL, 0x00000084 }, // AMP_GAIN_PCM 4.5 dB };
@@ -82,13 +82,13 @@ static const struct reg_sequence cs35l41_hda_config_dsp[] = { { CS35L41_DSP1_RX3_SRC, 0x00000018 }, // DSP1RX3 SRC = VMON { CS35L41_DSP1_RX4_SRC, 0x00000019 }, // DSP1RX4 SRC = IMON { CS35L41_DSP1_RX5_SRC, 0x00000029 }, // DSP1RX5 SRC = VBSTMON - { CS35L41_AMP_DIG_VOL_CTRL, 0x00000000 }, // AMP_VOL_PCM 0.0 dB + { CS35L41_AMP_DIG_VOL_CTRL, 0x00008000 }, // AMP_HPF_PCM_EN = 1, AMP_VOL_PCM 0.0 dB { CS35L41_AMP_GAIN_CTRL, 0x00000233 }, // AMP_GAIN_PCM = 17.5dB AMP_GAIN_PDM = 19.5dB };static const struct reg_sequence cs35l41_hda_mute[] = { {CS35L41_AMP_GAIN_CTRL ,0x00000000 },// AMP_GAIN_PCM 0.5 dB - {CS35L41_AMP_DIG_VOL_CTRL ,0x0000A678 },// AMP_VOL_PCM Mute + {CS35L41_AMP_DIG_VOL_CTRL ,0x0000A678 },// AMP_HPF_PCM_EN = 1, AMP_VOL_PCM Mute };static void cs35l41_add_controls (struct cs35l41_hda *cs35l41)
Signature · 1 line
2.34.1
Takashi Iwai
AppliedQuoted 7 lines · Stefan Binding
Fixes issue in calibration, where return codes were misinterpreted. Enable High Pass filter to reduce pops and clicks.
Add improvement to ensure firmware and tuning files are always loaded together. This ensure the firmware is alsways running with valid coefficients.
Quoted 6 lines
Stefan Binding (2):
ALSA: hda: cs35l41: Ensurefirmware/tuningpairs are always loaded
ALSA: hda: cs35l41: Enable Amp High Pass FilterVitaly Rodionov (1):
ALSA: hda: cs35l41: Correct error condition handling
Applied all three patches now to for-next branch.
thanks,
Takashi