ASoC: topology: Add topology UAPI header.
RFC 1/4 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 | 33 +--- include/uapi/sound/asoc.h | 420 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 421 insertions(+), 32 deletions(-) create mode 100644 include/uapi/sound/asoc.h
include/sound/soc-dapm.h +1 -32
@@ -15,6 +15,7 @@#include <linux/types.h> #include <sound/control.h> +#include <sound/asoc.h> struct device ;
@@ -447,38 +448,6 @@ struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol)struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm (struct snd_kcontrol *kcontrol); -/* dapm widget types */ -enum snd_soc_dapm_type { - snd_soc_dapm_input =0 ,/* input pin */ - snd_soc_dapm_output,/* output pin */ - snd_soc_dapm_mux,/* selects 1 analog signal from many inputs */ - snd_soc_dapm_mixer,/* mixes several analog signals together */ - snd_soc_dapm_mixer_named_ctl,/* mixer with named controls */ - snd_soc_dapm_pga,/* programmable gain/attenuation (volume) */ - snd_soc_dapm_out_drv,/* output driver */ - snd_soc_dapm_adc,/* analog to digital converter */ - snd_soc_dapm_dac,/* digital to analog converter */ - snd_soc_dapm_micbias,/* microphone bias (power) */ - snd_soc_dapm_mic,/* microphone */ - snd_soc_dapm_hp,/* headphones */ - snd_soc_dapm_spk,/* speaker */ - snd_soc_dapm_line,/* line input/output */ - snd_soc_dapm_switch,/* analog switch */ - snd_soc_dapm_vmid,/* codec bias/vmid - to minimise pops */ - snd_soc_dapm_pre,/* machine specific pre widget - exec first */ - snd_soc_dapm_post,/* machine specific post widget - exec last */ - snd_soc_dapm_supply,/* power/clock supply */ - snd_soc_dapm_regulator_supply,/* external regulator */ - snd_soc_dapm_clock_supply,/* external clock */ - snd_soc_dapm_aif_in,/* audio interface input */ - snd_soc_dapm_aif_out,/* audio interface output */ - snd_soc_dapm_siggen,/* signal generator */ - snd_soc_dapm_dai_in,/* link to DAI structure */ - snd_soc_dapm_dai_out, - snd_soc_dapm_dai_link,/* link between two DAI structures */ - snd_soc_dapm_kcontrol,/* Auto-disabled kcontrol */ -}; -enum snd_soc_dapm_subclass {SND_SOC_DAPM_CLASS_INIT =0 ,SND_SOC_DAPM_CLASS_RUNTIME =1 ,
include/uapi/sound/asoc.h new file +420 -0
420 lines not on this page · raw message
Signature · 1 line
2.1.0
Mark Brown
maintainerinclude/uapi/sound/asoc.h line 219
Quoted 10 lines · Liam Girdwood
include/uapi/sound/asoc.h new file +10
-0+struct snd_soc_tplg_hdr { +__le32 magic; +__le32 abi;/* ABI version */ +__le32 version;/* optional vendor specific version details */ +__le32 type;/* SND_SOC_TPLG_ */ +__le32 vendor_type;/* optional vendor specific type info */ +__le32 size;/* data bytes, excluding this header */ +__le32 id;/* identifier for block */ +char reserved[128 ]; +} __attribute__((packed));
Not got a massively strong opinion here but given that we have ABI versioning can we just skip the 128 bytes of reserved space in most of the structs? Doesn't seem to be doing much except making the files bigger.
include/uapi/sound/asoc.h line 286
Quoted 12 lines
include/uapi/sound/asoc.h new file +12
-0+/* +* Mixer kcontrol. +*/ +struct snd_soc_tplg_mixer_control { +struct snd_soc_tplg_control_hdr hdr; +__le32 min; +__le32 max; +__le32 platform_max; +__le32 reg; +__le32 rreg; +__le32 shift; +__le32 rshift;
Do we want to convert this into an array of reg/shift tuples for the (dobutless forthcoming) 5.1 controls? Not sure it's worth it. I do think we probably need some explicit documentation for things like what to do with the left and right bits, I guess we hope other OSs or whatever can make use of the same topology if we're trying to make it standard.
Quoted 17 lines · Mark Brown
include/uapi/sound/asoc.h line 219
Quoted 10 lines · Liam Girdwood
include/uapi/sound/asoc.h new file +10
-0+struct snd_soc_tplg_hdr { +__le32 magic; +__le32 abi;/* ABI version */ +__le32 version;/* optional vendor specific version details */ +__le32 type;/* SND_SOC_TPLG_ */ +__le32 vendor_type;/* optional vendor specific type info */ +__le32 size;/* data bytes, excluding this header */ +__le32 id;/* identifier for block */ +char reserved[128 ]; +} __attribute__((packed));Not got a massively strong opinion here but given that we have ABI versioning can we just skip the 128 bytes of reserved space in most of the structs? Doesn't seem to be doing much except making the files bigger.
We had a similar discussion in Nuremburg last week, the intention is to keep the size of the structures constant so wont dont break older kernels with newer userspace ABIs etc.
Quoted 12 lines
Quoted 12 lines
include/uapi/sound/asoc.h new file +11
-0+/* +* Mixer kcontrol. +*/ +struct snd_soc_tplg_mixer_control { +struct snd_soc_tplg_control_hdr hdr; +__le32 min; +__le32 max; +__le32 platform_max; +__le32 reg; +__le32 rreg; +__le32 shift;
Quoted 8 lines
include/uapi/sound/asoc.h line 286
Quoted 1 line
include/uapi/sound/asoc.h new file +1
-0+__le32 rshift;Do we want to convert this into an array of reg/shift tuples for the (dobutless forthcoming) 5.1 controls? Not sure it's worth it. I do think we probably need some explicit documentation for things like what to do with the left and right bits, I guess we hope other OSs or whatever can make use of the same topology if we're trying to make it standard.
Yeah, that's a good point which we should address :)
What about something like :-
struct snd_soc_mixer_channel {
__le32 reg;
__le32 shift;
}struct snd_soc_tplg_mixer_control {
struct snd_soc_tplg_control_hdr hdr;
__le32 min;
__le32 max;
__le32 platform_max;
__le32 invert;
__le32 num_channels;
char reserved[64];
struct snd_soc_tplg_mixer_channel channel[0];
struct snd_soc_tplg_private priv;
} __attribute__((packed));The same could be applied to the other control types too ?
Liam
Quoted 4 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Tue, 21 Apr 2015 10:47:53 +0100,
Quoted 20 lines · Liam Girdwood
Quoted 17 lines · Mark Brown
include/uapi/sound/asoc.h line 219
Quoted 10 lines · Liam Girdwood
include/uapi/sound/asoc.h new file +10
-0+struct snd_soc_tplg_hdr { +__le32 magic; +__le32 abi;/* ABI version */ +__le32 version;/* optional vendor specific version details */ +__le32 type;/* SND_SOC_TPLG_ */ +__le32 vendor_type;/* optional vendor specific type info */ +__le32 size;/* data bytes, excluding this header */ +__le32 id;/* identifier for block */ +char reserved[128 ]; +} __attribute__((packed));Not got a massively strong opinion here but given that we have ABI versioning can we just skip the 128 bytes of reserved space in most of the structs? Doesn't seem to be doing much except making the files bigger.
Quoted 3 lines
We had a similar discussion in Nuremburg last week, the intention is to keep the size of the structures constant so wont dont break older kernels with newer userspace ABIs etc.
Maybe a question is whether the size is sensible. But the argument here was "memory is cheap nowadays".
Quoted 29 lines
Quoted 11 lines
Quoted 11 lines
include/uapi/sound/asoc.h new file +11
-0+/* +* Mixer kcontrol. +*/ +struct snd_soc_tplg_mixer_control { +struct snd_soc_tplg_control_hdr hdr; +__le32 min; +__le32 max; +__le32 platform_max; +__le32 reg; +__le32 rreg; +__le32 shift;Quoted 8 lines
include/uapi/sound/asoc.h line 286
Quoted 1 line
include/uapi/sound/asoc.h new file +1
-0+__le32 rshift;Do we want to convert this into an array of reg/shift tuples for the (dobutless forthcoming) 5.1 controls? Not sure it's worth it. I do think we probably need some explicit documentation for things like what to do with the left and right bits, I guess we hope other OSs or whatever can make use of the same topology if we're trying to make it standard.
Yeah, that's a good point which we should address :)
What about something like :-
struct snd_soc_mixer_channel { __le32 reg; __le32 shift; }
Quoted 10 lines
struct snd_soc_tplg_mixer_control {
struct snd_soc_tplg_control_hdr hdr;
__le32 min;
__le32 max;
__le32 platform_max;
__le32 invert;
__le32 num_channels;
char reserved[64];
struct snd_soc_tplg_mixer_channel channel[0];
struct snd_soc_tplg_private priv;A field after a variable array doesn't work. Either drop priv or make channel a fixed size array (with some max).
Takashi
Quoted 22 lines · Takashi Iwai
At Tue, 21 Apr 2015 10:47:53 +0100,
Quoted 20 lines · Liam Girdwood
Quoted 17 lines · Mark Brown
include/uapi/sound/asoc.h line 219
Quoted 10 lines · Liam Girdwood
include/uapi/sound/asoc.h new file +10
-0+struct snd_soc_tplg_hdr { +__le32 magic; +__le32 abi;/* ABI version */ +__le32 version;/* optional vendor specific version details */ +__le32 type;/* SND_SOC_TPLG_ */ +__le32 vendor_type;/* optional vendor specific type info */ +__le32 size;/* data bytes, excluding this header */ +__le32 id;/* identifier for block */ +char reserved[128 ]; +} __attribute__((packed));Not got a massively strong opinion here but given that we have ABI versioning can we just skip the 128 bytes of reserved space in most of the structs? Doesn't seem to be doing much except making the files bigger.
Quoted 6 lines
Quoted 3 lines
We had a similar discussion in Nuremburg last week, the intention is to keep the size of the structures constant so wont dont break older kernels with newer userspace ABIs etc.
Maybe a question is whether the size is sensible. But the argument here was "memory is cheap nowadays".
Ok, we can reduce the size here. I think Vinod wanted at least 4 * 4 byte words (i.e. 16 bytes) minimum IIRC, what about 16 bytes ? That would give us at least 4 new members for the future ?
Quoted 42 lines
Quoted 31 lines
Quoted 13 lines
Quoted 13 lines
include/uapi/sound/asoc.h new file +11
-0+/* +* Mixer kcontrol. +*/ +struct snd_soc_tplg_mixer_control { +struct snd_soc_tplg_control_hdr hdr; +__le32 min; +__le32 max; +__le32 platform_max; +__le32 reg; +__le32 rreg; +__le32 shift;Quoted 8 lines
include/uapi/sound/asoc.h line 286
Quoted 1 line
include/uapi/sound/asoc.h new file +1
-0+__le32 rshift;Do we want to convert this into an array of reg/shift tuples for the (dobutless forthcoming) 5.1 controls? Not sure it's worth it. I do think we probably need some explicit documentation for things like what to do with the left and right bits, I guess we hope other OSs or whatever can make use of the same topology if we're trying to make it standard.
Yeah, that's a good point which we should address :)
What about something like :-
struct snd_soc_mixer_channel { __le32 reg; __le32 shift; }Quoted 10 lines
struct snd_soc_tplg_mixer_control { struct snd_soc_tplg_control_hdr hdr; __le32 min; __le32 max; __le32 platform_max; __le32 invert; __le32 num_channels; char reserved[64]; struct snd_soc_tplg_mixer_channel channel[0]; struct snd_soc_tplg_private priv;
Quoted 2 lines
A field after a variable array doesn't work. Either drop priv or make channel a fixed size array (with some max).
Oh I did not try and build this ;) A fixed size works for me. What about 8 channels (meaning we support upto 7.1) ?
Another thing that comes to mind is should we also include some channel mapping data ?
struct snd_soc_mixer_channel {
__le32 map; /* Maps to ID for Left, Right, LFE etc */
__le32 reg;
__le32 shift;
}Liam
At Tue, 21 Apr 2015 13:43:47 +0100,
Quoted 77 lines · Liam Girdwood
Quoted 22 lines · Takashi Iwai
At Tue, 21 Apr 2015 10:47:53 +0100,
Quoted 20 lines · Liam Girdwood
Quoted 17 lines · Mark Brown
include/uapi/sound/asoc.h line 219
Quoted 10 lines · Liam Girdwood
include/uapi/sound/asoc.h new file +10
-0+struct snd_soc_tplg_hdr { +__le32 magic; +__le32 abi;/* ABI version */ +__le32 version;/* optional vendor specific version details */ +__le32 type;/* SND_SOC_TPLG_ */ +__le32 vendor_type;/* optional vendor specific type info */ +__le32 size;/* data bytes, excluding this header */ +__le32 id;/* identifier for block */ +char reserved[128 ]; +} __attribute__((packed));Not got a massively strong opinion here but given that we have ABI versioning can we just skip the 128 bytes of reserved space in most of the structs? Doesn't seem to be doing much except making the files bigger.
Quoted 6 lines
Quoted 3 lines
We had a similar discussion in Nuremburg last week, the intention is to keep the size of the structures constant so wont dont break older kernels with newer userspace ABIs etc.
Maybe a question is whether the size is sensible. But the argument here was "memory is cheap nowadays".
Ok, we can reduce the size here. I think Vinod wanted at least 4 * 4 byte words (i.e. 16 bytes) minimum IIRC, what about 16 bytes ? That would give us at least 4 new members for the future ?
Quoted 42 lines
Quoted 41 lines
Quoted 13 lines
Quoted 13 lines
include/uapi/sound/asoc.h new file +11
-0+/* +* Mixer kcontrol. +*/ +struct snd_soc_tplg_mixer_control { +struct snd_soc_tplg_control_hdr hdr; +__le32 min; +__le32 max; +__le32 platform_max; +__le32 reg; +__le32 rreg; +__le32 shift;Quoted 8 lines
include/uapi/sound/asoc.h line 286
Quoted 1 line
include/uapi/sound/asoc.h new file +1
-0+__le32 rshift;Do we want to convert this into an array of reg/shift tuples for the (dobutless forthcoming) 5.1 controls? Not sure it's worth it. I do think we probably need some explicit documentation for things like what to do with the left and right bits, I guess we hope other OSs or whatever can make use of the same topology if we're trying to make it standard.
Yeah, that's a good point which we should address :)
What about something like :-
struct snd_soc_mixer_channel { __le32 reg; __le32 shift; }struct snd_soc_tplg_mixer_control { struct snd_soc_tplg_control_hdr hdr; __le32 min; __le32 max; __le32 platform_max; __le32 invert; __le32 num_channels; char reserved[64]; struct snd_soc_tplg_mixer_channel channel[0]; struct snd_soc_tplg_private priv;
Quoted 5 lines
Quoted 2 lines
A field after a variable array doesn't work. Either drop priv or make channel a fixed size array (with some max).
Oh I did not try and build this ;) A fixed size works for me. What about 8 channels (meaning we support upto 7.1) ?
I can imagine more than handful speakers :)
But then it's a question whether they should be handled as a single mixer control.
Quoted 8 lines
Another thing that comes to mind is should we also include some channel mapping data ?
struct snd_soc_mixer_channel { __le32 map; /* Maps to ID for Left, Right, LFE etc */ __le32 reg; __le32 shift; }
This is an interesting question. The speaker mapping isn't always unique to the number of channels. Several channel maps are available for 8 channels, and it's the reason I came up with chmap API a couple of years ago.
Takashi
Mark Brown
maintainerQuoted 12 lines · Liam Girdwood
Quoted 10 lines · Takashi Iwai
At Tue, 21 Apr 2015 10:47:53 +0100,
Quoted 8 lines
Quoted 4 lines
Not got a massively strong opinion here but given that we have ABI versioning can we just skip the 128 bytes of reserved space in most of the structs? Doesn't seem to be doing much except making the files bigger.
We had a similar discussion in Nuremburg last week, the intention is to keep the size of the structures constant so wont dont break older kernels with newer userspace ABIs etc.
Quoted 6 lines
Quoted 2 lines
Maybe a question is whether the size is sensible. But the argument here was "memory is cheap nowadays".
Ok, we can reduce the size here. I think Vinod wanted at least 4 * 4 byte words (i.e. 16 bytes) minimum IIRC, what about 16 bytes ? That would give us at least 4 new members for the future ?
That's sounding like an awfully small number if we're trying to be infititely future proof (obviously the default value for that is 640k!). We'd also need to go through and give *all* the structures padding. How about just adding length fields instead with a rule that if the structure is bigger than you know about just ignore anything at the end?
At Tue, 21 Apr 2015 16:03:42 +0100,
Quoted 21 lines · Mark Brown
Quoted 12 lines · Liam Girdwood
Quoted 10 lines · Takashi Iwai
At Tue, 21 Apr 2015 10:47:53 +0100,
Quoted 8 lines
Quoted 4 lines
Not got a massively strong opinion here but given that we have ABI versioning can we just skip the 128 bytes of reserved space in most of the structs? Doesn't seem to be doing much except making the files bigger.
We had a similar discussion in Nuremburg last week, the intention is to keep the size of the structures constant so wont dont break older kernels with newer userspace ABIs etc.
Quoted 6 lines
Quoted 2 lines
Maybe a question is whether the size is sensible. But the argument here was "memory is cheap nowadays".
Ok, we can reduce the size here. I think Vinod wanted at least 4 * 4 byte words (i.e. 16 bytes) minimum IIRC, what about 16 bytes ? That would give us at least 4 new members for the future ?
Quoted 5 lines
That's sounding like an awfully small number if we're trying to be infititely future proof (obviously the default value for that is 640k!). We'd also need to go through and give *all* the structures padding. How about just adding length fields instead with a rule that if the structure is bigger than you know about just ignore anything at the end?
In theory, having only "abi" field should be enough, as we can know the size predefined for each ABI version. But I agree that it'd be friendlier for a parser if the header itself declares its size, e.g. via a header_size field or embedding the size into some check field like ioctl.
Takashi
Mark Brown
maintainerQuoted 8 lines · Takashi Iwai
Quoted 5 lines · Mark Brown
That's sounding like an awfully small number if we're trying to be infititely future proof (obviously the default value for that is 640k!). We'd also need to go through and give *all* the structures padding. How about just adding length fields instead with a rule that if the structure is bigger than you know about just ignore anything at the end?
Quoted 5 lines
In theory, having only "abi" field should be enough, as we can know the size predefined for each ABI version. But I agree that it'd be friendlier for a parser if the header itself declares its size, e.g. via a
header_sizefield or embedding the size into some check field like ioctl.
The trouble with the ABI version information is that it tells new kernels how to handle old tables but old kernels will have no idea what to do with new firmwares.
Quoted 15 lines · Mark Brown
Quoted 8 lines · Takashi Iwai
Quoted 5 lines · Mark Brown
That's sounding like an awfully small number if we're trying to be infititely future proof (obviously the default value for that is 640k!). We'd also need to go through and give *all* the structures padding. How about just adding length fields instead with a rule that if the structure is bigger than you know about just ignore anything at the end?
Quoted 5 lines
In theory, having only "abi" field should be enough, as we can know the size predefined for each ABI version. But I agree that it'd be friendlier for a parser if the header itself declares its size, e.g. via a
header_sizefield or embedding the size into some check field like ioctl.
Quoted 3 lines
The trouble with the ABI version information is that it tells new kernels how to handle old tables but old kernels will have no idea what to do with new firmwares.
What I did for the SigmaDSP firmware format (which can hopefully be superseded by this) is to have a header which a block type and the block length for each block for exactly this reason. It allows fully backward and forward compatibility between kernel versions and does not require a change in the ABI each time a new type of block is added. It also keeps the parser simple since it does not have to know the size and also makes support for vendor blocks quite easy, since the processing of those can be offloaded to some vendor callbacks without the core having to be informed what the content or size of those vendor blocks is.
- Lars
Quoted 13 lines · Liam Girdwood
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.
Quoted 7 lines
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.
Signed-off-by Liam Girdwood <[email protected]>
I'm a bit concerned with how much ASoC internals this makes ABI, set in stone forever. Not all our internal abstractions are that great and exporting them sets them in stone forever.
[...]
Quoted 60 lines
include/uapi/sound/asoc.h new file +54
-0@@ -0,0 +1,420 @@ +/* +* uapi/sound/asoc.h -- ALSA SoC Firmware Controls and DAPM +* +* Copyright (C) 2012 Texas Instruments Inc. +* Copyright (C) 2015 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Simple file API to load FW that includes mixers, coefficients, DAPM graphs, +* algorithms, equalisers, DAIs, widgets etc. +*/ + +#ifndef __LINUX_UAPI_SND_ASOC_H +#define __LINUX_UAPI_SND_ASOC_H + +#include <linux/types.h> +#include <sound/asound.h> + +/* +* Numeric IDs for stock mixer types that are used to map and enumerate FW +* based mixers. +*/ +#define SOC_CONTROL_ID_PUT (p) ((p & 0xff) << 16) +#define SOC_CONTROL_ID_GET (g) ((g & 0xff) << 8) +#define SOC_CONTROL_ID_INFO (i) ((i & 0xff) << 0) +#define SOC_CONTROL_ID (g, p, i) \ + (SOC_CONTROL_ID_PUT(p) | SOC_CONTROL_ID_GET(g) |\ + SOC_CONTROL_ID_INFO(i)) + +#define SOC_CONTROL_GET_ID_PUT (id) ((id & 0xff0000) >> 16) +#define SOC_CONTROL_GET_ID_GET (id) ((id & 0x00ff00) >> 8) +#define SOC_CONTROL_GET_ID_INFO (id) ((id & 0x0000ff) >> 0) + +/* individual kcontrol info types - can be mixed with other types */ +#define SOC_CONTROL_TYPE_EXT 0/* driver defined */ +#define SOC_CONTROL_TYPE_VOLSW 1 +#define SOC_CONTROL_TYPE_VOLSW_SX 2 +#define SOC_CONTROL_TYPE_VOLSW_S8 3 +#define SOC_CONTROL_TYPE_VOLSW_XR_SX 4 +#define SOC_CONTROL_TYPE_ENUM 6 +#define SOC_CONTROL_TYPE_ENUM_EXT 7 +#define SOC_CONTROL_TYPE_BYTES 8 +#define SOC_CONTROL_TYPE_BOOL_EXT 9 +#define SOC_CONTROL_TYPE_ENUM_VALUE 10 +#define SOC_CONTROL_TYPE_RANGE 11 +#define SOC_CONTROL_TYPE_STROBE 12 +#define SOC_CONTROL_TYPE_BYTES_EXT 13 +#define SOC_CONTROL_TYPE_VOLSW_EXT 14 + +/* convenience macros for compound control type mappings */ +#define SOC_CONTROL_IO_VOLSW \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_VOLSW, \
include/uapi/sound/asoc.h line 64
Quoted 10 lines
include/uapi/sound/asoc.h new file +10
-0+ SOC_CONTROL_TYPE_VOLSW, \ + SOC_CONTROL_TYPE_VOLSW) +#define SOC_CONTROL_IO_VOLSW_SX \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_VOLSW_SX, \ + SOC_CONTROL_TYPE_VOLSW_SX, \ + SOC_CONTROL_TYPE_VOLSW) +#define SOC_CONTROL_IO_VOLSW_S8 \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_VOLSW_S8, \ + SOC_CONTROL_TYPE_VOLSW_S8, \ + SOC_CONTROL_TYPE_VOLSW_S8)
S8, is just a special case of the normal VOLSW
Quoted 35 lines
include/uapi/sound/asoc.h new file +35
-0+#define SOC_CONTROL_IO_VOLSW_XR_SX \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_VOLSW_XR_SX, \ + SOC_CONTROL_TYPE_VOLSW_XR_SX, \ + SOC_CONTROL_TYPE_VOLSW_XR_SX) +#define SOC_CONTROL_IO_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_VOLSW) +#define SOC_CONTROL_IO_ENUM \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_ENUM, \ + SOC_CONTROL_TYPE_ENUM, \ + SOC_CONTROL_TYPE_ENUM) +#define SOC_CONTROL_IO_ENUM_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_ENUM_EXT) +#define SOC_CONTROL_IO_BYTES \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_BYTES, \ + SOC_CONTROL_TYPE_BYTES, \ + SOC_CONTROL_TYPE_BYTES) +#define SOC_CONTROL_IO_BOOL_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_BOOL_EXT) +#define SOC_CONTROL_IO_ENUM_VALUE \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_ENUM_VALUE, \ + SOC_CONTROL_TYPE_ENUM_VALUE, \ + SOC_CONTROL_TYPE_ENUM) +#define SOC_CONTROL_IO_RANGE \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_RANGE, \ + SOC_CONTROL_TYPE_RANGE, \ + SOC_CONTROL_TYPE_RANGE) +#define SOC_CONTROL_IO_STROBE \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_STROBE, \ + SOC_CONTROL_TYPE_STROBE, \
include/uapi/sound/asoc.h line 109
Quoted 10 lines
include/uapi/sound/asoc.h new file +10
-0+ SOC_CONTROL_TYPE_STROBE) +#define SOC_CONTROL_IO_BYTES_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_BYTES_EXT) +#define SOC_CONTROL_IO_VOLSW_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_VOLSW) +
How exactly are the _EXT controls going to work? They need callbacks for reading and writing the control state.
[...]
Quoted 22 lines
include/uapi/sound/asoc.h new file +22
-0+/* dapm widget types */ +enum snd_soc_dapm_type { + snd_soc_dapm_input =0 ,/* input pin */ + snd_soc_dapm_output,/* output pin */ + snd_soc_dapm_mux,/* selects 1 analog signal from many inputs */ + snd_soc_dapm_mixer,/* mixes several analog signals together */ + snd_soc_dapm_mixer_named_ctl,/* mixer with named controls */ + snd_soc_dapm_pga,/* programmable gain/attenuation (volume) */ + snd_soc_dapm_out_drv,/* output driver */ + snd_soc_dapm_adc,/* analog to digital converter */ + snd_soc_dapm_dac,/* digital to analog converter */ + snd_soc_dapm_micbias,/* microphone bias (power) */ + snd_soc_dapm_mic,/* microphone */ + snd_soc_dapm_hp,/* headphones */ + snd_soc_dapm_spk,/* speaker */ + snd_soc_dapm_line,/* line input/output */ + snd_soc_dapm_switch,/* analog switch */ + snd_soc_dapm_vmid,/* codec bias/vmid - to minimise pops */ + snd_soc_dapm_pre,/* machine specific pre widget - exec first */ + snd_soc_dapm_post,/* machine specific post widget - exec last */ + snd_soc_dapm_supply,/* power/clock supply */ + snd_soc_dapm_regulator_supply,/* external regulator */
include/uapi/sound/asoc.h line 175
Quoted 10 lines
include/uapi/sound/asoc.h new file +10
-0+ snd_soc_dapm_clock_supply,/* external clock */ + snd_soc_dapm_aif_in,/* audio interface input */ + snd_soc_dapm_aif_out,/* audio interface output */ + snd_soc_dapm_siggen,/* signal generator */ + snd_soc_dapm_dai_in,/* link to DAI structure */ + snd_soc_dapm_dai_out, + snd_soc_dapm_dai_link,/* link between two DAI structures */ + snd_soc_dapm_kcontrol, /* Auto-disabled kcontrol */ +}; +
This is leaking to much internals in my opinion. Some of those are only meant to be used by the DAPM core, some of those only work if they have proper callbacks specified, some of them are deprecated. Exporting all of them makes them ABI, impossible to ever modify or remove. In my opinion we should limit this to the types of widgets that make sense to be used in a firmware.
[...]
At Tue, 21 Apr 2015 17:35:02 +0100,
Quoted 16 lines · Mark Brown
Quoted 8 lines · Takashi Iwai
Quoted 5 lines · Mark Brown
That's sounding like an awfully small number if we're trying to be infititely future proof (obviously the default value for that is 640k!). We'd also need to go through and give *all* the structures padding. How about just adding length fields instead with a rule that if the structure is bigger than you know about just ignore anything at the end?
Quoted 5 lines
In theory, having only "abi" field should be enough, as we can know the size predefined for each ABI version. But I agree that it'd be friendlier for a parser if the header itself declares its size, e.g. via a
header_sizefield or embedding the size into some check field like ioctl.
Quoted 3 lines
The trouble with the ABI version information is that it tells new kernels how to handle old tables but old kernels will have no idea what to do with new firmwares.
If the given data is incompatible, kernel can't handle it anyway. So, ideally speaking, the ABI version should contain two things: the binary compatibility as a major version and the detailed data definition as a minor version. If the major version is same, an old kernel can assume that the data has the same size and read it as is. If it's greater than the supported major version, the kernel should return the error.
But, again, I'm for having the header size, too. I just explain here how abi version field could be used in theory.
Takashi
Quoted 20 lines · Lars-Peter Clausen
Quoted 19 lines · Liam Girdwood
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.
Quoted 5 lines
Quoted 1 line
Signed-off-by Liam Girdwood <[email protected]>I'm a bit concerned with how much ASoC internals this makes ABI, set in stone forever. Not all our internal abstractions are that great and exporting them sets them in stone forever.
You should have seen V1 about 2 years ago ... many internal structures were exported at that time !
Quoted 66 lines
[...]
Quoted 64 lines
include/uapi/sound/asoc.h new file +58
-0@@ -0,0 +1,420 @@ +/* +* uapi/sound/asoc.h -- ALSA SoC Firmware Controls and DAPM +* +* Copyright (C) 2012 Texas Instruments Inc. +* Copyright (C) 2015 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Simple file API to load FW that includes mixers, coefficients, DAPM graphs, +* algorithms, equalisers, DAIs, widgets etc. +*/ + +#ifndef __LINUX_UAPI_SND_ASOC_H +#define __LINUX_UAPI_SND_ASOC_H + +#include <linux/types.h> +#include <sound/asound.h> + +/* +* Numeric IDs for stock mixer types that are used to map and enumerate FW +* based mixers. +*/ +#define SOC_CONTROL_ID_PUT (p) ((p & 0xff) << 16) +#define SOC_CONTROL_ID_GET (g) ((g & 0xff) << 8) +#define SOC_CONTROL_ID_INFO (i) ((i & 0xff) << 0) +#define SOC_CONTROL_ID (g, p, i) \ + (SOC_CONTROL_ID_PUT(p) | SOC_CONTROL_ID_GET(g) |\ + SOC_CONTROL_ID_INFO(i)) + +#define SOC_CONTROL_GET_ID_PUT (id) ((id & 0xff0000) >> 16) +#define SOC_CONTROL_GET_ID_GET (id) ((id & 0x00ff00) >> 8) +#define SOC_CONTROL_GET_ID_INFO (id) ((id & 0x0000ff) >> 0) + +/* individual kcontrol info types - can be mixed with other types */ +#define SOC_CONTROL_TYPE_EXT 0/* driver defined */ +#define SOC_CONTROL_TYPE_VOLSW 1 +#define SOC_CONTROL_TYPE_VOLSW_SX 2 +#define SOC_CONTROL_TYPE_VOLSW_S8 3 +#define SOC_CONTROL_TYPE_VOLSW_XR_SX 4 +#define SOC_CONTROL_TYPE_ENUM 6 +#define SOC_CONTROL_TYPE_ENUM_EXT 7 +#define SOC_CONTROL_TYPE_BYTES 8 +#define SOC_CONTROL_TYPE_BOOL_EXT 9 +#define SOC_CONTROL_TYPE_ENUM_VALUE 10 +#define SOC_CONTROL_TYPE_RANGE 11 +#define SOC_CONTROL_TYPE_STROBE 12 +#define SOC_CONTROL_TYPE_BYTES_EXT 13 +#define SOC_CONTROL_TYPE_VOLSW_EXT 14 + +/* convenience macros for compound control type mappings */ +#define SOC_CONTROL_IO_VOLSW \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_VOLSW, \ + SOC_CONTROL_TYPE_VOLSW, \ + SOC_CONTROL_TYPE_VOLSW) +#define SOC_CONTROL_IO_VOLSW_SX \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_VOLSW_SX, \
Quoted 8 lines
include/uapi/sound/asoc.h line 64
Quoted 6 lines
include/uapi/sound/asoc.h new file +6
-0+ SOC_CONTROL_TYPE_VOLSW_SX, \ + SOC_CONTROL_TYPE_VOLSW) +#define SOC_CONTROL_IO_VOLSW_S8 \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_VOLSW_S8, \ + SOC_CONTROL_TYPE_VOLSW_S8, \ + SOC_CONTROL_TYPE_VOLSW_S8)S8, is just a special case of the normal VOLSW
These macros are just mirroring the kernel versions for completeness, I could remove it but that could mean confusion for anyone expecting it to be present.
Quoted 41 lines
Quoted 41 lines
include/uapi/sound/asoc.h new file +40
-0+#define SOC_CONTROL_IO_VOLSW_XR_SX \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_VOLSW_XR_SX, \ + SOC_CONTROL_TYPE_VOLSW_XR_SX, \ + SOC_CONTROL_TYPE_VOLSW_XR_SX) +#define SOC_CONTROL_IO_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_VOLSW) +#define SOC_CONTROL_IO_ENUM \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_ENUM, \ + SOC_CONTROL_TYPE_ENUM, \ + SOC_CONTROL_TYPE_ENUM) +#define SOC_CONTROL_IO_ENUM_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_ENUM_EXT) +#define SOC_CONTROL_IO_BYTES \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_BYTES, \ + SOC_CONTROL_TYPE_BYTES, \ + SOC_CONTROL_TYPE_BYTES) +#define SOC_CONTROL_IO_BOOL_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_BOOL_EXT) +#define SOC_CONTROL_IO_ENUM_VALUE \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_ENUM_VALUE, \ + SOC_CONTROL_TYPE_ENUM_VALUE, \ + SOC_CONTROL_TYPE_ENUM) +#define SOC_CONTROL_IO_RANGE \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_RANGE, \ + SOC_CONTROL_TYPE_RANGE, \ + SOC_CONTROL_TYPE_RANGE) +#define SOC_CONTROL_IO_STROBE \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_STROBE, \ + SOC_CONTROL_TYPE_STROBE, \ + SOC_CONTROL_TYPE_STROBE) +#define SOC_CONTROL_IO_BYTES_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_BYTES_EXT)
Quoted 8 lines
include/uapi/sound/asoc.h line 109
Quoted 5 lines
include/uapi/sound/asoc.h new file +5
-0+#define SOC_CONTROL_IO_VOLSW_EXT \ + SOC_CONTROL_ID(SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_EXT, \ + SOC_CONTROL_TYPE_VOLSW) +How exactly are the
_EXTcontrols going to work? They need callbacks for reading and writing the control state.
The info/get/put methods can be bound to component driver callback using ID numbers.
Quoted 33 lines
[...]
Quoted 31 lines
include/uapi/sound/asoc.h new file +31
-0+/* dapm widget types */ +enum snd_soc_dapm_type { + snd_soc_dapm_input =0 ,/* input pin */ + snd_soc_dapm_output,/* output pin */ + snd_soc_dapm_mux,/* selects 1 analog signal from many inputs */ + snd_soc_dapm_mixer,/* mixes several analog signals together */ + snd_soc_dapm_mixer_named_ctl,/* mixer with named controls */ + snd_soc_dapm_pga,/* programmable gain/attenuation (volume) */ + snd_soc_dapm_out_drv,/* output driver */ + snd_soc_dapm_adc,/* analog to digital converter */ + snd_soc_dapm_dac,/* digital to analog converter */ + snd_soc_dapm_micbias,/* microphone bias (power) */ + snd_soc_dapm_mic,/* microphone */ + snd_soc_dapm_hp,/* headphones */ + snd_soc_dapm_spk,/* speaker */ + snd_soc_dapm_line,/* line input/output */ + snd_soc_dapm_switch,/* analog switch */ + snd_soc_dapm_vmid,/* codec bias/vmid - to minimise pops */ + snd_soc_dapm_pre,/* machine specific pre widget - exec first */ + snd_soc_dapm_post,/* machine specific post widget - exec last */ + snd_soc_dapm_supply,/* power/clock supply */ + snd_soc_dapm_regulator_supply,/* external regulator */ + snd_soc_dapm_clock_supply,/* external clock */ + snd_soc_dapm_aif_in,/* audio interface input */ + snd_soc_dapm_aif_out,/* audio interface output */ + snd_soc_dapm_siggen,/* signal generator */ + snd_soc_dapm_dai_in,/* link to DAI structure */ + snd_soc_dapm_dai_out, + snd_soc_dapm_dai_link,/* link between two DAI structures */ + snd_soc_dapm_kcontrol,/* Auto-disabled kcontrol */ +};
Quoted 8 lines
Quoted 1 line
+
This is leaking to much internals in my opinion. Some of those are only meant to be used by the DAPM core, some of those only work if they have proper callbacks specified, some of them are deprecated. Exporting all of them makes them ABI, impossible to ever modify or remove. In my opinion we should limit this to the types of widgets that make sense to be used in a firmware.
The alternative here is to map them to macro ID numbers which I dont mind doing. Btw, we should really mark the deprecated widget types so they are not used in new drivers and then can eventually be removed.
Liam
Quoted 2 lines
[...]
Mark Brown
maintainerQuoted 6 lines · Lars-Peter Clausen
Quoted 3 lines · Mark Brown
The trouble with the ABI version information is that it tells new kernels how to handle old tables but old kernels will have no idea what to do with new firmwares.
Quoted 9 lines
What I did for the SigmaDSP firmware format (which can hopefully be superseded by this) is to have a header which a block type and the block length for each block for exactly this reason. It allows fully backward and forward compatibility between kernel versions and does not require a change in the ABI each time a new type of block is added. It also keeps the parser simple since it does not have to know the size and also makes support for vendor blocks quite easy, since the processing of those can be offloaded to some vendor callbacks without the core having to be informed what the content or size of those vendor blocks is.
Yes, that's what the ex-Wolfson stuff does too (it also has ABI versioning but most things shouldn't need it).
Quoted 17 lines · Mark Brown
Quoted 6 lines · Lars-Peter Clausen
Quoted 3 lines · Mark Brown
The trouble with the ABI version information is that it tells new kernels how to handle old tables but old kernels will have no idea what to do with new firmwares.
Quoted 9 lines
What I did for the SigmaDSP firmware format (which can hopefully be superseded by this) is to have a header which a block type and the block length for each block for exactly this reason. It allows fully backward and forward compatibility between kernel versions and does not require a change in the ABI each time a new type of block is added. It also keeps the parser simple since it does not have to know the size and also makes support for vendor blocks quite easy, since the processing of those can be offloaded to some vendor callbacks without the core having to be informed what the content or size of those vendor blocks is.
Quoted 2 lines
Yes, that's what the ex-Wolfson stuff does too (it also has ABI versioning but most things shouldn't need it).
Ok, I'll add in the block length for V2. Travelling atm so V2 will probably arrive sometime next week.
Liam