From patchwork Tue May 7 10:27: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: 13656578 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.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 DA23014EC7E for ; Tue, 7 May 2024 10:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077668; cv=none; b=f90TZGnKKLRaHXn0Xmc9pauVtRLt719tiiJJMbB00D0/Cde6g5XpX4Hn5Dwo5/WeUEtmcaO7XT/bCRfKmKu+ravXewL+KpkM5MIMEa7NMYswzHYhETk5sWYETKgFYnwCJ0KW5BS0vd7hiLQVaubHXIWWlAamC9/rLl4PDKGxdiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077668; c=relaxed/simple; bh=Yd5y0XTCc1hyaa/GdghPWKfW395tAOrPQ+3gt73tVPA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bAZCJxZBYhM/+lpXU7nGIIZx/6Nmcgm0JxH62B0vc6CyqhnZHuHZkLRCI1zrqBUo/yAQatQm33GHXG5eua9Vix49rf6psIQ7YxU+r5i2CiHe4EBKDxbb3cCMtf7OUdaAEPtr8OG5/ipBfCaeopFoiA/+AiYjYiQ91r8Xz3Zhryk= 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=H5NZm8aA; arc=none smtp.client-ip=209.85.167.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="H5NZm8aA" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-51f45104ef0so3197867e87.3 for ; Tue, 07 May 2024 03:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715077665; x=1715682465; 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=Y3ijywAq87DR82i6I0xJ7qUn776Qu12Oxhv6aBLe9MI=; b=H5NZm8aAgQ2/KxVNngi+/11DZBFePm7GJzUFI983/811eQRDZg9tPY59tn4f3HB9Ff VSV95yUUIEmsxVmtregwQSGgg3TElJyKLhV4ixjoJTuM1eaaqv20bQWA9pk3gjbLHxuA Za/EUW9krpQrvach8YIMrhzkKuNfAxqsvfvNq5ecvPNIgmMgp8a9P/DxIjuC6HpuYEs0 oMNckXE0K1Ij5HzT7xJKGXYr7Tuy9mAka1b/ne6FdkkDuOaGDVSWRl5y4JidJlLG+wxx pN8ZyrBvUBSwoloZBaO/tnuSeL/FtvpZrAfUm2YyuDdPkuoBPb2+qYqlyuX0Zmj6JSdo lKtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715077665; x=1715682465; 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=Y3ijywAq87DR82i6I0xJ7qUn776Qu12Oxhv6aBLe9MI=; b=R4E5X3SriDCeuhHyB1II/EdOklajOUHyhKFoep2x9Jho7rXhjcKLpqBXEMMJA7t/Ys /pOWQdKYghnHgCbEMdbwk5IH0x1LA/KjIIQ8do0jyisJgPsLSWtMjrjxisL6pHnTxuZa 8T2X/U7DaTcyxLbN84Pp3yNA4cgbpWjbikTE3CypFCBtbPme0y+r1aNBRhE58kKOETPZ e09Uy0Bl6HJItv5WN4j4/Aondq7r7iMRI5iE4Nx2z3noNtz49tA6l6H+Z+A9tMDYaADG /pFdZWCWlklY8yTtNzOjP3T3fRIBgawLF3GZ7XUYkui7R+isUf3hx/91+So0CwKqKzig 6Mdg== X-Forwarded-Encrypted: i=1; AJvYcCVYauPR5k2wssXZQDSWncIFvxguiCefYBFjAt/ffh71QnQWO3UlcxeA5qbE1tbXbqzLm6dP0EERXOwkBBkeb7xscYc2+EWJgG/RFYg= X-Gm-Message-State: AOJu0YyxA5PQB0h1sA23cXAhYtYuHC3Ifs1eMpWx1mETgXp5LfVHXErO ZY6jP2yRxk8ArpbotMm75psP0AVVTJ8rl+ISMtZawaFh65/MvvUybjyqlLGokyvzo7AlRt8VvOr l X-Google-Smtp-Source: AGHT+IFyRrIkyKNovHNJaD44VkmQvzSWnGl9GuIzIVGcT3FmHg9oNUq+xd4XDCn3zqRxUQ4eg1wHmA== X-Received: by 2002:ac2:5a07:0:b0:51f:601f:cbae with SMTP id q7-20020ac25a07000000b0051f601fcbaemr6825817lfn.56.1715077664695; Tue, 07 May 2024 03:27:44 -0700 (PDT) Received: from [127.0.1.1] ([178.197.206.169]) by smtp.gmail.com with ESMTPSA id bo15-20020a170906d04f00b00a59b87dd0bbsm3370093ejb.161.2024.05.07.03.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:27:44 -0700 (PDT) From: Krzysztof Kozlowski Date: Tue, 07 May 2024 12:27:30 +0200 Subject: [PATCH 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: <20240507-asoc-x1e80100-4-channel-mapping-v1-1-b12c13e0a55d@linaro.org> References: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@linaro.org> In-Reply-To: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@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=10004; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Yd5y0XTCc1hyaa/GdghPWKfW395tAOrPQ+3gt73tVPA=; b=kA0DAAoBwTdm5oaLg9cByyZiAGY6AhqjPjPYMuBMBQmWEKYRtlETMg2edTTBzYwajHo269E+m YkCMwQAAQoAHRYhBN3SYig9ERsjO264qME3ZuaGi4PXBQJmOgIaAAoJEME3ZuaGi4PXx7YP/ik6 YYkvFP7txSD3qyRPfcYSysD73XwMxoha2BQR2w5rpCwjn0XOzLCmLXUVYYPk38GCJX/WnACOCNV jU9DCCvuUDbX1fAFkzL7ZUY2m5TwP/rl5d0hyQyqGLvqZqjU9H6arlCiqtfJewZlbtCq/q5wkYJ L7d2yYvM9zPsDNircjnKYhQutsNHjCNx+9dHLe80riOCsSW8K7nEM2pCAdBKFsfWlN/1fy5tpCN gT/C5qnY0dx70ATHEkx125PCs92MA/DeJNNO+1A6sgdWZYrgRa7qZL2lsaHKxT2u8JYhgZYmZxK TcL28FDky7lKGZByHWyAZcdZzPCTW3I7M9w7K2Vh/sK4LT8lkOjsPIqES6oG0N3DKzoslWaPWpN PWePIikrRIg17SYRvegSEgTSYRg+KhAlRkD1T5n0tTytuQa5quJ7/YX6h68+F3i5n/DmpnPKqdw G+uYu6qdz7rgsIpU7PNc/+fMISMN5br7AaJBO+LJyv5o+gXhi4AUoc8vYoXMdFhZ/GdKRezfEky +2qyT3Vwn/thTwjaQZz4oo7FWJjxR7zWDHKWGPvPkPfyBsxhnW10JyXMvF18nruH33oFJl9M4fC xTPnEXETfosHV2r7Zh+q27FuaCRw6dSRWeH9aJmuZPRffvTioEYkzjmV5m3oz7G9XaRzdKzghZE qnqJY 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 --- 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 Tue May 7 10:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13656579 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 4E16F14F9DB for ; Tue, 7 May 2024 10:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077670; cv=none; b=Aox7JDjRO9f6d5/JL62IGGy+ZgnpTW74GgDK1l64Y8RVRXgNKfURtjEHjvdQgJop2F5Lk6KXn8M/64oGPX0FsIMSwwIRiWzwxyV1JxjW3uo5saVWDOVmgj5Ga35YS0Tel70/JQSRPnTZG92Tm3YtrwU9vY6MMGb3iHPe9sFSvd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077670; c=relaxed/simple; bh=w+Fl9c8AtnA+l9Cg99+RBTFrfVWFNV6HnWmwPoSsPcg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IFexf/5xQI4C6iE6AGOG4J48c7/R3OaRYJ3xu7GeRvIq8gJZTVhK5kcZjuayDsBbIo+mQfKGWdqCzyMeTDOTsw9txocLuHvdq2MRNRip5nAgSGu9ptt/CWgPURo9JsTv1V8WiMwcpBvCeNF8GImZn0BeuVmilVmwW2mcL65uCYU= 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=rhvo6yVR; arc=none smtp.client-ip=209.85.218.52 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="rhvo6yVR" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a59ab4f60a6so630603566b.0 for ; Tue, 07 May 2024 03:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715077666; x=1715682466; 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=frwVb4bQCosSJuHrr/Xjlu4xhpYBhEr8JVc+TOrLf3o=; b=rhvo6yVRO3lA96Xm578YOIKIGFsiRZjzSmmF2qQEsuAEzPjraUFLt5kPKv9cZdCcIN v+Ul0ElZfzDW3BYB1M/b9XJPLON1+drigHfO1azQ2jhPfqUzTr5CVfLPBHRvoLdjTsd+ uKsPQ9dhIu9fckWNtJtfDtruw5WKgxshAl3VVEKNOrQAGcqln94iKkAcu6mbJD5cr6Bf E4OeEfoTIWMTnckpaL1BlpTncYEXPNiqCZJfu7quYREu2b8CzkbYxdbl0bOSfausBVRU naqMKVtGyp8uKOCwV9Eh0c1w3Oh6PU/6ToAzHwIc5vDE+rWCel/ZZiiko+r2MJ0l/D97 BITQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715077666; x=1715682466; 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=frwVb4bQCosSJuHrr/Xjlu4xhpYBhEr8JVc+TOrLf3o=; b=b+oieiqotYlsZLUvib99W6lxZQiMvy/9W8QdB6AW0iFCVzMGJ+Bo2xUE862+icbibT IxhSrEenFGH+GY7jNF/yeBUDEbuoLxFvAGvCXEmbOnD0AkbCQkFQKePhyxE3VhyYOYOq XotQwtloU8UDkrOqFxj3b97kv0/LBnojWHqDn65IqqNYUVR9ghAKGISBAYmCyBlcA/y4 J5Df82h11Xu65pgnUyc58rCaIniv/q0y7/luXuo/riuesFRnW4X6GxmT091wP4wjFqOE Msdk9WBe8T5ExQpwQ27lQ/GBrGyeHGxraC5fDe0rqdu41sBAvjK5o/huAjMktP3VE5gw wS5w== X-Forwarded-Encrypted: i=1; AJvYcCWutJUsspjC6SIKpXj/LlTtQYLgToVhix+YWE18YTrNtkc3ph+2wmSBmFUzoJeqXCKfWIIpiXMv+LVAFTuVVXbsg9EIlfO7Dopj20k= X-Gm-Message-State: AOJu0YykRFWX1IKu5EQ6/ZHFeeSIbvRbxJI/936lK8B/uFbB60DAbwR/ H2CTHhwJjdqqEDPQPW4LK2Rk5+ftt+5Y7V67UMl/EF+Uha/B9/XS76U0UYKLc1z7WkdjSAnzapR u X-Google-Smtp-Source: AGHT+IHboeLxH9ZlC99nEXUe5Xp5uK4F4Ftf7MB/od/D3dIouLXpgXrm5GbrxBLT3K4oEU8bz77mNw== X-Received: by 2002:a17:906:c415:b0:a59:a977:a159 with SMTP id u21-20020a170906c41500b00a59a977a159mr7420468ejz.64.1715077666141; Tue, 07 May 2024 03:27:46 -0700 (PDT) Received: from [127.0.1.1] ([178.197.206.169]) by smtp.gmail.com with ESMTPSA id bo15-20020a170906d04f00b00a59b87dd0bbsm3370093ejb.161.2024.05.07.03.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:27:45 -0700 (PDT) From: Krzysztof Kozlowski Date: Tue, 07 May 2024 12:27:31 +0200 Subject: [PATCH 2/4] ASoC: qcom: q6dsp: Implement proper channel mapping in Audioreach Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240507-asoc-x1e80100-4-channel-mapping-v1-2-b12c13e0a55d@linaro.org> References: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@linaro.org> In-Reply-To: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@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=5679; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=w+Fl9c8AtnA+l9Cg99+RBTFrfVWFNV6HnWmwPoSsPcg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmOgIaKvmANyZKclREQrsCajh6i81LFK/Hyjt3l OEPizCxqTqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZjoCGgAKCRDBN2bmhouD 1+sMD/90/buBkgY9ho+CVgCsV9DM/H02icdUsmdJiwuG/OCPvTtxuhMqj6GJC4AehbBP7hNPPT2 cNGSXyo/Hhuni/1SQBMTENd7dDpm1/HlcQZohfB3KguU8gd3fmYk5/lEjJrJzf4KNz7FJSQhW+4 48sjo3c23reJCJLpnwgf0a4s9Lu/Hx0Y8n4j3M7+KW5lLP6l2NeawGsxMqA1BQhhbimlVrselDM 35i3dM6uufruxzq+SsEKofs62e583ev9SGUVLoNJgp0LndyW4x/vk5zjJvGA/UGPXC4twme5uhL 9pG0queC+Uw0xrdjt1Ldug2NDgKj1JjWI2FcDY2IKBHeHBghbDgHpwokHlvg/KXD+SVvBKuCk/o 65cWEWJe8EDmVoI3d4wq/owSVc7ZQWdsOBLo6+XYEXBOvE1MO1pWVRu56qzb/whCJotGZbkyTFo vWtfG02mIC9TUSAtGE9YYKiyQEFsDE5pXrLWDQNvL9HqFwDdSGUgSc0BLjkg/YhAkNRh4LQO2UT 3SAfnjqlp1HoR2fToqzcSVSp5JZ3gIsOInJKDyZOVe93dKCp5BUBIXEm2t0vHe6CUm0T2C6wXHl 5WWxmxR4IAj8wvE9r/HF+W4K6L5lK8i4R9levS2CQMMAHvR1Ag4KdwPKq55OPRyWOl1JHge6ltC 7LNJn2vkCcQwugg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Instead of relying on default channel mapping in all Audioreach platforms, implement set_channel_map() callback to allow sound cards customize the mapping depending on needs. The channel mapping is set on frontend DAIs coming from the topology, not DTS, thus need to add DAI ops in topology dai_load() callback. Signed-off-by: Krzysztof Kozlowski --- sound/soc/qcom/qdsp6/audioreach.c | 2 +- sound/soc/qcom/qdsp6/audioreach.h | 1 + sound/soc/qcom/qdsp6/q6apm.c | 28 +++++++++++++++++++++++++++- sound/soc/qcom/qdsp6/q6apm.h | 8 ++++++++ sound/soc/qcom/qdsp6/topology.c | 12 ++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index c655f0213723..8175678d8843 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; diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 2c82917b7162..cef9a9015dcc 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -767,6 +767,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.c b/sound/soc/qcom/qdsp6/q6apm.c index 2a2a5bd98110..c29a2dd36992 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include "audioreach.h" @@ -29,6 +30,29 @@ struct apm_graph_mgmt_cmd { static struct q6apm *g_apm; +static int q6apm_dai_set_channel_map(struct snd_soc_dai *dai, + unsigned int tx_num, + const unsigned int *tx_ch_mask, + unsigned int rx_num, + const unsigned int *rx_ch_mask) +{ + struct q6apm *apm = dev_get_drvdata(dai->dev); + int i; + + if (dai->id >= ARRAY_SIZE(apm->dai_config)) + return -EINVAL; + + apm->dai_config[dai->id].num_channels = rx_num; + for (i = 0; i < rx_num; i++) + apm->dai_config[dai->id].channel_map[i] = rx_ch_mask[i]; + + return 0; +} + +const struct snd_soc_dai_ops q6apm_dai_ops = { + .set_channel_map = q6apm_dai_set_channel_map, +}; + int q6apm_send_cmd_sync(struct q6apm *apm, struct gpr_pkt *pkt, uint32_t rsp_opcode) { gpr_device_t *gdev = apm->gdev; @@ -722,7 +746,7 @@ static int apm_probe(gpr_device_t *gdev) { struct device *dev = &gdev->dev; struct q6apm *apm; - int ret; + int ret, i; apm = devm_kzalloc(dev, sizeof(*apm), GFP_KERNEL); if (!apm) @@ -733,6 +757,8 @@ static int apm_probe(gpr_device_t *gdev) mutex_init(&apm->lock); apm->dev = dev; apm->gdev = gdev; + for (i = 0; i < ARRAY_SIZE(apm->dai_config); i++) + audioreach_set_channel_mapping(apm->dai_config[i].channel_map, 4); init_waitqueue_head(&apm->wait); INIT_LIST_HEAD(&apm->widget_list); diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index c248c8d2b1ab..0e2e7b6cd6c1 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -47,6 +47,11 @@ #define APM_LAST_BUFFER_FLAG BIT(30) #define NO_TIMESTAMP 0xFF00 +struct q6apm_dai_config { + unsigned int num_channels; + u8 channel_map[AR_PCM_MAX_NUM_CHANNEL]; +}; + struct q6apm { struct device *dev; gpr_port_t *port; @@ -65,6 +70,7 @@ struct q6apm { struct idr sub_graphs_idr; struct idr containers_idr; struct idr modules_idr; + struct q6apm_dai_config dai_config[4]; }; struct audio_buffer { @@ -108,6 +114,8 @@ struct q6apm_graph { struct audioreach_graph_info *info; }; +extern const struct snd_soc_dai_ops q6apm_dai_ops; + /* Graph Operations */ struct q6apm_graph *q6apm_graph_open(struct device *dev, q6apm_cb cb, void *priv, int graph_id); diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c index 70572c83e101..9708d200568d 100644 --- a/sound/soc/qcom/qdsp6/topology.c +++ b/sound/soc/qcom/qdsp6/topology.c @@ -1034,6 +1034,17 @@ static int audioreach_tplg_complete(struct snd_soc_component *component) return 0; } +static int audioreach_dai_load(struct snd_soc_component *cmp, int index, + struct snd_soc_dai_driver *dai_drv, + struct snd_soc_tplg_pcm *pcm, + struct snd_soc_dai *dai) +{ + if (pcm) + dai_drv->ops = &q6apm_dai_ops; + + return 0; +} + /* DAI link - used for any driver specific init */ static int audioreach_link_load(struct snd_soc_component *component, int index, struct snd_soc_dai_link *link, @@ -1251,6 +1262,7 @@ static struct snd_soc_tplg_ops audioreach_tplg_ops = { .widget_unload = audioreach_widget_unload, .complete = audioreach_tplg_complete, + .dai_load = audioreach_dai_load, .link_load = audioreach_link_load, .dapm_route_load = audioreach_route_load, From patchwork Tue May 7 10:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13656580 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 ABC291514C8 for ; Tue, 7 May 2024 10:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077671; cv=none; b=ai41lsFBCH49oPwPqaP7BC/txeyu+s7w88847G63a/NBXEc3dwLSSaX5tFTCPSASUXJGMXbAQqou425Mjitx+m2vFNycc6R8nVf8FFUeA/sWgreCINKbaE27qT4x7xzKWumFMJQT36+AYrtCxpAPEayHqDnhJq0/4M5EwJIfSbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077671; c=relaxed/simple; bh=61rdmjNwJzA0Rtp3TjaO5PN4giA8+BNLRSAlZB30sVw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V2MprY2yPKTPjhceee5bGocju8VeGvMK7McOqHQyniBfb0HBVaiqLF+m7Mi+E3DpA/GFv3WGddtNWysHV6dfKkZF/nnxCOGYKo24cNru12BKOMstXE8gerJCQDqcSd7NLFVaAuItiWusOdvsvcxRcUP/CwQL1BbwYn84txqOozU= 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=YO7bnWpT; arc=none smtp.client-ip=209.85.218.48 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="YO7bnWpT" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a59b81d087aso618100666b.3 for ; Tue, 07 May 2024 03:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715077667; x=1715682467; 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=fudiQRTJbxGJqty5CRk/uevh8tsrjGRaaIqrnS9XFA8=; b=YO7bnWpTjgGMIv+4oWS3EYt2oK8L2JMip7PAVyooVDtmzkn/tkdaTLhHD+yEyxlSbA dfNTPuHM7IZjVMOeJVObS3o+3dIQ75z6RM0Gl7SfJgV1mWe/WW425pozwnQFYUpWUY0S piDjMDbHQp+T+HanCyqbSAuw6g/xC4jM1gdniGF1WWaj6GQw3JKHiCYWQsae20VG1/qp FgJY4wRx/H10eeoOFUAZAUTe+jSp4pNZTQnGqxVWd2b0Ta3KT1AQLHTQzTEZV71zcuWb N2SI/exSodMjxyp/OS70YqinGpe4LqubnAIo6bg8o/MyxafvGHKY8/zemmeWiWjGE2MZ WXJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715077667; x=1715682467; 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=fudiQRTJbxGJqty5CRk/uevh8tsrjGRaaIqrnS9XFA8=; b=SNmrrmYq9xYRmb4iZLBkf9my1xSTp+gKIi/+Xvcmq1JwPa8nMPuo9I8JicIjObsRQ0 lzRuUovXBzWWJDV3ipHu++oFhnBK3CTXL21PsJHazgUJhtGszMOvrekCDwhNHxQhSr5L FfMYNVRSxCMegVDptk/bxF/4FGgKjJTAlJsawsrXH6W+LXTeNB01EWHM+h3FEpwSCoFN Jvrh+Kp7vwd29h0AQRvu3E7zw+X+LAcvPxVCHh2SKv5ZapX8g8CwZSQiWJX7Z77bCOCq 9pdIObIkqhlH+umQF0Q1mvWwQvLz+8+WVRwPdy9VQX8h5eafxS5bVXdUOWKrsAtPmhw9 ZEYg== X-Forwarded-Encrypted: i=1; AJvYcCVqqFEQ/egSWz++EYIyP+jOKaSf5JsWW6GL9l3nJ/lHKZgTMu4UcBo9/2/XT2h12FObrFPtTcGbUJk8nj7V8gzsr+GiZNSDOlo7h0Y= X-Gm-Message-State: AOJu0YygreU8Bd8P5qO+RdqPbM2RmXTho9NPWKaGkx3AaUfjqLKomjHP ddTaFQ8tM0xu7SkQGvlnZmjIndZT23JiRKXSe1KcJON1tDwxC0emQN8HQePubWRrCfWLTjc1tBW k X-Google-Smtp-Source: AGHT+IHeOlkBiIXj8Ch31jd6t9X4LVA9p4Vu0ILX858d59ZVwRVIRHE6OkXJlDTMC2ytyTIzzPodsw== X-Received: by 2002:a17:907:968a:b0:a59:d39a:8d6b with SMTP id hd10-20020a170907968a00b00a59d39a8d6bmr5605681ejc.43.1715077667462; Tue, 07 May 2024 03:27:47 -0700 (PDT) Received: from [127.0.1.1] ([178.197.206.169]) by smtp.gmail.com with ESMTPSA id bo15-20020a170906d04f00b00a59b87dd0bbsm3370093ejb.161.2024.05.07.03.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:27:47 -0700 (PDT) From: Krzysztof Kozlowski Date: Tue, 07 May 2024 12:27:32 +0200 Subject: [PATCH 3/4] ASoC: qcom: q6dsp: 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: <20240507-asoc-x1e80100-4-channel-mapping-v1-3-b12c13e0a55d@linaro.org> References: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@linaro.org> In-Reply-To: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@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=5315; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=61rdmjNwJzA0Rtp3TjaO5PN4giA8+BNLRSAlZB30sVw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmOgIbJbQul/L/8gMPvUdCdFm1n2BLVDa2rGuTT vd895AN+lyJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZjoCGwAKCRDBN2bmhouD 1xuFD/4j2Tg7l1A0ljCHS9wL5fFYDjnOz06WS1T18RBCRlyN4NQ/j474jqc2h/FBN0Zlo+v3Ovl J7qzwq7HL5C4l+Zan5FRXXcAujOhPK4USRvN4uZFKEyNz8LLKEx+Rk2XACNcZYDO8NQie2+IqVf IvE0prnkEjVOTrqmGWzbUV7Yrw5jzR9fmGG0iTYcLhsdmpC3GX+iKqiMZPy+lsc77EKJfe6ajpw kad/dTTUbHuWNyfygNAwZ4fmq0gZ3+VihnTIhcxDvli84fEr2reiZfzjtIo0oIWLqE9AO4mFoMI svJiGg5z0l64QhSnN4AWf3euEdUat7oViLkMpY06lrENrr/Vg4gIqTGRr7tnkOueOt/wGFoHXUG wIa65wXzRNA1TpNPaB6Fox6Pig6ImS8qbvPsBdigarlh49d42NKlPGTFHmNbtqnUTyoKfiz1yP6 pMB5UD2vF7SvKSsHImW7dHuXdVYGKkbRnimEi0pcGrCoG1VQEGqrYaTbuxs+Y/0YvObF3bk1Sx+ 90pYsJ8rX+RxNRs2LyfuC6jxIrzxvrWkSjkmt+Lo7Nl/dIH3ChQ013kmKXfYIxk9zRF9Gmow8/O rnHDyhpunMW9tGqAfJx+VOOVD4sopCh7ZCGOQnbwwJJQuypXuZlFsitiyFkTZ/h4jQZLlerg99v fK+FD8dkPIwZB/Q== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Use previously set channel mapping instead of defaults when preparing frontent Q6APM component. This allows machine sound card drivers to override channel mappings. Signed-off-by: Krzysztof Kozlowski --- sound/soc/qcom/qdsp6/audioreach.c | 14 +++++--------- sound/soc/qcom/qdsp6/audioreach.h | 2 +- sound/soc/qcom/qdsp6/q6apm-dai.c | 12 ++++++++++++ sound/soc/qcom/qdsp6/q6apm.c | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 8175678d8843..83b33e4c9de2 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); -void audioreach_set_channel_mapping(u8 *ch_map, int num_channels) +void audioreach_set_default_channel_mapping(u8 *ch_map, int num_channels) { if (num_channels == 1) { ch_map[0] = PCM_CHANNEL_FL; @@ -884,8 +884,8 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr, mp3_cfg->endianness = PCM_LITTLE_ENDIAN; mp3_cfg->num_channels = mcfg->num_channels; - audioreach_set_channel_mapping(mp3_cfg->channel_mapping, - mcfg->num_channels); + audioreach_set_default_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 +1104,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 +1161,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 cef9a9015dcc..6ae95eb85118 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -767,7 +767,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_set_default_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..5dfbd011bb97 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -223,7 +224,10 @@ static int q6apm_dai_prepare(struct snd_soc_component *component, struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(soc_prtd, 0); struct q6apm_dai_rtd *prtd = runtime->private_data; + struct q6apm *apm = prtd->graph->apm; struct audioreach_module_config cfg; struct device *dev = component->dev; struct q6apm_dai_data *pdata; @@ -238,9 +242,17 @@ static int q6apm_dai_prepare(struct snd_soc_component *component, return -EINVAL; } + if (cpu_dai->id >= ARRAY_SIZE(apm->dai_config)) { + dev_err(dev, "Unsupported DAI ID number %d (%s)\n", + cpu_dai->id, cpu_dai->name); + return -EINVAL; + } + cfg.direction = substream->stream; cfg.sample_rate = runtime->rate; cfg.num_channels = runtime->channels; + memcpy(cfg.channel_map, apm->dai_config[cpu_dai->id].channel_map, + runtime->channels); cfg.bit_width = prtd->bits_per_sample; cfg.fmt = SND_AUDIOCODEC_PCM; diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index c29a2dd36992..f6fa15f42633 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -758,7 +758,7 @@ static int apm_probe(gpr_device_t *gdev) apm->dev = dev; apm->gdev = gdev; for (i = 0; i < ARRAY_SIZE(apm->dai_config); i++) - audioreach_set_channel_mapping(apm->dai_config[i].channel_map, 4); + audioreach_set_default_channel_mapping(apm->dai_config[i].channel_map, 4); init_waitqueue_head(&apm->wait); INIT_LIST_HEAD(&apm->widget_list); From patchwork Tue May 7 10:27:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13656581 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 EC1511514EE for ; Tue, 7 May 2024 10:27:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077672; cv=none; b=lZjbEarKzrLhf1Fi4VAfLWrljMB8Zwba6kpSRWunVCjvQo6AwwinMXxc6uZpXH+q+Hwr5RzXWjTg4uc1ACYFqqba4JqDdzbGJ59ymdtnTNSiDAwoiLt3+tX5k6ZQmDGidNwGtYytCRNE8hdkL62beVuENbWVnw692tXYlWno7Sc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715077672; c=relaxed/simple; bh=ncE3FH0TY58sFGa9Rl6y2ExmL1TBCQDazEEcf1SbmOY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q+49bibiWDOafECDCSeAuKYTemy6Ol3SO5vqLP3rDjSo5rqicxjcAtRXfrpw2L1M27qHlKvV5N1v4uzw+SRf0Cj+J0KRoDwU8S2YccD5ese1VR3ZrqqNeDdVOl8D/vis76L+eVQfV+kOes8/nVUCyZ4s1zIK1pfgnJVov9JNKN0= 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=bTqboszw; arc=none smtp.client-ip=209.85.218.54 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="bTqboszw" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a59ce1e8609so309693366b.0 for ; Tue, 07 May 2024 03:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715077669; x=1715682469; 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=4nKzFo7oe//9kG74WVhks4ZLuw4EcTS+WpLRtZjt0GY=; b=bTqboszwrQ4aUsNQ4cwbqXwqnXgXwUR9tNkxITgpR1n2X4hAiCOXDr8wPemJpKK48a TiVDbDcWTHE6Qb8FFYouZJzkTPgN9nB9D5bqhgfbx8rxS5Y30upEQNr5d9B08ckfde8N w/86sj4hDO6uQprJrCCGQtccFK9ckR3JBAHVWqE7KShnyUTvwcuJxasS95Nqm7Dnp6rP xUAx8Wy2/j/nOM7QbJaq26x3Fjtyde/RzxwsKcoEFK8jkQVWbio4b0ZgWBu5R4g2MgEY BbBn/JV9grFEdlbAfktwt7bu5JWYO+SNeU27n/SrtbcYmx2rNAc0b7Mn0k7vuOV0rIBM n09w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715077669; x=1715682469; 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=4nKzFo7oe//9kG74WVhks4ZLuw4EcTS+WpLRtZjt0GY=; b=nFBuCLA8kMFBvAjSNAv7NQCKWK3qvbUiEfG0rKvnKTjrKQeUDqSnqDgKyDz57e9eEo pCc1BFmI/z0SoNNymk/49Sa9t97VpyB1eFeKifBSDGGGZgFqswF1Oj4SdoK6/KR8AKgg tE9mwPsUkGSq1QBEYimiMmWaM5t0LcUSb16qCrfdJBzQAENwpvFt4vUiwzmtnkAvlF9U jLncvdBJO0rqJyJ3q8/+HaduVANmkA12ec9zZAn1R+doUTRtyqNctTRFHutVthr72S5L 2inCp4xTUa0y2dwwXCzRF0AAC/S08mtdAyhkkeasnPBp9Qf6W/OYwme6NHmoIro5p5fj gp8w== X-Forwarded-Encrypted: i=1; AJvYcCWjYBrFZDU7doBc+YyskmOszR7CNnwO/79z4sbd2GRFOK0X7zNw2MuvoCVcLwUeSvrycpBbPglsmS+QJBrUqculEwDNSdrprewB4MQ= X-Gm-Message-State: AOJu0Yx79Y0dPNO+Q1cHVT/4jWENkLUJ3TzVwpoNkm588ctc3JkfXPI8 DIMmHSTKj4HXtxNzCO7TpuDvZfa1Wa4HoPlIZJSJkLYwB84ypug5Nd8rQa/7vIEOMFGTuciA4cs j X-Google-Smtp-Source: AGHT+IHxr+kpeiafMqoxHfKgf5yt6IB9ScYZU6jaD6rdvbS50GCRRhzNcEFrQXFWvrvB3EXyV7WKoA== X-Received: by 2002:a17:906:71c9:b0:a55:aded:200d with SMTP id i9-20020a17090671c900b00a55aded200dmr1705986ejk.12.1715077668923; Tue, 07 May 2024 03:27:48 -0700 (PDT) Received: from [127.0.1.1] ([178.197.206.169]) by smtp.gmail.com with ESMTPSA id bo15-20020a170906d04f00b00a59b87dd0bbsm3370093ejb.161.2024.05.07.03.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:27:48 -0700 (PDT) From: Krzysztof Kozlowski Date: Tue, 07 May 2024 12:27:33 +0200 Subject: [PATCH 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: <20240507-asoc-x1e80100-4-channel-mapping-v1-4-b12c13e0a55d@linaro.org> References: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@linaro.org> In-Reply-To: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@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=3113; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=ncE3FH0TY58sFGa9Rl6y2ExmL1TBCQDazEEcf1SbmOY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmOgIcJ8C4pKpQ2s1uPew1mzWN5b8egwDGkdXHd q6kDAPoZn6JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZjoCHAAKCRDBN2bmhouD 14RHD/97iqUCmd+/m5xbNrWdeCNRTnpiBM/7B858xCTJ9NZ21Z+511GhAjTfglasiURr7dVtlEY DX2TAk/WsCkE+LiRRLwpSa61DvhwbUPUPzS8ACCMsuP9ol0hFdJeGBrqLiLFfcpxG2fNxJDEE7k aMyuiQOveIQGqtl25oREsxDO/tSzrYnrkKsv9w4y1D1qTTnttcJ1kj2S21B1J5i/s4+urXfFWNH vEEWa8+HQO0lZ3gG0AmsF/KyIf3S4bMr9BnIOjfVCAdOM0AZ+V0r06+JwtWLM7IQtttq5j1yRgR hcq5iN8bKo4uiQ+YZEozR9/7hlxkxrxMaFUMG+QR3PqAfDuB4Ra+uKY253yukq/UFjA2SN2J7jH Nuq1ZqtsVmeHP5WpAUAtsWvEudUHSn5EBM9lfmJ5v4NtMTkbAkorOB4c2EBWR5T6spWKef9zNPF mugo2RADZpNz7rloQpQkgktnSGHCAO9DnIyd/jk1iZgEeCXS/ymruAZ8Ave7zDhQbRvHho3xgDg rDy/wf/ztDUnYstNhQEgeaKoFQiRej8HVlUVKyWoCbL6p/kpbhr05aaxS/sNImzgAZKVF/za7Tk xA5dKkU8x0uhU75l34zhUh3uj8ePWn6GPltw30TgCTuzTE+qAswufzAzGNAayAeB9VuclLAtYNx UQ6b4+9KKmjCqnQ== 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. Adjust the channel maps for frontend DAIs to fix stereo and four-channel playback. Signed-off-by: Krzysztof Kozlowski --- sound/soc/qcom/x1e80100.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/x1e80100.c b/sound/soc/qcom/x1e80100.c index c3c8bf7ffb5b..e90c68815b5c 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 { @@ -74,7 +75,7 @@ static int x1e80100_snd_hw_params(struct snd_pcm_substream *substream, return qcom_snd_sdw_hw_params(substream, params, &data->sruntime[cpu_dai->id]); } -static int x1e80100_snd_prepare(struct snd_pcm_substream *substream) +static int x1e80100_snd_be_prepare(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); @@ -96,12 +97,34 @@ static int x1e80100_snd_hw_free(struct snd_pcm_substream *substream) &data->stream_prepared[cpu_dai->id]); } +static int x1e80100_snd_fe_prepare(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + const unsigned int rx_slot[4] = { PCM_CHANNEL_FL, + PCM_CHANNEL_LB, + PCM_CHANNEL_FR, + PCM_CHANNEL_RB }; + + snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, ARRAY_SIZE(rx_slot), + rx_slot); + } + + return 0; +} + static const struct snd_soc_ops x1e80100_be_ops = { .startup = qcom_snd_sdw_startup, .shutdown = x1e80100_snd_shutdown, .hw_params = x1e80100_snd_hw_params, .hw_free = x1e80100_snd_hw_free, - .prepare = x1e80100_snd_prepare, + .prepare = x1e80100_snd_be_prepare, +}; + +static const struct snd_soc_ops x1e80100_fe_ops = { + .prepare = x1e80100_snd_fe_prepare, }; static void x1e80100_add_be_ops(struct snd_soc_card *card) @@ -118,6 +141,15 @@ static void x1e80100_add_be_ops(struct snd_soc_card *card) } } +static int x1e80100_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link) +{ + /* Add ops for Frontend DAIs coming from Topology */ + if (link->dynamic && !link->no_pcm && !link->ops) + link->ops = &x1e80100_fe_ops; + + return 0; +} + static int x1e80100_platform_probe(struct platform_device *pdev) { struct snd_soc_card *card; @@ -135,6 +167,7 @@ static int x1e80100_platform_probe(struct platform_device *pdev) card->owner = THIS_MODULE; card->dev = dev; + card->add_dai_link = x1e80100_add_dai_link; dev_set_drvdata(dev, card); snd_soc_card_set_drvdata(card, data);