Skip to contentSkip to conversation

ASoC: topology: Add topology UAPI header

PATCH Applied Liam Girdwood 3 participants 6 messages May 29, 2015 – Jun 3, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 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
index 1065095..6f440b2 100644
@@ -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
#1 lore raw

PATCH v3 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     | 1826 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 2012 insertions(+)
 create mode 100644 include/sound/soc-topology.h
 create mode 100644 sound/soc/soc-topology.c
include/sound/soc-dapm.h +2 -0
index 6f440b2..940dfad 100644
@@ -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
index f6226914..5b92662 100644
@@ -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
@@ -767,6 +768,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
@@ -1111,6 +1115,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;
@@ -1170,6 +1177,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 {
@@ -1180,6 +1188,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);
@@ -1200,6 +1210,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
index 974ba70..c2ef1ec 100644
@@ -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
index 7d028e8..ce5e4cca 100644
@@ -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 +1826 -0

1,826 lines not on this page · raw message

Signature · 1 line
2.1.4
#2 lore raw

PATCH v3 3/3 ALSA: topology: Export ID types for TLV controls.

In reply to Liam Girdwood

Make sure userspace can define TLV controls for topology using the correct type numbers and channel mappings.

---
 include/sound/tlv.h      | 15 +--------------
 include/uapi/sound/tlv.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 14 deletions(-)
 create mode 100644 include/uapi/sound/tlv.h
include/sound/tlv.h +1 -14
index e11e179..df97d19 100644
@@ -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__
@@ -90,12 +85,4 @@
 
 #define TLV_DB_GAIN_MUTE	-9999999
 
-/*
- * channel-mapping TLV items
- *  TLV length must match with num_channels
- */
-#define SNDRV_CTL_TLVT_CHMAP_FIXED	0x101	/* fixed channel position */
-#define SNDRV_CTL_TLVT_CHMAP_VAR	0x102	/* channels freely swappable */
-#define SNDRV_CTL_TLVT_CHMAP_PAIRED	0x103	/* pair-wise swappable */
-
 #endif /* __SOUND_TLV_H */
include/uapi/sound/tlv.h new file +31 -0
new file mode 100644
index 0000000..ffc4f20
@@ -0,0 +1,31 @@
+/*
+ *   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 */
+
+/*
+ * channel-mapping TLV items
+ *  TLV length must match with num_channels
+ */
+#define SNDRV_CTL_TLVT_CHMAP_FIXED	0x101	/* fixed channel position */
+#define SNDRV_CTL_TLVT_CHMAP_VAR	0x102	/* channels freely swappable */
+#define SNDRV_CTL_TLVT_CHMAP_PAIRED	0x103	/* pair-wise swappable */
+
+#endif
Signature · 1 line
2.1.4
maintainer
#3 lore raw

Re: [PATCH v3 3/3] ALSA: topology: Export ID types for TLV controls.

Quoted 2 lines · Liam Girdwood

Make sure userspace can define TLV controls for topology using the correct type numbers and channel mappings.

Takashi, are you OK with this move?

Acked-by
#4 lore raw

Re: [PATCH v3 3/3] ALSA: topology: Export ID types for TLV controls.

At Wed, 3 Jun 2015 19:23:00 +0100,

Quoted 6 lines · Mark Brown
Quoted 2 lines · Liam Girdwood

Make sure userspace can define TLV controls for topology using the correct type numbers and channel mappings.

Takashi, are you OK with this move?

Takashi

maintainer Applied
#5 lore raw
In reply to Liam Girdwood
Quoted 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.

Applied all, thanks. I had to fix up a conflict with the DAPM topic, please check but it was trivial.