-
Notifications
You must be signed in to change notification settings - Fork 308
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
src: codec_adapter: Add process passthrough path #3766
Conversation
@@ -261,7 +277,12 @@ int codec_process(struct comp_dev *dev) | |||
return -EPERM; | |||
} | |||
|
|||
ret = codec->ops->process(dev); | |||
// TODO: how to set cd->passthrough flag? | |||
if (cd->passthrough) { |
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.
via topology?
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.
Yea, but we have no example of enum or on/off controls I think is why it's left as a todo
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 any example so thi scan be added into topology and code here ?
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.
we have examples of enums in tdfb, @johnylin76 please us those
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 realized that we may need to add a "passthrough_possible" flag. for codecs that more "encodecs/decoders" (e.g. MP3 decoder). We could do a simple source_hwparams == sink_hwparams as a check
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 assume the use case here is runtime switching into and out of passthrough mode ?
@@ -261,7 +277,12 @@ int codec_process(struct comp_dev *dev) | |||
return -EPERM; | |||
} | |||
|
|||
ret = codec->ops->process(dev); | |||
// TODO: how to set cd->passthrough flag? | |||
if (cd->passthrough) { |
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 any example so thi scan be added into topology and code here ?
OK, makes sense. If the switching is a runtime I think the best way is to forget about doing this via topology file and use a kcontrol widget associated with codec adapter component. |
Yes, that is the plan is to do this via runtime controls, not topology. So as long as the process is not doing any any sort of format conversion (i.e. sink_hw_params == source_hw_params) we can shut of the processing easily from userspace regardless of whether the codec added a passthrough mode |
Agree to the concept "passthrough_possible". However I suspect current codec adapter is still specified to sample processing (not including encoder/decoder). For example, ca_config only stores channels, one sample_width, and one sample_rate, and cpd provides no information but data. (I am surprised that there is no format (S16, S24,...) information for codec.) So I think that the encoder/decoder might be probably not considered by codec adapter? "passthrough" flag should be a runtime control in generic layer (like ca_config) rather than in codec layer. However runtime config now only supports params in codec layer. I think we should create a ca_runtime_config, or preserve an id of codec_param for it? |
@plbossart @johnylin76 @cujomalainey @dbaluta this actually gave me an idea when we are pass a nonfree processing component UUID in a topology (where there are no nonfree componentes in the FW) we can assign it to this passthrough (and emit obvious FW / kernel warnings). Topology will still load, user will get sound albeit without the 3rd party processing. |
That would actually optimize our fallback mechanism for closed source processing when using the open source builds. Excellent idea. So we should default the adapter to Y in this case? |
Probably yes (on CAVS platforms). It's not huge. @mrajwa any inputs here ? |
codec_adapter, as the name suggest doesn't perform any encoding/deciding by itself. So if you need some additional, not already present variables
I am OK with the passthru default setting in the topology which can be overloaded by RUNTIME params. |
I think the idea here is to go past params. E.g. if topology asks for codec adapter with cadence core but firmware doesnt have cadence core but does have codec adapter, then adapter would install in passthrough mode just to keep audio working. |
Hmm but if FW has codec_adapter on some pipeline then it should be tied with some processing lib right? What's the point of having "dummy" adapter with no lib bounded? I am also not sure about "keep audio working" part, can you describe this situation? |
Sure, hypothetical situation. Chromeos launches device with processing lib. Due to licensing restrictions, final sof firmware build is only part of private chromeos builds. Therefore, the public (chromium) builds need a different firmware without the processing lib. Rather than also duplicating the topology to also remove the processing lib from the topology, this would allow the same topology to be used but the codec_adapter would just default to a passthrough since the processing lib was not part of the firmware image. In other words, users will be able to grab private topologies and reuse them with public/dev SOF builds. |
@cujomalainey ideally we should separate somehow sof firmware binary from processing libraries binaries, in the same way Linux kernel separates kernel Image from modules. Or in the space way, user space binaries use shared libraries. As it is now, sof-.ri needs all binaries stitched together, so we are stuck with different .ri binaries to solve the licensing restrictions. I think the proposed solution for pass through is a reasonable compromise. |
I agree, dynamic libs would be an excellent solution but it is not something we have unfortunately. It would also make my job easier |
Will try to attack this dynamic libs approach with Google Summer of Code project :). |
Good to hear - The simplest method given the GSoC time constraints is to statically map a library into a known memory offset i.e.
The optimal solution is to do the runtime linking and adress remapping (like Linux does), but this will take longer. |
Random thought, could we possibly design it in a way to thin provision the code regions? I.e. Build firmware that when completely loaded uses > system memory constraint but has the expectation that topology will only trigger certain modules to be loaded and the subset will be less than system memory. I am thinking for the chrome case. Say platform X has device A with processing lib J, and Device B with processing lib K. A firmware with both lib J and K would exceed system memory limits. Since they all use the same system image, currently each firmware would have to be built independently and have unique paths. But with with this mechanism there would be one firmware image and the topology would trigger only loading the proper modules for the device. Or does this simply fall under runtime linking? |
@cujomalainey I would expect most of the decisions should be taken at runtime linking. I am yet to study this. How do I see things:
So, we should be able to run all sorts of algorithms from dynamically loaded libraries and the constraint here would be that the memory needed in order to run this to be at least equal with the size of largest library binary. This will be a very interesting feature to have. Also, right now all the modules + sof firmware are compiled under the same sof-.ri this is a very big limitation both because of licensing and of the size of sof-.ri. @cujomalainey I understand your question. I am yet to process the suggestions from @lgirdwood Later edit: I understand now @lgirdwood suggestion and it makes sense. |
Hmm, that makes for a different usage than for processing libs which will not need swapping out. This may need a meeting and design proposal. |
If the passthrough flag is enabled, on process() the data in the input buffer should be directly copied to the output buffer. The passthrough flag is implemented to be set/get by topology enum control. Signed-off-by: Pin-chih Lin <johnylin@google.com>
I have implemented set/get passthrough flag by enum control.
According to error message "no scontrol for widget" from the source code, it reports error because there is no private data for enum control? Does it mean we need the definition of private data for enum control just like byte control? |
ret = process_passthrough(dev); | ||
} else { | ||
ret = codec->ops->process(dev); | ||
} |
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.
no need for curly brackets here.
Hi @singalsu and @juimonen ,
|
@johnylin76 do you have a separate m4 topology for your usecase? |
@johnylin76 do you have this in your kernel? thesofproject/linux#2423, you need to have it for multiple different types of control in 1 widget... |
I didn't have that, and I think this is probably the root cause. Will give it a try. |
Do you mean the top-level topology like sof-tgl-*.m4? Yes I have but I didn't upload to this PR because it is just for testing purpose. |
|
@juimonen do we have an ETA for thesofproject/linux#2423 landing upstream ? |
Please resubmit with "main" as PR base branch. |
If the passthrough flag is enabled, on process() the data in the input
buffer should be directly copied to the output buffer.
We should determine how and when to set the passthrough flag.