Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp539869lqb; Wed, 29 May 2024 03:38:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzzwOa5o0VEEwsaSJ0aRgvpphVpTcIWIMCY4L06aMcSbTaSkWQcANJM4oksbZM9EHTIvmbu1leywpRPy3PCVyafw/D/NUJk26ztz+CqA== X-Google-Smtp-Source: AGHT+IHJoV1lF690BVTNsTfa2JHz6VgcdY91goMgvTTGE7dzLw1o3Nf7LWn2sF72tTjdk/XZl8q6 X-Received: by 2002:a25:bcc:0:b0:df7:9295:ffc5 with SMTP id 3f1490d57ef6-df792962f60mr10680769276.5.1716979086534; Wed, 29 May 2024 03:38:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716979086; cv=pass; d=google.com; s=arc-20160816; b=bBN7B+99W6dtSq/lHA4bVvEk3CwYlPmCovRH9cjPO7I09sQqqeh28DB6AY/hcm99QG UmSrZiP2pi58x0rHsGhfxw/LjdVJAsIx6ncswulT2kwVlKbR46cq9y+4/4W0MErFWBtE z7p6CBbfoiV6LlQ4Qd7NYji6cdNjuhdnwK/FcZ3MEVx55OGXXaN5DEGIXg9M+SSO0nj3 KW/fJD2IYanPtOOIzaFKpWCg5l9ibLsQMBJ9XKUQpdxRx/RhGiVKUXBnD7xpKJueyao/ m4Z/K+1Eink1sHKv7WFnaJshC/dctDw7G+Czx19XiDzzppUDlcjO5/KUCwe/LUAEukLN V5IQ== 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=gbTce+LVcO4bL3KUBnZa++UMz5RC5JOaMX/CYP78Ezc=; fh=W+19KStTqcW5oWbYNylwb8RIB9rIZpBaPGCCGg164Pk=; b=bLc+v3x1LJxBbI0M2Lg+2nvGyXltQUO1terfFmhuVYmflcNjeoLqiqb5PZRYjAnr6g Xf8x+/oYwuaL4FsJVIvmrANSjoU8gt1JeW/iImrKaP2l7yKkGoEAnTfDTP/uIm9eJc4j 0I9X3DnH3rMmoUn0M8urtj2ZFOIg+lsZUBLvBI2RH9sWpak+4NhrJmkIt/VP24idKy+v rGDR79Ung9JcbuLbHE1AkvQpGWcwQCPK2g26Y59hkcnWlQ3ChpsfxIu6XzJvZHDu8J4L ZWIXSCSUj5GDHBew1ftzVFxpvEN7mFNYbQvq6qLkSu1JEMSlTI0rL58Pudtq4UBuQ7cF woaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=u3kqZZY0; 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-193968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ac1616ae02si124558266d6.361.2024.05.29.03.38.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 03:38:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=u3kqZZY0; 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-193968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193968-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2A07E1C244F9 for ; Wed, 29 May 2024 10:37:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB55317B43A; Wed, 29 May 2024 10:37:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="u3kqZZY0" 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 9442C17B50B for ; Wed, 29 May 2024 10:37:25 +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=1716979048; cv=none; b=duoMfEwW2Db/CTym3UzxnupWjSbZ/WmjFbZ4c/DZI31WT4HUaUKEKd/6jH0LspcHu8H8d6qlZ2m1fSERfZ/pd0NiiLa6KBDtnKkx/4PhL/j1/W7FGzVFXyRw+c9UNDyK9yfUHEQrUXFmuB0F9XzyIKuSJopy4VZBjmDJ9uPQ0tQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716979048; c=relaxed/simple; bh=RRhep4tQqxUgLf/+iYgoXbZOV9YBI9NwCmFOsL9sl5w=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=EBXROvRbtoy+tgELfzhKprBbaA5r8rS2nFWrnm4VzziqQ9KG0EjDfEWh5wJPihumVLtCQr8/NRa1ftYqD4Eh2rGZV1c8EWHlSDV712F48EthCYkh4FPhbHH8iuN+XHJpX6jYuA3Bf9OC5m0gXrTseO+g2PkjqS4hd9j+gAZFd3E= 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=u3kqZZY0; 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 44TAZwoX127872; Wed, 29 May 2024 05:35:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1716978958; bh=gbTce+LVcO4bL3KUBnZa++UMz5RC5JOaMX/CYP78Ezc=; h=From:To:CC:Subject:Date; b=u3kqZZY0LKmxp/QLo4TJ+YtAhr0OITDfEP2MApf36JkCSKJEobaIvbbp1MI+ppbqw sSdo3rNPASlSRk42NuUfTWBHg0iMT4F1kHYGS77UWUW0mqw9rAvSOLLnuHqisIVn5R UEWTo6KVpYuGZ7zLFAXW4TpPlupQngso0B+JxvbA= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44TAZw4h091218 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 29 May 2024 05:35:58 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 29 May 2024 05:35:57 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE115.ent.ti.com (157.170.170.26) 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, 29 May 2024 05:35:57 -0500 Received: from LT5CG31242FY.dhcp.ti.com (lt5cg31242fy.dhcp.ti.com [10.85.14.171]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 44TAZlsL034133; Wed, 29 May 2024 05:35:48 -0500 From: Shenghao Ding To: CC: , , , , <13916275206@139.com>, , , , , , , , , , , , , , , , , , , , , , Shenghao Ding Subject: [PATCH v3] ASoc: tas2781: Enable RCA-based playback without DSP firmware download Date: Wed, 29 May 2024 18:35:41 +0800 Message-ID: <20240529103543.2089-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 In only RCA(Reconfigurable Architecture) binary case, no DSP program will be working inside tas2563/tas2781, that is dsp-bypass mode, do not support speaker protection, and audio acoustic algorithms in this mode. Fixes: ef3bcde75d06 ("ASoC: tas2781: Add tas2781 driver") Signed-off-by: Shenghao Ding --- v3: - Add description on RCA is Reconfigurable Architecture. - Add the description on enabling - Reword the commit - Remove question mark in the comments. - Add spaces in comments. v2: - Correct comment. - Add Fixes. - Move header file to the first. v1: - Split out the different logical changes into different patches. - rename tasdevice_dsp_fw_state -> tasdevice_fw_state, the fw are not only DSP fw, but also RCA(Reconfigurable data, such as acoustic data and register setting, etc). - Add TASDEVICE_RCA_FW_OK in tasdevice_fw_state to identify the state that only RCA binary file has been download successfully, but DSP fw is not loaded or loading failure. - Add the this strategy into tasdevice_tuning_switch. - If one side of the if/else has a braces both should in tasdevice_tuning_switch. - Identify whehter both RCA and DSP have been loaded or only RCA has been loaded in tasdevice_fw_ready. - Add check fw load status in tasdevice_startup. - remove ret in tasdevice_startup to make the code neater. --- include/sound/tas2781-dsp.h | 3 ++- sound/soc/codecs/tas2781-fmwlib.c | 16 ++++++++++----- sound/soc/codecs/tas2781-i2c.c | 33 ++++++++++++++++++++----------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/include/sound/tas2781-dsp.h b/include/sound/tas2781-dsp.h index 7fba7ea26a4b..92d68ca5eafb 100644 --- a/include/sound/tas2781-dsp.h +++ b/include/sound/tas2781-dsp.h @@ -117,10 +117,11 @@ struct tasdevice_fw { struct device *dev; }; -enum tasdevice_dsp_fw_state { +enum tasdevice_fw_state { TASDEVICE_DSP_FW_NONE = 0, TASDEVICE_DSP_FW_PENDING, TASDEVICE_DSP_FW_FAIL, + TASDEVICE_RCA_FW_OK, TASDEVICE_DSP_FW_ALL_OK, }; diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-fmwlib.c index 265a8ca25cbb..5db1a0ac6036 100644 --- a/sound/soc/codecs/tas2781-fmwlib.c +++ b/sound/soc/codecs/tas2781-fmwlib.c @@ -2324,14 +2324,19 @@ void tasdevice_tuning_switch(void *context, int state) struct tasdevice_fw *tas_fmw = tas_priv->fmw; int profile_cfg_id = tas_priv->rcabin.profile_cfg_id; - if (tas_priv->fw_state == TASDEVICE_DSP_FW_FAIL) { - dev_err(tas_priv->dev, "DSP bin file not loaded\n"); + /* + * Only RCA-based Playback can still work with no dsp program running + * inside the chip? + */ + if (!(tas_priv->fw_state == TASDEVICE_RCA_FW_OK || + tas_priv->fw_state == TASDEVICE_DSP_FW_ALL_OK)) { + dev_err(tas_priv->dev, "No firmware loaded\n"); return; } if (state == 0) { - if (tas_priv->cur_prog < tas_fmw->nr_programs) { - /*dsp mode or tuning mode*/ + if (tas_fmw && tas_priv->cur_prog < tas_fmw->nr_programs) { + /* dsp mode or tuning mode */ profile_cfg_id = tas_priv->rcabin.profile_cfg_id; tasdevice_select_tuningprm_cfg(tas_priv, tas_priv->cur_prog, tas_priv->cur_conf, @@ -2340,9 +2345,10 @@ void tasdevice_tuning_switch(void *context, int state) tasdevice_select_cfg_blk(tas_priv, profile_cfg_id, TASDEVICE_BIN_BLK_PRE_POWER_UP); - } else + } else { tasdevice_select_cfg_blk(tas_priv, profile_cfg_id, TASDEVICE_BIN_BLK_PRE_SHUTDOWN); + } } EXPORT_SYMBOL_NS_GPL(tasdevice_tuning_switch, SND_SOC_TAS2781_FMWLIB); diff --git a/sound/soc/codecs/tas2781-i2c.c b/sound/soc/codecs/tas2781-i2c.c index 9350972dfefe..9b85a44511c2 100644 --- a/sound/soc/codecs/tas2781-i2c.c +++ b/sound/soc/codecs/tas2781-i2c.c @@ -380,23 +380,33 @@ static void tasdevice_fw_ready(const struct firmware *fmw, mutex_lock(&tas_priv->codec_lock); ret = tasdevice_rca_parser(tas_priv, fmw); - if (ret) + if (ret) { + tasdevice_config_info_remove(tas_priv); goto out; + } tasdevice_create_control(tas_priv); tasdevice_dsp_remove(tas_priv); tasdevice_calbin_remove(tas_priv); - tas_priv->fw_state = TASDEVICE_DSP_FW_PENDING; + tas_priv->fw_state = TASDEVICE_RCA_FW_OK; scnprintf(tas_priv->coef_binaryname, 64, "%s_coef.bin", tas_priv->dev_name); + ret = tasdevice_dsp_parser(tas_priv); if (ret) { dev_err(tas_priv->dev, "dspfw load %s error\n", tas_priv->coef_binaryname); - tas_priv->fw_state = TASDEVICE_DSP_FW_FAIL; goto out; } - tasdevice_dsp_create_ctrls(tas_priv); + + /* + * If no dsp-related kcontrol created, the dsp resource will be freed. + */ + ret = tasdevice_dsp_create_ctrls(tas_priv); + if (ret) { + dev_err(tas_priv->dev, "dsp controls error\n"); + goto out; + } tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK; @@ -417,9 +427,8 @@ static void tasdevice_fw_ready(const struct firmware *fmw, tasdevice_prmg_load(tas_priv, 0); tas_priv->cur_prog = 0; out: - if (tas_priv->fw_state == TASDEVICE_DSP_FW_FAIL) { - /*If DSP FW fail, kcontrol won't be created */ - tasdevice_config_info_remove(tas_priv); + if (tas_priv->fw_state == TASDEVICE_RCA_FW_OK) { + /*If DSP FW fail, DSP kcontrol won't be created */ tasdevice_dsp_remove(tas_priv); } mutex_unlock(&tas_priv->codec_lock); @@ -466,14 +475,14 @@ static int tasdevice_startup(struct snd_pcm_substream *substream, { struct snd_soc_component *codec = dai->component; struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); - int ret = 0; - if (tas_priv->fw_state != TASDEVICE_DSP_FW_ALL_OK) { - dev_err(tas_priv->dev, "DSP bin file not loaded\n"); - ret = -EINVAL; + if (!(tas_priv->fw_state == TASDEVICE_DSP_FW_ALL_OK || + tas_priv->fw_state == TASDEVICE_RCA_FW_OK)) { + dev_err(tas_priv->dev, "Bin file not loaded\n"); + return -EINVAL; } - return ret; + return 0; } static int tasdevice_hw_params(struct snd_pcm_substream *substream, -- 2.34.1