[alsa-devel] [PATCH 2/3] drm/mediatek: support HDMI jack status reporting
Tzung-Bi Shih
tzungbi at google.com
Wed Feb 5 10:37:44 CET 2020
1.
Provides a callback (i.e. mtk_hdmi_audio_hook_plugged_cb) to hdmi-codec.
When ASoC machine driver calls hdmi_codec_set_jack_detect(), the
callback will be invoked to save plugged_cb and codec_dev parameters.
+---------+ set_jack_ +------------+ plugged_cb +----------+
| machine | ----------> | hdmi-codec | ----------> | mtk-hdmi |
+---------+ detect() +------------+ codec_dev +----------+
2.
When there is any jack status changes, mtk-hdmi will call the
plugged_cb() to notify hdmi-codec. And then hdmi-codec will call
snd_soc_jack_report().
+----------+ plugged_cb +------------+
| mtk-hdmi | ----------> | hdmi-codec | -> snd_soc_jack_report()
+----------+ codec_dev +------------+
connector_status
Signed-off-by: Tzung-Bi Shih <tzungbi at google.com>
---
drivers/gpu/drm/mediatek/mtk_hdmi.c | 41 +++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 23c2b0e8693d..15736ed0a96a 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -169,6 +169,8 @@ struct mtk_hdmi {
bool audio_enable;
bool powered;
bool enabled;
+ hdmi_codec_plugged_cb plugged_cb;
+ struct device *codec_dev;
};
static inline struct mtk_hdmi *hdmi_ctx_from_bridge(struct drm_bridge *b)
@@ -1194,13 +1196,27 @@ static void mtk_hdmi_clk_disable_audio(struct mtk_hdmi *hdmi)
clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_AUD_SPDIF]);
}
+static void mtk_hdmi_update_plugged_status(struct mtk_hdmi *hdmi,
+ enum drm_connector_status status)
+{
+ if (hdmi->plugged_cb && hdmi->codec_dev)
+ hdmi->plugged_cb(hdmi->codec_dev,
+ status == connector_status_connected);
+}
+
static enum drm_connector_status hdmi_conn_detect(struct drm_connector *conn,
bool force)
{
struct mtk_hdmi *hdmi = hdmi_ctx_from_conn(conn);
+ enum drm_connector_status status;
- return mtk_cec_hpd_high(hdmi->cec_dev) ?
- connector_status_connected : connector_status_disconnected;
+ if (mtk_cec_hpd_high(hdmi->cec_dev))
+ status = connector_status_connected;
+ else
+ status = connector_status_disconnected;
+
+ mtk_hdmi_update_plugged_status(hdmi, status);
+ return status;
}
static void hdmi_conn_destroy(struct drm_connector *conn)
@@ -1648,20 +1664,41 @@ static int mtk_hdmi_audio_get_eld(struct device *dev, void *data, uint8_t *buf,
return 0;
}
+static int mtk_hdmi_audio_hook_plugged_cb(struct device *dev, void *data,
+ hdmi_codec_plugged_cb fn,
+ struct device *codec_dev)
+{
+ struct mtk_hdmi *hdmi = data;
+
+ hdmi->plugged_cb = fn;
+ hdmi->codec_dev = codec_dev;
+
+ if (mtk_cec_hpd_high(hdmi->cec_dev))
+ mtk_hdmi_update_plugged_status(
+ hdmi, connector_status_connected);
+ else
+ mtk_hdmi_update_plugged_status(
+ hdmi, connector_status_disconnected);
+ return 0;
+}
+
static const struct hdmi_codec_ops mtk_hdmi_audio_codec_ops = {
.hw_params = mtk_hdmi_audio_hw_params,
.audio_startup = mtk_hdmi_audio_startup,
.audio_shutdown = mtk_hdmi_audio_shutdown,
.digital_mute = mtk_hdmi_audio_digital_mute,
.get_eld = mtk_hdmi_audio_get_eld,
+ .hook_plugged_cb = mtk_hdmi_audio_hook_plugged_cb,
};
static int mtk_hdmi_register_audio_driver(struct device *dev)
{
+ struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
struct hdmi_codec_pdata codec_data = {
.ops = &mtk_hdmi_audio_codec_ops,
.max_i2s_channels = 2,
.i2s = 1,
+ .data = hdmi,
};
struct platform_device *pdev;
--
2.25.0.341.g760bfbb309-goog
More information about the Alsa-devel
mailing list