ASoC: tas2781: Fix wrong loading calibrated data sequence

[ Upstream commit b195acf526 ]

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. Remove declaration of unused API
which load calibrated data in wrong sequence, changed the copyright year
and correct file name in license
header.

Fixes: ef3bcde75d ("ASoC: tas2781: Add tas2781 driver")
Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>
Link: https://msgid.link/r/20240518141546.1742-1-shenghao-ding@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Shenghao Ding 2024-05-18 22:15:46 +08:00 committed by Greg Kroah-Hartman
parent 92503b5caa
commit 57847c2ec5
3 changed files with 32 additions and 82 deletions

View File

@ -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 <kevin-lu@ti.com>
//
#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
@ -175,7 +175,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);

View File

@ -2181,6 +2181,24 @@ static int tasdevice_load_data(struct tasdevice_priv *tas_priv,
return ret;
}
static void tasdev_load_calibrated_data(struct tasdevice_priv *priv, int i)
{
struct tasdevice_calibration *cal;
struct tasdevice_fw *cal_fmw;
cal_fmw = priv->tasdevice[i].cali_data_fmw;
/* No calibrated data for current devices, playback will go ahead. */
if (!cal_fmw)
return;
cal = cal_fmw->calibrations;
if (cal)
return;
load_calib_data(priv, &cal->dev_data);
}
int tasdevice_select_tuningprm_cfg(void *context, int prm_no,
int cfg_no, int rca_conf_no)
{
@ -2240,21 +2258,9 @@ int tasdevice_select_tuningprm_cfg(void *context, int prm_no,
for (i = 0; i < tas_priv->ndev; i++) {
if (tas_priv->tasdevice[i].is_loaderr == true)
continue;
else if (tas_priv->tasdevice[i].is_loaderr == false
&& tas_priv->tasdevice[i].is_loading == true) {
struct tasdevice_fw *cal_fmw =
tas_priv->tasdevice[i].cali_data_fmw;
if (cal_fmw) {
struct tasdevice_calibration
*cal = cal_fmw->calibrations;
if (cal)
load_calib_data(tas_priv,
&(cal->dev_data));
}
if (tas_priv->tasdevice[i].is_loaderr == false &&
tas_priv->tasdevice[i].is_loading == true)
tas_priv->tasdevice[i].cur_prog = prm_no;
}
}
}
@ -2275,11 +2281,15 @@ int tasdevice_select_tuningprm_cfg(void *context, int prm_no,
tasdevice_load_data(tas_priv, &(conf->dev_data));
for (i = 0; i < tas_priv->ndev; i++) {
if (tas_priv->tasdevice[i].is_loaderr == true) {
status |= 1 << (i + 4);
status |= BIT(i + 4);
continue;
} else if (tas_priv->tasdevice[i].is_loaderr == false
&& tas_priv->tasdevice[i].is_loading == true)
}
if (tas_priv->tasdevice[i].is_loaderr == false &&
tas_priv->tasdevice[i].is_loading == true) {
tasdev_load_calibrated_data(tas_priv, i);
tas_priv->tasdevice[i].cur_conf = cfg_no;
}
}
} else
dev_dbg(tas_priv->dev, "%s: Unneeded loading dsp conf %d\n",
@ -2338,65 +2348,6 @@ out:
}
EXPORT_SYMBOL_NS_GPL(tasdevice_prmg_load, SND_SOC_TAS2781_FMWLIB);
int tasdevice_prmg_calibdata_load(void *context, int prm_no)
{
struct tasdevice_priv *tas_priv = (struct tasdevice_priv *) context;
struct tasdevice_fw *tas_fmw = tas_priv->fmw;
struct tasdevice_prog *program;
int prog_status = 0;
int i;
if (!tas_fmw) {
dev_err(tas_priv->dev, "%s: Firmware is NULL\n", __func__);
goto out;
}
if (prm_no >= tas_fmw->nr_programs) {
dev_err(tas_priv->dev,
"%s: prm(%d) is not in range of Programs %u\n",
__func__, prm_no, tas_fmw->nr_programs);
goto out;
}
for (i = 0, prog_status = 0; i < tas_priv->ndev; i++) {
if (prm_no >= 0 && tas_priv->tasdevice[i].cur_prog != prm_no) {
tas_priv->tasdevice[i].cur_conf = -1;
tas_priv->tasdevice[i].is_loading = true;
prog_status++;
}
tas_priv->tasdevice[i].is_loaderr = false;
}
if (prog_status) {
program = &(tas_fmw->programs[prm_no]);
tasdevice_load_data(tas_priv, &(program->dev_data));
for (i = 0; i < tas_priv->ndev; i++) {
if (tas_priv->tasdevice[i].is_loaderr == true)
continue;
else if (tas_priv->tasdevice[i].is_loaderr == false
&& tas_priv->tasdevice[i].is_loading == true) {
struct tasdevice_fw *cal_fmw =
tas_priv->tasdevice[i].cali_data_fmw;
if (cal_fmw) {
struct tasdevice_calibration *cal =
cal_fmw->calibrations;
if (cal)
load_calib_data(tas_priv,
&(cal->dev_data));
}
tas_priv->tasdevice[i].cur_prog = prm_no;
}
}
}
out:
return prog_status;
}
EXPORT_SYMBOL_NS_GPL(tasdevice_prmg_calibdata_load,
SND_SOC_TAS2781_FMWLIB);
void tasdevice_tuning_switch(void *context, int state)
{
struct tasdevice_priv *tas_priv = (struct tasdevice_priv *) context;

View File

@ -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
@ -412,7 +412,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) {