Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp815710lqo; Fri, 17 May 2024 02:22:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJd9L4ae30UK8soSEhcUB5f0oHV+cdT4HJ72s+Uat9xKEbjoE7TX+4/n+XU67yOagAGM0IliRkJwTlAeYh4kS66St2UsyG/tdRQXSQxA== X-Google-Smtp-Source: AGHT+IGTIhSPbXnl4ucHaBfPKANdKBLTs2Q0TBIgqmEL8skXIVsHqd1UEolVFle8JL+6z0Zz78mv X-Received: by 2002:a05:6a21:328e:b0:1af:d044:1395 with SMTP id adf61e73a8af0-1afde0b0c18mr23571650637.20.1715937751760; Fri, 17 May 2024 02:22:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715937751; cv=pass; d=google.com; s=arc-20160816; b=F1mZwVpGrGo0kcomz/0Ya1Vy4xBZ+df6rkDf+JK3z0dYJRvxFn0377l57CoN3Xd/Eo z/XgrOxLsLlzgvEGyqFIYPBqCUWDjhMoYy31wYdng6tJEJkp3CNF81wC8MAzAByAV6o7 wqRpNykvd3qn3+HcerjdwDgilyHJrAuGb6cQVqNjTU28VfEIpYLVW1Q9TcHATWCISnpR /rBCA729NVjyerqlDmU7XsV/feRdLIl/q/FQIJOJ7f/uvrIX5bfcTvY1lmjeNNXTHN3B xPFYw7NpBpSvolklOWS9GqFidbsPBMipCEWdRgeWWCNWQCEWaUb/ZzqWf5LzXoXcyfoN E6+A== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=v/JP+TebD92PX87mV21Jf/D0L7YhRppUzC72Kr69hSk=; fh=ABd84OJQRUrD+A12QMz3wVb/zHQYobBaZgm1K44zlcc=; b=V8S7RMf0IM8OZYR+jy+LTgZA8ib2jvORJsPsdOEa3q8/8VmRskXS2/El9pX0NdGnn5 8X+1WQaZ4idbjYeluw8WSRC+jsUgBZdak6zTzLVzDO0xQ8xYqU3DZJR7R/eKxeabuxk1 Uq2pjCb3gNxZvlqgH/t7oVxu7r7ZNt9nvDIJ47GPaDCRfa5mu2/kI9Vcv5RB2Lht5ijC t/jEdo9uZ5KpNGO6Yd7hLGRt47ttr3mL28k5nI7p8Hl0jv2wjvg1x5EXBGCI+Rx1ysru HVlnb9wxAsxWlMEuRPW6VLuBViv/ggzfsJFCUwWQ4XYenzT/N3UgQrqvQp9N4xqoxM/S xA7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=x3z+gZAP; 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-181911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181911-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 98e67ed59e1d1-2b670f4e141si17611829a91.50.2024.05.17.02.22.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 02:22:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181911-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=x3z+gZAP; 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-181911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181911-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 C8787B216B1 for ; Fri, 17 May 2024 09:22:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25900288A4; Fri, 17 May 2024 09:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="x3z+gZAP" 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 61FB022EF8 for ; Fri, 17 May 2024 09:22:17 +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=1715937739; cv=none; b=fA/6vSMABGIxqVnP2yylqLUgRRRfm66NmtvuL7+bOpnEN3F1jJAsAMioqIyHmixBoEFN97Rtv5jZXH6PH46m1iv2wtKNiyQsSs97/RWCrwHCOap52QS1ooexXDiSyAjYio40foKrQsPqm6GKm2YRpjzsujg+SktolYlRb566lNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715937739; c=relaxed/simple; bh=I351u7aT7I6ouH4KN0hZjNx1w49MRdZV/3oL7OssEN0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UNEQuJxJuLu3pmtu1mgIy/FjlCrFAFe6ce79Lcr39vS1937X6A8BFIvh8naa9zSJNqXXlK28tqaIdIL5UJg/zYC/Adetid+JNPSCNp5/3v6e0HIwmKDfJbjNThaRKFx9l9UW6Bb/H2M6SVmJ0gkeBxtl6g1y2YrncYntw+2UZfw= 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=x3z+gZAP; 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 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44H9KuE1081883; Fri, 17 May 2024 04:20:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1715937656; bh=v/JP+TebD92PX87mV21Jf/D0L7YhRppUzC72Kr69hSk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=x3z+gZAPpmIPkpTxCQM/9VMVbDxQzljZT/MrOkCITi4ME2UK7m9Q+hcfsUgD4cqWx ssSNSv9cgEUIPT1YkSVV8LB901o0vD4pQPUdfBldDc7TR368WtcAM9gng8MRE/tvu0 sPWhaOiy1zsCUmr3w1g3egChgxDgBawPf8wcCwLM= Received: from DFLE101.ent.ti.com (dfle101.ent.ti.com [10.64.6.22]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44H9KuqL129367 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 17 May 2024 04:20:56 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) 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; Fri, 17 May 2024 04:20:55 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE110.ent.ti.com (10.64.6.31) 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; Fri, 17 May 2024 04:20:55 -0500 Received: from LT5CG31242FY.dhcp.ti.com (lt5cg31242fy.dhcp.ti.com [10.85.14.114]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44H9KhXr036740; Fri, 17 May 2024 04:20:50 -0500 From: Shenghao Ding To: CC: , , , , <13916275206@139.com>, , , , , , , , , , , , Shenghao Ding Subject: [RESEND PATCH v5 2/3] ASoC: tas2781: Fix wrong loading calibrated data sequence Date: Fri, 17 May 2024 17:20:37 +0800 Message-ID: <20240517092039.688-2-shenghao-ding@ti.com> X-Mailer: git-send-email 2.33.0.windows.2 In-Reply-To: <20240517092039.688-1-shenghao-ding@ti.com> References: <20240517092039.688-1-shenghao-ding@ti.com> 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: ef3bcde75d06 ("ASoc: tas2781: Add tas2781 driver") Signed-off-by: Shenghao Ding --- v5: - No change. v4: - Use the the culprit of the bug itself as the fixes tag. - Better variant for tasdev_load_calibrated_data in order to much easier to read and understand and maintain, as it makes harder to squeeze the code. - Fix the indentation and move operator to the previous line. 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-lkp@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 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. --- sound/soc/codecs/tas2781-fmwlib.c | 103 ++++++++---------------------- 1 file changed, 27 insertions(+), 76 deletions(-) diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-fmwlib.c index a6be81adcb83..265a8ca25cbb 100644 --- a/sound/soc/codecs/tas2781-fmwlib.c +++ b/sound/soc/codecs/tas2781-fmwlib.c @@ -2151,6 +2151,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) { @@ -2210,21 +2228,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; - } } } @@ -2245,11 +2251,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", @@ -2308,65 +2318,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; -- 2.34.1