Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp353171lqt; Thu, 6 Jun 2024 05:52:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKto9GjAHuIFAqEuZHatMVA0CCOEijIPdux+uf1f3zBlFlt4b/BftaxrieEIcff5b4Vv9OP0dXaj7Kpc+J013DFVmVhtaruRTv1VsCeA== X-Google-Smtp-Source: AGHT+IEB/tJESZPVwxX1Na0tmjJJ+ftART+r5zWlDjAGs7SpVXLUReudra2Oammgyq25oCLxWkb6 X-Received: by 2002:a50:c30e:0:b0:579:cd1c:8d69 with SMTP id 4fb4d7f45d1cf-57aa53e09a3mr2310110a12.2.1717678374308; Thu, 06 Jun 2024 05:52:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717678374; cv=pass; d=google.com; s=arc-20160816; b=tnIp6RERX17WxxZroA0TncCYlM1Imn4fRiaSI6REG4hkXKV/Z+3jfJuXydUHDNrR+Z M/U+dV/KMMIfsnU/taQ7tHmE6e0RhuO/kPrEZYO6IxdfOaVenuIbqBirc8dF4jLRceJw hojoE+79RZBQkSIt5cc2cPZfkKTT9yDKF8690Y80NmBjS0lgU2lST0FABqcplwZbvJZk /OFP16O859aOxFnVPbLkcqp1ONFI+cup61t9IHfR6avOCaWFHFGs8ox62UI0cj0+hfef tWtrJI39V94DAu26KxDyFtIeRJXGcWpnqXLUIX5O2U2dtC2iyk1bX6kwKacbJ24YRSIA ho7A== 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=swyYL/UTh/fJIrJdY36x8AgMYNmXTYRmwCF34ITHoj4=; fh=RT4363P6BmPt6bNBzCvqul30ZXuIeBsAu95f0oTDR5o=; b=XZaZeOZTWcVa8GCFkMM74ySGM1YkvTCWoLEe3lIBrMRIEjmnVbxgywuf5XGTKICBAU Q7NkChaYoygsYHl5xyErl0NEalFcHwtvGRpac4IWs8RpJwNPDM52W2aIrOc/gernbRsH WcSaXIFv+zpU4hVHmz+iyM2IzNSBTS692Y7sFltW5TNuPs5RoTgKNdR47JHTz7AXrhig y2vBOl3vH++XPVmMXMve7kzuF7Lf0TKwG8+jjKMe47L2I7/eZ2PKugQEF3nsGm54F5xJ 4MqQ5Sp7IW4UrFxjluxzrRc49chmRnQT22A+39idbhrELZFp9C8RHheIE210Xvoevyki oGfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KrPhtBIC; 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-204286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae1fdfc4si679314a12.257.2024.06.06.05.52.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 05:52:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=KrPhtBIC; 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-204286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204286-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D5F941F28063 for ; Thu, 6 Jun 2024 12:43:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 774CC195B11; Thu, 6 Jun 2024 12:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="KrPhtBIC" 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 92444195981 for ; Thu, 6 Jun 2024 12:43:15 +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=1717677797; cv=none; b=QxTpL/Jdz04Qcw+hvXqamTr/ZYHqb0mSMlkSqT5BfdqF9f/0AMQ/1RvNUVs5b72SG34miBI8+GAcB2s1GNdbZAdSwjizqaaCSRRpPv3J6eu73j2T70KZuwZq70k9yQr6YTuc+hLMhR60yzIM63Wsfl7bpObcLJbsidk8vBNjscE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717677797; c=relaxed/simple; bh=PzL3Agibp2BwAUGKAq4VnWqww86W93usoupJOjzqlQk=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=CtKu0DPAZoflCJBOE/dRWpfV9MUbL+1qQqdcVN9QjBKVVs8Ozy0epPTo31++nnuO04mNczIgyC8qy37hrtmILzEJ+cFTF1z0McHRxoKC9Y4qbu8LO9sVEBvPyNR9IHydy3R1uiU4o+HSXCjtBqnLHOz2wiof99tI+nHIr3WJjjQ= 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=KrPhtBIC; 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 lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 456CfLTs113415; Thu, 6 Jun 2024 07:41:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1717677681; bh=swyYL/UTh/fJIrJdY36x8AgMYNmXTYRmwCF34ITHoj4=; h=From:To:CC:Subject:Date; b=KrPhtBICtQCzyNuZnJ8b7wwxW8OP4WMYICJHklMQAM5zM2+q57syNvTz0Ik8OByNF aWfa5DCMffEKHwbNJkN/Tx3gwI0fP3GHfG3sm4TAr/XE6+Geh0mIJFXTo7YQzXeIE1 BD7gIoLzPImGPpY7mGVazwQ8ijGj5nBFV2Hc8t4I= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 456CfLbq006673 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Jun 2024 07:41:21 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 6 Jun 2024 07:41:20 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) 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 via Frontend Transport; Thu, 6 Jun 2024 07:41:20 -0500 Received: from LT5CG31242FY.dhcp.ti.com ([10.250.160.158]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 456CfAJt103595; Thu, 6 Jun 2024 07:41:11 -0500 From: Shenghao Ding To: CC: , , , , <13916275206@139.com>, , , , , , , , , , , , , , , , , , , , , , , , , Shenghao Ding Subject: [RESEND PATCH v4] ASoc: tas2781: Enable RCA-based playback without DSP firmware download Date: Thu, 6 Jun 2024 20:41:03 +0800 Message-ID: <20240606124105.1492-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 --- v4: - add a description of what the state machine looks like, and why FW_PENDING/FAIL remain but are not used. - Remove TASDEVICE_DSP_FW_NONE because of unused. - Remove stray change. - Fix broken indentation. 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 | 11 ++++++++-- sound/soc/codecs/tas2781-fmwlib.c | 18 +++++++++++----- sound/soc/codecs/tas2781-i2c.c | 34 +++++++++++++++++++------------ 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/include/sound/tas2781-dsp.h b/include/sound/tas2781-dsp.h index 7fba7ea26a4b..3cda9da14f6d 100644 --- a/include/sound/tas2781-dsp.h +++ b/include/sound/tas2781-dsp.h @@ -117,10 +117,17 @@ struct tasdevice_fw { struct device *dev; }; -enum tasdevice_dsp_fw_state { - TASDEVICE_DSP_FW_NONE = 0, +enum tasdevice_fw_state { + /* Driver in startup mode, not load any firmware. */ TASDEVICE_DSP_FW_PENDING, + /* DSP firmware in the system, but parsing error. */ TASDEVICE_DSP_FW_FAIL, + /* + * Only RCA (Reconfigurable Architecture) firmware load + * successfully. + */ + TASDEVICE_RCA_FW_OK, + /* Both RCA and DSP firmware load successfully. */ TASDEVICE_DSP_FW_ALL_OK, }; diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-fmwlib.c index 265a8ca25cbb..838d29fead96 100644 --- a/sound/soc/codecs/tas2781-fmwlib.c +++ b/sound/soc/codecs/tas2781-fmwlib.c @@ -2324,14 +2324,21 @@ 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. + */ + switch (tas_priv->fw_state) { + case TASDEVICE_RCA_FW_OK: + case TASDEVICE_DSP_FW_ALL_OK: + break; + default: 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 +2347,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..9c3c89cb36de 100644 --- a/sound/soc/codecs/tas2781-i2c.c +++ b/sound/soc/codecs/tas2781-i2c.c @@ -380,23 +380,32 @@ 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 +426,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 +474,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; + switch (tas_priv->fw_state) { + case TASDEVICE_RCA_FW_OK: + case TASDEVICE_DSP_FW_ALL_OK: + return 0; + default: + return -EINVAL; } - - return ret; } static int tasdevice_hw_params(struct snd_pcm_substream *substream, -- 2.34.1