Skip to contentSkip to conversation

drm: bridge: add ssd2825 RGB/DSI bridge support

PATCH Superseded Svyatoslav Ryhel 2 participants 10 messages May 26, 2025 – Jul 14, 2025

Subsystems (4)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover drm: bridge: add ssd2825 RGB/DSI bridge support

Solomon SSD2825 is a RGB to MIPI DSI bridge used in LG Optimus 4D P880 and LG Optimus Vu P895

---
Changes on switching from v5 to v6:
- set correct module name in Kconfig help
- return error if spi sync failed for reading

Changes on switching from v4 to v5:
- rebased on top of drm-misc-next with adjustments to fit

Changes on switching from v3 to v4:
- no changes, resend

Changes on switching from v2 to v3:
- added mutex guard
- configuration register flags parametrized using panel flags
- removed unneded debug messages
- removed unimplemented modes checks
- added check for maximum pixel row length
- use types header
- remove ssd2825_to_ns
- shift bridge setup into atomic pre-enable
- cleaned default values of hzd and hpd

Changes on switching from v1 to v2:
- added description for clock
- removed clock-names
- added boundries for hs-zero-delay-ns and hs-prep-delay-ns
- added mutex lock for host transfers
- converted to atomic ops
- get drm_display_mode mode with atomic helpers
- parameterized INTERFACE_CTRL_REG_6 configuration
- added video mode validation and fixup
- removed clock name
- switched to devm_regulator_bulk_get_const
- added default timings
---

Svyatoslav Ryhel (2):
dt-bindings: display: bridge: Document Solomon SSD2825
drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

 .../display/bridge/solomon,ssd2825.yaml       | 141 +++
 drivers/gpu/drm/bridge/Kconfig                |  13 +
 drivers/gpu/drm/bridge/Makefile               |   1 +
 drivers/gpu/drm/bridge/ssd2825.c              | 814 ++++++++++++++++++
 4 files changed, 969 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/solomon,ssd2825.yaml
 create mode 100644 drivers/gpu/drm/bridge/ssd2825.c
Signature · 1 line
2.48.1
#1 lore raw

PATCH v6 1/2 dt-bindings: display: bridge: Document Solomon SSD2825

Add bindings for Solomon SSD2825 MIPI master bridge chip that connects an application processor with traditional parallel LCD interface and an LCD driver with MIPI slave interface. The SSD2825 supports both parallel RGB interface and serial SPI interface.

---
 .../display/bridge/solomon,ssd2825.yaml       | 141 ++++++++++++++++++
 1 file changed, 141 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/solomon,ssd2825.yaml
Documentation/devicetree/bindings/display/bridge/solomon,ssd2825.yaml new file +141 -0
new file mode 100644
index 000000000000..e2d293d623b8
@@ -0,0 +1,141 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/bridge/solomon,ssd2825.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Solomon SSD2825 RGB to MIPI-DSI bridge
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+properties:
+  compatible:
+    const: solomon,ssd2825
+
+  reg:
+    maxItems: 1
+
+  reset-gpios: true
+
+  dvdd-supply:
+    description: Regulator for 1.2V digital power supply.
+
+  avdd-supply:
+    description: Regulator for 1.2V analog power supply.
+
+  vddio-supply:
+    description: Regulator for 1.8V IO power supply.
+
+  spi-max-frequency:
+    maximum: 1000000
+
+  spi-cpha: true
+  spi-cpol: true
+
+  clocks:
+    maxItems: 1
+    description: Reference TX_CLK used before PLL is locked.
+
+  solomon,hs-zero-delay-ns:
+    description:
+      HS zero delay period
+    minimum: 0
+    maximum: 1700
+    default: 133
+
+  solomon,hs-prep-delay-ns:
+    description:
+      HS prep delay period
+    minimum: 0
+    maximum: 1728
+    default: 40
+
+  ports:
+    $ref: /schemas/graph.yaml#/properties/ports
+
+    properties:
+      port@0:
+        $ref: /schemas/graph.yaml#/$defs/port-base
+        unevaluatedProperties: false
+        description:
+          Video port for RGB input
+
+        properties:
+          endpoint:
+            $ref: /schemas/graph.yaml#/$defs/endpoint-base
+            unevaluatedProperties: false
+
+            properties:
+              bus-width:
+                enum: [ 16, 18, 24 ]
+
+      port@1:
+        $ref: /schemas/graph.yaml#/properties/port
+        description:
+          Video port for DSI output (panel or connector)
+
+    required:
+      - port@0
+      - port@1
+
+required:
+  - compatible
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        dsi@2 {
+            compatible = "solomon,ssd2825";
+            reg = <2>;
+
+            spi-max-frequency = <1000000>;
+
+            spi-cpha;
+            spi-cpol;
+
+            reset-gpios = <&gpio 114 GPIO_ACTIVE_LOW>;
+
+            dvdd-supply = <&vdd_1v2>;
+            avdd-supply = <&vdd_1v2>;
+            vddio-supply = <&vdd_1v8_io>;
+
+            solomon,hs-zero-delay-ns = <300>;
+            solomon,hs-prep-delay-ns = <65>;
+
+            clocks = <&ssd2825_tx_clk>;
+
+            ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                port@0 {
+                    reg = <0>;
+
+                    bridge_input: endpoint {
+                        remote-endpoint = <&dpi_output>;
+                        bus-width = <24>;
+                    };
+                };
+
+                port@1 {
+                    reg = <1>;
+
+                    bridge_output: endpoint {
+                        remote-endpoint = <&panel_input>;
+                    };
+                };
+            };
+        };
+    };
Signature · 1 line
2.48.1
#2 lore raw

PATCH v6 2/2 drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

In reply to Svyatoslav Ryhel

SSD2825 is a cost-effective MIPI Bridge Chip solution targeting mainly smartphones. It can convert 24bit RGB interface into 4-lane MIPI-DSI interface to drive display modules of up to 800 x 1366, while supporting AMOLED, a-si LCD or LTPS panel technologies for smartphone applications.

---
 drivers/gpu/drm/bridge/Kconfig   |  13 +
 drivers/gpu/drm/bridge/Makefile  |   1 +
 drivers/gpu/drm/bridge/ssd2825.c | 814 +++++++++++++++++++++++++++++++
 3 files changed, 828 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/ssd2825.c
drivers/gpu/drm/bridge/Kconfig +13 -0
index b9e0ca85226a..c11444c80d88 100644
@@ -316,6 +316,19 @@ config DRM_SIMPLE_BRIDGE
 	  Support for non-programmable DRM bridges, such as ADI ADV7123, TI
 	  THS8134 and THS8135 or passive resistor ladder DACs.
 
+config DRM_SOLOMON_SSD2825
+	tristate "SSD2825 RGB/DSI bridge"
+	depends on SPI_MASTER && OF
+	select DRM_MIPI_DSI
+	select DRM_KMS_HELPER
+	select DRM_PANEL
+	help
+	  Say Y here if you want support for the Solomon SSD2825 RGB/DSI
+	  SPI bridge driver.
+
+	  Say M here if you want to support this hardware as a module.
+	  The module will be named "ssd2825".
+
 config DRM_THINE_THC63LVD1024
 	tristate "Thine THC63LVD1024 LVDS decoder bridge"
 	depends on OF
drivers/gpu/drm/bridge/Makefile +1 -0
index 245e8a27e3fc..19f5a09d9291 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_DRM_SIL_SII8620) += sil-sii8620.o
 obj-$(CONFIG_DRM_SII902X) += sii902x.o
 obj-$(CONFIG_DRM_SII9234) += sii9234.o
 obj-$(CONFIG_DRM_SIMPLE_BRIDGE) += simple-bridge.o
+obj-$(CONFIG_DRM_SOLOMON_SSD2825) += ssd2825.o
 obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358762) += tc358762.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
drivers/gpu/drm/bridge/ssd2825.c new file +814 -0

814 lines not on this page · raw message

Signature · 1 line
2.48.1
maintainer
#3 lore raw

Re: [PATCH v6 2/2] drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

drivers/gpu/drm/bridge/ssd2825.c line 356

Quoted 13 lines · Svyatoslav Ryhel
drivers/gpu/drm/bridge/ssd2825.c new file +13 -0
+static ssize_t ssd2825_dsi_host_transfer(struct mipi_dsi_host *host,
+					 const struct mipi_dsi_msg *msg)
+{
+	struct ssd2825_priv *priv = dsi_host_to_ssd2825(host);
+	struct mipi_dsi_device *dsi_dev = priv->output.dev;
+	u8 buf = *(u8 *)msg->tx_buf;
+	u16 config;
+	int ret;
+
+	if (!priv->enabled) {
+		dev_err(priv->dev, "Bridge is not enabled\n");
+		return -ENODEV;
+	}

Transfers can and should happen even when the bridge is disabled. The hardware might not permit that, but you'll need to elaborate in the comment about why.

Quoted 47 lines
drivers/gpu/drm/bridge/ssd2825.c new file +47 -0
+	if (msg->rx_len) {
+		dev_warn(priv->dev, "MIPI rx is not supported\n");
+		return -EOPNOTSUPP;
+	}
+
+	guard(mutex)(&priv->mlock);
+
+	ret = ssd2825_read_reg(priv, SSD2825_CONFIGURATION_REG, &config);
+	if (ret)
+		return ret;
+
+	switch (msg->type) {
+	case MIPI_DSI_DCS_SHORT_WRITE:
+	case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+	case MIPI_DSI_DCS_LONG_WRITE:
+		config |= SSD2825_CONF_REG_DCS;
+		break;
+	case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
+	case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
+	case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
+	case MIPI_DSI_GENERIC_LONG_WRITE:
+		config &= ~SSD2825_CONF_REG_DCS;
+		break;
+	case MIPI_DSI_DCS_READ:
+	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+	case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+	default:
+		return 0;
+	}
+
+	ret = ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+	if (ret)
+		return ret;
+
+	ret = ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0x0000);
+	if (ret)
+		return ret;
+
+	ret = ssd2825_write_dsi(priv, msg->tx_buf, msg->tx_len);
+	if (ret)
+		return ret;
+
+	if (buf == MIPI_DCS_SET_DISPLAY_ON) {
+		/*
+		 * NOTE! This is here since it cannot be called in bridge enable because
+		 * bridge pre enable and bridge enable have no gap in between.

drivers/gpu/drm/bridge/ssd2825.c line 414

Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+		 *
+		 * Existing framework bridge-panel seq is:
+		 *	panel_prepare > bridge_pre_enable > bridge_enable > panel_enable
+		 *
+		 * Using prepare_prev_first was tested, but it switches seq like this:
+		 *	bridge_pre_enable > panel_prepare > bridge_enable > panel_enable
+		 *
+		 * This will not work since panel hw MUST be prepared before bridge is
+		 * configured. Correct seq should be:
+		 *	panel_prepare > bridge_pre_enable > panel_enable > bridge_enable

Where is that requirement coming from?

panel prepare is documented as:

The .prepare() function is typically called before the display controller starts to transmit video data.

And video data transmission for bridges only happen at bridge_enable time.

So, from an API PoV, all the sequences above are correct.

drivers/gpu/drm/bridge/ssd2825.c line 422

Quoted 7 lines
drivers/gpu/drm/bridge/ssd2825.c new file +7 -0
+		 * Last two functions should be swapped related to existing framework.
+		 * I am not aware about method which allows that.
+		 *
+		 * Once there will be such method/flag, code below should be moved into
+		 * bridge_enable since it is basically a bridge configuration completing
+		 * after initial panel DSI sequence is completed.
+		 */

If there's anything to fix, we should do it before introducing that driver.

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+static void ssd2825_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+					     struct drm_atomic_state *state)
+{
+	struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+	struct mipi_dsi_device *dsi_dev = priv->output.dev;
+	const struct drm_crtc_state *crtc_state;

drivers/gpu/drm/bridge/ssd2825.c line 545

Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+	const struct drm_display_mode *mode;
+	struct drm_connector *connector;
+	struct drm_crtc *crtc;
+	u32 input_bus_flags = bridge->timings->input_bus_flags;
+	u16 flags = 0, config;
+	u8 pixel_format;
+	int ret;
+
+	if (priv->enabled)
+		return;

What is this guarding against?

Quoted 83 lines
drivers/gpu/drm/bridge/ssd2825.c new file +83 -0
+	/* Power Sequence */
+	ret = clk_prepare_enable(priv->tx_clk);
+	if (ret)
+		dev_err(priv->dev, "error enabling tx_clk (%d)\n", ret);
+
+	ret = regulator_bulk_enable(ARRAY_SIZE(ssd2825_supplies), priv->supplies);
+	if (ret)
+		dev_err(priv->dev, "error enabling regulators (%d)\n", ret);
+
+	usleep_range(1000, 2000);
+
+	ssd2825_hw_reset(priv);
+
+	/* Perform SW reset */
+	ssd2825_write_reg(priv, SSD2825_OPERATION_CTRL_REG, 0x0100);
+
+	/* Set pixel format */
+	switch (dsi_dev->format) {
+	case MIPI_DSI_FMT_RGB565:
+		pixel_format = 0x00;
+		break;
+	case MIPI_DSI_FMT_RGB666_PACKED:
+		pixel_format = 0x01;
+		break;
+	case MIPI_DSI_FMT_RGB666:
+		pixel_format = 0x02;
+		break;
+	case MIPI_DSI_FMT_RGB888:
+	default:
+		pixel_format = 0x03;
+		break;
+	}
+
+	connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
+	crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
+	crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+	mode = &crtc_state->adjusted_mode;
+
+	/* Set panel timings */
+	ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_1,
+			  ((mode->vtotal - mode->vsync_end) << 8) |
+			  (mode->htotal - mode->hsync_end));
+	ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_2,
+			  ((mode->vtotal - mode->vsync_start) << 8) |
+			  (mode->htotal - mode->hsync_start));
+	ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_3,
+			  ((mode->vsync_start - mode->vdisplay) << 8) |
+			  (mode->hsync_start - mode->hdisplay));
+	ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_4, mode->hdisplay);
+	ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_5, mode->vdisplay);
+
+	if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+		flags |= SSD2825_HSYNC_HIGH;
+
+	if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+		flags |= SSD2825_VSYNC_HIGH;
+
+	if (dsi_dev->mode_flags & MIPI_DSI_MODE_VIDEO)
+		flags |= SSD2825_NON_BURST_EV;
+
+	if (input_bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
+		flags |= SSD2825_PCKL_HIGH;
+
+	ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_6, flags | pixel_format);
+	ssd2825_write_reg(priv, SSD2825_LANE_CONFIGURATION_REG, dsi_dev->lanes - 1);
+	ssd2825_write_reg(priv, SSD2825_TEST_REG, 0x0004);
+
+	/* Call PLL configuration */
+	ssd2825_setup_pll(priv, mode);
+
+	usleep_range(10000, 11000);
+
+	config = SSD2825_CONF_REG_HS | SSD2825_CONF_REG_CKE | SSD2825_CONF_REG_DCS |
+		 SSD2825_CONF_REG_ECD | SSD2825_CONF_REG_EOT;
+
+	if (dsi_dev->mode_flags & MIPI_DSI_MODE_LPM)
+		config &= ~SSD2825_CONF_REG_HS;
+
+	if (dsi_dev->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET)
+		config &= ~SSD2825_CONF_REG_EOT;
+
+	/* Initial DSI configuration register set */
+	ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);

drivers/gpu/drm/bridge/ssd2825.c line 639

Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+	ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0);
+
+	priv->enabled = true;
+}
+
+static void ssd2825_bridge_atomic_enable(struct drm_bridge *bridge,
+					 struct drm_atomic_state *state)
+{
+	/* placeholder */
+}

That doesn't work with any bridge or panel that doesn't require any DCS command to power up, unfortunately.

Quoted 97 lines
drivers/gpu/drm/bridge/ssd2825.c new file +97 -0
+static void ssd2825_bridge_atomic_disable(struct drm_bridge *bridge,
+					  struct drm_atomic_state *state)
+{
+	struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+	int ret;
+
+	if (!priv->enabled)
+		return;
+
+	msleep(100);
+
+	/* Exit DSI configuration register set */
+	ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG,
+			  SSD2825_CONF_REG_ECD | SSD2825_CONF_REG_EOT);
+	ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0);
+
+	/* HW disable */
+	gpiod_set_value_cansleep(priv->reset_gpio, 1);
+	usleep_range(5000, 6000);
+
+	ret = regulator_bulk_disable(ARRAY_SIZE(ssd2825_supplies),
+				     priv->supplies);
+	if (ret < 0)
+		dev_err(priv->dev, "error disabling regulators (%d)\n", ret);
+
+	clk_disable_unprepare(priv->tx_clk);
+
+	priv->enabled = false;
+}
+
+static int ssd2825_bridge_attach(struct drm_bridge *bridge, struct drm_encoder *encoder,
+				 enum drm_bridge_attach_flags flags)
+{
+	struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+
+	return drm_bridge_attach(bridge->encoder, priv->output.bridge, bridge,
+				 flags);
+}
+
+static enum drm_mode_status
+ssd2825_bridge_mode_valid(struct drm_bridge *bridge,
+			  const struct drm_display_info *info,
+			  const struct drm_display_mode *mode)
+{
+	if (mode->hdisplay > 1366)
+		return MODE_H_ILLEGAL;
+
+	if (mode->vdisplay > 1366)
+		return MODE_V_ILLEGAL;
+
+	return MODE_OK;
+}
+
+static bool ssd2825_mode_fixup(struct drm_bridge *bridge,
+			       const struct drm_display_mode *mode,
+			       struct drm_display_mode *adjusted_mode)
+{
+	/* Default to positive sync */
+
+	if (!(adjusted_mode->flags &
+	      (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC)))
+		adjusted_mode->flags |= DRM_MODE_FLAG_PHSYNC;
+
+	if (!(adjusted_mode->flags &
+	      (DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC)))
+		adjusted_mode->flags |= DRM_MODE_FLAG_PVSYNC;
+
+	return true;
+}
+
+static const struct drm_bridge_funcs ssd2825_bridge_funcs = {
+	.attach = ssd2825_bridge_attach,
+	.mode_valid = ssd2825_bridge_mode_valid,
+	.mode_fixup = ssd2825_mode_fixup,
+
+	.atomic_pre_enable = ssd2825_bridge_atomic_pre_enable,
+	.atomic_enable = ssd2825_bridge_atomic_enable,
+	.atomic_disable = ssd2825_bridge_atomic_disable,
+
+	.atomic_reset = drm_atomic_helper_bridge_reset,
+	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+};
+
+static const struct drm_bridge_timings default_ssd2825_timings = {
+	.input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE
+		 | DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE
+		 | DRM_BUS_FLAG_DE_HIGH,
+};
+
+static int ssd2825_probe(struct spi_device *spi)
+{
+	struct ssd2825_priv *priv;
+	struct device *dev = &spi->dev;
+	struct device_node *np = dev->of_node;
+	int ret;
+

drivers/gpu/drm/bridge/ssd2825.c line 747

Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+	/* Driver supports only 8 bit 3 Wire mode */
+	spi->bits_per_word = 9;
+
+	ret = spi_setup(spi);
+	if (ret)
+		return ret;
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;

devm_drm_bridge_alloc()

drivers/gpu/drm/bridge/ssd2825.c line 753

Quoted 5 lines
drivers/gpu/drm/bridge/ssd2825.c new file +5 -0
+	spi_set_drvdata(spi, priv);
+	priv->spi = spi;
+
+	dev_set_drvdata(dev, priv);
+	priv->dev = dev;

spi_set_drvdata and dev_set_drvdata are doing the same thing here.

Maxime

#4 lore raw

Re: [PATCH v6 2/2] drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

чт, 19 черв. 2025 р. о 12:41 Maxime Ripard <[email protected]> пише:

Quoted 11 lines · Svyatoslav Ryhel
Quoted 9 lines
drivers/gpu/drm/bridge/ssd2825.c new file +9 -0
+static ssize_t ssd2825_dsi_host_transfer(struct mipi_dsi_host *host,
+                                      const struct mipi_dsi_msg *msg)
+{
+     struct ssd2825_priv *priv = dsi_host_to_ssd2825(host);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     u8 buf = *(u8 *)msg->tx_buf;
+     u16 config;
+     int ret;
+
Quoted 9 lines

drivers/gpu/drm/bridge/ssd2825.c line 356

Quoted 4 lines
drivers/gpu/drm/bridge/ssd2825.c new file +4 -0
+     if (!priv->enabled) {
+             dev_err(priv->dev, "Bridge is not enabled\n");
+             return -ENODEV;
+     }

Transfers can and should happen even when the bridge is disabled. The hardware might not permit that, but you'll need to elaborate in the comment about why.

This ensures that hw was configured properly in pre_enable and since pre_enable is void it will not return any errors if it fails.

Quoted 51 lines
Quoted 51 lines
drivers/gpu/drm/bridge/ssd2825.c new file +51 -0
+     if (msg->rx_len) {
+             dev_warn(priv->dev, "MIPI rx is not supported\n");
+             return -EOPNOTSUPP;
+     }
+
+     guard(mutex)(&priv->mlock);
+
+     ret = ssd2825_read_reg(priv, SSD2825_CONFIGURATION_REG, &config);
+     if (ret)
+             return ret;
+
+     switch (msg->type) {
+     case MIPI_DSI_DCS_SHORT_WRITE:
+     case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+     case MIPI_DSI_DCS_LONG_WRITE:
+             config |= SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
+     case MIPI_DSI_GENERIC_LONG_WRITE:
+             config &= ~SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_DCS_READ:
+     case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+     default:
+             return 0;
+     }
+
+     ret = ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0x0000);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_dsi(priv, msg->tx_buf, msg->tx_len);
+     if (ret)
+             return ret;
+
+     if (buf == MIPI_DCS_SET_DISPLAY_ON) {
+             /*
+              * NOTE! This is here since it cannot be called in bridge enable because
+              * bridge pre enable and bridge enable have no gap in between.
+              *
+              * Existing framework bridge-panel seq is:
+              *      panel_prepare > bridge_pre_enable > bridge_enable > panel_enable
+              *
Quoted 9 lines

drivers/gpu/drm/bridge/ssd2825.c line 414

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+              * Using prepare_prev_first was tested, but it switches seq like this:
+              *      bridge_pre_enable > panel_prepare > bridge_enable > panel_enable
+              *
+              * This will not work since panel hw MUST be prepared before bridge is
+              * configured. Correct seq should be:
+              *      panel_prepare > bridge_pre_enable > panel_enable > bridge_enable

Where is that requirement coming from?

This is how my device's (LG P895) bridge-panel combo works. Panel hw must be enabled before bridge, then bridge hw, then panel can send init sequence and then bridge must complete configuration.

Quoted 11 lines

panel prepare is documented as:

The .prepare() function is typically called before the display controller starts to transmit video data.

And video data transmission for bridges only happen at bridge_enable time.

So, from an API PoV, all the sequences above are correct.

There is no way ATM for this bridge to complete configuration, there either should be a way to swap panel_enable and bridge_enable or there should be added an additional operation like bridge_post_enable or smth like that for cases like here when bridge has to complete configuration after panel init seq is sent.

Quoted 11 lines

drivers/gpu/drm/bridge/ssd2825.c line 422

Quoted 7 lines
drivers/gpu/drm/bridge/ssd2825.c new file +7 -0
+              * Last two functions should be swapped related to existing framework.
+              * I am not aware about method which allows that.
+              *
+              * Once there will be such method/flag, code below should be moved into
+              * bridge_enable since it is basically a bridge configuration completing
+              * after initial panel DSI sequence is completed.
+              */

If there's anything to fix, we should do it before introducing that driver.

I just want to have a bridge my device uses to be supported by mainline linux. I have no intention to touch any part of DRM framework and cause instabilities, maintainers rage and hate.

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+static void ssd2825_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+                                          struct drm_atomic_state *state)
+{
+     struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     const struct drm_crtc_state *crtc_state;
+     const struct drm_display_mode *mode;
+     struct drm_connector *connector;
+     struct drm_crtc *crtc;
+     u32 input_bus_flags = bridge->timings->input_bus_flags;
Quoted 9 lines

drivers/gpu/drm/bridge/ssd2825.c line 545

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+     u16 flags = 0, config;
+     u8 pixel_format;
+     int ret;
+
+     if (priv->enabled)
+             return;

What is this guarding against?

blocks repeating ssd2825_bridge_atomic_pre_enable calls

Quoted 88 lines
Quoted 88 lines
drivers/gpu/drm/bridge/ssd2825.c new file +88 -0
+     /* Power Sequence */
+     ret = clk_prepare_enable(priv->tx_clk);
+     if (ret)
+             dev_err(priv->dev, "error enabling tx_clk (%d)\n", ret);
+
+     ret = regulator_bulk_enable(ARRAY_SIZE(ssd2825_supplies), priv->supplies);
+     if (ret)
+             dev_err(priv->dev, "error enabling regulators (%d)\n", ret);
+
+     usleep_range(1000, 2000);
+
+     ssd2825_hw_reset(priv);
+
+     /* Perform SW reset */
+     ssd2825_write_reg(priv, SSD2825_OPERATION_CTRL_REG, 0x0100);
+
+     /* Set pixel format */
+     switch (dsi_dev->format) {
+     case MIPI_DSI_FMT_RGB565:
+             pixel_format = 0x00;
+             break;
+     case MIPI_DSI_FMT_RGB666_PACKED:
+             pixel_format = 0x01;
+             break;
+     case MIPI_DSI_FMT_RGB666:
+             pixel_format = 0x02;
+             break;
+     case MIPI_DSI_FMT_RGB888:
+     default:
+             pixel_format = 0x03;
+             break;
+     }
+
+     connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
+     crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
+     crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+     mode = &crtc_state->adjusted_mode;
+
+     /* Set panel timings */
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_1,
+                       ((mode->vtotal - mode->vsync_end) << 8) |
+                       (mode->htotal - mode->hsync_end));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_2,
+                       ((mode->vtotal - mode->vsync_start) << 8) |
+                       (mode->htotal - mode->hsync_start));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_3,
+                       ((mode->vsync_start - mode->vdisplay) << 8) |
+                       (mode->hsync_start - mode->hdisplay));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_4, mode->hdisplay);
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_5, mode->vdisplay);
+
+     if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+             flags |= SSD2825_HSYNC_HIGH;
+
+     if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+             flags |= SSD2825_VSYNC_HIGH;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_VIDEO)
+             flags |= SSD2825_NON_BURST_EV;
+
+     if (input_bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
+             flags |= SSD2825_PCKL_HIGH;
+
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_6, flags | pixel_format);
+     ssd2825_write_reg(priv, SSD2825_LANE_CONFIGURATION_REG, dsi_dev->lanes - 1);
+     ssd2825_write_reg(priv, SSD2825_TEST_REG, 0x0004);
+
+     /* Call PLL configuration */
+     ssd2825_setup_pll(priv, mode);
+
+     usleep_range(10000, 11000);
+
+     config = SSD2825_CONF_REG_HS | SSD2825_CONF_REG_CKE | SSD2825_CONF_REG_DCS |
+              SSD2825_CONF_REG_ECD | SSD2825_CONF_REG_EOT;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_LPM)
+             config &= ~SSD2825_CONF_REG_HS;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET)
+             config &= ~SSD2825_CONF_REG_EOT;
+
+     /* Initial DSI configuration register set */
+     ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0);
+
+     priv->enabled = true;
+}
+
Quoted 9 lines

drivers/gpu/drm/bridge/ssd2825.c line 639

Quoted 5 lines
drivers/gpu/drm/bridge/ssd2825.c new file +5 -0
+static void ssd2825_bridge_atomic_enable(struct drm_bridge *bridge,
+                                      struct drm_atomic_state *state)
+{
+     /* placeholder */
+}

That doesn't work with any bridge or panel that doesn't require any DCS command to power up, unfortunately.

Yes that is a flaw unfortunately, if you have suggestions of fixing this just tell me.

Quoted 101 lines
Quoted 101 lines
drivers/gpu/drm/bridge/ssd2825.c new file +101 -0
+static void ssd2825_bridge_atomic_disable(struct drm_bridge *bridge,
+                                       struct drm_atomic_state *state)
+{
+     struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+     int ret;
+
+     if (!priv->enabled)
+             return;
+
+     msleep(100);
+
+     /* Exit DSI configuration register set */
+     ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG,
+                       SSD2825_CONF_REG_ECD | SSD2825_CONF_REG_EOT);
+     ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0);
+
+     /* HW disable */
+     gpiod_set_value_cansleep(priv->reset_gpio, 1);
+     usleep_range(5000, 6000);
+
+     ret = regulator_bulk_disable(ARRAY_SIZE(ssd2825_supplies),
+                                  priv->supplies);
+     if (ret < 0)
+             dev_err(priv->dev, "error disabling regulators (%d)\n", ret);
+
+     clk_disable_unprepare(priv->tx_clk);
+
+     priv->enabled = false;
+}
+
+static int ssd2825_bridge_attach(struct drm_bridge *bridge, struct drm_encoder *encoder,
+                              enum drm_bridge_attach_flags flags)
+{
+     struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+
+     return drm_bridge_attach(bridge->encoder, priv->output.bridge, bridge,
+                              flags);
+}
+
+static enum drm_mode_status
+ssd2825_bridge_mode_valid(struct drm_bridge *bridge,
+                       const struct drm_display_info *info,
+                       const struct drm_display_mode *mode)
+{
+     if (mode->hdisplay > 1366)
+             return MODE_H_ILLEGAL;
+
+     if (mode->vdisplay > 1366)
+             return MODE_V_ILLEGAL;
+
+     return MODE_OK;
+}
+
+static bool ssd2825_mode_fixup(struct drm_bridge *bridge,
+                            const struct drm_display_mode *mode,
+                            struct drm_display_mode *adjusted_mode)
+{
+     /* Default to positive sync */
+
+     if (!(adjusted_mode->flags &
+           (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NHSYNC)))
+             adjusted_mode->flags |= DRM_MODE_FLAG_PHSYNC;
+
+     if (!(adjusted_mode->flags &
+           (DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC)))
+             adjusted_mode->flags |= DRM_MODE_FLAG_PVSYNC;
+
+     return true;
+}
+
+static const struct drm_bridge_funcs ssd2825_bridge_funcs = {
+     .attach = ssd2825_bridge_attach,
+     .mode_valid = ssd2825_bridge_mode_valid,
+     .mode_fixup = ssd2825_mode_fixup,
+
+     .atomic_pre_enable = ssd2825_bridge_atomic_pre_enable,
+     .atomic_enable = ssd2825_bridge_atomic_enable,
+     .atomic_disable = ssd2825_bridge_atomic_disable,
+
+     .atomic_reset = drm_atomic_helper_bridge_reset,
+     .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+     .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+};
+
+static const struct drm_bridge_timings default_ssd2825_timings = {
+     .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE
+              | DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE
+              | DRM_BUS_FLAG_DE_HIGH,
+};
+
+static int ssd2825_probe(struct spi_device *spi)
+{
+     struct ssd2825_priv *priv;
+     struct device *dev = &spi->dev;
+     struct device_node *np = dev->of_node;
+     int ret;
+
+     /* Driver supports only 8 bit 3 Wire mode */
+     spi->bits_per_word = 9;
+
+     ret = spi_setup(spi);
Quoted 9 lines

drivers/gpu/drm/bridge/ssd2825.c line 747

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+     if (ret)
+             return ret;
+
+     priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+     if (!priv)
+             return -ENOMEM;

devm_drm_bridge_alloc()

OK

Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 753

Quoted 5 lines
drivers/gpu/drm/bridge/ssd2825.c new file +5 -0
+     spi_set_drvdata(spi, priv);
+     priv->spi = spi;
+
+     dev_set_drvdata(dev, priv);
+     priv->dev = dev;

spi_set_drvdata and dev_set_drvdata are doing the same thing here.

spi_set_drvdata is actually used, but dev_set_drvdata may be removed, yes.

Quoted 1 line

Maxime

maintainer
#5 lore raw

Re: [PATCH v6 2/2] drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

Quoted 21 lines · Svyatoslav Ryhel

чт, 19 черв. 2025 р. о 12:41 Maxime Ripard <[email protected]> пише:

Quoted 11 lines · Svyatoslav Ryhel
Quoted 9 lines
drivers/gpu/drm/bridge/ssd2825.c new file +9 -0
+static ssize_t ssd2825_dsi_host_transfer(struct mipi_dsi_host *host,
+                                      const struct mipi_dsi_msg *msg)
+{
+     struct ssd2825_priv *priv = dsi_host_to_ssd2825(host);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     u8 buf = *(u8 *)msg->tx_buf;
+     u16 config;
+     int ret;
+
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 356

Quoted 4 lines
drivers/gpu/drm/bridge/ssd2825.c new file +4 -0
+     if (!priv->enabled) {
+             dev_err(priv->dev, "Bridge is not enabled\n");
+             return -ENODEV;
+     }

Transfers can and should happen even when the bridge is disabled. The hardware might not permit that, but you'll need to elaborate in the comment about why.

Quoted 2 lines

This ensures that hw was configured properly in pre_enable and since pre_enable is void it will not return any errors if it fails.

There's no relationship between the bridge pre_enable and enable hooks, and the MIPI-DSI host transfer one. It's perfectly valid to call transfer if the bridge is detached or disabled.

Quoted 60 lines
Quoted 51 lines
Quoted 51 lines
drivers/gpu/drm/bridge/ssd2825.c new file +51 -0
+     if (msg->rx_len) {
+             dev_warn(priv->dev, "MIPI rx is not supported\n");
+             return -EOPNOTSUPP;
+     }
+
+     guard(mutex)(&priv->mlock);
+
+     ret = ssd2825_read_reg(priv, SSD2825_CONFIGURATION_REG, &config);
+     if (ret)
+             return ret;
+
+     switch (msg->type) {
+     case MIPI_DSI_DCS_SHORT_WRITE:
+     case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+     case MIPI_DSI_DCS_LONG_WRITE:
+             config |= SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
+     case MIPI_DSI_GENERIC_LONG_WRITE:
+             config &= ~SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_DCS_READ:
+     case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+     default:
+             return 0;
+     }
+
+     ret = ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0x0000);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_dsi(priv, msg->tx_buf, msg->tx_len);
+     if (ret)
+             return ret;
+
+     if (buf == MIPI_DCS_SET_DISPLAY_ON) {
+             /*
+              * NOTE! This is here since it cannot be called in bridge enable because
+              * bridge pre enable and bridge enable have no gap in between.
+              *
+              * Existing framework bridge-panel seq is:
+              *      panel_prepare > bridge_pre_enable > bridge_enable > panel_enable
+              *
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 414

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+              * Using prepare_prev_first was tested, but it switches seq like this:
+              *      bridge_pre_enable > panel_prepare > bridge_enable > panel_enable
+              *
+              * This will not work since panel hw MUST be prepared before bridge is
+              * configured. Correct seq should be:
+              *      panel_prepare > bridge_pre_enable > panel_enable > bridge_enable

Where is that requirement coming from?

Quoted 3 lines

This is how my device's (LG P895) bridge-panel combo works. Panel hw must be enabled before bridge, then bridge hw, then panel can send init sequence and then bridge must complete configuration.

Do you have a documentation for that DSI device?

DSI devices typically come with requirement of the power states of the lanes, that's what you want to discuss here. How we can model that in software is a discussion we need to have once we've identified what the hardware needs exactly.

Quoted 25 lines
Quoted 10 lines

panel prepare is documented as:

The .prepare() function is typically called before the display controller starts to transmit video data.

And video data transmission for bridges only happen at bridge_enable time.

So, from an API PoV, all the sequences above are correct.

There is no way ATM for this bridge to complete configuration, there either should be a way to swap panel_enable and bridge_enable or there should be added an additional operation like bridge_post_enable or smth like that for cases like here when bridge has to complete configuration after panel init seq is sent.

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/bridge/ssd2825.c new file +7 -0
+              * Last two functions should be swapped related to existing framework.
+              * I am not aware about method which allows that.
+              *
+              * Once there will be such method/flag, code below should be moved into
+              * bridge_enable since it is basically a bridge configuration completing
+              * after initial panel DSI sequence is completed.
+              */
Quoted 6 lines
Quoted 2 lines

If there's anything to fix, we should do it before introducing that driver.

I just want to have a bridge my device uses to be supported by mainline linux. I have no intention to touch any part of DRM framework and cause instabilities, maintainers rage and hate.

And I just want all drivers to behave consistently.

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+static void ssd2825_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+                                          struct drm_atomic_state *state)
+{
+     struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     const struct drm_crtc_state *crtc_state;
+     const struct drm_display_mode *mode;
+     struct drm_connector *connector;
+     struct drm_crtc *crtc;
+     u32 input_bus_flags = bridge->timings->input_bus_flags;
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 545

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+     u16 flags = 0, config;
+     u8 pixel_format;
+     int ret;
+
+     if (priv->enabled)
+             return;

What is this guarding against?

Quoted 1 line

blocks repeating ssd2825_bridge_atomic_pre_enable calls

Which happens in which situation?

Quoted 97 lines
Quoted 88 lines
Quoted 88 lines
drivers/gpu/drm/bridge/ssd2825.c new file +88 -0
+     /* Power Sequence */
+     ret = clk_prepare_enable(priv->tx_clk);
+     if (ret)
+             dev_err(priv->dev, "error enabling tx_clk (%d)\n", ret);
+
+     ret = regulator_bulk_enable(ARRAY_SIZE(ssd2825_supplies), priv->supplies);
+     if (ret)
+             dev_err(priv->dev, "error enabling regulators (%d)\n", ret);
+
+     usleep_range(1000, 2000);
+
+     ssd2825_hw_reset(priv);
+
+     /* Perform SW reset */
+     ssd2825_write_reg(priv, SSD2825_OPERATION_CTRL_REG, 0x0100);
+
+     /* Set pixel format */
+     switch (dsi_dev->format) {
+     case MIPI_DSI_FMT_RGB565:
+             pixel_format = 0x00;
+             break;
+     case MIPI_DSI_FMT_RGB666_PACKED:
+             pixel_format = 0x01;
+             break;
+     case MIPI_DSI_FMT_RGB666:
+             pixel_format = 0x02;
+             break;
+     case MIPI_DSI_FMT_RGB888:
+     default:
+             pixel_format = 0x03;
+             break;
+     }
+
+     connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
+     crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
+     crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+     mode = &crtc_state->adjusted_mode;
+
+     /* Set panel timings */
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_1,
+                       ((mode->vtotal - mode->vsync_end) << 8) |
+                       (mode->htotal - mode->hsync_end));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_2,
+                       ((mode->vtotal - mode->vsync_start) << 8) |
+                       (mode->htotal - mode->hsync_start));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_3,
+                       ((mode->vsync_start - mode->vdisplay) << 8) |
+                       (mode->hsync_start - mode->hdisplay));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_4, mode->hdisplay);
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_5, mode->vdisplay);
+
+     if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+             flags |= SSD2825_HSYNC_HIGH;
+
+     if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+             flags |= SSD2825_VSYNC_HIGH;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_VIDEO)
+             flags |= SSD2825_NON_BURST_EV;
+
+     if (input_bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
+             flags |= SSD2825_PCKL_HIGH;
+
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_6, flags | pixel_format);
+     ssd2825_write_reg(priv, SSD2825_LANE_CONFIGURATION_REG, dsi_dev->lanes - 1);
+     ssd2825_write_reg(priv, SSD2825_TEST_REG, 0x0004);
+
+     /* Call PLL configuration */
+     ssd2825_setup_pll(priv, mode);
+
+     usleep_range(10000, 11000);
+
+     config = SSD2825_CONF_REG_HS | SSD2825_CONF_REG_CKE | SSD2825_CONF_REG_DCS |
+              SSD2825_CONF_REG_ECD | SSD2825_CONF_REG_EOT;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_LPM)
+             config &= ~SSD2825_CONF_REG_HS;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET)
+             config &= ~SSD2825_CONF_REG_EOT;
+
+     /* Initial DSI configuration register set */
+     ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0);
+
+     priv->enabled = true;
+}
+
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 639

Quoted 5 lines
drivers/gpu/drm/bridge/ssd2825.c new file +5 -0
+static void ssd2825_bridge_atomic_enable(struct drm_bridge *bridge,
+                                      struct drm_atomic_state *state)
+{
+     /* placeholder */
+}

That doesn't work with any bridge or panel that doesn't require any DCS command to power up, unfortunately.

Quoted 2 lines

Yes that is a flaw unfortunately, if you have suggestions of fixing this just tell me.

Untangle pre_enable and enable from transfer, and in enable actually enable the bridge, and it will work just fine.

Maxime

#6 lore raw

Re: [PATCH v6 2/2] drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

чт, 19 черв. 2025 р. о 15:05 Maxime Ripard <[email protected]> пише:

Quoted 23 lines · Svyatoslav Ryhel
Quoted 21 lines

чт, 19 черв. 2025 р. о 12:41 Maxime Ripard <[email protected]> пише:

Quoted 19 lines · Svyatoslav Ryhel

drivers/gpu/drm/bridge/ssd2825.c line 356

Quoted 13 lines
drivers/gpu/drm/bridge/ssd2825.c new file +13 -0
+static ssize_t ssd2825_dsi_host_transfer(struct mipi_dsi_host *host,
+                                      const struct mipi_dsi_msg *msg)
+{
+     struct ssd2825_priv *priv = dsi_host_to_ssd2825(host);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     u8 buf = *(u8 *)msg->tx_buf;
+     u16 config;
+     int ret;
+
+     if (!priv->enabled) {
+             dev_err(priv->dev, "Bridge is not enabled\n");
+             return -ENODEV;
+     }

Transfers can and should happen even when the bridge is disabled. The hardware might not permit that, but you'll need to elaborate in the comment about why.

Quoted 7 lines
Quoted 2 lines

This ensures that hw was configured properly in pre_enable and since pre_enable is void it will not return any errors if it fails.

There's no relationship between the bridge pre_enable and enable hooks, and the MIPI-DSI host transfer one. It's perfectly valid to call transfer if the bridge is detached or disabled.

That is twisted logic, but ok, fine, I don't care.

Quoted 60 lines
Quoted 60 lines
Quoted 59 lines
Quoted 47 lines
drivers/gpu/drm/bridge/ssd2825.c new file +47 -0
+     if (msg->rx_len) {
+             dev_warn(priv->dev, "MIPI rx is not supported\n");
+             return -EOPNOTSUPP;
+     }
+
+     guard(mutex)(&priv->mlock);
+
+     ret = ssd2825_read_reg(priv, SSD2825_CONFIGURATION_REG, &config);
+     if (ret)
+             return ret;
+
+     switch (msg->type) {
+     case MIPI_DSI_DCS_SHORT_WRITE:
+     case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+     case MIPI_DSI_DCS_LONG_WRITE:
+             config |= SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
+     case MIPI_DSI_GENERIC_LONG_WRITE:
+             config &= ~SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_DCS_READ:
+     case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+     default:
+             return 0;
+     }
+
+     ret = ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0x0000);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_dsi(priv, msg->tx_buf, msg->tx_len);
+     if (ret)
+             return ret;
+
+     if (buf == MIPI_DCS_SET_DISPLAY_ON) {
+             /*
+              * NOTE! This is here since it cannot be called in bridge enable because
+              * bridge pre enable and bridge enable have no gap in between.

drivers/gpu/drm/bridge/ssd2825.c line 414

Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+              *
+              * Existing framework bridge-panel seq is:
+              *      panel_prepare > bridge_pre_enable > bridge_enable > panel_enable
+              *
+              * Using prepare_prev_first was tested, but it switches seq like this:
+              *      bridge_pre_enable > panel_prepare > bridge_enable > panel_enable
+              *
+              * This will not work since panel hw MUST be prepared before bridge is
+              * configured. Correct seq should be:
+              *      panel_prepare > bridge_pre_enable > panel_enable > bridge_enable

Where is that requirement coming from?

Quoted 6 lines
Quoted 3 lines

This is how my device's (LG P895) bridge-panel combo works. Panel hw must be enabled before bridge, then bridge hw, then panel can send init sequence and then bridge must complete configuration.

Do you have a documentation for that DSI device?

No

Quoted 30 lines

DSI devices typically come with requirement of the power states of the lanes, that's what you want to discuss here. How we can model that in software is a discussion we need to have once we've identified what the hardware needs exactly.

Quoted 25 lines
Quoted 10 lines

panel prepare is documented as:

The .prepare() function is typically called before the display controller starts to transmit video data.

And video data transmission for bridges only happen at bridge_enable time.

So, from an API PoV, all the sequences above are correct.

There is no way ATM for this bridge to complete configuration, there either should be a way to swap panel_enable and bridge_enable or there should be added an additional operation like bridge_post_enable or smth like that for cases like here when bridge has to complete configuration after panel init seq is sent.

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/bridge/ssd2825.c new file +7 -0
+              * Last two functions should be swapped related to existing framework.
+              * I am not aware about method which allows that.
+              *
+              * Once there will be such method/flag, code below should be moved into
+              * bridge_enable since it is basically a bridge configuration completing
+              * after initial panel DSI sequence is completed.
+              */
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

If there's anything to fix, we should do it before introducing that driver.

I just want to have a bridge my device uses to be supported by mainline linux. I have no intention to touch any part of DRM framework and cause instabilities, maintainers rage and hate.

And I just want all drivers to behave consistently.

Ye, sure.

Quoted 120 lines
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+static void ssd2825_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+                                          struct drm_atomic_state *state)
+{
+     struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     const struct drm_crtc_state *crtc_state;
+     const struct drm_display_mode *mode;
+     struct drm_connector *connector;
+     struct drm_crtc *crtc;
+     u32 input_bus_flags = bridge->timings->input_bus_flags;
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 545

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+     u16 flags = 0, config;
+     u8 pixel_format;
+     int ret;
+
+     if (priv->enabled)
+             return;

What is this guarding against?

Quoted 1 line

blocks repeating ssd2825_bridge_atomic_pre_enable calls

Which happens in which situation?

Quoted 97 lines
Quoted 96 lines
Quoted 83 lines
drivers/gpu/drm/bridge/ssd2825.c new file +83 -0
+     /* Power Sequence */
+     ret = clk_prepare_enable(priv->tx_clk);
+     if (ret)
+             dev_err(priv->dev, "error enabling tx_clk (%d)\n", ret);
+
+     ret = regulator_bulk_enable(ARRAY_SIZE(ssd2825_supplies), priv->supplies);
+     if (ret)
+             dev_err(priv->dev, "error enabling regulators (%d)\n", ret);
+
+     usleep_range(1000, 2000);
+
+     ssd2825_hw_reset(priv);
+
+     /* Perform SW reset */
+     ssd2825_write_reg(priv, SSD2825_OPERATION_CTRL_REG, 0x0100);
+
+     /* Set pixel format */
+     switch (dsi_dev->format) {
+     case MIPI_DSI_FMT_RGB565:
+             pixel_format = 0x00;
+             break;
+     case MIPI_DSI_FMT_RGB666_PACKED:
+             pixel_format = 0x01;
+             break;
+     case MIPI_DSI_FMT_RGB666:
+             pixel_format = 0x02;
+             break;
+     case MIPI_DSI_FMT_RGB888:
+     default:
+             pixel_format = 0x03;
+             break;
+     }
+
+     connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
+     crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
+     crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+     mode = &crtc_state->adjusted_mode;
+
+     /* Set panel timings */
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_1,
+                       ((mode->vtotal - mode->vsync_end) << 8) |
+                       (mode->htotal - mode->hsync_end));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_2,
+                       ((mode->vtotal - mode->vsync_start) << 8) |
+                       (mode->htotal - mode->hsync_start));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_3,
+                       ((mode->vsync_start - mode->vdisplay) << 8) |
+                       (mode->hsync_start - mode->hdisplay));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_4, mode->hdisplay);
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_5, mode->vdisplay);
+
+     if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+             flags |= SSD2825_HSYNC_HIGH;
+
+     if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+             flags |= SSD2825_VSYNC_HIGH;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_VIDEO)
+             flags |= SSD2825_NON_BURST_EV;
+
+     if (input_bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
+             flags |= SSD2825_PCKL_HIGH;
+
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_6, flags | pixel_format);
+     ssd2825_write_reg(priv, SSD2825_LANE_CONFIGURATION_REG, dsi_dev->lanes - 1);
+     ssd2825_write_reg(priv, SSD2825_TEST_REG, 0x0004);
+
+     /* Call PLL configuration */
+     ssd2825_setup_pll(priv, mode);
+
+     usleep_range(10000, 11000);
+
+     config = SSD2825_CONF_REG_HS | SSD2825_CONF_REG_CKE | SSD2825_CONF_REG_DCS |
+              SSD2825_CONF_REG_ECD | SSD2825_CONF_REG_EOT;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_LPM)
+             config &= ~SSD2825_CONF_REG_HS;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET)
+             config &= ~SSD2825_CONF_REG_EOT;
+
+     /* Initial DSI configuration register set */
+     ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);

drivers/gpu/drm/bridge/ssd2825.c line 639

Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+     ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0);
+
+     priv->enabled = true;
+}
+
+static void ssd2825_bridge_atomic_enable(struct drm_bridge *bridge,
+                                      struct drm_atomic_state *state)
+{
+     /* placeholder */
+}

That doesn't work with any bridge or panel that doesn't require any DCS command to power up, unfortunately.

Quoted 6 lines
Quoted 2 lines

Yes that is a flaw unfortunately, if you have suggestions of fixing this just tell me.

Untangle pre_enable and enable from transfer, and in enable actually enable the bridge, and it will work just fine.

No it will not, I have tried and panel fails cause panel hw is init in pre-enable and init sequence is sent in enable, which is expected logic. Yet bridge cannot complete configuration because panel enable function is called AFTER bridge enable.

Quoted 1 line

Maxime

maintainer
#7 lore raw

Re: [PATCH v6 2/2] drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

Quoted 24 lines · Svyatoslav Ryhel

чт, 19 черв. 2025 р. о 15:05 Maxime Ripard <[email protected]> пише:

Quoted 23 lines · Svyatoslav Ryhel
Quoted 21 lines

чт, 19 черв. 2025 р. о 12:41 Maxime Ripard <[email protected]> пише:

Quoted 19 lines · Svyatoslav Ryhel

drivers/gpu/drm/bridge/ssd2825.c line 356

Quoted 13 lines
drivers/gpu/drm/bridge/ssd2825.c new file +13 -0
+static ssize_t ssd2825_dsi_host_transfer(struct mipi_dsi_host *host,
+                                      const struct mipi_dsi_msg *msg)
+{
+     struct ssd2825_priv *priv = dsi_host_to_ssd2825(host);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     u8 buf = *(u8 *)msg->tx_buf;
+     u16 config;
+     int ret;
+
+     if (!priv->enabled) {
+             dev_err(priv->dev, "Bridge is not enabled\n");
+             return -ENODEV;
+     }

Transfers can and should happen even when the bridge is disabled. The hardware might not permit that, but you'll need to elaborate in the comment about why.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

This ensures that hw was configured properly in pre_enable and since pre_enable is void it will not return any errors if it fails.

There's no relationship between the bridge pre_enable and enable hooks, and the MIPI-DSI host transfer one. It's perfectly valid to call transfer if the bridge is detached or disabled.

That is twisted logic, but ok, fine, I don't care.

It's not twisted. It's perfectly valid for a panel to read its revision at probe time, before it registers, for example.

It would happen before the panel is enabled, and before the bridge is enabled.

Quoted 234 lines
Quoted 60 lines
Quoted 60 lines
Quoted 59 lines
Quoted 47 lines
drivers/gpu/drm/bridge/ssd2825.c new file +47 -0
+     if (msg->rx_len) {
+             dev_warn(priv->dev, "MIPI rx is not supported\n");
+             return -EOPNOTSUPP;
+     }
+
+     guard(mutex)(&priv->mlock);
+
+     ret = ssd2825_read_reg(priv, SSD2825_CONFIGURATION_REG, &config);
+     if (ret)
+             return ret;
+
+     switch (msg->type) {
+     case MIPI_DSI_DCS_SHORT_WRITE:
+     case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+     case MIPI_DSI_DCS_LONG_WRITE:
+             config |= SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
+     case MIPI_DSI_GENERIC_LONG_WRITE:
+             config &= ~SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_DCS_READ:
+     case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+     default:
+             return 0;
+     }
+
+     ret = ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0x0000);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_dsi(priv, msg->tx_buf, msg->tx_len);
+     if (ret)
+             return ret;
+
+     if (buf == MIPI_DCS_SET_DISPLAY_ON) {
+             /*
+              * NOTE! This is here since it cannot be called in bridge enable because
+              * bridge pre enable and bridge enable have no gap in between.

drivers/gpu/drm/bridge/ssd2825.c line 414

Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+              *
+              * Existing framework bridge-panel seq is:
+              *      panel_prepare > bridge_pre_enable > bridge_enable > panel_enable
+              *
+              * Using prepare_prev_first was tested, but it switches seq like this:
+              *      bridge_pre_enable > panel_prepare > bridge_enable > panel_enable
+              *
+              * This will not work since panel hw MUST be prepared before bridge is
+              * configured. Correct seq should be:
+              *      panel_prepare > bridge_pre_enable > panel_enable > bridge_enable

Where is that requirement coming from?

Quoted 6 lines
Quoted 3 lines

This is how my device's (LG P895) bridge-panel combo works. Panel hw must be enabled before bridge, then bridge hw, then panel can send init sequence and then bridge must complete configuration.

Do you have a documentation for that DSI device?

No

Quoted 30 lines

DSI devices typically come with requirement of the power states of the lanes, that's what you want to discuss here. How we can model that in software is a discussion we need to have once we've identified what the hardware needs exactly.

Quoted 25 lines
Quoted 10 lines

panel prepare is documented as:

The .prepare() function is typically called before the display controller starts to transmit video data.

And video data transmission for bridges only happen at bridge_enable time.

So, from an API PoV, all the sequences above are correct.

There is no way ATM for this bridge to complete configuration, there either should be a way to swap panel_enable and bridge_enable or there should be added an additional operation like bridge_post_enable or smth like that for cases like here when bridge has to complete configuration after panel init seq is sent.

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/bridge/ssd2825.c new file +7 -0
+              * Last two functions should be swapped related to existing framework.
+              * I am not aware about method which allows that.
+              *
+              * Once there will be such method/flag, code below should be moved into
+              * bridge_enable since it is basically a bridge configuration completing
+              * after initial panel DSI sequence is completed.
+              */
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

If there's anything to fix, we should do it before introducing that driver.

I just want to have a bridge my device uses to be supported by mainline linux. I have no intention to touch any part of DRM framework and cause instabilities, maintainers rage and hate.

And I just want all drivers to behave consistently.

Ye, sure.

Quoted 123 lines
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+static void ssd2825_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+                                          struct drm_atomic_state *state)
+{
+     struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     const struct drm_crtc_state *crtc_state;
+     const struct drm_display_mode *mode;
+     struct drm_connector *connector;
+     struct drm_crtc *crtc;
+     u32 input_bus_flags = bridge->timings->input_bus_flags;
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 545

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+     u16 flags = 0, config;
+     u8 pixel_format;
+     int ret;
+
+     if (priv->enabled)
+             return;

What is this guarding against?

Quoted 1 line

blocks repeating ssd2825_bridge_atomic_pre_enable calls

Which happens in which situation?

Quoted 99 lines
Quoted 88 lines
Quoted 88 lines
drivers/gpu/drm/bridge/ssd2825.c new file +88 -0
+     /* Power Sequence */
+     ret = clk_prepare_enable(priv->tx_clk);
+     if (ret)
+             dev_err(priv->dev, "error enabling tx_clk (%d)\n", ret);
+
+     ret = regulator_bulk_enable(ARRAY_SIZE(ssd2825_supplies), priv->supplies);
+     if (ret)
+             dev_err(priv->dev, "error enabling regulators (%d)\n", ret);
+
+     usleep_range(1000, 2000);
+
+     ssd2825_hw_reset(priv);
+
+     /* Perform SW reset */
+     ssd2825_write_reg(priv, SSD2825_OPERATION_CTRL_REG, 0x0100);
+
+     /* Set pixel format */
+     switch (dsi_dev->format) {
+     case MIPI_DSI_FMT_RGB565:
+             pixel_format = 0x00;
+             break;
+     case MIPI_DSI_FMT_RGB666_PACKED:
+             pixel_format = 0x01;
+             break;
+     case MIPI_DSI_FMT_RGB666:
+             pixel_format = 0x02;
+             break;
+     case MIPI_DSI_FMT_RGB888:
+     default:
+             pixel_format = 0x03;
+             break;
+     }
+
+     connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
+     crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
+     crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+     mode = &crtc_state->adjusted_mode;
+
+     /* Set panel timings */
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_1,
+                       ((mode->vtotal - mode->vsync_end) << 8) |
+                       (mode->htotal - mode->hsync_end));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_2,
+                       ((mode->vtotal - mode->vsync_start) << 8) |
+                       (mode->htotal - mode->hsync_start));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_3,
+                       ((mode->vsync_start - mode->vdisplay) << 8) |
+                       (mode->hsync_start - mode->hdisplay));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_4, mode->hdisplay);
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_5, mode->vdisplay);
+
+     if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+             flags |= SSD2825_HSYNC_HIGH;
+
+     if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+             flags |= SSD2825_VSYNC_HIGH;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_VIDEO)
+             flags |= SSD2825_NON_BURST_EV;
+
+     if (input_bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
+             flags |= SSD2825_PCKL_HIGH;
+
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_6, flags | pixel_format);
+     ssd2825_write_reg(priv, SSD2825_LANE_CONFIGURATION_REG, dsi_dev->lanes - 1);
+     ssd2825_write_reg(priv, SSD2825_TEST_REG, 0x0004);
+
+     /* Call PLL configuration */
+     ssd2825_setup_pll(priv, mode);
+
+     usleep_range(10000, 11000);
+
+     config = SSD2825_CONF_REG_HS | SSD2825_CONF_REG_CKE | SSD2825_CONF_REG_DCS |
+              SSD2825_CONF_REG_ECD | SSD2825_CONF_REG_EOT;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_LPM)
+             config &= ~SSD2825_CONF_REG_HS;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET)
+             config &= ~SSD2825_CONF_REG_EOT;
+
+     /* Initial DSI configuration register set */
+     ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0);
+
+     priv->enabled = true;
+}
+
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 639

Quoted 5 lines
drivers/gpu/drm/bridge/ssd2825.c new file +5 -0
+static void ssd2825_bridge_atomic_enable(struct drm_bridge *bridge,
+                                      struct drm_atomic_state *state)
+{
+     /* placeholder */
+}

That doesn't work with any bridge or panel that doesn't require any DCS command to power up, unfortunately.

Yes that is a flaw unfortunately, if you have suggestions of fixing this just tell me.

Quoted 8 lines
Quoted 3 lines

Untangle pre_enable and enable from transfer, and in enable actually enable the bridge, and it will work just fine.

No it will not, I have tried and panel fails cause panel hw is init in pre-enable and init sequence is sent in enable, which is expected logic. Yet bridge cannot complete configuration because panel enable function is called AFTER bridge enable.

Then I guess we're at a dead-end now, aren't we?

Maxime

#8 lore raw

Re: [PATCH v6 2/2] drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

чт, 19 черв. 2025 р. о 16:13 Maxime Ripard <[email protected]> пише:

Quoted 279 lines · Svyatoslav Ryhel
Quoted 24 lines

чт, 19 черв. 2025 р. о 15:05 Maxime Ripard <[email protected]> пише:

Quoted 23 lines · Svyatoslav Ryhel
Quoted 21 lines

чт, 19 черв. 2025 р. о 12:41 Maxime Ripard <[email protected]> пише:

Quoted 19 lines · Svyatoslav Ryhel

drivers/gpu/drm/bridge/ssd2825.c line 356

Quoted 13 lines
drivers/gpu/drm/bridge/ssd2825.c new file +13 -0
+static ssize_t ssd2825_dsi_host_transfer(struct mipi_dsi_host *host,
+                                      const struct mipi_dsi_msg *msg)
+{
+     struct ssd2825_priv *priv = dsi_host_to_ssd2825(host);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     u8 buf = *(u8 *)msg->tx_buf;
+     u16 config;
+     int ret;
+
+     if (!priv->enabled) {
+             dev_err(priv->dev, "Bridge is not enabled\n");
+             return -ENODEV;
+     }

Transfers can and should happen even when the bridge is disabled. The hardware might not permit that, but you'll need to elaborate in the comment about why.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

This ensures that hw was configured properly in pre_enable and since pre_enable is void it will not return any errors if it fails.

There's no relationship between the bridge pre_enable and enable hooks, and the MIPI-DSI host transfer one. It's perfectly valid to call transfer if the bridge is detached or disabled.

That is twisted logic, but ok, fine, I don't care.

It's not twisted. It's perfectly valid for a panel to read its revision at probe time, before it registers, for example.

It would happen before the panel is enabled, and before the bridge is enabled.

Quoted 238 lines
Quoted 60 lines
Quoted 60 lines
Quoted 59 lines
Quoted 47 lines
drivers/gpu/drm/bridge/ssd2825.c new file +47 -0
+     if (msg->rx_len) {
+             dev_warn(priv->dev, "MIPI rx is not supported\n");
+             return -EOPNOTSUPP;
+     }
+
+     guard(mutex)(&priv->mlock);
+
+     ret = ssd2825_read_reg(priv, SSD2825_CONFIGURATION_REG, &config);
+     if (ret)
+             return ret;
+
+     switch (msg->type) {
+     case MIPI_DSI_DCS_SHORT_WRITE:
+     case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+     case MIPI_DSI_DCS_LONG_WRITE:
+             config |= SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
+     case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
+     case MIPI_DSI_GENERIC_LONG_WRITE:
+             config &= ~SSD2825_CONF_REG_DCS;
+             break;
+     case MIPI_DSI_DCS_READ:
+     case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+     case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+     default:
+             return 0;
+     }
+
+     ret = ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0x0000);
+     if (ret)
+             return ret;
+
+     ret = ssd2825_write_dsi(priv, msg->tx_buf, msg->tx_len);
+     if (ret)
+             return ret;
+
+     if (buf == MIPI_DCS_SET_DISPLAY_ON) {
+             /*
+              * NOTE! This is here since it cannot be called in bridge enable because
+              * bridge pre enable and bridge enable have no gap in between.

drivers/gpu/drm/bridge/ssd2825.c line 414

Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+              *
+              * Existing framework bridge-panel seq is:
+              *      panel_prepare > bridge_pre_enable > bridge_enable > panel_enable
+              *
+              * Using prepare_prev_first was tested, but it switches seq like this:
+              *      bridge_pre_enable > panel_prepare > bridge_enable > panel_enable
+              *
+              * This will not work since panel hw MUST be prepared before bridge is
+              * configured. Correct seq should be:
+              *      panel_prepare > bridge_pre_enable > panel_enable > bridge_enable

Where is that requirement coming from?

Quoted 6 lines
Quoted 3 lines

This is how my device's (LG P895) bridge-panel combo works. Panel hw must be enabled before bridge, then bridge hw, then panel can send init sequence and then bridge must complete configuration.

Do you have a documentation for that DSI device?

No

Quoted 30 lines

DSI devices typically come with requirement of the power states of the lanes, that's what you want to discuss here. How we can model that in software is a discussion we need to have once we've identified what the hardware needs exactly.

Quoted 25 lines
Quoted 10 lines

panel prepare is documented as:

The .prepare() function is typically called before the display controller starts to transmit video data.

And video data transmission for bridges only happen at bridge_enable time.

So, from an API PoV, all the sequences above are correct.

There is no way ATM for this bridge to complete configuration, there either should be a way to swap panel_enable and bridge_enable or there should be added an additional operation like bridge_post_enable or smth like that for cases like here when bridge has to complete configuration after panel init seq is sent.

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/bridge/ssd2825.c new file +7 -0
+              * Last two functions should be swapped related to existing framework.
+              * I am not aware about method which allows that.
+              *
+              * Once there will be such method/flag, code below should be moved into
+              * bridge_enable since it is basically a bridge configuration completing
+              * after initial panel DSI sequence is completed.
+              */
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

If there's anything to fix, we should do it before introducing that driver.

I just want to have a bridge my device uses to be supported by mainline linux. I have no intention to touch any part of DRM framework and cause instabilities, maintainers rage and hate.

And I just want all drivers to behave consistently.

Ye, sure.

Quoted 126 lines
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/bridge/ssd2825.c new file +10 -0
+static void ssd2825_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+                                          struct drm_atomic_state *state)
+{
+     struct ssd2825_priv *priv = bridge_to_ssd2825(bridge);
+     struct mipi_dsi_device *dsi_dev = priv->output.dev;
+     const struct drm_crtc_state *crtc_state;
+     const struct drm_display_mode *mode;
+     struct drm_connector *connector;
+     struct drm_crtc *crtc;
+     u32 input_bus_flags = bridge->timings->input_bus_flags;
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 545

Quoted 6 lines
drivers/gpu/drm/bridge/ssd2825.c new file +6 -0
+     u16 flags = 0, config;
+     u8 pixel_format;
+     int ret;
+
+     if (priv->enabled)
+             return;

What is this guarding against?

Quoted 1 line

blocks repeating ssd2825_bridge_atomic_pre_enable calls

Which happens in which situation?

Quoted 97 lines
Quoted 88 lines
Quoted 88 lines
drivers/gpu/drm/bridge/ssd2825.c new file +88 -0
+     /* Power Sequence */
+     ret = clk_prepare_enable(priv->tx_clk);
+     if (ret)
+             dev_err(priv->dev, "error enabling tx_clk (%d)\n", ret);
+
+     ret = regulator_bulk_enable(ARRAY_SIZE(ssd2825_supplies), priv->supplies);
+     if (ret)
+             dev_err(priv->dev, "error enabling regulators (%d)\n", ret);
+
+     usleep_range(1000, 2000);
+
+     ssd2825_hw_reset(priv);
+
+     /* Perform SW reset */
+     ssd2825_write_reg(priv, SSD2825_OPERATION_CTRL_REG, 0x0100);
+
+     /* Set pixel format */
+     switch (dsi_dev->format) {
+     case MIPI_DSI_FMT_RGB565:
+             pixel_format = 0x00;
+             break;
+     case MIPI_DSI_FMT_RGB666_PACKED:
+             pixel_format = 0x01;
+             break;
+     case MIPI_DSI_FMT_RGB666:
+             pixel_format = 0x02;
+             break;
+     case MIPI_DSI_FMT_RGB888:
+     default:
+             pixel_format = 0x03;
+             break;
+     }
+
+     connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
+     crtc = drm_atomic_get_new_connector_state(state, connector)->crtc;
+     crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+     mode = &crtc_state->adjusted_mode;
+
+     /* Set panel timings */
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_1,
+                       ((mode->vtotal - mode->vsync_end) << 8) |
+                       (mode->htotal - mode->hsync_end));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_2,
+                       ((mode->vtotal - mode->vsync_start) << 8) |
+                       (mode->htotal - mode->hsync_start));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_3,
+                       ((mode->vsync_start - mode->vdisplay) << 8) |
+                       (mode->hsync_start - mode->hdisplay));
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_4, mode->hdisplay);
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_5, mode->vdisplay);
+
+     if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+             flags |= SSD2825_HSYNC_HIGH;
+
+     if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+             flags |= SSD2825_VSYNC_HIGH;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_VIDEO)
+             flags |= SSD2825_NON_BURST_EV;
+
+     if (input_bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE)
+             flags |= SSD2825_PCKL_HIGH;
+
+     ssd2825_write_reg(priv, SSD2825_RGB_INTERFACE_CTRL_REG_6, flags | pixel_format);
+     ssd2825_write_reg(priv, SSD2825_LANE_CONFIGURATION_REG, dsi_dev->lanes - 1);
+     ssd2825_write_reg(priv, SSD2825_TEST_REG, 0x0004);
+
+     /* Call PLL configuration */
+     ssd2825_setup_pll(priv, mode);
+
+     usleep_range(10000, 11000);
+
+     config = SSD2825_CONF_REG_HS | SSD2825_CONF_REG_CKE | SSD2825_CONF_REG_DCS |
+              SSD2825_CONF_REG_ECD | SSD2825_CONF_REG_EOT;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_LPM)
+             config &= ~SSD2825_CONF_REG_HS;
+
+     if (dsi_dev->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET)
+             config &= ~SSD2825_CONF_REG_EOT;
+
+     /* Initial DSI configuration register set */
+     ssd2825_write_reg(priv, SSD2825_CONFIGURATION_REG, config);
+     ssd2825_write_reg(priv, SSD2825_VC_CTRL_REG, 0);
+
+     priv->enabled = true;
+}
+
Quoted 8 lines

drivers/gpu/drm/bridge/ssd2825.c line 639

Quoted 5 lines
drivers/gpu/drm/bridge/ssd2825.c new file +5 -0
+static void ssd2825_bridge_atomic_enable(struct drm_bridge *bridge,
+                                      struct drm_atomic_state *state)
+{
+     /* placeholder */
+}

That doesn't work with any bridge or panel that doesn't require any DCS command to power up, unfortunately.

Quoted 2 lines

Yes that is a flaw unfortunately, if you have suggestions of fixing this just tell me.

Untangle pre_enable and enable from transfer, and in enable actually enable the bridge, and it will work just fine.

Quoted 7 lines
Quoted 4 lines

No it will not, I have tried and panel fails cause panel hw is init in pre-enable and init sequence is sent in enable, which is expected logic. Yet bridge cannot complete configuration because panel enable function is called AFTER bridge enable.

Then I guess we're at a dead-end now, aren't we?

I tried to address issues that you have pointed to here in v7 version of this patch set.
https://lore.kernel.org/lkml/[email protected]/

Quoted 1 line

Maxime

#9 lore raw
In reply to Svyatoslav Ryhel

пн, 26 трав. 2025 р. о 14:44 Svyatoslav Ryhel <[email protected]> пише:

Quoted 52 lines

Solomon SSD2825 is a RGB to MIPI DSI bridge used in LG Optimus 4D P880 and LG Optimus Vu P895

---
Changes on switching from v5 to v6:
- set correct module name in Kconfig help
- return error if spi sync failed for reading

Changes on switching from v4 to v5:
- rebased on top of drm-misc-next with adjustments to fit

Changes on switching from v3 to v4:
- no changes, resend

Changes on switching from v2 to v3:
- added mutex guard
- configuration register flags parametrized using panel flags
- removed unneded debug messages
- removed unimplemented modes checks
- added check for maximum pixel row length
- use types header
- remove ssd2825_to_ns
- shift bridge setup into atomic pre-enable
- cleaned default values of hzd and hpd

Changes on switching from v1 to v2:
- added description for clock
- removed clock-names
- added boundries for hs-zero-delay-ns and hs-prep-delay-ns
- added mutex lock for host transfers
- converted to atomic ops
- get drm_display_mode mode with atomic helpers
- parameterized INTERFACE_CTRL_REG_6 configuration
- added video mode validation and fixup
- removed clock name
- switched to devm_regulator_bulk_get_const
- added default timings
---

Svyatoslav Ryhel (2):
dt-bindings: display: bridge: Document Solomon SSD2825
drm: bridge: Add support for Solomon SSD2825 RGB/DSI bridge

 .../display/bridge/solomon,ssd2825.yaml       | 141 +++
 drivers/gpu/drm/bridge/Kconfig                |  13 +
 drivers/gpu/drm/bridge/Makefile               |   1 +
 drivers/gpu/drm/bridge/ssd2825.c              | 814 ++++++++++++++++++
 4 files changed, 969 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/solomon,ssd2825.yaml
 create mode 100644 drivers/gpu/drm/bridge/ssd2825.c
Quoted 3 lines

--
2.48.1

These patches had no activity/feedback from DRM maintainers for a while, so, in case they got lost in the depths of email box, this is a friendly reminder that they are still relevant and I would like them to move on.

Best regards,
Svyatoslav R.