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
src/control/control_hw.c
Outdated
| 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.
There was a problem hiding this comment.
Done now, hopefully this makes more sense.
Kernel v3 patch with the 32-bit code will come soon
There was a problem hiding this comment.
Also now added some better handling in snd_ctl_card_info_free/_clear/_copy()
bdbc0d4 to
1ab0036
Compare
include/local.h
Outdated
| unsigned char longname[80]; /* name + info text about soundcard */ | ||
| unsigned char reserved_[16]; /* reserved for future (was ID of mixer) */ | ||
| unsigned char mixername[80]; /* visual mixer identification */ | ||
| char *components; |
There was a problem hiding this comment.
Unfortunately, for alsa-lib, the all data must be allocated together ahead. See snd_ctl_card_info_alloca. So, please, return back fixed array to this structure.
There was a problem hiding this comment.
Returned to components[512]. In this case also removed the "length query" from the ioctl, writing into info->components directly and only running a quick sanity xheck on the length, though not sure if it is necessary
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>
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