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: sof-mtl-rt5650: add SSP FMT 24 bits support #8917

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 120 additions & 81 deletions tools/topology/topology2/cavs-mixin-mixout-eqiir-dts-ssp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Object.Pipeline {

Object.Widget.host-copier.1 {
stream_name '$HEADSET_PLAYBACK_PCM_STREAM_NAME'
pcm_id $HEADSET_PCM_ID
pcm_id $HEADSET_PCM_ID
}
Object.Widget.gain.1 {
Object.Control.mixer.1 {
Expand All @@ -26,7 +26,7 @@ Object.Pipeline {

Object.Widget.host-copier.1 {
stream_name '$SPEAKER_PLAYBACK_PCM_STREAM_NAME'
pcm_id $SPEAKER_PCM_ID
pcm_id $SPEAKER_PCM_ID
}
Object.Widget.gain.1 {
Object.Control.mixer.1 {
Expand All @@ -36,94 +36,133 @@ Object.Pipeline {
}
]

mixout-gain-eqiir-dts-dai-copier-playback [
{
index 2

Object.Widget.dai-copier.1 {
dai_index $HEADSET_SSP_DAI_INDEX
dai_type "SSP"
copier_type "SSP"
stream_name "$HEADSET_CODEC_NAME"
node_type $I2S_LINK_OUTPUT_CLASS
}
mixout-gain-eqiir-dts-dai-copier-playback [
{
index 2

Object.Widget.gain.1 {
Object.Control.mixer.1 {
name 'Post Mixer $HEADSET_PCM_NAME Playback Volume'
}
}
Object.Widget.dai-copier.1 {
dai_index $HEADSET_SSP_DAI_INDEX
dai_type "SSP"
copier_type "SSP"
stream_name "$HEADSET_CODEC_NAME"
node_type $I2S_LINK_OUTPUT_CLASS
IncludeByKey.SSP_HS_FMT_24 {
"true" {
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 24
out_sample_type $SAMPLE_TYPE_LSB_INTEGER
out_fmt_cfg "$[($out_channels | ($out_valid_bit_depth * 256))]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, with MSB_INTEGER, the data sent to SSP will be basicly same as before, 32bit containers with just the lower 8 bits zeroed out. Not sure if this makes a different to the codec. I'm I missing something, does the codec DAI specification also need a change ("sample_bits 24"), so that we change what is sent over I2S:.?

Copy link
Contributor Author

@macchian macchian Mar 13, 2024

Choose a reason for hiding this comment

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

I'm I missing something, does the codec DAI specification also need a change ("sample_bits 24"), so that we change what is sent over I2S:.?

@kv2019i , codec dai no need to change the sample bits 24 bits. Because the valid bit 24 bits can be in 32 container. Thanks for pointing out, I think the SOF FW currently set LSB_INTEGER and it will use sample type to choose format conversion. It makes no difference to the codec with MSB_INTEGER. Remove it, any concerns?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we don't need to overwrite out_fmt_cfg if we don't set out_sample_type here right? @kv2019i @ranj063

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, but I think the problem is what we want to achieve (see Pierre's comment above). While ALH (for which we have tplg examples for 24bit output) takes MSB-format 32bit values, SSP behaves differently. We don't have any examples for 24bit SSP in upstream, so this is not so obvious, but SSP hw requires 24bit in the lower bits, so if the valid bits is 24bits in the SSP configuration, then copier needs to be configured to SAMPLE_TYPE_LSB_INTEGER here, and SSP configuration needs to set to have a 24bit configuration.

DSP/Copier will send 32bit containers with audio in the lower 24bit, SSP will send the 24bit over SSP bus.

But yeah, @macchian , is above the correct configuration? The current cavs-rt5682.conf only defines 32bit SSP config. And if that is correct, then you don't need anything special in copier configuration. It outputs 32/32bit by default (MSB/LSB makes no differences if valid_bits==container_bits).

Copy link
Contributor Author

@macchian macchian Mar 15, 2024

Choose a reason for hiding this comment

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

@kv2019i ,

But yeah, @macchian , is above the correct configuration?

yes, correct! It's what we'd like to do. As the exact as you mentioned, we want to achieve valid 24 bits / 32 bits container support.
"DSP/Copier will send 32bit containers with audio in the lower 24bit, SSP will send the 24bit over SSP bus."

Copy link
Collaborator

@kv2019i kv2019i Mar 15, 2024

Choose a reason for hiding this comment

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

@macchian Right, so then your patch is correct but the sample type needs to be "out_sample_type $SAMPLE_TYPE_LSB_INTEGER". This is very confusing, but hopefully having more examples will help. The reason for confusion stems from fact that historically the FW has "fixed up" some bad configurations. See e.g. commit 383d17a . So even if host/topology sets copier to input/output 24bit in a certain format, the FW has based on the link type (.e.g whether it's SSP/DMIC/ALH) overwritten the configuration and done the right thing. There are some legacy cases FW still needs to support, but we are trying to get rid of this in topology and have the correct formats in topology and not rely on the FW to fixup the values. Problem is that one must still enter some value in topology and having values in topology than in practise will be ignored by FW, is source for a lot of confusion. Hopefully this clarifies. So some short term pain to adapt, but in longer term this should be easier for both tplg and FW development.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@macchian Right, so then your patch is correct but the sample type needs to be "out_sample_type $SAMPLE_TYPE_LSB_INTEGER".

@kv2019i , yes, it's clear to me. Add in/out_sample_type $SAMPLE_TYPE_LSB_INTEGER for easier review by everyone.

}
]
}
"false" {
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 32
}
]
}
}
}

Object.Widget.eqiir.1 {
Object.Control.bytes."1" {
name 'EQIIR2.0 eqiir_coef_2'
}
}
Object.Widget.gain.1 {
Object.Control.mixer.1 {
name 'Post Mixer $HEADSET_PCM_NAME Playback Volume'
}
}

Object.Widget.dts.1 {
Object.Control.bytes."1" {
max 2048
name 'CODEC_ADAPTER2.0 DTS Codec Setup 2'
}
}
}
{
index 4
Object.Widget.eqiir.1 {
Object.Control.bytes."1" {
name 'EQIIR2.0 eqiir_coef_2'
}
}

Object.Widget.dai-copier.1 {
dai_index $SPEAKER_SSP_DAI_INDEX
dai_type "SSP"
copier_type "SSP"
stream_name "$SPEAKER_CODEC_NAME"
node_type $I2S_LINK_OUTPUT_CLASS
}
Object.Widget.dts.1 {
Object.Control.bytes."1" {
max 2048
name 'CODEC_ADAPTER2.0 DTS Codec Setup 2'
}
}
}
{
index 4

Object.Widget.gain.1 {
Object.Control.mixer.1 {
name 'Post Mixer $SPEAKER_PCM_NAME Playback Volume'
}
}
Object.Widget.dai-copier.1 {
dai_index $SPEAKER_SSP_DAI_INDEX
dai_type "SSP"
copier_type "SSP"
stream_name "$SPEAKER_CODEC_NAME"
node_type $I2S_LINK_OUTPUT_CLASS
IncludeByKey.SSP_SPK_FMT_24 {
"true" {
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 24
out_sample_type $SAMPLE_TYPE_LSB_INTEGER
out_fmt_cfg "$[($out_channels | ($out_valid_bit_depth * 256))]"
}
]
}
"false" {
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 32
}
]
}
}
macchian marked this conversation as resolved.
Show resolved Hide resolved
}

Object.Widget.eqiir.1 {
Object.Control.bytes."1" {
name 'EQIIR1.0 eqiir_coef_1'
}
}
Object.Widget.gain.1 {
Object.Control.mixer.1 {
name 'Post Mixer $SPEAKER_PCM_NAME Playback Volume'
}
}

Object.Widget.dts.1 {
Object.Control.bytes."1" {
max 2048
name 'CODEC_ADAPTER1.0 DTS Codec Setup 1'
}
}
Object.Widget.eqiir.1 {
Object.Control.bytes."1" {
name 'EQIIR1.0 eqiir_coef_1'
}
}

}
]
Object.Widget.dts.1 {
Object.Control.bytes."1" {
max 2048
name 'CODEC_ADAPTER1.0 DTS Codec Setup 1'
}
}
}
]
}

Object.Base.route [
{
source "gain.2.1"
sink "eqiir.2.1"
}
{
source "dts.2.1"
sink "dai-copier.SSP.$HEADSET_CODEC_NAME.playback"
}
{
source "mixin.1.1"
sink "mixout.2.1"
}
{
source "gain.4.1"
sink "eqiir.4.1"
}
{
source "dts.4.1"
sink "dai-copier.SSP.$SPEAKER_CODEC_NAME.playback"
}
{
source "mixin.3.1"
sink "mixout.4.1"
}
{
source "gain.2.1"
sink "eqiir.2.1"
}
{
source "dts.2.1"
sink "dai-copier.SSP.$HEADSET_CODEC_NAME.playback"
}
{
source "mixin.1.1"
sink "mixout.2.1"
}
{
source "gain.4.1"
sink "eqiir.4.1"
}
{
source "dts.4.1"
sink "dai-copier.SSP.$SPEAKER_CODEC_NAME.playback"
}
{
source "mixin.3.1"
sink "mixout.4.1"
}
]
140 changes: 90 additions & 50 deletions tools/topology/topology2/cavs-mixin-mixout-ssp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Object.Pipeline {

Object.Widget.host-copier.1 {
stream_name '$HEADSET_PLAYBACK_PCM_STREAM_NAME'
pcm_id $HEADSET_PCM_ID
pcm_id $HEADSET_PCM_ID
}
Object.Widget.gain.1 {
Object.Control.mixer.1 {
Expand All @@ -27,7 +27,7 @@ Object.Pipeline {

Object.Widget.host-copier.1 {
stream_name '$SPEAKER_PLAYBACK_PCM_STREAM_NAME'
pcm_id $SPEAKER_PCM_ID
pcm_id $SPEAKER_PCM_ID
}
Object.Widget.gain.1 {
Object.Control.mixer.1 {
Expand All @@ -37,59 +37,99 @@ Object.Pipeline {
}
]

mixout-gain-dai-copier-playback [
{
index $HEADSET_DAI_PIPELINE_ID
mixout-gain-dai-copier-playback [
{
index $HEADSET_DAI_PIPELINE_ID

Object.Widget.dai-copier.1 {
dai_index $HEADSET_SSP_DAI_INDEX
dai_type "SSP"
copier_type "SSP"
stream_name "$HEADSET_CODEC_NAME"
node_type $I2S_LINK_OUTPUT_CLASS
}
Object.Widget.dai-copier.1 {
dai_index $HEADSET_SSP_DAI_INDEX
dai_type "SSP"
copier_type "SSP"
stream_name "$HEADSET_CODEC_NAME"
node_type $I2S_LINK_OUTPUT_CLASS
IncludeByKey.SSP_HS_FMT_24 {
"true" {
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 24
out_sample_type $SAMPLE_TYPE_LSB_INTEGER
out_fmt_cfg "$[($out_channels | ($out_valid_bit_depth * 256))]"
}
]
}
"false" {
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 32
}
]
}
}
}

Object.Widget.gain.1 {
Object.Control.mixer.1 {
name 'Post Mixer $HEADSET_PCM_NAME Playback Volume'
}
}
}
{
index $SPEAKER_DAI_PIPELINE_ID
Object.Widget.gain.1 {
Object.Control.mixer.1 {
name 'Post Mixer $HEADSET_PCM_NAME Playback Volume'
}
}
}
{
index $SPEAKER_DAI_PIPELINE_ID

Object.Widget.dai-copier.1 {
dai_index $SPEAKER_SSP_DAI_INDEX
dai_type "SSP"
copier_type "SSP"
stream_name "$SPEAKER_CODEC_NAME"
node_type $I2S_LINK_OUTPUT_CLASS
}
Object.Widget.dai-copier.1 {
dai_index $SPEAKER_SSP_DAI_INDEX
dai_type "SSP"
copier_type "SSP"
stream_name "$SPEAKER_CODEC_NAME"
node_type $I2S_LINK_OUTPUT_CLASS
IncludeByKey.SSP_SPK_FMT_24 {
"true" {
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 24
out_sample_type $SAMPLE_TYPE_LSB_INTEGER
out_fmt_cfg "$[($out_channels | ($out_valid_bit_depth * 256))]"
}
]
}
"false" {
Object.Base.output_audio_format [
{
out_bit_depth 32
out_valid_bit_depth 32
}
]
}
}
}

Object.Widget.gain.1 {
Object.Control.mixer.1 {
name 'Post Mixer $SPEAKER_PCM_NAME Playback Volume'
}
}
}
]
Object.Widget.gain.1 {
Object.Control.mixer.1 {
name 'Post Mixer $SPEAKER_PCM_NAME Playback Volume'
}
}
}
]
}

Object.Base.route [
{
source "gain.$HEADSET_DAI_PIPELINE_ID.1"
sink "dai-copier.SSP.$HEADSET_CODEC_NAME.playback"
}
{
source "mixin.$HEADSET_HOST_PIPELINE_ID.1"
sink "mixout.$HEADSET_DAI_PIPELINE_ID.1"
}
{
source "gain.$SPEAKER_DAI_PIPELINE_ID.1"
sink "dai-copier.SSP.$SPEAKER_CODEC_NAME.playback"
}
{
source "mixin.$SPEAKER_HOST_PIPELINE_ID.1"
sink "mixout.$SPEAKER_DAI_PIPELINE_ID.1"
}
{
source "gain.$HEADSET_DAI_PIPELINE_ID.1"
sink "dai-copier.SSP.$HEADSET_CODEC_NAME.playback"
}
{
source "mixin.$HEADSET_HOST_PIPELINE_ID.1"
sink "mixout.$HEADSET_DAI_PIPELINE_ID.1"
}
{
source "gain.$SPEAKER_DAI_PIPELINE_ID.1"
sink "dai-copier.SSP.$SPEAKER_CODEC_NAME.playback"
}
{
source "mixin.$SPEAKER_HOST_PIPELINE_ID.1"
sink "mixout.$SPEAKER_DAI_PIPELINE_ID.1"
}
]
Loading
Loading