Skip to contentSkip to conversation

ASoC: tas2783-sdw: restore the stereo split when no SDCA function data

PATCH Superseded Lee Mann 2 participants 2 messages Dec 3

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Lee Mann

author
#0 lore raw

PATCH v2 1/1 ASoC: tas2783-sdw: restore the stereo split when no SDCA function data

Commit f42fbd560cd8 ("ASoC: tas2783-sdw: add firmware download status check") removed the per-amp channel mask from tas_sdw_hw_params(), on the basis that the channel is selected by the SDCA init table from ACPI DisCo.

That only holds when the SmartAmp function is parsed. On the ASUS ProArt PX13 (HN7306EA, two TAS2783 on SoundWire link 1) the ACPI declares the function type without a DisCo constant, so sdca_parse_function() fails, sa_func_data stays NULL and the init table is never written. Both amps keep ClusterIndex 0x01 from tas2783_init_seq and, with the full playback mask, the right speaker is silent.

Restore the split for that case only: when sa_func_data is NULL and the link has one amp per channel, give each amp a single channel from its machine-assigned prefix, as before f42fbd560cd8, and set ch_count to match the mask. Links with more amps than channels, such as the four-amp tas2783_2_adr boards, keep the full mask: there the split pushes amps 3 and 4 past the two-channel payload. Platforms where the init table is applied are unchanged.

Tested on the PX13 on v7.3.7 with the v7.4-rc5 driver plus this patch, speaker-test -c2 -t wav: left and right correct.

Fixes f42fbd560cd8 ("ASoC: tas2783-sdw: add firmware download status check")
Assisted-by LLM

---
v2:
- only split when the link has two amps (Mark: four-amp tas2783_2_adr; Waldemar Hamm's report from a four-amp HP board shows amps 3/4 silent with the split and correct stereo with the full mask)
- set stream_config.ch_count to 1 to match the mask (Mark). On AMD it only sizes the port slot reservation (offsets come from the mask); the generic allocator used by Intel doesn't read it.

Baojun, could you check v2 on your two-amp boards? I expect them to log "Found Smart Amp function", in which case nothing changes there.

v1: https://lore.kernel.org/all/?q=s%3A%22restore+the+stereo+split%22

AI note: written with Claude Code; I reviewed, built and tested it.

 sound/soc/codecs/tas2783-sdw.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
sound/soc/codecs/tas2783-sdw.c +24 -0
index 3f21700..76280f6 100644
@@ -995,6 +995,30 @@ static s32 tas_sdw_hw_params(struct snd_pcm_substream *substream,
 	snd_sdw_params_to_config(substream, params,
 				 &stream_config, &port_config);
 
+	/*
+	 * Without the SDCA SmartAmp function data from ACPI DisCo, the per-amp
+	 * init table that selects each amp's channel is never written and both
+	 * amps keep the ClusterIndex from tas2783_init_seq, so with the full
+	 * mask from snd_sdw_params_to_config() the pair renders one channel.
+	 * With one amp per channel, give each amp its own channel, keyed off
+	 * the machine-assigned prefix (tas2783-1 left, tas2783-2 right).
+	 * Links with more amps than channels keep the full mask, as do
+	 * platforms where the init table selects the channel.
+	 */
+	if (!tas_dev->sa_func_data &&
+	    substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+	    params_channels(params) == 2 &&
+	    snd_soc_substream_to_rtd(substream)->dai_link->num_codecs == 2 &&
+	    component->name_prefix) {
+		const char *idx_str = strrchr(component->name_prefix, '-');
+		unsigned long idx;
+
+		if (idx_str && !kstrtoul(idx_str + 1, 10, &idx) && idx) {
+			port_config.ch_mask = (idx & 1) ? BIT(0) : BIT(1);
+			stream_config.ch_count = 1;
+		}
+	}
+
 	/* port 1 for playback */
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 		port_config.num = 1;
Signature · 1 line
2.56.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] ASoC: tas2783-sdw: inaccurate comment on ClusterIndex and ch_mask routing --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] ASoC: tas2783-sdw: inaccurate comment on ClusterIndex and ch_mask routing
--

commit faa58a455f0635ef0eb57c9ed35971c94e6b53eb
Author: Lee Mann <[email protected]>

ASoC: tas2783-sdw: restore the stereo split when no SDCA function data

This commit restores a single-channel port_config.ch_mask and sets stream_config.ch_count to 1 in tas_sdw_hw_params() for two-amp playback links when SDCA SmartAmp function data is unavailable.

Quoted 21 lines
sound/soc/codecs/tas2783-sdw.c +13 -0
index 08b37e7b3a9e4..899873a169b43 100644
@@ -994,6 +994,30 @@ static s32 tas_sdw_hw_params(struct snd_pcm_substream *substream,
 	snd_sdw_params_to_config(substream, params,
 				 &stream_config, &port_config);
 
+	/*
+	 * Without the SDCA SmartAmp function data from ACPI DisCo, the per-amp
+	 * init table that selects each amp's channel is never written and both
+	 * amps keep the ClusterIndex from tas2783_init_seq, so with the full
+	 * mask from snd_sdw_params_to_config() the pair renders one channel.
+	 * With one amp per channel, give each amp its own channel, keyed off
+	 * the machine-assigned prefix (tas2783-1 left, tas2783-2 right).
+	 * Links with more amps than channels keep the full mask, as do
+	 * platforms where the init table selects the channel.
+	 */
+	if (!tas_dev->sa_func_data &&
+	    substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+	    params_channels(params) == 2 &&

sound/soc/codecs/tas2783-sdw.c static s32 tas_sdw_hw_params(struct snd_pcm_substream *substream, · line 1019

Quoted 10 lines
sound/soc/codecs/tas2783-sdw.c +10 -0
+	    snd_soc_substream_to_rtd(substream)->dai_link->num_codecs == 2 &&
+	    component->name_prefix) {
+		const char *idx_str = strrchr(component->name_prefix, '-');
+		unsigned long idx;
+
+		if (idx_str && !kstrtoul(idx_str + 1, 10, &idx) && idx) {
+			port_config.ch_mask = (idx & 1) ? BIT(0) : BIT(1);
+			stream_config.ch_count = 1;
+		}
+	}

[Severity: Low]
Are the comment and commit message accurate in saying both amps keep ClusterIndex from tas2783_init_seq? tas2783_init_seq writes control 0x10 on TAS2783_SDCA_ENT_PPU21, which is SDCA_CTL_PPU_POSTURENUMBER, not ClusterIndex (control 0x10 on TAS2783_SDCA_ENT_UDMPU23).

The comment also implies that BIT(0) vs BIT(1) from component->name_prefix selects left vs right. sdw_compute_slave_ports() only uses hweight32(p_rt->ch_mask) to advance port_bo across m_rt->slave_rt_list, so channel assignment comes from codec ordering on the DAI link, not the bit.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1