Skip to contentSkip to conversation

ASoC: topology: Add support for FE DAI & DAI links

PATCH Superseded [email protected] 5 participants 15 messages Jan 15, 2016 – Feb 16, 2016

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover ASoC: topology: Add support for FE DAI & DAI links

From: Mengdong Lin <[email protected]>

This series allows topology to create FE DAI and DAI links from the PCM topology objects defined by the user space.

History:
v2: Remove first 2 patches in v1 that were accepted.
Add Ack by Takashi to patch 'ALSA: pcm: Add snd_pcm_rate_range_to_bits()' and add his comments on the function's assumption to c file.

Mengdong Lin (3):
ALSA: pcm: Add snd_pcm_rate_range_to_bits()
ASoC: topology: Add FE DAIs dynamically
ASoC: topology: Add FE DAI links dynamically

 include/sound/pcm.h          |   2 +
 include/sound/soc-topology.h |  21 +++--
 include/sound/soc.h          |   2 +-
 sound/core/pcm_misc.c        |  30 +++++++
 sound/soc/soc-topology.c     | 195 ++++++++++++++++++++++++++++++++++---------
 5 files changed, 197 insertions(+), 53 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH v2 1/3 ALSA: pcm: Add snd_pcm_rate_range_to_bits()

From: Mengdong Lin <[email protected]>

This helper function can convert a given sample rate range to SNDRV_PCM_RATE_xxx bits.

include/sound/pcm.h +2 -0
index b0be092..af1fb37 100644
@@ -1093,6 +1093,8 @@ unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
 unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
 unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
 					 unsigned int rates_b);
+unsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min,
+					unsigned int rate_max);
 
 /**
  * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer
sound/core/pcm_misc.c +30 -0
index ebe8444..53dc373 100644
@@ -565,3 +565,33 @@ unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
 	return rates_a & rates_b;
 }
 EXPORT_SYMBOL_GPL(snd_pcm_rate_mask_intersect);
+
+/**
+ * snd_pcm_rate_range_to_bits - converts rate range to SNDRV_PCM_RATE_xxx bit
+ * @rate_min: the minimum sample rate
+ * @rate_max: the maximum sample rate
+ *
+ * This function has an implicit assumption: the rates in the given range have
+ * only the pre-defined rates like 44100 or 16000.
+ *
+ * Return: The SNDRV_PCM_RATE_xxx flag that corresponds to the given rate range,
+ * or SNDRV_PCM_RATE_KNOT for an unknown range.
+ */
+unsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min,
+	unsigned int rate_max)
+{
+	unsigned int rates = 0;
+	int i;
+
+	for (i = 0; i < snd_pcm_known_rates.count; i++) {
+		if (snd_pcm_known_rates.list[i] >= rate_min
+			&& snd_pcm_known_rates.list[i] <= rate_max)
+			rates |= 1 << i;
+	}
+
+	if (!rates)
+		rates = SNDRV_PCM_RATE_KNOT;
+
+	return rates;
+}
+EXPORT_SYMBOL_GPL(snd_pcm_rate_range_to_bits);
Signature · 1 line
2.5.0
maintainer
#2 lore raw

Applied "ALSA: pcm: Add snd_pcm_rate_range_to_bits()" to the asoc tree

The patch

ALSA: pcm: Add snd_pcm_rate_range_to_bits()

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 3bdff244a2bcbde37ec33bf3cdde4638049c6c38 Mon Sep 17 00:00:00 2001

From: Mengdong Lin <[email protected]>
Date: Fri, 15 Jan 2016 16:13:10 +0800
Subject: [PATCH] ALSA: pcm: Add snd_pcm_rate_range_to_bits()

This helper function can convert a given sample rate range to SNDRV_PCM_RATE_xxx bits.

---
 include/sound/pcm.h   |  2 ++
 sound/core/pcm_misc.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
include/sound/pcm.h +2 -0
index b0be09279943..af1fb37c6b26 100644
@@ -1093,6 +1093,8 @@ unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
 unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
 unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
 					 unsigned int rates_b);
+unsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min,
+					unsigned int rate_max);
 
 /**
  * snd_pcm_set_runtime_buffer - Set the PCM runtime buffer
sound/core/pcm_misc.c +30 -0
index ebe8444de6c6..53dc37357bca 100644
@@ -565,3 +565,33 @@ unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
 	return rates_a & rates_b;
 }
 EXPORT_SYMBOL_GPL(snd_pcm_rate_mask_intersect);
+
+/**
+ * snd_pcm_rate_range_to_bits - converts rate range to SNDRV_PCM_RATE_xxx bit
+ * @rate_min: the minimum sample rate
+ * @rate_max: the maximum sample rate
+ *
+ * This function has an implicit assumption: the rates in the given range have
+ * only the pre-defined rates like 44100 or 16000.
+ *
+ * Return: The SNDRV_PCM_RATE_xxx flag that corresponds to the given rate range,
+ * or SNDRV_PCM_RATE_KNOT for an unknown range.
+ */
+unsigned int snd_pcm_rate_range_to_bits(unsigned int rate_min,
+	unsigned int rate_max)
+{
+	unsigned int rates = 0;
+	int i;
+
+	for (i = 0; i < snd_pcm_known_rates.count; i++) {
+		if (snd_pcm_known_rates.list[i] >= rate_min
+			&& snd_pcm_known_rates.list[i] <= rate_max)
+			rates |= 1 << i;
+	}
+
+	if (!rates)
+		rates = SNDRV_PCM_RATE_KNOT;
+
+	return rates;
+}
+EXPORT_SYMBOL_GPL(snd_pcm_rate_range_to_bits);
Signature · 1 line
2.7.0.rc3
#3 lore raw

PATCH v2 2/3 ASoC: topology: Add FE DAIs dynamically

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Topology will create FE DAIs dynamically from the PCM objects, and register them to the component.

A PCM topoplogy object describes a FE DAI and DAI link. Later patch will add FE DAI links as well.

Change tplg load ops for DAI:
- Only process a DAI.
- Pass the DAI driver pointer to the component driver for extra initialization.

include/sound/soc-topology.h +4 -11
index 73713e6..ec562d0 100644
@@ -56,12 +56,6 @@ struct snd_soc_dobj_widget {
 	unsigned int kcontrol_enum:1;	/* this widget is an enum kcontrol */
 };
 
-/* dynamic PCM DAI object */
-struct snd_soc_dobj_pcm_dai {
-	struct snd_soc_tplg_pcm_dai *pd;
-	unsigned int count;
-};
-
 /* generic dynamic object - all dynamic objects belong to this struct */
 struct snd_soc_dobj {
 	enum snd_soc_dobj_type type;
@@ -71,7 +65,6 @@ struct snd_soc_dobj {
 	union {
 		struct snd_soc_dobj_control control;
 		struct snd_soc_dobj_widget widget;
-		struct snd_soc_dobj_pcm_dai pcm_dai;
 	};
 	void *private; /* core does not touch this */
 };
@@ -126,10 +119,10 @@ struct snd_soc_tplg_ops {
 	int (*widget_unload)(struct snd_soc_component *,
 		struct snd_soc_dobj *);
 
-	/* FE - used for any driver specific init */
-	int (*pcm_dai_load)(struct snd_soc_component *,
-		struct snd_soc_tplg_pcm_dai *pcm_dai, int num_fe);
-	int (*pcm_dai_unload)(struct snd_soc_component *,
+	/* FE DAI - used for any driver specific init */
+	int (*dai_load)(struct snd_soc_component *,
+		struct snd_soc_dai_driver *dai_drv);
+	int (*dai_unload)(struct snd_soc_component *,
 		struct snd_soc_dobj *);
 
 	/* callback to handle vendor bespoke data */
include/sound/soc.h +1 -1
index 1811e73..100bb0a 100644
@@ -27,7 +27,6 @@
 #include <sound/compress_driver.h>
 #include <sound/control.h>
 #include <sound/ac97_codec.h>
-#include <sound/soc-topology.h>
 
 /*
  * Convenience kcontrol builders
@@ -404,6 +403,7 @@ struct snd_soc_jack_zone;
 struct snd_soc_jack_pin;
 #include <sound/soc-dapm.h>
 #include <sound/soc-dpcm.h>
+#include <sound/soc-topology.h>
 
 struct snd_soc_jack_gpio;
 
sound/soc/soc-topology.c +87 -42

184 lines not on this page · raw message

Signature · 1 line
2.5.0
#4 lore raw

Re: [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically

On 01/15/2016 09:13 AM, [email protected] wrote:
[...]

Review

Quoted 2 lines
(quoted diff) +2 -0
+		stream->rates = snd_pcm_rate_range_to_bits(caps->rate_min,
+							caps->rate_max);

How about just setting stream->rate_min and stream->rate_max?

- Lars

maintainer
#5 lore raw

Re: [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically

Quoted 6 lines · Lars-Peter Clausen

On 01/15/2016 09:13 AM, [email protected] wrote:
[...]

Review

Quoted 2 lines
(quoted diff) +2 -0
+		stream->rates = snd_pcm_rate_range_to_bits(caps->rate_min,
+							caps->rate_max);

How about just setting stream->rate_min and stream->rate_max?

I'll apply this but please send a followup patch fixing this.

#6 lore raw

Re: [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically

Quoted 10 lines · Mark Brown
Quoted 6 lines · Lars-Peter Clausen

On 01/15/2016 09:13 AM, [email protected] wrote:
[...]

Review

Quoted 2 lines
(quoted diff) +2 -0
+		stream->rates = snd_pcm_rate_range_to_bits(caps->rate_min,
+							caps->rate_max);

How about just setting stream->rate_min and stream->rate_max?

I'll apply this but please send a followup patch fixing this.

I've sent out a patch to fix this:
[PATCH] ASoC: topology: Fix setting of stream rates, rate_min and rate_max

Please review and overlook my v3 series which just merged this fix with the applied patches.

Thanks
Mengdong

#7 lore raw

Re: [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically

In reply to Lars-Peter Clausen
Quoted 8 lines · Lars-Peter Clausen

On 01/15/2016 09:13 AM, [email protected] wrote:
[...]

Review

Quoted 2 lines
(quoted diff) +2 -0
+		stream->rates = snd_pcm_rate_range_to_bits(caps->rate_min,
+							caps->rate_max);

How about just setting stream->rate_min and stream->rate_max?

- Lars

Yes, we can directly set the stream's rates, rate_min and rate_max from the topology caps. I revised this as you suggested in v3.

Sorry for the late reply. I'm just back from a two weeks CNY holiday.

Thanks
Mengdong

#8 lore raw

PATCH v2 3/3 ASoC: topology: Add FE DAI links dynamically

In reply to [email protected]

From: Mengdong Lin <[email protected]>

Topology will also create FE DAI links dynamically from the PCM objects. These links will be removed when the component is removed and its topology info is unloaded.

The component driver can implement link_load/unload ops for extra intialization (e.g. error check) and destruction.

include/sound/soc-topology.h +6 -0
index ec562d0..d318fe4 100644
@@ -125,6 +125,12 @@ struct snd_soc_tplg_ops {
 	int (*dai_unload)(struct snd_soc_component *,
 		struct snd_soc_dobj *);
 
+	/* DAI link - used for any driver specific init */
+	int (*link_load)(struct snd_soc_component *,
+		struct snd_soc_dai_link *link);
+	int (*link_unload)(struct snd_soc_component *,
+		struct snd_soc_dobj *);
+
 	/* callback to handle vendor bespoke data */
 	int (*vendor_load)(struct snd_soc_component *,
 		struct snd_soc_tplg_hdr *);
sound/soc/soc-topology.c +69 -1

97 lines not on this page · raw message

Signature · 1 line
2.5.0
Acked-by on the v2 series
#9 lore raw
In reply to [email protected]
Quoted 10 lines · On Fri, 2016-01-15 at 16:11 +0800, [email protected] wrote:

From: Mengdong Lin <[email protected]>

This series allows topology to create FE DAI and DAI links from the PCM topology objects defined by the user space.

History:
v2: Remove first 2 patches in v1 that were accepted.
Add Ack by Takashi to patch 'ALSA: pcm: Add snd_pcm_rate_range_to_bits()' and add his comments on the function's assumption to c file.

Quoted 5 lines

Mengdong Lin (3):
ALSA: pcm: Add snd_pcm_rate_range_to_bits()
ASoC: topology: Add FE DAIs dynamically
ASoC: topology: Add FE DAI links dynamically

Mengdong, it might be easier to split this patch into 1/3 and 2,3/3 since 1/3 will be in Takashi's tree, but then that might not be needed it Takashi and Mark agree.

Liam

maintainer
#10 lore raw
Quoted 3 lines · Liam Girdwood

Mengdong, it might be easier to split this patch into 1/3 and 2,3/3 since 1/3 will be in Takashi's tree, but then that might not be needed it Takashi and Mark agree.

They'll need to all end up in one tree at some point since at least one of the ASoC patches depends on the ALSA core patch. Usually we do this by having me apply things (IIRC Takashi has already acked the ALSA patch).

#11 lore raw
Quoted 11 lines · Mark Brown
Quoted 3 lines · Liam Girdwood

Mengdong, it might be easier to split this patch into 1/3 and 2,3/3 since 1/3 will be in Takashi's tree, but then that might not be needed it Takashi and Mark agree.

They'll need to all end up in one tree at some point since at least one of the ASoC patches depends on the ALSA core patch. Usually we do this by having me apply things (IIRC Takashi has already acked the ALSA patch).

Yep, my previous ack is found at msg id <[email protected]>

Takashi

#12 lore raw

Thanks for your comments, Takashi!

Hi Mark,

Could you help to review the other 2 patches when convenient?

Thanks
Mengdong

Quoted 23 lines · Takashi Iwai
Quoted 11 lines · Mark Brown
Quoted 3 lines · Liam Girdwood

Mengdong, it might be easier to split this patch into 1/3 and 2,3/3 since 1/3 will be in Takashi's tree, but then that might not be needed it Takashi and Mark agree.

They'll need to all end up in one tree at some point since at least one of the ASoC patches depends on the ALSA core patch. Usually we do this by having me apply things (IIRC Takashi has already acked the ALSA patch).

Yep, my previous ack is found at msg id <[email protected]>

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#13 lore raw
Quoted 1 line · Mengdong Lin

Could you help to review the other 2 patches when convenient?

Please allow some time for review and bear in mind that we only just came out of the merge window.

maintainer
#14 lore raw
In reply to [email protected]
Quoted 2 lines · On Fri, Jan 15, 2016 at 04:11:49PM +0800, [email protected] wrote:

This series allows topology to create FE DAI and DAI links from the PCM topology objects defined by the user space.

Of course that'll be kind of fun at the minute since we don't currently have a userspace ABI for topologies... 8c90503bf246beb (ASoC: topology:
Disable use from userspace) is *still* in place since v4.2 with no move to actually finalize the ABI.