All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ASoC: mediatek: mt8183: support DP audio
@ 2019-10-22 11:44 ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:44 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: alsa-devel, devicetree, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, dri-devel, allen.chen, cychiang, dgreid, tzungbi

(This series depends on https://lore.kernel.org/patchwork/patch/1126819/
 which has not applied to the maintainer's tree yet.)

This series makes mt8183-mt6358-ts3a227-max98357 support DP (display port)
audio output.

ASoC: hdmi-codec: add PCM trigger operator
- add a PCM trigger callback if codec driver is interested in PCM events.

drm: bridge: it6505: bridge to hdmi-codec
- add audio feature support of it6505.
- bridge to hdmi-codec so that ASoC can use the audio feature. 
- defer the "enabling" after receiving PCM START or RESUME event.

ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
ASoC: mediatek: mt8183: use hdmi-codec
- bind to hdmi-codec in mt8183-mt6358-ts3a227-max98357.

drm: bridge: it6505: report connector status
ASoC: mediatek: mt8183: support HDMI jack reporting
- use the mechanism from the following patch
https://mailman.alsa-project.org/pipermail/alsa-devel/2019-September/155302.html
  to report jack status (from DRM to ASoC).

Allen Chen (1):
  drm: bridge: it6505: bridge to hdmi-codec

Tzung-Bi Shih (5):
  ASoC: hdmi-codec: add PCM trigger operator
  ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
  ASoC: mediatek: mt8183: use hdmi-codec
  drm: bridge: it6505: report connector status
  ASoC: mediatek: mt8183: support HDMI jack reporting

 .../sound/mt8183-mt6358-ts3a227-max98357.txt  |   2 +
 drivers/gpu/drm/bridge/ite-it6505.c           | 191 +++++++++++++++++-
 include/sound/hdmi-codec.h                    |  13 ++
 sound/soc/codecs/hdmi-codec.c                 |  31 +++
 sound/soc/mediatek/Kconfig                    |   3 +-
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c   |  36 +++-
 6 files changed, 266 insertions(+), 10 deletions(-)

-- 
2.23.0.866.gb869b98d4c-goog


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

* [alsa-devel] [PATCH 0/6] ASoC: mediatek: mt8183: support DP audio
@ 2019-10-22 11:44 ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:44 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

(This series depends on https://lore.kernel.org/patchwork/patch/1126819/
 which has not applied to the maintainer's tree yet.)

This series makes mt8183-mt6358-ts3a227-max98357 support DP (display port)
audio output.

ASoC: hdmi-codec: add PCM trigger operator
- add a PCM trigger callback if codec driver is interested in PCM events.

drm: bridge: it6505: bridge to hdmi-codec
- add audio feature support of it6505.
- bridge to hdmi-codec so that ASoC can use the audio feature. 
- defer the "enabling" after receiving PCM START or RESUME event.

ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
ASoC: mediatek: mt8183: use hdmi-codec
- bind to hdmi-codec in mt8183-mt6358-ts3a227-max98357.

drm: bridge: it6505: report connector status
ASoC: mediatek: mt8183: support HDMI jack reporting
- use the mechanism from the following patch
https://mailman.alsa-project.org/pipermail/alsa-devel/2019-September/155302.html
  to report jack status (from DRM to ASoC).

Allen Chen (1):
  drm: bridge: it6505: bridge to hdmi-codec

Tzung-Bi Shih (5):
  ASoC: hdmi-codec: add PCM trigger operator
  ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
  ASoC: mediatek: mt8183: use hdmi-codec
  drm: bridge: it6505: report connector status
  ASoC: mediatek: mt8183: support HDMI jack reporting

 .../sound/mt8183-mt6358-ts3a227-max98357.txt  |   2 +
 drivers/gpu/drm/bridge/ite-it6505.c           | 191 +++++++++++++++++-
 include/sound/hdmi-codec.h                    |  13 ++
 sound/soc/codecs/hdmi-codec.c                 |  31 +++
 sound/soc/mediatek/Kconfig                    |   3 +-
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c   |  36 +++-
 6 files changed, 266 insertions(+), 10 deletions(-)

-- 
2.23.0.866.gb869b98d4c-goog

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH 0/6] ASoC: mediatek: mt8183: support DP audio
@ 2019-10-22 11:44 ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:44 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

(This series depends on https://lore.kernel.org/patchwork/patch/1126819/
 which has not applied to the maintainer's tree yet.)

This series makes mt8183-mt6358-ts3a227-max98357 support DP (display port)
audio output.

ASoC: hdmi-codec: add PCM trigger operator
- add a PCM trigger callback if codec driver is interested in PCM events.

drm: bridge: it6505: bridge to hdmi-codec
- add audio feature support of it6505.
- bridge to hdmi-codec so that ASoC can use the audio feature. 
- defer the "enabling" after receiving PCM START or RESUME event.

ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
ASoC: mediatek: mt8183: use hdmi-codec
- bind to hdmi-codec in mt8183-mt6358-ts3a227-max98357.

drm: bridge: it6505: report connector status
ASoC: mediatek: mt8183: support HDMI jack reporting
- use the mechanism from the following patch
https://mailman.alsa-project.org/pipermail/alsa-devel/2019-September/155302.html
  to report jack status (from DRM to ASoC).

Allen Chen (1):
  drm: bridge: it6505: bridge to hdmi-codec

Tzung-Bi Shih (5):
  ASoC: hdmi-codec: add PCM trigger operator
  ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
  ASoC: mediatek: mt8183: use hdmi-codec
  drm: bridge: it6505: report connector status
  ASoC: mediatek: mt8183: support HDMI jack reporting

 .../sound/mt8183-mt6358-ts3a227-max98357.txt  |   2 +
 drivers/gpu/drm/bridge/ite-it6505.c           | 191 +++++++++++++++++-
 include/sound/hdmi-codec.h                    |  13 ++
 sound/soc/codecs/hdmi-codec.c                 |  31 +++
 sound/soc/mediatek/Kconfig                    |   3 +-
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c   |  36 +++-
 6 files changed, 266 insertions(+), 10 deletions(-)

-- 
2.23.0.866.gb869b98d4c-goog

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

* [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator
  2019-10-22 11:44 ` [alsa-devel] " Tzung-Bi Shih
  (?)
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  -1 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: alsa-devel, devicetree, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, dri-devel, allen.chen, cychiang, dgreid, tzungbi

HDMI codec may be also interested in PCM triggers.  Add PCM trigger
operator.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 include/sound/hdmi-codec.h    | 13 +++++++++++++
 sound/soc/codecs/hdmi-codec.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 83b17682e01c..9de462ef170d 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -50,6 +50,13 @@ struct hdmi_codec_params {
 typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
 				      bool plugged);
 
+enum {
+	HDMI_CODEC_TRIGGER_EVENT_STOP,
+	HDMI_CODEC_TRIGGER_EVENT_START,
+	HDMI_CODEC_TRIGGER_EVENT_SUSPEND,
+	HDMI_CODEC_TRIGGER_EVENT_RESUME,
+};
+
 struct hdmi_codec_pdata;
 struct hdmi_codec_ops {
 	/*
@@ -66,6 +73,12 @@ struct hdmi_codec_ops {
 			 struct hdmi_codec_daifmt *fmt,
 			 struct hdmi_codec_params *hparms);
 
+	/*
+	 * PCM trigger callback.
+	 * Optional
+	 */
+	int (*trigger)(struct device *dev, int event);
+
 	/*
 	 * Shuts down the audio stream.
 	 * Mandatory
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index b5fd8f08726e..1ba2fa26ba03 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -565,12 +565,42 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute)
 	return 0;
 }
 
+static int hdmi_codec_trigger(struct snd_pcm_substream *substream, int cmd,
+			      struct snd_soc_dai *dai)
+{
+	struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
+	int event;
+
+	if (!hcp->hcd.ops->trigger)
+		return 0;
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_STOP:
+		event = HDMI_CODEC_TRIGGER_EVENT_STOP;
+		break;
+	case SNDRV_PCM_TRIGGER_START:
+		event = HDMI_CODEC_TRIGGER_EVENT_START;
+		break;
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+		event = HDMI_CODEC_TRIGGER_EVENT_SUSPEND;
+		break;
+	case SNDRV_PCM_TRIGGER_RESUME:
+		event = HDMI_CODEC_TRIGGER_EVENT_RESUME;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return hcp->hcd.ops->trigger(dai->dev->parent, event);
+}
+
 static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
 	.startup	= hdmi_codec_startup,
 	.shutdown	= hdmi_codec_shutdown,
 	.hw_params	= hdmi_codec_hw_params,
 	.set_fmt	= hdmi_codec_i2s_set_fmt,
 	.digital_mute	= hdmi_codec_digital_mute,
+	.trigger	= hdmi_codec_trigger,
 };
 
 static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
@@ -578,6 +608,7 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
 	.shutdown	= hdmi_codec_shutdown,
 	.hw_params	= hdmi_codec_hw_params,
 	.digital_mute	= hdmi_codec_digital_mute,
+	.trigger	= hdmi_codec_trigger,
 };
 
 #define HDMI_RATES	(SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
-- 
2.23.0.866.gb869b98d4c-goog


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

* [alsa-devel] [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

HDMI codec may be also interested in PCM triggers.  Add PCM trigger
operator.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 include/sound/hdmi-codec.h    | 13 +++++++++++++
 sound/soc/codecs/hdmi-codec.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 83b17682e01c..9de462ef170d 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -50,6 +50,13 @@ struct hdmi_codec_params {
 typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
 				      bool plugged);
 
+enum {
+	HDMI_CODEC_TRIGGER_EVENT_STOP,
+	HDMI_CODEC_TRIGGER_EVENT_START,
+	HDMI_CODEC_TRIGGER_EVENT_SUSPEND,
+	HDMI_CODEC_TRIGGER_EVENT_RESUME,
+};
+
 struct hdmi_codec_pdata;
 struct hdmi_codec_ops {
 	/*
@@ -66,6 +73,12 @@ struct hdmi_codec_ops {
 			 struct hdmi_codec_daifmt *fmt,
 			 struct hdmi_codec_params *hparms);
 
+	/*
+	 * PCM trigger callback.
+	 * Optional
+	 */
+	int (*trigger)(struct device *dev, int event);
+
 	/*
 	 * Shuts down the audio stream.
 	 * Mandatory
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index b5fd8f08726e..1ba2fa26ba03 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -565,12 +565,42 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute)
 	return 0;
 }
 
+static int hdmi_codec_trigger(struct snd_pcm_substream *substream, int cmd,
+			      struct snd_soc_dai *dai)
+{
+	struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
+	int event;
+
+	if (!hcp->hcd.ops->trigger)
+		return 0;
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_STOP:
+		event = HDMI_CODEC_TRIGGER_EVENT_STOP;
+		break;
+	case SNDRV_PCM_TRIGGER_START:
+		event = HDMI_CODEC_TRIGGER_EVENT_START;
+		break;
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+		event = HDMI_CODEC_TRIGGER_EVENT_SUSPEND;
+		break;
+	case SNDRV_PCM_TRIGGER_RESUME:
+		event = HDMI_CODEC_TRIGGER_EVENT_RESUME;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return hcp->hcd.ops->trigger(dai->dev->parent, event);
+}
+
 static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
 	.startup	= hdmi_codec_startup,
 	.shutdown	= hdmi_codec_shutdown,
 	.hw_params	= hdmi_codec_hw_params,
 	.set_fmt	= hdmi_codec_i2s_set_fmt,
 	.digital_mute	= hdmi_codec_digital_mute,
+	.trigger	= hdmi_codec_trigger,
 };
 
 static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
@@ -578,6 +608,7 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
 	.shutdown	= hdmi_codec_shutdown,
 	.hw_params	= hdmi_codec_hw_params,
 	.digital_mute	= hdmi_codec_digital_mute,
+	.trigger	= hdmi_codec_trigger,
 };
 
 #define HDMI_RATES	(SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
-- 
2.23.0.866.gb869b98d4c-goog

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

HDMI codec may be also interested in PCM triggers.  Add PCM trigger
operator.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 include/sound/hdmi-codec.h    | 13 +++++++++++++
 sound/soc/codecs/hdmi-codec.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 83b17682e01c..9de462ef170d 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -50,6 +50,13 @@ struct hdmi_codec_params {
 typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
 				      bool plugged);
 
+enum {
+	HDMI_CODEC_TRIGGER_EVENT_STOP,
+	HDMI_CODEC_TRIGGER_EVENT_START,
+	HDMI_CODEC_TRIGGER_EVENT_SUSPEND,
+	HDMI_CODEC_TRIGGER_EVENT_RESUME,
+};
+
 struct hdmi_codec_pdata;
 struct hdmi_codec_ops {
 	/*
@@ -66,6 +73,12 @@ struct hdmi_codec_ops {
 			 struct hdmi_codec_daifmt *fmt,
 			 struct hdmi_codec_params *hparms);
 
+	/*
+	 * PCM trigger callback.
+	 * Optional
+	 */
+	int (*trigger)(struct device *dev, int event);
+
 	/*
 	 * Shuts down the audio stream.
 	 * Mandatory
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index b5fd8f08726e..1ba2fa26ba03 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -565,12 +565,42 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute)
 	return 0;
 }
 
+static int hdmi_codec_trigger(struct snd_pcm_substream *substream, int cmd,
+			      struct snd_soc_dai *dai)
+{
+	struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
+	int event;
+
+	if (!hcp->hcd.ops->trigger)
+		return 0;
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_STOP:
+		event = HDMI_CODEC_TRIGGER_EVENT_STOP;
+		break;
+	case SNDRV_PCM_TRIGGER_START:
+		event = HDMI_CODEC_TRIGGER_EVENT_START;
+		break;
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+		event = HDMI_CODEC_TRIGGER_EVENT_SUSPEND;
+		break;
+	case SNDRV_PCM_TRIGGER_RESUME:
+		event = HDMI_CODEC_TRIGGER_EVENT_RESUME;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return hcp->hcd.ops->trigger(dai->dev->parent, event);
+}
+
 static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
 	.startup	= hdmi_codec_startup,
 	.shutdown	= hdmi_codec_shutdown,
 	.hw_params	= hdmi_codec_hw_params,
 	.set_fmt	= hdmi_codec_i2s_set_fmt,
 	.digital_mute	= hdmi_codec_digital_mute,
+	.trigger	= hdmi_codec_trigger,
 };
 
 static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
@@ -578,6 +608,7 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
 	.shutdown	= hdmi_codec_shutdown,
 	.hw_params	= hdmi_codec_hw_params,
 	.digital_mute	= hdmi_codec_digital_mute,
+	.trigger	= hdmi_codec_trigger,
 };
 
 #define HDMI_RATES	(SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
-- 
2.23.0.866.gb869b98d4c-goog

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

* [PATCH 2/6] drm: bridge: it6505: bridge to hdmi-codec
  2019-10-22 11:44 ` [alsa-devel] " Tzung-Bi Shih
  (?)
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  -1 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: alsa-devel, devicetree, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, dri-devel, allen.chen, cychiang, dgreid, tzungbi

From: Allen Chen <allen.chen@ite.com.tw>

Bridge to hdmi-codec to support audio feature.

It is observed that some DP-to-HDMI dongles will get into bad states
if sending InfoFrame without audio data.  Defer to enable it6505's
audio feature when PCM triggers START or RESUME.

Signed-off-by: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/gpu/drm/bridge/ite-it6505.c | 152 ++++++++++++++++++++++++++++
 1 file changed, 152 insertions(+)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 5e046f677343..1d19184d2056 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -26,6 +26,8 @@
 #include <drm/drm_dp_helper.h>
 #include <drm/drm_edid.h>
 
+#include <sound/hdmi-codec.h>
+
 #define AX 0
 #define BX 1
 #define AUDSEL I2S
@@ -146,6 +148,7 @@ struct it6505 {
 	struct notifier_block event_nb;
 	struct extcon_dev *extcon;
 	struct work_struct extcon_wq;
+	struct delayed_work delayed_audio;
 	enum sys_status status;
 	bool hbr;
 	u8 en_ssc;
@@ -1223,6 +1226,149 @@ static void it6505_set_audio(struct it6505 *it6505)
 	dptxset(it6505, 0xD3, 0x20, 0x00);
 }
 
+static void it6505_delayed_audio(struct work_struct *work)
+{
+	struct it6505 *it6505 = container_of(work, struct it6505,
+					     delayed_audio.work);
+
+	it6505_set_audio(it6505);
+	it6505->en_audio = 1;
+}
+
+static int it6505_audio_hw_params(struct device *dev, void *data,
+				  struct hdmi_codec_daifmt *daifmt,
+				  struct hdmi_codec_params *params)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+	unsigned int channel_num = params->cea.channels;
+
+	DRM_DEV_DEBUG_DRIVER(dev, "setting %d Hz, %d bit, %d channels\n",
+			     params->sample_rate, params->sample_width,
+			     channel_num);
+
+	if (!it6505->bridge.encoder)
+		return -ENODEV;
+
+	switch (params->sample_rate) {
+	case 24000:
+		it6505->aud_fs = AUD24K;
+		break;
+	case 32000:
+		it6505->aud_fs = AUD32K;
+		break;
+	case 44100:
+		it6505->aud_fs = AUD44P1K;
+		break;
+	case 48000:
+		it6505->aud_fs = AUD48K;
+		break;
+	case 88200:
+		it6505->aud_fs = AUD88P2K;
+		break;
+	case 96000:
+		it6505->aud_fs = AUD96K;
+		break;
+	case 176400:
+		it6505->aud_fs = AUD176P4K;
+		break;
+	case 192000:
+		it6505->aud_fs = AUD192K;
+		break;
+	default:
+		DRM_DEV_DEBUG_DRIVER(dev, "sample rate: %d Hz not support",
+				     params->sample_rate);
+		return -EINVAL;
+	}
+
+	switch (params->sample_width) {
+	case 16:
+		it6505->audwordlength = AUD16BIT;
+		break;
+	case 18:
+		it6505->audwordlength = AUD18BIT;
+		break;
+	case 20:
+		it6505->audwordlength = AUD20BIT;
+		break;
+	case 24:
+	case 32:
+		it6505->audwordlength = AUD24BIT;
+		break;
+	default:
+		DRM_DEV_DEBUG_DRIVER(dev, "wordlength: %d bit not support",
+				     params->sample_width);
+		return -EINVAL;
+	}
+
+	if (channel_num == 0 || channel_num % 2) {
+		DRM_DEV_DEBUG_DRIVER(dev, "channel number: %d not support",
+				     channel_num);
+		return -EINVAL;
+	}
+	it6505->aud_ch = channel_num;
+
+	return 0;
+}
+
+static int it6505_audio_trigger(struct device *dev, int event)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+
+	DRM_DEV_DEBUG_DRIVER(dev, "event: %d", event);
+	switch (event) {
+	case HDMI_CODEC_TRIGGER_EVENT_START:
+	case HDMI_CODEC_TRIGGER_EVENT_RESUME:
+		queue_delayed_work(system_wq, &it6505->delayed_audio,
+				   msecs_to_jiffies(180));
+		break;
+	case HDMI_CODEC_TRIGGER_EVENT_STOP:
+	case HDMI_CODEC_TRIGGER_EVENT_SUSPEND:
+		cancel_delayed_work(&it6505->delayed_audio);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void it6505_audio_shutdown(struct device *dev, void *data)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+
+	dptxset(it6505, 0xE8, 0x22, 0x00);
+	dptxset(it6505, 0x05, 0x02, 0x02);
+	it6505->en_audio = 0;
+}
+
+static const struct hdmi_codec_ops it6505_audio_codec_ops = {
+	.hw_params = it6505_audio_hw_params,
+	.trigger = it6505_audio_trigger,
+	.audio_shutdown = it6505_audio_shutdown,
+};
+
+static int it6505_register_audio_driver(struct device *dev)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+	struct hdmi_codec_pdata codec_data = {
+		.ops = &it6505_audio_codec_ops,
+		.max_i2s_channels = 8,
+		.i2s = 1,
+	};
+	struct platform_device *pdev;
+
+	pdev = platform_device_register_data(dev, HDMI_CODEC_DRV_NAME,
+					     PLATFORM_DEVID_AUTO, &codec_data,
+					     sizeof(codec_data));
+	if (IS_ERR(pdev))
+		return PTR_ERR(pdev);
+
+	INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio);
+
+	DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME);
+	return 0;
+}
+
 /***************************************************************************
  * DPCD Read and EDID
  ***************************************************************************/
@@ -2460,6 +2606,12 @@ static int it6505_i2c_probe(struct i2c_client *client,
 		return err;
 	}
 
+	err = it6505_register_audio_driver(dev);
+	if (err < 0) {
+		DRM_DEV_ERROR(dev, "Failed to register audio driver: %d", err);
+		return err;
+	}
+
 	/* Register aux channel */
 	it6505->aux.name = "DP-AUX";
 	it6505->aux.dev = dev;
-- 
2.23.0.866.gb869b98d4c-goog


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

* [alsa-devel] [PATCH 2/6] drm: bridge: it6505: bridge to hdmi-codec
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

From: Allen Chen <allen.chen@ite.com.tw>

Bridge to hdmi-codec to support audio feature.

It is observed that some DP-to-HDMI dongles will get into bad states
if sending InfoFrame without audio data.  Defer to enable it6505's
audio feature when PCM triggers START or RESUME.

Signed-off-by: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/gpu/drm/bridge/ite-it6505.c | 152 ++++++++++++++++++++++++++++
 1 file changed, 152 insertions(+)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 5e046f677343..1d19184d2056 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -26,6 +26,8 @@
 #include <drm/drm_dp_helper.h>
 #include <drm/drm_edid.h>
 
+#include <sound/hdmi-codec.h>
+
 #define AX 0
 #define BX 1
 #define AUDSEL I2S
@@ -146,6 +148,7 @@ struct it6505 {
 	struct notifier_block event_nb;
 	struct extcon_dev *extcon;
 	struct work_struct extcon_wq;
+	struct delayed_work delayed_audio;
 	enum sys_status status;
 	bool hbr;
 	u8 en_ssc;
@@ -1223,6 +1226,149 @@ static void it6505_set_audio(struct it6505 *it6505)
 	dptxset(it6505, 0xD3, 0x20, 0x00);
 }
 
+static void it6505_delayed_audio(struct work_struct *work)
+{
+	struct it6505 *it6505 = container_of(work, struct it6505,
+					     delayed_audio.work);
+
+	it6505_set_audio(it6505);
+	it6505->en_audio = 1;
+}
+
+static int it6505_audio_hw_params(struct device *dev, void *data,
+				  struct hdmi_codec_daifmt *daifmt,
+				  struct hdmi_codec_params *params)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+	unsigned int channel_num = params->cea.channels;
+
+	DRM_DEV_DEBUG_DRIVER(dev, "setting %d Hz, %d bit, %d channels\n",
+			     params->sample_rate, params->sample_width,
+			     channel_num);
+
+	if (!it6505->bridge.encoder)
+		return -ENODEV;
+
+	switch (params->sample_rate) {
+	case 24000:
+		it6505->aud_fs = AUD24K;
+		break;
+	case 32000:
+		it6505->aud_fs = AUD32K;
+		break;
+	case 44100:
+		it6505->aud_fs = AUD44P1K;
+		break;
+	case 48000:
+		it6505->aud_fs = AUD48K;
+		break;
+	case 88200:
+		it6505->aud_fs = AUD88P2K;
+		break;
+	case 96000:
+		it6505->aud_fs = AUD96K;
+		break;
+	case 176400:
+		it6505->aud_fs = AUD176P4K;
+		break;
+	case 192000:
+		it6505->aud_fs = AUD192K;
+		break;
+	default:
+		DRM_DEV_DEBUG_DRIVER(dev, "sample rate: %d Hz not support",
+				     params->sample_rate);
+		return -EINVAL;
+	}
+
+	switch (params->sample_width) {
+	case 16:
+		it6505->audwordlength = AUD16BIT;
+		break;
+	case 18:
+		it6505->audwordlength = AUD18BIT;
+		break;
+	case 20:
+		it6505->audwordlength = AUD20BIT;
+		break;
+	case 24:
+	case 32:
+		it6505->audwordlength = AUD24BIT;
+		break;
+	default:
+		DRM_DEV_DEBUG_DRIVER(dev, "wordlength: %d bit not support",
+				     params->sample_width);
+		return -EINVAL;
+	}
+
+	if (channel_num == 0 || channel_num % 2) {
+		DRM_DEV_DEBUG_DRIVER(dev, "channel number: %d not support",
+				     channel_num);
+		return -EINVAL;
+	}
+	it6505->aud_ch = channel_num;
+
+	return 0;
+}
+
+static int it6505_audio_trigger(struct device *dev, int event)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+
+	DRM_DEV_DEBUG_DRIVER(dev, "event: %d", event);
+	switch (event) {
+	case HDMI_CODEC_TRIGGER_EVENT_START:
+	case HDMI_CODEC_TRIGGER_EVENT_RESUME:
+		queue_delayed_work(system_wq, &it6505->delayed_audio,
+				   msecs_to_jiffies(180));
+		break;
+	case HDMI_CODEC_TRIGGER_EVENT_STOP:
+	case HDMI_CODEC_TRIGGER_EVENT_SUSPEND:
+		cancel_delayed_work(&it6505->delayed_audio);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void it6505_audio_shutdown(struct device *dev, void *data)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+
+	dptxset(it6505, 0xE8, 0x22, 0x00);
+	dptxset(it6505, 0x05, 0x02, 0x02);
+	it6505->en_audio = 0;
+}
+
+static const struct hdmi_codec_ops it6505_audio_codec_ops = {
+	.hw_params = it6505_audio_hw_params,
+	.trigger = it6505_audio_trigger,
+	.audio_shutdown = it6505_audio_shutdown,
+};
+
+static int it6505_register_audio_driver(struct device *dev)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+	struct hdmi_codec_pdata codec_data = {
+		.ops = &it6505_audio_codec_ops,
+		.max_i2s_channels = 8,
+		.i2s = 1,
+	};
+	struct platform_device *pdev;
+
+	pdev = platform_device_register_data(dev, HDMI_CODEC_DRV_NAME,
+					     PLATFORM_DEVID_AUTO, &codec_data,
+					     sizeof(codec_data));
+	if (IS_ERR(pdev))
+		return PTR_ERR(pdev);
+
+	INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio);
+
+	DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME);
+	return 0;
+}
+
 /***************************************************************************
  * DPCD Read and EDID
  ***************************************************************************/
@@ -2460,6 +2606,12 @@ static int it6505_i2c_probe(struct i2c_client *client,
 		return err;
 	}
 
+	err = it6505_register_audio_driver(dev);
+	if (err < 0) {
+		DRM_DEV_ERROR(dev, "Failed to register audio driver: %d", err);
+		return err;
+	}
+
 	/* Register aux channel */
 	it6505->aux.name = "DP-AUX";
 	it6505->aux.dev = dev;
-- 
2.23.0.866.gb869b98d4c-goog

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH 2/6] drm: bridge: it6505: bridge to hdmi-codec
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

From: Allen Chen <allen.chen@ite.com.tw>

Bridge to hdmi-codec to support audio feature.

It is observed that some DP-to-HDMI dongles will get into bad states
if sending InfoFrame without audio data.  Defer to enable it6505's
audio feature when PCM triggers START or RESUME.

Signed-off-by: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/gpu/drm/bridge/ite-it6505.c | 152 ++++++++++++++++++++++++++++
 1 file changed, 152 insertions(+)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 5e046f677343..1d19184d2056 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -26,6 +26,8 @@
 #include <drm/drm_dp_helper.h>
 #include <drm/drm_edid.h>
 
+#include <sound/hdmi-codec.h>
+
 #define AX 0
 #define BX 1
 #define AUDSEL I2S
@@ -146,6 +148,7 @@ struct it6505 {
 	struct notifier_block event_nb;
 	struct extcon_dev *extcon;
 	struct work_struct extcon_wq;
+	struct delayed_work delayed_audio;
 	enum sys_status status;
 	bool hbr;
 	u8 en_ssc;
@@ -1223,6 +1226,149 @@ static void it6505_set_audio(struct it6505 *it6505)
 	dptxset(it6505, 0xD3, 0x20, 0x00);
 }
 
+static void it6505_delayed_audio(struct work_struct *work)
+{
+	struct it6505 *it6505 = container_of(work, struct it6505,
+					     delayed_audio.work);
+
+	it6505_set_audio(it6505);
+	it6505->en_audio = 1;
+}
+
+static int it6505_audio_hw_params(struct device *dev, void *data,
+				  struct hdmi_codec_daifmt *daifmt,
+				  struct hdmi_codec_params *params)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+	unsigned int channel_num = params->cea.channels;
+
+	DRM_DEV_DEBUG_DRIVER(dev, "setting %d Hz, %d bit, %d channels\n",
+			     params->sample_rate, params->sample_width,
+			     channel_num);
+
+	if (!it6505->bridge.encoder)
+		return -ENODEV;
+
+	switch (params->sample_rate) {
+	case 24000:
+		it6505->aud_fs = AUD24K;
+		break;
+	case 32000:
+		it6505->aud_fs = AUD32K;
+		break;
+	case 44100:
+		it6505->aud_fs = AUD44P1K;
+		break;
+	case 48000:
+		it6505->aud_fs = AUD48K;
+		break;
+	case 88200:
+		it6505->aud_fs = AUD88P2K;
+		break;
+	case 96000:
+		it6505->aud_fs = AUD96K;
+		break;
+	case 176400:
+		it6505->aud_fs = AUD176P4K;
+		break;
+	case 192000:
+		it6505->aud_fs = AUD192K;
+		break;
+	default:
+		DRM_DEV_DEBUG_DRIVER(dev, "sample rate: %d Hz not support",
+				     params->sample_rate);
+		return -EINVAL;
+	}
+
+	switch (params->sample_width) {
+	case 16:
+		it6505->audwordlength = AUD16BIT;
+		break;
+	case 18:
+		it6505->audwordlength = AUD18BIT;
+		break;
+	case 20:
+		it6505->audwordlength = AUD20BIT;
+		break;
+	case 24:
+	case 32:
+		it6505->audwordlength = AUD24BIT;
+		break;
+	default:
+		DRM_DEV_DEBUG_DRIVER(dev, "wordlength: %d bit not support",
+				     params->sample_width);
+		return -EINVAL;
+	}
+
+	if (channel_num == 0 || channel_num % 2) {
+		DRM_DEV_DEBUG_DRIVER(dev, "channel number: %d not support",
+				     channel_num);
+		return -EINVAL;
+	}
+	it6505->aud_ch = channel_num;
+
+	return 0;
+}
+
+static int it6505_audio_trigger(struct device *dev, int event)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+
+	DRM_DEV_DEBUG_DRIVER(dev, "event: %d", event);
+	switch (event) {
+	case HDMI_CODEC_TRIGGER_EVENT_START:
+	case HDMI_CODEC_TRIGGER_EVENT_RESUME:
+		queue_delayed_work(system_wq, &it6505->delayed_audio,
+				   msecs_to_jiffies(180));
+		break;
+	case HDMI_CODEC_TRIGGER_EVENT_STOP:
+	case HDMI_CODEC_TRIGGER_EVENT_SUSPEND:
+		cancel_delayed_work(&it6505->delayed_audio);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void it6505_audio_shutdown(struct device *dev, void *data)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+
+	dptxset(it6505, 0xE8, 0x22, 0x00);
+	dptxset(it6505, 0x05, 0x02, 0x02);
+	it6505->en_audio = 0;
+}
+
+static const struct hdmi_codec_ops it6505_audio_codec_ops = {
+	.hw_params = it6505_audio_hw_params,
+	.trigger = it6505_audio_trigger,
+	.audio_shutdown = it6505_audio_shutdown,
+};
+
+static int it6505_register_audio_driver(struct device *dev)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+	struct hdmi_codec_pdata codec_data = {
+		.ops = &it6505_audio_codec_ops,
+		.max_i2s_channels = 8,
+		.i2s = 1,
+	};
+	struct platform_device *pdev;
+
+	pdev = platform_device_register_data(dev, HDMI_CODEC_DRV_NAME,
+					     PLATFORM_DEVID_AUTO, &codec_data,
+					     sizeof(codec_data));
+	if (IS_ERR(pdev))
+		return PTR_ERR(pdev);
+
+	INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio);
+
+	DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME);
+	return 0;
+}
+
 /***************************************************************************
  * DPCD Read and EDID
  ***************************************************************************/
@@ -2460,6 +2606,12 @@ static int it6505_i2c_probe(struct i2c_client *client,
 		return err;
 	}
 
+	err = it6505_register_audio_driver(dev);
+	if (err < 0) {
+		DRM_DEV_ERROR(dev, "Failed to register audio driver: %d", err);
+		return err;
+	}
+
 	/* Register aux channel */
 	it6505->aux.name = "DP-AUX";
 	it6505->aux.dev = dev;
-- 
2.23.0.866.gb869b98d4c-goog

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

* [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
  2019-10-22 11:44 ` [alsa-devel] " Tzung-Bi Shih
  (?)
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  -1 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: alsa-devel, devicetree, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, dri-devel, allen.chen, cychiang, dgreid, tzungbi

Add an optional property "mediatek,hdmi-codec".

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../bindings/sound/mt8183-mt6358-ts3a227-max98357.txt           | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt b/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
index decaa013a07e..cc2845287e61 100644
--- a/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
+++ b/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
@@ -8,6 +8,7 @@ Optional properties:
 - mediatek,headset-codec: the phandles of ts3a227 codecs
 - mediatek,ec-codec: the phandle of EC codecs.
                      See google,cros-ec-codec.txt for more details.
+- mediatek,hdmi-codec: the phandles of HDMI codec
 
 Example:
 
@@ -15,6 +16,7 @@ Example:
 		compatible = "mediatek,mt8183_mt6358_ts3a227_max98357";
 		mediatek,headset-codec = <&ts3a227>;
 		mediatek,ec-codec = <&ec_codec>;
+		mediatek,hdmi-codec = <&it6505dptx>;
 		mediatek,platform = <&afe>;
 	};
 
-- 
2.23.0.866.gb869b98d4c-goog


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

* [alsa-devel] [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek, hdmi-codec"
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

Add an optional property "mediatek,hdmi-codec".

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../bindings/sound/mt8183-mt6358-ts3a227-max98357.txt           | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt b/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
index decaa013a07e..cc2845287e61 100644
--- a/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
+++ b/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
@@ -8,6 +8,7 @@ Optional properties:
 - mediatek,headset-codec: the phandles of ts3a227 codecs
 - mediatek,ec-codec: the phandle of EC codecs.
                      See google,cros-ec-codec.txt for more details.
+- mediatek,hdmi-codec: the phandles of HDMI codec
 
 Example:
 
@@ -15,6 +16,7 @@ Example:
 		compatible = "mediatek,mt8183_mt6358_ts3a227_max98357";
 		mediatek,headset-codec = <&ts3a227>;
 		mediatek,ec-codec = <&ec_codec>;
+		mediatek,hdmi-codec = <&it6505dptx>;
 		mediatek,platform = <&afe>;
 	};
 
-- 
2.23.0.866.gb869b98d4c-goog

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek, hdmi-codec"
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

Add an optional property "mediatek,hdmi-codec".

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../bindings/sound/mt8183-mt6358-ts3a227-max98357.txt           | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt b/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
index decaa013a07e..cc2845287e61 100644
--- a/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
+++ b/Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
@@ -8,6 +8,7 @@ Optional properties:
 - mediatek,headset-codec: the phandles of ts3a227 codecs
 - mediatek,ec-codec: the phandle of EC codecs.
                      See google,cros-ec-codec.txt for more details.
+- mediatek,hdmi-codec: the phandles of HDMI codec
 
 Example:
 
@@ -15,6 +16,7 @@ Example:
 		compatible = "mediatek,mt8183_mt6358_ts3a227_max98357";
 		mediatek,headset-codec = <&ts3a227>;
 		mediatek,ec-codec = <&ec_codec>;
+		mediatek,hdmi-codec = <&it6505dptx>;
 		mediatek,platform = <&afe>;
 	};
 
-- 
2.23.0.866.gb869b98d4c-goog

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

* [PATCH 4/6] ASoC: mediatek: mt8183: use hdmi-codec
  2019-10-22 11:44 ` [alsa-devel] " Tzung-Bi Shih
  (?)
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  -1 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: alsa-devel, devicetree, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, dri-devel, allen.chen, cychiang, dgreid, tzungbi

Add DAI link to use hdmi-codec.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c      | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
index 0555f7d73d05..258f1416fae1 100644
--- a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
+++ b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
@@ -191,7 +191,7 @@ SND_SOC_DAILINK_DEFS(i2s5,
 
 SND_SOC_DAILINK_DEFS(tdm,
 	DAILINK_COMP_ARRAY(COMP_CPU("TDM")),
-	DAILINK_COMP_ARRAY(COMP_DUMMY()),
+	DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "i2s-hifi")),
 	DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 static int mt8183_mt6358_tdm_startup(struct snd_pcm_substream *substream)
@@ -479,7 +479,7 @@ static int
 mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &mt8183_mt6358_ts3a227_max98357_card;
-	struct device_node *platform_node, *ec_codec;
+	struct device_node *platform_node, *ec_codec, *hdmi_codec;
 	struct snd_soc_dai_link *dai_link;
 	struct mt8183_mt6358_ts3a227_max98357_priv *priv;
 	int ret;
@@ -496,9 +496,12 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 
 	ec_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,ec-codec", 0);
 
+	hdmi_codec = of_parse_phandle(pdev->dev.of_node,
+				      "mediatek,hdmi-codec", 0);
+
 	for_each_card_prelinks(card, i, dai_link) {
-		if (dai_link->platforms->name)
-			continue;
+		if (!dai_link->platforms->name)
+			dai_link->platforms->of_node = platform_node;
 
 		if (ec_codec && strcmp(dai_link->name, "Wake on Voice") == 0) {
 			dai_link->cpus[0].name = NULL;
@@ -509,9 +512,10 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 			dai_link->codecs[0].dai_name = "Wake on Voice";
 			dai_link->platforms[0].of_node = ec_codec;
 			dai_link->ignore = 0;
-		} else {
-			dai_link->platforms->of_node = platform_node;
 		}
+
+		if (hdmi_codec && strcmp(dai_link->name, "TDM") == 0)
+			dai_link->codecs->of_node = hdmi_codec;
 	}
 
 	mt8183_mt6358_ts3a227_max98357_headset_dev.dlc.of_node =
-- 
2.23.0.866.gb869b98d4c-goog


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

* [alsa-devel] [PATCH 4/6] ASoC: mediatek: mt8183: use hdmi-codec
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

Add DAI link to use hdmi-codec.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c      | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
index 0555f7d73d05..258f1416fae1 100644
--- a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
+++ b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
@@ -191,7 +191,7 @@ SND_SOC_DAILINK_DEFS(i2s5,
 
 SND_SOC_DAILINK_DEFS(tdm,
 	DAILINK_COMP_ARRAY(COMP_CPU("TDM")),
-	DAILINK_COMP_ARRAY(COMP_DUMMY()),
+	DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "i2s-hifi")),
 	DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 static int mt8183_mt6358_tdm_startup(struct snd_pcm_substream *substream)
@@ -479,7 +479,7 @@ static int
 mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &mt8183_mt6358_ts3a227_max98357_card;
-	struct device_node *platform_node, *ec_codec;
+	struct device_node *platform_node, *ec_codec, *hdmi_codec;
 	struct snd_soc_dai_link *dai_link;
 	struct mt8183_mt6358_ts3a227_max98357_priv *priv;
 	int ret;
@@ -496,9 +496,12 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 
 	ec_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,ec-codec", 0);
 
+	hdmi_codec = of_parse_phandle(pdev->dev.of_node,
+				      "mediatek,hdmi-codec", 0);
+
 	for_each_card_prelinks(card, i, dai_link) {
-		if (dai_link->platforms->name)
-			continue;
+		if (!dai_link->platforms->name)
+			dai_link->platforms->of_node = platform_node;
 
 		if (ec_codec && strcmp(dai_link->name, "Wake on Voice") == 0) {
 			dai_link->cpus[0].name = NULL;
@@ -509,9 +512,10 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 			dai_link->codecs[0].dai_name = "Wake on Voice";
 			dai_link->platforms[0].of_node = ec_codec;
 			dai_link->ignore = 0;
-		} else {
-			dai_link->platforms->of_node = platform_node;
 		}
+
+		if (hdmi_codec && strcmp(dai_link->name, "TDM") == 0)
+			dai_link->codecs->of_node = hdmi_codec;
 	}
 
 	mt8183_mt6358_ts3a227_max98357_headset_dev.dlc.of_node =
-- 
2.23.0.866.gb869b98d4c-goog

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH 4/6] ASoC: mediatek: mt8183: use hdmi-codec
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

Add DAI link to use hdmi-codec.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c      | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
index 0555f7d73d05..258f1416fae1 100644
--- a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
+++ b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
@@ -191,7 +191,7 @@ SND_SOC_DAILINK_DEFS(i2s5,
 
 SND_SOC_DAILINK_DEFS(tdm,
 	DAILINK_COMP_ARRAY(COMP_CPU("TDM")),
-	DAILINK_COMP_ARRAY(COMP_DUMMY()),
+	DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "i2s-hifi")),
 	DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 static int mt8183_mt6358_tdm_startup(struct snd_pcm_substream *substream)
@@ -479,7 +479,7 @@ static int
 mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &mt8183_mt6358_ts3a227_max98357_card;
-	struct device_node *platform_node, *ec_codec;
+	struct device_node *platform_node, *ec_codec, *hdmi_codec;
 	struct snd_soc_dai_link *dai_link;
 	struct mt8183_mt6358_ts3a227_max98357_priv *priv;
 	int ret;
@@ -496,9 +496,12 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 
 	ec_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,ec-codec", 0);
 
+	hdmi_codec = of_parse_phandle(pdev->dev.of_node,
+				      "mediatek,hdmi-codec", 0);
+
 	for_each_card_prelinks(card, i, dai_link) {
-		if (dai_link->platforms->name)
-			continue;
+		if (!dai_link->platforms->name)
+			dai_link->platforms->of_node = platform_node;
 
 		if (ec_codec && strcmp(dai_link->name, "Wake on Voice") == 0) {
 			dai_link->cpus[0].name = NULL;
@@ -509,9 +512,10 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
 			dai_link->codecs[0].dai_name = "Wake on Voice";
 			dai_link->platforms[0].of_node = ec_codec;
 			dai_link->ignore = 0;
-		} else {
-			dai_link->platforms->of_node = platform_node;
 		}
+
+		if (hdmi_codec && strcmp(dai_link->name, "TDM") == 0)
+			dai_link->codecs->of_node = hdmi_codec;
 	}
 
 	mt8183_mt6358_ts3a227_max98357_headset_dev.dlc.of_node =
-- 
2.23.0.866.gb869b98d4c-goog

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

* [PATCH 5/6] drm: bridge: it6505: report connector status
  2019-10-22 11:44 ` [alsa-devel] " Tzung-Bi Shih
  (?)
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  -1 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: alsa-devel, devicetree, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, dri-devel, allen.chen, cychiang, dgreid, tzungbi

When a connector connected or disconnected, report the jack status.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/gpu/drm/bridge/ite-it6505.c | 39 +++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 1d19184d2056..645d7947acc2 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -180,6 +180,10 @@ struct it6505 {
 	bool powered;
 	/* it6505 driver hold option */
 	unsigned int drv_hold;
+
+	hdmi_codec_plugged_cb plugged_cb;
+	struct device *codec_dev;
+	enum drm_connector_status last_connector_status;
 };
 
 static const struct regmap_range it6505_bridge_volatile_ranges[] = {
@@ -882,15 +886,31 @@ static const struct drm_connector_helper_funcs it6505_connector_helper_funcs = {
 	.get_modes = it6505_get_modes,
 };
 
+static void it6505_update_plugged_status(struct it6505 *it6505,
+					 enum drm_connector_status status)
+{
+	if (it6505->plugged_cb && it6505->codec_dev)
+		it6505->plugged_cb(it6505->codec_dev,
+				   status == connector_status_connected);
+}
+
 static enum drm_connector_status it6505_detect(struct drm_connector *connector,
 					       bool force)
 {
 	struct it6505 *it6505 = connector_to_it6505(connector);
+	enum drm_connector_status status;
 
 	if (gpiod_get_value(it6505->pdata.gpiod_hpd))
-		return connector_status_disconnected;
+		status = connector_status_disconnected;
+	else
+		status = connector_status_connected;
+
+	if (status != it6505->last_connector_status) {
+		it6505->last_connector_status = status;
+		it6505_update_plugged_status(it6505, status);
+	}
 
-	return connector_status_connected;
+	return status;
 }
 
 static const struct drm_connector_funcs it6505_connector_funcs = {
@@ -1341,10 +1361,23 @@ static void it6505_audio_shutdown(struct device *dev, void *data)
 	it6505->en_audio = 0;
 }
 
+static int it6505_audio_hook_plugged_cb(struct device *dev, void *data,
+					hdmi_codec_plugged_cb fn,
+					struct device *codec_dev)
+{
+	struct it6505 *it6505 = data;
+
+	it6505->plugged_cb = fn;
+	it6505->codec_dev = codec_dev;
+	it6505_update_plugged_status(it6505, it6505->last_connector_status);
+	return 0;
+}
+
 static const struct hdmi_codec_ops it6505_audio_codec_ops = {
 	.hw_params = it6505_audio_hw_params,
 	.trigger = it6505_audio_trigger,
 	.audio_shutdown = it6505_audio_shutdown,
+	.hook_plugged_cb = it6505_audio_hook_plugged_cb,
 };
 
 static int it6505_register_audio_driver(struct device *dev)
@@ -1354,6 +1387,7 @@ static int it6505_register_audio_driver(struct device *dev)
 		.ops = &it6505_audio_codec_ops,
 		.max_i2s_channels = 8,
 		.i2s = 1,
+		.data = it6505,
 	};
 	struct platform_device *pdev;
 
@@ -1364,6 +1398,7 @@ static int it6505_register_audio_driver(struct device *dev)
 		return PTR_ERR(pdev);
 
 	INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio);
+	it6505->last_connector_status = connector_status_disconnected;
 
 	DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME);
 	return 0;
-- 
2.23.0.866.gb869b98d4c-goog


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

* [alsa-devel] [PATCH 5/6] drm: bridge: it6505: report connector status
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

When a connector connected or disconnected, report the jack status.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/gpu/drm/bridge/ite-it6505.c | 39 +++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 1d19184d2056..645d7947acc2 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -180,6 +180,10 @@ struct it6505 {
 	bool powered;
 	/* it6505 driver hold option */
 	unsigned int drv_hold;
+
+	hdmi_codec_plugged_cb plugged_cb;
+	struct device *codec_dev;
+	enum drm_connector_status last_connector_status;
 };
 
 static const struct regmap_range it6505_bridge_volatile_ranges[] = {
@@ -882,15 +886,31 @@ static const struct drm_connector_helper_funcs it6505_connector_helper_funcs = {
 	.get_modes = it6505_get_modes,
 };
 
+static void it6505_update_plugged_status(struct it6505 *it6505,
+					 enum drm_connector_status status)
+{
+	if (it6505->plugged_cb && it6505->codec_dev)
+		it6505->plugged_cb(it6505->codec_dev,
+				   status == connector_status_connected);
+}
+
 static enum drm_connector_status it6505_detect(struct drm_connector *connector,
 					       bool force)
 {
 	struct it6505 *it6505 = connector_to_it6505(connector);
+	enum drm_connector_status status;
 
 	if (gpiod_get_value(it6505->pdata.gpiod_hpd))
-		return connector_status_disconnected;
+		status = connector_status_disconnected;
+	else
+		status = connector_status_connected;
+
+	if (status != it6505->last_connector_status) {
+		it6505->last_connector_status = status;
+		it6505_update_plugged_status(it6505, status);
+	}
 
-	return connector_status_connected;
+	return status;
 }
 
 static const struct drm_connector_funcs it6505_connector_funcs = {
@@ -1341,10 +1361,23 @@ static void it6505_audio_shutdown(struct device *dev, void *data)
 	it6505->en_audio = 0;
 }
 
+static int it6505_audio_hook_plugged_cb(struct device *dev, void *data,
+					hdmi_codec_plugged_cb fn,
+					struct device *codec_dev)
+{
+	struct it6505 *it6505 = data;
+
+	it6505->plugged_cb = fn;
+	it6505->codec_dev = codec_dev;
+	it6505_update_plugged_status(it6505, it6505->last_connector_status);
+	return 0;
+}
+
 static const struct hdmi_codec_ops it6505_audio_codec_ops = {
 	.hw_params = it6505_audio_hw_params,
 	.trigger = it6505_audio_trigger,
 	.audio_shutdown = it6505_audio_shutdown,
+	.hook_plugged_cb = it6505_audio_hook_plugged_cb,
 };
 
 static int it6505_register_audio_driver(struct device *dev)
@@ -1354,6 +1387,7 @@ static int it6505_register_audio_driver(struct device *dev)
 		.ops = &it6505_audio_codec_ops,
 		.max_i2s_channels = 8,
 		.i2s = 1,
+		.data = it6505,
 	};
 	struct platform_device *pdev;
 
@@ -1364,6 +1398,7 @@ static int it6505_register_audio_driver(struct device *dev)
 		return PTR_ERR(pdev);
 
 	INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio);
+	it6505->last_connector_status = connector_status_disconnected;
 
 	DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME);
 	return 0;
-- 
2.23.0.866.gb869b98d4c-goog

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH 5/6] drm: bridge: it6505: report connector status
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

When a connector connected or disconnected, report the jack status.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/gpu/drm/bridge/ite-it6505.c | 39 +++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 1d19184d2056..645d7947acc2 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -180,6 +180,10 @@ struct it6505 {
 	bool powered;
 	/* it6505 driver hold option */
 	unsigned int drv_hold;
+
+	hdmi_codec_plugged_cb plugged_cb;
+	struct device *codec_dev;
+	enum drm_connector_status last_connector_status;
 };
 
 static const struct regmap_range it6505_bridge_volatile_ranges[] = {
@@ -882,15 +886,31 @@ static const struct drm_connector_helper_funcs it6505_connector_helper_funcs = {
 	.get_modes = it6505_get_modes,
 };
 
+static void it6505_update_plugged_status(struct it6505 *it6505,
+					 enum drm_connector_status status)
+{
+	if (it6505->plugged_cb && it6505->codec_dev)
+		it6505->plugged_cb(it6505->codec_dev,
+				   status == connector_status_connected);
+}
+
 static enum drm_connector_status it6505_detect(struct drm_connector *connector,
 					       bool force)
 {
 	struct it6505 *it6505 = connector_to_it6505(connector);
+	enum drm_connector_status status;
 
 	if (gpiod_get_value(it6505->pdata.gpiod_hpd))
-		return connector_status_disconnected;
+		status = connector_status_disconnected;
+	else
+		status = connector_status_connected;
+
+	if (status != it6505->last_connector_status) {
+		it6505->last_connector_status = status;
+		it6505_update_plugged_status(it6505, status);
+	}
 
-	return connector_status_connected;
+	return status;
 }
 
 static const struct drm_connector_funcs it6505_connector_funcs = {
@@ -1341,10 +1361,23 @@ static void it6505_audio_shutdown(struct device *dev, void *data)
 	it6505->en_audio = 0;
 }
 
+static int it6505_audio_hook_plugged_cb(struct device *dev, void *data,
+					hdmi_codec_plugged_cb fn,
+					struct device *codec_dev)
+{
+	struct it6505 *it6505 = data;
+
+	it6505->plugged_cb = fn;
+	it6505->codec_dev = codec_dev;
+	it6505_update_plugged_status(it6505, it6505->last_connector_status);
+	return 0;
+}
+
 static const struct hdmi_codec_ops it6505_audio_codec_ops = {
 	.hw_params = it6505_audio_hw_params,
 	.trigger = it6505_audio_trigger,
 	.audio_shutdown = it6505_audio_shutdown,
+	.hook_plugged_cb = it6505_audio_hook_plugged_cb,
 };
 
 static int it6505_register_audio_driver(struct device *dev)
@@ -1354,6 +1387,7 @@ static int it6505_register_audio_driver(struct device *dev)
 		.ops = &it6505_audio_codec_ops,
 		.max_i2s_channels = 8,
 		.i2s = 1,
+		.data = it6505,
 	};
 	struct platform_device *pdev;
 
@@ -1364,6 +1398,7 @@ static int it6505_register_audio_driver(struct device *dev)
 		return PTR_ERR(pdev);
 
 	INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio);
+	it6505->last_connector_status = connector_status_disconnected;
 
 	DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME);
 	return 0;
-- 
2.23.0.866.gb869b98d4c-goog

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

* [PATCH 6/6] ASoC: mediatek: mt8183: support HDMI jack reporting
  2019-10-22 11:44 ` [alsa-devel] " Tzung-Bi Shih
  (?)
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  -1 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: alsa-devel, devicetree, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, dri-devel, allen.chen, cychiang, dgreid, tzungbi

Support HDMI jack reporting.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/mediatek/Kconfig                    |  3 ++-
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c   | 20 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index 8b29f3979899..0d8d75c5f984 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -126,9 +126,10 @@ config SND_SOC_MT8183_MT6358_TS3A227E_MAX98357A
 	select SND_SOC_BT_SCO
 	select SND_SOC_TS3A227E
 	select SND_SOC_CROS_EC_CODEC
+	select SND_SOC_HDMI_CODEC
 	help
 	  This adds ASoC driver for Mediatek MT8183 boards
-	  with the MT6358 TS3A227E MAX98357A audio codec.
+	  with the MT6358 TS3A227E MAX98357A audio codec and HDMI codec.
 	  Select Y if you have such device.
 	  If unsure select "N".
 
diff --git a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
index 258f1416fae1..23305dd2f958 100644
--- a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
+++ b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
@@ -11,6 +11,7 @@
 #include <sound/soc.h>
 #include <sound/jack.h>
 #include <linux/pinctrl/consumer.h>
+#include <sound/hdmi-codec.h>
 
 #include "mt8183-afe-common.h"
 #include "../../codecs/ts3a227e.h"
@@ -30,7 +31,7 @@ static const char * const mt8183_pin_str[PIN_STATE_MAX] = {
 struct mt8183_mt6358_ts3a227_max98357_priv {
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pin_states[PIN_STATE_MAX];
-	struct snd_soc_jack headset_jack;
+	struct snd_soc_jack headset_jack, hdmi_jack;
 };
 
 static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream,
@@ -270,6 +271,22 @@ static const struct snd_soc_ops mt8183_mt6358_ts3a227_max98357_wov_ops = {
 	.shutdown = mt8183_mt6358_ts3a227_max98357_wov_shutdown,
 };
 
+static int
+mt8183_mt6358_ts3a227_max98357_hdmi_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct mt8183_mt6358_ts3a227_max98357_priv *priv =
+		snd_soc_card_get_drvdata(rtd->card);
+	int ret;
+
+	ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT,
+				    &priv->hdmi_jack, NULL, 0);
+	if (ret)
+		return ret;
+
+	return hdmi_codec_set_jack_detect(rtd->codec_dai->component,
+					  &priv->hdmi_jack);
+}
+
 static struct snd_soc_dai_link
 mt8183_mt6358_ts3a227_max98357_dai_links[] = {
 	/* FE */
@@ -436,6 +453,7 @@ mt8183_mt6358_ts3a227_max98357_dai_links[] = {
 		.ignore_suspend = 1,
 		.be_hw_params_fixup = mt8183_i2s_hw_params_fixup,
 		.ops = &mt8183_mt6358_tdm_ops,
+		.init = mt8183_mt6358_ts3a227_max98357_hdmi_init,
 		SND_SOC_DAILINK_REG(tdm),
 	},
 };
-- 
2.23.0.866.gb869b98d4c-goog


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

* [alsa-devel] [PATCH 6/6] ASoC: mediatek: mt8183: support HDMI jack reporting
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

Support HDMI jack reporting.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/mediatek/Kconfig                    |  3 ++-
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c   | 20 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index 8b29f3979899..0d8d75c5f984 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -126,9 +126,10 @@ config SND_SOC_MT8183_MT6358_TS3A227E_MAX98357A
 	select SND_SOC_BT_SCO
 	select SND_SOC_TS3A227E
 	select SND_SOC_CROS_EC_CODEC
+	select SND_SOC_HDMI_CODEC
 	help
 	  This adds ASoC driver for Mediatek MT8183 boards
-	  with the MT6358 TS3A227E MAX98357A audio codec.
+	  with the MT6358 TS3A227E MAX98357A audio codec and HDMI codec.
 	  Select Y if you have such device.
 	  If unsure select "N".
 
diff --git a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
index 258f1416fae1..23305dd2f958 100644
--- a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
+++ b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
@@ -11,6 +11,7 @@
 #include <sound/soc.h>
 #include <sound/jack.h>
 #include <linux/pinctrl/consumer.h>
+#include <sound/hdmi-codec.h>
 
 #include "mt8183-afe-common.h"
 #include "../../codecs/ts3a227e.h"
@@ -30,7 +31,7 @@ static const char * const mt8183_pin_str[PIN_STATE_MAX] = {
 struct mt8183_mt6358_ts3a227_max98357_priv {
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pin_states[PIN_STATE_MAX];
-	struct snd_soc_jack headset_jack;
+	struct snd_soc_jack headset_jack, hdmi_jack;
 };
 
 static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream,
@@ -270,6 +271,22 @@ static const struct snd_soc_ops mt8183_mt6358_ts3a227_max98357_wov_ops = {
 	.shutdown = mt8183_mt6358_ts3a227_max98357_wov_shutdown,
 };
 
+static int
+mt8183_mt6358_ts3a227_max98357_hdmi_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct mt8183_mt6358_ts3a227_max98357_priv *priv =
+		snd_soc_card_get_drvdata(rtd->card);
+	int ret;
+
+	ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT,
+				    &priv->hdmi_jack, NULL, 0);
+	if (ret)
+		return ret;
+
+	return hdmi_codec_set_jack_detect(rtd->codec_dai->component,
+					  &priv->hdmi_jack);
+}
+
 static struct snd_soc_dai_link
 mt8183_mt6358_ts3a227_max98357_dai_links[] = {
 	/* FE */
@@ -436,6 +453,7 @@ mt8183_mt6358_ts3a227_max98357_dai_links[] = {
 		.ignore_suspend = 1,
 		.be_hw_params_fixup = mt8183_i2s_hw_params_fixup,
 		.ops = &mt8183_mt6358_tdm_ops,
+		.init = mt8183_mt6358_ts3a227_max98357_hdmi_init,
 		SND_SOC_DAILINK_REG(tdm),
 	},
 };
-- 
2.23.0.866.gb869b98d4c-goog

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH 6/6] ASoC: mediatek: mt8183: support HDMI jack reporting
@ 2019-10-22 11:45   ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2019-10-22 11:45 UTC (permalink / raw)
  To: broonie, robh+dt, narmstrong
  Cc: devicetree, alsa-devel, cychiang, jonas, allen.chen,
	jernej.skrabec, dri-devel, a.hajda, Laurent.pinchart, tzungbi,
	dgreid

Support HDMI jack reporting.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/mediatek/Kconfig                    |  3 ++-
 .../mt8183/mt8183-mt6358-ts3a227-max98357.c   | 20 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index 8b29f3979899..0d8d75c5f984 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -126,9 +126,10 @@ config SND_SOC_MT8183_MT6358_TS3A227E_MAX98357A
 	select SND_SOC_BT_SCO
 	select SND_SOC_TS3A227E
 	select SND_SOC_CROS_EC_CODEC
+	select SND_SOC_HDMI_CODEC
 	help
 	  This adds ASoC driver for Mediatek MT8183 boards
-	  with the MT6358 TS3A227E MAX98357A audio codec.
+	  with the MT6358 TS3A227E MAX98357A audio codec and HDMI codec.
 	  Select Y if you have such device.
 	  If unsure select "N".
 
diff --git a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
index 258f1416fae1..23305dd2f958 100644
--- a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
+++ b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
@@ -11,6 +11,7 @@
 #include <sound/soc.h>
 #include <sound/jack.h>
 #include <linux/pinctrl/consumer.h>
+#include <sound/hdmi-codec.h>
 
 #include "mt8183-afe-common.h"
 #include "../../codecs/ts3a227e.h"
@@ -30,7 +31,7 @@ static const char * const mt8183_pin_str[PIN_STATE_MAX] = {
 struct mt8183_mt6358_ts3a227_max98357_priv {
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pin_states[PIN_STATE_MAX];
-	struct snd_soc_jack headset_jack;
+	struct snd_soc_jack headset_jack, hdmi_jack;
 };
 
 static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream,
@@ -270,6 +271,22 @@ static const struct snd_soc_ops mt8183_mt6358_ts3a227_max98357_wov_ops = {
 	.shutdown = mt8183_mt6358_ts3a227_max98357_wov_shutdown,
 };
 
+static int
+mt8183_mt6358_ts3a227_max98357_hdmi_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct mt8183_mt6358_ts3a227_max98357_priv *priv =
+		snd_soc_card_get_drvdata(rtd->card);
+	int ret;
+
+	ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT,
+				    &priv->hdmi_jack, NULL, 0);
+	if (ret)
+		return ret;
+
+	return hdmi_codec_set_jack_detect(rtd->codec_dai->component,
+					  &priv->hdmi_jack);
+}
+
 static struct snd_soc_dai_link
 mt8183_mt6358_ts3a227_max98357_dai_links[] = {
 	/* FE */
@@ -436,6 +453,7 @@ mt8183_mt6358_ts3a227_max98357_dai_links[] = {
 		.ignore_suspend = 1,
 		.be_hw_params_fixup = mt8183_i2s_hw_params_fixup,
 		.ops = &mt8183_mt6358_tdm_ops,
+		.init = mt8183_mt6358_ts3a227_max98357_hdmi_init,
 		SND_SOC_DAILINK_REG(tdm),
 	},
 };
-- 
2.23.0.866.gb869b98d4c-goog

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

* Re: [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
  2019-10-22 11:45   ` [alsa-devel] " Tzung-Bi Shih
  (?)
  (?)
@ 2019-10-29 16:57     ` Rob Herring
  -1 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2019-10-29 16:57 UTC (permalink / raw)
  To: Tzung-Bi Shih
  Cc: broonie, robh+dt, narmstrong, alsa-devel, devicetree, a.hajda,
	Laurent.pinchart, jonas, jernej.skrabec, dri-devel, allen.chen,
	cychiang, dgreid, tzungbi

On Tue, 22 Oct 2019 19:45:02 +0800, Tzung-Bi Shih wrote:
> Add an optional property "mediatek,hdmi-codec".
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  .../bindings/sound/mt8183-mt6358-ts3a227-max98357.txt           | 2 ++
>  1 file changed, 2 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [alsa-devel] [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek, hdmi-codec"
@ 2019-10-29 16:57     ` Rob Herring
  0 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2019-10-29 16:57 UTC (permalink / raw)
  To: Tzung-Bi Shih
  Cc: devicetree, alsa-devel, cychiang, narmstrong, allen.chen,
	dri-devel, jonas, jernej.skrabec, robh+dt, a.hajda, broonie,
	Laurent.pinchart, tzungbi, dgreid

On Tue, 22 Oct 2019 19:45:02 +0800, Tzung-Bi Shih wrote:
> Add an optional property "mediatek,hdmi-codec".
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  .../bindings/sound/mt8183-mt6358-ts3a227-max98357.txt           | 2 ++
>  1 file changed, 2 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
@ 2019-10-29 16:57     ` Rob Herring
  0 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2019-10-29 16:57 UTC (permalink / raw)
  Cc: devicetree, alsa-devel, cychiang, narmstrong, allen.chen,
	dri-devel, jonas, jernej.skrabec, robh+dt, broonie,
	Laurent.pinchart, tzungbi, dgreid

On Tue, 22 Oct 2019 19:45:02 +0800, Tzung-Bi Shih wrote:
> Add an optional property "mediatek,hdmi-codec".
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  .../bindings/sound/mt8183-mt6358-ts3a227-max98357.txt           | 2 ++
>  1 file changed, 2 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec"
@ 2019-10-29 16:57     ` Rob Herring
  0 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2019-10-29 16:57 UTC (permalink / raw)
  To: Tzung-Bi Shih
  Cc: devicetree, alsa-devel, cychiang, narmstrong, allen.chen,
	dri-devel, jonas, jernej.skrabec, robh+dt, broonie,
	Laurent.pinchart, tzungbi, dgreid

On Tue, 22 Oct 2019 19:45:02 +0800, Tzung-Bi Shih wrote:
> Add an optional property "mediatek,hdmi-codec".
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  .../bindings/sound/mt8183-mt6358-ts3a227-max98357.txt           | 2 ++
>  1 file changed, 2 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator
  2019-10-22 11:45   ` [alsa-devel] " Tzung-Bi Shih
  (?)
@ 2022-11-24  5:52     ` Allen-KH Cheng (程冠勳)
  -1 siblings, 0 replies; 30+ messages in thread
From: Allen-KH Cheng (程冠勳) @ 2022-11-24  5:52 UTC (permalink / raw)
  To: tzungbi
  Cc: narmstrong, robh+dt, devicetree, jernej.skrabec, broonie,
	a.hajda, dri-devel, jonas, cychiang, dgreid, hsinyi,
	Laurent.pinchart, allen.chen, alsa-devel,
	Jiaxin Yu (俞家鑫)

Hi Tzung-Bi,

We would want to confirm with you as we work on the hdmi-codec for the
mt8186.

Do you have any plan to continue working on this series? We may take
over as well.

Thanks,
Allen

On Tue, 2019-10-22 at 19:45 +0800, Tzung-Bi Shih wrote:
> HDMI codec may be also interested in PCM triggers.  Add PCM trigger
> operator.
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  include/sound/hdmi-codec.h    | 13 +++++++++++++
>  sound/soc/codecs/hdmi-codec.c | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
> index 83b17682e01c..9de462ef170d 100644
> --- a/include/sound/hdmi-codec.h
> +++ b/include/sound/hdmi-codec.h
> @@ -50,6 +50,13 @@ struct hdmi_codec_params {
>  typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
>  				      bool plugged);
>  
> +enum {
> +	HDMI_CODEC_TRIGGER_EVENT_STOP,
> +	HDMI_CODEC_TRIGGER_EVENT_START,
> +	HDMI_CODEC_TRIGGER_EVENT_SUSPEND,
> +	HDMI_CODEC_TRIGGER_EVENT_RESUME,
> +};
> +
>  struct hdmi_codec_pdata;
>  struct hdmi_codec_ops {
>  	/*
> @@ -66,6 +73,12 @@ struct hdmi_codec_ops {
>  			 struct hdmi_codec_daifmt *fmt,
>  			 struct hdmi_codec_params *hparms);
>  
> +	/*
> +	 * PCM trigger callback.
> +	 * Optional
> +	 */
> +	int (*trigger)(struct device *dev, int event);
> +
>  	/*
>  	 * Shuts down the audio stream.
>  	 * Mandatory
> diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-
> codec.c
> index b5fd8f08726e..1ba2fa26ba03 100644
> --- a/sound/soc/codecs/hdmi-codec.c
> +++ b/sound/soc/codecs/hdmi-codec.c
> @@ -565,12 +565,42 @@ static int hdmi_codec_digital_mute(struct
> snd_soc_dai *dai, int mute)
>  	return 0;
>  }
>  
> +static int hdmi_codec_trigger(struct snd_pcm_substream *substream,
> int cmd,
> +			      struct snd_soc_dai *dai)
> +{
> +	struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
> +	int event;
> +
> +	if (!hcp->hcd.ops->trigger)
> +		return 0;
> +
> +	switch (cmd) {
> +	case SNDRV_PCM_TRIGGER_STOP:
> +		event = HDMI_CODEC_TRIGGER_EVENT_STOP;
> +		break;
> +	case SNDRV_PCM_TRIGGER_START:
> +		event = HDMI_CODEC_TRIGGER_EVENT_START;
> +		break;
> +	case SNDRV_PCM_TRIGGER_SUSPEND:
> +		event = HDMI_CODEC_TRIGGER_EVENT_SUSPEND;
> +		break;
> +	case SNDRV_PCM_TRIGGER_RESUME:
> +		event = HDMI_CODEC_TRIGGER_EVENT_RESUME;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return hcp->hcd.ops->trigger(dai->dev->parent, event);
> +}
> +
>  static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
>  	.startup	= hdmi_codec_startup,
>  	.shutdown	= hdmi_codec_shutdown,
>  	.hw_params	= hdmi_codec_hw_params,
>  	.set_fmt	= hdmi_codec_i2s_set_fmt,
>  	.digital_mute	= hdmi_codec_digital_mute,
> +	.trigger	= hdmi_codec_trigger,
>  };
>  
>  static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
> @@ -578,6 +608,7 @@ static const struct snd_soc_dai_ops
> hdmi_codec_spdif_dai_ops = {
>  	.shutdown	= hdmi_codec_shutdown,
>  	.hw_params	= hdmi_codec_hw_params,
>  	.digital_mute	= hdmi_codec_digital_mute,
> +	.trigger	= hdmi_codec_trigger,
>  };
>  
>  #define HDMI_RATES	(SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\

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

* Re: [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator
@ 2022-11-24  5:52     ` Allen-KH Cheng (程冠勳)
  0 siblings, 0 replies; 30+ messages in thread
From: Allen-KH Cheng (程冠勳) @ 2022-11-24  5:52 UTC (permalink / raw)
  To: tzungbi
  Cc: devicetree, jernej.skrabec, cychiang, narmstrong, allen.chen,
	broonie, jonas, alsa-devel, dri-devel,
	Jiaxin Yu (俞家鑫),
	a.hajda, robh+dt, Laurent.pinchart, hsinyi, dgreid

[-- Attachment #1: Type: text/html, Size: 5850 bytes --]

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

Hi Tzung-Bi,

We would want to confirm with you as we work on the hdmi-codec for the
mt8186.

Do you have any plan to continue working on this series? We may take
over as well.

Thanks,
Allen

On Tue, 2019-10-22 at 19:45 +0800, Tzung-Bi Shih wrote:
> HDMI codec may be also interested in PCM triggers.  Add PCM trigger
> operator.
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  include/sound/hdmi-codec.h    | 13 +++++++++++++
>  sound/soc/codecs/hdmi-codec.c | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
> index 83b17682e01c..9de462ef170d 100644
> --- a/include/sound/hdmi-codec.h
> +++ b/include/sound/hdmi-codec.h
> @@ -50,6 +50,13 @@ struct hdmi_codec_params {
>  typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
>  				      bool plugged);
>  
> +enum {
> +	HDMI_CODEC_TRIGGER_EVENT_STOP,
> +	HDMI_CODEC_TRIGGER_EVENT_START,
> +	HDMI_CODEC_TRIGGER_EVENT_SUSPEND,
> +	HDMI_CODEC_TRIGGER_EVENT_RESUME,
> +};
> +
>  struct hdmi_codec_pdata;
>  struct hdmi_codec_ops {
>  	/*
> @@ -66,6 +73,12 @@ struct hdmi_codec_ops {
>  			 struct hdmi_codec_daifmt *fmt,
>  			 struct hdmi_codec_params *hparms);
>  
> +	/*
> +	 * PCM trigger callback.
> +	 * Optional
> +	 */
> +	int (*trigger)(struct device *dev, int event);
> +
>  	/*
>  	 * Shuts down the audio stream.
>  	 * Mandatory
> diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-
> codec.c
> index b5fd8f08726e..1ba2fa26ba03 100644
> --- a/sound/soc/codecs/hdmi-codec.c
> +++ b/sound/soc/codecs/hdmi-codec.c
> @@ -565,12 +565,42 @@ static int hdmi_codec_digital_mute(struct
> snd_soc_dai *dai, int mute)
>  	return 0;
>  }
>  
> +static int hdmi_codec_trigger(struct snd_pcm_substream *substream,
> int cmd,
> +			      struct snd_soc_dai *dai)
> +{
> +	struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
> +	int event;
> +
> +	if (!hcp->hcd.ops->trigger)
> +		return 0;
> +
> +	switch (cmd) {
> +	case SNDRV_PCM_TRIGGER_STOP:
> +		event = HDMI_CODEC_TRIGGER_EVENT_STOP;
> +		break;
> +	case SNDRV_PCM_TRIGGER_START:
> +		event = HDMI_CODEC_TRIGGER_EVENT_START;
> +		break;
> +	case SNDRV_PCM_TRIGGER_SUSPEND:
> +		event = HDMI_CODEC_TRIGGER_EVENT_SUSPEND;
> +		break;
> +	case SNDRV_PCM_TRIGGER_RESUME:
> +		event = HDMI_CODEC_TRIGGER_EVENT_RESUME;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return hcp->hcd.ops->trigger(dai->dev->parent, event);
> +}
> +
>  static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
>  	.startup	= hdmi_codec_startup,
>  	.shutdown	= hdmi_codec_shutdown,
>  	.hw_params	= hdmi_codec_hw_params,
>  	.set_fmt	= hdmi_codec_i2s_set_fmt,
>  	.digital_mute	= hdmi_codec_digital_mute,
> +	.trigger	= hdmi_codec_trigger,
>  };
>  
>  static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
> @@ -578,6 +608,7 @@ static const struct snd_soc_dai_ops
> hdmi_codec_spdif_dai_ops = {
>  	.shutdown	= hdmi_codec_shutdown,
>  	.hw_params	= hdmi_codec_hw_params,
>  	.digital_mute	= hdmi_codec_digital_mute,
> +	.trigger	= hdmi_codec_trigger,
>  };
>  
>  #define HDMI_RATES	(SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\

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

* Re: [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator
@ 2022-11-24  5:52     ` Allen-KH Cheng (程冠勳)
  0 siblings, 0 replies; 30+ messages in thread
From: Allen-KH Cheng (程冠勳) @ 2022-11-24  5:52 UTC (permalink / raw)
  To: tzungbi
  Cc: devicetree, jernej.skrabec, cychiang, narmstrong, allen.chen,
	broonie, jonas, alsa-devel, dri-devel,
	Jiaxin Yu (俞家鑫),
	a.hajda, robh+dt, Laurent.pinchart, hsinyi, dgreid

Hi Tzung-Bi,

We would want to confirm with you as we work on the hdmi-codec for the
mt8186.

Do you have any plan to continue working on this series? We may take
over as well.

Thanks,
Allen

On Tue, 2019-10-22 at 19:45 +0800, Tzung-Bi Shih wrote:
> HDMI codec may be also interested in PCM triggers.  Add PCM trigger
> operator.
>
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  include/sound/hdmi-codec.h    | 13 +++++++++++++
>  sound/soc/codecs/hdmi-codec.c | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
>
> diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
> index 83b17682e01c..9de462ef170d 100644
> --- a/include/sound/hdmi-codec.h
> +++ b/include/sound/hdmi-codec.h
> @@ -50,6 +50,13 @@ struct hdmi_codec_params {
>  typedef void (*hdmi_codec_plugged_cb)(struct device *dev,
>        bool plugged);
>
> +enum {
> +HDMI_CODEC_TRIGGER_EVENT_STOP,
> +HDMI_CODEC_TRIGGER_EVENT_START,
> +HDMI_CODEC_TRIGGER_EVENT_SUSPEND,
> +HDMI_CODEC_TRIGGER_EVENT_RESUME,
> +};
> +
>  struct hdmi_codec_pdata;
>  struct hdmi_codec_ops {
>  /*
> @@ -66,6 +73,12 @@ struct hdmi_codec_ops {
>   struct hdmi_codec_daifmt *fmt,
>   struct hdmi_codec_params *hparms);
>
> +/*
> + * PCM trigger callback.
> + * Optional
> + */
> +int (*trigger)(struct device *dev, int event);
> +
>  /*
>   * Shuts down the audio stream.
>   * Mandatory
> diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-
> codec.c
> index b5fd8f08726e..1ba2fa26ba03 100644
> --- a/sound/soc/codecs/hdmi-codec.c
> +++ b/sound/soc/codecs/hdmi-codec.c
> @@ -565,12 +565,42 @@ static int hdmi_codec_digital_mute(struct
> snd_soc_dai *dai, int mute)
>  return 0;
>  }
>
> +static int hdmi_codec_trigger(struct snd_pcm_substream *substream,
> int cmd,
> +      struct snd_soc_dai *dai)
> +{
> +struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
> +int event;
> +
> +if (!hcp->hcd.ops->trigger)
> +return 0;
> +
> +switch (cmd) {
> +case SNDRV_PCM_TRIGGER_STOP:
> +event = HDMI_CODEC_TRIGGER_EVENT_STOP;
> +break;
> +case SNDRV_PCM_TRIGGER_START:
> +event = HDMI_CODEC_TRIGGER_EVENT_START;
> +break;
> +case SNDRV_PCM_TRIGGER_SUSPEND:
> +event = HDMI_CODEC_TRIGGER_EVENT_SUSPEND;
> +break;
> +case SNDRV_PCM_TRIGGER_RESUME:
> +event = HDMI_CODEC_TRIGGER_EVENT_RESUME;
> +break;
> +default:
> +return -EINVAL;
> +}
> +
> +return hcp->hcd.ops->trigger(dai->dev->parent, event);
> +}
> +
>  static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
>  .startup= hdmi_codec_startup,
>  .shutdown= hdmi_codec_shutdown,
>  .hw_params= hdmi_codec_hw_params,
>  .set_fmt= hdmi_codec_i2s_set_fmt,
>  .digital_mute= hdmi_codec_digital_mute,
> +.trigger= hdmi_codec_trigger,
>  };
>
>  static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
> @@ -578,6 +608,7 @@ static const struct snd_soc_dai_ops
> hdmi_codec_spdif_dai_ops = {
>  .shutdown= hdmi_codec_shutdown,
>  .hw_params= hdmi_codec_hw_params,
>  .digital_mute= hdmi_codec_digital_mute,
> +.trigger= hdmi_codec_trigger,
>  };
>
>  #define HDMI_RATES(SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\


************* MEDIATEK Confidentiality Notice ********************
The information contained in this e-mail message (including any
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be
conveyed only to the designated recipient(s). Any use, dissemination,
distribution, printing, retaining or copying of this e-mail (including its
attachments) by unintended recipient(s) is strictly prohibited and may
be unlawful. If you are not an intended recipient of this e-mail, or believe
that you have received this e-mail in error, please notify the sender
immediately (by replying to this e-mail), delete any and all copies of
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!

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

* Re: [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator
  2022-11-24  5:52     ` Allen-KH Cheng (程冠勳)
@ 2022-11-24  9:54       ` Tzung-Bi Shih
  -1 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2022-11-24  9:54 UTC (permalink / raw)
  To: Allen-KH Cheng (程冠勳)
  Cc: devicetree, jernej.skrabec, cychiang, narmstrong, allen.chen,
	broonie, jonas, alsa-devel, dri-devel,
	Jiaxin Yu (俞家鑫),
	a.hajda, robh+dt, Laurent.pinchart, hsinyi, dgreid

On Thu, Nov 24, 2022 at 1:52 PM Allen-KH Cheng (程冠勳)
<Allen-KH.Cheng@mediatek.com> wrote:
> We would want to confirm with you as we work on the hdmi-codec for the
> mt8186.
>
> Do you have any plan to continue working on this series? We may take
> over as well.

No (from testing's perspective).  Please take over it as you require.

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

* Re: [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator
@ 2022-11-24  9:54       ` Tzung-Bi Shih
  0 siblings, 0 replies; 30+ messages in thread
From: Tzung-Bi Shih @ 2022-11-24  9:54 UTC (permalink / raw)
  To: Allen-KH Cheng (程冠勳)
  Cc: narmstrong, robh+dt, devicetree, jernej.skrabec, broonie,
	a.hajda, dri-devel, jonas, cychiang, dgreid, hsinyi,
	Laurent.pinchart, allen.chen, alsa-devel,
	Jiaxin Yu (俞家鑫)

On Thu, Nov 24, 2022 at 1:52 PM Allen-KH Cheng (程冠勳)
<Allen-KH.Cheng@mediatek.com> wrote:
> We would want to confirm with you as we work on the hdmi-codec for the
> mt8186.
>
> Do you have any plan to continue working on this series? We may take
> over as well.

No (from testing's perspective).  Please take over it as you require.

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

end of thread, other threads:[~2022-11-24  9:55 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 11:44 [PATCH 0/6] ASoC: mediatek: mt8183: support DP audio Tzung-Bi Shih
2019-10-22 11:44 ` Tzung-Bi Shih
2019-10-22 11:44 ` [alsa-devel] " Tzung-Bi Shih
2019-10-22 11:45 ` [PATCH 1/6] ASoC: hdmi-codec: add PCM trigger operator Tzung-Bi Shih
2019-10-22 11:45   ` Tzung-Bi Shih
2019-10-22 11:45   ` [alsa-devel] " Tzung-Bi Shih
2022-11-24  5:52   ` Allen-KH Cheng (程冠勳)
2022-11-24  5:52     ` Allen-KH Cheng (程冠勳)
2022-11-24  5:52     ` Allen-KH Cheng (程冠勳)
2022-11-24  9:54     ` Tzung-Bi Shih
2022-11-24  9:54       ` Tzung-Bi Shih
2019-10-22 11:45 ` [PATCH 2/6] drm: bridge: it6505: bridge to hdmi-codec Tzung-Bi Shih
2019-10-22 11:45   ` Tzung-Bi Shih
2019-10-22 11:45   ` [alsa-devel] " Tzung-Bi Shih
2019-10-22 11:45 ` [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec" Tzung-Bi Shih
2019-10-22 11:45   ` [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek, hdmi-codec" Tzung-Bi Shih
2019-10-22 11:45   ` [alsa-devel] " Tzung-Bi Shih
2019-10-29 16:57   ` [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek,hdmi-codec" Rob Herring
2019-10-29 16:57     ` Rob Herring
2019-10-29 16:57     ` Rob Herring
2019-10-29 16:57     ` [alsa-devel] [PATCH 3/6] ASoC: dt-bindings: mt8183: add a property "mediatek, hdmi-codec" Rob Herring
2019-10-22 11:45 ` [PATCH 4/6] ASoC: mediatek: mt8183: use hdmi-codec Tzung-Bi Shih
2019-10-22 11:45   ` Tzung-Bi Shih
2019-10-22 11:45   ` [alsa-devel] " Tzung-Bi Shih
2019-10-22 11:45 ` [PATCH 5/6] drm: bridge: it6505: report connector status Tzung-Bi Shih
2019-10-22 11:45   ` Tzung-Bi Shih
2019-10-22 11:45   ` [alsa-devel] " Tzung-Bi Shih
2019-10-22 11:45 ` [PATCH 6/6] ASoC: mediatek: mt8183: support HDMI jack reporting Tzung-Bi Shih
2019-10-22 11:45   ` Tzung-Bi Shih
2019-10-22 11:45   ` [alsa-devel] " Tzung-Bi Shih

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.