Skip to contentSkip to conversation

arm64: qcom: Arduino UNO Q: DisplayPort audio playback

PATCH In review Riccardo Mereu 2 participants 8 messages Dec 1

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover arm64: qcom: Arduino UNO Q: DisplayPort audio playback

The Arduino UNO Q (QRB2210) drives DisplayPort over its USB-C port through an ANX7625 bridge. The bridge takes audio on an I2S input wired to the LPASS Secondary MI2S interface. This series adds DP audio playback on top of the sound card support for the board that is already in linux-next.

The ANX7625 has its I2S channel length fixed to 32 bits, while the MI2S backends of the sm8250 machine driver always run with 16-bit slots and a fixed 1.536 MHz bit clock. The board therefore needs a way to ask for 32-bit slots, and the rest of the path has to accept them.

Patches 1-2 are fixes for bugs found while bringing the board up. They do not depend on the rest of the series and can be picked on their own:

- 1: register frontend DAI links before backend ones. The board DT lists its backend links first, and without this patch the card does not register here ("Failed to add route ...", card -19).
- 2: out of bounds write in pm4125 when a compander switch is set.

Patch 3 lets a board run an MI2S backend with 32-bit slots: the sm8250 machine driver takes the slot width from dai-tdm-slot-width in the cpu node of the dai-link and derives the bit clock from the stream parameters. Without the property nothing changes for existing boards. The MI2S playback DAIs already accept S24_LE and S32_LE since commit e03e85ff7500 ("ASoC: qcom: q6dsp: add S24_LE and S32_LE to MI2S playback DAIs").

Patches 4-5 are for the ANX7625: the binding allows #sound-dai-cells and the driver accepts a 32-bit sample width.

Patch 6 describes the DP audio path in the board DT. An overlay that takes the DSI output away from the ANX7625 (a DSI panel) must also disable &dp_audio_link, otherwise the sound card waits for the missing codec and does not register at all.

There are no build dependencies between the ASoC, drm/bridge and DT parts. Patch 6 needs patch 4 to pass dtbs_check, and patches 3 and 5 for the link to work at runtime.

Tested on the Arduino UNO Q on next-20261127, which includes the 24-bit fix for q6asm, commit f29b683543cc ("ASoC: qcom: q6asm: fix 24-bit PCM level via media format V4/V5"):

- The I2S bus captured with a logic analyser: S16_LE, S24_3LE and S32_LE reach the bridge bit-exact, MSB aligned in the 32-bit slots, with a 3.072 MHz bit clock. S32_LE keeps all 32 bits.
- S16_LE, S24_3LE and S32_LE at the same level on a DP monitor, left and right correct, also through PipeWire, which now picks S32_LE.
- 20 stop/prepare cycles of an open stream, 44.1 kHz resampled by the DSP, and DP and headphones playing at the same time.
- Headphone playback and headset microphone capture still work, at 16 and 24 bits.
- With the DP link disabled by an overlay, the card registers without it and the analog paths still work.

Only this board was tested. Other users of the sm8250 machine driver keep S16_LE and a 1.536 MHz bit clock, but the clock is now set in hw_params instead of startup.

Riccardo Mereu (4):
ASoC: codecs: pm4125: add compander channels to the RX channel table
ASoC: qcom: sm8250: support 32-bit MI2S slots
dt-bindings: display: bridge: analogix,anx7625: add #sound-dai-cells
arm64: dts: qcom: qrb2210-arduino-imola: add DP audio playback

Srinivas Kandagatla (2):
ASoC: qcom: common: setup fe dais before be dais drm/bridge: anx7625: accept 32-bit I2S sample width

 .../display/bridge/analogix,anx7625.yaml      |   4 +
 arch/arm64/boot/dts/qcom/Makefile             |   1 +
 .../boot/dts/qcom/qrb2210-arduino-imola.dts   |  43 +++++
 drivers/gpu/drm/bridge/analogix/anx7625.c     |   1 +
 sound/soc/codecs/pm4125-sdw.c                 |   2 +
 sound/soc/qcom/common.c                       | 182 +++++++++++-------
 sound/soc/qcom/sm8250.c                       | 114 ++++++-----
 7 files changed, 216 insertions(+), 131 deletions(-)

base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d

Signature · 16 lines
2.56.1


-- 





Privacy and Confidentiality Notice: This email and all attachments are 
confidential and for the designated recipient(s) only. They may also be 
privileged. If you are not the intended recipient or among the intended 
recipients, you may not use, read, retransmit, disseminate, store/copy the 
information in any medium or take any action in reliance upon it. Please 
notify the sender that you have received it in error and immediately delete 
the entire communication, including any attachments.
#1 lore raw

PATCH 1/6 ASoC: qcom: common: setup fe dais before be dais

From: Srinivas Kandagatla <[email protected]>

qcom_snd_parse_of() registers DAI links in the devicetree order of the sound{} child nodes. q6routing wires static routes such as

    "MM_DL1" -> "MultiMedia1" -> "HDMI Mixer"

which need the frontend (MultiMediaN) widgets to exist before the backend widgets that reference them. This is a latent ordering
bug: any devicetree or overlay that lists a backend node before its matching frontend trips it with

q6routing ...routing: ASoC: Failed to add route MM_DL1(*) -> [MultiMedia1] -> HDMI Mixer q6routing ...routing: ASoC: Failed to add route MM_DL2(*) -> [MultiMedia2] -> HDMI Mixer
...

and today it is easily triggered just by reordering the sound{} children, or by an overlay that appends a backend link.

Iterate the children twice, frontends (no codec child) first and backends (codec child) after, so frontend PCM DAIs are always registered before the backends. Per-node setup is moved into a new qcom_snd_setup_dai_link() helper so both passes are identical; cards where every child has a codec child (non-DPCM) hit only the second pass and see no change.

Fixes c25e295cd77b ("ASoC: qcom: Add support to parse common audio device nodes")
---
 sound/soc/qcom/common.c | 182 ++++++++++++++++++++++++----------------
 1 file changed, 109 insertions(+), 73 deletions(-)
sound/soc/qcom/common.c +109 -73
index af5cacddf67d..372cf5d9813f 100644
@@ -178,12 +178,104 @@ int qcom_snd_apply_dai_tdm_slots(struct snd_soc_pcm_runtime *rtd)
 }
 EXPORT_SYMBOL_GPL(qcom_snd_apply_dai_tdm_slots);
 
+static int qcom_snd_setup_dai_link(struct snd_soc_card *card,
+				   struct snd_soc_dai_link *link,
+				   struct device_node *np)
+{
+	struct device *dev = card->dev;
+	struct snd_soc_dai_link_component *dlc;
+	struct of_phandle_args args;
+	int ret;
+
+	dlc = devm_kzalloc_objs(dev, *dlc, 2);
+	if (!dlc)
+		return -ENOMEM;
+
+	link->cpus	= &dlc[0];
+	link->platforms	= &dlc[1];
+
+	link->num_cpus		= 1;
+	link->num_platforms	= 1;
+
+	ret = of_property_read_string(np, "link-name", &link->name);
+	if (ret) {
+		dev_err(dev, "error getting codec dai_link name\n");
+		return ret;
+	}
+
+	struct device_node *cpu __free(device_node) =
+		of_get_child_by_name(np, "cpu");
+	struct device_node *platform __free(device_node) =
+		of_get_child_by_name(np, "platform");
+	struct device_node *codec __free(device_node) =
+		of_get_child_by_name(np, "codec");
+
+	if (!cpu) {
+		dev_err(dev, "%s: Can't find cpu DT node\n", link->name);
+		return -EINVAL;
+	}
+
+	ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
+	if (ret) {
+		dev_err_probe(dev, ret,
+			      "%s: error getting cpu dai name\n", link->name);
+		return ret;
+	}
+
+	link->id = args.args[0];
+
+	if (link->id >= LPASS_MAX_PORT) {
+		dev_err(dev, "%s: Invalid cpu dai id %d\n", link->name, link->id);
+		return -EINVAL;
+	}
+
+	if (platform) {
+		link->platforms->of_node = of_parse_phandle(platform,
+				"sound-dai",
+				0);
+		if (!link->platforms->of_node) {
+			dev_err(dev, "%s: platform dai not found\n", link->name);
+			return -EINVAL;
+		}
+	} else {
+		link->platforms->of_node = link->cpus->of_node;
+	}
+
+	if (codec) {
+		ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
+		if (ret < 0) {
+			dev_err_probe(dev, ret,
+				      "%s: codec dai not found\n", link->name);
+			return ret;
+		}
+
+		if (platform) {
+			/* DPCM backend */
+			link->no_pcm = 1;
+			link->ignore_pmdown_time = 1;
+		}
+	} else {
+		/* DPCM frontend */
+		link->codecs	 = &snd_soc_dummy_dlc;
+		link->num_codecs = 1;
+		link->dynamic = 1;
+	}
+
+	if (platform || !codec) {
+		/* DPCM */
+		link->ignore_suspend = 1;
+		link->nonatomic = 1;
+	}
+
+	link->stream_name = link->name;
+
+	return 0;
+}
+
 int qcom_snd_parse_of(struct snd_soc_card *card)
 {
 	struct device *dev = card->dev;
 	struct snd_soc_dai_link *link;
-	struct of_phandle_args args;
-	struct snd_soc_dai_link_component *dlc;
 	int ret, num_links;
 
 	ret = snd_soc_of_parse_card_name(card, "model");
@@ -233,88 +325,32 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 	card->num_links = num_links;
 	link = card->dai_link;
 
+	/* Register frontends first so q6routing can resolve BE targets. */
 	for_each_available_child_of_node_scoped(dev->of_node, np) {
-		dlc = devm_kzalloc_objs(dev, *dlc, 2);
-		if (!dlc)
-			return -ENOMEM;
-
-		link->cpus	= &dlc[0];
-		link->platforms	= &dlc[1];
-
-		link->num_cpus		= 1;
-		link->num_platforms	= 1;
-
-		ret = of_property_read_string(np, "link-name", &link->name);
-		if (ret) {
-			dev_err(dev, "error getting codec dai_link name\n");
-			return ret;
-		}
-
-		struct device_node *cpu __free(device_node) =
-			of_get_child_by_name(np, "cpu");
-		struct device_node *platform __free(device_node) =
-			of_get_child_by_name(np, "platform");
 		struct device_node *codec __free(device_node) =
 			of_get_child_by_name(np, "codec");
 
-		if (!cpu) {
-			dev_err(dev, "%s: Can't find cpu DT node\n", link->name);
-			return -EINVAL;
-		}
+		if (codec)
+			continue;
 
-		ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
-		if (ret) {
-			dev_err_probe(dev, ret,
-				      "%s: error getting cpu dai name\n", link->name);
+		ret = qcom_snd_setup_dai_link(card, link, np);
+		if (ret)
 			return ret;
-		}
 
-		link->id = args.args[0];
-
-		if (link->id >= LPASS_MAX_PORT) {
-			dev_err(dev, "%s: Invalid cpu dai id %d\n", link->name, link->id);
-			return -EINVAL;
-		}
-
-		if (platform) {
-			link->platforms->of_node = of_parse_phandle(platform,
-					"sound-dai",
-					0);
-			if (!link->platforms->of_node) {
-				dev_err(dev, "%s: platform dai not found\n", link->name);
-				return -EINVAL;
-			}
-		} else {
-			link->platforms->of_node = link->cpus->of_node;
-		}
+		link++;
+	}
 
-		if (codec) {
-			ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
-			if (ret < 0) {
-				dev_err_probe(dev, ret,
-					      "%s: codec dai not found\n", link->name);
-				return ret;
-			}
+	for_each_available_child_of_node_scoped(dev->of_node, np) {
+		struct device_node *codec __free(device_node) =
+			of_get_child_by_name(np, "codec");
 
-			if (platform) {
-				/* DPCM backend */
-				link->no_pcm = 1;
-				link->ignore_pmdown_time = 1;
-			}
-		} else {
-			/* DPCM frontend */
-			link->codecs	 = &snd_soc_dummy_dlc;
-			link->num_codecs = 1;
-			link->dynamic = 1;
-		}
+		if (!codec)
+			continue;
 
-		if (platform || !codec) {
-			/* DPCM */
-			link->ignore_suspend = 1;
-			link->nonatomic = 1;
-		}
+		ret = qcom_snd_setup_dai_link(card, link, np);
+		if (ret)
+			return ret;
 
-		link->stream_name = link->name;
 		link++;
 	}
 
Signature · 16 lines
2.56.1


-- 





Privacy and Confidentiality Notice: This email and all attachments are 
confidential and for the designated recipient(s) only. They may also be 
privileged. If you are not the intended recipient or among the intended 
recipients, you may not use, read, retransmit, disseminate, store/copy the 
information in any medium or take any action in reliance upon it. Please 
notify the sender that you have received it in error and immediately delete 
the entire communication, including any attachments.
#2 lore raw

PATCH 2/6 ASoC: codecs: pm4125: add compander channels to the RX channel table

In reply to Riccardo Mereu

From: Riccardo Mereu <[email protected]>

The HPHL_COMP and HPHR_COMP switches pass PM4125_COMP_L and PM4125_COMP_R as channel index to pm4125_connect_port(), but pm4125_sdw_rx_ch_info[] only has entries for PM4125_HPH_L and PM4125_HPH_R. The lookup reads past the end of the table and the port number it returns is used, minus one, to index sdw_priv->port_config[]. That writes outside the array, onto the fields around it, including the sruntime pointer just before it.

On the Arduino UNO Q this crashes in two ways: when alsactl restores the compander switches at boot,

  Unable to handle kernel write to read-only memory at virtual address ffff0000c7e3a0e0
  pc : pm4125_connect_port.isra.0+0x2c/0x78 [snd_soc_pm4125]
  lr : pm4125_set_compander+0x84/0xa0 [snd_soc_pm4125]

and on the next hw_free after a compander switch changed the stream pointer:

  Unable to handle kernel paging request at virtual address ffffffffffffffe0
  pc : sdw_slave_port_free+0x48/0x110 [soundwire_bus]
  lr : sdw_stream_remove_slave+0x3c/0x74 [soundwire_bus]
  Call trace:
   sdw_slave_port_free+0x48/0x110 [soundwire_bus] (P)
   sdw_stream_remove_slave+0x3c/0x74 [soundwire_bus]
   pm4125_codec_free+0x2c/0x40 [snd_soc_pm4125]
   snd_soc_dai_hw_free+0x54/0x68 [snd_soc_core]

The driver already defines PM4125_COMP_PORT. Add the two compander channels on it to the RX table, as wcd937x does.

Fixes 8ad529484937 ("ASoC: codecs: add new pm4125 audio codec driver")
---
 sound/soc/codecs/pm4125-sdw.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/codecs/pm4125-sdw.c +2 -0
index c279bf0a88b1..06d51b185e6a 100644
@@ -23,6 +23,8 @@
 static struct wcd_sdw_ch_info pm4125_sdw_rx_ch_info[] = {
 	WCD_SDW_CH(PM4125_HPH_L, PM4125_HPH_PORT, BIT(0)),
 	WCD_SDW_CH(PM4125_HPH_R, PM4125_HPH_PORT, BIT(1)),
+	WCD_SDW_CH(PM4125_COMP_L, PM4125_COMP_PORT, BIT(0)),
+	WCD_SDW_CH(PM4125_COMP_R, PM4125_COMP_PORT, BIT(1)),
 };
 
 static struct wcd_sdw_ch_info pm4125_sdw_tx_ch_info[] = {
Signature · 16 lines
2.56.1


-- 





Privacy and Confidentiality Notice: This email and all attachments are 
confidential and for the designated recipient(s) only. They may also be 
privileged. If you are not the intended recipient or among the intended 
recipients, you may not use, read, retransmit, disseminate, store/copy the 
information in any medium or take any action in reliance upon it. Please 
notify the sender that you have received it in error and immediately delete 
the entire communication, including any attachments.
#3 lore raw

PATCH 3/6 ASoC: qcom: sm8250: support 32-bit MI2S slots

In reply to Riccardo Mereu

From: Riccardo Mereu <[email protected]>

The MI2S backends always run at S16_LE with the bit clock fixed at MI2S_BCLK_RATE (1.536 MHz), which only fits 48 kHz, 2 channels and 16-bit slots. That does not work for every codec: the ANX7625 DP bridge on QRB2210 boards has its I2S channel length fixed to 32 bits, so it needs 32-bit slots and twice the bit clock.

Board compatibles cannot carry this: the Qualcomm RB1 uses the same qcom,qrb2210-sndcard with an LT9611 HDMI bridge on the same port, at S16_LE. Take the setting from the dai-link node instead: with dai-tdm-slot-width = <32> in the cpu node, the backend runs at S32_LE. The DSP sizes the slots from the sample width, so this gives 32-bit slots. An S16_LE front end goes out MSB first at the top of each slot, which is the standard I2S layout.

Set the bit clock in hw_params from the rate, the physical sample width and the channel count, instead of the fixed value at startup, and map each MI2S DAI to its IBIT clock in one helper, so startup does not repeat the same block for every port. Without the property, every current user still runs at S16_LE and 1.536 MHz.

---
 sound/soc/qcom/sm8250.c | 114 ++++++++++++++++++++--------------------
 1 file changed, 56 insertions(+), 58 deletions(-)
sound/soc/qcom/sm8250.c +56 -58
index d0015e5f5257..c4edceb71443 100644
@@ -16,8 +16,6 @@
 #include "usb_offload_utils.h"
 #include "sdw.h"
 
-#define MI2S_BCLK_RATE		1536000
-
 struct sm8250_snd_data {
 	bool stream_prepared[AFE_PORT_MAX];
 	struct snd_soc_card *card;
@@ -65,6 +63,28 @@ static void sm8250_snd_exit(struct snd_soc_pcm_runtime *rtd)
 
 }
 
+static int sm8250_mi2s_bclk_id(int dai_id)
+{
+	switch (dai_id) {
+	case PRIMARY_MI2S_RX:
+		return Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT;
+	case SECONDARY_MI2S_RX:
+		return Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT;
+	case TERTIARY_MI2S_RX:
+		return Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT;
+	case QUINARY_MI2S_RX:
+		return Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT;
+	case SENARY_MI2S_RX:
+		return Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT;
+	case LPI_MI2S_RX_0:
+		return Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT;
+	case LPI_MI2S_TX_3:
+		return Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT;
+	default:
+		return -EINVAL;
+	}
+}
+
 static int sm8250_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 				     struct snd_pcm_hw_params *params)
 {
@@ -73,11 +93,24 @@ static int sm8250_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 	struct snd_interval *channels = hw_param_interval(params,
 					SNDRV_PCM_HW_PARAM_CHANNELS);
 	struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
+	struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
+	struct qcom_snd_tdm_slot_cfg cpu_cfg, codec_cfg;
 
 	rate->min = rate->max = 48000;
 	channels->min = channels->max = 2;
 	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
 
+	/*
+	 * The DSP sizes the MI2S slots from the sample width, so run the
+	 * backend at S32_LE when the board asks for 32-bit slots.
+	 */
+	if (sm8250_mi2s_bclk_id(cpu_dai->id) >= 0 &&
+	    !qcom_snd_get_dai_tdm_slots(rtd, &cpu_cfg, &codec_cfg) &&
+	    cpu_cfg.slot_width == 32) {
+		snd_mask_none(fmt);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S32_LE);
+	}
+
 	return 0;
 }
 
@@ -89,70 +122,34 @@ static int sm8250_snd_startup(struct snd_pcm_substream *substream)
 	struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
 	struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
 
-	switch (cpu_dai->id) {
-	case PRIMARY_MI2S_RX:
-		codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
-		snd_soc_dai_set_sysclk(cpu_dai,
-			Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
-			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
-		snd_soc_dai_set_fmt(cpu_dai, fmt);
-		snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
-		break;
-	case SECONDARY_MI2S_RX:
-		codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
-		snd_soc_dai_set_sysclk(cpu_dai,
-			Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
-			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
-		snd_soc_dai_set_fmt(cpu_dai, fmt);
-		snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
-		break;
-	case TERTIARY_MI2S_RX:
+	if (sm8250_mi2s_bclk_id(cpu_dai->id) >= 0) {
 		codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
-		snd_soc_dai_set_sysclk(cpu_dai,
-			Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
-			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
 		snd_soc_dai_set_fmt(cpu_dai, fmt);
 		snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
-		break;
-	case QUINARY_MI2S_RX:
-		codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
-		snd_soc_dai_set_sysclk(cpu_dai,
-			Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
-			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
-		snd_soc_dai_set_fmt(cpu_dai, fmt);
-		snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
-		break;
-	case SENARY_MI2S_RX:
-		codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
-		snd_soc_dai_set_sysclk(cpu_dai,
-			Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT,
-			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
-		snd_soc_dai_set_fmt(cpu_dai, fmt);
-		snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
-		break;
-	case LPI_MI2S_RX_0:
-		codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
-		snd_soc_dai_set_sysclk(cpu_dai,
-			Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT,
-			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
-		snd_soc_dai_set_fmt(cpu_dai, fmt);
-		snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
-		break;
-	case LPI_MI2S_TX_3:
-		codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
-		snd_soc_dai_set_sysclk(cpu_dai,
-			Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT,
-			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_CAPTURE);
-		snd_soc_dai_set_fmt(cpu_dai, fmt);
-		snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
-		break;
-	default:
-		break;
 	}
 
 	return qcom_snd_sdw_startup(substream);
 }
 
+static int sm8250_snd_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params)
+{
+	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);
+	int clk_id, bclk;
+
+	clk_id = sm8250_mi2s_bclk_id(cpu_dai->id);
+	if (clk_id < 0)
+		return 0;
+
+	/* The DSP clocks out whole slots, so use the physical sample width */
+	bclk = snd_soc_calc_bclk(params_rate(params),
+				 params_physical_width(params),
+				 params_channels(params), 1);
+
+	return snd_soc_dai_set_sysclk(cpu_dai, clk_id, bclk, substream->stream);
+}
+
 static int sm8250_snd_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
@@ -173,6 +170,7 @@ static int sm8250_snd_hw_free(struct snd_pcm_substream *substream)
 
 static const struct snd_soc_ops sm8250_be_ops = {
 	.startup = sm8250_snd_startup,
+	.hw_params = sm8250_snd_hw_params,
 	.shutdown = qcom_snd_sdw_shutdown,
 	.hw_free = sm8250_snd_hw_free,
 	.prepare = sm8250_snd_prepare,
Signature · 16 lines
2.56.1


-- 





Privacy and Confidentiality Notice: This email and all attachments are 
confidential and for the designated recipient(s) only. They may also be 
privileged. If you are not the intended recipient or among the intended 
recipients, you may not use, read, retransmit, disseminate, store/copy the 
information in any medium or take any action in reliance upon it. Please 
notify the sender that you have received it in error and immediately delete 
the entire communication, including any attachments.
#4 lore raw

PATCH 4/6 dt-bindings: display: bridge: analogix,anx7625: add #sound-dai-cells

In reply to Riccardo Mereu

From: Riccardo Mereu <[email protected]>

The ANX7625 driver registers an hdmi-codec device when analogix,audio-enable is set, so boards wire the bridge into a sound card as a DAI provider. The binding does not allow #sound-dai-cells, and with additionalProperties: false any DT doing this fails dtbs_check.

Allow #sound-dai-cells with a value of 1. The cell selects the hdmi-codec DAI; 0 is the I2S input, the only one the driver exposes today. This matches other hdmi-codec bridges such as lontium,lt9611.

---
 .../devicetree/bindings/display/bridge/analogix,anx7625.yaml  | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml +4 -0
index 6ad466952c02..e9eff7b43806 100644
@@ -21,6 +21,9 @@ properties:
   reg:
     maxItems: 1
 
+  "#sound-dai-cells":
+    const: 1
+
   interrupts:
     description: used for interrupt pin B8.
     maxItems: 1
@@ -226,6 +229,7 @@ examples:
             vdd10-supply = <&pp1000_mipibrdg>;
             vdd18-supply = <&pp1800_mipibrdg>;
             vdd33-supply = <&pp3300_mipibrdg>;
+            #sound-dai-cells = <1>;
             analogix,audio-enable;
             analogix,lane0-swing = /bits/ 8 <0x14 0x54 0x64 0x74>;
             analogix,lane1-swing = /bits/ 8 <0x14 0x54 0x64 0x74>;
Signature · 16 lines
2.56.1


-- 





Privacy and Confidentiality Notice: This email and all attachments are 
confidential and for the designated recipient(s) only. They may also be 
privileged. If you are not the intended recipient or among the intended 
recipients, you may not use, read, retransmit, disseminate, store/copy the 
information in any medium or take any action in reliance upon it. Please 
notify the sender that you have received it in error and immediately delete 
the entire communication, including any attachments.
#5 lore raw

PATCH 5/6 drm/bridge: anx7625: accept 32-bit I2S sample width

In reply to Riccardo Mereu

From: Srinivas Kandagatla <[email protected]>

Some I2S hosts, like the Qualcomm Q6 DSP on QRB2210, run the link with 32-bit slots. The ANX7625 handles this: it takes up to 24 valid bits from each slot. Right now hw_params turns down a 32-bit width with -EINVAL, so these hosts get no audio at all.

Treat a 32-bit width like 24 bits and program AUDIO_W_LEN_24_24MAX, the widest word length the chip has.

---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +1 -0
index c3af88e14f8b..cc76000c0888 100644
@@ -2044,6 +2044,7 @@ static int anx7625_audio_hw_params(struct device *dev, void *data,
 		wl = AUDIO_W_LEN_20_20MAX;
 		break;
 	case 24:
+	case 32:
 		wl = AUDIO_W_LEN_24_24MAX;
 		break;
 	default:
Signature · 16 lines
2.56.1


-- 





Privacy and Confidentiality Notice: This email and all attachments are 
confidential and for the designated recipient(s) only. They may also be 
privileged. If you are not the intended recipient or among the intended 
recipients, you may not use, read, retransmit, disseminate, store/copy the 
information in any medium or take any action in reliance upon it. Please 
notify the sender that you have received it in error and immediately delete 
the entire communication, including any attachments.
#6 lore raw

PATCH 6/6 arm64: dts: qcom: qrb2210-arduino-imola: add DP audio playback

In reply to Riccardo Mereu

From: Riccardo Mereu <[email protected]>

The UNO Q drives DisplayPort over its USB-C port through an ANX7625 bridge. The bridge takes audio on an I2S input wired to the LPASS Secondary MI2S interface, data on SD0.

Describe that path: make the ANX7625 a DAI provider, give Secondary MI2S its data line, select the LPI I2S2 pins, and add a DP playback link to the sound card.

The ANX7625 takes standard I2S with its channel length fixed to 32 bits, so the link sets a 32-bit cpu slot width. The link name matches the one used on RB1, and a MultiMedia4 frontend is added because the qcm2290 UCM configuration plays HDMI/DP audio on it.

The DSI lanes also go to a panel connector. A panel there takes DSI0 away from the ANX7625, which then does not register its DAI, and the whole sound card fails to probe. Label the DP link and build the DTB with symbols, so that a panel overlay can disable the link.

---
 arch/arm64/boot/dts/qcom/Makefile             |  1 +
 .../boot/dts/qcom/qrb2210-arduino-imola.dts   | 43 +++++++++++++++++++
 2 files changed, 44 insertions(+)
arch/arm64/boot/dts/qcom/Makefile +1 -0
index 19310879349d..21248c7525c9 100644
@@ -277,6 +277,7 @@ qcs9100-ride-r3-el2-dtbs := qcs9100-ride-r3.dtb lemans-el2.dtbo
 dtb-$(CONFIG_ARCH_QCOM)	+= qcs9100-ride-el2.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= qcs9100-ride-r3-el2.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= qdu1000-idp.dtb
+DTC_FLAGS_qrb2210-arduino-imola := -@
 dtb-$(CONFIG_ARCH_QCOM)	+= qrb2210-arduino-imola.dtb
 dtb-$(CONFIG_ARCH_QCOM)	+= qrb2210-rb1.dtb
 
arch/arm64/boot/dts/qcom/qrb2210-arduino-imola.dts +43 -0

73 lines not on this page · raw message

Signature · 16 lines
2.56.1


-- 





Privacy and Confidentiality Notice: This email and all attachments are 
confidential and for the designated recipient(s) only. They may also be 
privileged. If you are not the intended recipient or among the intended 
recipients, you may not use, read, retransmit, disseminate, store/copy the 
information in any medium or take any action in reliance upon it. Please 
notify the sender that you have received it in error and immediately delete 
the entire communication, including any attachments.
Reviewed-by on v1 6/6
#7 lore raw

Re: [PATCH 6/6] arm64: dts: qcom: qrb2210-arduino-imola: add DP audio playback

Quoted 5 lines · Riccardo Mereu

From: Riccardo Mereu <[email protected]>

The UNO Q drives DisplayPort over its USB-C port through an ANX7625 bridge. The bridge takes audio on an I2S input wired to the LPASS Secondary MI2S interface, data on SD0.

Konrad