ASoC: core: Change device numbering#5311
Closed
amadeuszslawinski-intel wants to merge 1 commit intothesofproject:topic/sof-devfrom
Closed
ASoC: core: Change device numbering#5311amadeuszslawinski-intel wants to merge 1 commit intothesofproject:topic/sof-devfrom
amadeuszslawinski-intel wants to merge 1 commit intothesofproject:topic/sof-devfrom
Conversation
Currently ASoC cards when enumerating create CPUs rtds first and CODECs rtds second. This causes device number on cards to not start from 0, but from number of present CPUs. During that it does count number of rtds and uses it as device number visible in userspace. This patch changes device visible to userspace, when listing cards: Before: card 0: hdaudioB0D0 [hdaudioB0D0], device 1: HDAudio Analog (*) [] card 1: hdaudioB0D2 [hdaudioB0D2], device 1: HDMI1 (*) [] card 1: hdaudioB0D2 [hdaudioB0D2], device 2: HDMI2 (*) [] card 1: hdaudioB0D2 [hdaudioB0D2], device 3: HDMI3 (*) [] After: card 0: hdaudioB0D0 [hdaudioB0D0], device 0: HDAudio Analog (*) [] card 1: hdaudioB0D2 [hdaudioB0D2], device 0: HDMI1 (*) [] card 1: hdaudioB0D2 [hdaudioB0D2], device 1: HDMI2 (*) [] card 1: hdaudioB0D2 [hdaudioB0D2], device 2: HDMI3 (*) [] It is done by skipping back end devices and only counting front end ones. Now there are few concerns I have: - while rtd->id is not used much, few drivers seem to be using it as index into a table, above may break this use (although "include/sound/simple_card_utils.h: * the ID stored in rtd->id may not be a valid array index." suggests that maybe it is a bad idea anyway, but I'm not sure how generic that comment is) - this will break user scripts, with hardcoded device IDs - this will also break some UCMs with hardcoded IDs Now my main question is, if such patch would even be considered? Perhaps device IDs are not considered as "stable" interface and can be changed and my above worries are unnecessary. Patch is a result of discussion from: alsa-project/alsa-ucm-conf#499 and as such I may consider others ways of fixing the problem.
ujfalusi
reviewed
Jan 28, 2025
| rtd->dai_link = dai_link; | ||
| rtd->id = card->num_rtd++; | ||
| if (!rtd->dai_link->no_pcm) | ||
| rtd->id = card->num_rtd++; |
Collaborator
There was a problem hiding this comment.
I think the patch which needs to be fixed is
8b12da9 ("ASoC: cleanup function parameter for rtd and its id")
before this patch the rtd->dai_link->id was passed as PCM index to soc_new_pcm(), but after it the rtd->id is used and this can be the route of the problem?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently ASoC cards when enumerating create CPUs rtds first and CODECs rtds second. This causes device number on cards to not start from 0, but from number of present CPUs. During that it does count number of rtds and uses it as device number visible in userspace.
This patch changes device visible to userspace, when listing cards:
Before:
card 0: hdaudioB0D0 [hdaudioB0D0], device 1: HDAudio Analog () [] card 1: hdaudioB0D2 [hdaudioB0D2], device 1: HDMI1 () [] card 1: hdaudioB0D2 [hdaudioB0D2], device 2: HDMI2 () [] card 1: hdaudioB0D2 [hdaudioB0D2], device 3: HDMI3 () []
After:
card 0: hdaudioB0D0 [hdaudioB0D0], device 0: HDAudio Analog () [] card 1: hdaudioB0D2 [hdaudioB0D2], device 0: HDMI1 () [] card 1: hdaudioB0D2 [hdaudioB0D2], device 1: HDMI2 () [] card 1: hdaudioB0D2 [hdaudioB0D2], device 2: HDMI3 () []
It is done by skipping back end devices and only counting front end ones.
Now there are few concerns I have:
Now my main question is, if such patch would even be considered? Perhaps device IDs are not considered as "stable" interface and can be changed and my above worries are unnecessary.
Patch is a result of discussion from:
alsa-project/alsa-ucm-conf#499 and as such I may consider others ways of fixing the problem.