Commit a25b988ff83f ("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. Based on 2e87bf389e13 ("drm/rockchip: add DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to drm_bridge_attach") This makes LT9611 work with i.MX8M Mini. Signed-off-by: Marek Vasut <marex@xxxxxxx> --- Cc: Andrzej Hajda <andrzej.hajda@xxxxxxxxx> Cc: David Airlie <airlied@xxxxxxxxx> Cc: Fabio Estevam <festevam@xxxxxxxxx> Cc: Jernej Skrabec <jernej.skrabec@xxxxxxxxx> Cc: Jonas Karlman <jonas@xxxxxxxxx> Cc: Laurent Pinchart <Laurent.pinchart@xxxxxxxxxxxxxxxx> Cc: Liu Ying <victor.liu@xxxxxxx> Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx> Cc: Maxime Ripard <mripard@xxxxxxxxxx> Cc: Neil Armstrong <neil.armstrong@xxxxxxxxxx> Cc: Pengutronix Kernel Team <kernel@xxxxxxxxxxxxxx> Cc: Robert Foss <rfoss@xxxxxxxxxx> Cc: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> Cc: Shawn Guo <shawnguo@xxxxxxxxxx> Cc: Simona Vetter <simona@xxxxxxxx> Cc: Stefan Agner <stefan@xxxxxxxx> Cc: Thomas Zimmermann <tzimmermann@xxxxxxx> Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx Cc: imx@xxxxxxxxxxxxxxx Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx --- drivers/gpu/drm/mxsfb/Kconfig | 1 + drivers/gpu/drm/mxsfb/mxsfb_drv.c | 36 +++++++++++++++++++++---------- drivers/gpu/drm/mxsfb/mxsfb_drv.h | 2 +- drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 +++--- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/Kconfig b/drivers/gpu/drm/mxsfb/Kconfig index 07fb6901996ae..e67de148955b2 100644 --- a/drivers/gpu/drm/mxsfb/Kconfig +++ b/drivers/gpu/drm/mxsfb/Kconfig @@ -12,6 +12,7 @@ config DRM_MXSFB select DRM_CLIENT_SELECTION select DRM_MXS select DRM_KMS_HELPER + select DRM_BRIDGE_CONNECTOR select DRM_GEM_DMA_HELPER select DRM_PANEL select DRM_PANEL_BRIDGE diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index 59020862cf65e..d034c21e186a4 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -20,6 +20,7 @@ #include <drm/clients/drm_client_setup.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_bridge.h> +#include <drm/drm_bridge_connector.h> #include <drm/drm_connector.h> #include <drm/drm_drv.h> #include <drm/drm_fbdev_dma.h> @@ -118,10 +119,10 @@ static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = { static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb) { + struct drm_connector *connector = &mxsfb->connector; struct drm_device *drm = mxsfb->drm; - struct drm_connector_list_iter iter; - struct drm_panel *panel; struct drm_bridge *bridge; + struct drm_panel *panel; int ret; ret = drm_of_find_panel_or_bridge(drm->dev->of_node, 0, 0, &panel, @@ -139,21 +140,34 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb) if (!bridge) return -ENODEV; - ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL, 0); + ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) return dev_err_probe(drm->dev, ret, "Failed to attach bridge\n"); - mxsfb->bridge = bridge; + connector = drm_bridge_connector_init(drm, &mxsfb->encoder); + if (IS_ERR(connector)) { + ret = PTR_ERR(connector); + dev_err_probe(drm->dev, ret, + "Failed to initialize bridge connector: %pe\n", + connector); + return ret; + } - /* - * Get hold of the connector. This is a bit of a hack, until the bridge - * API gives us bus flags and formats. - */ - drm_connector_list_iter_begin(drm, &iter); - mxsfb->connector = drm_connector_list_iter_next(&iter); - drm_connector_list_iter_end(&iter); + ret = drm_connector_attach_encoder(connector, &mxsfb->encoder); + if (ret < 0) { + dev_err_probe(drm->dev, ret, + "Failed to attach encoder.\n"); + goto err_cleanup_connector; + } + + mxsfb->bridge = bridge; return 0; + +err_cleanup_connector: + drm_connector_cleanup(connector); + return ret; } static irqreturn_t mxsfb_irq_handler(int irq, void *data) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h index d160d921b25fc..7a24e96ab4263 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h @@ -43,7 +43,7 @@ struct mxsfb_drm_private { } planes; struct drm_crtc crtc; struct drm_encoder encoder; - struct drm_connector *connector; + struct drm_connector connector; struct drm_bridge *bridge; bool crc_active; diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index 7ed2516b6de05..30584091e2aa8 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -281,7 +281,7 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb, { struct drm_device *drm = mxsfb->crtc.dev; struct drm_display_mode *m = &mxsfb->crtc.state->adjusted_mode; - u32 bus_flags = mxsfb->connector->display_info.bus_flags; + u32 bus_flags = mxsfb->connector.display_info.bus_flags; int err; if (mxsfb->bridge && mxsfb->bridge->timings) @@ -378,8 +378,8 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc, } /* If there is no bridge, use bus format from connector */ - if (!bus_format && mxsfb->connector->display_info.num_bus_formats) - bus_format = mxsfb->connector->display_info.bus_formats[0]; + if (!bus_format && mxsfb->connector.display_info.num_bus_formats) + bus_format = mxsfb->connector.display_info.bus_formats[0]; /* If all else fails, default to RGB888_1X24 */ if (!bus_format) -- 2.45.2