gpu: drm: nexell: Add extcon notification for hdmi connection
authorDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 10 Nov 2017 02:55:12 +0000 (11:55 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 29 Jan 2019 02:25:34 +0000 (11:25 +0900)
Currently, HDMI cable connection generates only uevent by drm core. In
addition, it has no inforation about connection state. But, in tizen,
to handle TV-out mode uevent should be generated by extcon subsystem
with connection state. To this end, this patch will add extcon
notification for hdmi connection.

Change-Id: I101bf3b582498fbe46733839e3cbd75c292cf88f
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
drivers/gpu/drm/nexell/Kconfig
drivers/gpu/drm/nexell/nx_drm_hdmi.c

index 8b841d13aa54846e26488d3ed6a11af2843a5907..eedcb129f605d1c68d578862927649d0b0629542 100644 (file)
@@ -58,6 +58,7 @@ config DRM_NX_MIPI_DSI
 config DRM_NX_HDMI
        bool "HDMI support"
        depends on DRM_NX
+       select EXTCON
        help
         This selects support for HDMI display out.
         If you want to enable HDMI display,
index d5ebffd9b8598b33c15a0d261539957043e9fd74..4de04355125e05708c327735f4ee3282474856cd 100644 (file)
@@ -29,6 +29,7 @@
 #include <video/of_display_timing.h>
 #include <dt-bindings/gpio/gpio.h>
 #include <drm/nexell_drm.h>
+#include <linux/extcon.h>
 
 #include "nx_drm_drv.h"
 #include "nx_drm_fb.h"
@@ -51,6 +52,12 @@ struct hdmi_context {
        /* properties */
        int crtc_pipe;
        unsigned int possible_crtcs_mask;
+       struct extcon_dev *edev;
+};
+
+static const unsigned int supported_cable[] = {
+       EXTCON_DISP_HDMI,
+       EXTCON_NONE,
 };
 
 #define ctx_to_display(c)      \
@@ -367,6 +374,8 @@ static void panel_hdmi_hpd_work(struct work_struct *work)
 
        DRM_INFO("HDMI %s\n", plug ? "plug" : "unplug");
 
+       extcon_set_cable_state_(ctx->edev, EXTCON_DISP_HDMI, plug);
+
        ctx->plug = plug;
        connector = &ctx->connector->connector;
        drm_helper_hpd_irq_event(connector->dev);
@@ -557,6 +566,40 @@ static int panel_hdmi_get_display(struct platform_device *pdev,
        return 0;
 }
 
+static int panel_hdmi_extcon_init(struct platform_device *pdev,
+                                       struct hdmi_context *ctx)
+{
+       struct device *dev = &pdev->dev;
+       struct nx_drm_display *display = ctx_to_display(ctx);
+       struct extcon_dev *edev;
+       int err;
+
+       edev = devm_extcon_dev_allocate(dev, supported_cable);
+       if (IS_ERR(edev)) {
+               DRM_ERROR("failed to allocate extcon device\n");
+               return -ENODEV;
+       }
+
+       err = devm_extcon_dev_register(dev, edev);
+       if (err) {
+               DRM_ERROR("failed to register extcon device\n");
+               return err;
+       }
+
+       if (!display->ops->hdmi->is_connected) {
+               DRM_ERROR("HDMI not implement connected API\n");
+               return -ENOENT;
+       }
+
+       ctx->edev = edev;
+
+       /* notify the plugged state when hdmi is already connected */
+       if (display->ops->hdmi->is_connected(display))
+               extcon_set_cable_state_(edev, EXTCON_DISP_HDMI, true);
+
+       return 0;
+}
+
 static int panel_hdmi_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -593,6 +636,10 @@ static int panel_hdmi_probe(struct platform_device *pdev)
        if (err < 0)
                goto err_probe;
 
+       err = panel_hdmi_extcon_init(pdev, ctx);
+       if (0 > err)
+               return err;
+
        dev_set_drvdata(dev, ctx);
 
        component_add(dev, &panel_comp_ops);