From patchwork Mon Aug 5 10:27:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13753486 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 B9A8414F9CC; Mon, 5 Aug 2024 10:29:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722853799; cv=none; b=ToxNeyUznRQIsVyTUREgMMtYMGpYITH5xNlYzipJngrvAhwR7CHImitIChMYYfNtottjSDMVHNVA7MSrd+n9bmPMK6S9/rFf7mSOe41u2p8UlavxArxkJmBwOdeM0fLz99Ntvwtf/XMsf36iC2LndUQsBsoNowB5VF2+X6HIAwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722853799; c=relaxed/simple; bh=34lKbWc8oLhiLYcDTgHZAE17ty1RjO2OwjzN3VvP6gk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UKqkrpX6flVXKpf7drJ4t++85b5AOS1EnJfvZoN6OgTEBsKKylAW5bB4SrIbG2Tz4Ltn3sY5occJxnTaN+gYeIY0ASQQLKMVjffKiBzh7pFEcmBJCjm/tfsUmZ6xv/g8x5xnAEsX1FUMxAACrDjSS8fhHtnt6Kvt9CRl0zcaOzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=DX7aWo4f; arc=none smtp.client-ip=67.231.152.168 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="DX7aWo4f" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47571BNK029909; Mon, 5 Aug 2024 05:27:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=FNw6vv0s5msc0CKCtO00gDMzIXAb4kuva88RL1xu+1U=; b= DX7aWo4fVg9IQE1S2ZK44UAUTKOT9swzC40KAPIv/6vKvdS0wy7zhenF6OolrOJc 2uyHPTeo25HXzlcQbT88R4yMISNcRhPucgXd9O5kdPxDPXo6BLIeUx/A/m3FVkzB DCER5WMZvrhFUe6WCKG/Y7iwvPlLy9YT2qFZyptLi0K3Q60jS/fXtO7rguoyzUqZ 7FVbWmlm5LS+ehraADooND+bEfABLEnIA3iyVWo5+PrZlrEOFwhTWgvrvrTKt6TO LlE5Og4lDgInes/O5xudGeA7t2+phJteIALKsegZXZal9njq1wKSR+vd+ztJeE9p BlaaGg+nH4nwJxtauB4+TQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 40sgyhsmt5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Aug 2024 05:27:41 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 5 Aug 2024 11:27:40 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 5 Aug 2024 11:27:40 +0100 Received: from lonswws01.ad.cirrus.com (lonswws01.ad.cirrus.com [198.90.188.26]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 69173820241; Mon, 5 Aug 2024 10:27:40 +0000 (UTC) From: Simon Trimmer To: CC: , , , , "Simon Trimmer" Subject: [PATCH 1/2] ASoC: wm_adsp: Add control_add callback and export wm_adsp_control_add() Date: Mon, 5 Aug 2024 10:27:20 +0000 Message-ID: <20240805102721.30102-2-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240805102721.30102-1-simont@opensource.cirrus.com> References: <20240805102721.30102-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: h1A4EbJ4nuKHU7v8clfUjmwlE1SPaB35 X-Proofpoint-GUID: h1A4EbJ4nuKHU7v8clfUjmwlE1SPaB35 X-Proofpoint-Spam-Reason: safe The callback allows codec drivers to affect how firmware coefficients are added as controls. For example a codec driver may selectively add controls by choosing to call wm_adsp_control_add() based on some filter logic. Signed-off-by: Simon Trimmer --- sound/soc/codecs/wm_adsp.c | 17 ++++++++++++++--- sound/soc/codecs/wm_adsp.h | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 9f8549b34e30..e69283195f36 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -583,7 +583,7 @@ static void wm_adsp_ctl_work(struct work_struct *work) kfree(kcontrol); } -static int wm_adsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl) +int wm_adsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl) { struct wm_adsp *dsp = container_of(cs_ctl->dsp, struct wm_adsp, cs_dsp); struct cs_dsp *cs_dsp = &dsp->cs_dsp; @@ -658,6 +658,17 @@ static int wm_adsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl) return ret; } +EXPORT_SYMBOL_GPL(wm_adsp_control_add); + +static int wm_adsp_control_add_cb(struct cs_dsp_coeff_ctl *cs_ctl) +{ + struct wm_adsp *dsp = container_of(cs_ctl->dsp, struct wm_adsp, cs_dsp); + + if (dsp->control_add) + return (dsp->control_add)(dsp, cs_ctl); + else + return wm_adsp_control_add(cs_ctl); +} static void wm_adsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl) { @@ -2072,12 +2083,12 @@ irqreturn_t wm_halo_wdt_expire(int irq, void *data) EXPORT_SYMBOL_GPL(wm_halo_wdt_expire); static const struct cs_dsp_client_ops wm_adsp1_client_ops = { - .control_add = wm_adsp_control_add, + .control_add = wm_adsp_control_add_cb, .control_remove = wm_adsp_control_remove, }; static const struct cs_dsp_client_ops wm_adsp2_client_ops = { - .control_add = wm_adsp_control_add, + .control_add = wm_adsp_control_add_cb, .control_remove = wm_adsp_control_remove, .pre_run = wm_adsp_pre_run, .post_run = wm_adsp_event_post_run, diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h index e53dfcf1f78f..edc5b02ae765 100644 --- a/sound/soc/codecs/wm_adsp.h +++ b/sound/soc/codecs/wm_adsp.h @@ -37,6 +37,7 @@ struct wm_adsp { bool wmfw_optional; struct work_struct boot_work; + int (*control_add)(struct wm_adsp *dsp, struct cs_dsp_coeff_ctl *cs_ctl); int (*pre_run)(struct wm_adsp *dsp); bool preloaded; @@ -132,6 +133,8 @@ int wm_adsp_compr_pointer(struct snd_soc_component *component, int wm_adsp_compr_copy(struct snd_soc_component *component, struct snd_compr_stream *stream, char __user *buf, size_t count); + +int wm_adsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl); int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, unsigned int alg, void *buf, size_t len); int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type, From patchwork Mon Aug 5 10:27:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13753487 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 A01891547DD; Mon, 5 Aug 2024 10:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722853800; cv=none; b=NHZF57P6RRhmMMVeApFxwe7uxDBmRyYfVDOpodaLe9pXrrc0+tJS6kEdlzpq0kA4VHzjG3798+TaoBSQcj3XODjmL7dkUOufTJ86wspS/E/Ox9d9wAeKaDWquArg+5y46/BvFcPZBD3MlhP4Qb2+WR3wFEpRoceC/YQZJqOyQcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722853800; c=relaxed/simple; bh=9RcYMtMM4r+MQSxgDOMv3UjOKLUb1JBAjfVJavx3WSE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cz9UNdUYfk7prfW4E2XCU9C7aGLURXq4DD3Pw4tQowE1t/Zcd3OSRcrMKMc4aSn3Txju4L/qGTnQVIe8wfkYsKAiBNLxj19bB3JDiExJj4m9hrc81IvUyU/QV52L6MoHwhTNS/ZiEoGGf/0hC+Zg8vuc7mP4MGx3uaxuPjFXhpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=c+xSjutt; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="c+xSjutt" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4755WGqT021667; Mon, 5 Aug 2024 05:27:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=d2cHf22ZBP8FBiZHr6wfdXREEjqKc/hSUSPbj/TXBFw=; b= c+xSjuttdqX8ncc91jkijhbgVBzbb9knAtvIarBKShOMSWjlk9CcLux0QEqAWFdP cGAtXiE1SlZ6sVH1dDks1tzW7XTo7PanQ4lirmFEW0pnBF4iqpqSrX3XcCywb6wG DtZXdNz+lhHKuXIe9pewCTfm0hL+7ecsl/V8hz08jD2aJX+/FtNznhgmGNajqXUS 1b8q/IWEt/Yd/LC8B95VlV5GpG/YXN0QbhR2VHsG1k6EeC+aDo1CrX334Xay7fa9 +Jnr3VcOFatHUMdQXVy9l1G+0e0a7o/qMKooYLihqxY3tIbnvmdlaqeBG3TUrZp3 AlZ61JyVr5Xfe3U1KIP5NA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 40shxx1n3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Aug 2024 05:27:44 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 5 Aug 2024 11:27:42 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 5 Aug 2024 11:27:41 +0100 Received: from lonswws01.ad.cirrus.com (lonswws01.ad.cirrus.com [198.90.188.26]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id C8A62820241; Mon, 5 Aug 2024 10:27:41 +0000 (UTC) From: Simon Trimmer To: CC: , , , , "Simon Trimmer" Subject: [PATCH 2/2] ASoC: cs35l56: Stop creating ALSA controls for firmware coefficients Date: Mon, 5 Aug 2024 10:27:21 +0000 Message-ID: <20240805102721.30102-3-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240805102721.30102-1-simont@opensource.cirrus.com> References: <20240805102721.30102-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: sBVzMXPYgLNwkSpv0ZkT_I88tf6S0Cns X-Proofpoint-ORIG-GUID: sBVzMXPYgLNwkSpv0ZkT_I88tf6S0Cns X-Proofpoint-Spam-Reason: safe A number of laptops have gone to market with old firmware versions that export controls that have since been hidden, but we can't just install a newer firmware because the firmware for each product is customized and qualified by the OEM. The issue is that alsactl save and restore has no idea what controls are good to persist which can lead to misconfiguration. There is no reason that the UCM or user should need to interact with any of the ALSA controls for the firmware coefficients so they can be removed entirely. Fixes: e49611252900 ("ASoC: cs35l56: Add driver for Cirrus Logic CS35L56") Signed-off-by: Simon Trimmer --- sound/soc/codecs/cs35l56.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index 84c34f5b1a51..757ade6373ed 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -1095,6 +1095,11 @@ int cs35l56_system_resume(struct device *dev) } EXPORT_SYMBOL_GPL(cs35l56_system_resume); +static int cs35l56_control_add_nop(struct wm_adsp *dsp, struct cs_dsp_coeff_ctl *cs_ctl) +{ + return 0; +} + static int cs35l56_dsp_init(struct cs35l56_private *cs35l56) { struct wm_adsp *dsp; @@ -1117,6 +1122,12 @@ static int cs35l56_dsp_init(struct cs35l56_private *cs35l56) dsp->fw = 12; dsp->wmfw_optional = true; + /* + * None of the firmware controls need to be exported so add a no-op + * callback that suppresses creating an ALSA control. + */ + dsp->control_add = &cs35l56_control_add_nop; + dev_dbg(cs35l56->base.dev, "DSP system name: '%s'\n", dsp->system_name); ret = wm_halo_init(dsp);