From ebbbc52acc2748a96e0c4500c2170e5de331439e Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Thu, 9 Feb 2017 18:15:30 +0800 Subject: [PATCH] drm: bridge/dw_hdmi: add switch state to support hdmi audio Change-Id: Ib8122f9cc913d2cd15b92a3d6c57c7edf77d0483 Signed-off-by: Bin Yang --- drivers/gpu/drm/bridge/dw-hdmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index 0ddc7b7da990..0153be6ffbd4 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -30,6 +30,9 @@ #include #include #include +#ifdef CONFIG_SWITCH +#include +#endif #include "dw-hdmi.h" #include "dw-hdmi-audio.h" @@ -213,6 +216,10 @@ struct dw_hdmi { unsigned int audio_n; bool audio_enable; +#ifdef CONFIG_SWITCH + struct switch_dev switchdev; +#endif + void (*write)(struct dw_hdmi *hdmi, u8 val, int offset); u8 (*read)(struct dw_hdmi *hdmi, int offset); }; @@ -1942,6 +1949,12 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) dev_dbg(hdmi->dev, "EVENT=%s\n", phy_int_pol & HDMI_PHY_HPD ? "plugin" : "plugout"); drm_helper_hpd_irq_event(hdmi->bridge->dev); +#ifdef CONFIG_SWITCH + if (phy_int_pol & HDMI_PHY_HPD) + switch_set_state(&hdmi->switchdev, 1); + else + switch_set_state(&hdmi->switchdev, 0); +#endif } hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0); @@ -2132,6 +2145,11 @@ int dw_hdmi_bind(struct device *dev, struct device *master, if (ret) goto err_iahb; +#ifdef CONFIG_SWITCH + hdmi->switchdev.name = "hdmi"; + switch_dev_register(&hdmi->switchdev); +#endif + hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), HDMI_IH_MUTE_PHY_STAT0); @@ -2200,6 +2218,9 @@ void dw_hdmi_unbind(struct device *dev, struct device *master, void *data) /* Disable all interrupts */ hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); +#ifdef CONFIG_SWITCH + switch_dev_unregister(&hdmi->switchdev); +#endif hdmi->connector.funcs->destroy(&hdmi->connector); hdmi->encoder->funcs->destroy(hdmi->encoder); -- 2.34.1