From nobody Wed Dec 17 20:41:14 2025 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BC4557C96 for ; Thu, 2 May 2024 23:26:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714692381; cv=none; b=H1dyIQHqzEdxKU1SOR5KFLB1Nmk7M2nPlY3RnhbT+QiMsNf12hn6XYMy8jpMdXAxw1iCBMX70AC2Np3qJADRTiwm6cpLBftIGaTJuM85LuW5VAFSogi+l281Qb5EtI7E1eIbGkkA8DkDeCenr+oze2SSSVFoL106lJGcXe7NLK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714692381; c=relaxed/simple; bh=qXSaDu9v+OXECWQi18wi0ASMKFCVuk1uyWzeP00KOSQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ZOd+2/NTIuqGvkJjnqv7W7DXLE8tSEpDEuiM/t9qC4XWVLJmEr0cCMVwCcJ7QQWdpDJ3+/lUwuBhtqKPv6yNq61XkZQkPNcB5UrRu1e25djJ0GTyY4Vap2Mf2sdFqjnDE6v+bl4k2tPLg1nKx3rkdKY+3zDESn6H0ixz19gK7Tg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=RPBSwNXb; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="RPBSwNXb" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 442NP2P4097410; Thu, 2 May 2024 18:25:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714692302; bh=1Igba9qc/3JOdjDKcJji6d5T+uHCRoguonaIxhTWhTE=; h=From:To:CC:Subject:Date; b=RPBSwNXbIpYxngufDIi3Sa2A2mQ27zZZ4VqtH7FrkoaWJhmRgSAVHZ8cEX/1AeH9/ 6MR0yUTJy8EOa6GrcNdTCdCiQC91jri7l6ue9lXGTJApYMd5yt1xTWS0cBa1XtsFE0 MYRNQR3IjrbjozQzy1qB8jBbCA3ScMvvjtQGNwy8= Received: from DFLE101.ent.ti.com (dfle101.ent.ti.com [10.64.6.22]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 442NP2bT057493 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 2 May 2024 18:25:02 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 2 May 2024 18:25:01 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 2 May 2024 18:25:01 -0500 Received: from LT5CG31242FY.dhcp.ti.com ([10.250.160.109]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 442NOtIA110098; Thu, 2 May 2024 18:24:56 -0500 From: Shenghao Ding To: CC: , , , , <13916275206@139.com>, , , , , , , , , , , , Shenghao Ding Subject: [PATCH v3] ALSA: ASoc/tas2781: Fix wrong loading calibrated data sequence Date: Fri, 3 May 2024 07:24:49 +0800 Message-ID: <20240502232450.484-1-shenghao-ding@ti.com> X-Mailer: git-send-email 2.33.0.windows.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Content-Type: text/plain; charset="utf-8" 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"")' Signed-off-by: Shenghao Ding --- 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 | Closes: https://lore.kernel.org/oe-kbuild-all/202405021200.YHInjV43-lk= p@intel.com/ 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(-) diff --git a/include/sound/tas2781-dsp.h b/include/sound/tas2781-dsp.h index ea9af2726a53..7fba7ea26a4b 100644 --- a/include/sound/tas2781-dsp.h +++ b/include/sound/tas2781-dsp.h @@ -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 // =20 -#ifndef __TASDEVICE_DSP_H__ -#define __TASDEVICE_DSP_H__ +#ifndef __TAS2781_DSP_H__ +#define __TAS2781_DSP_H__ =20 #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); diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-f= mwlib.c index 45760fe19523..2ab4c7a55b90 100644 --- a/sound/soc/codecs/tas2781-fmwlib.c +++ b/sound/soc/codecs/tas2781-fmwlib.c @@ -2,7 +2,7 @@ // // tasdevice-fmw.c -- TASDEVICE firmware support // -// Copyright 2023 Texas Instruments, Inc. +// Copyright 2023 - 2024 Texas Instruments, Inc. // // Author: Shenghao Ding =20 @@ -1878,7 +1878,7 @@ int tas2781_load_calibration(void *context, char *fil= e_name, { struct tasdevice_priv *tas_priv =3D (struct tasdevice_priv *)context; struct tasdevice *tasdev =3D &(tas_priv->tasdevice[i]); - const struct firmware *fw_entry; + const struct firmware *fw_entry =3D NULL; struct tasdevice_fw *tas_fmw; struct firmware fmw; int offset =3D 0; @@ -2151,6 +2151,18 @@ static int tasdevice_load_data(struct tasdevice_priv= *tas_priv, return ret; } =20 +static void tasdev_load_calibrated_data(struct tasdevice_priv *priv, int i) +{ + struct tasdevice_fw *cal_fmw =3D priv->tasdevice[i].cali_data_fmw; + + if (cal_fmw) { + struct tasdevice_calibration *cal =3D cal_fmw->calibrations; + + if (cal) + load_calib_data(priv, &cal->dev_data); + } +} + int tasdevice_select_tuningprm_cfg(void *context, int prm_no, int cfg_no, int rca_conf_no) { @@ -2210,21 +2222,9 @@ int tasdevice_select_tuningprm_cfg(void *context, in= t prm_no, for (i =3D 0; i < tas_priv->ndev; i++) { if (tas_priv->tasdevice[i].is_loaderr =3D=3D true) continue; - else if (tas_priv->tasdevice[i].is_loaderr =3D=3D false - && tas_priv->tasdevice[i].is_loading =3D=3D true) { - struct tasdevice_fw *cal_fmw =3D - tas_priv->tasdevice[i].cali_data_fmw; - - if (cal_fmw) { - struct tasdevice_calibration - *cal =3D cal_fmw->calibrations; - - if (cal) - load_calib_data(tas_priv, - &(cal->dev_data)); - } + if (tas_priv->tasdevice[i].is_loaderr =3D=3D false + && tas_priv->tasdevice[i].is_loading =3D=3D true) tas_priv->tasdevice[i].cur_prog =3D prm_no; - } } } =20 @@ -2247,9 +2247,13 @@ int tasdevice_select_tuningprm_cfg(void *context, in= t prm_no, if (tas_priv->tasdevice[i].is_loaderr =3D=3D true) { status |=3D 1 << (i + 4); continue; - } else if (tas_priv->tasdevice[i].is_loaderr =3D=3D false - && tas_priv->tasdevice[i].is_loading =3D=3D true) + } + + if (tas_priv->tasdevice[i].is_loaderr =3D=3D false + && tas_priv->tasdevice[i].is_loading =3D=3D true) { + tasdev_load_calibrated_data(tas_priv, i); tas_priv->tasdevice[i].cur_conf =3D cfg_no; + } } } else dev_dbg(tas_priv->dev, "%s: Unneeded loading dsp conf %d\n", @@ -2308,65 +2312,6 @@ int tasdevice_prmg_load(void *context, int prm_no) } EXPORT_SYMBOL_NS_GPL(tasdevice_prmg_load, SND_SOC_TAS2781_FMWLIB); =20 -int tasdevice_prmg_calibdata_load(void *context, int prm_no) -{ - struct tasdevice_priv *tas_priv =3D (struct tasdevice_priv *) context; - struct tasdevice_fw *tas_fmw =3D tas_priv->fmw; - struct tasdevice_prog *program; - int prog_status =3D 0; - int i; - - if (!tas_fmw) { - dev_err(tas_priv->dev, "%s: Firmware is NULL\n", __func__); - goto out; - } - - if (prm_no >=3D 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 =3D 0, prog_status =3D 0; i < tas_priv->ndev; i++) { - if (prm_no >=3D 0 && tas_priv->tasdevice[i].cur_prog !=3D prm_no) { - tas_priv->tasdevice[i].cur_conf =3D -1; - tas_priv->tasdevice[i].is_loading =3D true; - prog_status++; - } - tas_priv->tasdevice[i].is_loaderr =3D false; - } - - if (prog_status) { - program =3D &(tas_fmw->programs[prm_no]); - tasdevice_load_data(tas_priv, &(program->dev_data)); - for (i =3D 0; i < tas_priv->ndev; i++) { - if (tas_priv->tasdevice[i].is_loaderr =3D=3D true) - continue; - else if (tas_priv->tasdevice[i].is_loaderr =3D=3D false - && tas_priv->tasdevice[i].is_loading =3D=3D true) { - struct tasdevice_fw *cal_fmw =3D - tas_priv->tasdevice[i].cali_data_fmw; - - if (cal_fmw) { - struct tasdevice_calibration *cal =3D - cal_fmw->calibrations; - - if (cal) - load_calib_data(tas_priv, - &(cal->dev_data)); - } - tas_priv->tasdevice[i].cur_prog =3D 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 =3D (struct tasdevice_priv *) context; diff --git a/sound/soc/codecs/tas2781-i2c.c b/sound/soc/codecs/tas2781-i2c.c index b5abff230e43..9350972dfefe 100644 --- a/sound/soc/codecs/tas2781-i2c.c +++ b/sound/soc/codecs/tas2781-i2c.c @@ -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 *f= mw, __func__, tas_priv->cal_binaryname[i]); } =20 - tasdevice_prmg_calibdata_load(tas_priv, 0); + tasdevice_prmg_load(tas_priv, 0); tas_priv->cur_prog =3D 0; out: if (tas_priv->fw_state =3D=3D TASDEVICE_DSP_FW_FAIL) { --=20 2.34.1