ALSA: ASoc/tas2781: Fix wrong loading calibrated data sequence
Subsystems (3)
Shenghao Ding
maintainerPATCH v3 1/1 ALSA: ASoc/tas2781: Fix wrong loading calibrated data sequence
Calibrated data will be set to default after loading DSP config params, which will cause speaker protection work abnormally. Reload calibrated data after loading DSP config params.
'Fixes: 0a0877812628 ("ASoc: tas2781: Fix spelling mistake "calibraiton"
-> "calibration"")'
---
v3:
- Remove redundant return in tasdev_load_calibrated_data
- Put the second function parameter into the previous line for tasdev_load_calibrated_data
- | Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
v2:
- In the Subject, fixed --> Fix
- In tas2781-fmwlib.c, tasdevice-fmw.c ---> tas2781-fmwlib.c
- dsp --> DSP
- Remove unneeded parentheses for & (dereference) operator
- Add Fixes tag
- Changed the copyright year to 2024 in the related files
- In tas2781-dsp.h, __TASDEVICE_DSP_H__ --> __TAS2781_DSP_H__
v1:
- Download calibrated data after loading the new DSP config params
- call tasdevice_prmg_load instead of tasdevice_prmg_calibdata_load, it is unnecessary to load calibrated data after loading DSP program. Load it after loading DSP config params each time.
- Remove tasdevice_prmg_calibdata_load, because it is unnecessary to load calibrated data after loading DSP program.
--- include/sound/tas2781-dsp.h | 7 +-- sound/soc/codecs/tas2781-fmwlib.c | 99 +++++++------------------------ sound/soc/codecs/tas2781-i2c.c | 4 +- 3 files changed, 27 insertions(+), 83 deletions(-)
include/sound/tas2781-dsp.h +3 -4
@@ -2,7 +2,7 @@// // ALSA SoC Texas Instruments TAS2781 Audio Smart Amplifier // -// Copyright (C) 2022 - 2023 Texas Instruments Incorporated +// Copyright (C) 2022 - 2024 Texas Instruments Incorporated // https://www.ti.com // // The TAS2781 driver implements a flexible and configurable
@@ -13,8 +13,8 @@// Author: Kevin Lu <[email protected]> // -#ifndef __TASDEVICE_DSP_H__ -#define __TASDEVICE_DSP_H__ +#ifndef __TAS2781_DSP_H__ +#define __TAS2781_DSP_H__#define MAIN_ALL_DEVICES 0x0d#define MAIN_DEVICE_A 0x01
@@ -180,7 +180,6 @@ void tasdevice_calbin_remove(void *context);int tasdevice_select_tuningprm_cfg (void *context,int prm,int cfg_no,int rca_conf_no);int tasdevice_prmg_load (void *context,int prm_no); -int tasdevice_prmg_calibdata_load (void *context,int prm_no);void tasdevice_tuning_switch (void *context,int state);int tas2781_load_calibration (void *context,char *file_name,unsigned short i);
sound/soc/codecs/tas2781-fmwlib.c +22 -77
137 lines not on this page · raw message
sound/soc/codecs/tas2781-i2c.c +2 -2
@@ -2,7 +2,7 @@// // ALSA SoC Texas Instruments TAS2563/TAS2781 Audio Smart Amplifier // -// Copyright (C) 2022 - 2023 Texas Instruments Incorporated +// Copyright (C) 2022 - 2024 Texas Instruments Incorporated // https://www.ti.com // // The TAS2563/TAS2781 driver implements a flexible and configurable
@@ -414,7 +414,7 @@ static void tasdevice_fw_ready(const struct firmware *fmw, __func__, tas_priv->cal_binaryname[i]); } -tasdevice_prmg_calibdata_load (tas_priv,0 ); +tasdevice_prmg_load (tas_priv,0 ); tas_priv->cur_prog =0 ; out:if (tas_priv->fw_state ==TASDEVICE_DSP_FW_FAIL ) {
Signature · 1 line
2.34.1
Quoted 7 lines · Shenghao Ding
Calibrated data will be set to default after loading DSP config params, which will cause speaker protection work abnormally. Reload calibrated data after loading DSP config params.
'Fixes:
0a0877812628("ASoc: tas2781: Fix spelling mistake "calibraiton"
-> "calibration"")'
This usage of Fixes tag is utterly wrong: first off, drop the single quote of the whole line. Moreover, the suggested commit looks very dubious. It's merely a change to correct spelling, and this can't be the culprit of the bug itself. Please point to the right commit.
include/sound/tas2781-dsp.h line 17
Quoted 8 lines
include/sound/tas2781-dsp.h +2
-2@@ -13,8 +13,8 @@// Author: Kevin Lu <[email protected]> // -#ifndef __TASDEVICE_DSP_H__ -#define __TASDEVICE_DSP_H__ +#ifndef __TAS2781_DSP_H__ +#define __TAS2781_DSP_H__
This is unnecessary / related change, better to keep or do it in another patch.
sound/soc/codecs/tas2781-fmwlib.c int tas2781_load_calibration(void *context, char *file_name, · line 1881
Quoted 6 lines
sound/soc/codecs/tas2781-fmwlib.c +1
-1@@ -1878,7 +1878,7 @@ int tas2781_load_calibration(void *context, char *file_name, {struct tasdevice_priv *tas_priv = (struct tasdevice_priv *)context;struct tasdevice *tasdev = &(tas_priv->tasdevice[i]); -const struct firmware *fw_entry; +const struct firmware *fw_entry =NULL ;
Why is this needed? If a NULL initialization is a must (for some warning fix or whatever), do it in an individual fix patch instead.
The rest changes look OK, but it's a bit hard to judge because the code has too few comments, unfortunately...
thanks,
Takashi
Quoted 3 lines · Shenghao Ding
Calibrated data will be set to default after loading DSP config params, which will cause speaker protection work abnormally. Reload calibrated data after loading DSP config params.
...
sound/soc/codecs/tas2781-fmwlib.c static int tasdevice_load_data(struct tasdevice_priv *tas_priv, · line 2158
Quoted 6 lines
sound/soc/codecs/tas2781-fmwlib.c +5
-0+static void tasdev_load_calibrated_data (struct tasdevice_priv *priv,int i) +{ +struct tasdevice_fw *cal_fmw = priv->tasdevice[i].cali_data_fmw; + +if (cal_fmw) {
Better variant is
struct tasdevice_calibration *cal; struct tasdevice_fw *cal_fmw; cal_fmw = priv->tasdevice[i].cali_data_fmw; if (!cal_fmw) return;
sound/soc/codecs/tas2781-fmwlib.c static int tasdevice_load_data(struct tasdevice_priv *tas_priv, · line 2163
Quoted 5 lines
sound/soc/codecs/tas2781-fmwlib.c +5
-0+struct tasdevice_calibration *cal = cal_fmw->calibrations; + +if (cal) +load_calib_data (priv, &cal->dev_data); + }
In the similar way
cal = cal_fmw->calibrations; if (!cal) return; load_calib_data(priv, &cal->dev_data);
Quoted 1 line
+}
The result is much easier to read and understand and maintain, as it makes harder to squeeze the code between initialization and use and breaking things.
...
sound/soc/codecs/tas2781-fmwlib.c int tasdevice_select_tuningprm_cfg(void *context, int prm_no, · line 2227
Quoted 3 lines
sound/soc/codecs/tas2781-fmwlib.c +2
-0+if (tas_priv->tasdevice[i].is_loaderr == false + && tas_priv->tasdevice[i].is_loading == true) tas_priv->tasdevice[i].cur_prog = prm_no;
While at it, make it better (fix the indentation and move operator to the previous line):
if (tas_priv->tasdevice[i].is_loaderr == false && tas_priv->tasdevice[i].is_loading == true) tas_priv->tasdevice[i].cur_prog = prm_no;
...
sound/soc/codecs/tas2781-fmwlib.c int tasdevice_select_tuningprm_cfg(void *context, int prm_no, · line 2248
Quoted 2 lines
sound/soc/codecs/tas2781-fmwlib.c +0
-0if (tas_priv->tasdevice[i].is_loaderr == true) { status |=1 << (i +4 );
Side note: Use BIT()
Quoted 1 line
continue;
...
sound/soc/codecs/tas2781-fmwlib.c int tasdevice_select_tuningprm_cfg(void *context, int prm_no, · line 2253
Quoted 2 lines
sound/soc/codecs/tas2781-fmwlib.c +2
-0+if (tas_priv->tasdevice[i].is_loaderr == false + && tas_priv->tasdevice[i].is_loading == true) {
As per above.
Quoted 3 lines
sound/soc/codecs/tas2781-fmwlib.c +2
-0+tasdev_load_calibrated_data (tas_priv, i); tas_priv->tasdevice[i].cur_conf = cfg_no; + }
Signature · 2 lines
With Best Regards, Andy Shevchenko