Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp234034lqh; Thu, 30 May 2024 22:28:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFQHo2r9N2rufcltNwXqbnfeMsYch2nk9wd4NHTktWaMoVbvXYQqPWiN9lhtIidSxZZbddAV73qIABXPf+7bL2ATddOShSROx3vb/GkA== X-Google-Smtp-Source: AGHT+IG274Fh0RiHIv6CFoulr0EgH1GMWrQREZuw9vWooRcdO/E4kdd5H6MTsd70Zy4TDqrJUgi0 X-Received: by 2002:a17:902:e883:b0:1f4:64d6:919d with SMTP id d9443c01a7336-1f6370cd8bbmr9741935ad.66.1717133294550; Thu, 30 May 2024 22:28:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717133294; cv=pass; d=google.com; s=arc-20160816; b=BJKAW3UAurj3gx5c2UBTP85nIE1GQ/u+DScaT1blBjUbx5/44++l9ckGwLMocZqSTJ muV0trD/THWNqE/schCLrXWxp75xHz8w5Oy63OuM6ie8VHZsFuAjnRLBwTYPTUtLjYY8 p5HoVUJAxLWWwNwHPhRhEseFWK/cCfPsZsgixqdTcSJsDtfrsSzdff38YLzlNPJqwRN4 J9CKHMUexW0NH1IPAjySHmsksbQ8EIB1/9fh+jVwPCQTl0BE9gaBbudvHchAdhNYjzhR D3bVgfERIv5hExt0jRscyWkNVADN/YqCvcY6ymMNoDtgJzwqICyMPjYHhDOtIZ3ctZw5 yZPQ== 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=oKBk9vOJlkZx2G9X5E9S7ZMg/8maZZkRcQRRjcwLFdo=; b=tEdg+b3g1be6+3fwmp8LNzWOyHuKpVWD+ZBCJnMZAfsv1IhIVxVjQD5hoeP6rpqctp Sy/YgHt1Tukcyjzi3W6FRGW1JLOnLOt3H7oD9VZbST2ZsP9yY+92zev0FUJ/PpN4WL51 tbJ6rxvCqvA5fME3p1gSAL/D5AaIQZaH3RJEPipAUW7oKIy3rqaNZP1k74XPhTycJ5+Y GKrzItf0PUw6O9dWpdQBmZ55xmlOe6CW+EQrG9khydrRPuZDtUV9MSm+D/EAAhWkJwkP jLL1g8AGp+5iMtaLkcI6Owg98A9JtyeGnjTbUd+xRRIXUo4q7vQNu9mAp+3O0n2F8huy pkoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JYr8c36p; 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-196294-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f63233d1d1si9327985ad.82.2024.05.30.22.28.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 22:28:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196294-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JYr8c36p; 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-196294-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196294-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2D397283BB7 for ; Fri, 31 May 2024 05:28:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 745CE7A15A; Fri, 31 May 2024 05:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="JYr8c36p" 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 2BCAD2595 for ; Fri, 31 May 2024 05:28:04 +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=1717133287; cv=none; b=GJ5wA3iO178DsA7KSZcjt96CrT1x+rxMwQHXPsimhv6BHhAiLeh5Hc9VHB+Un7KjSMYuEfe7DBEEvsxRtXVoJ8XLaxanmCvdjN9UFmzWl/P2+4ZwulEE7hhbXNgZ1LRyHD1y7rUpZZapNHa9oVnplXiKXwBI0VmPFw5TyxM8Aio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717133287; c=relaxed/simple; bh=PzL3Agibp2BwAUGKAq4VnWqww86W93usoupJOjzqlQk=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=JVxTQ5JHIGkHIupB6I/grLnKfYYFRu6FmNLr6j/C6wRK9dfgdYwTo9c+6EfTSFvb/ZPf1Xjir7EkKQfAjJcQhI2CGmWoo1SiXYU7b4r5A6fDrFfbjxsSyxxf07YFbqQLiOVvDW1dp4Tz6i36VI6R6MIzfJi8BFIxyq1gZfvu4F0= 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=JYr8c36p; 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 lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 44V5Qn9V126365; Fri, 31 May 2024 00:26:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1717133209; bh=swyYL/UTh/fJIrJdY36x8AgMYNmXTYRmwCF34ITHoj4=; h=From:To:CC:Subject:Date; b=JYr8c36pFLhiIJe19M6rv6+V+UNNJYYpoQ1z+60bESp3+DuWm3qHeFOzRicqJToyR DTqYzb5keeS2lYi/S2n1SYiMqON2J0T/A9wL6+YRBso5WCzbNUhOOuJENTA8j2OWx2 AT/YoZAcyG7S6FTQsZqqZuzaJQ91L3bvp99b8D0M= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 44V5QnMH007938 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 31 May 2024 00:26:49 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 31 May 2024 00:26:49 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE101.ent.ti.com (157.170.170.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, 31 May 2024 00:26:49 -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 44V5Qe1q005196; Fri, 31 May 2024 00:26:41 -0500 From: Shenghao Ding To: CC: , , , , <13916275206@139.com>, , , , , , , , , , , , , , , , , , , , , , Shenghao Ding Subject: [PATCH v4] ASoc: tas2781: Enable RCA-based playback without DSP firmware download Date: Fri, 31 May 2024 13:26:35 +0800 Message-ID: <20240531052636.565-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