From patchwork Wed May 8 08:16:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13658238 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA23D28DCA for ; Wed, 8 May 2024 08:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156203; cv=none; b=KTI4aDu7EBaS+qd0vW4PnHdhjU3Wa1UqYQdFkNePHT9LvjVJlJZtKzqNeNbBTTuYNU6cP0WdSr1j2Xrcj9nM2sE8XtSBR9nBwCXHLydvUWfQ2vlN3XjPeHoUyhSfI8HGLYFvWs7+VrP3zOrFBe9cumuKiOCvn0B2XI8xd0WopOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156203; c=relaxed/simple; bh=HZ5c05lASDGke6zV6oGSp7GtVTkm9nQ4CbvayqlVq5o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EVVgHlIT6CshnGKgjqZfGw5Nyo8MpWx2AHSSJ2DSU57k24gzNZffG1r/8PP36X1w9VUYqTza3SgzxYPBixWV3rW7sFH4pQ/tnZ8UzhhjFkHNiTFfJ05ARLdPUDZ/eUS8Zvte2HOw2aOS7XQoMQ78ATHSMu8yxOUz/PowmeWs16U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=GUifNWdA; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GUifNWdA" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a59cc765c29so739805066b.3 for ; Wed, 08 May 2024 01:16:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715156200; x=1715761000; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0LwDR/uj963neDfuvigHcDzvEI8lpRkCIvqpr3ctsbs=; b=GUifNWdATX03PF165ZYiIzkjoM1j/STDJCAvjtcbOb1aYj+W/MYaMpWYNjGkw0X967 IZxuNWYttHzxMvAhQpSF+9NJxMpPTnU3Q+rxhAxMWuLYECkQ03zNOrt8A0I+Cwl2xwp7 bxovSdb99bGfRP0LimaeJPmN1+K5jfwUye30K7f9UW0xQdKMDSM6zmPzgTm8XR+g4TY7 EWC+BbquakvsFiDLhNnLNMrslwV3ADtVRjFoynSvU9Bq4uCXK2ztfRoY0g/jOiV0L9WG Ju8lOdBbNLm/41NcQtMGmnb3jHZhFYdTRfItXof8TlGBCCoJgfMf/CDmLN7IFLj7dJQP P4kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715156200; x=1715761000; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0LwDR/uj963neDfuvigHcDzvEI8lpRkCIvqpr3ctsbs=; b=plkgEBUEwBWt575yMX2L7fJKuW/cZcuBJnQe2eZVudCTQoi+twxosIURnlOCn0vDLZ fQiD5vmiGfmXXp80ZCDH2xChtUF30b2iSjybvEZxXcox5vxjnXeMyHhIKA9FholJZ2WO HhDMwCW4EqKYuQJmJ1K0haTvJIGEOLzOUC24XLx/p3/5uBKlBQHmDGS/bkz02q6DAPKw XkQITiZiocIbiM4qvFZ6SCrtxbud8aDXGBA11uCuXoSV5mnzAoByRj7srXS7p0EMVXsv GTvq5yLck9VPgUzqNQflqSNp100EhZm7clgowrN8G1qcZbhOVo+C2htFGroVAA0Y4zUM 3DMg== X-Forwarded-Encrypted: i=1; AJvYcCW21zqQPJH98rXmEZvrzBd+hqRpV/qlqpWgHxmayPf//wnC5sRsPcQ+yGS3qTNip75Fb83w4jjUjl2zpq6fcVtdHKCgrhT9tWcIeZg= X-Gm-Message-State: AOJu0YwmX273Kt2yrthsv124J2rKgW1TRD+TOxg8HT8Pc5lqZImmUe++ lgqWhi0D0zUr5i/Wx7ZExtQKSlpednqiet7lxx7AOn8vBptdLM/hECM8RneYMSg= X-Google-Smtp-Source: AGHT+IFObuqnHNAZx3tIfH6k17QV8p4TQzZlUFXl/C0j8YnL6NYLHT142nQn12hW7zd9PdMUhzCNRg== X-Received: by 2002:a17:906:16d8:b0:a59:a0c1:2624 with SMTP id a640c23a62f3a-a59fb968db2mr107669366b.39.1715156199807; Wed, 08 May 2024 01:16:39 -0700 (PDT) Received: from [127.0.1.1] ([178.197.206.169]) by smtp.gmail.com with ESMTPSA id va28-20020a17090711dc00b00a59b87dd0d7sm4564734ejb.147.2024.05.08.01.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:16:39 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 08 May 2024 10:16:27 +0200 Subject: [PATCH v2 1/4] ASoC: Constify channel mapping array arguments in set_channel_map() Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240508-asoc-x1e80100-4-channel-mapping-v2-1-ccef9a66a572@linaro.org> References: <20240508-asoc-x1e80100-4-channel-mapping-v2-0-ccef9a66a572@linaro.org> In-Reply-To: <20240508-asoc-x1e80100-4-channel-mapping-v2-0-ccef9a66a572@linaro.org> To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Lars-Peter Clausen , =?utf-8?q?Nuno_S=C3=A1?= , Srinivas Kandagatla , Banajit Goswami Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=10038; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=HZ5c05lASDGke6zV6oGSp7GtVTkm9nQ4CbvayqlVq5o=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmOzThPDEa3Y144bYqYosGCjC/SAw0gTeweR2Id aEVzLem9f2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZjs04QAKCRDBN2bmhouD 1+yNEACRYti+q8Z0fVyDZbDn8FGaexH1ORpc4CR2JCGcC+4xcoB+ytKpUrD2PVU3CwbgRmKCvl7 dbVYXOkFBoUGSkRZuu1JWmv1Ed7kGlKbplaXhZzcQVD7PqlYe5tfOKBV3mVC8CYf8HGC1ngeuen iuB/dy2CHbjK3eIMQ9LxPilN9hDitxnPgpOAGXlrVYD3eyZ4m1z3gkn6DJZAemKBmLA1Vkbe7Je 0ExKdRHDz9PJrI2LbUfVsMOL+wykRJNPQALyv0ZS9/qRXQvWob1d1XlwlQ0CtNCeHCNDcyX8UJz cUY8glVhVn9mozHqP9lDZKKaUy92IkG5VR0iJ0Wky5IqmBn8zmgkhEe8tWxtZ59Zu2RyXvWLAqk a3yPbFNTVOgN4BKSIVXk1+J9YVa6M1iQ+g97BpAoT9B4iz5UjMXauH3D4QWtFp3JBwogKsG04/c SlPZPM9AI4EqfCEJnw8d+J38cwB3WFC7ILVBsIPD0KMDAy/OEekGA3JLrvzUdZBwbGOvimnsQla JNQ/PPRRvs+0uCt3EVQCRv1Om1uFPGYaDHUNkXZsWFn3LAFB9EYtAuik/LPvDNGsT2kx43IW3YO fl/5i5Zz2bOidPnMHwbo7BAAF+HhEH5HXc3TLBdH2mw18MII16TsLaT8b47UGlQqncMiAcgwsn/ 62YkmriK3XYlCxQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B There is no need for implementations of DAI set_channel_map() to modify contents of passed arrays with actual channel mapping. Additionally, the caller keeps full ownership of the array. Constify these pointer arguments so the code will be safer and easier to read (documenting the caller's ownership). Signed-off-by: Krzysztof Kozlowski Acked-by: Charles Keepax --- Changes in v2: 1. None --- include/sound/cs35l41.h | 4 ++-- include/sound/soc-dai.h | 8 ++++---- sound/soc/codecs/adau7118.c | 6 ++++-- sound/soc/codecs/cs35l41-lib.c | 4 ++-- sound/soc/codecs/cs35l41.c | 3 ++- sound/soc/codecs/max98504.c | 6 ++++-- sound/soc/codecs/wcd9335.c | 6 ++++-- sound/soc/codecs/wcd934x.c | 6 ++++-- sound/soc/qcom/qdsp6/q6afe-dai.c | 16 ++++++++++------ sound/soc/qcom/qdsp6/q6apm-lpass-dais.c | 6 ++++-- sound/soc/soc-dai.c | 4 ++-- 11 files changed, 42 insertions(+), 27 deletions(-) diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h index bb70782d15d0..43c6a9ef8d9f 100644 --- a/include/sound/cs35l41.h +++ b/include/sound/cs35l41.h @@ -896,8 +896,8 @@ int cs35l41_test_key_lock(struct device *dev, struct regmap *regmap); int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap); int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsigned int reg_revid); int cs35l41_set_channels(struct device *dev, struct regmap *reg, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot); + unsigned int tx_num, const unsigned int *tx_slot, + unsigned int rx_num, const unsigned int *rx_slot); int cs35l41_gpio_config(struct regmap *regmap, struct cs35l41_hw_cfg *hw_cfg); void cs35l41_configure_cs_dsp(struct device *dev, struct regmap *reg, struct cs_dsp *dsp); int cs35l41_set_cspl_mbox_cmd(struct device *dev, struct regmap *regmap, diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index adcd8719d343..15ef268c9845 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -188,8 +188,8 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width); int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot); + unsigned int tx_num, const unsigned int *tx_slot, + unsigned int rx_num, const unsigned int *rx_slot); int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); @@ -305,8 +305,8 @@ struct snd_soc_dai_ops { unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width); int (*set_channel_map)(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot); + unsigned int tx_num, const unsigned int *tx_slot, + unsigned int rx_num, const unsigned int *rx_slot); int (*get_channel_map)(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot); diff --git a/sound/soc/codecs/adau7118.c b/sound/soc/codecs/adau7118.c index a663d37e5776..abc4764697a5 100644 --- a/sound/soc/codecs/adau7118.c +++ b/sound/soc/codecs/adau7118.c @@ -121,8 +121,10 @@ static const struct snd_soc_dapm_widget adau7118_widgets[] = { }; static int adau7118_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) + unsigned int tx_num, + const unsigned int *tx_slot, + unsigned int rx_num, + const unsigned int *rx_slot) { struct adau7118_data *st = snd_soc_component_get_drvdata(dai->component); diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c index e9993a39f7d0..1702f26049d3 100644 --- a/sound/soc/codecs/cs35l41-lib.c +++ b/sound/soc/codecs/cs35l41-lib.c @@ -936,8 +936,8 @@ int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsign EXPORT_SYMBOL_GPL(cs35l41_register_errata_patch); int cs35l41_set_channels(struct device *dev, struct regmap *reg, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) + unsigned int tx_num, const unsigned int *tx_slot, + unsigned int rx_num, const unsigned int *rx_slot) { unsigned int val, mask; int i; diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index cb25c33cc9b9..1688c2c688f0 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -673,7 +673,8 @@ static const struct snd_soc_dapm_route cs35l41_audio_map[] = { }; static int cs35l41_set_channel_map(struct snd_soc_dai *dai, unsigned int tx_n, - unsigned int *tx_slot, unsigned int rx_n, unsigned int *rx_slot) + const unsigned int *tx_slot, + unsigned int rx_n, const unsigned int *rx_slot) { struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); diff --git a/sound/soc/codecs/max98504.c b/sound/soc/codecs/max98504.c index 93412b966b33..6b6a7ece4cec 100644 --- a/sound/soc/codecs/max98504.c +++ b/sound/soc/codecs/max98504.c @@ -220,8 +220,10 @@ static int max98504_set_tdm_slot(struct snd_soc_dai *dai, return 0; } static int max98504_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) + unsigned int tx_num, + const unsigned int *tx_slot, + unsigned int rx_num, + const unsigned int *rx_slot) { struct max98504_priv *max98504 = snd_soc_dai_get_drvdata(dai); struct regmap *map = max98504->regmap; diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c index deb15b95992d..42a99978fe5a 100644 --- a/sound/soc/codecs/wcd9335.c +++ b/sound/soc/codecs/wcd9335.c @@ -1983,8 +1983,10 @@ static int wcd9335_trigger(struct snd_pcm_substream *substream, int cmd, } static int wcd9335_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) + unsigned int tx_num, + const unsigned int *tx_slot, + unsigned int rx_num, + const unsigned int *rx_slot) { struct wcd9335_codec *wcd; int i; diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index de870c7819ca..fcad2c9fba55 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -1923,8 +1923,10 @@ static int wcd934x_trigger(struct snd_pcm_substream *substream, int cmd, } static int wcd934x_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) + unsigned int tx_num, + const unsigned int *tx_slot, + unsigned int rx_num, + const unsigned int *rx_slot) { struct wcd934x_codec *wcd; int i; diff --git a/sound/soc/qcom/qdsp6/q6afe-dai.c b/sound/soc/qcom/qdsp6/q6afe-dai.c index a9c4f896a7df..7d9628cda875 100644 --- a/sound/soc/qcom/qdsp6/q6afe-dai.c +++ b/sound/soc/qcom/qdsp6/q6afe-dai.c @@ -172,8 +172,8 @@ static int q6tdm_set_tdm_slot(struct snd_soc_dai *dai, } static int q6tdm_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) + unsigned int tx_num, const unsigned int *tx_slot, + unsigned int rx_num, const unsigned int *rx_slot) { struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); @@ -250,8 +250,10 @@ static int q6tdm_hw_params(struct snd_pcm_substream *substream, } static int q6dma_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_ch_mask, - unsigned int rx_num, unsigned int *rx_ch_mask) + unsigned int tx_num, + const unsigned int *tx_ch_mask, + unsigned int rx_num, + const unsigned int *rx_ch_mask) { struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); @@ -407,8 +409,10 @@ static int q6afe_dai_prepare(struct snd_pcm_substream *substream, } static int q6slim_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) + unsigned int tx_num, + const unsigned int *tx_slot, + unsigned int rx_num, + const unsigned int *rx_slot) { struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); struct q6afe_port_config *pcfg = &dai_data->port_config[dai->id]; diff --git a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c index 68a38f63a2db..6bfbb52345e1 100644 --- a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c +++ b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c @@ -25,8 +25,10 @@ struct q6apm_lpass_dai_data { }; static int q6dma_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_ch_mask, - unsigned int rx_num, unsigned int *rx_ch_mask) + unsigned int tx_num, + const unsigned int *tx_ch_mask, + unsigned int rx_num, + const unsigned int *rx_ch_mask) { struct q6apm_lpass_dai_data *dai_data = dev_get_drvdata(dai->dev); diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index fefe394dce72..03afd5efb24c 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -304,8 +304,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot); * configure the relationship between channel number and TDM slot number. */ int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) + unsigned int tx_num, const unsigned int *tx_slot, + unsigned int rx_num, const unsigned int *rx_slot) { int ret = -ENOTSUPP; From patchwork Wed May 8 08:16:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13658239 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0349A3FBB1 for ; Wed, 8 May 2024 08:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156204; cv=none; b=YKaETYoz0c6NhjmpP8jAI0/C31yIAflpaGU+WCZiCeX/ehZ2rPMJ511LeW1OexSgMuAxqjIm5ielr1YAcaJqWJAIBGnqEgmx1+S4GhrCQ2S/Ao9dYNkFcX56xuWhqVSAIX6XXKiRmo7AD5TFXbZ4nqSMzW2OPaSnecrTMRBDnD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156204; c=relaxed/simple; bh=d+whTvaCUFBkWJxrgaqvE8kSJoAykKqRo1KOv90DlbU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UPSOom0UrtLCBvcEaH2VuhaSX7w4hb+vNCfXagoVFbBAUNp94Mc6/lEGSGtYBVXNwDlXK1XsIhEdnv5RhEXlsokFnTwFK5U2HA2Qx0inmpyBDvdSG/HmAsjN65h+SAIs64WYMEUud+UQADgSD8JpkMnlQpXOFsWm94wziOip/RU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=f7vbQN84; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="f7vbQN84" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a599c55055dso983298466b.0 for ; Wed, 08 May 2024 01:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715156201; x=1715761001; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0J7Cge03mHzKytqfe46M5SWmiJDYT6L/0iD5WUZ2XNk=; b=f7vbQN84MmEXa6zfdIQXTCMOu/cdgPlHNYqaT1scThHruAPl6lBcFx0uMY44aNwHkl zjIjP3Acd8niiTc93Y2c5RlaMY3o3pbT4H43ujxJwoAu2HqaZgwD6Z9JJ5LaECwJua+f QF6nNtCUqQfNfpNx4CXIE7smNJO7PkGjt0e3ViNqfwK+w25y9rRuj2L7pP06WsvPin+O us3Vfz0oqiUFTaxb27FiOeMtZdJM6o+67xNBBfZtfhoo39ljw2shXPBwBTOn2s52NkeP E2EViKQPKLfL8FdZHsnuwDO92xOBU/so6F6UOjH8OhvXwIzjwunh9KJ7E8e5l26SBN96 MUFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715156201; x=1715761001; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0J7Cge03mHzKytqfe46M5SWmiJDYT6L/0iD5WUZ2XNk=; b=gf+ynMnuINkQC6Ek5dKNJr7fehhP7ELpduSYyUJxt+KBda77oWC8yuqef02XMrXqQN cddLmBKiQh6DQ9FBJ9TIy/X5BV3LpxZ7+53UX9hXnudG4pKAycu50YUhHzgrQAXZ0/gZ pd7c3g7X9BYoAs3bSzldIRMoaQiil8SixkR2Pc6Z8+P3GgsMIVVIv5PoXUdAOHw7kvSO 68G/l1Lw43Q6P3Epvp6GLqzITOM5iruSkQuRcegrh7FjT/4lnV0B283V1Q4V0BIk4hZu ogEdvRjH2MoWtXIra8pSokxeGA9fPLuhC0pK7CvGHMRrRjNF5hgoOwFxMW64ihDTp3Qn XuYw== X-Forwarded-Encrypted: i=1; AJvYcCW8W/4DWOw0n4/i3xeu/1mNjkjenDOJC/0s1xsZljqP37y4aiLIo9QH+kI+ol9hirCdOEqdgx4LjlRPir4fgw6dgmhwqOiEaFYtvrE= X-Gm-Message-State: AOJu0Yzal9O7XWzFO++D6QtYz8IQm9j8wH5sbF08xMIHnhJ2BQe+rF22 O7SSStLb7caXeDLUrcDnD8Z6ItLHqGnIAlqqzYacO7WU97L/tzBabboSjgK83O8= X-Google-Smtp-Source: AGHT+IFZ3qYEvnZ6rTmw8oYG9ikVNB5PUPg8nEX7L1tXb4l7wu50K2eH4wdfLFOOD0rRGkPUkUdGPw== X-Received: by 2002:a17:906:4a01:b0:a59:afdd:5911 with SMTP id a640c23a62f3a-a59fb9cf8ebmr117229466b.61.1715156201334; Wed, 08 May 2024 01:16:41 -0700 (PDT) Received: from [127.0.1.1] ([178.197.206.169]) by smtp.gmail.com with ESMTPSA id va28-20020a17090711dc00b00a59b87dd0d7sm4564734ejb.147.2024.05.08.01.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:16:40 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 08 May 2024 10:16:28 +0200 Subject: [PATCH v2 2/4] ASoC: qcom: q6apm-lpass-dais: Implement proper channel mapping Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240508-asoc-x1e80100-4-channel-mapping-v2-2-ccef9a66a572@linaro.org> References: <20240508-asoc-x1e80100-4-channel-mapping-v2-0-ccef9a66a572@linaro.org> In-Reply-To: <20240508-asoc-x1e80100-4-channel-mapping-v2-0-ccef9a66a572@linaro.org> To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Lars-Peter Clausen , =?utf-8?q?Nuno_S=C3=A1?= , Srinivas Kandagatla , Banajit Goswami Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2494; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=d+whTvaCUFBkWJxrgaqvE8kSJoAykKqRo1KOv90DlbU=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmOzTi8NEsdlADISPfQf36sKPevu5VsjGLqs0hx kDZ6uc8tH+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZjs04gAKCRDBN2bmhouD 11aOD/9s1WsoAA6B5DobpnjGcCX7UuSSk/NL0D87AYUsJWiNfkbfnVALM79q2oh77xiICczVoTc F+UQ2l/Z7dybuXatUoPdSrs0jzy3aAhh4Cq85245TWhfmAVzAEwKGLUAXYGMNiWSkGhr8PF0AMl w0XyISwuUL5jS9yjcycHy2Y8xd2GWrJN5BjrEOz85WR8W+lWoietfVaE+HeFcwXXDNcXgSkSuae ndEbcKiJ01RB4rqL1ka/dn8Dvz6/S+ddEU2NlPUttdvaLsWK+MEYg+4v7VlJvm3VBlh5Uy4pmuW 3rNPNsQ6iqIH4UQ+JCiLd5Z5gTNLSAsZ9gAslAd/2AlLmYr6VeohJvMCWU3jGYjndWs3ypoHGf4 h5mnWpYgylDE94yfPG8kSiEuWRKFrKEmfGLLMzKr1NP6dR1d6pHQXZvZcV8Ge4NQkmPmHtT7sOs bMSPaJN1T0S3K0xwx/dDOFE/Tm+n5oxBYX6HyfHkgXMoF3RO0679nax4RQyea+7a6f13hrBXQEW D4cc2QND4Omhz3v7sq5pYnhMTAN3CujXiL9/dYigdLg0RXCScmuTZFtpWMWZBFHGPBbiPJsp529 BrdEQZBQHuNK38RvxE8pY72CYAJbZrUKUiXPj29rASjjCprRepydfG/Vlp60j7OnImnt+p7zFCG d85DyJDwvsMneqQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B The set_channel_map() implementation in q6apm-lpass-dais driver was copying older pre-Audioreach code from q6afe-dai driver, but not really using it. The code sets active channel mask based on passed channel mapping, but Audioreach code does not use that mask ever. Audioreach module configuration does have on the other hand proper channel mapping field, which should supersed that active channel mask. Drop the unused active channel mask and implement proper mapping of channels in q6apm-lpass-dais driver. Signed-off-by: Krzysztof Kozlowski --- Changes in v2: 1. Entirely replaced - now channel mapping is implemented in q6apm-lpass-dais. --- sound/soc/qcom/qdsp6/audioreach.h | 1 - sound/soc/qcom/qdsp6/q6apm-lpass-dais.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 2c82917b7162..eb9306280988 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -755,7 +755,6 @@ struct audioreach_module_config { u16 data_format; u16 num_channels; - u16 active_channels_mask; u16 dp_idx; u32 channel_allocation; u32 sd_line_mask; diff --git a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c index 6bfbb52345e1..a4ad1d0e6abd 100644 --- a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c +++ b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c @@ -33,7 +33,7 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai, struct q6apm_lpass_dai_data *dai_data = dev_get_drvdata(dai->dev); struct audioreach_module_config *cfg = &dai_data->module_config[dai->id]; - int ch_mask; + int i; switch (dai->id) { case WSA_CODEC_DMA_TX_0: @@ -58,7 +58,8 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai, tx_num); return -EINVAL; } - ch_mask = *tx_ch_mask; + for (i = 0; i < tx_num; i++) + cfg->channel_map[i] = tx_ch_mask[i]; break; case WSA_CODEC_DMA_RX_0: @@ -81,7 +82,8 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai, rx_num); return -EINVAL; } - ch_mask = *rx_ch_mask; + for (i = 0; i < rx_num; i++) + cfg->channel_map[i] = rx_ch_mask[i]; break; default: @@ -90,8 +92,6 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai, return -EINVAL; } - cfg->active_channels_mask = ch_mask; - return 0; } From patchwork Wed May 8 08:16:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13658240 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFA1C481C4 for ; Wed, 8 May 2024 08:16:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156206; cv=none; b=GNe0Q0+q3bRDwlUYJhdtx/kZk6Q2Z/Kf6OC7dVb1YaAVgOi9dSjkFYPMgg9kRIrOu16G0eXbjz9Lx0NSqsXxBztW6LPU8wxB0cHPauM7r2jNMCMEqQFeUjsNV6lNV0Q9c8btmgZZOwQxhEn8gSNKo4JWaO4M2e4Kn1UUumPH7X8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156206; c=relaxed/simple; bh=cMddYFvxag2xiuk6mbkfydpMJeegTn2R9D7VIBWz/p4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CtHDtVxLCd+f4y7z1h0mEvgEFVpjRshkAppGDJ8mUNnZHGUpMbavz48XvVQ1lwx8nw3wYNJ29L7TuXqtLdegY9pCwcvNlww881Szlz+jhz72vfPkCqOwem5DsDK+CppHyRHLKSuPQdd8IBsvRTg3lrRw+kTwDCBK4cZ0J1zQTAE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=yz334gtn; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yz334gtn" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a59a5f81af4so1052042466b.3 for ; Wed, 08 May 2024 01:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715156203; x=1715761003; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0d/mfFuQBbC2bnLXnrpmIq7nUGA3L1YuLtXQ7YCcvk8=; b=yz334gtnzTar/XweHtjao9czWV2B5CML/D2TE9o2INrPvokUd6fyXZvwVPB07xeWST 8pv2PfwUY6V9ucdeBjkN2Pzq6+7CXldOI1rVBP+WRVDNDW8TYa3UBueLeZrxEMvFOz8x 0loyg2thsgLCCv36ecZ2XME2v5yd1fC5UPMGU+R0eC/ytFQw3gwgka7QBk+m1YAvi8Az vc7zbXeuaLZ8D95oNvkBsGABWLVC78/JoeWtqdJnF4cjpAVX9aqwet5hWYAAGPcCUB0P HtMECP6VcZ0Pp3DZ215txvfM0BJXGLx+NJ6FjedrrPluTbetL1eTXdvaKEf8otKjw4pZ mgAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715156203; x=1715761003; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0d/mfFuQBbC2bnLXnrpmIq7nUGA3L1YuLtXQ7YCcvk8=; b=h7+twgBvOqzlYuQZHa6GuIkmlh3iKPn7C9sYyYw+S0+GJoym1h7eXu3zsaqoPJT7Of z8JPGM/JVBahmoctCBU41J2t5FMDl38k5FyifqzsiefZ+LaKF3GadjOFHxv0YdHBOp9C wrQ35kvcko4NANzyBzKMpg5oD7JbscuXUTy7LToohETCCrjoslh6jimT4ir4LqKs1SgA p1/EDZw6TwS6WYsJn5IPD19I/GH7vctZCRnXfZ08K5Hnv8im/O7L90h1ZFLj1FvEPpzA PkP1gZurYOIpKS86fFN2dBD+9aYJ0xPSA8ka62ptWNWPUCTKFIbP9oiSTVX9N7rw4qke 2cRg== X-Forwarded-Encrypted: i=1; AJvYcCWo9sOr5P9OWXrVZH5YZQP5nLYgN6oXs8CsVDDD7/L18wPHkrhjMWA0AgP2uBP8l8vZE/S7fiwhfWivLvwCo5HBffDMZGHdTyY6eoA= X-Gm-Message-State: AOJu0YykPe8y7z4C0+LOGD0xtYVaKUWZ/hWd8LURrruPbAzoinVPBs0u UhcnKtkYknsC7ZBuTfueqXzm2LdI+9Jxpe0lgN5VGn6k8u2eu1gifGeojHjGoTo= X-Google-Smtp-Source: AGHT+IE1MBNbXZrLfjXyx1dCe1syvalb4+faepTXKfJQ+upTD3a+dk8JxubWK9XFT7IdyM5EGPflKw== X-Received: by 2002:a17:906:1d5b:b0:a59:cc9b:d6ea with SMTP id a640c23a62f3a-a59fb955674mr108227966b.22.1715156203092; Wed, 08 May 2024 01:16:43 -0700 (PDT) Received: from [127.0.1.1] ([178.197.206.169]) by smtp.gmail.com with ESMTPSA id va28-20020a17090711dc00b00a59b87dd0d7sm4564734ejb.147.2024.05.08.01.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:16:42 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 08 May 2024 10:16:29 +0200 Subject: [PATCH v2 3/4] ASoC: qcom: qdsp6: Set channel mapping instead of fixed defaults Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240508-asoc-x1e80100-4-channel-mapping-v2-3-ccef9a66a572@linaro.org> References: <20240508-asoc-x1e80100-4-channel-mapping-v2-0-ccef9a66a572@linaro.org> In-Reply-To: <20240508-asoc-x1e80100-4-channel-mapping-v2-0-ccef9a66a572@linaro.org> To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Lars-Peter Clausen , =?utf-8?q?Nuno_S=C3=A1?= , Srinivas Kandagatla , Banajit Goswami Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7708; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=cMddYFvxag2xiuk6mbkfydpMJeegTn2R9D7VIBWz/p4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmOzTjyxhpO8DzaA8ppReHM4hPV3Z/adqaBpWAV 0H7r4EXyQyJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZjs04wAKCRDBN2bmhouD 11/XD/wPSSdoWkExslTsPTSBfHnP9U/c6S/6Ai1uhniexM/T+60CUs/r9WrlcPpyJY4YifM6D9e hlS8kSPGPKWxGaZI7Vro6X1HuhiPcJ1fYykAr47hIWinhSBsqkVNutj7EvSfQuvW0pzxYMkc8wx 9CW7Ice7Y8zU3I+BwFwqo8OidcMdvJ7DIMpJmZg5tzkh0ZMbcEzhozYCHjSDP/w09BvXzcc+3Z0 H5zptJp8bSDZkXD/0wVReTpj7JFfogyhp6xOf/hATQQPpibRzEQEdYvt+cug7gX34Qx8XnIL1o0 ckaYIsQU9jfJI0/zfILYxI/WZaBCS01DywAC00Q93N4Of8p00YP+Su22Dt3n4GIe9/NB0B6AQcj 3/KLSSQvKB1rhZtvbvgx1NRaA1WZH7Mkg7IkJybvrBv1iyt2Ijb5+VMvit0422/5mx2l59GUP/C fqxBjI8/xKpDbj84LHul7HOg+w5lKJUM/D4N6/CZyoAJ/WT+rfY6f6a3ah6b5UUukOM/JYuh4NL OSaQNOa2JZfosVMG7zY3X8OVZwIJnN3EKV02OK005BNl5w38P2LJIoPIarQwBc0RYKMd3/M+zr7 uYHy8QjCMlk34jsRYjdHilui/7sdjWvoJ8AJmDx7s3TV3EGjPLTreeM4WxN30wd/awInXHMsZiw UP8rDg7JnNIleDw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B When constructing packets to DSP, the Audioreach code uses 'struct audioreach_module_config' to configure parameters like number of channels, bitrate, sample rate etc, but uses defaults for the channel mapping. Rework this code to copy the channel mapping from 'struct audioreach_module_config', instead of using the default. This requires all callers to fill that structure: add missing initialization of channel mapping. Entire patch makes code more logical and easier to follow: 1. q6apm-dai and q6apm-lpass-dais code which allocates 'struct audioreach_module_config' initializes it fully, so fills both the number of channels and the channel mapping. 2. Audioreach code, which uses 'struct audioreach_module_config' when constructing packets, copies entire contents of passed config, not only pieces of it. Signed-off-by: Krzysztof Kozlowski --- Changes in v2: 1. Extend commit msg, rationale. 2. Rework to new approach, but most of the code stays. 3. Export audioreach_set_channel_mapping() (needed by Q6APM DAIS and LPASS DAIS) 4. Correct channel mapping also in audioreach_mfc_set_media_format(), because MFC DAI is now part of backend. 5. Do not adjust dynamic DAIs (drop audioreach_dai_load()). --- sound/soc/qcom/qdsp6/audioreach.c | 30 +++++++----------------------- sound/soc/qcom/qdsp6/audioreach.h | 1 + sound/soc/qcom/qdsp6/q6apm-dai.c | 2 ++ sound/soc/qcom/qdsp6/q6apm-lpass-dais.c | 5 ++++- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 5291deac0a0b..750b8ba64211 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -267,7 +267,7 @@ void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t token } EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt); -static void audioreach_set_channel_mapping(u8 *ch_map, int num_channels) +void audioreach_set_channel_mapping(u8 *ch_map, int num_channels) { if (num_channels == 1) { ch_map[0] = PCM_CHANNEL_FL; @@ -281,6 +281,7 @@ static void audioreach_set_channel_mapping(u8 *ch_map, int num_channels) ch_map[3] = PCM_CHANNEL_RS; } } +EXPORT_SYMBOL_GPL(audioreach_set_channel_mapping); static void apm_populate_container_config(struct apm_container_obj *cfg, struct audioreach_container *cont) @@ -819,7 +820,7 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, uint32_t num_channels = cfg->num_channels; int payload_size; struct gpr_pkt *pkt; - int rc; + int rc, i; void *p; payload_size = APM_MFC_CFG_PSIZE(media_format, num_channels) + @@ -842,18 +843,8 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, media_format->sample_rate = cfg->sample_rate; media_format->bit_width = cfg->bit_width; media_format->num_channels = cfg->num_channels; - - if (num_channels == 1) { - media_format->channel_mapping[0] = PCM_CHANNEL_FL; - } else if (num_channels == 2) { - media_format->channel_mapping[0] = PCM_CHANNEL_FL; - media_format->channel_mapping[1] = PCM_CHANNEL_FR; - } else if (num_channels == 4) { - media_format->channel_mapping[0] = PCM_CHANNEL_FL; - media_format->channel_mapping[1] = PCM_CHANNEL_FR; - media_format->channel_mapping[2] = PCM_CHANNEL_LS; - media_format->channel_mapping[3] = PCM_CHANNEL_RS; - } + for (i = 0; i < num_channels; i++) + media_format->channel_mapping[i] = cfg->channel_map[i]; rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); @@ -883,9 +874,6 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr, mp3_cfg->q_factor = mcfg->bit_width - 1; mp3_cfg->endianness = PCM_LITTLE_ENDIAN; mp3_cfg->num_channels = mcfg->num_channels; - - audioreach_set_channel_mapping(mp3_cfg->channel_mapping, - mcfg->num_channels); break; case SND_AUDIOCODEC_AAC: media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED; @@ -1104,9 +1092,7 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph, media_cfg->num_channels = mcfg->num_channels; media_cfg->q_factor = mcfg->bit_width - 1; media_cfg->bits_per_sample = mcfg->bit_width; - - audioreach_set_channel_mapping(media_cfg->channel_mapping, - num_channels); + memcpy(media_cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels); rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); @@ -1163,9 +1149,7 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph, cfg->q_factor = mcfg->bit_width - 1; cfg->endianness = PCM_LITTLE_ENDIAN; cfg->num_channels = mcfg->num_channels; - - audioreach_set_channel_mapping(cfg->channel_mapping, - num_channels); + memcpy(cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels); } else { rc = audioreach_set_compr_media_format(header, p, mcfg); if (rc) { diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index eb9306280988..208b74e50445 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -766,6 +766,7 @@ struct audioreach_module_config { /* Packet Allocation routines */ void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t token); +void audioreach_set_channel_mapping(u8 *ch_map, int num_channels); void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode, uint32_t token, uint32_t src_port, uint32_t dest_port); diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index 00bbd291be5c..8ab55869e8a2 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -243,6 +243,7 @@ static int q6apm_dai_prepare(struct snd_soc_component *component, cfg.num_channels = runtime->channels; cfg.bit_width = prtd->bits_per_sample; cfg.fmt = SND_AUDIOCODEC_PCM; + audioreach_set_channel_mapping(cfg.channel_map, runtime->channels); if (prtd->state) { /* clear the previous setup if any */ @@ -669,6 +670,7 @@ static int q6apm_dai_compr_set_params(struct snd_soc_component *component, cfg.num_channels = 2; cfg.bit_width = prtd->bits_per_sample; cfg.fmt = codec->id; + audioreach_set_channel_mapping(cfg.channel_map, cfg.num_channels); memcpy(&cfg.codec, codec, sizeof(*codec)); ret = q6apm_graph_media_format_shmem(prtd->graph, &cfg); diff --git a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c index a4ad1d0e6abd..8340e4fb78f4 100644 --- a/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c +++ b/sound/soc/qcom/qdsp6/q6apm-lpass-dais.c @@ -106,6 +106,7 @@ static int q6hdmi_hw_params(struct snd_pcm_substream *substream, cfg->bit_width = params_width(params); cfg->sample_rate = params_rate(params); cfg->num_channels = channels; + audioreach_set_channel_mapping(cfg->channel_map, channels); switch (dai->id) { case DISPLAY_PORT_RX_0: @@ -130,10 +131,12 @@ static int q6dma_hw_params(struct snd_pcm_substream *substream, { struct q6apm_lpass_dai_data *dai_data = dev_get_drvdata(dai->dev); struct audioreach_module_config *cfg = &dai_data->module_config[dai->id]; + int channels = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max; cfg->bit_width = params_width(params); cfg->sample_rate = params_rate(params); - cfg->num_channels = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS)->max; + cfg->num_channels = channels; + audioreach_set_channel_mapping(cfg->channel_map, channels); return 0; } From patchwork Wed May 8 08:16:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13658241 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5772A52F86 for ; Wed, 8 May 2024 08:16:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156209; cv=none; b=QfAXw/GWbanlLZXRr45tNiIg7bk+DgEI0kc5lyqpzG+7AEDhMHAuIgeFA4wscb+HvNzCPx6x0Rss/6SkPIhD0T9HGL/9GSFOZEcKZOXEqsdgEpEJ4OUAu7pLi8NjlRSErYip4GS3W5bkblSa72qonFPqVDtOrpwIrw9m8HUM5rs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715156209; c=relaxed/simple; bh=RVNDo+PUPNeV1sa0OC/s/rwZqNAdhw3yPx+40/ruZ0I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GrCiNvfxua0ZZnnoqUv/Jq7ENf9l/WmaGUFAgl4+w1jDpSEqeocKzq3CMDCLplwHErH1XemhHmy5t/rZJKpwpX9O1Eh4wkDYQ8w91D0XUjF1CMSp1sSn6L+khJBFA7UeWqJakzqw1mLoZLUMR2iRqorRNqKJtQsfiTrYFXIKIdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SyctnA4x; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SyctnA4x" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a59ab4f60a6so877662266b.0 for ; Wed, 08 May 2024 01:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715156204; x=1715761004; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=sm/iyvA/oRf8IDDwCG6199y51shfGYvzaBKbXuvmT5Q=; b=SyctnA4xYaVsB2PPGVfs+voYP5cw3cQhuWXRyCUAs6+naaiTT1v4+V0CCIJeatEQh6 mJqOzkukGLxu0IcYF9JxVjNSooAsuvfHC/PWaZPpAyuPjHcE0sdBvSVcRMA24wAa1x6G Ih7++DwW++DPUqlHr0rU/w9Uyo7st10AywkFAJWYTtW5tzFeOFbpio6enpG8FpAeKck9 nNbiN00ErA08hpn3oDnK/pAqgwVOtmIKTxFzqgkVD8j+3YuXyp9bpY1EywrTn22aOpBq dk0zoUEG+7rNLIUy622kKBTBLpAqPp1WuRPCRfpE37Vad3Gtsn1c/t8fJMDOoHkkl5ON Oq1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715156204; x=1715761004; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sm/iyvA/oRf8IDDwCG6199y51shfGYvzaBKbXuvmT5Q=; b=R1fG86EtnihhkYpDJc214lNwcHRp6vwt+KQS62QFwjg9lrPsPUm2gP7Zztlb4JD4oL GK1gEQbKI//4CYXAI3BawfDfoGr5t35Bf3r5sD133C9HPZSHgSin5xDxJ6A3nYKUDSg0 bd/DImXNJT8qf/tK8p6DfSMXG/fTliXF4HK4SVbc6dIcqrauTfLKCSNnVl1aua6HJeAt PxPMSdboj7gD7XizAcGic+KFGF+J/oRVZpTI4lXwGoQkuWrQvNjo8RFj4hlMmSVirPcr zJ38qmF6+FLa5s1tKCxQJZmLIqwr7O8I0MulX31jrA4GEZuJwgBKnBPtddfQmGDJvrSj 6mWw== X-Forwarded-Encrypted: i=1; AJvYcCXnPUcABQvHH2uXo1ut3E/zYc40AB5QHvq/RiC81psJ+/uLYnuGxbp9uJDv2Twnx7xNac73wQDW+C+Pi1QNp3cTQRKiBjMzCcuQUek= X-Gm-Message-State: AOJu0YzYHXUfXfd9fQWZMVw33s/dYQ9y+nEN4bbFk0xRcBdvTFhnlftm Xs0hpjTqhAeG54tXRKavjSb8SUiSN6qHlHDs7Fmq8n2Ng9EFxIz2uD8m4vN4Rrs= X-Google-Smtp-Source: AGHT+IEcO03sXS25ca8HNMd80x92ztrXnHCfFufNC3oFOema6hx6ZWP/GUScP9uFCp2eEtc5nFXxgw== X-Received: by 2002:a17:906:c2d9:b0:a59:c23d:85ce with SMTP id a640c23a62f3a-a59fb9c6b24mr143408066b.51.1715156204516; Wed, 08 May 2024 01:16:44 -0700 (PDT) Received: from [127.0.1.1] ([178.197.206.169]) by smtp.gmail.com with ESMTPSA id va28-20020a17090711dc00b00a59b87dd0d7sm4564734ejb.147.2024.05.08.01.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:16:44 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 08 May 2024 10:16:30 +0200 Subject: [PATCH v2 4/4] ASoC: qcom: x1e80100: Correct channel mapping Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240508-asoc-x1e80100-4-channel-mapping-v2-4-ccef9a66a572@linaro.org> References: <20240508-asoc-x1e80100-4-channel-mapping-v2-0-ccef9a66a572@linaro.org> In-Reply-To: <20240508-asoc-x1e80100-4-channel-mapping-v2-0-ccef9a66a572@linaro.org> To: James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Lars-Peter Clausen , =?utf-8?q?Nuno_S=C3=A1?= , Srinivas Kandagatla , Banajit Goswami Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1580; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=RVNDo+PUPNeV1sa0OC/s/rwZqNAdhw3yPx+40/ruZ0I=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmOzTkOvfRHwYugcz1kWoAcP3RrYYVLFgYomUkd wIXaQGCsqWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZjs05AAKCRDBN2bmhouD 17MfD/9ppYgawBoat2rd8pJ2G9oUl2iFD/zoJ64d4jFm5+wgcwXzMQiTRfSf7oFG8U+a9tEP9Lz KIEJluX00tJicgT3dxM0fC1NxHgTQKdyRhCTgsyoYlIdMsM5ffGkaPXZpKUnbZLpvoKC5TS9l45 XuZnc1CaiutElSV2WeOBZN055cBzSup7HUYMjrpjYw1ZjJodQmROFvIp6DC8ck09Eaivs1Faz4A pRgweZoMHmEmVlESPoHB574JtwtKaYnL3naL9Q9PxmReTPmIyHYXlQvao76rKgdsVaHcjuveRWM Se7RGCOp0csNhKv9bvu/U9+OUUUizlnwE1OktST9U9nZxrmM0kTURDj6kz7+84uVwf/dN3AUiq/ akm0Zt99Wo5Jc3m2WwBRizlSMx7SIx6tM8tjNL6NDW296+M4Z4wlKD5o/Vm509RE5V/LSula/Qa G1OvZI53EqPpwlgGtESAYdfmmQl4pnz+mAIbhyevVgEjrpgLmVfUaPb6g9jc45jR8XBkkH+hs8A Pjg++CEL6W05MMiNzBediwzt5EYd8dvKeQB1Bj2P/Y3kfuPKUnW2tJ8b2bevnmE4DJwlHzyCVDT 8sxPzgstpttuV5NNVaJjbbnJr1HFnS3lhLY61Y6JW/kmIRUoEj59SdrGb/tqhXXsz7lQPgYiRhl /HjRVehRnvlOnwg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X1E80100 CRD board comes with four speakers arranged as left front+back and then right front+back. Using default channel mapping causes front right speaker to play left back stream. Signed-off-by: Krzysztof Kozlowski --- Changes in v2: 1. Rework significantly, because only backend DAIs is now affected. --- sound/soc/qcom/x1e80100.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/soc/qcom/x1e80100.c b/sound/soc/qcom/x1e80100.c index c3c8bf7ffb5b..27f34c0873ab 100644 --- a/sound/soc/qcom/x1e80100.c +++ b/sound/soc/qcom/x1e80100.c @@ -12,6 +12,7 @@ #include "common.h" #include "qdsp6/q6afe.h" +#include "qdsp6/q6dsp-common.h" #include "sdw.h" struct x1e80100_snd_data { @@ -80,6 +81,23 @@ static int x1e80100_snd_prepare(struct snd_pcm_substream *substream) struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card); struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; + const unsigned int rx_slot[4] = { PCM_CHANNEL_FL, + PCM_CHANNEL_LB, + PCM_CHANNEL_FR, + PCM_CHANNEL_RB }; + int ret; + + switch (cpu_dai->id) { + case WSA_CODEC_DMA_RX_0: + case WSA_CODEC_DMA_RX_1: + ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, + ARRAY_SIZE(rx_slot), rx_slot); + if (ret) + return ret; + break; + default: + break; + } return qcom_snd_sdw_prepare(substream, sruntime, &data->stream_prepared[cpu_dai->id]);