Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp433517lqm; Wed, 1 May 2024 05:28:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUC1sSa+NFhejtRU3Ch61daTyV/GYB8yxkSZqofIMH4AfhVixoydScCnMwtOxPKVKepn2nqBITnJ3AmGnL4fbwpSAVTEwFyBYF4ZdOuwg== X-Google-Smtp-Source: AGHT+IGPtbzQnDmRkLu/jkyXaKOXAs0JelpCUN6Va2TCfqx7F0tPYJM0LF0uqXFdmEMKQt7D4N7R X-Received: by 2002:a17:903:22ce:b0:1e1:6850:f823 with SMTP id y14-20020a17090322ce00b001e16850f823mr2462106plg.13.1714566518783; Wed, 01 May 2024 05:28:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714566518; cv=pass; d=google.com; s=arc-20160816; b=nYB2JHwBgdwZA3wQ0zQ88Gw/Gy1NYtSTjAr8IvT5Eqclyynqv6jlqgRj3aEJXTQMOs 218azw+xI2nBSwCWikiNaa9bB1GnxDe9EkWuTGfSHuaD59Zpqzxqz46n2N5AGWV7pqUR jXQ3Sl9dF+kV0T9KJlSN8IWAo3rfGp8K4wOq1B51buSZZCTzVEIoUIpsySaizC/lonXP an3YjIgxUxf5UoKTAnxUVseQoMol61cXftP5Hy4GZBI+qgvHVZHQ4EBtYmZAWvV+DaNo 6kRIgpdyd/1qV5+nQ5a2yB8titGKHEyHQ6Rz0dXhc65va3wZ+aTo4TV4HRMtdK8zmBK5 hh/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=LzZ/t7t/FM96l7qsRcnfi3T22p23/zeE2lnAV0eULX0=; fh=PG225YqQA+oxmyhCBCJfJTCcpgIDt6QapgveX+5b1TE=; b=Cv4g91WkNQKqb9MCgt/hxnTycqFolKJ3YvHPJdQvU62bR8Ln3jshOkdivRKqFO8egd leFnbUvNTduZywuxQuOcANT638UTml7J2LElCMVF4ydvn+DezRT3JiLewfP5DS+8FW+k LstSFLIXE2t5Dtm69C2sfeYJVETob1wjl0FjsdiDOcHq7tp8g5eQN2hKpYbjI+8PXfCn I9twkeFdOIf+hrn0x35XzFufup+5P9StZ8UBmK+BLX0lcnpnFIYB8W9Pwt7nPo9Sepuf YgP3r5QZDCiNKnLWnubP3wUL3ko4TJPpYwRKsyOZqQ6h4HZj5cjg8ONDl/4hHXrrQUlG Xwdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=YpaItMYL; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-165236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ck18-20020a17090afe1200b002a2140cc869si1389768pjb.130.2024.05.01.05.28.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:28:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=YpaItMYL; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-165236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C6D93B23ECB for ; Wed, 1 May 2024 12:25:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAF301272AF; Wed, 1 May 2024 12:24:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="YpaItMYL" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 B948A85923 for ; Wed, 1 May 2024 12:24:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714566280; cv=none; b=YVbhrqTWWGVUWuEyUsdy0gkokg+irIDROl4lagjuNHF1rE+UxzIuJQQ1tU9vHiiXWqEn08TDo2mi/DRD7VFPktSthnqfS35YnyVSdFgXsy2YsZzbsykdJ5Y7tepytRqjAhecfzOa0IvEhjlwgutzFGT7XXJU2s9NQtao7p0d/B0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714566280; c=relaxed/simple; bh=QQttAjkWsqg4VXZTAH5YeoEfGOe259wZhk6ldrPF234=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=E1n0ZQ8M82aH8DGxiCO6y4mijsdjToRmXXdGrBtf0h6a4ibArKeGbJdUWJEGFH/Cq9zBc6fjEXbkAWBu+/NCk0wcXdPIqju4A9FBenEzF/Fz2EvXrB5fjdX1fz0CsSbKxEsPhSTjiHCh4i7islJldHP/njrESMjjhtWealEZicQ= 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=YpaItMYL; arc=none smtp.client-ip=198.47.23.248 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 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 441CN8m8071177; Wed, 1 May 2024 07:23:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714566188; bh=LzZ/t7t/FM96l7qsRcnfi3T22p23/zeE2lnAV0eULX0=; h=From:To:CC:Subject:Date; b=YpaItMYLGpPIdyeRT+MWR16VgCnXowS/1u1bq3OMnGT2vsRf8H1Fh47HcdqjKOm9/ UntQFWn7swM7fsFog8+OH+nQTTXQUrQC62fwPt2mmo9EiM7O4sI9lkr/gu2uNdy3RM BEh76JnFXeVIbzs627Wf0tt6VJChwdC2MLaY/9hE= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 441CN8vi092019 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 1 May 2024 07:23:08 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 1 May 2024 07:23:08 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE111.ent.ti.com (10.64.6.32) 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; Wed, 1 May 2024 07:23:08 -0500 Received: from LT5CG31242FY.dhcp.ti.com ([10.250.160.109]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 441CN1EP113570; Wed, 1 May 2024 07:23:02 -0500 From: Shenghao Ding To: CC: , , , , <13916275206@139.com>, , , , , , , , , , , , , Shenghao Ding Subject: [PATCH v2] ALSA: ASoc/tas2781: Fix wrong loading calibrated data sequence Date: Wed, 1 May 2024 20:22:50 +0800 Message-ID: <20240501122252.1215-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: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 --- 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, 28 insertions(+), 82 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 // -#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); diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-fmwlib.c index 45760fe19523..5a4095c6a954 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 @@ -2151,6 +2151,20 @@ 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_fw *cal_fmw = priv->tasdevice[i].cali_data_fmw; + + if (cal_fmw) { + struct tasdevice_calibration *cal = cal_fmw->calibrations; + + if (cal) + load_calib_data(priv, &cal->dev_data); + return; + } +} + int tasdevice_select_tuningprm_cfg(void *context, int prm_no, int cfg_no, int rca_conf_no) { @@ -2210,21 +2224,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; - } } } @@ -2247,9 +2249,13 @@ int tasdevice_select_tuningprm_cfg(void *context, int prm_no, if (tas_priv->tasdevice[i].is_loaderr == true) { status |= 1 << (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", @@ -2308,65 +2314,6 @@ int tasdevice_prmg_load(void *context, int prm_no) } 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; 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 *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) { -- 2.34.1