control: ucm: add ioctl to retrieve full card components#494
control: ucm: add ioctl to retrieve full card components#494mstrozek wants to merge 1 commit intoalsa-project:masterfrom
Conversation
Changes added to kernel [1] and alsa-lib [2] allow usage of an extended components string, amend amixer to allow display of the new string. [1] https://lore.kernel.org/all/20260122111249.67319-1-mstrozek@opensource.cirrus.com/ [2] alsa-project/alsa-lib#494 Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
|
Thanks for your change, but the situation with new components string can be handled using new internal structure in alsa-lib like: Difference for memory allocations should be already covered using |
d90ae37 to
e1352ee
Compare
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 alsa-lib can read the full string if the original is truncated. [1] link to v3 Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
| snd_strlcpy((char *)info->longname, (char *)kinfo.longname, sizeof(info->longname)); | ||
| snd_strlcpy((char *)info->reserved_, (char *)kinfo.reserved_, sizeof(info->reserved_)); | ||
| snd_strlcpy((char *)info->mixername, (char *)kinfo.mixername, sizeof(info->mixername)); | ||
| if (strnlen((char *)kinfo.components, sizeof(kinfo.components)) > 0 && |
There was a problem hiding this comment.
The string lenght must be exactly "sizeof(kinfo.components) - 1" here.
| return -errno; | ||
| } | ||
| comp.length = sizeof(comp.components); | ||
| if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CARD_COMPONENTS, &comp) < 0) { |
There was a problem hiding this comment.
I don't follow the second call. If the ioctl structure defined array with 512 bytes, it cannot be beyond sizeof(comp.components). Perhaps, you may just add assert to assure that "sizeof(info.components) == sizeof(comp.components)" and keep the bogus comp.length check.
There was a problem hiding this comment.
Yes, it does not make much sense if the size is fixed to 512 bytes... or do you think it might be better to make 'components' a dynamic array? and allocate it to the queried length received in the first call?
There was a problem hiding this comment.
Yes, I think that Takashi meant to use pointer to the string array in the structure like we do in e.g. struct snd_xferi. Note: The ioctl for 32-bit code must be added to sound/core/control_compat.c (kernel) for this variant.
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 alsa-lib can read the full string if the original is truncated.
[1] link to v3