[alsa-devel] [PATCH 1/1] Asoc: bytcr-rt5640: add more machine/board information for user space

Liam Girdwood liam.r.girdwood at linux.intel.com
Tue Mar 29 09:05:41 CEST 2016


On Tue, 2016-03-29 at 14:35 +0800, han.lu at intel.com wrote:
> From: "Lu, Han" <han.lu at intel.com>
> 
> Add more machine/board information for PA and UCM.
> Previously on ASoc, the card short name, driver name and long name are
> all the same as the machine driver name. On T100TA it looks like:
>   $ cat /proc/asound/cards
>     0 [bytcr-rt5640]: bytcr-rt5640 -  bytcr-rt5640
>                       bytcr-rt5640
> The patch made changes below:
>   driver name --->  machine driver name
>   short name  --->  DMI_PRODUCT_NAME or DMI_BOARD_NAME
>   long name   --->  short name:driver name(:DMI_SYS_VENDOR if applicable)
> And add card component: long name:firmware name. On T100TA it looks like:
>   $ cat /proc/asound/cards
>     0 [T100TA      ]: bytcr-rt5640 -  T100TA
>                       T100TA:bytcr-rt5640:ASUSTek COMPUTER INC.
>   $ amixer -c0 info
>   Card hw:0 'T100TA'/'T100TA:bytcr-rt5640:ASUSTek COMPUTER INC.'
>     Mixer name    : ''
>     Components    : 'T100TA:bytcr-rt5640:ASUSTek COMPUTER INC.:intel/fw_s
>   st_0f28.bin'
>     Controls      : 256
>     Simple ctrls  : 228
> 
> Signed-off-by: Lu, Han <han.lu at intel.com>
> 
> diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
> index 032a2e7..068cd58 100644
> --- a/sound/soc/intel/boards/bytcr_rt5640.c
> +++ b/sound/soc/intel/boards/bytcr_rt5640.c
> @@ -152,6 +152,8 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
>  	{}
>  };
>  
> +static struct snd_soc_card byt_rt5640_card;
> +
>  static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
>  {
>  	int ret;
> @@ -159,6 +161,34 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
>  	struct snd_soc_card *card = runtime->card;
>  	const struct snd_soc_dapm_route *custom_map;
>  	int num_routes;
> +	const char *dmi_name;
> +	char *component;
> +	struct sst_acpi_mach *mach = byt_rt5640_card.dev->platform_data;
> +
> +	/* Add machine/board information for userspace:
> +	 *   card driver name --->  machine driver name
> +	 *   card short name  --->  DMI_PRODUCT_NAME or DMI_BOARD_NAME
> +	 *   card long name   --->  short name:driver name(:DMI_SYS_VENDOR)
> +	 */
> +	card->driver_name = card->name;
> +	dmi_name = dmi_get_system_info(DMI_PRODUCT_NAME);
> +	if (!dmi_name)
> +		dmi_name = dmi_get_system_info(DMI_BOARD_NAME);
> +	if (dmi_name)
> +		card->name = dmi_name;
> +	card->long_name = kstrdup(card->name, GFP_KERNEL)

Best to check here and below whether kstrdup succeeds.

> ;
> +	strcat((char *)card->long_name, ":");
> +	strcat((char *)card->long_name, card->driver_name);
> +	dmi_name = dmi_get_system_info(DMI_SYS_VENDOR);
> +	if (dmi_name) {
> +		strcat((char *)card->long_name, ":");
> +		strcat((char *)card->long_name, dmi_name);
> +	}
> +	/*  card component  --->  long name:firmware name */
> +	component = kstrdup(card->long_name, GFP_KERNEL);
> +	strcat(component, ":");
> +	strcat(component, mach->fw_filename);
> +	snd_component_add(card->snd_card, component);
>  
>  	card->dapm.idle_bias_off = true;
>  

We should probably add this as a core API since a lot of machine drivers
will likely just copy and paste.

Thanks

Liam




More information about the Alsa-devel mailing list