]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/rockchip: add DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to drm_bridge_attach
authorAlex Bee <knaerzche@gmail.com>
Mon, 13 Sep 2021 12:51:08 +0000 (14:51 +0200)
committerHeiko Stuebner <heiko@sntech.de>
Tue, 21 Sep 2021 09:43:29 +0000 (11:43 +0200)
Commit fa4d74f07e1e ("drm/bridge: Extend bridge API to disable connector creation")
added DRM_BRIDGE_ATTACH_NO_CONNECTOR bridge flag and all bridges handle
this flag in some way since then.
Newly added bridge drivers must no longer contain the connector creation and
will fail probing if this flag isn't set.

In order to be able to connect to those newly added bridges as well,
make use of drm_bridge_connector API and have the connector initialized
by the display controller.

Signed-off-by: Alex Bee <knaerzche@gmail.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210913125108.195704-1-knaerzche@gmail.com
drivers/gpu/drm/rockchip/rockchip_lvds.c
drivers/gpu/drm/rockchip/rockchip_rgb.c

index 551653940e396ccd65b00aa2b225f1e2286e9ddb..e3953c72fbdb215b1a66e0de25abb5aa34fc75d1 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
 #include <drm/drm_dp_helper.h>
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
@@ -612,9 +613,9 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
        }
 
        drm_encoder_helper_add(encoder, lvds->soc_data->helper_funcs);
+       connector = &lvds->connector;
 
        if (lvds->panel) {
-               connector = &lvds->connector;
                connector->dpms = DRM_MODE_DPMS_OFF;
                ret = drm_connector_init(drm_dev, connector,
                                         &rockchip_lvds_connector_funcs,
@@ -627,17 +628,27 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
 
                drm_connector_helper_add(connector,
                                         &rockchip_lvds_connector_helper_funcs);
-
-               ret = drm_connector_attach_encoder(connector, encoder);
-               if (ret < 0) {
-                       DRM_DEV_ERROR(drm_dev->dev,
-                                     "failed to attach encoder: %d\n", ret);
-                       goto err_free_connector;
-               }
        } else {
-               ret = drm_bridge_attach(encoder, lvds->bridge, NULL, 0);
+               ret = drm_bridge_attach(encoder, lvds->bridge, NULL,
+                                       DRM_BRIDGE_ATTACH_NO_CONNECTOR);
                if (ret)
                        goto err_free_encoder;
+
+               connector = drm_bridge_connector_init(lvds->drm_dev, encoder);
+               if (IS_ERR(connector)) {
+                       DRM_DEV_ERROR(drm_dev->dev,
+                                     "failed to initialize bridge connector: %pe\n",
+                                     connector);
+                       ret = PTR_ERR(connector);
+                       goto err_free_encoder;
+               }
+       }
+
+       ret = drm_connector_attach_encoder(connector, encoder);
+       if (ret < 0) {
+               DRM_DEV_ERROR(drm_dev->dev,
+                             "failed to attach encoder: %d\n", ret);
+               goto err_free_connector;
        }
 
        pm_runtime_enable(dev);
index d691d9bef8e7dc1512a1c474113a54ce3ef23bc6..09be9678f2bd2edfff31e2a032802f3991748ba2 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
 #include <drm/drm_dp_helper.h>
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
@@ -27,6 +28,7 @@ struct rockchip_rgb {
        struct drm_device *drm_dev;
        struct drm_bridge *bridge;
        struct drm_encoder encoder;
+       struct drm_connector connector;
        int output_mode;
 };
 
@@ -80,6 +82,7 @@ struct rockchip_rgb *rockchip_rgb_init(struct device *dev,
        int ret = 0, child_count = 0;
        struct drm_panel *panel;
        struct drm_bridge *bridge;
+       struct drm_connector *connector;
 
        rgb = devm_kzalloc(dev, sizeof(*rgb), GFP_KERNEL);
        if (!rgb)
@@ -142,12 +145,32 @@ struct rockchip_rgb *rockchip_rgb_init(struct device *dev,
 
        rgb->bridge = bridge;
 
-       ret = drm_bridge_attach(encoder, rgb->bridge, NULL, 0);
+       ret = drm_bridge_attach(encoder, rgb->bridge, NULL,
+                               DRM_BRIDGE_ATTACH_NO_CONNECTOR);
        if (ret)
                goto err_free_encoder;
 
+       connector = &rgb->connector;
+       connector = drm_bridge_connector_init(rgb->drm_dev, encoder);
+       if (IS_ERR(connector)) {
+               DRM_DEV_ERROR(drm_dev->dev,
+                             "failed to initialize bridge connector: %pe\n",
+                             connector);
+               ret = PTR_ERR(connector);
+               goto err_free_encoder;
+       }
+
+       ret = drm_connector_attach_encoder(connector, encoder);
+       if (ret < 0) {
+               DRM_DEV_ERROR(drm_dev->dev,
+                             "failed to attach encoder: %d\n", ret);
+               goto err_free_connector;
+       }
+
        return rgb;
 
+err_free_connector:
+       drm_connector_cleanup(connector);
 err_free_encoder:
        drm_encoder_cleanup(encoder);
        return ERR_PTR(ret);
@@ -157,6 +180,7 @@ EXPORT_SYMBOL_GPL(rockchip_rgb_init);
 void rockchip_rgb_fini(struct rockchip_rgb *rgb)
 {
        drm_panel_bridge_remove(rgb->bridge);
+       drm_connector_cleanup(&rgb->connector);
        drm_encoder_cleanup(&rgb->encoder);
 }
 EXPORT_SYMBOL_GPL(rockchip_rgb_fini);