[alsa-devel] Question about ASOC codec drivers
Mark Brown
broonie at opensource.wolfsonmicro.com
Thu Jan 20 21:54:35 CET 2011
On Thu, Jan 20, 2011 at 04:12:12PM +0000, Neil Jones wrote:
> > ...is exactly what you told the driver to do. You've told the core
> > there are seven items in the enumeration so it's expecting an array of
> > seven strings.
> DUH! sorry, in my head i read .xmax as .xmask cheers for the spot.
> I still get 'Failed to add route Line Input->Input Mux' though ?
You've probably typoed one of the strings. Look at the code to see why
it's detecting this error.
> @@ -761,6 +761,8 @@ typedef int __bitwise snd_ctl_elem_iface_t;
> #define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000)
> /* Off, with power */
> #define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001)
> /* Off, without power */
>
> +#define SNDRV_CTL_ELEMENT_INFO_NAME_LENGTH 64
> +
> struct snd_ctl_elem_id {
> unsigned int numid; /* numeric identifier, zero = invalid */
> snd_ctl_elem_iface_t iface; /* interface identifier */
> @@ -799,7 +801,8 @@ struct snd_ctl_elem_info {
> struct {
> unsigned int items; /* R: number of items */
> unsigned int item; /* W: item number */
> - char name[64]; /* R: value name */
> + /* R: value name */
> + char name[SNDRV_CTL_ELEMENT_INFO_NAME_LENGTH];
> } enumerated;
> unsigned char reserved[128];
> } value;
This I'd submit separately to Takashi.
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2056,8 +2056,9 @@ int snd_soc_info_enum_double(struct snd_kcontrol
> *kcontrol,
>
> if (uinfo->value.enumerated.item > e->max - 1)
> uinfo->value.enumerated.item = e->max - 1;
> - strcpy(uinfo->value.enumerated.name,
> - e->texts[uinfo->value.enumerated.item]);
> + strncpy(uinfo->value.enumerated.name,
> + e->texts[uinfo->value.enumerated.item],
> + SNDRV_CTL_ELEMENT_INFO_NAME_LENGTH);
> return 0;
ARRAY_SIZE() would do just as well here but this does look reasonable.
More information about the Alsa-devel
mailing list