Skip to contentSkip to conversation

Add support for Waveshare DSI2DPI unit

PATCH Superseded Joseph Guo 5 participants 19 messages Aug 4, 2025 – Aug 5, 2025

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Joseph Guo

author
#0 lore raw

v2 cover Add support for Waveshare DSI2DPI unit

This patchset add support for waveshare DSI2DPI unit.

---
Changes in v2:
- /s/i2c0/i2c/ in patch 1
- Add Review tags
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Joseph Guo (3):
dt-bindings: display: bridge: Add waveshare DSI2DPI unit support
dt-bindings: display: panel: Add waveshare DPI panel support
drm: bridge: Add waveshare DSI2DPI unit driver

 .../bindings/display/bridge/waveshare,dsi2dpi.yaml | 103 ++++++++++
 .../bindings/display/panel/panel-simple.yaml       |   4 +
 drivers/gpu/drm/bridge/Kconfig                     |  11 ++
 drivers/gpu/drm/bridge/Makefile                    |   1 +
 drivers/gpu/drm/bridge/waveshare-dsi.c             | 210 +++++++++++++++++++++
 5 files changed, 329 insertions(+)

---
base-commit: 0952d89c3acf6590b89bcfb8505595d7c0e6f367
change-id: 20250715-waveshare-dad93ea9980f

Best regards,

Signature · 1 line
Joseph Guo <[email protected]>
author
#1 lore raw

PATCH v2 1/3 dt-bindings: display: bridge: Add waveshare DSI2DPI unit support

Add dt-binding documentation for waveshare DSI2DPI unit

---
Change from v1 to v2
- /s/i2c0/i2c/

---
 .../bindings/display/bridge/waveshare,dsi2dpi.yaml | 103 +++++++++++++++++++++
 1 file changed, 103 insertions(+)
Documentation/devicetree/bindings/display/bridge/waveshare,dsi2dpi.yaml new file +103 -0
new file mode 100644
index 0000000000000000000000000000000000000000..5e8498c8303dd7415ecca97d12ac97362db73cf5
@@ -0,0 +1,103 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/bridge/waveshare,dsi2dpi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Waveshare MIPI-DSI to DPI Converter bridge
+
+maintainers:
+  - Joseph Guo <[email protected]>
+
+description:
+  Waveshare bridge board is part of Waveshare panel which converts DSI to DPI.
+
+properties:
+  compatible:
+    const: waveshare,dsi2dpi
+
+  reg:
+    maxItems: 1
+    description: base I2C address of the device
+
+  power-supply: true
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/$defs/port-base
+        unevaluatedProperties: false
+        description:
+          Video port for MIPI DSI input
+
+        properties:
+          endpoint:
+            $ref: /schemas/media/video-interfaces.yaml#
+            unevaluatedProperties: false
+
+            properties:
+              data-lanes:
+                description: array of physical DSI data lane indexes.
+                items:
+                  - const: 1
+                  - const: 2
+
+            required:
+              - data-lanes
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        description:
+          Video port for MIPI DPI output panel.
+
+    required:
+      - port@0
+      - port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+  - power-supply
+
+additionalProperties: false
+
+examples:
+  - |
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      bridge@45 {
+        compatible = "waveshare,dsi2dpi";
+        reg = <0x45>;
+        power-supply = <&reg_3p3v>;
+
+        ports {
+          #address-cells = <1>;
+          #size-cells = <0>;
+
+          port@0 {
+            reg = <0>;
+
+            waveshare_from_dsim: endpoint {
+              data-lanes = <1 2>;
+              remote-endpoint = <&dsim_to_waveshare>;
+            };
+          };
+
+          port@1 {
+            reg = <1>;
+
+            waveshare_to_panel: endpoint {
+              remote-endpoint = <&panel_to_waveshare>;
+            };
+          };
+        };
+      };
+    };
+
+...
Signature · 1 line
2.34.1
Acked-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: display: bridge: Add waveshare DSI2DPI unit support

Quoted 10 lines · Joseph Guo

Add dt-binding documentation for waveshare DSI2DPI unit

---
Change from v1 to v2
- /s/i2c0/i2c/

---
 .../bindings/display/bridge/waveshare,dsi2dpi.yaml | 103 +++++++++++++++++++++
 1 file changed, 103 insertions(+)
author
#3 lore raw

PATCH v2 2/3 dt-bindings: display: panel: Add waveshare DPI panel support

In reply to Joseph Guo

Add dt-binding documentation for waveshare DPI panel

---
 Documentation/devicetree/bindings/display/panel/panel-simple.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/display/panel/panel-simple.yaml +4 -0
index b89e3979057911ab9e669e97e71c16578d9e0150..16465fe3333948909c5d1fdc2a4ddf231bfbce70 100644
@@ -301,6 +301,10 @@ properties:
       - vivax,tpc9150-panel
         # VXT 800x480 color TFT LCD panel
       - vxt,vl050-8048nt-c01
+        # Waveshare 13.3" FHD (1920x1080) LCD panel
+      - waveshare,13.3inch-panel
+        # Waveshare 7.0" WSVGA (1024x600) LCD panel
+      - waveshare,7.0inch-c-panel
         # Winstar Display Corporation 3.5" QVGA (320x240) TFT LCD panel
       - winstar,wf35ltiacd
         # Yes Optoelectronics YTC700TLAG-05-201C 7" TFT LCD panel
Signature · 1 line
2.34.1
Acked-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] dt-bindings: display: panel: Add waveshare DPI panel support

Quoted 7 lines · Joseph Guo

Add dt-binding documentation for waveshare DPI panel

---
 Documentation/devicetree/bindings/display/panel/panel-simple.yaml | 4 ++++
 1 file changed, 4 insertions(+)
#5 lore raw

Re: [PATCH v2 2/3] dt-bindings: display: panel: Add waveshare DPI panel support

Quoted 10 lines · Liu Ying
Quoted 7 lines · Joseph Guo

Add dt-binding documentation for waveshare DPI panel

---
 Documentation/devicetree/bindings/display/panel/panel-simple.yaml | 4 ++++
 1 file changed, 4 insertions(+)

What issue is being fixed here, that you suggested?

Quoted 1 line

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH v2 2/3] dt-bindings: display: panel: Add waveshare DPI panel support

Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Joseph Guo

Add dt-binding documentation for waveshare DPI panel

That's not true. Please point me to lore discussion proving you received such tag.

Joseph, that tag should be A-b instead of R-b. You may use b4 or patchwork. They should collect tags for you.

https://lore.kernel.org/all/[email protected]/#t

Quoted 4 lines

Best regards,
Krzysztof

Signature · 2 lines
Regards,
Liu Ying
author
#8 lore raw

PATCH v2 3/3 drm: bridge: Add waveshare DSI2DPI unit driver

In reply to Joseph Guo

Waveshare touchscreen consists of a DPI panel and a driver board. The waveshare driver board consists of ICN6211 and a MCU to convert DSI to DPI and control the backlight.
This driver treats the MCU and ICN6211 board as a whole unit. It can support all resolution waveshare DSI2DPI based panel, the timing table should come from 'panel-dpi' panel in the device tree.

---
 drivers/gpu/drm/bridge/Kconfig         |  11 ++
 drivers/gpu/drm/bridge/Makefile        |   1 +
 drivers/gpu/drm/bridge/waveshare-dsi.c | 210 +++++++++++++++++++++++++++++++++
 3 files changed, 222 insertions(+)
drivers/gpu/drm/bridge/Kconfig +11 -0
index cb3b797fcea1c73e83c9187fef6582296b340305..26fec25c61ed7d950c094e0224f1196946079485 100644
@@ -472,4 +472,15 @@ config DRM_ITE_IT6161
 	help
 	  ITE IT6161 bridge chip driver.
 
+config DRM_WAVESHARE_BRIDGE
+	tristate "Waveshare DSI bridge"
+	depends on OF
+	select DRM_PANEL_BRIDGE
+	select DRM_KMS_HELPER
+	select DRM_MIPI_DSI
+	select REGMAP_I2C
+	help
+	  Driver for waveshare DSI to DPI bridge board.
+	  Please say Y if you have such hardware
+
 endmenu
drivers/gpu/drm/bridge/Makefile +1 -0
index d1db90688a150fdc3a5fd40acebe740798c452b0..3caa4d8f71675804328aa5a51ec67b2587938621 100644
@@ -48,3 +48,4 @@ obj-$(CONFIG_DRM_ITE_IT6263) += it6263.o
 obj-$(CONFIG_DRM_ITE_IT6161) += it6161.o
 obj-$(CONFIG_DRM_SEC_MIPI_DSIM) += sec-dsim.o
 obj-$(CONFIG_DRM_NXP_SEIKO_43WVFIG) += nxp-seiko-43wvfig.o
+obj-$(CONFIG_DRM_WAVESHARE_BRIDGE) += waveshare-dsi.o
drivers/gpu/drm/bridge/waveshare-dsi.c new file +210 -0

210 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 3/3
#9 lore raw

Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

Quoted 250 lines · Joseph Guo

Waveshare touchscreen consists of a DPI panel and a driver board. The waveshare driver board consists of ICN6211 and a MCU to convert DSI to DPI and control the backlight.
This driver treats the MCU and ICN6211 board as a whole unit. It can support all resolution waveshare DSI2DPI based panel, the timing table should come from 'panel-dpi' panel in the device tree.

---
  drivers/gpu/drm/bridge/Kconfig         |  11 ++
  drivers/gpu/drm/bridge/Makefile        |   1 +
  drivers/gpu/drm/bridge/waveshare-dsi.c | 210 +++++++++++++++++++++++++++++++++
  3 files changed, 222 insertions(+)
drivers/gpu/drm/bridge/Kconfig +11 -0
index cb3b797fcea1c73e83c9187fef6582296b340305..26fec25c61ed7d950c094e0224f1196946079485 100644
@@ -472,4 +472,15 @@ config DRM_ITE_IT6161
  	help
  	  ITE IT6161 bridge chip driver.
 
+config DRM_WAVESHARE_BRIDGE
+	tristate "Waveshare DSI bridge"
+	depends on OF
+	select DRM_PANEL_BRIDGE
+	select DRM_KMS_HELPER
+	select DRM_MIPI_DSI
+	select REGMAP_I2C
+	help
+	  Driver for waveshare DSI to DPI bridge board.
+	  Please say Y if you have such hardware
+
  endmenu
drivers/gpu/drm/bridge/Makefile +1 -0
index d1db90688a150fdc3a5fd40acebe740798c452b0..3caa4d8f71675804328aa5a51ec67b2587938621 100644
@@ -48,3 +48,4 @@ obj-$(CONFIG_DRM_ITE_IT6263) += it6263.o
  obj-$(CONFIG_DRM_ITE_IT6161) += it6161.o
  obj-$(CONFIG_DRM_SEC_MIPI_DSIM) += sec-dsim.o
  obj-$(CONFIG_DRM_NXP_SEIKO_43WVFIG) += nxp-seiko-43wvfig.o
+obj-$(CONFIG_DRM_WAVESHARE_BRIDGE) += waveshare-dsi.o
drivers/gpu/drm/bridge/waveshare-dsi.c new file +200 -0
new file mode 100644
index 0000000000000000000000000000000000000000..efb3a2fc501b5725b02f49862526d1704a3a4b7b
@@ -0,0 +1,210 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ *  Copyright 2025 NXP
+ * Based on panel-raspberrypi-touchscreen by Broadcom
+ */
+
+#include <linux/backlight.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_graph.h>
+#include <linux/regmap.h>
+
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_bridge.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_of.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+
+struct ws_bridge {
+	struct drm_bridge bridge;
+	struct drm_bridge *next_bridge;
+	struct backlight_device *backlight;
+	struct device *dev;
+	struct regmap *reg_map;
+};
+
+static const struct regmap_config ws_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = 0xff,
+	.disable_debugfs = true,
+};
+
+static struct ws_bridge *bridge_to_ws_bridge(struct drm_bridge *bridge)
+{
+	return container_of(bridge, struct ws_bridge, bridge);
+}
+
+static int ws_bridge_attach_dsi(struct ws_bridge *ws)
+{
+	struct device_node *dsi_host_node;
+	struct mipi_dsi_host *host;
+	struct mipi_dsi_device *dsi;
+	const struct mipi_dsi_device_info info = {
+		.type = "ws-bridge",
+		.channel = 0,
+		.node = NULL,
+	};
+	struct device *dev = ws->dev;
+	int ret;
+
+	dsi_host_node = of_graph_get_remote_node(dev->of_node, 0, 0);
+	if (!dsi_host_node) {
+		dev_err(dev, "Failed to get remote port\n");
+		return -ENODEV;
+	}
+
+	host = of_find_mipi_dsi_host_by_node(dsi_host_node);
+
+	of_node_put(dsi_host_node);
+	if (!host)
+		return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find dsi_host\n");
+
+	dsi = devm_mipi_dsi_device_register_full(dev, host, &info);
+
+	if (IS_ERR(dsi))
+		return dev_err_probe(dev, PTR_ERR(dsi), "Failed to create dsi device\n");
+
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_VIDEO |
+			  MIPI_DSI_CLOCK_NON_CONTINUOUS;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->lanes = 2;
+
+	ret = devm_mipi_dsi_attach(dev, dsi);
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Failed to attach dsi to host\n");
+
+	return 0;
+}
+
+static int ws_bridge_bridge_attach(struct drm_bridge *bridge,
+				   enum drm_bridge_attach_flags flags)
+{
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+	int ret;
+
+	ret = ws_bridge_attach_dsi(ws);
+	if (ret)
+		return ret;
+
+	return drm_bridge_attach(ws->bridge.encoder, ws->next_bridge,
+				 &ws->bridge, flags);
+}
+
+static void ws_bridge_bridge_enable(struct drm_bridge *bridge)
+{
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+
+	regmap_write(ws->reg_map, 0xad, 0x01);
+	backlight_enable(ws->backlight);
+}
+
+static void ws_bridge_bridge_disable(struct drm_bridge *bridge)
+{
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+
+	backlight_disable(ws->backlight);
+	regmap_write(ws->reg_map, 0xad, 0x00);
+}
+
+static const struct drm_bridge_funcs ws_bridge_bridge_funcs = {
+	.enable = ws_bridge_bridge_enable,
+	.disable = ws_bridge_bridge_disable,
+	.attach = ws_bridge_bridge_attach,
+};
+
+static int ws_bridge_bl_update_status(struct backlight_device *bl)
+{
+	struct ws_bridge *ws = bl_get_data(bl);
+
+	regmap_write(ws->reg_map, 0xab, 0xff - backlight_get_brightness(bl));
+	regmap_write(ws->reg_map, 0xaa, 0x01);
+
+	return 0;
+}
+
+static const struct backlight_ops ws_bridge_bl_ops = {
+	.update_status = ws_bridge_bl_update_status,
+};
+
+static struct backlight_device *ws_bridge_create_backlight(struct ws_bridge *ws)
+{
+	struct device *dev = ws->dev;
+	const struct backlight_properties props = {
+		.type = BACKLIGHT_RAW,
+		.brightness = 255,
+		.max_brightness = 255,
+	};
+
+	return devm_backlight_device_register(dev, dev_name(dev), dev, ws,
+					      &ws_bridge_bl_ops, &props);
+}
+
+static int ws_bridge_probe(struct i2c_client *i2c)
+{
+	struct device *dev = &i2c->dev;
+	struct ws_bridge *ws;
+	struct drm_panel *panel;
+	int ret;
+	struct backlight_device *backlight;
+
+	ws = devm_kzalloc(dev, sizeof(*ws), GFP_KERNEL);
+	if (!ws)
+		return -ENOMEM;
+
+	ws->dev = dev;
+
+	ws->reg_map = devm_regmap_init_i2c(i2c, &ws_regmap_config);
+	if (IS_ERR(ws->reg_map))
+		return dev_err_probe(dev, PTR_ERR(ws->reg_map), "Failed to allocate regmap\n");
+
+	ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, &panel, NULL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to find remote panel\n");
+
+	ws->next_bridge = devm_drm_panel_bridge_add(dev, panel);
+	if (IS_ERR(ws->next_bridge))
+		return PTR_ERR(ws->next_bridge);
+
+	ws->backlight = ws_bridge_create_backlight(ws);
+	if (IS_ERR(backlight)) {
+		ret = PTR_ERR(backlight);
+		dev_err(dev, "Failed to create backlight: %d\n", ret);
+		return ret;
+	}
+
+	regmap_write(ws->reg_map, 0xc0, 0x01);
+	regmap_write(ws->reg_map, 0xc2, 0x01);
+	regmap_write(ws->reg_map, 0xac, 0x01);
+
+	ws->bridge.funcs = &ws_bridge_bridge_funcs;
+	ws->bridge.type = DRM_MODE_CONNECTOR_DPI;
+	ws->bridge.of_node = dev->of_node;
+	devm_drm_bridge_add(dev, &ws->bridge);
+
+	return 0;
+}
+
+static const struct of_device_id ws_bridge_of_ids[] = {
+	{.compatible = "waveshare,dsi2dpi",},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, ws_bridge_of_ids);
+
+static struct i2c_driver ws_bridge_driver = {
+	.driver = {

drivers/gpu/drm/bridge/waveshare-dsi.c line 210

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+		.name = "ws_dsi2dpi",
+		.of_match_table = ws_bridge_of_ids,
+	},
+	.probe = ws_bridge_probe,
+};
+module_i2c_driver(ws_bridge_driver);
+
+MODULE_AUTHOR("Joseph Guo <[email protected]>");
+MODULE_DESCRIPTION("Waveshare DSI2DPI bridge driver");
+MODULE_LICENSE("GPL");

LGTM

#10 lore raw

Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

In reply to Joseph Guo

Hi Joseph,

Quoted 8 lines · Joseph Guo

Waveshare touchscreen consists of a DPI panel and a driver board. The waveshare driver board consists of ICN6211 and a MCU to convert DSI to DPI and control the backlight.
This driver treats the MCU and ICN6211 board as a whole unit. It can support all resolution waveshare DSI2DPI based panel, the timing table should come from 'panel-dpi' panel in the device tree.

For next version, you may add:

Quoted 5 lines
---
 drivers/gpu/drm/bridge/Kconfig         |  11 ++
 drivers/gpu/drm/bridge/Makefile        |   1 +
 drivers/gpu/drm/bridge/waveshare-dsi.c | 210 +++++++++++++++++++++++++++++++++
 3 files changed, 222 insertions(+)

This patch doesn't apply to drm-misc-next cleanly. I see conflicts in Kconfig and Makefile. It seems that you generate the patch series based on NXP down stream kernel instead of the upstream kernel.

drivers/gpu/drm/bridge/Kconfig config DRM_ITE_IT6161 · line 475

Quoted 10 lines
drivers/gpu/drm/bridge/Kconfig +1 -0
index cb3b797fcea1c73e83c9187fef6582296b340305..26fec25c61ed7d950c094e0224f1196946079485 100644
@@ -472,4 +472,15 @@ config DRM_ITE_IT6161
 	help
 	  ITE IT6161 bridge chip driver.
 
+config DRM_WAVESHARE_BRIDGE

Sort the config names alphabetically.

drivers/gpu/drm/bridge/Kconfig config DRM_ITE_IT6161 · line 476

Quoted 1 line
drivers/gpu/drm/bridge/Kconfig +1 -0
+	tristate "Waveshare DSI bridge"

depends on BACKLIGHT_CLASS_DEVICE

Quoted 15 lines
drivers/gpu/drm/bridge/Kconfig +9 -0
+	depends on OF
+	select DRM_PANEL_BRIDGE
+	select DRM_KMS_HELPER
+	select DRM_MIPI_DSI
+	select REGMAP_I2C
+	help
+	  Driver for waveshare DSI to DPI bridge board.
+	  Please say Y if you have such hardware
+
 endmenu
drivers/gpu/drm/bridge/Makefile +0 -0
index d1db90688a150fdc3a5fd40acebe740798c452b0..3caa4d8f71675804328aa5a51ec67b2587938621 100644

drivers/gpu/drm/bridge/Makefile obj-$(CONFIG_DRM_ITE_IT6263) += it6263.o · line 51

Quoted 4 lines
drivers/gpu/drm/bridge/Makefile +1 -0
@@ -48,3 +48,4 @@ obj-$(CONFIG_DRM_ITE_IT6263) += it6263.o
 obj-$(CONFIG_DRM_ITE_IT6161) += it6161.o
 obj-$(CONFIG_DRM_SEC_MIPI_DSIM) += sec-dsim.o
 obj-$(CONFIG_DRM_NXP_SEIKO_43WVFIG) += nxp-seiko-43wvfig.o
+obj-$(CONFIG_DRM_WAVESHARE_BRIDGE) += waveshare-dsi.o

Sort the config names alphabetically with the best effort.

drivers/gpu/drm/bridge/waveshare-dsi.c line 3

Quoted 9 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +3 -0
new file mode 100644
index 0000000000000000000000000000000000000000..efb3a2fc501b5725b02f49862526d1704a3a4b7b
@@ -0,0 +1,210 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ *  Copyright 2025 NXP

Nit: Drop a space between * and C.

Quoted 21 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +21 -0
+ * Based on panel-raspberrypi-touchscreen by Broadcom
+ */
+
+#include <linux/backlight.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_graph.h>
+#include <linux/regmap.h>
+
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_bridge.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_of.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+
+struct ws_bridge {
+	struct drm_bridge bridge;
+	struct drm_bridge *next_bridge;

drivers/gpu/drm/bridge/waveshare-dsi.c line 34

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+	struct backlight_device *backlight;
+	struct device *dev;
+	struct regmap *reg_map;
+};
+
+static const struct regmap_config ws_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = 0xff,
+	.disable_debugfs = true,

drivers/gpu/drm/bridge/waveshare-dsi.c:34:10: error: ‘const struct regmap_config’ has no member named ‘disable_debugfs’
34 | .disable_debugfs = true,

      |          ^~~~~~~~~~~~~~~
Quoted 9 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +9 -0
+};
+
+static struct ws_bridge *bridge_to_ws_bridge(struct drm_bridge *bridge)
+{
+	return container_of(bridge, struct ws_bridge, bridge);
+}
+
+static int ws_bridge_attach_dsi(struct ws_bridge *ws)
+{

drivers/gpu/drm/bridge/waveshare-dsi.c line 53

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+	struct device_node *dsi_host_node;
+	struct mipi_dsi_host *host;
+	struct mipi_dsi_device *dsi;
+	const struct mipi_dsi_device_info info = {
+		.type = "ws-bridge",
+		.channel = 0,
+		.node = NULL,
+	};
+	struct device *dev = ws->dev;
+	int ret;

Nit: Sort these variables in reverse Christmas tree fashion.

drivers/gpu/drm/bridge/waveshare-dsi.c line 62

Quoted 9 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +9 -0
+
+	dsi_host_node = of_graph_get_remote_node(dev->of_node, 0, 0);
+	if (!dsi_host_node) {
+		dev_err(dev, "Failed to get remote port\n");
+		return -ENODEV;
+	}
+
+	host = of_find_mipi_dsi_host_by_node(dsi_host_node);
+

Nit: Drop this blank line.

drivers/gpu/drm/bridge/waveshare-dsi.c line 68

Quoted 6 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +6 -0
+	of_node_put(dsi_host_node);
+	if (!host)
+		return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find dsi_host\n");
+
+	dsi = devm_mipi_dsi_device_register_full(dev, host, &info);
+

Ditto.

Quoted 7 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +7 -0
+	if (IS_ERR(dsi))
+		return dev_err_probe(dev, PTR_ERR(dsi), "Failed to create dsi device\n");
+
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_VIDEO |
+			  MIPI_DSI_CLOCK_NON_CONTINUOUS;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->lanes = 2;

drivers/gpu/drm/bridge/waveshare-dsi.c line 85

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+
+	ret = devm_mipi_dsi_attach(dev, dsi);
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Failed to attach dsi to host\n");
+
+	return 0;
+}
+
+static int ws_bridge_bridge_attach(struct drm_bridge *bridge,
+				   enum drm_bridge_attach_flags flags)

drivers/gpu/drm/bridge/waveshare-dsi.c:117:19: error: initialization of ‘int (*)(struct drm_bridge *, struct drm_encoder *, enum drm_bridge_attach_flags)’ from incompatible pointer type ‘int (*)(struct drm_bridge *, enum drm_bridge_attach_flags)’ [-Werror=incompatible-pointer-types]
117 | .attach = ws_bridge_bridge_attach,

      |                   ^~~~~~~~~~~~~~~~~~~~~~~
Quoted 46 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +46 -0
+{
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+	int ret;
+
+	ret = ws_bridge_attach_dsi(ws);
+	if (ret)
+		return ret;
+
+	return drm_bridge_attach(ws->bridge.encoder, ws->next_bridge,
+				 &ws->bridge, flags);
+}
+
+static void ws_bridge_bridge_enable(struct drm_bridge *bridge)
+{
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+
+	regmap_write(ws->reg_map, 0xad, 0x01);
+	backlight_enable(ws->backlight);
+}
+
+static void ws_bridge_bridge_disable(struct drm_bridge *bridge)
+{
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+
+	backlight_disable(ws->backlight);
+	regmap_write(ws->reg_map, 0xad, 0x00);
+}
+
+static const struct drm_bridge_funcs ws_bridge_bridge_funcs = {
+	.enable = ws_bridge_bridge_enable,
+	.disable = ws_bridge_bridge_disable,
+	.attach = ws_bridge_bridge_attach,
+};
+
+static int ws_bridge_bl_update_status(struct backlight_device *bl)
+{
+	struct ws_bridge *ws = bl_get_data(bl);
+
+	regmap_write(ws->reg_map, 0xab, 0xff - backlight_get_brightness(bl));
+	regmap_write(ws->reg_map, 0xaa, 0x01);
+
+	return 0;
+}
+
+static const struct backlight_ops ws_bridge_bl_ops = {
+	.update_status = ws_bridge_bl_update_status,

drivers/gpu/drm/bridge/waveshare-dsi.c line 141

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+};
+
+static struct backlight_device *ws_bridge_create_backlight(struct ws_bridge *ws)
+{
+	struct device *dev = ws->dev;
+	const struct backlight_properties props = {
+		.type = BACKLIGHT_RAW,
+		.brightness = 255,
+		.max_brightness = 255,
+	};

Nit: Sort these variables in reverse Christmas tree fashion.

drivers/gpu/drm/bridge/waveshare-dsi.c line 153

Quoted 12 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +12 -0
+
+	return devm_backlight_device_register(dev, dev_name(dev), dev, ws,
+					      &ws_bridge_bl_ops, &props);
+}
+
+static int ws_bridge_probe(struct i2c_client *i2c)
+{
+	struct device *dev = &i2c->dev;
+	struct ws_bridge *ws;
+	struct drm_panel *panel;
+	int ret;
+	struct backlight_device *backlight;

Ditto.

drivers/gpu/drm/bridge/waveshare-dsi.c line 155

Quoted 2 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +2 -0
+
+	ws = devm_kzalloc(dev, sizeof(*ws), GFP_KERNEL);

Recently upstream bridge drivers were changed to use devm_drm_bridge_alloc() to allocate the main structure which contains the DRM bridge member. devm_kzalloc() is no more allowed to be used.

Quoted 56 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +55 -0
+	if (!ws)
+		return -ENOMEM;
+
+	ws->dev = dev;
+
+	ws->reg_map = devm_regmap_init_i2c(i2c, &ws_regmap_config);
+	if (IS_ERR(ws->reg_map))
+		return dev_err_probe(dev, PTR_ERR(ws->reg_map), "Failed to allocate regmap\n");
+
+	ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, &panel, NULL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to find remote panel\n");
+
+	ws->next_bridge = devm_drm_panel_bridge_add(dev, panel);
+	if (IS_ERR(ws->next_bridge))
+		return PTR_ERR(ws->next_bridge);
+
+	ws->backlight = ws_bridge_create_backlight(ws);
+	if (IS_ERR(backlight)) {
+		ret = PTR_ERR(backlight);
+		dev_err(dev, "Failed to create backlight: %d\n", ret);
+		return ret;
+	}
+
+	regmap_write(ws->reg_map, 0xc0, 0x01);
+	regmap_write(ws->reg_map, 0xc2, 0x01);
+	regmap_write(ws->reg_map, 0xac, 0x01);
+
+	ws->bridge.funcs = &ws_bridge_bridge_funcs;
+	ws->bridge.type = DRM_MODE_CONNECTOR_DPI;
+	ws->bridge.of_node = dev->of_node;
+	devm_drm_bridge_add(dev, &ws->bridge);
+
+	return 0;
+}
+
+static const struct of_device_id ws_bridge_of_ids[] = {
+	{.compatible = "waveshare,dsi2dpi",},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, ws_bridge_of_ids);
+
+static struct i2c_driver ws_bridge_driver = {
+	.driver = {
+		.name = "ws_dsi2dpi",
+		.of_match_table = ws_bridge_of_ids,
+	},
+	.probe = ws_bridge_probe,
+};
+module_i2c_driver(ws_bridge_driver);
+
+MODULE_AUTHOR("Joseph Guo <[email protected]>");
+MODULE_DESCRIPTION("Waveshare DSI2DPI bridge driver");
+MODULE_LICENSE("GPL");
Signature · 2 lines
Regards,
Liu Ying
author
#11 lore raw

RE: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

Hi Ying

Quoted 41 lines

-----Original Message-----
From: Ying Liu <[email protected]>
Sent: Tuesday, August 5, 2025 10:22 AM
To: Joseph Guo <[email protected]>; Andrzej Hajda <[email protected]>; Neil Armstrong <[email protected]>; Robert Foss <[email protected]>; Laurent Pinchart <[email protected]>; Jonas Karlman <[email protected]>; Jernej Skrabec <[email protected]>; David Airlie <[email protected]>; Simona Vetter <[email protected]>; Maarten Lankhorst <[email protected]>; Maxime Ripard <[email protected]>; Thomas Zimmermann <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Jessica Zhang <[email protected]>; Thierry Reding <[email protected]>; Sam Ravnborg <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

Hi Joseph,

Quoted 8 lines · Joseph Guo

Waveshare touchscreen consists of a DPI panel and a driver board. The waveshare driver board consists of ICN6211 and a MCU to convert DSI to DPI and control the backlight.
This driver treats the MCU and ICN6211 board as a whole unit. It can support all resolution waveshare DSI2DPI based panel, the timing table should come from 'panel-dpi' panel in the device tree.

For next version, you may add:

Quoted 6 lines
---
 drivers/gpu/drm/bridge/Kconfig         |  11 ++
 drivers/gpu/drm/bridge/Makefile        |   1 +
 drivers/gpu/drm/bridge/waveshare-dsi.c | 210
+++++++++++++++++++++++++++++++++
 3 files changed, 222 insertions(+)
Quoted 4 lines

This patch doesn't apply to drm-misc-next cleanly. I see conflicts in Kconfig and Makefile. It seems that you generate the patch series based on NXP down stream kernel instead of the upstream kernel.

[Joseph] OK, I will generate the patch based on upstream kernel in next version instead.

Quoted 157 lines
Quoted 4 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/Kconfig index

cb3b797fcea1c73e83c9187fef6582296b340305..26fec25c61ed7d950c094e0224 f1

drivers/gpu/drm/bridge/Kconfig config DRM_ITE_IT6161 · line 475

Quoted 8 lines

196946079485 100644

drivers/gpu/drm/bridge/Kconfig +1 -0
@@ -472,4 +472,15 @@ config DRM_ITE_IT6161
 	help
 	  ITE IT6161 bridge chip driver.
 
+config DRM_WAVESHARE_BRIDGE

Sort the config names alphabetically.

drivers/gpu/drm/bridge/Kconfig config DRM_ITE_IT6161 · line 476

Quoted 1 line
drivers/gpu/drm/bridge/Kconfig +1 -0
+	tristate "Waveshare DSI bridge"

depends on BACKLIGHT_CLASS_DEVICE

Quoted 11 lines
drivers/gpu/drm/bridge/Kconfig +9 -0
+	depends on OF
+	select DRM_PANEL_BRIDGE
+	select DRM_KMS_HELPER
+	select DRM_MIPI_DSI
+	select REGMAP_I2C
+	help
+	  Driver for waveshare DSI to DPI bridge board.
+	  Please say Y if you have such hardware
+
 endmenu
(quoted diff) +0 -0
Quoted 2 lines

b/drivers/gpu/drm/bridge/Makefile index

d1db90688a150fdc3a5fd40acebe740798c452b0..3caa4d8f71675804328aa5a51 ec6

drivers/gpu/drm/bridge/Makefile obj-$(CONFIG_DRM_ITE_IT6263) += it6263.o · line 51

Quoted 8 lines

7b2587938621 100644

drivers/gpu/drm/bridge/Makefile +1 -0
@@ -48,3 +48,4 @@ obj-$(CONFIG_DRM_ITE_IT6263) += it6263.o
 obj-$(CONFIG_DRM_ITE_IT6161) += it6161.o
 obj-$(CONFIG_DRM_SEC_MIPI_DSIM) += sec-dsim.o
 obj-$(CONFIG_DRM_NXP_SEIKO_43WVFIG) += nxp-seiko-43wvfig.o
+obj-$(CONFIG_DRM_WAVESHARE_BRIDGE) += waveshare-dsi.o

Sort the config names alphabetically with the best effort.

Quoted 5 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +0 -0
new file mode 100644

index

0000000000000000000000000000000000000000..efb3a2fc501b5725b02f498625 26

drivers/gpu/drm/bridge/waveshare-dsi.c line 3

Quoted 7 lines

d1704a3a4b7b

drivers/gpu/drm/bridge/waveshare-dsi.c new file +3 -0
@@ -0,0 +1,210 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ *  Copyright 2025 NXP

Nit: Drop a space between * and C.

Quoted 20 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +20 -0
+ * Based on panel-raspberrypi-touchscreen by Broadcom */
+
+#include <linux/backlight.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_graph.h>
+#include <linux/regmap.h>
+
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_bridge.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_of.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+
+struct ws_bridge {
+	struct drm_bridge bridge;
+	struct drm_bridge *next_bridge;

drivers/gpu/drm/bridge/waveshare-dsi.c line 34

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+	struct backlight_device *backlight;
+	struct device *dev;
+	struct regmap *reg_map;
+};
+
+static const struct regmap_config ws_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = 0xff,
+	.disable_debugfs = true,

drivers/gpu/drm/bridge/waveshare-dsi.c:34:10: error: ‘const struct regmap_config’ has no member named ‘disable_debugfs’
34 | .disable_debugfs = true,

      |          ^~~~~~~~~~~~~~~
Quoted 7 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +7 -0
+};
+
+static struct ws_bridge *bridge_to_ws_bridge(struct drm_bridge
+*bridge) {
+	return container_of(bridge, struct ws_bridge, bridge); }
+
+static int ws_bridge_attach_dsi(struct ws_bridge *ws) {

drivers/gpu/drm/bridge/waveshare-dsi.c line 53

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+	struct device_node *dsi_host_node;
+	struct mipi_dsi_host *host;
+	struct mipi_dsi_device *dsi;
+	const struct mipi_dsi_device_info info = {
+		.type = "ws-bridge",
+		.channel = 0,
+		.node = NULL,
+	};
+	struct device *dev = ws->dev;
+	int ret;

Nit: Sort these variables in reverse Christmas tree fashion.

drivers/gpu/drm/bridge/waveshare-dsi.c line 62

Quoted 9 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +9 -0
+
+	dsi_host_node = of_graph_get_remote_node(dev->of_node, 0, 0);
+	if (!dsi_host_node) {
+		dev_err(dev, "Failed to get remote port\n");
+		return -ENODEV;
+	}
+
+	host = of_find_mipi_dsi_host_by_node(dsi_host_node);
+

Nit: Drop this blank line.

drivers/gpu/drm/bridge/waveshare-dsi.c line 68

Quoted 7 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +7 -0
+	of_node_put(dsi_host_node);
+	if (!host)
+		return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find
+dsi_host\n");
+
+	dsi = devm_mipi_dsi_device_register_full(dev, host, &info);
+

Ditto.

drivers/gpu/drm/bridge/waveshare-dsi.c line 68

Quoted 2 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +2 -0
+	if (IS_ERR(dsi))
+		return dev_err_probe(dev, PTR_ERR(dsi), "Failed to create

dsi

drivers/gpu/drm/bridge/waveshare-dsi.c line 71

Quoted 3 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +3 -0
+device\n");
+
+	dsi->mode_flags = MIPI_DSI_MODE_VIDEO_HSE |

MIPI_DSI_MODE_VIDEO |

drivers/gpu/drm/bridge/waveshare-dsi.c

Quoted 7 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +7 -0
+			  MIPI_DSI_CLOCK_NON_CONTINUOUS;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->lanes = 2;
+
+	ret = devm_mipi_dsi_attach(dev, dsi);
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Failed to attach dsi to

host\n");

Quoted 12 lines

drivers/gpu/drm/bridge/waveshare-dsi.c line 85

Quoted 6 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +6 -0
+
+	return 0;
+}
+
+static int ws_bridge_bridge_attach(struct drm_bridge *bridge,
+				   enum drm_bridge_attach_flags flags)

drivers/gpu/drm/bridge/waveshare-dsi.c:117:19: error: initialization of ‘int (*)(struct drm_bridge *, struct drm_encoder *, enum drm_bridge_attach_flags)’ from incompatible pointer type ‘int (*)(struct drm_bridge *, enum drm_bridge_attach_flags)’ [-Werror=incompatible- pointer-types]

[Joseph] It seems all the build error and warning came from the different version of downstream and upstream. I will resolve them all in v3. Thank you.

Regards,
Joseph

Quoted 145 lines

117 | .attach = ws_bridge_bridge_attach,

      |                   ^~~~~~~~~~~~~~~~~~~~~~~
Quoted 25 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +25 -0
+{
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+	int ret;
+
+	ret = ws_bridge_attach_dsi(ws);
+	if (ret)
+		return ret;
+
+	return drm_bridge_attach(ws->bridge.encoder, ws->next_bridge,
+				 &ws->bridge, flags);
+}
+
+static void ws_bridge_bridge_enable(struct drm_bridge *bridge) {
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+
+	regmap_write(ws->reg_map, 0xad, 0x01);
+	backlight_enable(ws->backlight);
+}
+
+static void ws_bridge_bridge_disable(struct drm_bridge *bridge) {
+	struct ws_bridge *ws = bridge_to_ws_bridge(bridge);
+
+	backlight_disable(ws->backlight);
+	regmap_write(ws->reg_map, 0xad, 0x00); }
+

drivers/gpu/drm/bridge/waveshare-dsi.c

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+static const struct drm_bridge_funcs ws_bridge_bridge_funcs = {
+	.enable = ws_bridge_bridge_enable,
+	.disable = ws_bridge_bridge_disable,
+	.attach = ws_bridge_bridge_attach,
+};
+
+static int ws_bridge_bl_update_status(struct backlight_device *bl) {
+	struct ws_bridge *ws = bl_get_data(bl);
+
+	regmap_write(ws->reg_map, 0xab, 0xff -

backlight_get_brightness(bl));

Quoted 6 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +6 -0
+	regmap_write(ws->reg_map, 0xaa, 0x01);
+
+	return 0;
+}
+
+static const struct backlight_ops ws_bridge_bl_ops = {

drivers/gpu/drm/bridge/waveshare-dsi.c line 141

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+	.update_status = ws_bridge_bl_update_status, };
+
+static struct backlight_device *ws_bridge_create_backlight(struct
+ws_bridge *ws) {
+	struct device *dev = ws->dev;
+	const struct backlight_properties props = {
+		.type = BACKLIGHT_RAW,
+		.brightness = 255,
+		.max_brightness = 255,
+	};

Nit: Sort these variables in reverse Christmas tree fashion.

drivers/gpu/drm/bridge/waveshare-dsi.c line 137

Quoted 2 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +2 -0
+
+	return devm_backlight_device_register(dev, dev_name(dev), dev,

ws,

drivers/gpu/drm/bridge/waveshare-dsi.c line 153

Quoted 8 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +8 -0
+					      &ws_bridge_bl_ops, &props); }
+
+static int ws_bridge_probe(struct i2c_client *i2c) {
+	struct device *dev = &i2c->dev;
+	struct ws_bridge *ws;
+	struct drm_panel *panel;
+	int ret;
+	struct backlight_device *backlight;

Ditto.

drivers/gpu/drm/bridge/waveshare-dsi.c line 147

Quoted 2 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +2 -0
+
+	ws = devm_kzalloc(dev, sizeof(*ws), GFP_KERNEL);

Recently upstream bridge drivers were changed to use devm_drm_bridge_alloc() to allocate the main structure which contains the DRM bridge member.
devm_kzalloc() is no more allowed to be used.

drivers/gpu/drm/bridge/waveshare-dsi.c

Quoted 8 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +8 -0
+	if (!ws)
+		return -ENOMEM;
+
+	ws->dev = dev;
+
+	ws->reg_map = devm_regmap_init_i2c(i2c, &ws_regmap_config);
+	if (IS_ERR(ws->reg_map))
+		return dev_err_probe(dev, PTR_ERR(ws->reg_map), "Failed

to allocate

drivers/gpu/drm/bridge/waveshare-dsi.c line 158

Quoted 3 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +3 -0
+regmap\n");
+
+	ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, &panel,

NULL);

drivers/gpu/drm/bridge/waveshare-dsi.c line 160

Quoted 2 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +2 -0
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to find remote

panel\n");

Quoted 34 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +33 -0
+
+	ws->next_bridge = devm_drm_panel_bridge_add(dev, panel);
+	if (IS_ERR(ws->next_bridge))
+		return PTR_ERR(ws->next_bridge);
+
+	ws->backlight = ws_bridge_create_backlight(ws);
+	if (IS_ERR(backlight)) {
+		ret = PTR_ERR(backlight);
+		dev_err(dev, "Failed to create backlight: %d\n", ret);
+		return ret;
+	}
+
+	regmap_write(ws->reg_map, 0xc0, 0x01);
+	regmap_write(ws->reg_map, 0xc2, 0x01);
+	regmap_write(ws->reg_map, 0xac, 0x01);
+
+	ws->bridge.funcs = &ws_bridge_bridge_funcs;
+	ws->bridge.type = DRM_MODE_CONNECTOR_DPI;
+	ws->bridge.of_node = dev->of_node;
+	devm_drm_bridge_add(dev, &ws->bridge);
+
+	return 0;
+}
+
+static const struct of_device_id ws_bridge_of_ids[] = {
+	{.compatible = "waveshare,dsi2dpi",},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, ws_bridge_of_ids);
+
+static struct i2c_driver ws_bridge_driver = {
+	.driver = {

drivers/gpu/drm/bridge/waveshare-dsi.c line 210

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+		.name = "ws_dsi2dpi",
+		.of_match_table = ws_bridge_of_ids,
+	},
+	.probe = ws_bridge_probe,
+};
+module_i2c_driver(ws_bridge_driver);
+
+MODULE_AUTHOR("Joseph Guo <[email protected]>");
+MODULE_DESCRIPTION("Waveshare DSI2DPI bridge driver");
+MODULE_LICENSE("GPL");

--
Regards,
Liu Ying

#12 lore raw

Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

In reply to Liu Ying
Quoted 10 lines · Liu Ying

Hi Joseph,

Quoted 7 lines · Joseph Guo

Waveshare touchscreen consists of a DPI panel and a driver board. The waveshare driver board consists of ICN6211 and a MCU to convert DSI to DPI and control the backlight.
This driver treats the MCU and ICN6211 board as a whole unit. It can support all resolution waveshare DSI2DPI based panel, the timing table should come from 'panel-dpi' panel in the device tree.

Quoted 4 lines
Quoted 1 line

For next version, you may add:

Why?

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Liu Ying

Hi Joseph,

Quoted 7 lines · Joseph Guo

Waveshare touchscreen consists of a DPI panel and a driver board. The waveshare driver board consists of ICN6211 and a MCU to convert DSI to DPI and control the backlight.
This driver treats the MCU and ICN6211 board as a whole unit. It can support all resolution waveshare DSI2DPI based panel, the timing table should come from 'panel-dpi' panel in the device tree.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

For next version, you may add:

Why?

As I replied in the cover letter, I provided general idea for this patch series in NXP down stream kernel. Same for the DT binding patches.

https://lore.kernel.org/dri-devel/[email protected]/T/#mb491c1e74df28dab74d8dcb7843f12e7a3b537cb

Quoted 3 lines

Best regards,
Krzysztof

Signature · 2 lines
Regards,
Liu Ying
#14 lore raw

Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

Quoted 14 lines · Liu Ying
Quoted 13 lines · Krzysztof Kozlowski
Quoted 12 lines · Liu Ying

Hi Joseph,

Quoted 8 lines · Joseph Guo

Waveshare touchscreen consists of a DPI panel and a driver board. The waveshare driver board consists of ICN6211 and a MCU to convert DSI to DPI and control the backlight.
This driver treats the MCU and ICN6211 board as a whole unit. It can support all resolution waveshare DSI2DPI based panel, the timing table should come from 'panel-dpi' panel in the device tree.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

For next version, you may add:

Why?

As I replied in the cover letter, I provided general idea for this patch series in NXP down stream kernel. Same for the DT binding patches.

General idea to add support for new driver? So like every patch being a result of for example task from manager means "Suggested-by"? Since when new device support is treated as suggested-by?

I also do not understand how downstream kernel is relevant here.

Best regards,
Krzysztof

#15 lore raw

Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

Quoted 18 lines · Krzysztof Kozlowski
Quoted 17 lines · Liu Ying
Quoted 16 lines · Krzysztof Kozlowski
Quoted 14 lines · Liu Ying

Hi Joseph,

Quoted 8 lines · Joseph Guo

Waveshare touchscreen consists of a DPI panel and a driver board. The waveshare driver board consists of ICN6211 and a MCU to convert DSI to DPI and control the backlight.
This driver treats the MCU and ICN6211 board as a whole unit. It can support all resolution waveshare DSI2DPI based panel, the timing table should come from 'panel-dpi' panel in the device tree.

For next version, you may add:

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Why?

As I replied in the cover letter, I provided general idea for this patch series in NXP down stream kernel. Same for the DT binding patches.

General idea to add support for new driver? So like every patch being a result of for example task from manager means "Suggested-by"? Since when new device support is treated as suggested-by?

Not for new driver, but for architecture level, like treating the MCU and ICN6211 as a whole unit/DRM bridge and treating the DPI panel as a simple panel from both DT's point of view and DRM driver's point of view.

Quoted 2 lines

I also do not understand how downstream kernel is relevant here.

That suggestion did happen when I reviewed this patch series for downstream kernel. Just shared the information.

Quoted 3 lines

Best regards,
Krzysztof

Signature · 2 lines
Regards,
Liu Ying
#16 lore raw

Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

In reply to Joseph Guo

On 08/04/2025, Joseph Guo wrote:

[...]

drivers/gpu/drm/bridge/waveshare-dsi.c line 153

Quoted 7 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +7 -0
+static int ws_bridge_probe(struct i2c_client *i2c)
+{
+	struct device *dev = &i2c->dev;
+	struct ws_bridge *ws;
+	struct drm_panel *panel;
+	int ret;
+	struct backlight_device *backlight;

Drop backlight as there is ws->backlight.

Quoted 11 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +11 -0
+
+	ws = devm_kzalloc(dev, sizeof(*ws), GFP_KERNEL);
+	if (!ws)
+		return -ENOMEM;
+
+	ws->dev = dev;
+
+	ws->reg_map = devm_regmap_init_i2c(i2c, &ws_regmap_config);
+	if (IS_ERR(ws->reg_map))
+		return dev_err_probe(dev, PTR_ERR(ws->reg_map), "Failed to allocate regmap\n");
+

drivers/gpu/drm/bridge/waveshare-dsi.c line 174

Quoted 10 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +10 -0
+	ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, &panel, NULL);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to find remote panel\n");
+
+	ws->next_bridge = devm_drm_panel_bridge_add(dev, panel);
+	if (IS_ERR(ws->next_bridge))
+		return PTR_ERR(ws->next_bridge);
+
+	ws->backlight = ws_bridge_create_backlight(ws);
+	if (IS_ERR(backlight)) {

s/backlight/ws->backlight/

drivers/gpu/drm/bridge/waveshare-dsi.c line 175

Quoted 1 line
drivers/gpu/drm/bridge/waveshare-dsi.c new file +1 -0
+		ret = PTR_ERR(backlight);

s/backlight/ws->backlight/

Quoted 3 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +3 -0
+		dev_err(dev, "Failed to create backlight: %d\n", ret);
+		return ret;
+	}
Signature · 2 lines
Regards,
Liu Ying
#17 lore raw

Re: [PATCH v2 3/3] drm: bridge: Add waveshare DSI2DPI unit driver

In reply to Joseph Guo

On 08/04/2025, Joseph Guo wrote:

[...]

Quoted 1 line

+#include <drm/drm_atomic_helper.h>

Unused header file. Drop.

drivers/gpu/drm/bridge/waveshare-dsi.c line 20

Quoted 5 lines
drivers/gpu/drm/bridge/waveshare-dsi.c new file +5 -0
+#include <drm/drm_bridge.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_of.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>

Ditto.

Signature · 2 lines
Regards,
Liu Ying
#18 lore raw
In reply to Joseph Guo
Quoted 3 lines · Joseph Guo

This patchset add support for waveshare DSI2DPI unit.

I provided general idea and conducted heavy review for this patch series in NXP down stream kernel. Yet some comments on patch 3.

Quoted 23 lines

---
Changes in v2:
- /s/i2c0/i2c/ in patch 1
- Add Review tags
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Joseph Guo (3):
dt-bindings: display: bridge: Add waveshare DSI2DPI unit support
dt-bindings: display: panel: Add waveshare DPI panel support
drm: bridge: Add waveshare DSI2DPI unit driver

 .../bindings/display/bridge/waveshare,dsi2dpi.yaml | 103 ++++++++++
 .../bindings/display/panel/panel-simple.yaml       |   4 +
 drivers/gpu/drm/bridge/Kconfig                     |  11 ++
 drivers/gpu/drm/bridge/Makefile                    |   1 +
 drivers/gpu/drm/bridge/waveshare-dsi.c             | 210 +++++++++++++++++++++
 5 files changed, 329 insertions(+)

---
base-commit: 0952d89c3acf6590b89bcfb8505595d7c0e6f367
change-id: 20250715-waveshare-dad93ea9980f

Best regards,

Signature · 2 lines
Regards,
Liu Ying