drm/omap: Determine connector type directly in omap_connector.c
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 5 Jun 2018 21:31:57 +0000 (00:31 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 3 Sep 2018 13:13:29 +0000 (16:13 +0300)
Instead of determining the connector type from the type of the display's
omap_dss_device and passing it to the omap_connector_init() function,
move the type determination code to omap_connector.c and remove the type
argument to the connector init function. This moves code to a more
natural location, making the driver easier to read.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/omap_connector.c
drivers/gpu/drm/omapdrm/omap_connector.h
drivers/gpu/drm/omapdrm/omap_drv.c

index 92fea0085a9c7a1ea6ed2bb0f10ca42a9a256291..06c48a64b7456157ade7855f6a991753ef2d6d52 100644 (file)
@@ -325,10 +325,33 @@ static const struct drm_connector_helper_funcs omap_connector_helper_funcs = {
        .mode_valid = omap_connector_mode_valid,
 };
 
+static int omap_connector_get_type(struct omap_dss_device *display)
+{
+       switch (display->type) {
+       case OMAP_DISPLAY_TYPE_HDMI:
+               return DRM_MODE_CONNECTOR_HDMIA;
+       case OMAP_DISPLAY_TYPE_DVI:
+               return DRM_MODE_CONNECTOR_DVID;
+       case OMAP_DISPLAY_TYPE_DSI:
+               return DRM_MODE_CONNECTOR_DSI;
+       case OMAP_DISPLAY_TYPE_DPI:
+       case OMAP_DISPLAY_TYPE_DBI:
+               return DRM_MODE_CONNECTOR_DPI;
+       case OMAP_DISPLAY_TYPE_VENC:
+               /* TODO: This could also be composite */
+               return DRM_MODE_CONNECTOR_SVIDEO;
+       case OMAP_DISPLAY_TYPE_SDI:
+               return DRM_MODE_CONNECTOR_LVDS;
+       default:
+               return DRM_MODE_CONNECTOR_Unknown;
+       }
+}
+
 /* initialize connector */
 struct drm_connector *omap_connector_init(struct drm_device *dev,
-               int connector_type, struct omap_dss_device *output,
-               struct omap_dss_device *display, struct drm_encoder *encoder)
+                                         struct omap_dss_device *output,
+                                         struct omap_dss_device *display,
+                                         struct drm_encoder *encoder)
 {
        struct drm_connector *connector = NULL;
        struct omap_connector *omap_connector;
@@ -348,7 +371,7 @@ struct drm_connector *omap_connector_init(struct drm_device *dev,
        connector->doublescan_allowed = 0;
 
        drm_connector_init(dev, connector, &omap_connector_funcs,
-                               connector_type);
+                          omap_connector_get_type(display));
        drm_connector_helper_add(connector, &omap_connector_helper_funcs);
 
        /*
index 42ff0a106179928c45ffa2fca973fac88d303df6..854099801649b547e15fb5cc1db18552bf1934d3 100644 (file)
@@ -28,8 +28,9 @@ struct drm_encoder;
 struct omap_dss_device;
 
 struct drm_connector *omap_connector_init(struct drm_device *dev,
-               int connector_type, struct omap_dss_device *output,
-               struct omap_dss_device *display, struct drm_encoder *encoder);
+                                         struct omap_dss_device *output,
+                                         struct omap_dss_device *display,
+                                         struct drm_encoder *encoder);
 struct drm_encoder *omap_connector_attached_encoder(
                struct drm_connector *connector);
 bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
index 03771f818eaa1407505895fb945878f2756ee20a..5f98506ac2c5d976899d9704d322842ee583289a 100644 (file)
@@ -129,28 +129,6 @@ static const struct drm_mode_config_funcs omap_mode_config_funcs = {
        .atomic_commit = drm_atomic_helper_commit,
 };
 
-static int get_connector_type(struct omap_dss_device *display)
-{
-       switch (display->type) {
-       case OMAP_DISPLAY_TYPE_HDMI:
-               return DRM_MODE_CONNECTOR_HDMIA;
-       case OMAP_DISPLAY_TYPE_DVI:
-               return DRM_MODE_CONNECTOR_DVID;
-       case OMAP_DISPLAY_TYPE_DSI:
-               return DRM_MODE_CONNECTOR_DSI;
-       case OMAP_DISPLAY_TYPE_DPI:
-       case OMAP_DISPLAY_TYPE_DBI:
-               return DRM_MODE_CONNECTOR_DPI;
-       case OMAP_DISPLAY_TYPE_VENC:
-               /* TODO: This could also be composite */
-               return DRM_MODE_CONNECTOR_SVIDEO;
-       case OMAP_DISPLAY_TYPE_SDI:
-               return DRM_MODE_CONNECTOR_LVDS;
-       default:
-               return DRM_MODE_CONNECTOR_Unknown;
-       }
-}
-
 static void omap_disconnect_pipelines(struct drm_device *ddev)
 {
        struct omap_drm_private *priv = ddev->dev_private;
@@ -322,9 +300,8 @@ static int omap_modeset_init(struct drm_device *dev)
                if (!encoder)
                        return -ENOMEM;
 
-               connector = omap_connector_init(dev,
-                               get_connector_type(display), pipe->output,
-                               display, encoder);
+               connector = omap_connector_init(dev, pipe->output, display,
+                                               encoder);
                if (!connector)
                        return -ENOMEM;