Skip to content

[RFC]topology: hda: add a volume component to convert 24bit format - #866

Merged
lgirdwood merged 2 commits into
thesofproject:masterfrom
RanderWang:hda_24bit
Jan 29, 2019
Merged

lgirdwood merged 2 commits into
thesofproject:masterfrom
RanderWang:hda_24bit

Conversation

@RanderWang

Copy link
Copy Markdown
Collaborator

Fix the bug: sof audio pipeline with the format of 24bit doesn't
work on HDA platform. It is caused by sample data layout. SOF supports
S24_LE, and each sample format is like pattern of 0ddd, d stands for
data. Samples are padded with 0‟s at the MSB.

Link dma copys samples directly to hda bus, but hda bus requires samples
layout like pattern of ddd0. Samples are padded with 0‟s at the LSB to
left justify the sample within the container.

Suggesting by Liam and Seppo, using volume to convert S24_LE to S32_LE
in topology file.

This fixes #700
Signed-off-by: Rander Wang rander.wang@linux.intel.com

@singalsu

Copy link
Copy Markdown
Collaborator

Hi, I wonder why the volume component is instantiated by DAI for the HDA type and not by the playback and capture pipelines? It makes the HDA DAI different from others and creates risk for unneccessary volume components duplication. Did I interpret the patch m4 code correctly?

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This means that all HDA pipes must have a volume ? Why not just use the sof volume pipeline on the HDA pipes that need them.

@RanderWang

RanderWang commented Jan 22, 2019 •

Copy link
Copy Markdown
Collaborator Author

Hi, I wonder why the volume component is instantiated by DAI for the HDA type and not by the playback and capture pipelines? It makes the HDA DAI different from others and creates risk for unnecessary volume components duplication. Did I interpret the patch m4 code correctly?

At pipelines, I don't know this playback or capture pipeline is for HDA or not, so I can't add a volume here. At dai component, I add a implicit volume here to let user doesn't take care of HW detail. And if we let users know this limitation and do it by themselves, they could use volume optimally

@RanderWang

RanderWang commented Jan 22, 2019 •

Copy link
Copy Markdown
Collaborator Author

This means that all HDA pipes must have a volume ? Why not just use the sof volume pipeline on the HDA pipes that need them.

No, only the hda pipes with 24bit dai. And if there is a 24bit dai, the hda pipe needs a sof volume. I add no redundant volume except the one mentioned by Seppo

please refer to following code, there is a ifese to add only volume to s24le.

define(`HDA_CAPTURE_P_GRAPH',
`ifelse($2, `s24le',
`HDA_INSERT_VOLUME()
P_GRAPH(DAI_NAME, PIPELINE_ID,
        LIST(`          ',
	`dapm(N_BUFFER(`HDA'PIPELINE_ID), $5)'
	`dapm(N_PGA(`HDA'PIPELINE_ID), N_BUFFER(`HDA'PIPELINE_ID))'
	`dapm($4, N_PGA(`HDA'PIPELINE_ID))'))',
`P_GRAPH(DAI_NAME, PIPELINE_ID,
	LIST(`          ', `dapm($4, $5)'))')'
)

@ranj063

ranj063 commented Jan 22, 2019 •

Copy link
Copy Markdown
Collaborator

Hi, I wonder why the volume component is instantiated by DAI for the HDA type and not by the playback and capture pipelines? It makes the HDA DAI different from others and creates risk for unnecessary volume components duplication. Did I interpret the patch m4 code correctly?

At here, I don't know this playback or capture pipeline is for HDA or not, so I can't add a volume here.
Here I add a implicit volume here to let user doesn't take care of HW detail. And if we let users know this limitation and do it by themselves, they could use volume optimally

@RanderWang this change is too difficult to follow.
I think the simplest change is as Liam suggested. When you create the top-level m4 file, you know if it is for a HDA pipeline, so you can just use pipe-volume-playback/capture for those.

@RanderWang

Copy link
Copy Markdown
Collaborator Author

Hi, I wonder why the volume component is instantiated by DAI for the HDA type and not by the playback and capture pipelines? It makes the HDA DAI different from others and creates risk for unnecessary volume components duplication. Did I interpret the patch m4 code correctly?

At here, I don't know this playback or capture pipeline is for HDA or not, so I can't add a volume here.
Here I add a implicit volume here to let user doesn't take care of HW detail. And if we let users know this limitation and do it by themselves, they could use volume optimally

@RanderWang this change is too difficult to follow.
I think the simplest change is as Liam suggested. When you create the top-level m4 file, you know if it is for a HDA pipeline, so you can just use sof-volume-playback/capture for those.

@ranj063 I have discussed with keyon and Liam, the conclusion is given by Liam:
This can be made transparent to user by adding the volume automatically to any pipe that uses this DAI endpoint. You will need to create an M4 file for HDA (called intel-hda.m4) like we already have for SSP. This will define some macros for creating HDA Intel DAI's that will automatically add the volume control.

@RanderWang

Copy link
Copy Markdown
Collaborator Author

@ranj063 please have a look at #700. it is a limitation of hda dma, and it should be transparent to user

Comment thread tools/topology/m4/dai.m4 Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@RanderWang why is this needed? Why are you overriding the s24le set in the top-level m4 to s32le?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Doesnt this change make the other changes redundant?

@RanderWang RanderWang Jan 22, 2019 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

volume component in FW would check source and sink format to select conversion function, so I need to change dai format.

Yes, you are right if there is a volume at the end of pipeline. I am try to figure out how to know whether there is a volume at the end of pipeline and if I know it, I don't need to add volume again

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@RanderWang I still see Intel specific logic in generic code. Why don't you take each pipeline in machine.m4 and use a volume pipeline(instead of passthrough) for every pipeline that has this requirement. Please see the diff I commented yesterday.

@ranj063

ranj063 commented Jan 22, 2019

Copy link
Copy Markdown
Collaborator

@ranj063 please have a look at #700. it is a limitation of hda dma, and it should be transparent to user

@RanderWang if you want to make it transparent, you need to have the change in the top-level m4. Besides, user is not the end user here right? It is someone like you or me who is quite aware of the limitation. I feel like this is a roundabout way of addressing the problem. The simpler solution is to add a comment before the PIPELINE_PCM_ADD for HDA pipelines about why they need to use the volume pipelines.

@RanderWang

Copy link
Copy Markdown
Collaborator Author

@ranj063 please have a look at #700. it is a limitation of hda dma, and it should be transparent to user

@RanderWang if you want to make it transparent, you need to have the change in the top-level m4. Besides, user is not the end user here right? It is someone like you or me who is quite aware of the limitation. I feel like this is a roundabout way of addressing the problem. The simpler solution is to add a comment before the PIPELINE_PCM_ADD for HDA pipelines about why they need to use the volume pipelines.

Yes, your idea is the simplest one, and I would get all feedback from others.
Here, users maybe other persons in community, so they may be confused about this.

@ranj063

ranj063 commented Jan 22, 2019 •

Copy link
Copy Markdown
Collaborator

@ranj063 please have a look at #700. it is a limitation of hda dma, and it should be transparent to user

@RanderWang if you want to make it transparent, you need to have the change in the top-level m4. Besides, user is not the end user here right? It is someone like you or me who is quite aware of the limitation. I feel like this is a roundabout way of addressing the problem. The simpler solution is to add a comment before the PIPELINE_PCM_ADD for HDA pipelines about why they need to use the volume pipelines.

Yes, your idea is the simplest one, and I would get all feedback from others.
Here, users maybe other persons in community, so they may be confused about this.

@RanderWang how about adding a debug check in debug.m4 for HDA DAI's which have s24le pipeline format?

@RanderWang

Copy link
Copy Markdown
Collaborator Author

Yes, your idea is the simplest one, and I would get all feedback from others.
Here, users maybe other persons in community, so they may be confused about this.

@RanderWang how about adding a debug check in debug.m4 for HDA DAI's which have s24le pipeline format?

so if it is s24le, then do what ?

@RanderWang

Copy link
Copy Markdown
Collaborator Author

update my PR. Now check whether there is a volume at the end of pipeline. Don't add volume if there is one.

@RanderWang

Copy link
Copy Markdown
Collaborator Author

Now if it is HDA dai && format == S24le && no volume at the end of pipeline, a volume would be added.

@lgirdwood

lgirdwood commented Jan 22, 2019 •

Copy link
Copy Markdown
Member

@RanderWang I still see this as the wrong course as it adds complexity where it's not needed. Can you define pipelines for each required machine like

PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4,

@RanderWang

Copy link
Copy Markdown
Collaborator Author

@RanderWang I still see this as the wrong course as it adds complexity where it's not needed. Can you define pipelines for each required machine like

PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4,

Done, thanks!

@lgirdwood

Copy link
Copy Markdown
Member

Sorry @RanderWang I mean this

diff --git a/tools/topology/sof-whl-hda.m4 b/tools/topology/sof-whl-hda.m4
index ff6aa5f2..a4fa719a 100644
--- a/tools/topology/sof-whl-hda.m4
+++ b/tools/topology/sof-whl-hda.m4
@@ -28,7 +28,7 @@ include(`platform/intel/bxt.m4')
 
 # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le.
 # Schedule 48 frames per 1000us deadline on core 0 with priority 0
-PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4,
+PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4,
        1, 0, 2, s24le,
        48, 1000, 0, 0)
 

This we we include a volume transformation for each pipeline and it does not impact other HDA users who may not need or want a volume.

@RanderWang

Copy link
Copy Markdown
Collaborator Author

Update my PR, thanks!

Comment thread tools/topology/m4/dai.m4 Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@RanderWang I still see Intel specific logic in generic code. Why don't you take each pipeline in machine.m4 and use a volume pipeline(instead of passthrough) for every pipeline that has this requirement. Please see the diff I commented yesterday.

@RanderWang

Copy link
Copy Markdown
Collaborator Author

@lgirdwood

Update my PR, thanks!

your method is the simplest one. But I discussed with you

In bug: #700, I said, it is a limitation of hda dma, and it should be transparent to user. And you suggest to define some macros for creating HDA Intel DAI's that will automatically add the volume control. So I did so much work and try make user do it as usual and we do the left in our library.

@RanderWang

Copy link
Copy Markdown
Collaborator Author

@lgirdwood sof-hda-generic.m4 is used by intel platform. sof-whl-hda.m4 is not used now.
Do you mean: use sof-hda-whl.m4 for whl, sof-hda-icl.m4 for ICL, sof-hda-apl.m4 for APL?

Thanks!

@lgirdwood

lgirdwood commented Jan 25, 2019 •

Copy link
Copy Markdown
Member

@RanderWang I mean that sof-hda-generic.m4 will be for all HDA capable platforms and not just Intel platforms so must be generic (you cant make any Intel only changes to this file). You can however make Intel specific changes to intel files. So dai.m4 is generic and should not contain Intel specific logic.

If you renamed sof-hda-generic.m4 to sof-hda-intel-common.m4 then there is no problem making these changes.

@RanderWang

RanderWang commented Jan 28, 2019 •

Copy link
Copy Markdown
Collaborator Author

@RanderWang I mean that sof-hda-generic.m4 will be for all HDA capable platforms and not just Intel platforms so must be generic (you cant make any Intel only changes to this file). You can however make Intel specific changes to intel files. So dai.m4 is generic and should not contain Intel specific logic.

If you renamed sof-hda-generic.m4 to sof-hda-intel-common.m4 then there is no problem making these changes.

Yes, one problem is in our kernel code, the topology for intel is named sof-hda-generic.tplg. This is not
a complex issue. If we used sof-hda-intel-common.m4, we need to build the file and rename it to sof-hda-generic.tplg before scp

It is useless now and sof-hda-generic.m4 would be used by WHL.

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
sof audio pipeline with the format of 24bit doesn't
work on HDA platform. It is caused by sample data layout. SOF supports
S24_LE, and each sample format is like pattern of 0ddd, d stands for
data. Samples are padded with 0‟s at the MSB.

Link dma copys samples directly to hda bus, but hda bus requires samples
layout like pattern of ddd0. Samples are padded with 0‟s at the LSB to
left justify the sample within the container.

Now there is a volume at the end of hda pipeline. We only need to
convert dai type from S24_LE to S32_LE to make volume convert hda data to
correct format

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
@RanderWang

Copy link
Copy Markdown
Collaborator Author

Update PR, thanks!

@lgirdwood

Copy link
Copy Markdown
Member

@RanderWang pls check CI

@RanderWang

Copy link
Copy Markdown
Collaborator Author

@lgirdwood CI is successful.

@lgirdwood
lgirdwood merged commit a5d32b4 into thesofproject:master Jan 29, 2019
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.

sof audio pipeline with the format of 24bit doesn't work on HDA platform

4 participants