control: ucm: add ioctl to retrieve full card components

The fixed-size components field in SNDRV_CTL_IOCTL_CARD_INFO can be too
small on systems with many audio devices. The kernel [1] will provide a
new ioctl to read the full string while truncating the original in
card_info if it grows too big. Make sure the code falls back to original
if the new ioctl is not supported.

[1]: https://lore.kernel.org/all/20260122111249.67319-1-mstrozek@opensource.cirrus.com/
Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
This commit is contained in:
Maciej Strozek 2026-01-22 09:14:17 +00:00
parent 75ed5f05ba
commit d4cf5da490
17 changed files with 180 additions and 5 deletions

View file

@ -8,11 +8,13 @@ int main(void)
int idx, dev, err;
snd_ctl_t *handle;
snd_ctl_card_info_t *info;
snd_ctl_card_components_t *components;
snd_pcm_info_t *pcminfo;
snd_rawmidi_info_t *rawmidiinfo;
char str[128];
snd_ctl_card_info_alloca(&info);
snd_ctl_card_components_alloca(&components);
snd_pcm_info_alloca(&pcminfo);
snd_rawmidi_info_alloca(&rawmidiinfo);
@ -40,7 +42,10 @@ int main(void)
printf(" name - '%s'\n", snd_ctl_card_info_get_name(info));
printf(" longname - '%s'\n", snd_ctl_card_info_get_longname(info));
printf(" mixername - '%s'\n", snd_ctl_card_info_get_mixername(info));
printf(" components - '%s'\n", snd_ctl_card_info_get_components(info));
if (snd_ctl_card_components(handle, components) >= 0)
printf(" components - '%s'\n", snd_ctl_card_components_get_string(components));
else
printf(" components - '%s'\n", snd_ctl_card_info_get_components(info));
dev = -1;
while (1) {
snd_pcm_sync_id_t sync;