[PATCH v13 02/17] drm/bridge: Move legacy bridge driver out of imx directory for multi-platform use

Damon Ding
2026-04-09T08:08:52Z

As suggested by Dmitry, the DRM legacy bridge driver can be pulled
out of imx/ subdir for multi-platform use. The driver is also renamed
to make it more generic and suitable for platforms other than i.MX.

Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de> # rk3588

---

Changes in v7:
- Rename legacy-bridge to of-display-mode-bridge.
- Remove unnecessary API drm_bridge_is_legacy().

Changes in v9:
- Fix the Kconfig help text.
- Add Tested-by tag.

Changes in v10:
- Add Reviewed-by tag.

Changes in v13:
- Rebase after commit 02df94d98ff8 ("drm/imx: parallel-display: add
DRM_DISPLAY_HELPER for DRM_IMX_PARALLEL_DISPLAY")
- Modify '(on rk3588)' to '# rk3588' for Tested-by tag.
---
drivers/gpu/drm/bridge/Kconfig | 10 ++
drivers/gpu/drm/bridge/Makefile | 1 +
drivers/gpu/drm/bridge/imx/Kconfig | 10 --
drivers/gpu/drm/bridge/imx/Makefile | 1 -
.../gpu/drm/bridge/imx/imx-legacy-bridge.c | 91 ------------------
.../gpu/drm/bridge/of-display-mode-bridge.c | 93 +++++++++++++++++++
drivers/gpu/drm/imx/ipuv3/Kconfig | 4 +-
drivers/gpu/drm/imx/ipuv3/imx-ldb.c | 6 +-
drivers/gpu/drm/imx/ipuv3/parallel-display.c | 5 +-
include/drm/bridge/imx.h | 17 ----
include/drm/bridge/of-display-mode-bridge.h | 17 ++++
11 files changed, 129 insertions(+), 126 deletions(-)
delete mode 100644 drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
create mode 100644 drivers/gpu/drm/bridge/of-display-mode-bridge.c
delete mode 100644 include/drm/bridge/imx.h
create mode 100644 include/drm/bridge/of-display-mode-bridge.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index c3209b0f4678..f81b566c82a1 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -262,6 +262,16 @@ config DRM_NXP_PTN3460
help
NXP PTN3460 eDP-LVDS bridge chip driver.

+config DRM_OF_DISPLAY_MODE_BRIDGE
+ tristate
+ depends on DRM_BRIDGE && OF
+ help
+ This is a DRM bridge implementation that uses of_get_drm_display_mode
+ to acquire display mode.
+
+ It exists for compatibility with legacy display mode parsing, in order
+ to conform to the panel-bridge framework.
+
config DRM_PARADE_PS8622
tristate "Parade eDP/LVDS bridge"
depends on OF
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index beab5b695a6e..15cc821d85b7 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_DRM_LVDS_CODEC) += lvds-codec.o
obj-$(CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW) += megachips-stdpxxxx-ge-b850v3-fw.o
obj-$(CONFIG_DRM_MICROCHIP_LVDS_SERIALIZER) += microchip-lvds.o
obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
+obj-$(CONFIG_DRM_OF_DISPLAY_MODE_BRIDGE) += of-display-mode-bridge.o
obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o
obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o
obj-$(CONFIG_DRM_SAMSUNG_DSIM) += samsung-dsim.o
diff --git a/drivers/gpu/drm/bridge/imx/Kconfig b/drivers/gpu/drm/bridge/imx/Kconfig
index b9028a5e5a06..8877b9789868 100644
--- a/drivers/gpu/drm/bridge/imx/Kconfig
+++ b/drivers/gpu/drm/bridge/imx/Kconfig
@@ -3,16 +3,6 @@ if ARCH_MXC || COMPILE_TEST
config DRM_IMX_LDB_HELPER
tristate

-config DRM_IMX_LEGACY_BRIDGE
- tristate
- depends on DRM_IMX
- help
- This is a DRM bridge implementation for the DRM i.MX IPUv3 driver,
- that uses of_get_drm_display_mode to acquire display mode.
-
- Newer designs should not use this bridge and should use proper panel
- driver instead.
-
config DRM_IMX8MP_DW_HDMI_BRIDGE
tristate "Freescale i.MX8MP HDMI-TX bridge support"
depends on OF
diff --git a/drivers/gpu/drm/bridge/imx/Makefile b/drivers/gpu/drm/bridge/imx/Makefile
index 8d01fda25451..69d9f9abbe36 100644
--- a/drivers/gpu/drm/bridge/imx/Makefile
+++ b/drivers/gpu/drm/bridge/imx/Makefile
@@ -1,5 +1,4 @@
obj-$(CONFIG_DRM_IMX_LDB_HELPER) += imx-ldb-helper.o
-obj-$(CONFIG_DRM_IMX_LEGACY_BRIDGE) += imx-legacy-bridge.o
obj-$(CONFIG_DRM_IMX8MP_DW_HDMI_BRIDGE) += imx8mp-hdmi-tx.o
obj-$(CONFIG_DRM_IMX8MP_HDMI_PAI) += imx8mp-hdmi-pai.o
obj-$(CONFIG_DRM_IMX8MP_HDMI_PVI) += imx8mp-hdmi-pvi.o
diff --git a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c b/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
deleted file mode 100644
index 0e31d5000e7c..000000000000
--- a/drivers/gpu/drm/bridge/imx/imx-legacy-bridge.c
+++ /dev/null
@@ -1,91 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Freescale i.MX drm driver
- *
- * bridge driver for legacy DT bindings, utilizing display-timings node
- */
-
-#include <linux/export.h>
-
-#include <drm/drm_bridge.h>
-#include <drm/drm_modes.h>
-#include <drm/drm_probe_helper.h>
-#include <drm/bridge/imx.h>
-
-#include <video/of_display_timing.h>
-#include <video/of_videomode.h>
-
-struct imx_legacy_bridge {
- struct drm_bridge base;
-
- struct drm_display_mode mode;
- u32 bus_flags;
-};
-
-#define to_imx_legacy_bridge(bridge) container_of(bridge, struct imx_legacy_bridge, base)
-
-static int imx_legacy_bridge_attach(struct drm_bridge *bridge,
- struct drm_encoder *encoder,
- enum drm_bridge_attach_flags flags)
-{
- if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
- return -EINVAL;
-
- return 0;
-}
-
-static int imx_legacy_bridge_get_modes(struct drm_bridge *bridge,
- struct drm_connector *connector)
-{
- struct imx_legacy_bridge *imx_bridge = to_imx_legacy_bridge(bridge);
- int ret;
-
- ret = drm_connector_helper_get_modes_fixed(connector, &imx_bridge->mode);
- if (ret)
- return ret;
-
- connector->display_info.bus_flags = imx_bridge->bus_flags;
-
- return 0;
-}
-
-struct drm_bridge_funcs imx_legacy_bridge_funcs = {
- .attach = imx_legacy_bridge_attach,
- .get_modes = imx_legacy_bridge_get_modes,
-};
-
-struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
- struct device_node *np,
- int type)
-{
- struct imx_legacy_bridge *imx_bridge;
- int ret;
-
- imx_bridge = devm_drm_bridge_alloc(dev, struct imx_legacy_bridge,
- base, &imx_legacy_bridge_funcs);
- if (IS_ERR(imx_bridge))
- return ERR_CAST(imx_bridge);
-
- ret = of_get_drm_display_mode(np,
- &imx_bridge->mode,
- &imx_bridge->bus_flags,
- OF_USE_NATIVE_MODE);
- if (ret)
- return ERR_PTR(ret);
-
- imx_bridge->mode.type |= DRM_MODE_TYPE_DRIVER;
-
- imx_bridge->base.of_node = np;
- imx_bridge->base.ops = DRM_BRIDGE_OP_MODES;
- imx_bridge->base.type = type;
-
- ret = devm_drm_bridge_add(dev, &imx_bridge->base);
- if (ret)
- return ERR_PTR(ret);
-
- return &imx_bridge->base;
-}
-EXPORT_SYMBOL_GPL(devm_imx_drm_legacy_bridge);
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Freescale i.MX DRM bridge driver for legacy DT bindings");
diff --git a/drivers/gpu/drm/bridge/of-display-mode-bridge.c b/drivers/gpu/drm/bridge/of-display-mode-bridge.c
new file mode 100644
index 000000000000..cb15713f3a79
--- /dev/null
+++ b/drivers/gpu/drm/bridge/of-display-mode-bridge.c
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2012 Sascha Hauer, Pengutronix
+ *
+ * bridge driver for legacy DT bindings, utilizing display-timings node
+ *
+ * Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
+ */
+
+#include <linux/export.h>
+
+#include <drm/drm_bridge.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_probe_helper.h>
+#include <drm/bridge/of-display-mode-bridge.h>
+
+#include <video/of_display_timing.h>
+#include <video/of_videomode.h>
+
+struct of_display_mode_bridge {
+ struct drm_bridge base;
+
+ struct drm_display_mode mode;
+ u32 bus_flags;
+};
+
+#define to_of_display_mode_bridge(bridge) container_of(bridge, struct of_display_mode_bridge, base)
+
+static int of_display_mode_bridge_attach(struct drm_bridge *bridge,
+ struct drm_encoder *encoder,
+ enum drm_bridge_attach_flags flags)
+{
+ if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
+ return -EINVAL;
+
+ return 0;
+}
+
+static int of_display_mode_bridge_get_modes(struct drm_bridge *bridge,
+ struct drm_connector *connector)
+{
+ struct of_display_mode_bridge *of_bridge = to_of_display_mode_bridge(bridge);
+ int ret;
+
+ ret = drm_connector_helper_get_modes_fixed(connector, &of_bridge->mode);
+ if (ret)
+ return ret;
+
+ connector->display_info.bus_flags = of_bridge->bus_flags;
+
+ return 0;
+}
+
+struct drm_bridge_funcs of_display_mode_bridge_funcs = {
+ .attach = of_display_mode_bridge_attach,
+ .get_modes = of_display_mode_bridge_get_modes,
+};
+
+struct drm_bridge *devm_drm_of_display_mode_bridge(struct device *dev,
+ struct device_node *np,
+ int type)
+{
+ struct of_display_mode_bridge *of_bridge;
+ int ret;
+
+ of_bridge = devm_drm_bridge_alloc(dev, struct of_display_mode_bridge,
+ base, &of_display_mode_bridge_funcs);
+ if (IS_ERR(of_bridge))
+ return ERR_CAST(of_bridge);
+
+ ret = of_get_drm_display_mode(np,
+ &of_bridge->mode,
+ &of_bridge->bus_flags,
+ OF_USE_NATIVE_MODE);
+ if (ret)
+ return ERR_PTR(ret);
+
+ of_bridge->mode.type |= DRM_MODE_TYPE_DRIVER;
+
+ of_bridge->base.of_node = np;
+ of_bridge->base.ops = DRM_BRIDGE_OP_MODES;
+ of_bridge->base.type = type;
+
+ ret = devm_drm_bridge_add(dev, &of_bridge->base);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return &of_bridge->base;
+}
+EXPORT_SYMBOL_GPL(devm_drm_of_display_mode_bridge);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("DRM bridge driver for legacy DT bindings");
diff --git a/drivers/gpu/drm/imx/ipuv3/Kconfig b/drivers/gpu/drm/imx/ipuv3/Kconfig
index b2240998df4f..351dc65913eb 100644
--- a/drivers/gpu/drm/imx/ipuv3/Kconfig
+++ b/drivers/gpu/drm/imx/ipuv3/Kconfig
@@ -16,7 +16,7 @@ config DRM_IMX_PARALLEL_DISPLAY
select DRM_BRIDGE
select DRM_BRIDGE_CONNECTOR
select DRM_DISPLAY_HELPER
- select DRM_IMX_LEGACY_BRIDGE
+ select DRM_OF_DISPLAY_MODE_BRIDGE
select DRM_PANEL_BRIDGE
select VIDEOMODE_HELPERS

@@ -37,7 +37,7 @@ config DRM_IMX_LDB
select DRM_BRIDGE
select DRM_BRIDGE_CONNECTOR
select DRM_PANEL_BRIDGE
- select DRM_IMX_LEGACY_BRIDGE
+ select DRM_OF_DISPLAY_MODE_BRIDGE
help
Choose this to enable the internal LVDS Display Bridge (LDB)
found on i.MX53 and i.MX6 processors.
diff --git a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
index 626d410d9150..730caf883e83 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
+++ b/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
@@ -28,7 +28,7 @@
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h>
-#include <drm/bridge/imx.h>
+#include <drm/bridge/of-display-mode-bridge.h>

#include "imx-drm.h"

@@ -605,8 +605,8 @@ static int imx_ldb_probe(struct platform_device *pdev)
* checking the bus_format property.
*/
if (!channel->bridge) {
- channel->bridge = devm_imx_drm_legacy_bridge(dev, child,
- DRM_MODE_CONNECTOR_LVDS);
+ channel->bridge = devm_drm_of_display_mode_bridge(dev, child,
+ DRM_MODE_CONNECTOR_LVDS);
if (IS_ERR(channel->bridge)) {
ret = PTR_ERR(channel->bridge);
goto free_child;
diff --git a/drivers/gpu/drm/imx/ipuv3/parallel-display.c b/drivers/gpu/drm/imx/ipuv3/parallel-display.c
index a356f0b764cb..6c505becb31d 100644
--- a/drivers/gpu/drm/imx/ipuv3/parallel-display.c
+++ b/drivers/gpu/drm/imx/ipuv3/parallel-display.c
@@ -19,7 +19,7 @@
#include <drm/drm_of.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h>
-#include <drm/bridge/imx.h>
+#include <drm/bridge/of-display-mode-bridge.h>

#include "imx-drm.h"

@@ -242,7 +242,8 @@ static int imx_pd_probe(struct platform_device *pdev)
/* port@1 is the output port */
imxpd->next_bridge = devm_drm_of_get_bridge(dev, np, 1, 0);
if (imxpd->next_bridge == ERR_PTR(-ENODEV))
- imxpd->next_bridge = devm_imx_drm_legacy_bridge(dev, np, DRM_MODE_CONNECTOR_DPI);
+ imxpd->next_bridge = devm_drm_of_display_mode_bridge(dev, np,
+ DRM_MODE_CONNECTOR_DPI);
if (IS_ERR(imxpd->next_bridge)) {
ret = PTR_ERR(imxpd->next_bridge);
return ret;
diff --git a/include/drm/bridge/imx.h b/include/drm/bridge/imx.h
deleted file mode 100644
index b93f719fe0e7..000000000000
--- a/include/drm/bridge/imx.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2012 Sascha Hauer, Pengutronix
- */
-
-#ifndef DRM_IMX_BRIDGE_H
-#define DRM_IMX_BRIDGE_H
-
-struct device;
-struct device_node;
-struct drm_bridge;
-
-struct drm_bridge *devm_imx_drm_legacy_bridge(struct device *dev,
- struct device_node *np,
- int type);
-
-#endif
diff --git a/include/drm/bridge/of-display-mode-bridge.h b/include/drm/bridge/of-display-mode-bridge.h
new file mode 100644
index 000000000000..89fcfedf68d8
--- /dev/null
+++ b/include/drm/bridge/of-display-mode-bridge.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2012 Sascha Hauer, Pengutronix
+ */
+
+#ifndef DRM_OF_DISPLAY_MODE_BRIDGE_H
+#define DRM_OF_DISPLAY_MODE_BRIDGE_H
+
+struct device;
+struct device_node;
+struct drm_bridge;
+
+struct drm_bridge *devm_drm_of_display_mode_bridge(struct device *dev,
+ struct device_node *np,
+ int type);
+
+#endif
--
2.34.1