ASoC: partial match the sdca codec name#5664
ASoC: partial match the sdca codec name#5664bardliao wants to merge 3 commits intothesofproject:topic/sof-devfrom
Conversation
| if (dai_info->codec_name) { | ||
| struct snd_soc_component *component; | ||
|
|
||
| component = snd_soc_lookup_component_by_name(dai_info->codec_name); |
There was a problem hiding this comment.
Can we be sure the component exists by this point?
There was a problem hiding this comment.
Can we be sure the component exists by this point?
No, but in theory, the function will be called again when the component probed and be registered.
|
Ok well it mostly works for me, will investigate the probe concerns a little more. One thing that is missing though is the handling of aux devices on the link, we added very basic support for this for the HID device and it would also need renaming. |
Oh, yes, I missed |
3495316 to
e4b195e
Compare
sound/soc/soc-core.c
Outdated
| struct snd_soc_component *component; | ||
|
|
||
| mutex_lock(&client_mutex); | ||
| component = snd_soc_lookup_component_by_name_nolocked(component_name); |
There was a problem hiding this comment.
I don't think this helps much in readability, just move the for_each... here
and use guard(mutex)(&client_mutex); instead of the manual lock/unlock, it takes care of unlock at returns
For now, we will have only one device for each SDCA function. We will figure out how to handle the case when it really happens. |
Add a helper to help user to get the component by name. Signed-off-by: Bard Liao <[email protected]>
Currently, we can set codec name in the dai info which will be set as the codec component name in a DAI link. However, the codec name may not be fixed. For example, there is an index in a SDCA codec name and that is not fixed. Lookup the fixed codec name string from the component list to get the right component name to ensure the DAI link will bind to the right codec component. Signed-off-by: Bard Liao <[email protected]>
The index is not fixed and it will lead to the DAI link can't bind the codec component with the name when the index is different from the predefined one. Signed-off-by: Bard Liao <[email protected]>
e4b195e to
0f09026
Compare
Hrm, so is it like that there is only a single codec with a unique name with a random number tossed to it's name for whatever reason? |
Yes, but the number is not random. I think it is the order of the function being listed in the DisCo table. @charleskeepax Please correct me if I am wrong. |
|
Yeah its an IDA in the SDCA auxiliary, typically it will be the order things are registered although I don't think that is guaranteed if drivers are removed and added. |
Right, but can we have |
|
As Bard notes it won't with the current code, but we don't currently have any devices doing that. We likely will in the future but we are hoping to save that problem for another day. |
I'm perfectly aware that we won't with the current code, I'm asking if is this a valid concern or just a perfectionists problem. |
|
No, it's a real problem. UAJ stands for Universal Audio Jack, it is one of several functions that can exist on an SDCA audio part. Parts can have multiple functions and there are no rules against a part having multiple instances of the same function, say in the UAJ case this might be a part that supported dual jack sockets. There are currently no parts supported by the SDCA driver that have duplicate functions, but it is likely there will be in the future. |
| { | ||
| if (dai_info->codec_name) | ||
| return devm_kstrdup(dev, dai_info->codec_name, GFP_KERNEL); | ||
| if (dai_info->codec_name) { |
There was a problem hiding this comment.
what is the "partial match" you mention in your commit in the code?
There was a problem hiding this comment.
I removed the index from the codec_name, and use the partial codec name to match the component name.
|
@ujfalusi I understand that we will need to handle the duplicate function case sometime in the future. But this PR can buy us some time to solve the current issue. Unless we can find a way to handle the duplicate function case shortly, otherwise I would suggest that we go with the solution to unblock the OEM release. |
| __func__, component->name, dai_info->codec_name); | ||
| return devm_kstrdup(dev, component->name, GFP_KERNEL); | ||
| } else { | ||
| return devm_kstrdup(dev, dai_info->codec_name, GFP_KERNEL); |
There was a problem hiding this comment.
it'd be worth having a real example to show the old behavior and the new behavior...
In the next path you use "snd_soc_sdca.UAJ.1" and remove the trailing index, but that doesn't tell us how the component->name is brought in the picture on line 1225
Currently, we set a predefined codec component name in a DAI link. But the codec name may contain an index which is not fixed. This series suggest using partial match the codec name to fix the issue.