linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: add HDMI sound support for Codec
@ 2017-05-18  1:38 Kuninori Morimoto
  2017-05-18  1:39 ` [PATCH 1/5] ASoC: add snd_soc_get_dai_id() function Kuninori Morimoto
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Kuninori Morimoto @ 2017-05-18  1:38 UTC (permalink / raw)
  To: Mark Brown, Archit Taneja
  Cc: Linux-ALSA, Simon, linux-renesas-soc, David Airlie,
	Laurent Pinchart, Russell King, Jose Abreu, dri-devel,
	linux-kernel


Hi Mark, Archit

These supports HDMI sound for Codec.
Now, SYNOPSYS dw-hdmi-i2s-audio driver is supporting HDMI I2S
and is using hdmi-codec driver.
Now, ALSA SoC supports OF-graph DT style, this means V4L2/ALSA SoC
can share same DT bindings.
But 1 issue is that ALSA SoC side needs to adjust port ID <-> Sound DAI
matching. 1) - 4) are for these purpose.

 1) - 4) : ASoC side patch for hdmi-codec
 5)      : V4L2 side patch for SYNOPSYS dw-hdmi

Kuninori Morimoto (5):
  1) ASoC: add snd_soc_get_dai_id() function
  2) ASoC: simple-card-utils: support snd_soc_get_dai_id()
  3) ASoC: hdmi-codec: remove multi detection support
  4) ASoC: hdmi-codec: add .get_dai_id support
  5) drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC

 .../bindings/display/bridge/renesas,dw-hdmi.txt    |  9 ++-
 .../gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c    | 21 +++++
 include/sound/hdmi-codec.h                         |  9 +++
 include/sound/soc.h                                |  3 +
 sound/soc/codecs/hdmi-codec.c                      | 91 +++-------------------
 sound/soc/generic/simple-card-utils.c              |  9 +++
 sound/soc/soc-core.c                               | 37 +++++++++
 7 files changed, 98 insertions(+), 81 deletions(-)

-- 
1.9.1

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

* [PATCH 1/5] ASoC: add snd_soc_get_dai_id() function
  2017-05-18  1:38 [PATCH 0/5] ASoC: add HDMI sound support for Codec Kuninori Morimoto
@ 2017-05-18  1:39 ` Kuninori Morimoto
  2017-05-24 17:41   ` Applied "ASoC: add snd_soc_get_dai_id() function" to the asoc tree Mark Brown
  2017-05-18  1:39 ` [PATCH 2/5] ASoC: simple-card-utils: support snd_soc_get_dai_id() Kuninori Morimoto
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Kuninori Morimoto @ 2017-05-18  1:39 UTC (permalink / raw)
  To: Mark Brown, Archit Taneja
  Cc: Linux-ALSA, Simon, linux-renesas-soc, David Airlie,
	Laurent Pinchart, Russell King, Jose Abreu, dri-devel,
	linux-kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC needs to know connected DAI ID for detecting.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new snd_soc_get_dai_id() and
its related .of_xlate_dai_id callback on component driver.
In below case, we can handle Sound port (= port@2) as ID = 0
if .of_xlate_dai_id has its support.

	hdmi {
		port@0 { /* VIDEO */ };
		port@1 { /* VIDEO */ };
		port@2 { /* SOUND */ };
	};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  3 +++
 sound/soc/soc-core.c | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5170fd8..9c94b97 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -803,6 +803,8 @@ struct snd_soc_component_driver {
 	int (*of_xlate_dai_name)(struct snd_soc_component *component,
 				 struct of_phandle_args *args,
 				 const char **dai_name);
+	int (*of_xlate_dai_id)(struct snd_soc_component *comment,
+			       struct device_node *endpoint);
 	void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
 		int subseq);
 	int (*stream_event)(struct snd_soc_component *, int event);
@@ -1676,6 +1678,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
 				     struct device_node **framemaster);
+int snd_soc_get_dai_id(struct device_node *ep);
 int snd_soc_get_dai_name(struct of_phandle_args *args,
 			 const char **dai_name);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ab7a07f..9ba1837 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -34,6 +34,7 @@
 #include <linux/ctype.h>
 #include <linux/slab.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <linux/dmi.h>
 #include <sound/core.h>
 #include <sound/jack.h>
@@ -4048,6 +4049,42 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
+int snd_soc_get_dai_id(struct device_node *ep)
+{
+	struct snd_soc_component *pos;
+	struct device_node *node;
+	int ret;
+
+	node = of_graph_get_port_parent(ep);
+
+	/*
+	 * For example HDMI case, HDMI has video/sound port,
+	 * but ALSA SoC needs sound port number only.
+	 * Thus counting HDMI DT port/endpoint doesn't work.
+	 * Then, it should have .of_xlate_dai_id
+	 */
+	ret = -ENOTSUPP;
+	mutex_lock(&client_mutex);
+	list_for_each_entry(pos, &component_list, list) {
+		struct device_node *component_of_node = pos->dev->of_node;
+
+		if (!component_of_node && pos->dev->parent)
+			component_of_node = pos->dev->parent->of_node;
+
+		if (component_of_node != node)
+			continue;
+
+		if (pos->driver->of_xlate_dai_id)
+			ret = pos->driver->of_xlate_dai_id(pos, ep);
+
+		break;
+	}
+	mutex_unlock(&client_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_dai_id);
+
 int snd_soc_get_dai_name(struct of_phandle_args *args,
 				const char **dai_name)
 {
-- 
1.9.1

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

* [PATCH 2/5] ASoC: simple-card-utils: support snd_soc_get_dai_id()
  2017-05-18  1:38 [PATCH 0/5] ASoC: add HDMI sound support for Codec Kuninori Morimoto
  2017-05-18  1:39 ` [PATCH 1/5] ASoC: add snd_soc_get_dai_id() function Kuninori Morimoto
@ 2017-05-18  1:39 ` Kuninori Morimoto
  2017-05-24 17:44   ` Applied "ASoC: simple-card-utils: support snd_soc_get_dai_id()" to the asoc tree Mark Brown
  2017-05-18  1:40 ` [PATCH 3/5] ASoC: hdmi-codec: remove multi detection support Kuninori Morimoto
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Kuninori Morimoto @ 2017-05-18  1:39 UTC (permalink / raw)
  To: Mark Brown, Archit Taneja
  Cc: Linux-ALSA, Simon, linux-renesas-soc, David Airlie,
	Laurent Pinchart, Russell King, Jose Abreu, dri-devel,
	linux-kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC needs to know connected DAI ID for detecting.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new snd_soc_get_dai_id() and
its related .of_xlate_dai_id callback on component driver.
In below case, we can handle Sound port (= port@2) as ID = 0
if .of_xlate_dai_id has its support.

	hdmi {
		port@0 { /* VIDEO */ };
		port@1 { /* VIDEO */ };
		port@2 { /* SOUND */ };
	};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card-utils.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 5a3d51e..fe726e8 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -177,9 +177,18 @@ static int asoc_simple_card_get_dai_id(struct device_node *ep)
 	struct device_node *node;
 	struct device_node *endpoint;
 	int i, id;
+	int ret;
+
+	ret = snd_soc_get_dai_id(ep);
+	if (ret != -ENOTSUPP)
+		return ret;
 
 	node = of_graph_get_port_parent(ep);
 
+	/*
+	 * Non HDMI sound case, counting port/endpoint on its DT
+	 * is enough. Let's count it.
+	 */
 	i = 0;
 	id = -1;
 	for_each_endpoint_of_node(node, endpoint) {
-- 
1.9.1

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

* [PATCH 3/5] ASoC: hdmi-codec: remove multi detection support
  2017-05-18  1:38 [PATCH 0/5] ASoC: add HDMI sound support for Codec Kuninori Morimoto
  2017-05-18  1:39 ` [PATCH 1/5] ASoC: add snd_soc_get_dai_id() function Kuninori Morimoto
  2017-05-18  1:39 ` [PATCH 2/5] ASoC: simple-card-utils: support snd_soc_get_dai_id() Kuninori Morimoto
@ 2017-05-18  1:40 ` Kuninori Morimoto
  2017-05-24 17:45   ` Applied "ASoC: hdmi-codec: remove multi detection support" to the asoc tree Mark Brown
  2017-05-18  1:40 ` [PATCH 4/5] ASoC: hdmi-codec: add .get_dai_id support Kuninori Morimoto
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Kuninori Morimoto @ 2017-05-18  1:40 UTC (permalink / raw)
  To: Mark Brown, Archit Taneja
  Cc: Linux-ALSA, Simon, linux-renesas-soc, David Airlie,
	Laurent Pinchart, Russell King, Jose Abreu, dri-devel,
	linux-kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

DesignWare HDMI driver (= dw-hdmi) is supporting HDMI sound, and its
probe function was calling sound binding function multiple times as
same HDMI device different port.

Because of this behavior, commit 9731f82d601 ("ASoC: hdmi-codec: enable
multi probe for ...") was added for multi detection case.
But, this DesignWare HDMI detection/bind code was exchanged/adjusted by
commit 69497eb9234 ("drm: bridge: dw-hdmi: Implement DRM bridge...").
Now, all DesignWare HDMI sound ports are detected as 1 bindng function.

Because of this, hdmi-codec multi detection support is no longer needed.
Thus, this patch removes
commit 9731f82d601 ("ASoC: hdmi-codec: enable multi probe for ..."),
and its related
commit 340327a62c4 ("ASoC: hdmi-codec: Fix hdmi_of_xlate_dai_name...")
commit 8480ac56795 ("ASoC: hdmi-codec: remove HDMI device unregister")
commit 0c343a35bfe ("ASoC: hdmi-codec: fix spelling mistake: ...)

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/codecs/hdmi-codec.c | 88 ++-----------------------------------------
 1 file changed, 3 insertions(+), 85 deletions(-)

diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index a3f1514..8659b76 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -25,17 +25,6 @@
 
 #include <drm/drm_crtc.h> /* This is only to get MAX_ELD_BYTES */
 
-struct hdmi_device {
-	struct device *dev;
-	struct list_head list;
-	int cnt;
-};
-#define pos_to_hdmi_device(pos)	container_of((pos), struct hdmi_device, list)
-LIST_HEAD(hdmi_device_list);
-static DEFINE_MUTEX(hdmi_mutex);
-
-#define DAI_NAME_SIZE 16
-
 #define HDMI_CODEC_CHMAP_IDX_UNKNOWN  -1
 
 struct hdmi_codec_channel_map_table {
@@ -702,6 +691,7 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
 }
 
 static struct snd_soc_dai_driver hdmi_i2s_dai = {
+	.name = "i2s-hifi",
 	.id = DAI_ID_I2S,
 	.playback = {
 		.stream_name = "Playback",
@@ -716,6 +706,7 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
 };
 
 static const struct snd_soc_dai_driver hdmi_spdif_dai = {
+	.name = "spdif-hifi",
 	.id = DAI_ID_SPDIF,
 	.playback = {
 		.stream_name = "Playback",
@@ -728,32 +719,6 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
 	.pcm_new = hdmi_codec_pcm_new,
 };
 
-static char hdmi_dai_name[][DAI_NAME_SIZE] = {
-	"hdmi-hifi.0",
-	"hdmi-hifi.1",
-	"hdmi-hifi.2",
-	"hdmi-hifi.3",
-};
-
-static int hdmi_of_xlate_dai_name(struct snd_soc_component *component,
-				  struct of_phandle_args *args,
-				  const char **dai_name)
-{
-	int id;
-
-	if (args->args_count)
-		id = args->args[0];
-	else
-		id = 0;
-
-	if (id < ARRAY_SIZE(hdmi_dai_name)) {
-		*dai_name = hdmi_dai_name[id];
-		return 0;
-	}
-
-	return -EAGAIN;
-}
-
 static struct snd_soc_codec_driver hdmi_codec = {
 	.component_driver = {
 		.controls		= hdmi_controls,
@@ -762,7 +727,6 @@ static int hdmi_of_xlate_dai_name(struct snd_soc_component *component,
 		.num_dapm_widgets	= ARRAY_SIZE(hdmi_widgets),
 		.dapm_routes		= hdmi_routes,
 		.num_dapm_routes	= ARRAY_SIZE(hdmi_routes),
-		.of_xlate_dai_name	= hdmi_of_xlate_dai_name,
 	},
 };
 
@@ -771,8 +735,6 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 	struct hdmi_codec_pdata *hcd = pdev->dev.platform_data;
 	struct device *dev = &pdev->dev;
 	struct hdmi_codec_priv *hcp;
-	struct hdmi_device *hd;
-	struct list_head *pos;
 	int dai_count, i = 0;
 	int ret;
 
@@ -794,35 +756,6 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 	if (!hcp)
 		return -ENOMEM;
 
-	hd = NULL;
-	mutex_lock(&hdmi_mutex);
-	list_for_each(pos, &hdmi_device_list) {
-		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
-
-		if (tmp->dev == dev->parent) {
-			hd = tmp;
-			break;
-		}
-	}
-
-	if (!hd) {
-		hd = devm_kzalloc(dev, sizeof(*hd), GFP_KERNEL);
-		if (!hd) {
-			mutex_unlock(&hdmi_mutex);
-			return -ENOMEM;
-		}
-
-		hd->dev = dev->parent;
-
-		list_add_tail(&hd->list, &hdmi_device_list);
-	}
-	mutex_unlock(&hdmi_mutex);
-
-	if (hd->cnt >= ARRAY_SIZE(hdmi_dai_name)) {
-		dev_err(dev, "too many hdmi codec are detected\n");
-		return -EINVAL;
-	}
-
 	hcp->hcd = *hcd;
 	mutex_init(&hcp->current_stream_lock);
 
@@ -835,14 +768,11 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 		hcp->daidrv[i] = hdmi_i2s_dai;
 		hcp->daidrv[i].playback.channels_max =
 			hcd->max_i2s_channels;
-		hcp->daidrv[i].name = hdmi_dai_name[hd->cnt++];
 		i++;
 	}
 
-	if (hcd->spdif) {
+	if (hcd->spdif)
 		hcp->daidrv[i] = hdmi_spdif_dai;
-		hcp->daidrv[i].name = hdmi_dai_name[hd->cnt++];
-	}
 
 	ret = snd_soc_register_codec(dev, &hdmi_codec, hcp->daidrv,
 				     dai_count);
@@ -859,20 +789,8 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 static int hdmi_codec_remove(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct list_head *pos;
 	struct hdmi_codec_priv *hcp;
 
-	mutex_lock(&hdmi_mutex);
-	list_for_each(pos, &hdmi_device_list) {
-		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
-
-		if (tmp->dev == dev->parent) {
-			list_del(pos);
-			break;
-		}
-	}
-	mutex_unlock(&hdmi_mutex);
-
 	hcp = dev_get_drvdata(dev);
 	kfree(hcp->chmap_info);
 	snd_soc_unregister_codec(dev);
-- 
1.9.1

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

* [PATCH 4/5] ASoC: hdmi-codec: add .get_dai_id support
  2017-05-18  1:38 [PATCH 0/5] ASoC: add HDMI sound support for Codec Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2017-05-18  1:40 ` [PATCH 3/5] ASoC: hdmi-codec: remove multi detection support Kuninori Morimoto
@ 2017-05-18  1:40 ` Kuninori Morimoto
  2017-05-24 17:45   ` Applied "ASoC: hdmi-codec: add .get_dai_id support" to the asoc tree Mark Brown
  2017-05-18  1:40 ` [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC Kuninori Morimoto
  2017-06-19  0:39 ` [PATCH][RESEND] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC Kuninori Morimoto
  5 siblings, 1 reply; 17+ messages in thread
From: Kuninori Morimoto @ 2017-05-18  1:40 UTC (permalink / raw)
  To: Mark Brown, Archit Taneja
  Cc: Linux-ALSA, Simon, linux-renesas-soc, David Airlie,
	Laurent Pinchart, Russell King, Jose Abreu, dri-devel,
	linux-kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC needs to know connected DAI ID for probing.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new .get_dai_id callback
on hdmi_codec_ops

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/hdmi-codec.h    |  9 +++++++++
 sound/soc/codecs/hdmi-codec.c | 13 +++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 915c435..9483c55 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -18,9 +18,11 @@
 #ifndef __HDMI_CODEC_H__
 #define __HDMI_CODEC_H__
 
+#include <linux/of_graph.h>
 #include <linux/hdmi.h>
 #include <drm/drm_edid.h>
 #include <sound/asoundef.h>
+#include <sound/soc.h>
 #include <uapi/sound/asound.h>
 
 /*
@@ -87,6 +89,13 @@ struct hdmi_codec_ops {
 	 */
 	int (*get_eld)(struct device *dev, void *data,
 		       uint8_t *buf, size_t len);
+
+	/*
+	 * Getting DAI ID
+	 * Optional
+	 */
+	int (*get_dai_id)(struct snd_soc_component *comment,
+			  struct device_node *endpoint);
 };
 
 /* HDMI codec initalization data */
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 8659b76..6d05161 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -719,6 +719,18 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
 	.pcm_new = hdmi_codec_pcm_new,
 };
 
+static int hdmi_of_xlate_dai_id(struct snd_soc_component *component,
+				 struct device_node *endpoint)
+{
+	struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
+	int ret = -ENOTSUPP; /* see snd_soc_get_dai_id() */
+
+	if (hcp->hcd.ops->get_dai_id)
+		ret = hcp->hcd.ops->get_dai_id(component, endpoint);
+
+	return ret;
+}
+
 static struct snd_soc_codec_driver hdmi_codec = {
 	.component_driver = {
 		.controls		= hdmi_controls,
@@ -727,6 +739,7 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
 		.num_dapm_widgets	= ARRAY_SIZE(hdmi_widgets),
 		.dapm_routes		= hdmi_routes,
 		.num_dapm_routes	= ARRAY_SIZE(hdmi_routes),
+		.of_xlate_dai_id	= hdmi_of_xlate_dai_id,
 	},
 };
 
-- 
1.9.1

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

* [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC
  2017-05-18  1:38 [PATCH 0/5] ASoC: add HDMI sound support for Codec Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2017-05-18  1:40 ` [PATCH 4/5] ASoC: hdmi-codec: add .get_dai_id support Kuninori Morimoto
@ 2017-05-18  1:40 ` Kuninori Morimoto
  2017-05-24 17:38   ` Mark Brown
  2017-06-28 19:48   ` Applied "drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC" to the asoc tree Mark Brown
  2017-06-19  0:39 ` [PATCH][RESEND] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC Kuninori Morimoto
  5 siblings, 2 replies; 17+ messages in thread
From: Kuninori Morimoto @ 2017-05-18  1:40 UTC (permalink / raw)
  To: Mark Brown, Archit Taneja
  Cc: Linux-ALSA, Simon, linux-renesas-soc, David Airlie,
	Laurent Pinchart, Russell King, Jose Abreu, dri-devel,
	linux-kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC needs to know connected DAI ID for probing.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new .get_dai_id callback
on hdmi_codec_ops.
dw-hdmi-i2s will assume that HDMI sound will be connected
to reg = <2>. Then, ALSA SoC side will recognized it as DAI 0

	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			/* HDMI Video IN */
		};
		port@1 {
			reg = <1>;
			/* HDMI OUT */
		};
		port@2 {
			reg = <2>;
			/* HDMI Sound IN */
		};
	};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../bindings/display/bridge/renesas,dw-hdmi.txt     |  9 ++++++++-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
index f6b3f36..81b6858 100644
--- a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
+++ b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
@@ -25,7 +25,8 @@ Required properties:
 - clock-names: Shall contain "iahb" and "isfr" as defined in dw_hdmi.txt.
 - ports: See dw_hdmi.txt. The DWC HDMI shall have one port numbered 0
   corresponding to the video input of the controller and one port numbered 1
-  corresponding to its HDMI output. Each port shall have a single endpoint.
+  corresponding to its HDMI output, and one port numbered 2 corresponding to
+  sound input of the controller. Each port shall have a single endpoint.
 
 Optional properties:
 
@@ -59,6 +60,12 @@ Example:
 					remote-endpoint = <&hdmi0_con>;
 				};
 			};
+			port@2 {
+				reg = <2>;
+				rcar_dw_hdmi0_sound_in: endpoint {
+					remote-endpoint = <&hdmi_sound_out>;
+				};
+			};
 		};
 	};
 
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
index aaf287d..b2cf59f 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
@@ -82,9 +82,30 @@ static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data)
 	hdmi_write(audio, HDMI_AUD_CONF0_SW_RESET, HDMI_AUD_CONF0);
 }
 
+static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,
+				  struct device_node *endpoint)
+{
+	struct of_endpoint of_ep;
+	int ret;
+
+	ret = of_graph_parse_endpoint(endpoint, &of_ep);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * HDMI sound should be located as reg = <2>
+	 * Then, it is sound port 0
+	 */
+	if (of_ep.port == 2)
+		return 0;
+
+	return -EINVAL;
+}
+
 static struct hdmi_codec_ops dw_hdmi_i2s_ops = {
 	.hw_params	= dw_hdmi_i2s_hw_params,
 	.audio_shutdown	= dw_hdmi_i2s_audio_shutdown,
+	.get_dai_id	= dw_hdmi_i2s_get_dai_id,
 };
 
 static int snd_dw_hdmi_probe(struct platform_device *pdev)
-- 
1.9.1

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

* Re: [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC
  2017-05-18  1:40 ` [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC Kuninori Morimoto
@ 2017-05-24 17:38   ` Mark Brown
  2017-05-24 23:34     ` Kuninori Morimoto
  2017-06-28 19:48   ` Applied "drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC" to the asoc tree Mark Brown
  1 sibling, 1 reply; 17+ messages in thread
From: Mark Brown @ 2017-05-24 17:38 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Archit Taneja, Linux-ALSA, Simon, linux-renesas-soc,
	David Airlie, Laurent Pinchart, Russell King, Jose Abreu,
	dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 415 bytes --]

On Thu, May 18, 2017 at 01:40:47AM +0000, Kuninori Morimoto wrote:

> ALSA SoC needs to know connected DAI ID for probing.
> It is not a big problem if device/driver was only for sound,
> but getting DAI ID will be difficult if device includes both
> Video/Sound, like HDMI.

As far as I understand what's going on with the graph code this seems to
make sense to me.  How do we want to go about handling the patch?

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

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

* Applied "ASoC: add snd_soc_get_dai_id() function" to the asoc tree
  2017-05-18  1:39 ` [PATCH 1/5] ASoC: add snd_soc_get_dai_id() function Kuninori Morimoto
@ 2017-05-24 17:41   ` Mark Brown
  0 siblings, 0 replies; 17+ messages in thread
From: Mark Brown @ 2017-05-24 17:41 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Mark Brown, Archit Taneja, Jose Abreu, Linux-ALSA,
	Laurent Pinchart, David Airlie, linux-kernel, dri-devel,
	linux-renesas-soc, Russell King, Simon, alsa-devel

The patch

   ASoC: add snd_soc_get_dai_id() function

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 a180e8b988437b3e84a1b501ac4d073467602ca6 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Thu, 18 May 2017 01:39:25 +0000
Subject: [PATCH] ASoC: add snd_soc_get_dai_id() function

ALSA SoC needs to know connected DAI ID for detecting.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new snd_soc_get_dai_id() and
its related .of_xlate_dai_id callback on component driver.
In below case, we can handle Sound port (= port@2) as ID = 0
if .of_xlate_dai_id has its support.

	hdmi {
		port@0 { /* VIDEO */ };
		port@1 { /* VIDEO */ };
		port@2 { /* SOUND */ };
	};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/sound/soc.h  |  3 +++
 sound/soc/soc-core.c | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5170fd81e1fd..9c94b97c17f8 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -803,6 +803,8 @@ struct snd_soc_component_driver {
 	int (*of_xlate_dai_name)(struct snd_soc_component *component,
 				 struct of_phandle_args *args,
 				 const char **dai_name);
+	int (*of_xlate_dai_id)(struct snd_soc_component *comment,
+			       struct device_node *endpoint);
 	void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
 		int subseq);
 	int (*stream_event)(struct snd_soc_component *, int event);
@@ -1676,6 +1678,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
 				     struct device_node **framemaster);
+int snd_soc_get_dai_id(struct device_node *ep);
 int snd_soc_get_dai_name(struct of_phandle_args *args,
 			 const char **dai_name);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index aae099c0e502..b0fb17082691 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -34,6 +34,7 @@
 #include <linux/ctype.h>
 #include <linux/slab.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <linux/dmi.h>
 #include <sound/core.h>
 #include <sound/jack.h>
@@ -4044,6 +4045,42 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
+int snd_soc_get_dai_id(struct device_node *ep)
+{
+	struct snd_soc_component *pos;
+	struct device_node *node;
+	int ret;
+
+	node = of_graph_get_port_parent(ep);
+
+	/*
+	 * For example HDMI case, HDMI has video/sound port,
+	 * but ALSA SoC needs sound port number only.
+	 * Thus counting HDMI DT port/endpoint doesn't work.
+	 * Then, it should have .of_xlate_dai_id
+	 */
+	ret = -ENOTSUPP;
+	mutex_lock(&client_mutex);
+	list_for_each_entry(pos, &component_list, list) {
+		struct device_node *component_of_node = pos->dev->of_node;
+
+		if (!component_of_node && pos->dev->parent)
+			component_of_node = pos->dev->parent->of_node;
+
+		if (component_of_node != node)
+			continue;
+
+		if (pos->driver->of_xlate_dai_id)
+			ret = pos->driver->of_xlate_dai_id(pos, ep);
+
+		break;
+	}
+	mutex_unlock(&client_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_dai_id);
+
 int snd_soc_get_dai_name(struct of_phandle_args *args,
 				const char **dai_name)
 {
-- 
2.11.0

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

* Applied "ASoC: simple-card-utils: support snd_soc_get_dai_id()" to the asoc tree
  2017-05-18  1:39 ` [PATCH 2/5] ASoC: simple-card-utils: support snd_soc_get_dai_id() Kuninori Morimoto
@ 2017-05-24 17:44   ` Mark Brown
  0 siblings, 0 replies; 17+ messages in thread
From: Mark Brown @ 2017-05-24 17:44 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Mark Brown, Archit Taneja, Jose Abreu, Linux-ALSA,
	Laurent Pinchart, David Airlie, linux-kernel, dri-devel,
	linux-renesas-soc, Russell King, Simon, alsa-devel

The patch

   ASoC: simple-card-utils: support snd_soc_get_dai_id()

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 73b17f1a65c881fcf97109d77056006da2d40152 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Thu, 18 May 2017 01:39:44 +0000
Subject: [PATCH] ASoC: simple-card-utils: support snd_soc_get_dai_id()

ALSA SoC needs to know connected DAI ID for detecting.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new snd_soc_get_dai_id() and
its related .of_xlate_dai_id callback on component driver.
In below case, we can handle Sound port (= port@2) as ID = 0
if .of_xlate_dai_id has its support.

	hdmi {
		port@0 { /* VIDEO */ };
		port@1 { /* VIDEO */ };
		port@2 { /* SOUND */ };
	};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/generic/simple-card-utils.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 5a3d51e45938..fe726e83d0bd 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -177,9 +177,18 @@ static int asoc_simple_card_get_dai_id(struct device_node *ep)
 	struct device_node *node;
 	struct device_node *endpoint;
 	int i, id;
+	int ret;
+
+	ret = snd_soc_get_dai_id(ep);
+	if (ret != -ENOTSUPP)
+		return ret;
 
 	node = of_graph_get_port_parent(ep);
 
+	/*
+	 * Non HDMI sound case, counting port/endpoint on its DT
+	 * is enough. Let's count it.
+	 */
 	i = 0;
 	id = -1;
 	for_each_endpoint_of_node(node, endpoint) {
-- 
2.11.0

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

* Applied "ASoC: hdmi-codec: add .get_dai_id support" to the asoc tree
  2017-05-18  1:40 ` [PATCH 4/5] ASoC: hdmi-codec: add .get_dai_id support Kuninori Morimoto
@ 2017-05-24 17:45   ` Mark Brown
  0 siblings, 0 replies; 17+ messages in thread
From: Mark Brown @ 2017-05-24 17:45 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Mark Brown, Archit Taneja, Jose Abreu, Linux-ALSA,
	Laurent Pinchart, David Airlie, linux-kernel, dri-devel,
	linux-renesas-soc, Russell King, Simon, alsa-devel

The patch

   ASoC: hdmi-codec: add .get_dai_id support

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 96203fb4237bf70f0fd0fa307ca2975077db3ceb Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Thu, 18 May 2017 01:40:20 +0000
Subject: [PATCH] ASoC: hdmi-codec: add .get_dai_id support

ALSA SoC needs to know connected DAI ID for probing.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new .get_dai_id callback
on hdmi_codec_ops

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/sound/hdmi-codec.h    |  9 +++++++++
 sound/soc/codecs/hdmi-codec.c | 13 +++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 915c4357945c..9483c55f871b 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -18,9 +18,11 @@
 #ifndef __HDMI_CODEC_H__
 #define __HDMI_CODEC_H__
 
+#include <linux/of_graph.h>
 #include <linux/hdmi.h>
 #include <drm/drm_edid.h>
 #include <sound/asoundef.h>
+#include <sound/soc.h>
 #include <uapi/sound/asound.h>
 
 /*
@@ -87,6 +89,13 @@ struct hdmi_codec_ops {
 	 */
 	int (*get_eld)(struct device *dev, void *data,
 		       uint8_t *buf, size_t len);
+
+	/*
+	 * Getting DAI ID
+	 * Optional
+	 */
+	int (*get_dai_id)(struct snd_soc_component *comment,
+			  struct device_node *endpoint);
 };
 
 /* HDMI codec initalization data */
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 8659b76b066a..6d05161b625d 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -719,6 +719,18 @@ static const struct snd_soc_dai_driver hdmi_spdif_dai = {
 	.pcm_new = hdmi_codec_pcm_new,
 };
 
+static int hdmi_of_xlate_dai_id(struct snd_soc_component *component,
+				 struct device_node *endpoint)
+{
+	struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
+	int ret = -ENOTSUPP; /* see snd_soc_get_dai_id() */
+
+	if (hcp->hcd.ops->get_dai_id)
+		ret = hcp->hcd.ops->get_dai_id(component, endpoint);
+
+	return ret;
+}
+
 static struct snd_soc_codec_driver hdmi_codec = {
 	.component_driver = {
 		.controls		= hdmi_controls,
@@ -727,6 +739,7 @@ static struct snd_soc_codec_driver hdmi_codec = {
 		.num_dapm_widgets	= ARRAY_SIZE(hdmi_widgets),
 		.dapm_routes		= hdmi_routes,
 		.num_dapm_routes	= ARRAY_SIZE(hdmi_routes),
+		.of_xlate_dai_id	= hdmi_of_xlate_dai_id,
 	},
 };
 
-- 
2.11.0

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

* Applied "ASoC: hdmi-codec: remove multi detection support" to the asoc tree
  2017-05-18  1:40 ` [PATCH 3/5] ASoC: hdmi-codec: remove multi detection support Kuninori Morimoto
@ 2017-05-24 17:45   ` Mark Brown
  0 siblings, 0 replies; 17+ messages in thread
From: Mark Brown @ 2017-05-24 17:45 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Mark Brown, Archit Taneja, Jose Abreu, Linux-ALSA,
	Laurent Pinchart, David Airlie, linux-kernel, dri-devel,
	linux-renesas-soc, Russell King, Simon, alsa-devel

The patch

   ASoC: hdmi-codec: remove multi detection support

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 24069b589b02cc1292761b0f72623dd50ad1e19c Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Thu, 18 May 2017 01:40:02 +0000
Subject: [PATCH] ASoC: hdmi-codec: remove multi detection support

DesignWare HDMI driver (= dw-hdmi) is supporting HDMI sound, and its
probe function was calling sound binding function multiple times as
same HDMI device different port.

Because of this behavior, commit 9731f82d601 ("ASoC: hdmi-codec: enable
multi probe for ...") was added for multi detection case.
But, this DesignWare HDMI detection/bind code was exchanged/adjusted by
commit 69497eb9234 ("drm: bridge: dw-hdmi: Implement DRM bridge...").
Now, all DesignWare HDMI sound ports are detected as 1 bindng function.

Because of this, hdmi-codec multi detection support is no longer needed.
Thus, this patch removes
commit 9731f82d601 ("ASoC: hdmi-codec: enable multi probe for ..."),
and its related
commit 340327a62c4 ("ASoC: hdmi-codec: Fix hdmi_of_xlate_dai_name...")
commit 8480ac56795 ("ASoC: hdmi-codec: remove HDMI device unregister")
commit 0c343a35bfe ("ASoC: hdmi-codec: fix spelling mistake: ...)

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/hdmi-codec.c | 88 ++-----------------------------------------
 1 file changed, 3 insertions(+), 85 deletions(-)

diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index a3f15149afcf..8659b76b066a 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -25,17 +25,6 @@
 
 #include <drm/drm_crtc.h> /* This is only to get MAX_ELD_BYTES */
 
-struct hdmi_device {
-	struct device *dev;
-	struct list_head list;
-	int cnt;
-};
-#define pos_to_hdmi_device(pos)	container_of((pos), struct hdmi_device, list)
-LIST_HEAD(hdmi_device_list);
-static DEFINE_MUTEX(hdmi_mutex);
-
-#define DAI_NAME_SIZE 16
-
 #define HDMI_CODEC_CHMAP_IDX_UNKNOWN  -1
 
 struct hdmi_codec_channel_map_table {
@@ -702,6 +691,7 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
 }
 
 static struct snd_soc_dai_driver hdmi_i2s_dai = {
+	.name = "i2s-hifi",
 	.id = DAI_ID_I2S,
 	.playback = {
 		.stream_name = "Playback",
@@ -716,6 +706,7 @@ static struct snd_soc_dai_driver hdmi_i2s_dai = {
 };
 
 static const struct snd_soc_dai_driver hdmi_spdif_dai = {
+	.name = "spdif-hifi",
 	.id = DAI_ID_SPDIF,
 	.playback = {
 		.stream_name = "Playback",
@@ -728,32 +719,6 @@ static const struct snd_soc_dai_driver hdmi_spdif_dai = {
 	.pcm_new = hdmi_codec_pcm_new,
 };
 
-static char hdmi_dai_name[][DAI_NAME_SIZE] = {
-	"hdmi-hifi.0",
-	"hdmi-hifi.1",
-	"hdmi-hifi.2",
-	"hdmi-hifi.3",
-};
-
-static int hdmi_of_xlate_dai_name(struct snd_soc_component *component,
-				  struct of_phandle_args *args,
-				  const char **dai_name)
-{
-	int id;
-
-	if (args->args_count)
-		id = args->args[0];
-	else
-		id = 0;
-
-	if (id < ARRAY_SIZE(hdmi_dai_name)) {
-		*dai_name = hdmi_dai_name[id];
-		return 0;
-	}
-
-	return -EAGAIN;
-}
-
 static struct snd_soc_codec_driver hdmi_codec = {
 	.component_driver = {
 		.controls		= hdmi_controls,
@@ -762,7 +727,6 @@ static struct snd_soc_codec_driver hdmi_codec = {
 		.num_dapm_widgets	= ARRAY_SIZE(hdmi_widgets),
 		.dapm_routes		= hdmi_routes,
 		.num_dapm_routes	= ARRAY_SIZE(hdmi_routes),
-		.of_xlate_dai_name	= hdmi_of_xlate_dai_name,
 	},
 };
 
@@ -771,8 +735,6 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 	struct hdmi_codec_pdata *hcd = pdev->dev.platform_data;
 	struct device *dev = &pdev->dev;
 	struct hdmi_codec_priv *hcp;
-	struct hdmi_device *hd;
-	struct list_head *pos;
 	int dai_count, i = 0;
 	int ret;
 
@@ -794,35 +756,6 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 	if (!hcp)
 		return -ENOMEM;
 
-	hd = NULL;
-	mutex_lock(&hdmi_mutex);
-	list_for_each(pos, &hdmi_device_list) {
-		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
-
-		if (tmp->dev == dev->parent) {
-			hd = tmp;
-			break;
-		}
-	}
-
-	if (!hd) {
-		hd = devm_kzalloc(dev, sizeof(*hd), GFP_KERNEL);
-		if (!hd) {
-			mutex_unlock(&hdmi_mutex);
-			return -ENOMEM;
-		}
-
-		hd->dev = dev->parent;
-
-		list_add_tail(&hd->list, &hdmi_device_list);
-	}
-	mutex_unlock(&hdmi_mutex);
-
-	if (hd->cnt >= ARRAY_SIZE(hdmi_dai_name)) {
-		dev_err(dev, "too many hdmi codec are detected\n");
-		return -EINVAL;
-	}
-
 	hcp->hcd = *hcd;
 	mutex_init(&hcp->current_stream_lock);
 
@@ -835,14 +768,11 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 		hcp->daidrv[i] = hdmi_i2s_dai;
 		hcp->daidrv[i].playback.channels_max =
 			hcd->max_i2s_channels;
-		hcp->daidrv[i].name = hdmi_dai_name[hd->cnt++];
 		i++;
 	}
 
-	if (hcd->spdif) {
+	if (hcd->spdif)
 		hcp->daidrv[i] = hdmi_spdif_dai;
-		hcp->daidrv[i].name = hdmi_dai_name[hd->cnt++];
-	}
 
 	ret = snd_soc_register_codec(dev, &hdmi_codec, hcp->daidrv,
 				     dai_count);
@@ -859,20 +789,8 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 static int hdmi_codec_remove(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct list_head *pos;
 	struct hdmi_codec_priv *hcp;
 
-	mutex_lock(&hdmi_mutex);
-	list_for_each(pos, &hdmi_device_list) {
-		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
-
-		if (tmp->dev == dev->parent) {
-			list_del(pos);
-			break;
-		}
-	}
-	mutex_unlock(&hdmi_mutex);
-
 	hcp = dev_get_drvdata(dev);
 	kfree(hcp->chmap_info);
 	snd_soc_unregister_codec(dev);
-- 
2.11.0

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

* Re: [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC
  2017-05-24 17:38   ` Mark Brown
@ 2017-05-24 23:34     ` Kuninori Morimoto
  2017-05-26  4:16       ` Archit Taneja
  2017-05-26 17:26       ` Mark Brown
  0 siblings, 2 replies; 17+ messages in thread
From: Kuninori Morimoto @ 2017-05-24 23:34 UTC (permalink / raw)
  To: Mark Brown
  Cc: Archit Taneja, Linux-ALSA, Simon, linux-renesas-soc,
	David Airlie, Laurent Pinchart, Russell King, Jose Abreu,
	dri-devel, linux-kernel


Hi Mark
Cc: DRM maintainer

> > ALSA SoC needs to know connected DAI ID for probing.
> > It is not a big problem if device/driver was only for sound,
> > but getting DAI ID will be difficult if device includes both
> > Video/Sound, like HDMI.
> 
> As far as I understand what's going on with the graph code this seems to
> make sense to me.  How do we want to go about handling the patch?

This is comment to me ? or DRM maintainer ?

If to me, any case (pickup by Mark, or by DRM maintainer) is OK for me

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC
  2017-05-24 23:34     ` Kuninori Morimoto
@ 2017-05-26  4:16       ` Archit Taneja
  2017-05-26  4:24         ` Archit Taneja
  2017-05-26 17:26       ` Mark Brown
  1 sibling, 1 reply; 17+ messages in thread
From: Archit Taneja @ 2017-05-26  4:16 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown
  Cc: Linux-ALSA, Simon, linux-renesas-soc, David Airlie,
	Laurent Pinchart, Russell King, Jose Abreu, dri-devel,
	linux-kernel

Hi,

On 05/25/2017 05:04 AM, Kuninori Morimoto wrote:
>
> Hi Mark
> Cc: DRM maintainer
>
>>> ALSA SoC needs to know connected DAI ID for probing.
>>> It is not a big problem if device/driver was only for sound,
>>> but getting DAI ID will be difficult if device includes both
>>> Video/Sound, like HDMI.
>>
>> As far as I understand what's going on with the graph code this seems to
>> make sense to me.  How do we want to go about handling the patch?
>
> This is comment to me ? or DRM maintainer ?
>
> If to me, any case (pickup by Mark, or by DRM maintainer) is OK for me

I'll pick it up for drm-misc-next.

Thanks,
Archit

>
> Best regards
> ---
> Kuninori Morimoto
>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC
  2017-05-26  4:16       ` Archit Taneja
@ 2017-05-26  4:24         ` Archit Taneja
  0 siblings, 0 replies; 17+ messages in thread
From: Archit Taneja @ 2017-05-26  4:24 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown
  Cc: Jose Abreu, Linux-ALSA, Laurent Pinchart, linux-kernel,
	dri-devel, linux-renesas-soc, Russell King, Simon



On 05/26/2017 09:46 AM, Archit Taneja wrote:
> Hi,
>
> On 05/25/2017 05:04 AM, Kuninori Morimoto wrote:
>>
>> Hi Mark
>> Cc: DRM maintainer
>>
>>>> ALSA SoC needs to know connected DAI ID for probing.
>>>> It is not a big problem if device/driver was only for sound,
>>>> but getting DAI ID will be difficult if device includes both
>>>> Video/Sound, like HDMI.
>>>
>>> As far as I understand what's going on with the graph code this seems to
>>> make sense to me.  How do we want to go about handling the patch?
>>
>> This is comment to me ? or DRM maintainer ?
>>
>> If to me, any case (pickup by Mark, or by DRM maintainer) is OK for me
>
> I'll pick it up for drm-misc-next.

Ah, I just saw the dependence on the previous patches.

Mark,

Please feel free to pull this to the asoc tree. You can add my Ack:

Acked-by: Archit Taneja <architt@codeaurora.org>

Thanks,
Archit

>
> Thanks,
> Archit
>
>>
>> Best regards
>> ---
>> Kuninori Morimoto
>>
>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC
  2017-05-24 23:34     ` Kuninori Morimoto
  2017-05-26  4:16       ` Archit Taneja
@ 2017-05-26 17:26       ` Mark Brown
  1 sibling, 0 replies; 17+ messages in thread
From: Mark Brown @ 2017-05-26 17:26 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Archit Taneja, Linux-ALSA, Simon, linux-renesas-soc,
	David Airlie, Laurent Pinchart, Russell King, Jose Abreu,
	dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

On Wed, May 24, 2017 at 11:34:46PM +0000, Kuninori Morimoto wrote:

> > As far as I understand what's going on with the graph code this seems to
> > make sense to me.  How do we want to go about handling the patch?

> This is comment to me ? or DRM maintainer ?

> If to me, any case (pickup by Mark, or by DRM maintainer) is OK for me

The world in general - mainly the DRM people I guess.

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

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

* [PATCH][RESEND] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC
  2017-05-18  1:38 [PATCH 0/5] ASoC: add HDMI sound support for Codec Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2017-05-18  1:40 ` [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC Kuninori Morimoto
@ 2017-06-19  0:39 ` Kuninori Morimoto
  5 siblings, 0 replies; 17+ messages in thread
From: Kuninori Morimoto @ 2017-06-19  0:39 UTC (permalink / raw)
  To: Mark Brown, Archit Taneja
  Cc: Linux-ALSA, Simon, linux-renesas-soc, David Airlie,
	Laurent Pinchart, Russell King, Jose Abreu, dri-devel,
	linux-kernel


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC needs to know connected DAI ID for probing.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new .get_dai_id callback
on hdmi_codec_ops.
dw-hdmi-i2s will assume that HDMI sound will be connected
to reg = <2>. Then, ALSA SoC side will recognized it as DAI 0

	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			/* HDMI Video IN */
		};
		port@1 {
			reg = <1>;
			/* HDMI OUT */
		};
		port@2 {
			reg = <2>;
			/* HDMI Sound IN */
		};
	};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Archit Taneja <architt@codeaurora.org>
---
v1 -> v1 resend

 - add Archit's Acked-by (= DRM maintainer)

 .../bindings/display/bridge/renesas,dw-hdmi.txt     |  9 ++++++++-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
index f6b3f36..81b6858 100644
--- a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
+++ b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
@@ -25,7 +25,8 @@ Required properties:
 - clock-names: Shall contain "iahb" and "isfr" as defined in dw_hdmi.txt.
 - ports: See dw_hdmi.txt. The DWC HDMI shall have one port numbered 0
   corresponding to the video input of the controller and one port numbered 1
-  corresponding to its HDMI output. Each port shall have a single endpoint.
+  corresponding to its HDMI output, and one port numbered 2 corresponding to
+  sound input of the controller. Each port shall have a single endpoint.
 
 Optional properties:
 
@@ -59,6 +60,12 @@ Example:
 					remote-endpoint = <&hdmi0_con>;
 				};
 			};
+			port@2 {
+				reg = <2>;
+				rcar_dw_hdmi0_sound_in: endpoint {
+					remote-endpoint = <&hdmi_sound_out>;
+				};
+			};
 		};
 	};
 
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
index aaf287d..b2cf59f 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
@@ -82,9 +82,30 @@ static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data)
 	hdmi_write(audio, HDMI_AUD_CONF0_SW_RESET, HDMI_AUD_CONF0);
 }
 
+static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,
+				  struct device_node *endpoint)
+{
+	struct of_endpoint of_ep;
+	int ret;
+
+	ret = of_graph_parse_endpoint(endpoint, &of_ep);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * HDMI sound should be located as reg = <2>
+	 * Then, it is sound port 0
+	 */
+	if (of_ep.port == 2)
+		return 0;
+
+	return -EINVAL;
+}
+
 static struct hdmi_codec_ops dw_hdmi_i2s_ops = {
 	.hw_params	= dw_hdmi_i2s_hw_params,
 	.audio_shutdown	= dw_hdmi_i2s_audio_shutdown,
+	.get_dai_id	= dw_hdmi_i2s_get_dai_id,
 };
 
 static int snd_dw_hdmi_probe(struct platform_device *pdev)
-- 
1.9.1

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

* Applied "drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC" to the asoc tree
  2017-05-18  1:40 ` [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC Kuninori Morimoto
  2017-05-24 17:38   ` Mark Brown
@ 2017-06-28 19:48   ` Mark Brown
  1 sibling, 0 replies; 17+ messages in thread
From: Mark Brown @ 2017-06-28 19:48 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Archit Taneja, Mark Brown, Mark Brown, Archit Taneja, Jose Abreu,
	Linux-ALSA, Laurent Pinchart, David Airlie, linux-kernel,
	dri-devel, linux-renesas-soc, Russell King, Simon, alsa-devel

The patch

   drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC

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 e3839bd6f56a291f00a4c3737eb15ca0344a82a9 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Mon, 19 Jun 2017 00:39:29 +0000
Subject: [PATCH] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC

ALSA SoC needs to know connected DAI ID for probing.
It is not a big problem if device/driver was only for sound,
but getting DAI ID will be difficult if device includes both
Video/Sound, like HDMI.
To solve this issue, this patch adds new .get_dai_id callback
on hdmi_codec_ops.
dw-hdmi-i2s will assume that HDMI sound will be connected
to reg = <2>. Then, ALSA SoC side will recognized it as DAI 0

	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			/* HDMI Video IN */
		};
		port@1 {
			reg = <1>;
			/* HDMI OUT */
		};
		port@2 {
			reg = <2>;
			/* HDMI Sound IN */
		};
	};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 .../bindings/display/bridge/renesas,dw-hdmi.txt     |  9 ++++++++-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
index f6b3f36d422b..81b68580e199 100644
--- a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
+++ b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
@@ -25,7 +25,8 @@ Required properties:
 - clock-names: Shall contain "iahb" and "isfr" as defined in dw_hdmi.txt.
 - ports: See dw_hdmi.txt. The DWC HDMI shall have one port numbered 0
   corresponding to the video input of the controller and one port numbered 1
-  corresponding to its HDMI output. Each port shall have a single endpoint.
+  corresponding to its HDMI output, and one port numbered 2 corresponding to
+  sound input of the controller. Each port shall have a single endpoint.
 
 Optional properties:
 
@@ -59,6 +60,12 @@ Example:
 					remote-endpoint = <&hdmi0_con>;
 				};
 			};
+			port@2 {
+				reg = <2>;
+				rcar_dw_hdmi0_sound_in: endpoint {
+					remote-endpoint = <&hdmi_sound_out>;
+				};
+			};
 		};
 	};
 
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
index aaf287d2e91d..b2cf59f54c88 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
@@ -82,9 +82,30 @@ static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data)
 	hdmi_write(audio, HDMI_AUD_CONF0_SW_RESET, HDMI_AUD_CONF0);
 }
 
+static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,
+				  struct device_node *endpoint)
+{
+	struct of_endpoint of_ep;
+	int ret;
+
+	ret = of_graph_parse_endpoint(endpoint, &of_ep);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * HDMI sound should be located as reg = <2>
+	 * Then, it is sound port 0
+	 */
+	if (of_ep.port == 2)
+		return 0;
+
+	return -EINVAL;
+}
+
 static struct hdmi_codec_ops dw_hdmi_i2s_ops = {
 	.hw_params	= dw_hdmi_i2s_hw_params,
 	.audio_shutdown	= dw_hdmi_i2s_audio_shutdown,
+	.get_dai_id	= dw_hdmi_i2s_get_dai_id,
 };
 
 static int snd_dw_hdmi_probe(struct platform_device *pdev)
-- 
2.13.2

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

end of thread, other threads:[~2017-06-28 19:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-18  1:38 [PATCH 0/5] ASoC: add HDMI sound support for Codec Kuninori Morimoto
2017-05-18  1:39 ` [PATCH 1/5] ASoC: add snd_soc_get_dai_id() function Kuninori Morimoto
2017-05-24 17:41   ` Applied "ASoC: add snd_soc_get_dai_id() function" to the asoc tree Mark Brown
2017-05-18  1:39 ` [PATCH 2/5] ASoC: simple-card-utils: support snd_soc_get_dai_id() Kuninori Morimoto
2017-05-24 17:44   ` Applied "ASoC: simple-card-utils: support snd_soc_get_dai_id()" to the asoc tree Mark Brown
2017-05-18  1:40 ` [PATCH 3/5] ASoC: hdmi-codec: remove multi detection support Kuninori Morimoto
2017-05-24 17:45   ` Applied "ASoC: hdmi-codec: remove multi detection support" to the asoc tree Mark Brown
2017-05-18  1:40 ` [PATCH 4/5] ASoC: hdmi-codec: add .get_dai_id support Kuninori Morimoto
2017-05-24 17:45   ` Applied "ASoC: hdmi-codec: add .get_dai_id support" to the asoc tree Mark Brown
2017-05-18  1:40 ` [PATCH 5/5] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC Kuninori Morimoto
2017-05-24 17:38   ` Mark Brown
2017-05-24 23:34     ` Kuninori Morimoto
2017-05-26  4:16       ` Archit Taneja
2017-05-26  4:24         ` Archit Taneja
2017-05-26 17:26       ` Mark Brown
2017-06-28 19:48   ` Applied "drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC" to the asoc tree Mark Brown
2017-06-19  0:39 ` [PATCH][RESEND] drm: dw-hdmi-i2s: add .get_dai_id callback for ALSA SoC Kuninori Morimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).