-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: topology: change parsing functions to handle multiple items #1766
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
Conversation
plbossart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juimonen you can reduce the whole of changes a great deal, and with precisions on what you are trying to accomplish you'd make the task of reviewers a lot easier :-)
it's not even an objection on the merits of the patch, it's just hard to even get to the technical part of your proposal
Thanks!
|
@plbossart updated. There's still only 1 commit, but the number or changes should have been reduced. It is quite difficult to separate to commits as the changes don't make too much sense alone. The multiple entities are now called "sets" of tuples arrays. Also tried to change the commit message to be more clear... |
|
and changed to [RFC] as this needs to be tested really well as I'm poking with topology parsing... |
I am still a bit in the dark on the dmic changes. Are you Overall I am still not clear on what we are really trying to fix |
@plbossart let me try and explain. Our topology definitions today contain multiple sets of the same tuples only for the case of the DMIC PDM config tokens (see below). So the topology parser handles parsing these tokens in a very specific way. But with the addition of multiple set of tuples for the MUX/DEMUX stream data, we need to make the logic generic and this is what @juimonen and I discussed we should do. I will review the patch and add more comments. Does that make sense? |
@juimonen I had a slightly different approach in mind. Let me send you a patch today. |
|
@juimonen lets stick with your PR but we should split this into 3 commits to make the intention clear:
|
|
@ranj063 now chopped to 3 commits. However I'm not sure the dmic parsing will work properly after 2nd commit, that's why I made originally it with 1 patch. Anyway, hope it is more clear. |
|
@ranj063 I'm working at the same time on the demux with new interface (channel map) and unify it with dmic handling in this PR. So this PR would then also make more sense... |
|
@ranj063 updated, tried to address your comments. |
ranj063
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now @juimonen. Thanks!
|
@lyakh @kv2019i @plbossart this PR is needed to move forward and add support for other widgets with complex token arrays like the DMIC PDM tokens. |
lyakh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost LGTM, just a couple of minor comments from me
sound/soc/sof/topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't you want to change this to >=? If I understood you correctly, you said, that currently the ALSA topology compiler cannot generate arrays with elements of different sizes, right? So you should be safe here. But if someone wants to crash the kernel they will make a modified version of the compiler to create invalid topology binaries. So I don't think we can rely on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, changed now to >=
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juimonen I think this starts to be ready. One thing that bugs a bit me when rereading the reviews: the commit message doesn't actually explain why you are doing this. What is the benefit of this change? I think you should address this in the commit message. This is a fairly nontrivial patch and there'd need to be some motivation in the commit message why the change is needed. To me, reading code, the biggest benefit in current codebase seems to get rid of the weird usage of sof->private in dmic pdm parsing. Is there others?
| offset += object_size; | ||
| total += found; | ||
| found = 0; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juimonen At least not for this PR. Let's fix one issue at a time.
|
@kv2019i yes that's the benefit. Other is the optimization, that we are not parsing until the end of data area if we found the tokens. Before it was always going to the end of area even if token we're found. So it is a optimization, as @ranj063 wanted to point out in coommit message. Now for the "sets" parsing to work, I need to found items also (to be able to move to next set). So the commits are interdependent, I initially made only 1 commit, but as requested, I splitted it up. so summa summarum:
|
|
@juimonen wrote:
Ack, this is clear, first commit msg is good.
So I'd like the commit msg of second to mention this briefly, to describe why these changes are done. Now it just tells you add ability to parse sets, but this is a bit odd as to why dmic worked at all if sets were not parsed before. I think the commit message should explain this better. |
|
@kv2019i hmm, I now modified the 2nd commit message a bit. But as I see it, I'm exactly talking in the commit message first about the multiset generalization and then mentioning in the end that I'm modifying the dmic config. I think this is one of the most logical commit messages I've ever written :) (which might not tell good thing about me)... so next you'll have to suggest something and guide me through it... |
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @juimonen , now looks good. To me, "which is currently handled as a special case in token
parsing. This is not scalable for other components with multiple sets." is the magic addition.
|
@juimonen needs rebase |
Optimize the parsing so that it will stop after all required tokens have been found as there is no reason to continue after that. Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Widget's parameters are set in topology and they usually consist of several different types of tuple arrays like strings, words and bytes. Here this kind of combination is called a "set". Lately we've seen more complex widget definitions with multiple identical sets of tuple arrays. One example is the dmic pdm configuration, which is currently handled as a special case in token parsing. This is not scalable for other components with multiple sets. So add a new function sof_parse_token_sets, which can be used to parse multiple sets. This function defines the number of sets and an offset to copy the tokens to correct positions in the destination ipc struct. Old sof_parse_token function will be a special case of calling sof_parse_token_sets to parse 1 set with offset 0. Finally modify the dmic dai link loading to use the new sof_parse_array_sets to load multiple pdm configs. Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
sound/soc/sof/control.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a different patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, yes dealing with several PR's at the same time... sorry. should be updated now.
plbossart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still haven't understood why we need this but the code looks fine, thanks @juimonen
Widget's parameters can consist of several different types of tuples
arrays like strings, words and bytes. In essence, SOF topology parsing
transforms these sets of tuples arrays into an ipc message sent to dsp.
Lately we've been seeing more complex widget definitions with multiple
identical tuples array sets. These include for example dmic pdm
configuration and mux/demux channel map definitions.
SOF driver gets the widget from ASoC layer and parses the tuples from
widget's data. Currently parsing functions run always through the
widget's entire data area searching for the correct set of tuples
arrays.
If the widget happens to have multiple similar sets, parser doesn't
return after first found "instance", but the next one is always copied
on top of the previous one until end of data. So if you have multiple
identical token sets in topology, the parser will always return the last
one.
To be able to parse multiple tuples array sets this patch:
Changes the parsing so that the parsing will stop after all tokens
for single set have been found as there is no reason to continue parsing
after that.
Adds new function sof_parse_token_sets which can be used to parse
multiple sets. This function uses offset and number of sets to copy the
tokens to correct positions in the destination ipc struct.
sof_parse_token will be a special case of calling sof_parse_token_sets
to parse 1 set with offset 0.
Modifies the dmic dai link loading to show how to use
sof_parse_array_sets to load multiple sets.
Signed-off-by: Jaska Uimonen jaska.uimonen@linux.intel.com