[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fce36281-1aa4-4a83-afa1-2470df4453a0@perex.cz>
Date: Thu, 22 Jan 2026 14:30:04 +0100
From: Jaroslav Kysela <perex@...ex.cz>
To: Maciej Strozek <mstrozek@...nsource.cirrus.com>,
Takashi Iwai <tiwai@...e.com>
Cc: linux-kernel@...r.kernel.org, linux-sound@...r.kernel.org,
patches@...nsource.cirrus.com, alsa-devel@...a-project.org
Subject: Re: [PATCH v2] ALSA: control: add ioctl to retrieve full card
components
On 1/22/26 12:12, Maciej Strozek wrote:
> The fixed-size components field in SNDRV_CTL_IOCTL_CARD_INFO can be too
> small on systems with many audio devices.
>
> Keep the existing struct snd_ctl_card_info ABI intact and add a new ioctl
> to retrieve the full components string.
>
> When the legacy components field is truncated, append '>' to indicate
> that the full string is available via the new ioctl.
Thanks for the patch. Comments bellow.
> @@ -88,7 +89,8 @@ struct snd_card {
> char irq_descr[32]; /* Interrupt description */
> char mixername[80]; /* mixer name */
> char components[128]; /* card components delimited with
> - space */
> + space, truncated to 127 chars */
> + char components_extended[SNDRV_CTL_COMPONENTS_LEN]; /* full card components string */
I would remove the original components[128] string and replace it
with dynamically allocated 'char *components_ptr' with 'unsigned int
components_ptr_alloc' to store allocated size. Then the snd_component_add()
function may allocate (and resize) dynamically the components_ptr on demand
(using e.g. 32 byte step). This will also catch all drivers using the original
struct member when compiled and make the memory usage a little bit happier.
> +/*
> + * Card components can exceed the fixed 128 bytes in snd_ctl_card_info.
> + * Use SNDRV_CTL_IOCTL_CARD_COMPONENTS to retrieve the full string.
> + */
> +#define SNDRV_CTL_COMPONENTS_LEN 512
This define seems not much useful. The sizeof() on the structure member works
here.
> +struct snd_ctl_card_components {
> + int card; /* card number */
> + unsigned int length; /* returned length of components string */
... not used ... Zero terminated string is enough IMHO.
> + unsigned char components[SNDRV_CTL_COMPONENTS_LEN];
> +};
Jaroslav
--
Jaroslav Kysela <perex@...ex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Powered by blists - more mailing lists