All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links
@ 2016-01-15  8:11 mengdong.lin
  2016-01-15  8:13 ` [PATCH v2 1/3] ALSA: pcm: Add snd_pcm_rate_range_to_bits() mengdong.lin
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: mengdong.lin @ 2016-01-15  8:11 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: Mengdong Lin, tiwai, mengdong.lin, liam.r.girdwood, vinod.koul,
	jeeja.kp, subhransu.s.prusty

From: Mengdong Lin <mengdong.lin@linux.intel.com>

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(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 1/3] ALSA: pcm: Add snd_pcm_rate_range_to_bits()
  2016-01-15  8:11 [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links mengdong.lin
@ 2016-01-15  8:13 ` mengdong.lin
  2016-02-05 18:53   ` Applied "ALSA: pcm: Add snd_pcm_rate_range_to_bits()" to the asoc tree Mark Brown
  2016-01-15  8:13 ` [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically mengdong.lin
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: mengdong.lin @ 2016-01-15  8:13 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: Mengdong Lin, tiwai, mengdong.lin, liam.r.girdwood, vinod.koul,
	jeeja.kp, subhransu.s.prusty

From: Mengdong Lin <mengdong.lin@linux.intel.com>

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

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Acked-by: Takashi Iwai <tiwai@suse.de>

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index b0be092..af1fb37 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -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
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index ebe8444..53dc373 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -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);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically
  2016-01-15  8:11 [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links mengdong.lin
  2016-01-15  8:13 ` [PATCH v2 1/3] ALSA: pcm: Add snd_pcm_rate_range_to_bits() mengdong.lin
@ 2016-01-15  8:13 ` mengdong.lin
  2016-01-27  9:56   ` Lars-Peter Clausen
  2016-01-15  8:13 ` [PATCH v2 3/3] ASoC: topology: Add FE DAI links dynamically mengdong.lin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: mengdong.lin @ 2016-01-15  8:13 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: Mengdong Lin, vinod.koul, mengdong.lin, liam.r.girdwood,
	jeeja.kp, subhransu.s.prusty

From: Mengdong Lin <mengdong.lin@linux.intel.com>

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.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/sound/soc-topology.h b/include/sound/soc-topology.h
index 73713e6..ec562d0 100644
--- a/include/sound/soc-topology.h
+++ b/include/sound/soc-topology.h
@@ -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 */
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 1811e73..100bb0a 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -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;
 
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 6963ba2..446ac9a 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -330,12 +330,12 @@ static int soc_tplg_widget_load(struct soc_tplg *tplg,
 	return 0;
 }
 
-/* pass dynamic FEs configurations to component driver */
-static int soc_tplg_pcm_dai_load(struct soc_tplg *tplg,
-	struct snd_soc_tplg_pcm_dai *pcm_dai, int num_pcm_dai)
+/* pass DAI configurations to component driver for extra intialization */
+static int soc_tplg_dai_load(struct soc_tplg *tplg,
+	struct snd_soc_dai_driver *dai_drv)
 {
-	if (tplg->comp && tplg->ops && tplg->ops->pcm_dai_load)
-		return tplg->ops->pcm_dai_load(tplg->comp, pcm_dai, num_pcm_dai);
+	if (tplg->comp && tplg->ops && tplg->ops->dai_load)
+		return tplg->ops->dai_load(tplg->comp, dai_drv);
 
 	return 0;
 }
@@ -495,18 +495,21 @@ static void remove_widget(struct snd_soc_component *comp,
 	/* widget w is freed by soc-dapm.c */
 }
 
-/* remove PCM DAI configurations */
-static void remove_pcm_dai(struct snd_soc_component *comp,
+/* remove DAI configurations */
+static void remove_dai(struct snd_soc_component *comp,
 	struct snd_soc_dobj *dobj, int pass)
 {
+	struct snd_soc_dai_driver *dai_drv =
+		container_of(dobj, struct snd_soc_dai_driver, dobj);
+
 	if (pass != SOC_TPLG_PASS_PCM_DAI)
 		return;
 
-	if (dobj->ops && dobj->ops->pcm_dai_unload)
-		dobj->ops->pcm_dai_unload(comp, dobj);
+	if (dobj->ops && dobj->ops->dai_unload)
+		dobj->ops->dai_unload(comp, dobj);
 
 	list_del(&dobj->list);
-	kfree(dobj);
+	kfree(dai_drv);
 }
 
 /* bind a kcontrol to it's IO handlers */
@@ -1544,18 +1547,79 @@ static int soc_tplg_dapm_complete(struct soc_tplg *tplg)
 	return 0;
 }
 
-static int soc_tplg_pcm_dai_elems_load(struct soc_tplg *tplg,
+static int soc_tplg_dai_create(struct soc_tplg *tplg,
+	struct snd_soc_tplg_pcm *pcm)
+{
+	struct snd_soc_dai_driver *dai_drv;
+	struct snd_soc_pcm_stream *stream;
+	struct snd_soc_tplg_stream_caps *caps;
+	int ret;
+
+	dai_drv = kzalloc(sizeof(struct snd_soc_dai_driver), GFP_KERNEL);
+	if (dai_drv == NULL)
+		return -ENOMEM;
+
+	dai_drv->name = pcm->dai_name;
+	dai_drv->id = pcm->dai_id;
+
+	if (pcm->playback) {
+		stream = &dai_drv->playback;
+		caps = &pcm->caps[SND_SOC_TPLG_STREAM_PLAYBACK];
+
+		stream->stream_name = kstrdup(caps->name, GFP_KERNEL);
+		stream->channels_min = caps->channels_min;
+		stream->channels_max = caps->channels_max;
+		stream->rates = snd_pcm_rate_range_to_bits(caps->rate_min,
+							caps->rate_max);
+		stream->formats = caps->formats;
+	}
+
+	if (pcm->capture) {
+		stream = &dai_drv->capture;
+		caps = &pcm->caps[SND_SOC_TPLG_STREAM_CAPTURE];
+
+		stream->stream_name = kstrdup(caps->name, GFP_KERNEL);
+		stream->channels_min = caps->channels_min;
+		stream->channels_max = caps->channels_max;
+		stream->rates = snd_pcm_rate_range_to_bits(caps->rate_min,
+							caps->rate_max);
+		stream->formats = caps->formats;
+	}
+
+	/* pass control to component driver for optional further init */
+	ret = soc_tplg_dai_load(tplg, dai_drv);
+	if (ret < 0) {
+		dev_err(tplg->comp->dev, "ASoC: DAI loading failed\n");
+		kfree(dai_drv);
+		return ret;
+	}
+
+	dai_drv->dobj.index = tplg->index;
+	dai_drv->dobj.ops = tplg->ops;
+	dai_drv->dobj.type = SND_SOC_DOBJ_PCM;
+	list_add(&dai_drv->dobj.list, &tplg->comp->dobj_list);
+
+	/* register the DAI to the component */
+	return snd_soc_register_dai(tplg->comp, dai_drv);
+}
+
+static int soc_tplg_pcm_create(struct soc_tplg *tplg,
+	struct snd_soc_tplg_pcm *pcm)
+{
+	return soc_tplg_dai_create(tplg, pcm);
+}
+
+static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
 	struct snd_soc_tplg_hdr *hdr)
 {
-	struct snd_soc_tplg_pcm_dai *pcm_dai;
-	struct snd_soc_dobj *dobj;
+	struct snd_soc_tplg_pcm *pcm;
 	int count = hdr->count;
-	int ret;
+	int i;
 
 	if (tplg->pass != SOC_TPLG_PASS_PCM_DAI)
 		return 0;
 
-	pcm_dai = (struct snd_soc_tplg_pcm_dai *)tplg->pos;
+	pcm = (struct snd_soc_tplg_pcm *)tplg->pos;
 
 	if (soc_tplg_check_elem_count(tplg,
 		sizeof(struct snd_soc_tplg_pcm), count,
@@ -1565,31 +1629,16 @@ static int soc_tplg_pcm_dai_elems_load(struct soc_tplg *tplg,
 		return -EINVAL;
 	}
 
+	/* create the FE DAIs and DAI links */
+	for (i = 0; i < count; i++) {
+		soc_tplg_pcm_create(tplg, pcm);
+		pcm++;
+	}
+
 	dev_dbg(tplg->dev, "ASoC: adding %d PCM DAIs\n", count);
 	tplg->pos += sizeof(struct snd_soc_tplg_pcm) * count;
 
-	dobj = kzalloc(sizeof(struct snd_soc_dobj), GFP_KERNEL);
-	if (dobj == NULL)
-		return -ENOMEM;
-
-	/* Call the platform driver call back to register the dais */
-	ret = soc_tplg_pcm_dai_load(tplg, pcm_dai, count);
-	if (ret < 0) {
-		dev_err(tplg->comp->dev, "ASoC: PCM DAI loading failed\n");
-		goto err;
-	}
-
-	dobj->type = get_dobj_type(hdr, NULL);
-	dobj->pcm_dai.count = count;
-	dobj->pcm_dai.pd = pcm_dai;
-	dobj->ops = tplg->ops;
-	dobj->index = tplg->index;
-	list_add(&dobj->list, &tplg->comp->dobj_list);
 	return 0;
-
-err:
-	kfree(dobj);
-	return ret;
 }
 
 static int soc_tplg_manifest_load(struct soc_tplg *tplg,
@@ -1681,9 +1730,7 @@ static int soc_tplg_load_header(struct soc_tplg *tplg,
 	case SND_SOC_TPLG_TYPE_DAPM_WIDGET:
 		return soc_tplg_dapm_widget_elems_load(tplg, hdr);
 	case SND_SOC_TPLG_TYPE_PCM:
-	case SND_SOC_TPLG_TYPE_DAI_LINK:
-	case SND_SOC_TPLG_TYPE_CODEC_LINK:
-		return soc_tplg_pcm_dai_elems_load(tplg, hdr);
+		return soc_tplg_pcm_elems_load(tplg, hdr);
 	case SND_SOC_TPLG_TYPE_MANIFEST:
 		return soc_tplg_manifest_load(tplg, hdr);
 	default:
@@ -1841,9 +1888,7 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index)
 				remove_widget(comp, dobj, pass);
 				break;
 			case SND_SOC_DOBJ_PCM:
-			case SND_SOC_DOBJ_DAI_LINK:
-			case SND_SOC_DOBJ_CODEC_LINK:
-				remove_pcm_dai(comp, dobj, pass);
+				remove_dai(comp, dobj, pass);
 				break;
 			default:
 				dev_err(comp->dev, "ASoC: invalid component type %d for removal\n",
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 3/3] ASoC: topology: Add FE DAI links dynamically
  2016-01-15  8:11 [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links mengdong.lin
  2016-01-15  8:13 ` [PATCH v2 1/3] ALSA: pcm: Add snd_pcm_rate_range_to_bits() mengdong.lin
  2016-01-15  8:13 ` [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically mengdong.lin
@ 2016-01-15  8:13 ` mengdong.lin
  2016-01-25 11:37 ` [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links Liam Girdwood
  2016-02-15 18:26 ` Mark Brown
  4 siblings, 0 replies; 15+ messages in thread
From: mengdong.lin @ 2016-01-15  8:13 UTC (permalink / raw)
  To: alsa-devel, broonie
  Cc: Mengdong Lin, vinod.koul, mengdong.lin, liam.r.girdwood,
	jeeja.kp, subhransu.s.prusty

From: Mengdong Lin <mengdong.lin@linux.intel.com>

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.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>

diff --git a/include/sound/soc-topology.h b/include/sound/soc-topology.h
index ec562d0..d318fe4 100644
--- a/include/sound/soc-topology.h
+++ b/include/sound/soc-topology.h
@@ -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 *);
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 446ac9a..0eb01e8 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -340,6 +340,16 @@ static int soc_tplg_dai_load(struct soc_tplg *tplg,
 	return 0;
 }
 
+/* pass link configurations to component driver for extra intialization */
+static int soc_tplg_dai_link_load(struct soc_tplg *tplg,
+	struct snd_soc_dai_link *link)
+{
+	if (tplg->comp && tplg->ops && tplg->ops->link_load)
+		return tplg->ops->link_load(tplg->comp, link);
+
+	return 0;
+}
+
 /* tell the component driver that all firmware has been loaded in this request */
 static void soc_tplg_complete(struct soc_tplg *tplg)
 {
@@ -512,6 +522,24 @@ static void remove_dai(struct snd_soc_component *comp,
 	kfree(dai_drv);
 }
 
+/* remove link configurations */
+static void remove_link(struct snd_soc_component *comp,
+	struct snd_soc_dobj *dobj, int pass)
+{
+	struct snd_soc_dai_link *link =
+		container_of(dobj, struct snd_soc_dai_link, dobj);
+
+	if (pass != SOC_TPLG_PASS_PCM_DAI)
+		return;
+
+	if (dobj->ops && dobj->ops->link_unload)
+		dobj->ops->link_unload(comp, dobj);
+
+	list_del(&dobj->list);
+	snd_soc_remove_dai_link(comp->card, link);
+	kfree(link);
+}
+
 /* bind a kcontrol to it's IO handlers */
 static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
 	struct snd_kcontrol_new *k,
@@ -1603,10 +1631,47 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
 	return snd_soc_register_dai(tplg->comp, dai_drv);
 }
 
+static int soc_tplg_link_create(struct soc_tplg *tplg,
+	struct snd_soc_tplg_pcm *pcm)
+{
+	struct snd_soc_dai_link *link;
+	int ret;
+
+	link = kzalloc(sizeof(struct snd_soc_dai_link), GFP_KERNEL);
+	if (link == NULL)
+		return -ENOMEM;
+
+	link->name = pcm->pcm_name;
+	link->stream_name = pcm->pcm_name;
+
+	/* pass control to component driver for optional further init */
+	ret = soc_tplg_dai_link_load(tplg, link);
+	if (ret < 0) {
+		dev_err(tplg->comp->dev, "ASoC: FE link loading failed\n");
+		kfree(link);
+		return ret;
+	}
+
+	link->dobj.index = tplg->index;
+	link->dobj.ops = tplg->ops;
+	link->dobj.type = SND_SOC_DOBJ_DAI_LINK;
+	list_add(&link->dobj.list, &tplg->comp->dobj_list);
+
+	snd_soc_add_dai_link(tplg->comp->card, link);
+	return 0;
+}
+
+/* create a FE DAI and DAI link from the PCM object */
 static int soc_tplg_pcm_create(struct soc_tplg *tplg,
 	struct snd_soc_tplg_pcm *pcm)
 {
-	return soc_tplg_dai_create(tplg, pcm);
+	int ret;
+
+	ret = soc_tplg_dai_create(tplg, pcm);
+	if (ret < 0)
+		return ret;
+
+	return  soc_tplg_link_create(tplg, pcm);
 }
 
 static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
@@ -1890,6 +1955,9 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index)
 			case SND_SOC_DOBJ_PCM:
 				remove_dai(comp, dobj, pass);
 				break;
+			case SND_SOC_DOBJ_DAI_LINK:
+				remove_link(comp, dobj, pass);
+				break;
 			default:
 				dev_err(comp->dev, "ASoC: invalid component type %d for removal\n",
 					dobj->type);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links
  2016-01-15  8:11 [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links mengdong.lin
                   ` (2 preceding siblings ...)
  2016-01-15  8:13 ` [PATCH v2 3/3] ASoC: topology: Add FE DAI links dynamically mengdong.lin
@ 2016-01-25 11:37 ` Liam Girdwood
  2016-01-25 15:39   ` Mark Brown
  2016-02-15 18:26 ` Mark Brown
  4 siblings, 1 reply; 15+ messages in thread
From: Liam Girdwood @ 2016-01-25 11:37 UTC (permalink / raw)
  To: mengdong.lin
  Cc: alsa-devel, Vaibhav Agarwal, Takashi Iwai, mengdong.lin,
	vinod.koul, Mark Brown, jeeja.kp, subhransu.s.prusty

On Fri, 2016-01-15 at 16:11 +0800, mengdong.lin@linux.intel.com wrote:
> From: Mengdong Lin <mengdong.lin@linux.intel.com>
> 
> 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
> 

Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links
  2016-01-25 11:37 ` [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links Liam Girdwood
@ 2016-01-25 15:39   ` Mark Brown
  2016-01-25 15:45     ` Takashi Iwai
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2016-01-25 15:39 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: alsa-devel, mengdong.lin, Takashi Iwai, mengdong.lin, vinod.koul,
	Vaibhav Agarwal, jeeja.kp, subhransu.s.prusty


[-- Attachment #1.1: Type: text/plain, Size: 456 bytes --]

On Mon, Jan 25, 2016 at 11:37:50AM +0000, Liam Girdwood wrote:

> 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).

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links
  2016-01-25 15:39   ` Mark Brown
@ 2016-01-25 15:45     ` Takashi Iwai
  2016-01-27  8:03       ` Mengdong Lin
  0 siblings, 1 reply; 15+ messages in thread
From: Takashi Iwai @ 2016-01-25 15:45 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, mengdong.lin, vinod.koul, mengdong.lin,
	Liam Girdwood, Vaibhav Agarwal, jeeja.kp, subhransu.s.prusty

On Mon, 25 Jan 2016 16:39:54 +0100,
Mark Brown wrote:
> 
> On Mon, Jan 25, 2016 at 11:37:50AM +0000, Liam Girdwood wrote:
> 
> > 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 <s5hziwccx7f.wl-tiwai@suse.de>


Takashi

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links
  2016-01-25 15:45     ` Takashi Iwai
@ 2016-01-27  8:03       ` Mengdong Lin
  2016-01-27 13:33         ` Mark Brown
  0 siblings, 1 reply; 15+ messages in thread
From: Mengdong Lin @ 2016-01-27  8:03 UTC (permalink / raw)
  To: Takashi Iwai, Mark Brown
  Cc: alsa-devel, Vaibhav Agarwal, vinod.koul, mengdong.lin,
	Liam Girdwood, jeeja.kp, subhransu.s.prusty

Thanks for your comments, Takashi!

Hi Mark,

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

Thanks
Mengdong

On 01/25/2016 11:45 PM, Takashi Iwai wrote:
> On Mon, 25 Jan 2016 16:39:54 +0100,
> Mark Brown wrote:
>>
>> On Mon, Jan 25, 2016 at 11:37:50AM +0000, Liam Girdwood wrote:
>>
>>> 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 <s5hziwccx7f.wl-tiwai@suse.de>
>
>
> Takashi
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically
  2016-01-15  8:13 ` [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically mengdong.lin
@ 2016-01-27  9:56   ` Lars-Peter Clausen
  2016-02-15 19:35     ` Mark Brown
  2016-02-16  5:35     ` Mengdong Lin
  0 siblings, 2 replies; 15+ messages in thread
From: Lars-Peter Clausen @ 2016-01-27  9:56 UTC (permalink / raw)
  To: mengdong.lin, alsa-devel, broonie
  Cc: vinod.koul, mengdong.lin, subhransu.s.prusty, liam.r.girdwood, jeeja.kp

On 01/15/2016 09:13 AM, mengdong.lin@linux.intel.com wrote:
[...]
> +		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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links
  2016-01-27  8:03       ` Mengdong Lin
@ 2016-01-27 13:33         ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2016-01-27 13:33 UTC (permalink / raw)
  To: Mengdong Lin
  Cc: alsa-devel, Vaibhav Agarwal, Takashi Iwai, mengdong.lin,
	Liam Girdwood, vinod.koul, jeeja.kp, subhransu.s.prusty


[-- Attachment #1.1: Type: text/plain, Size: 227 bytes --]

On Wed, Jan 27, 2016 at 04:03:42PM +0800, Mengdong Lin wrote:

> 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.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Applied "ALSA: pcm: Add snd_pcm_rate_range_to_bits()" to the asoc tree
  2016-01-15  8:13 ` [PATCH v2 1/3] ALSA: pcm: Add snd_pcm_rate_range_to_bits() mengdong.lin
@ 2016-02-05 18:53   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2016-02-05 18:53 UTC (permalink / raw)
  To: Mengdong Lin, Takashi Iwai, Liam Girdwood, Mark Brown; +Cc: alsa-devel

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

>From 3bdff244a2bcbde37ec33bf3cdde4638049c6c38 Mon Sep 17 00:00:00 2001
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Acked-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/sound/pcm.h   |  2 ++
 sound/core/pcm_misc.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index b0be09279943..af1fb37c6b26 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -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
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index ebe8444de6c6..53dc37357bca 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -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);
-- 
2.7.0.rc3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links
  2016-01-15  8:11 [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links mengdong.lin
                   ` (3 preceding siblings ...)
  2016-01-25 11:37 ` [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links Liam Girdwood
@ 2016-02-15 18:26 ` Mark Brown
  4 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2016-02-15 18:26 UTC (permalink / raw)
  To: mengdong.lin
  Cc: alsa-devel, tiwai, mengdong.lin, liam.r.girdwood, vinod.koul,
	jeeja.kp, subhransu.s.prusty


[-- Attachment #1.1: Type: text/plain, Size: 447 bytes --]

On Fri, Jan 15, 2016 at 04:11:49PM +0800, mengdong.lin@linux.intel.com 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.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically
  2016-01-27  9:56   ` Lars-Peter Clausen
@ 2016-02-15 19:35     ` Mark Brown
  2016-02-16  6:22       ` Mengdong Lin
  2016-02-16  5:35     ` Mengdong Lin
  1 sibling, 1 reply; 15+ messages in thread
From: Mark Brown @ 2016-02-15 19:35 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: alsa-devel, mengdong.lin, vinod.koul, mengdong.lin,
	liam.r.girdwood, jeeja.kp, subhransu.s.prusty


[-- Attachment #1.1: Type: text/plain, Size: 361 bytes --]

On Wed, Jan 27, 2016 at 10:56:39AM +0100, Lars-Peter Clausen wrote:
> On 01/15/2016 09:13 AM, mengdong.lin@linux.intel.com wrote:
> [...]
> > +		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.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically
  2016-01-27  9:56   ` Lars-Peter Clausen
  2016-02-15 19:35     ` Mark Brown
@ 2016-02-16  5:35     ` Mengdong Lin
  1 sibling, 0 replies; 15+ messages in thread
From: Mengdong Lin @ 2016-02-16  5:35 UTC (permalink / raw)
  To: Lars-Peter Clausen, alsa-devel, broonie
  Cc: vinod.koul, mengdong.lin, subhransu.s.prusty, liam.r.girdwood, jeeja.kp



On 01/27/2016 05:56 PM, Lars-Peter Clausen wrote:
> On 01/15/2016 09:13 AM, mengdong.lin@linux.intel.com wrote:
> [...]
>> +		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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically
  2016-02-15 19:35     ` Mark Brown
@ 2016-02-16  6:22       ` Mengdong Lin
  0 siblings, 0 replies; 15+ messages in thread
From: Mengdong Lin @ 2016-02-16  6:22 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter Clausen
  Cc: alsa-devel, vinod.koul, mengdong.lin, liam.r.girdwood, jeeja.kp,
	subhransu.s.prusty


On 02/16/2016 03:35 AM, Mark Brown wrote:
> On Wed, Jan 27, 2016 at 10:56:39AM +0100, Lars-Peter Clausen wrote:
>> On 01/15/2016 09:13 AM, mengdong.lin@linux.intel.com wrote:
>> [...]
>>> +		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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-02-16  6:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-15  8:11 [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links mengdong.lin
2016-01-15  8:13 ` [PATCH v2 1/3] ALSA: pcm: Add snd_pcm_rate_range_to_bits() mengdong.lin
2016-02-05 18:53   ` Applied "ALSA: pcm: Add snd_pcm_rate_range_to_bits()" to the asoc tree Mark Brown
2016-01-15  8:13 ` [PATCH v2 2/3] ASoC: topology: Add FE DAIs dynamically mengdong.lin
2016-01-27  9:56   ` Lars-Peter Clausen
2016-02-15 19:35     ` Mark Brown
2016-02-16  6:22       ` Mengdong Lin
2016-02-16  5:35     ` Mengdong Lin
2016-01-15  8:13 ` [PATCH v2 3/3] ASoC: topology: Add FE DAI links dynamically mengdong.lin
2016-01-25 11:37 ` [PATCH v2 0/3] ASoC: topology: Add support for FE DAI & DAI links Liam Girdwood
2016-01-25 15:39   ` Mark Brown
2016-01-25 15:45     ` Takashi Iwai
2016-01-27  8:03       ` Mengdong Lin
2016-01-27 13:33         ` Mark Brown
2016-02-15 18:26 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.