ASoC: topology: Add topology UAPI header
PATCH v2 1/3 ASoC: topology: Add topology UAPI header
The ASoC topology UAPI header defines the structures
required to define any DSP firmware audio topology and control objects from userspace.
The following objects are supported :-
o kcontrols including TLV controls.
o DAPM widgets and graph elements
o Vendor bespoke objects.
o Coefficient data
o FE PCM capabilities and config.
o BE link capabilities and config.
o Codec <-> codec link capabilities and config.
o Topology object manifest.
The file format is simple and divided into blocks for each object type and each block has a header that defines it's size and type. Blocks can be in any order of type and can either all be in a single file or spread across more than one file. Blocks also have a group identifier ID so that they can be loaded and unloaded by ID.
--- include/sound/soc-dapm.h | 1 + include/uapi/sound/asoc.h | 388 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 389 insertions(+) create mode 100644 include/uapi/sound/asoc.h
include/sound/soc-dapm.h +1 -0
@@ -15,6 +15,7 @@#include <linux/types.h> #include <sound/control.h> +#include <sound/asoc.h> struct device ;
include/uapi/sound/asoc.h new file +388 -0
388 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 2/3 ASoC: topology: Add topology core
The topology core parses the FW topology file for known block types and instanciates any common ALSA/ASoC objects that it discovers. The core also passes any block that is does not understand to client component drivers for enumeration.
The core exports some APIs to client drivers in order to load and unload firmware topology data as use case require.
Currently the core deals with the following object types :-
o kcontrols. This includes TLV, enumerated and bytes controls.
o DAPM widgets. All types with any associated kcontrol.
o DAPM graph.
o FE PCM. FE PCM capabilities and configuration can be defined.
o BE DAI Link. BE DAI link capabilities and configuration can be defined.
o Codec <-> codec style links capabilities and configuration.
--- include/sound/soc-dapm.h | 2 + include/sound/soc-topology.h | 168 ++++ include/sound/soc.h | 11 + sound/soc/Makefile | 1 + sound/soc/soc-core.c | 4 + sound/soc/soc-topology.c | 1821 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 2007 insertions(+) create mode 100644 include/sound/soc-topology.h create mode 100644 sound/soc/soc-topology.c
include/sound/soc-dapm.h +2 -0
@@ -15,6 +15,7 @@#include <linux/types.h> #include <sound/control.h> +#include <sound/soc-topology.h> #include <sound/asoc.h> struct device ;
@@ -564,6 +565,7 @@ struct snd_soc_dapm_widget {int num_kcontrols;const struct snd_kcontrol_new *kcontrol_news;struct snd_kcontrol **kcontrols; +struct snd_soc_dobj dobj;/* widget input and outputs */ struct list_head sources;
include/sound/soc-topology.h new file +168 -0
168 lines not on this page · raw message
include/sound/soc.h +11 -0
@@ -27,6 +27,7 @@#include <sound/compress_driver.h> #include <sound/control.h> #include <sound/ac97_codec.h> +#include <sound/soc-topology.h> /* * Convenience kcontrol builders
@@ -755,6 +756,9 @@ struct snd_soc_component {struct mutex io_mutex; +/* attached dynamic objects */ +struct list_head dobj_list; +#ifdef CONFIG_DEBUG_FS struct dentry *debugfs_root;#endif
@@ -1099,6 +1103,9 @@ struct snd_soc_card {struct list_head dapm_list;struct list_head dapm_dirty; +/* attached dynamic objects */ +struct list_head dobj_list; +/* Generic DAPM context for the card */ struct snd_soc_dapm_context dapm;struct snd_soc_dapm_stats dapm_stats;
@@ -1158,6 +1165,7 @@ struct soc_mixer_control {unsigned int sign_bit; unsigned int invert:1; unsigned int autodisable:1; +struct snd_soc_dobj dobj; };struct soc_bytes {
@@ -1168,6 +1176,8 @@ struct soc_bytes {struct soc_bytes_ext {int max; +struct snd_soc_dobj dobj; +/* used for TLV byte control */ int (*get)(unsigned int __user *bytes,unsigned int size);int (*put)(const unsigned int __user *bytes,unsigned int size);
@@ -1188,6 +1198,7 @@ struct soc_enum {unsigned int mask;const char *const *texts;const unsigned int *values; +struct snd_soc_dobj dobj; };/**
sound/soc/Makefile +1 -0
@@ -1,5 +1,6 @@ snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o soc-ops.o +snd-soc-core-objs += soc-topology.o ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) snd-soc-core-objs += soc-generic-dmaengine-pcm.o
sound/soc/soc-core.c +4 -0
@@ -40,6 +40,7 @@#include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dpcm.h> +#include <sound/soc-topology.h> #include <sound/initval.h> #define CREATE_TRACE_POINTS
@@ -2435,6 +2436,7 @@ int snd_soc_register_card(struct snd_soc_card *card) card->rtd_aux[i].card = card;INIT_LIST_HEAD (&card->dapm_dirty); +INIT_LIST_HEAD (&card->dobj_list); card->instantiated =0 ;mutex_init (&card->mutex);mutex_init (&card->dapm_mutex);
@@ -2750,6 +2752,7 @@ static void snd_soc_component_add_unlocked(struct snd_soc_component *component) }list_add (&component->list, &component_list); +INIT_LIST_HEAD (&component->dobj_list); }static void snd_soc_component_add (struct snd_soc_component *component)
@@ -2826,6 +2829,7 @@ void snd_soc_unregister_component(struct device *dev)return ; found: +snd_soc_tplg_component_remove (cmpnt,SND_SOC_TPLG_INDEX_ALL );snd_soc_component_del_unlocked (cmpnt);mutex_unlock (&client_mutex);snd_soc_component_cleanup (cmpnt);
sound/soc/soc-topology.c new file +1821 -0
1,821 lines not on this page · raw message
Signature · 1 line
2.1.4
Mark Brown
maintainerRe: [PATCH v2 2/3] ASoC: topology: Add topology core
On Mon, May 25, 2015 at 06:22:49PM +0100, Liam Girdwood wrote:
This looks really nice at a high level, obviously it's a lot of code so there might be detail problems but I expect we can fix those up later.
include/sound/soc-dapm.h struct snd_soc_dapm_widget { · line 571
Quoted 8 lines
include/sound/soc-dapm.h +1
-0@@ -564,6 +565,7 @@ struct snd_soc_dapm_widget {int num_kcontrols;const struct snd_kcontrol_new *kcontrol_news;struct snd_kcontrol **kcontrols; +struct snd_soc_dobj dobj;/* widget input and outputs */ struct list_head sources;
This adds the dynamic object (which isn't enormous but isn't tiny) to every widget which could add up a bit. I don't know if it's worth making it a pointer to a dobj and allocating that separately? OTOH it's really routes rather than widgets that are the big cost, and it depends on allocators being friendly and not putting lots of padding round dobjs. Definitely fixable incrementally if it is an issue though.
include/sound/soc-topology.h line 111
Quoted 5 lines
include/sound/soc-topology.h new file +5
-0+/* external kcontrol init - used to set ext funcs + private data */ +int (*control_load)(struct snd_soc_component *, +struct snd_kcontrol_new *,struct snd_soc_tplg_ctl_hdr *); +int (*control_unload)(struct snd_soc_component *, +struct snd_soc_dobj *);
Do we have examples of all these external users yet? Just thinking about what happens if we need a load/unload function but the kernel doesn't know about this particular firmware type - the file didn't say code would be needed and perhaps the code is optional anyway (some optimisation or something). Is that something that was thought about yet, what sort of uses are we expecting?
Quoted 7 lines
sound/soc/soc-topology.c new file +7
-0+/* pass vendor data to component driver for processing */ +static int soc_tplg_vendor_load_ (struct soc_tplg *tplg, +struct snd_soc_tplg_hdr *hdr) +{ +int ret =0 ; + +if (tplg->comp && tplg->ops && tplg->ops->vendor_load)
sound/soc/soc-topology.c line 300
Quoted 10 lines
sound/soc/soc-topology.c new file +10
-0+ ret = tplg->ops->vendor_load (tplg->comp, hdr); + +if (ret <0 ) +dev_err (tplg->dev, +"ASoC: vendor load failed at hdr offset %ld/0x%lx for type %d:%d\n" , +soc_tplg_get_hdr_offset (tplg), +soc_tplg_get_hdr_offset (tplg), + hdr->type, hdr->vendor_type); +return ret; +}
For example I wonder if we should warn if we don't have a handler for vendor data that we see?
Re: [PATCH v2 2/3] ASoC: topology: Add topology core
Quoted 11 lines · Mark Brown
On Mon, May 25, 2015 at 06:22:49PM +0100, Liam Girdwood wrote:
This looks really nice at a high level, obviously it's a lot of code so there might be detail problems but I expect we can fix those up later.
Quoted 6 lines
include/sound/soc-dapm.h +1
-0@@ -564,6 +565,7 @@ struct snd_soc_dapm_widget {int num_kcontrols;const struct snd_kcontrol_new *kcontrol_news;struct snd_kcontrol **kcontrols; +struct snd_soc_dobj dobj;
Quoted 9 lines
include/sound/soc-dapm.h struct snd_soc_dapm_widget { · line 571
Quoted 2 lines
include/sound/soc-dapm.h +0
-0/* widget input and outputs */ struct list_head sources;This adds the dynamic object (which isn't enormous but isn't tiny) to every widget which could add up a bit. I don't know if it's worth making it a pointer to a dobj and allocating that separately? OTOH it's really routes rather than widgets that are the big cost, and it depends on allocators being friendly and not putting lots of padding round dobjs. Definitely fixable incrementally if it is an issue though.
Ideally we'd turn the dependency chain the other way around and have a snd_soc_dobj_widget struct which inherits snd_soc_dapm_widget and snd_soc_dobj. In the dobj callbacks you can then still use container_of to get it. This comes at the expense that we have to add a free() callback to snd_soc_dapm_widget. But it opens up the possibility to have other specialized widgets sub-classes. snd_soc_dapm_widget is already rather large given how many instance we have of it and quite a few of the fields are only used by a particular type of widget. Another good candidate for example would be the DAI link widget with all its params fields.
Mark Brown
maintainerRe: [PATCH v2 2/3] ASoC: topology: Add topology core
Quoted 9 lines · Lars-Peter Clausen
Ideally we'd turn the dependency chain the other way around and have a
snd_soc_dobj_widgetstruct which inheritssnd_soc_dapm_widgetandsnd_soc_dobj. In the dobj callbacks you can then still usecontainer_ofto get it. This comes at the expense that we have to add afree()callback tosnd_soc_dapm_widget. But it opens up the possibility to have other specialized widgets sub-classes.snd_soc_dapm_widgetis already rather large given how many instance we have of it and quite a few of the fields are only used by a particular type of widget. Another good candidate for example would be the DAI link widget with all its params fields.
Yeah, I was thinking something along those lines might be good long term but it's definitely a separate thing to getting the topology stuff in and I started worrying about things like multiple inheritance.
Re: [PATCH v2 2/3] ASoC: topology: Add topology core
Quoted 12 lines · Mark Brown
Quoted 9 lines · Lars-Peter Clausen
Ideally we'd turn the dependency chain the other way around and have a
snd_soc_dobj_widgetstruct which inheritssnd_soc_dapm_widgetandsnd_soc_dobj. In the dobj callbacks you can then still usecontainer_ofto get it. This comes at the expense that we have to add afree()callback tosnd_soc_dapm_widget. But it opens up the possibility to have other specialized widgets sub-classes.snd_soc_dapm_widgetis already rather large given how many instance we have of it and quite a few of the fields are only used by a particular type of widget. Another good candidate for example would be the DAI link widget with all its params fields.
Quoted 3 lines
Yeah, I was thinking something along those lines might be good long term but it's definitely a separate thing to getting the topology stuff in and I started worrying about things like multiple inheritance.
Yeah this would also help in reducing memory footprint. Probably a topic for the audio mini conf ?
Liam
Mark Brown
maintainerRe: [PATCH v2 2/3] ASoC: topology: Add topology core
Quoted 8 lines · Liam Girdwood
Quoted 3 lines · Mark Brown
Yeah, I was thinking something along those lines might be good long term but it's definitely a separate thing to getting the topology stuff in and I started worrying about things like multiple inheritance.
Yeah this would also help in reducing memory footprint. Probably a topic for the audio mini conf ?
I think so.
Re: [PATCH v2 2/3] ASoC: topology: Add topology core
In reply to Mark BrownQuoted 11 lines · Mark Brown
On Mon, May 25, 2015 at 06:22:49PM +0100, Liam Girdwood wrote:
This looks really nice at a high level, obviously it's a lot of code so there might be detail problems but I expect we can fix those up later.
Quoted 6 lines
include/sound/soc-dapm.h +1
-0@@ -564,6 +565,7 @@ struct snd_soc_dapm_widget {int num_kcontrols;const struct snd_kcontrol_new *kcontrol_news;struct snd_kcontrol **kcontrols; +struct snd_soc_dobj dobj;
Quoted 10 lines
include/sound/soc-dapm.h struct snd_soc_dapm_widget { · line 571
Quoted 2 lines
include/sound/soc-dapm.h +0
-0/* widget input and outputs */ struct list_head sources;This adds the dynamic object (which isn't enormous but isn't tiny) to every widget which could add up a bit. I don't know if it's worth making it a pointer to a dobj and allocating that separately? OTOH it's really routes rather than widgets that are the big cost, and it depends on allocators being friendly and not putting lots of padding round dobjs. Definitely fixable incrementally if it is an issue though.
Fwiw, we are planning to shrink DAPM a bit as part of the reduced memory work that Keyon and Vivian are doing. This will be on the list.
Quoted 4 lines
Quoted 4 lines
include/sound/soc-topology.h new file +4
-0+/* external kcontrol init - used to set ext funcs + private data */ +int (*control_load)(struct snd_soc_component *, +struct snd_kcontrol_new *,struct snd_soc_tplg_ctl_hdr *); + int (*control_unload)(struct snd_soc_component *,
Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ struct snd_soc_dobj *);Do we have examples of all these external users yet? Just thinking about what happens if we need a load/unload function but the kernel doesn't know about this particular firmware type - the file didn't say code would be needed and perhaps the code is optional anyway (some optimisation or something). Is that something that was thought about yet, what sort of uses are we expecting?
Vinod has some example code that has the callback on SKL (dont know if it's on public git atm). The intention here was to allow the driver to setup any configuration outside the standard kcontrol registration, so it would be used for things like sending DSP IPC messages to create the control in FW, or loading the private data into the DSP for that control etc. The comment is probably misleading since the get/put/info function binding is done in the core. I'll fix the comment for V3.
Quoted 13 lines
Quoted 13 lines
sound/soc/soc-topology.c new file +12
-0+/* pass vendor data to component driver for processing */ +static int soc_tplg_vendor_load_ (struct soc_tplg *tplg, +struct snd_soc_tplg_hdr *hdr) +{ +int ret =0 ; + +if (tplg->comp && tplg->ops && tplg->ops->vendor_load) + ret = tplg->ops->vendor_load (tplg->comp, hdr); + +if (ret <0 ) + dev_err(tplg->dev, + "ASoC: vendor load failed at hdr offset %ld/0x%lx for type %d:%d\n",
Quoted 8 lines
sound/soc/soc-topology.c line 300
Quoted 5 lines
sound/soc/soc-topology.c new file +5
-0+soc_tplg_get_hdr_offset (tplg), +soc_tplg_get_hdr_offset (tplg), + hdr->type, hdr->vendor_type); +return ret; +}For example I wonder if we should warn if we don't have a handler for vendor data that we see?
Yes, will fix in V3.
Re: [PATCH v2 2/3] ASoC: topology: Add topology core
Quoted 39 lines · Liam Girdwood
Quoted 11 lines · Mark Brown
On Mon, May 25, 2015 at 06:22:49PM +0100, Liam Girdwood wrote:
This looks really nice at a high level, obviously it's a lot of code so there might be detail problems but I expect we can fix those up later.
Quoted 6 lines
include/sound/soc-dapm.h +1
-0@@ -564,6 +565,7 @@ struct snd_soc_dapm_widget {int num_kcontrols;const struct snd_kcontrol_new *kcontrol_news;struct snd_kcontrol **kcontrols; +struct snd_soc_dobj dobj;Quoted 10 lines
include/sound/soc-dapm.h struct snd_soc_dapm_widget { · line 571
Quoted 2 lines
include/sound/soc-dapm.h +0
-0/* widget input and outputs */ struct list_head sources;This adds the dynamic object (which isn't enormous but isn't tiny) to every widget which could add up a bit. I don't know if it's worth making it a pointer to a dobj and allocating that separately? OTOH it's really routes rather than widgets that are the big cost, and it depends on allocators being friendly and not putting lots of padding round dobjs. Definitely fixable incrementally if it is an issue though.
Fwiw, we are planning to shrink DAPM a bit as part of the reduced memory work that Keyon and Vivian are doing. This will be on the list.
Quoted 4 lines
Quoted 4 lines
include/sound/soc-topology.h new file +4
-0+/* external kcontrol init - used to set ext funcs + private data */ +int (*control_load)(struct snd_soc_component *, +struct snd_kcontrol_new *,struct snd_soc_tplg_ctl_hdr *); + int (*control_unload)(struct snd_soc_component *,Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ struct snd_soc_dobj *);Do we have examples of all these external users yet? Just thinking about what happens if we need a load/unload function but the kernel doesn't know about this particular firmware type - the file didn't say code would be needed and perhaps the code is optional anyway (some optimisation or something). Is that something that was thought about yet, what sort of uses are we expecting?
Quoted 7 lines
Vinod has some example code that has the callback on SKL (dont know if it's on public git atm). The intention here was to allow the driver to setup any configuration outside the standard kcontrol registration, so it would be used for things like sending DSP IPC messages to create the control in FW, or loading the private data into the DSP for that control etc. The comment is probably misleading since the get/put/info function binding is done in the core. I'll fix the comment for V3.
The toplogy code wasnt sent in RFC as it was dependent on this series but I can push it to git if Mark wants a look :)
So for us, each control requires some parameters which we need to pass to DSP in order to instantiate that object. So we get the callback into driver and save the private data in kcontrol and pass it to DSP as IPC parameters
Signature · 1 line
~Vinod
Quoted 25 lines
Quoted 14 lines
Quoted 14 lines
sound/soc/soc-topology.c new file +12
-0+/* pass vendor data to component driver for processing */ +static int soc_tplg_vendor_load_ (struct soc_tplg *tplg, +struct snd_soc_tplg_hdr *hdr) +{ +int ret =0 ; + +if (tplg->comp && tplg->ops && tplg->ops->vendor_load) + ret = tplg->ops->vendor_load (tplg->comp, hdr); + +if (ret <0 ) + dev_err(tplg->dev, + "ASoC: vendor load failed at hdr offset %ld/0x%lx for type %d:%d\n",Quoted 8 lines
sound/soc/soc-topology.c line 300
Quoted 5 lines
sound/soc/soc-topology.c new file +5
-0+soc_tplg_get_hdr_offset (tplg), +soc_tplg_get_hdr_offset (tplg), + hdr->type, hdr->vendor_type); +return ret; +}For example I wonder if we should warn if we don't have a handler for vendor data that we see?
Yes, will fix in V3.
PATCH v2 3/3 ALSA: topology: Export ID types for TLV controls.
In reply to Liam GirdwoodMake sure userspace can define TLV controls for topolofy using the correct type numbers.
--- include/sound/tlv.h | 7 +------ include/uapi/sound/tlv.h | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 include/uapi/sound/tlv.h
include/sound/tlv.h +1 -6
@@ -31,12 +31,7 @@* ~(sizeof(unsigned int) - 1)) .... */ -#define SNDRV_CTL_TLVT_CONTAINER 0/* one level down - group of TLVs */ -#define SNDRV_CTL_TLVT_DB_SCALE 1/* dB scale */ -#define SNDRV_CTL_TLVT_DB_LINEAR 2/* linear volume */ -#define SNDRV_CTL_TLVT_DB_RANGE 3/* dB range container */ -#define SNDRV_CTL_TLVT_DB_MINMAX 4/* dB scale with min/max */ -#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5/* dB scale with min/max with mute */ +#include <uapi/sound/tlv.h> #define TLV_ITEM (type, ...) \ (type), TLV_LENGTH(__VA_ARGS__), __VA_ARGS__
include/uapi/sound/tlv.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __UAPI_SOUND_TLV_H +#define __UAPI_SOUND_TLV_H + +#define SNDRV_CTL_TLVT_CONTAINER 0/* one level down - group of TLVs */ +#define SNDRV_CTL_TLVT_DB_SCALE 1/* dB scale */ +#define SNDRV_CTL_TLVT_DB_LINEAR 2/* linear volume */ +#define SNDRV_CTL_TLVT_DB_RANGE 3/* dB range container */ +#define SNDRV_CTL_TLVT_DB_MINMAX 4/* dB scale with min/max */ +#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5/* dB scale with min/max with mute */ + +#endif
Signature · 1 line
2.1.4
Re: [PATCH v2 3/3] ALSA: topology: Export ID types for TLV controls.
include/sound/tlv.h
Quoted 11 lines · Liam Girdwood
Make sure userspace can define TLV controls for topolofy using the correct type numbers.
Signed-off-by Liam Girdwood <[email protected]>--- include/sound/tlv.h | 7 +------ include/uapi/sound/tlv.h | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 include/uapi/sound/tlv.hinclude/sound/tlv.h +0
-0
Takashi, do you want this rolled into uapi/sound/asound.h or is it fine as a separate file ?
Liam
Quoted 46 lines
index e11e179..7209331 100644
include/sound/tlv.h +1
-6@@ -31,12 +31,7 @@* ~(sizeof(unsigned int) - 1)) .... */ -#define SNDRV_CTL_TLVT_CONTAINER 0/* one level down - group of TLVs */ -#define SNDRV_CTL_TLVT_DB_SCALE 1/* dB scale */ -#define SNDRV_CTL_TLVT_DB_LINEAR 2/* linear volume */ -#define SNDRV_CTL_TLVT_DB_RANGE 3/* dB range container */ -#define SNDRV_CTL_TLVT_DB_MINMAX 4/* dB scale with min/max */ -#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5/* dB scale with min/max with mute */ +#include <uapi/sound/tlv.h> #define TLV_ITEM (type, ...) \ (type), TLV_LENGTH(__VA_ARGS__), __VA_ARGS__include/uapi/sound/tlv.h new file +23
-0@@ -0,0 +1,23 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __UAPI_SOUND_TLV_H +#define __UAPI_SOUND_TLV_H + +#define SNDRV_CTL_TLVT_CONTAINER 0/* one level down - group of TLVs */ +#define SNDRV_CTL_TLVT_DB_SCALE 1/* dB scale */ +#define SNDRV_CTL_TLVT_DB_LINEAR 2/* linear volume */ +#define SNDRV_CTL_TLVT_DB_RANGE 3/* dB range container */ +#define SNDRV_CTL_TLVT_DB_MINMAX 4/* dB scale with min/max */ +#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5/* dB scale with min/max with mute */ + +#endif
Re: [PATCH v2 3/3] ALSA: topology: Export ID types for TLV controls.
At Thu, 28 May 2015 15:47:36 +0100,
Quoted 12 lines · Liam Girdwood
Quoted 10 lines · Liam Girdwood
Make sure userspace can define TLV controls for topolofy using the correct type numbers.
Signed-off-by Liam Girdwood <[email protected]>--- include/sound/tlv.h | 7 +------ include/uapi/sound/tlv.h | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 include/uapi/sound/tlv.h
Quoted 4 lines
include/sound/tlv.h
Quoted 1 line
include/sound/tlv.h +0
-0Takashi, do you want this rolled into
uapi/sound/asound.hor is it fine as a separate file ?
I think uapi/sound/tlv.h is fine.
But don't forget to export other consts. For example, SNDRV_CTL_TLVT_CHMAP_* are also reserved for channel-maps.
thanks,
Takashi
Mark Brown
maintainerQuoted 3 lines · Liam Girdwood
The ASoC topology UAPI header defines the structures
required to define any DSP firmware audio topology and control objects from userspace.
This looks pretty good to me. I've got a few comments below but they're mostly either typo level stuff plus a couple of things that are basically "we should explicitly think about this" but where I'm not 100% convinced we actually need to change anything.
I'm not convinced we need to export *all* the control types we've got in the kernel at the minute but on the other hand they don't really do any harm.
include/uapi/sound/asoc.h line 77
Quoted 2 lines
include/uapi/sound/asoc.h new file +2
-0+/* string sizes */ +#define SND_SOC_TPLG_NUM_TEXTS 16
Comment probably needs updating.
include/uapi/sound/asoc.h line 83
Quoted 2 lines
include/uapi/sound/asoc.h new file +2
-0+/* Max size of TLV data */ +#define SND_SOC_TPLG_TLV_SIZE 32
Units (IIRC it might be ints or something in the kernel, I didn't check though)?
include/uapi/sound/asoc.h line 106
Quoted 5 lines
include/uapi/sound/asoc.h new file +5
-0+/* vendor block IDs - please add new vendor types to end */ +#define SND_SOC_TPLG_TYPE_VENDOR_FW 1000 +#define SND_SOC_TPLG_TYPE_VENDOR_CONFIG 1001 +#define SND_SOC_TPLG_TYPE_VENDOR_COEFF 1002 +#define SND_SOC_TPLG_TYPEVENDOR_CODEC 1003
Missing _
include/uapi/sound/asoc.h line 145
Quoted 6 lines
include/uapi/sound/asoc.h new file +6
-0+struct snd_soc_tplg_ctl_tlv { +__le32 size;/* in bytes aligned to 4 */ +__le32 numid;/* control element numeric identification */ +__le32 count;/* number of elem in data array */ +__le32 data[SND_SOC_TPLG_TLV_SIZE ]; +} __attribute__((packed));
We *could* make data variable size since there's a size field here. Not sure it's worth the effort though.
include/uapi/sound/asoc.h line 164
Quoted 8 lines
include/uapi/sound/asoc.h new file +8
-0+/* +* Kcontrol Operations IDs +*/ +struct snd_soc_tplg_kcontrol_ops_id { +__le32 get; +__le32 put; +__le32 info; +} __attribute__((packed));
Would these ever usefully not match up with each other?
include/uapi/sound/asoc.h line 185
Quoted 5 lines
include/uapi/sound/asoc.h new file +5
-0+struct snd_soc_tplg_stream_caps { +__le32 size;/* in bytes of this structure */ +char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +__le64 formats[SND_SOC_TPLG_MAX_FORMATS ];/* supported formats SNDRV_PCM_FMTBIT_* */ +__le32 rates;/* supported rates SNDRV_PCM_RATE_* */
We should move _FMTBIT and _RATE to UAPI as well since they're becoming part of the ABI (I think the other defines we reference already are or are moved as part of this patch).
include/uapi/sound/asoc.h line 196
Quoted 11 lines
include/uapi/sound/asoc.h new file +11
-0+__le32 rate_min;/* min rate */ +__le32 rate_max;/* max rate */ +__le32 channels_min;/* min channels */ +__le32 channels_max;/* max channels */ +__le32 periods_min;/* min number of periods */ +__le32 periods_max;/* max number of periods */ +__le32 period_size_min;/* min period size bytes */ +__le32 period_size_max;/* max period size bytes */ +__le32 buffer_size_min;/* min buffer size bytes */ +__le32 buffer_size_max;/* max buffer size bytes */ +} __attribute__((packed));
So, clearly this is easy to map onto ALSA. I am wondering if we want to take the time to tweak things a bit though, especially with channels where it seems we fairly often have a requirement for an even number of channels which this doesn't capture. I was thinking a list of valid channel counts and a list of valid rates, those should cope with whatever requirements come up in future. Don't know if it's really worth it though, but it should be fairly straightfoward to map and the above does cause friction with our current interfaces. Thoughts?
Quoted 7 lines
include/uapi/sound/asoc.h new file +7
-0+/* +* Bytes kcontrol +* +* File block representation for bytes kcontrol :- +* +-----------------------------------+----+ +* | struct snd_soc_tplg_hdr | 1 | +* +-----------------------------------+----+
include/uapi/sound/asoc.h line 305
Quoted 10 lines
include/uapi/sound/asoc.h new file +10
-0+* | struct snd_soc_tplg_bytes_control | N | +* +-----------------------------------+----+ +*/ +struct snd_soc_tplg_bytes_control { +struct snd_soc_tplg_ctl_hdr hdr; +__le32 size;/* in bytes of this structure */ +__le32 max; +__le32 mask; +__le32 base; +__le32 num_regs;
Should this be in registers or bytes - if it's registers we need to know how big a register is?
Quoted 5 lines
include/uapi/sound/asoc.h new file +5
-0+/* +* DAPM Graph Element +* +* File block representation for DAPM graph elements :- +* +-------------------------------------+----+
include/uapi/sound/asoc.h line 323
Quoted 10 lines
include/uapi/sound/asoc.h new file +10
-0+* | struct snd_soc_tplg_hdr | 1 | +* +-------------------------------------+----+ +* | struct snd_soc_tplg_dapm_graph_elem | N | +* +-------------------------------------+----+ +*/ +struct snd_soc_tplg_dapm_graph_elem { +char sink[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +char control[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +char source[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +} __attribute__((packed));
Since this format is going to be machine generated and read should we consider using numbers (mind you, strings are just very big numbers)? It'd make the files smaller but I'm really unsure it's worth the cost.
Given all the talk about size optimisation right now I can see people wanting to change that bit of our implementation soon though we will for the forseeable future always have a translation mechanism for strings so it's not like it'll bitrot and it's effort right now that would make things less debuggable at runtime ("What do I need to connect to 'firmware-534' again?").
include/uapi/sound/asoc.h line 351
Quoted 3 lines
include/uapi/sound/asoc.h new file +2
-0+struct snd_soc_tplg_dapm_widget { +__u32 ignore_suspend;/* kept enabled over suspend */
I don't think we want this in the binary file, the question of "what is suspend" gets tricky and it's mainly for machine drivers in the in-kernel stuff. Are you actually using it at the minute or is it just coming from the translation of the current in kernel structs?