Re: [PATCH] ALSA: sound: Increase max size of components field
From: Richard Fitzgerald
Date: Mon Oct 27 2025 - 08:35:06 EST
On 27/10/2025 11:50 am, Maciej Strozek wrote:
W dniu pon, 27.10.2025 o godzinie 10∶04 +0100, użytkownik Takashi Iwai
napisał:
On Thu, 23 Oct 2025 13:56:26 +0200,
Jaroslav Kysela wrote:
Or, we may introduce a separate ioctl for the components string.
The
stripped components string in struct snd_ctl_card_info may have a
special ASCII mark like '>' at the end of string specifying the
availability of the complete string through another ioctl. I would
prefer this solution.
Also, the components string may be dynamic in the kernel structure
(pointer) to save some space. 256 bytes is not small number.
As Jaroslav suggested, we need a different solution to keep the
compatibility.
My gut feeling is for the option to provide a new ioctl as it can be
most straightforward, but we can discuss further which is the good
choice.
Thank you for the advice! Not sure if I understand Jaroslav's new ioctl
approach properly, can you have a look at the quick draft below and say
if this is (more or less) what you would expect? If it is OK then I
will prepare a proper V2 patch here with a corresponding change for
alsa-lib repo too.
diff --git a/include/sound/core.h b/include/sound/core.h
index 0eb2e3ee0dd5..c4e52fb1704b 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -88,7 +88,9 @@ struct snd_card {
char irq_descr[32]; /* Interrupt description */
char mixername[80]; /* mixer name */
char components[256]; /* card components delimited
with
- space
*/
+ space */
+ char *components_pointer; /* full components string */
+ size_t components_pointer_len; /* length of full components
string */
You don't need components_pointer_len because you can mandate that
components_pointer must point to a NUL-terminated string.
I expect the new ioctl should require the caller to provide a pointer to
a buffer into which the string will be copied, and the length of that
buffer. It would return an error if the provided buffer is not long
enough to copy the content of components_pointer. Usual protocol is
that it can pass a NULL buffer pointer to retrieve the length of the
string so it knows how big a buffer to allocate.
I assume the ideal API would be that the new ioctl will return the
contents of the old components[] string if there isn't a new
components_pointer string. So if the kernel and user code both support
the new ioctl the user code only needs to call that new ioctl.