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: Mod cfg ibs obs cpc addition #7348

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jsarha
Copy link
Contributor

@jsarha jsarha commented Mar 29, 2023

I am feeling quite clueless here, so even if this does not work, I push this out in hope someone can spot the problem.

For some reason the widget tuple array only contains the first instance of mod_cfg objects in the topology2 conf file. I am trying to read the array out with this code: https://github.com/jsarha/linux-sof/tree/peter-cpc-test

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.

@ranj063 pls review

}
Object.Widget.gain.1 {
Object.Control.mixer.1 {
name '2 Main Playback Volume'
}
Object.Base.mod_cfg.1 {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to use the .1 here, is it possible to use ."48k2cS16LE" instead to describe the contents is a more human readable way ?

obs 3145
cpc 3178
}
num_mod_cfgs 3
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this, the CC should count this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I was actually wondering why some widgets have explicitly set num_audio_formats and some doesn't.

Copy link
Collaborator

Choose a reason for hiding this comment

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

some widgets support only 1 format, so they're set in teh class definition. Others support variable number of format based on tplg, so they're set in the top-level file

@jsarha
Copy link
Contributor Author

jsarha commented Mar 30, 2023

@ranj063 can help me out here?

@ranj063
Copy link
Collaborator

ranj063 commented Mar 30, 2023

I am feeling quite clueless here, so even if this does not work, I push this out in hope someone can spot the problem.

For some reason the widget tuple array only contains the first instance of mod_cfg objects in the topology2 conf file. I am trying to read the array out with this code: https://github.com/jsarha/linux-sof/tree/peter-cpc-test

@jsarha the tplg is fine. but what you are missing is the parsing bits in the kernel. Take a look at how we parset multiple audio formats here: https://github.com/thesofproject/linux/blob/bef9852fe3228ce83717dada3ebcb7ad07c6099b/sound/soc/sof/topology.c#L1238

You need to allocate memory for "n" number of token sets first. And then parse the number of sets you're expecting like https://github.com/thesofproject/linux/blob/bef9852fe3228ce83717dada3ebcb7ad07c6099b/sound/soc/sof/ipc4-topology.c#L221 and then finally parse the tokens like https://github.com/thesofproject/linux/blob/bef9852fe3228ce83717dada3ebcb7ad07c6099b/sound/soc/sof/ipc4-topology.c#L257. Hope this helps

@jsarha jsarha force-pushed the mod-conf-ibs-obs-cpc branch from e8ca6ee to 8c7b123 Compare March 31, 2023 12:49
@jsarha jsarha changed the title topology2: Mod cfg ibs obs cpc addition and a test commit to test it DOES NOT WORK topology2: Mod cfg ibs obs cpc addition Mar 31, 2023
@jsarha jsarha force-pushed the mod-conf-ibs-obs-cpc branch from 8c7b123 to 5696d10 Compare March 31, 2023 12:51
@jsarha
Copy link
Contributor Author

jsarha commented Mar 31, 2023

This should now be good. This introduces the mod_cfg class for all relevant widgets. However, this pr does not set any mod_cfg:s as such.

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.

@jsarha can you give an example of how this would work per module instance for @ujfalusi to check. Thanks !

@ujfalusi
Copy link
Contributor

ujfalusi commented Apr 4, 2023

@lgirdwood, I have my own variant of this (looks similar and I think @jsarha based this on my wip).
fwiw, this is how I set it for one module instance for testing:

diff --git a/tools/topology/topology2/include/pipelines/cavs/mixout-gain-dai-copier-playback.conf b/tools/topology/topology2/include/pipelines/cavs/mixout-gain-dai-copier-playback.conf
index 48a9d62938c2..ec2e31a72d76 100644
--- a/tools/topology/topology2/include/pipelines/cavs/mixout-gain-dai-copier-playback.conf
+++ b/tools/topology/topology2/include/pipelines/cavs/mixout-gain-dai-copier-playback.conf
@@ -17,6 +17,7 @@
 #
 
 <include/common/audio_format.conf>
+<include/common/mod_cfg.conf>
 <include/components/copier.conf>
 <include/components/gain.conf>
 <include/components/mixout.conf>
@@ -76,6 +77,7 @@ Class.Pipeline."mixout-gain-dai-copier-playback" {
 			num_audio_formats 2
 			num_input_audio_formats 2
 			num_output_audio_formats 2
+			num_mod_cfgs 3
 
 			# 32-bit 48KHz 2ch
 			Object.Base.audio_format.1 {
@@ -91,6 +93,24 @@ Class.Pipeline."mixout-gain-dai-copier-playback" {
 				out_bit_depth		32
 				out_valid_bit_depth	32
 			}
+
+			Object.Base.mod_cfg.1 {
+				ibs 192
+				obs 256
+				cpc 1456
+			}
+
+			Object.Base.mod_cfg.2 {
+				ibs 384
+				obs 384
+				cpc 4242
+			}
+
+			Object.Base.mod_cfg.3 {
+				ibs 432
+				obs 256
+				cpc 2566
+			}
 		}
 
 		pipeline."1" {

@lgirdwood
Copy link
Member

@jsarha @ujfalusi @ranj063 we need to have a per HW target per module file for each module i.e.

cavs/tgl/copier.conf
ace/mtl/copier.conf

and so on that we would include in teh high level generic pipeline files.

@jsarha
Copy link
Contributor Author

jsarha commented Apr 5, 2023

@jsarha @ujfalusi @ranj063 we need to have a per HW target per module file for each module i.e.

cavs/tgl/copier.conf
ace/mtl/copier.conf

and so on that we would include in teh high level generic pipeline files.

I still have some trouble in understanding the best ways to implement things in topology2, but I would like much more to have one place were we can define ibs/obs/cpc configurations for different platforms, than duplicating the module definitions for it. Could we have something like this:

Class.Widget."copier" {
#
# Pipeline ID for the copier object
#
DefineAttribute."index" {}

    IncludeByKey.PLATFORM {
     "mtl"	"platform/intel/mtl-copier-mod-cfgs.conf"
     "tgl"	"platform/intel/tgl-copier-mod-cfgs.conf"
    }

I have no idea if this would work, but it would be nice if it did 😅. @ranj063 can say if this approach could be made to work?

@jsarha jsarha closed this Apr 5, 2023
@jsarha jsarha reopened this Apr 5, 2023
@sys-pt1s
Copy link

sys-pt1s commented Apr 6, 2023

Can one of the admins verify this patch?

@kv2019i
Copy link
Collaborator

kv2019i commented Apr 24, 2023

@jsarha Status? Please mark as draft if this is not intended for merging...

@jsarha
Copy link
Contributor Author

jsarha commented Apr 24, 2023

@jsarha Status? Please mark as draft if this is not intended for merging...

This PR is good as such, but it does not contain the structures requested here: #7348 (comment)

They could be implemented as separate PR. But maybe I'll mark this as draft as you requested and try to put all the pieces together. Then again I have no idea of any mod_cfg settings for any platform, so in the end there will not be any settings in the later PR either, just places for different platforms to put them.

@kv2019i
Copy link
Collaborator

kv2019i commented Apr 24, 2023

@jsarha So ack, so maybe we need to push this forward then. thesofproject/linux#4315 is close to merging on driver side, so adding @ujfalusi and @ranj063 to review.

@jsarha
Copy link
Contributor Author

jsarha commented Apr 24, 2023

Actually, I am not so sure about the second commit in this series. Maybe its better to include the mod_cfg.conf already in the component files (e.g. in include/component/*.conf), and not in the pipeline definitions. I already have an alternative commit: ab8538c
@ranj063 , this is better, isn't it?

@ranj063
Copy link
Collaborator

ranj063 commented Apr 25, 2023

Actually, I am not so sure about the second commit in this series. Maybe its better to include the mod_cfg.conf already in the component files (e.g. in include/component/*.conf), and not in the pipeline definitions. I already have an alternative commit: ab8538c @ranj063 , this is better, isn't it?

@jsarha yes adding it to the widget class definitions where they will be instantaited and used is probably better

@jsarha jsarha force-pushed the mod-conf-ibs-obs-cpc branch from 5696d10 to 5b6ef5b Compare April 25, 2023 19:55
@jsarha
Copy link
Contributor Author

jsarha commented Apr 25, 2023

New version pushed. This version should have what was requested in #7348 (comment) . Please check that I have added the placeholder and included it in actual component widgets. I already removed pipeline from them, but for many of them I have no idea what those entities are.

Jyri Sarha added 3 commits April 26, 2023 12:16
Add mod_cfg class for ibs, obs, and cpc configuration triplets, and
num_mod_cfg to indicate the number of configurations. The num_mod_cfg
attribute is added to common widget attributes.

Signed-off-by: Jyri Sarha <[email protected]>
Add widget-common-inc.conf as a common place to add include files for all
components. Unlike widget-common.conf, this is included before the class
definition starts.

The initial content for the widget-common-inc.conf is
<include/common/mod_cfg.conf> for adding mod_cfg class definition before
to be used as a member in all component files or in widget-common.conf.

The commit also adds <include/components/widget-common-inc.conf> in
the beginning of the all component includes.

Signed-off-by: Jyri Sarha <[email protected]>
Adds empty include files for all modules and platforms to place their
mod_cfg objects in and includes them in the relevant widget class
files. Only thing found in the files is a comment telling what these
files are for.

Signed-off-by: Jyri Sarha <[email protected]>
@jsarha
Copy link
Contributor Author

jsarha commented Apr 26, 2023

New version pushed. This version should have what was requested in #7348 (comment) . Please check that I have added the placeholder and included it in actual component widgets. I already removed pipeline from them, but for many of them I have no idea what those entities are.

Hmm. The last commit does not work. I do not know if there is a way to instantiate mod_cfg objects already in widget class definition.

@jsarha
Copy link
Contributor Author

jsarha commented Apr 26, 2023

New version pushed. This version should have what was requested in #7348 (comment) . Please check that I have added the placeholder and included it in actual component widgets. I already removed pipeline from them, but for many of them I have no idea what those entities are.

Hmm. The last commit does not work. I do not know if there is a way to instantiate mod_cfg objects already in widget class definition.

Nope, this indeed does work. But only for targets that have PLATFROM variable set at compiler line. Generic targets, like sof-hda-generic.tplg, do not have any mod_cfg settings, but how could they, if the platform is not know at compile time. So, AFAICT this PR should be good.

@ranj063
Copy link
Collaborator

ranj063 commented Apr 26, 2023

@jsarha conflicts?

@jsarha jsarha force-pushed the mod-conf-ibs-obs-cpc branch from 5b6ef5b to c3bd46e Compare April 26, 2023 16:00
@jsarha
Copy link
Contributor Author

jsarha commented Apr 26, 2023

@jsarha conflicts?

Solved now.

@@ -29,6 +29,12 @@ Class.Widget."asrc" {
#include common component definition
<include/components/widget-common.conf>

#include platform specific module configs for the asrc module
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jsarha is there value in this commit just yet? Can we not add the files as and when needed?

Copy link
Contributor Author

@jsarha jsarha Apr 26, 2023

Choose a reason for hiding this comment

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

Sure we can. Just drop the last commit. It is all about interpreting this request #7348 (comment) .

Whether "Can we have?" is interpreted as if we can in theory or if the files should actually be added in practice. If it means in theory, then consider the last commit as a proof of concept.

Then again, adding them here and now would make it more likely that platform and component specific mod_cfgs files will be added in uniform way, following the same naming scheme for all the components.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lgirdwood Can you ack as this was an ask from you? I.e. to have the placeholders or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I agree add on demand.
  2. if want to add in this patch, I would suggest there is a folder to cover all component instead of directly under platform/intel/mod_cfg/

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Not sure what is more likely, need to override values per platform, or per specific product, but in any case, this PR provides the necessary building blocks for both needs, so seems good.

@@ -29,6 +29,12 @@ Class.Widget."asrc" {
#include common component definition
<include/components/widget-common.conf>

#include platform specific module configs for the asrc module
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lgirdwood Can you ack as this was an ask from you? I.e. to have the placeholders or not.

@jsarha jsarha marked this pull request as draft May 3, 2023 16:37
@jsarha
Copy link
Contributor Author

jsarha commented May 3, 2023

Pushed forwards, and changes requested in mail, so turning to draft again.

Girdwood, Liam R:

Jyri, a topology override must copy the manifest CPC schema exactly.
Even the unused fields must be copied and populated with 0 today.

@lgirdwood lgirdwood added this to the v2.7 milestone Jul 4, 2023
@lgirdwood
Copy link
Member

@jsarha now that the manifest and kernel CPC parts are working we should add the overide option for v2.7.
@ujfalusi @plbossart fyi.

@plbossart
Copy link
Member

@jsarha now that the manifest and kernel CPC parts are working we should add the overide option for v2.7. @ujfalusi @plbossart fyi.

We need to agree on the definition of 'working'. I still routinely see messages telling me that CPC is not set ?

@lgirdwood
Copy link
Member

@jsarha now that the manifest and kernel CPC parts are working we should add the overide option for v2.7. @ujfalusi @plbossart fyi.

We need to agree on the definition of 'working'. I still routinely see messages telling me that CPC is not set ?

There are still a lot of holes in the manifest CPC data for each module and (format, rate, channels) configuration. @aiChaoSONG will be working on populating this prior to v2.7. This should fix the kernel warning messages for all tested configs.

The toplogy part will use the same CPC schema and kernel logic/IPC, but will allow

  1. Adding a missing CPC data element if one is missing in manifest for a new configuration.
  2. Overide an existing manifest CPC data element if needed.

@plbossart
Copy link
Member

I'd like to reach the point where all CPC data is valid in the manifest and used for something meaningful, before we plan work on overriding stuff.

@lgirdwood
Copy link
Member

I'd like to reach the point where all CPC data is valid in the manifest and used for something meaningful, before we plan work on overriding stuff.

Need to do both in parallel, to be ready for mistakes in manifest CPC.

@plbossart
Copy link
Member

I'd like to reach the point where all CPC data is valid in the manifest and used for something meaningful, before we plan work on overriding stuff.

Need to do both in parallel, to be ready for mistakes in manifest CPC.

we can't afford to hedge our bets for every single feature. The firmware team is responsible for providing correct CPC values, if they don't it's a bug and they fix it.
We have lots of other things to do really with SoundWire-related enablement.

@lgirdwood
Copy link
Member

I'd like to reach the point where all CPC data is valid in the manifest and used for something meaningful, before we plan work on overriding stuff.

Need to do both in parallel, to be ready for mistakes in manifest CPC.

we can't afford to hedge our bets for every single feature. The firmware team is responsible for providing correct CPC values, if they don't it's a bug and they fix it. We have lots of other things to do really with SoundWire-related enablement.

CPC architecture is based on a single module unit test with no upstream/downstream module I$/D$ impact taken into consideration for module CPC performance delta when different pipeline topologies are used. This is not a big item and will be painful to modify/fix in manifest.

@alex-cri alex-cri modified the milestones: v2.7, v2.8 Aug 22, 2023
@kv2019i kv2019i modified the milestones: v2.8, v2.9 Nov 21, 2023
@kv2019i
Copy link
Collaborator

kv2019i commented Nov 21, 2023

In draft status, pushing to v2.9.

# Object.Base.mod_cfg."0" {
# ibs 384
# obs 384
# cpc 4600
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add comments here:
for ibs/obs, it is initialized as: 48 * 2 * 4 = 384, it is 48k LL with 2 channel 32 bit format.
for cpc, I am not sure how CPC figured out as instantiated value?

DefineAttribute."instance" {
}

# input buffer size
Copy link
Contributor

Choose a reason for hiding this comment

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

let's give comments like:
ibs = (sample rate / (1000000/period)) * channels * valid_sample_width

# This file is for include files needed for widget-common.conf
#
<include/common/mod_cfg.conf>

Copy link
Contributor

Choose a reason for hiding this comment

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

why not directly include mod_cfg.conf?

@@ -29,6 +29,12 @@ Class.Widget."asrc" {
#include common component definition
<include/components/widget-common.conf>

#include platform specific module configs for the asrc module
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I agree add on demand.
  2. if want to add in this patch, I would suggest there is a folder to cover all component instead of directly under platform/intel/mod_cfg/

@kv2019i
Copy link
Collaborator

kv2019i commented Mar 4, 2024

Stable-v2.9 branched, this didn't make the cut, bumping forward. @jsarha is this still valid (given bumps over multiple releases)?

@kv2019i kv2019i modified the milestones: v2.9, v2.10 Mar 4, 2024
@kv2019i
Copy link
Collaborator

kv2019i commented Apr 24, 2024

No activity in 2.7...2.9, clearing the milestone.

@kv2019i kv2019i removed this from the v2.10 milestone Apr 24, 2024
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.

9 participants