From 9a72f564dec662c816a2065c4555ca38f10d5aae 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/synopsys/dw-hdmi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 03ae15e1d989..f784f8098114 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -30,6 +30,9 @@ #include #include #include +#ifdef CONFIG_SWITCH +#include +#endif #include #include @@ -240,6 +243,10 @@ struct dw_hdmi { unsigned int audio_n; bool audio_enable; +#ifdef CONFIG_SWITCH + struct switch_dev switchdev; +#endif + unsigned int reg_shift; struct regmap *regm; void (*enable_audio)(struct dw_hdmi *hdmi); @@ -2511,6 +2518,12 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) phy_int_pol & HDMI_PHY_HPD ? "plugin" : "plugout"); if (hdmi->bridge.dev) 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); @@ -3046,6 +3059,11 @@ __dw_hdmi_probe(struct platform_device *pdev, hdmi->cec = platform_device_register_full(&pdevinfo); } +#ifdef CONFIG_SWITCH + hdmi->switchdev.name = "hdmi"; + switch_dev_register(&hdmi->switchdev); +#endif + /* Reset HDMI DDC I2C master controller and mute I2CM interrupts */ if (hdmi->i2c) dw_hdmi_i2c_init(hdmi); @@ -3084,6 +3102,10 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi) /* Disable all interrupts */ hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); +#ifdef CONFIG_SWITCH + switch_dev_unregister(&hdmi->switchdev); +#endif + dw_hdmi_destroy_properties(hdmi); if (hdmi->cec_notifier)