drm/rockchip: cdn-dp: add switch state to support dp audio
authorBin Yang <yangbin@rock-chips.com>
Wed, 8 Feb 2017 09:14:09 +0000 (17:14 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 13 Feb 2017 07:01:53 +0000 (15:01 +0800)
Change-Id: Ifb4f6c8c2ecc0df5a021c38c7b5fe57da5c98e6b
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
drivers/gpu/drm/rockchip/cdn-dp-core.c
drivers/gpu/drm/rockchip/cdn-dp-core.h

index a11292dfe5444691dd590ff5ecbffa77ed667f53..a61aca213813f9f483c950fafb647576f7a030a8 100644 (file)
@@ -693,8 +693,13 @@ static void cdn_dp_encoder_enable(struct drm_encoder *encoder)
        }
 out:
        mutex_unlock(&dp->lock);
-       if (!ret)
+       if (!ret) {
+#ifdef CONFIG_SWITCH
+               switch_set_state(&dp->switchdev, 1);
+#else
                hdmi_event_connect(dp->dev);
+#endif
+       }
 }
 
 static void cdn_dp_encoder_disable(struct drm_encoder *encoder)
@@ -711,7 +716,11 @@ static void cdn_dp_encoder_disable(struct drm_encoder *encoder)
                }
        }
        mutex_unlock(&dp->lock);
+#ifdef CONFIG_SWITCH
+       switch_set_state(&dp->switchdev, 0);
+#else
        hdmi_event_disconnect(dp->dev);
+#endif
 
        /*
         * In the following 2 cases, we need to run the event_work to re-enable
@@ -1109,6 +1118,11 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
 
        drm_connector_helper_add(connector, &cdn_dp_connector_helper_funcs);
 
+#ifdef CONFIG_SWITCH
+       dp->switchdev.name = "hdmi";
+       switch_dev_register(&dp->switchdev);
+#endif
+
        ret = drm_mode_connector_attach_encoder(connector, encoder);
        if (ret) {
                DRM_ERROR("failed to attach connector and encoder\n");
@@ -1150,6 +1164,10 @@ static void cdn_dp_unbind(struct device *dev, struct device *master, void *data)
        struct drm_encoder *encoder = &dp->encoder;
        struct drm_connector *connector = &dp->connector;
 
+#ifdef CONFIG_SWITCH
+       switch_dev_unregister(&dp->switchdev);
+#endif
+
        cancel_work_sync(&dp->event_work);
        platform_device_unregister(dp->audio_pdev);
        cdn_dp_encoder_disable(encoder);
index 7d48661362c8982f31666a459f801b2e4fb7d797..33bc49cc7bc8a234ecb798be53c0cbd21926cbed 100644 (file)
@@ -19,6 +19,9 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_dp_helper.h>
 #include <drm/drm_panel.h>
+#ifdef CONFIG_SWITCH
+#include <linux/switch.h>
+#endif
 #include "rockchip_drm_drv.h"
 
 #define MAX_PHY                2
@@ -107,5 +110,8 @@ struct cdn_dp_device {
 
        u8 dpcd[DP_RECEIVER_CAP_SIZE];
        bool sink_has_audio;
+#ifdef CONFIG_SWITCH
+       struct switch_dev switchdev;
+#endif
 };
 #endif  /* _CDN_DP_CORE_H */