Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topology2: force all SoundWire link-side copiers to use S24_LE #9282

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

plbossart
Copy link
Member

@plbossart plbossart commented Jul 4, 2024

Using S32_LE wastes bandwdith for no good reason, we should use 24 bits on the link to maximize bus efficiency with the 9.6 MHz bus clock.

FIXME: it's likely we need a kernel-side change as well to configure the hw_params to S24_LE, currently the stream/port is configured with

sconfig.bps = snd_pcm_format_width(params_format(params));

Link: #8960

@plbossart
Copy link
Member Author

looks like this topology change is enough, according to kernel logs this changes the format

[  167.550540] snd_sof:sof_ipc4_pcm_dai_link_fixup: sof-audio-pci-intel-mtl 0000:00:1f.3: Set SDW0-Playback to 24 bit format
[  167.748407] snd_sof:sof_ipc4_pcm_dai_link_fixup: sof-audio-pci-intel-mtl 0000:00:1f.3: Set SDW1-Playback to 24 bit format
[  167.770560] snd_sof:sof_ipc4_pcm_dai_link_fixup: sof-audio-pci-intel-mtl 0000:00:1f.3: Set SDW0-Capture to 24 bit format
````

@bardliao
Copy link
Collaborator

bardliao commented Jul 4, 2024

looks like this topology change is enough, according to kernel logs this changes the format

[  167.550540] snd_sof:sof_ipc4_pcm_dai_link_fixup: sof-audio-pci-intel-mtl 0000:00:1f.3: Set SDW0-Playback to 24 bit format
[  167.748407] snd_sof:sof_ipc4_pcm_dai_link_fixup: sof-audio-pci-intel-mtl 0000:00:1f.3: Set SDW1-Playback to 24 bit format
[  167.770560] snd_sof:sof_ipc4_pcm_dai_link_fixup: sof-audio-pci-intel-mtl 0000:00:1f.3: Set SDW0-Capture to 24 bit format

Yes, we did it at https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/ipc4-pcm.c#L713.

@plbossart
Copy link
Member Author

@bardliao I vaguely recall that the RT713/1713 configuration would give us one playback stream for the heaphone and two capture streams for headset and mic. Did we have any other cases where we ran out of bandwidth with a 4.8MHz clock?
I guess for the Rt722 we will have to use 9.6 MHz or two lanes, there's potentially 4 streams and that will not fly at 4.8/single lane.

@plbossart
Copy link
Member Author

plbossart commented Jul 4, 2024

Not sure what I did but now I have zero valid bits haha Pin index #0: 0Hz, 0bit, 0ch

https://sof-ci.01.org/sofpr/PR9282/build6224/devicetest/index.html?model=LNLM_SDW_AIOC&testcase=check-capture-10sec

[  245.072209] kernel: snd_sof:sof_ipc4_init_input_audio_fmt: sof-audio-pci-intel-lnl 0000:00:1f.3: Init input audio formats for alh-copier.SDW0-Capture.0
[  245.072213] kernel: snd_sof:sof_ipc4_dbg_audio_format: sof-audio-pci-intel-lnl 0000:00:1f.3: Pin index #0: 48000Hz, 32bit, 2ch (ch_map 0xffffff10 ch_cfg 1 interleaving_style 0 fmt_cfg 0x1802) buffer size 384
[  245.072219] kernel: snd_sof:sof_ipc4_prepare_copier_module: sof-audio-pci-intel-lnl 0000:00:1f.3: copier alh-copier.SDW0-Capture.0: reference output rate 48000, channels 2 valid_bits 0
[  245.072223] kernel: snd_sof:sof_ipc4_prepare_copier_module: sof-audio-pci-intel-lnl 0000:00:1f.3: Output audio format for alh-copier.SDW0-Capture.0
[  245.072225] kernel: snd_sof:sof_ipc4_dbg_audio_format: sof-audio-pci-intel-lnl 0000:00:1f.3: Pin index #0: 0Hz, 0bit, 0ch (ch_map 0x0 ch_cfg 0 interleaving_style 0 fmt_cfg 0x0) buffer size 0
[  245.072235] kernel: sof-audio-pci-intel-lnl 0000:00:1f.3: invalid PCM valid_bits 0
[  245.072331] kernel: sof-audio-pci-intel-lnl 0000:00:1f.3: failed to prepare widget alh-copier.SDW0-Capture.0

@plbossart plbossart force-pushed the sdw/use-24-bits-on-link-side branch from e32b01c to c1487a0 Compare July 4, 2024 12:55
@plbossart
Copy link
Member Author

v2: fixed the jack capture. the output format was missing.

@bardliao
Copy link
Collaborator

bardliao commented Jul 5, 2024

@bardliao I vaguely recall that the RT713/1713 configuration would give us one playback stream for the heaphone and two capture streams for headset and mic. Did we have any other cases where we ran out of bandwidth with a 4.8MHz clock? I guess for the Rt722 we will have to use 9.6 MHz or two lanes, there's potentially 4 streams and that will not fly at 4.8/single lane.

rt713/1713 uses a separated SDW interfaces for mic which is 1713. And rt713 is headset only. rt712 is rt713 + speaker playback. So, rt712 has up to 2 playback streams (headphone and speaker) and 1 capture stream (headset). IOW, the 4.8MHz bandwidth is enough for rt712/713 series. However, rt722 uses the same SDW interface for mic, and has up to 2 playback streams (headphone and speaker) and 2 capture streams (headset and mic). So, rt722 needs 9.6MHz or multilane. Same as rt712-VB. @shumingfan Please correct me if I am wrong.

@plbossart
Copy link
Member Author

Just to be clear @bardliao "the 4.8MHz bandwidth is enough for rt712/713 series" is only true with this topology modification. If we use 32-bits, then we don't have enough bandwidth for 3 streams at 4.8 MHz with a 50x4 frame shape.

@bardliao
Copy link
Collaborator

bardliao commented Jul 5, 2024

Just to be clear @bardliao "the 4.8MHz bandwidth is enough for rt712/713 series" is only true with this topology modification. If we use 32-bits, then we don't have enough bandwidth for 3 streams at 4.8 MHz with a 50x4 frame shape.

Oh, yes, that's right. I assume 24 bit format is used.

@plbossart
Copy link
Member Author

I am having second-thoughts on the PR, maybe we should avoid hard-coding the valid bits to 24, e.g. if we use 12.288 MHz 32 bits would be just fine since we'd have 64 rows. Probably a macro would be better.

@bardliao
Copy link
Collaborator

bardliao commented Jul 5, 2024

I am having second-thoughts on the PR, maybe we should avoid hard-coding the valid bits to 24, e.g. if we use 12.288 MHz 32 bits would be just fine since we'd have 64 rows. Probably a macro would be better.

Then we just need to set SDW_AMP_FMT_24 and SDW_JACK_FMT_24 = true by default.

@plbossart
Copy link
Member Author

plbossart commented Jul 5, 2024

Then we just need to set SDW_AMP_FMT_24 and SDW_JACK_FMT_24 = true by default.

Humm... the configuration does not really depend on the type of function but rather on the bus/link configuration. it's really SDW_LINK_BITS or something, and we want this to be a value not a boolean to make the code simpler.

@bardliao
Copy link
Collaborator

bardliao commented Jul 5, 2024

Then we just need to set SDW_AMP_FMT_24 and SDW_JACK_FMT_24 = true by default.

Humm... the configuration does not really depend on the type of function but rather on the bus/link configuration. it's really SDW_LINK_BITS or something, and we want this to be a value not a boolean to make the code simpler.

Be a value is definitely better. I just don't know how to do it. :)

Using S32_LE wastes bandwdith for no good reason, we should use 24
bits on the link to maximize bus efficiency with the 9.6 MHz bus
clock.

There is no need for a kernel-side change, the dailink fixup already
changes the dailink format based on the topology information.

Link: thesofproject#8960
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
in_sample_type $SAMPLE_TYPE_MSB_INTEGER
in_fmt_cfg "$[($in_channels | ($in_valid_bit_depth * 256))]"
}
]
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 32
out_sample_type $SAMPLE_TYPE_MSB_INTEGER
out_valid_bit_depth 24
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed now

@plbossart plbossart force-pushed the sdw/use-24-bits-on-link-side branch from c1487a0 to 08efff3 Compare July 5, 2024 08:22
@plbossart plbossart marked this pull request as ready for review July 5, 2024 08:23
@plbossart plbossart requested a review from jsarha as a code owner July 5, 2024 08:23
@plbossart
Copy link
Member Author

v3: added SDW_LINK_VALID_BITS macro and fixed bad edit for output format.

@bardliao
Copy link
Collaborator

bardliao commented Jul 5, 2024

Do we need to consider about in_bit_depth and out_bit_depth, too? For example, in_bit_depth and out_bit_depth can be 16 if the valid bit is 16.

@plbossart
Copy link
Member Author

The in_bit_depth is always 32 for the capture dai copier and the output_bit_depth is always 32 for the playback dai copier, isn't it? The options for 16 bits are only on the host-copier side

@bardliao
Copy link
Collaborator

bardliao commented Jul 5, 2024

The in_bit_depth is always 32 for the capture dai copier and the output_bit_depth is always 32 for the playback dai copier, isn't it? The options for 16 bits are only on the host-copier side

I am not sure about it. We have for example out_bit_depth 16 in current sdw-amp-generic.conf.

@lgirdwood lgirdwood added this to the v2.11 milestone Jul 5, 2024
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and will get plenty of PR testing prior to v2.11

@plbossart
Copy link
Member Author

The in_bit_depth is always 32 for the capture dai copier and the output_bit_depth is always 32 for the playback dai copier, isn't it? The options for 16 bits are only on the host-copier side

I am not sure about it. We have for example out_bit_depth 16 in current sdw-amp-generic.conf.

I removed all this to have a single bit depth on the link side. This configuration of 16 bits in 16 bit words makes no sense for SoundWire, the FIFOs only work for 32 bits. The only variable is the word length i.e. the number of bits pushed on the bus.

@plbossart
Copy link
Member Author

@kv2019i @lgirdwood this PR is not urgent, it should only be merged after re-testing all the SoundWire devices we have in the daily tests.

@lgirdwood
Copy link
Member

@kv2019i @lgirdwood this PR is not urgent, it should only be merged after re-testing all the SoundWire devices we have in the daily tests.

@ssavati @fredoh9 can someone help here with soundwire testing using this PR ?

@ssavati
Copy link

ssavati commented Jul 8, 2024

@ssavati @fredoh9 can someone help here with soundwire testing using this PR ?

Sure @lgirdwood I will run more test on SDW

@ssavati
Copy link

ssavati commented Jul 11, 2024

@ssavati @fredoh9 can someone help here with soundwire testing using this PR ?

@lgirdwood I have completed soundwire functional and stress tests for MTL and LNL . no new regression observed.
For more details look into test report ID 43727 and 43732

@plbossart
Copy link
Member Author

Thanks @ssavati, all good to merge then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants