amlogic: drm: Add extcon hdmi connection uevent 51/286351/2 accepted/tizen/unified/20230106.165104
authorHoegeun Kwon <hoegeun.kwon@samsung.com>
Wed, 4 Jan 2023 04:02:03 +0000 (13:02 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Thu, 5 Jan 2023 09:13:38 +0000 (18:13 +0900)
Add extcon hdmi connection and disconnection uevent when extcon
module is enabled.

Change-Id: I95686a9ec15700966103aaa14a7fe2702bd30a3a
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
drivers/amlogic/drm/meson_hdmi.c
drivers/amlogic/drm/meson_hdmi.h

index 7cbe8c1..9210a18 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/jiffies.h>
 #include <linux/kthread.h>
 #include <linux/device.h>
+#include <linux/extcon.h>
 
 #include <linux/workqueue.h>
 #include <linux/amlogic/media/vout/vout_notify.h>
@@ -146,6 +147,23 @@ static enum drm_connector_status am_hdmi_connector_detect
 {
        struct am_hdmi_tx *am_hdmi = to_am_hdmi(connector);
 
+#ifdef CONFIG_EXTCON
+       enum drm_connector_status status;
+
+       if (am_hdmi->hpd_flag == 0 && hdmitx_hpd_hw_op(HPD_READ_HPD_GPIO)) {
+               status = connector_status_connected;
+       } else if (am_hdmi->hpd_flag == 0 && !hdmitx_hpd_hw_op(HPD_READ_HPD_GPIO)) {
+               status = connector_status_disconnected;
+       } else {
+               status = am_hdmi->hpd_flag == 1 ?
+                       connector_status_connected : connector_status_disconnected;
+       }
+
+       extcon_set_state_sync(am_hdmi->edev, EXTCON_DISP_HDMI,
+                       (status == connector_status_connected ?
+                        true : false));
+#endif
+
        /* HPD rising */
        if (am_hdmi->hpd_flag == 1) {
                DRM_INFO("connector_status_connected\n");
@@ -582,6 +600,13 @@ struct drm_connector *am_meson_hdmi_connector(void)
        return &am_hdmi_info.connector;
 }
 
+#ifdef CONFIG_EXTCON
+static const unsigned int am_hdmi_extcon_cable[] = {
+       EXTCON_DISP_HDMI,
+       EXTCON_NONE,
+};
+#endif
+
 static int am_meson_hdmi_bind(struct device *dev,
        struct device *master, void *data)
 {
@@ -657,6 +682,21 @@ static int am_meson_hdmi_bind(struct device *dev,
                                DRM_DEBUG_KMS("HDCP init failed, skipping.\n");
                }
        }
+
+#ifdef CONFIG_EXTCON
+       /* Initialize extcon device */
+       am_hdmi->edev = devm_extcon_dev_allocate(dev, am_hdmi_extcon_cable);
+       if (IS_ERR(am_hdmi->edev)) {
+               dev_err(dev, "failed to allocate memory for extcon\n");
+               return PTR_ERR(am_hdmi->edev);
+       }
+
+       ret = devm_extcon_dev_register(dev, am_hdmi->edev);
+       if (ret) {
+               dev_err(dev, "failed to register extcon device\n");
+               return ret;
+       }
+#endif
        DRM_INFO("[%s] out\n", __func__);
        return 0;
 }
index d4bea37..9d3275e 100644 (file)
 #define VIC_MAX_NUM        512
 #define DRM_HDMITX_VER     "20180705"
 
+#ifdef CONFIG_EXTCON
+struct extcon_dev;
+#endif
+
 struct am_hdmi_data {
        unsigned int vic;
        u8 sink_is_hdmi;
@@ -77,6 +81,10 @@ struct am_hdmi_tx {
        unsigned int hdcp_stop_flag;/*turn off hdcp state machine*/
        unsigned int hdcp_try_times;
        struct task_struct *hdcp_work;
+
+#ifdef CONFIG_EXTCON
+       struct extcon_dev *edev;
+#endif
 };
 
 #define to_am_hdmi(x)  container_of(x, struct am_hdmi_tx, x)