Skip to contentSkip to conversation

drm: State readout for the i.MX8MN display pipeline

RFC PATCH New Dario Binacchi 1 participant 7 messages Dec 2

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

v2 cover drm: State readout for the i.MX8MN display pipeline

This series implements the hardware state readout [1] for the display pipeline of the i.MX8MN (LCDIF, Samsung DSIM, Synaptics R63353 panel), so that the splash screen shown by the bootloader stays on, without a modeset, until a client draws.

The first patch adds the hook a panel needs to acquire its resources when it is found enabled, without being reset and initialized again. It is a proposal for the panel takeover left open by the last patch of [1].

The series is based on [1] and on the panel fixes [2]. It needs [3] to keep the power domains of the display on, and a bootloader that sets up the pipeline as Linux does [4].

Tested on i.MX8MN (BSH SMM S2 PRO).

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/[email protected]
[4] https://lore.kernel.org/r/[email protected]

Changes in v2:
- Rename the hook to sro_enable_resources
- Call the hook from the panel bridge install state added by the state readout series
- Set the atomic_sro_install_state hook of the mode config helpers
- Use drm_atomic_helper_sro_find_refresh_from_clk() for the mode clock
- Use drm_atomic_helper_sro_create_gem_dma_object() for the framebuffer read out
- Use drm_atomic_helper_plane_compare_state()
- Update the atomic_sro_install_state hook to its new prototype
- Save the mode read out from the hardware, as no mode_set is run and the PLL is configured from it when the bridge is enabled again
- Rename the hook to sro_enable_resources
- Rebase on v10 of the state readout series
- Drop "drm/bridge: Add atomic_sro_install_state hook", part of the state readout series
- Drop "drm/mxsfb: Switch to drm_mode_config_create_initial_state()", merged in drm-misc-next

Dario Binacchi (6):
drm/panel: Add sro_enable_resources hook drm/mxsfb: Use the bridge connector drm/mxsfb: Stop the controller in hw_reset drm/mxsfb: Implement hw state readout drm/bridge: samsung-dsim: Implement hw state readout drm/panel: synaptics-r63353: Support hw state readout

 drivers/gpu/drm/bridge/samsung-dsim.c         | 130 +++++-
 drivers/gpu/drm/drm_panel.c                   |   8 +
 drivers/gpu/drm/mxsfb/Kconfig                 |   2 +
 drivers/gpu/drm/mxsfb/mxsfb_drv.c             |  26 +-
 drivers/gpu/drm/mxsfb/mxsfb_kms.c             | 369 +++++++++++++++++-
 drivers/gpu/drm/mxsfb/mxsfb_regs.h            |   3 +
 .../gpu/drm/panel/panel-synaptics-r63353.c    |  33 +-
 include/drm/drm_panel.h                       |  10 +
 8 files changed, 552 insertions(+), 29 deletions(-)

---
base-commit: d323a163981f3e3b1b8c40bd2aa0c416d0d9c7d8
branch: drm-sro-rfc-v2-send

Signature · 1 line
2.43.0
#1 lore raw

RFC PATCH v2 1/6 drm/panel: Add sro_enable_resources hook

When a panel is read out as active, the panel bridge prepares and enables it, so that its driver holds the resources it releases when the panel is unprepared. Doing so also resets and initializes a panel that is already displaying an image.

Add the sro_enable_resources hook, for a panel driver to acquire its resources without touching the hardware. On success the panel is marked as prepared and enabled.

---

Changes in v2:
- Rename the hook to sro_enable_resources
- Call the hook from the panel bridge install state added by the state readout series

 drivers/gpu/drm/drm_panel.c |  8 ++++++++
 include/drm/drm_panel.h     | 10 ++++++++++
 2 files changed, 18 insertions(+)
drivers/gpu/drm/drm_panel.c +8 -0
index ad521b6894ca..0286934de676 100644
@@ -360,6 +360,14 @@ panel_bridge_install_state(struct drm_bridge *bridge,
 {
 	struct drm_panel *panel = drm_bridge_to_panel(bridge);
 
+	/* Take over the running panel without reprogramming it */
+	if (panel->funcs && panel->funcs->sro_enable_resources &&
+	    !panel->funcs->sro_enable_resources(panel)) {
+		panel->prepared = true;
+		panel->enabled = true;
+		return;
+	}
+
 	if (!panel->prepared)
 		drm_panel_prepare(panel);
 
include/drm/drm_panel.h +10 -0
index d9059a9606fc..f64b4771a54a 100644
@@ -136,6 +136,16 @@ struct drm_panel_funcs {
 	 * Allows panels to create panels-specific debugfs files.
 	 */
 	void (*debugfs_init)(struct drm_panel *panel, struct dentry *root);
+
+	/**
+	 * @sro_enable_resources:
+	 *
+	 * Acquire the resources of a panel found enabled when the hardware
+	 * state was read out, without touching the hardware.
+	 *
+	 * This function is optional.
+	 */
+	int (*sro_enable_resources)(struct drm_panel *panel);
 };
 
 struct drm_panel_follower_funcs {
Signature · 1 line
2.43.0
#2 lore raw

RFC PATCH v2 2/6 drm/mxsfb: Use the bridge connector

In reply to Dario Binacchi

The state readout of a connector is implemented by the bridge connector helper. Use it, as the LCDIF driver already does, in place of the connector each bridge creates on its own.

---
The bridges used with this driver have not been checked one by one for DRM_BRIDGE_ATTACH_NO_CONNECTOR support.

(no changes since v1)

 drivers/gpu/drm/mxsfb/Kconfig     |  2 ++
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)
drivers/gpu/drm/mxsfb/Kconfig +2 -0
index 31db7a824a93..78e983b71ec0 100644
@@ -15,6 +15,8 @@ config DRM_MXSFB
 	select DRM_GEM_DMA_HELPER
 	select DRM_PANEL
 	select DRM_PANEL_BRIDGE
+	select DRM_DISPLAY_HELPER
+	select DRM_BRIDGE_CONNECTOR
 	help
 	  Choose this option if you have an LCDIF or eLCDIF LCD controller.
 	  Those devices are found in various i.MX SoC (including i.MX23,
drivers/gpu/drm/mxsfb/mxsfb_drv.c +10 -10
index 30eefcc5cfdd..43d5590b1829 100644
@@ -23,6 +23,7 @@
 #include <drm/clients/drm_client_setup.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
 #include <drm/drm_connector.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_fbdev_dma.h>
@@ -118,7 +119,7 @@ static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = {
 static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
 {
 	struct drm_device *drm = mxsfb->drm;
-	struct drm_connector_list_iter iter;
+	struct drm_connector *connector;
 	struct drm_panel *panel;
 	struct drm_bridge *bridge;
 	int ret;
@@ -138,19 +139,18 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
 	if (!bridge)
 		return -ENODEV;
 
-	ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL, 0);
+	ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL,
+				DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
 		return dev_err_probe(drm->dev, ret, "Failed to attach bridge\n");
 
-	mxsfb->bridge = bridge;
+	connector = drm_bridge_connector_init(drm, &mxsfb->encoder);
+	if (IS_ERR(connector))
+		return dev_err_probe(drm->dev, PTR_ERR(connector),
+				     "Failed to init bridge connector\n");
 
-	/*
-	 * Get hold of the connector. This is a bit of a hack, until the bridge
-	 * API gives us bus flags and formats.
-	 */
-	drm_connector_list_iter_begin(drm, &iter);
-	mxsfb->connector = drm_connector_list_iter_next(&iter);
-	drm_connector_list_iter_end(&iter);
+	mxsfb->bridge = bridge;
+	mxsfb->connector = connector;
 
 	return 0;
 }
Signature · 1 line
2.43.0
#3 lore raw

RFC PATCH v2 3/6 drm/mxsfb: Stop the controller in hw_reset

In reply to Dario Binacchi

When the hardware state can't be read out, a controller left running by the bootloader is reprogrammed while running on the first enable. Stop it in the hw_reset hook.

---

(no changes since v1)

 drivers/gpu/drm/mxsfb/mxsfb_drv.c |  2 ++
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 33 ++++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +2 -0
index 43d5590b1829..f0d4739f860f 100644
@@ -31,6 +31,7 @@
 #include <drm/drm_gem_dma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_mode_config.h>
+#include <drm/drm_modeset_helper.h>
 #include <drm/drm_module.h>
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
@@ -110,6 +111,7 @@ static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = {
 	.fb_create		= mxsfb_fb_create,
 	.atomic_check		= drm_atomic_helper_check,
 	.atomic_commit		= drm_atomic_helper_commit,
+	.hw_reset		= drm_mode_config_helper_hw_reset,
 };
 
 static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = {
drivers/gpu/drm/mxsfb/mxsfb_kms.c +32 -1
index bbc2a2df9f16..96cd80c6e76c 100644
@@ -35,6 +35,18 @@
 /* 1 second delay should be plenty of time for block reset */
 #define RESET_TIMEOUT		1000000
 
+static void mxsfb_hw_get(struct mxsfb_drm_private *mxsfb)
+{
+	pm_runtime_get_sync(mxsfb->drm->dev);
+	mxsfb_enable_axi_clk(mxsfb);
+}
+
+static void mxsfb_hw_put(struct mxsfb_drm_private *mxsfb)
+{
+	mxsfb_disable_axi_clk(mxsfb);
+	pm_runtime_put_sync(mxsfb->drm->dev);
+}
+
 /* -----------------------------------------------------------------------------
  * CRTC
  */
@@ -205,7 +217,7 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)
 	writel(CTRL_RUN, mxsfb->base + LCDC_CTRL + REG_SET);
 }
 
-static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb)
+static void mxsfb_stop_controller(struct mxsfb_drm_private *mxsfb)
 {
 	u32 reg;
 
@@ -221,6 +233,11 @@ static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb)
 	reg = readl(mxsfb->base + LCDC_VDCTRL4);
 	reg &= ~VDCTRL4_SYNC_SIGNALS_ON;
 	writel(reg, mxsfb->base + LCDC_VDCTRL4);
+}
+
+static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb)
+{
+	mxsfb_stop_controller(mxsfb);
 
 	clk_disable_unprepare(mxsfb->clk);
 	if (mxsfb->clk_disp_axi)
@@ -433,6 +450,19 @@ static void mxsfb_crtc_atomic_disable(struct drm_crtc *crtc,
 	pm_runtime_put_sync(drm->dev);
 }
 
+static void mxsfb_crtc_hw_reset(struct drm_crtc *crtc)
+{
+	struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(crtc->dev);
+
+	mxsfb_hw_get(mxsfb);
+
+	/* The bootloader may have left the controller running */
+	if (readl(mxsfb->base + LCDC_CTRL) & CTRL_RUN)
+		mxsfb_stop_controller(mxsfb);
+
+	mxsfb_hw_put(mxsfb);
+}
+
 static int mxsfb_crtc_enable_vblank(struct drm_crtc *crtc)
 {
 	struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(crtc->dev);
@@ -493,6 +523,7 @@ static const struct drm_crtc_helper_funcs mxsfb_crtc_helper_funcs = {
 	.atomic_flush = mxsfb_crtc_atomic_flush,
 	.atomic_enable = mxsfb_crtc_atomic_enable,
 	.atomic_disable = mxsfb_crtc_atomic_disable,
+	.hw_reset = mxsfb_crtc_hw_reset,
 };
 
 static const struct drm_crtc_funcs mxsfb_crtc_funcs = {
Signature · 1 line
2.43.0
#4 lore raw

RFC PATCH v2 4/6 drm/mxsfb: Implement hw state readout

In reply to Dario Binacchi

Read out the state of the CRTC and of the planes from the hardware, so that the first modeset can be skipped when the bootloader has already set up the display.

---

Changes in v2:
- Set the atomic_sro_install_state hook of the mode config helpers
- Use drm_atomic_helper_sro_find_refresh_from_clk() for the mode clock
- Use drm_atomic_helper_sro_create_gem_dma_object() for the framebuffer read out
- Use drm_atomic_helper_plane_compare_state()

 drivers/gpu/drm/mxsfb/mxsfb_drv.c  |   4 +
 drivers/gpu/drm/mxsfb/mxsfb_kms.c  | 336 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/mxsfb/mxsfb_regs.h |   3 +
 3 files changed, 339 insertions(+), 4 deletions(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +4 -0
index f0d4739f860f..0225b8823c11 100644
@@ -22,6 +22,7 @@
 
 #include <drm/clients/drm_client_setup.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_atomic_state_readout_helper.h>
 #include <drm/drm_bridge.h>
 #include <drm/drm_bridge_connector.h>
 #include <drm/drm_connector.h>
@@ -112,10 +113,13 @@ static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = {
 	.atomic_check		= drm_atomic_helper_check,
 	.atomic_commit		= drm_atomic_helper_commit,
 	.hw_reset		= drm_mode_config_helper_hw_reset,
+	.atomic_sro_readout_state = drm_atomic_helper_sro_readout_state,
 };
 
 static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = {
 	.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
+	.atomic_sro_build_state = drm_atomic_helper_sro_build_state,
+	.atomic_sro_install_state = drm_atomic_helper_sro_install_state,
 };
 
 static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
drivers/gpu/drm/mxsfb/mxsfb_kms.c +332 -4

420 lines not on this page · raw message

drivers/gpu/drm/mxsfb/mxsfb_regs.h +3 -0
index cf813a1da1d7..cfbd13a64388 100644
@@ -50,6 +50,7 @@
 #define CTRL_WORD_LENGTH_8		(1 << 8)
 #define CTRL_WORD_LENGTH_18		(2 << 8)
 #define CTRL_WORD_LENGTH_24		(3 << 8)
+#define CTRL_WORD_LENGTH_MASK		(0x3 << 8)
 #define CTRL_MASTER			BIT(5)
 #define CTRL_DF16			BIT(3)
 #define CTRL_DF18			BIT(2)
@@ -115,11 +116,13 @@
 #define AS_CTRL_FORMAT_ARGB1555		(0x8 << 4)
 #define AS_CTRL_FORMAT_RGB888		(0x4 << 4)
 #define AS_CTRL_FORMAT_ARGB8888		(0x0 << 4)
+#define AS_CTRL_FORMAT_MASK		(0xf << 4)
 #define AS_CTRL_ENABLE_COLORKEY		BIT(3)
 #define AS_CTRL_ALPHA_CTRL_ROP		(3 << 1)
 #define AS_CTRL_ALPHA_CTRL_MULTIPLY	(2 << 1)
 #define AS_CTRL_ALPHA_CTRL_OVERRIDE	(1 << 1)
 #define AS_CTRL_ALPHA_CTRL_EMBEDDED	(0 << 1)
+#define AS_CTRL_ALPHA_CTRL_MASK		(3 << 1)
 #define AS_CTRL_AS_ENABLE		BIT(0)
 
 #define MXSFB_MIN_XRES			120
Signature · 1 line
2.43.0
#5 lore raw

RFC PATCH v2 5/6 drm/bridge: samsung-dsim: Implement hw state readout

In reply to Dario Binacchi

Read out the state of the bridge from the hardware, so that a video stream left running by the bootloader is taken over without initializing the bridge again.

---

Changes in v2:
- Update the atomic_sro_install_state hook to its new prototype
- Save the mode read out from the hardware, as no mode_set is run and the PLL is configured from it when the bridge is enabled again

 drivers/gpu/drm/bridge/samsung-dsim.c | 130 +++++++++++++++++++++++---
 1 file changed, 117 insertions(+), 13 deletions(-)
drivers/gpu/drm/bridge/samsung-dsim.c +117 -13
index 480e568dd2c9..9b950e2e779d 100644
@@ -20,11 +20,15 @@
 #include <linux/of.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/units.h>
 
 #include <video/mipi_display.h>
 
 #include <drm/bridge/samsung-dsim.h>
+#include <drm/drm_atomic_state_readout.h>
+#include <drm/drm_atomic_state_readout_helper.h>
+#include <drm/drm_connector.h>
 #include <drm/drm_print.h>
 
 /* returns true iff both arguments logically differs */
@@ -1562,6 +1566,17 @@ static int samsung_dsim_transfer(struct samsung_dsim *dsi,
 	return xfer->result;
 }
 
+static void samsung_dsim_unmask_irqs(struct samsung_dsim *dsi)
+{
+	unsigned long mask = ~(DSIM_INT_RX_DONE |
+			       DSIM_INT_SFR_FIFO_EMPTY |
+			       DSIM_INT_SFR_HDR_FIFO_EMPTY |
+			       DSIM_INT_RX_ECC_ERR |
+			       DSIM_INT_SW_RST_RELEASE);
+
+	samsung_dsim_write(dsi, DSIM_INTMSK_REG, mask);
+}
+
 static irqreturn_t samsung_dsim_irq(int irq, void *dev_id)
 {
 	struct samsung_dsim *dsi = dev_id;
@@ -1578,12 +1593,7 @@ static irqreturn_t samsung_dsim_irq(int irq, void *dev_id)
 	samsung_dsim_write(dsi, DSIM_INTSRC_REG, status);
 
 	if (status & DSIM_INT_SW_RST_RELEASE) {
-		unsigned long mask = ~(DSIM_INT_RX_DONE |
-				       DSIM_INT_SFR_FIFO_EMPTY |
-				       DSIM_INT_SFR_HDR_FIFO_EMPTY |
-				       DSIM_INT_RX_ECC_ERR |
-				       DSIM_INT_SW_RST_RELEASE);
-		samsung_dsim_write(dsi, DSIM_INTMSK_REG, mask);
+		samsung_dsim_unmask_irqs(dsi);
 		complete(&dsi->completed);
 		return IRQ_HANDLED;
 	}
@@ -1758,14 +1768,9 @@ samsung_dsim_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 	return input_fmts;
 }
 
-static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
-				     struct drm_bridge_state *bridge_state,
-				     struct drm_crtc_state *crtc_state,
-				     struct drm_connector_state *conn_state)
+static void samsung_dsim_fixup_mode(struct samsung_dsim *dsi,
+				    struct drm_display_mode *adjusted_mode)
 {
-	struct samsung_dsim *dsi = bridge_to_dsi(bridge);
-	struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
-
 	/*
 	 * The i.MX8M Mini/Nano glue logic between LCDIF and DSIM
 	 * inverts HS/VS/DE sync signals polarity, therefore, while
@@ -1808,6 +1813,16 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
 			adjusted_mode->htotal      += remainder;
 		}
 	}
+}
+
+static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
+				     struct drm_bridge_state *bridge_state,
+				     struct drm_crtc_state *crtc_state,
+				     struct drm_connector_state *conn_state)
+{
+	struct samsung_dsim *dsi = bridge_to_dsi(bridge);
+
+	samsung_dsim_fixup_mode(dsi, &crtc_state->adjusted_mode);
 
 	return 0;
 }
@@ -1831,6 +1846,92 @@ static int samsung_dsim_attach(struct drm_bridge *bridge,
 				 flags);
 }
 
+static bool samsung_dsim_hw_is_running(struct samsung_dsim *dsi)
+{
+	const struct samsung_dsim_driver_data *driver_data = dsi->driver_data;
+	u32 reg;
+
+	if (!(samsung_dsim_read(dsi, DSIM_PLLCTRL_REG) & DSIM_PLL_EN))
+		return false;
+
+	if (driver_data->has_legacy_status_reg)
+		reg = samsung_dsim_read(dsi, DSIM_STATUS_REG);
+	else
+		reg = samsung_dsim_read(dsi, DSIM_LINK_STATUS_REG);
+
+	if (!(reg & BIT(driver_data->pll_stable_bit)))
+		return false;
+
+	return samsung_dsim_read(dsi, DSIM_MDRESOL_REG) & DSIM_MAIN_STAND_BY;
+}
+
+static int samsung_dsim_readout_state(struct drm_bridge *bridge,
+				      struct drm_atomic_sro_state *state,
+				      struct drm_bridge_state *bridge_state,
+				      struct drm_crtc_state *crtc_state,
+				      struct drm_connector_state *conn_state)
+{
+	struct samsung_dsim *dsi = bridge_to_dsi(bridge);
+	struct drm_display_info *info = &conn_state->connector->display_info;
+	u32 format = MEDIA_BUS_FMT_FIXED;
+	bool running;
+	int ret;
+
+	ret = pm_runtime_resume_and_get(dsi->dev);
+	if (ret < 0)
+		return ret;
+
+	running = samsung_dsim_hw_is_running(dsi);
+	pm_runtime_put(dsi->dev);
+
+	/* The pipeline is active but the video stream is not */
+	if (!running)
+		return -EINVAL;
+
+	/* Rebuild the bus configuration the atomic helpers negotiate */
+	if (info->num_bus_formats)
+		format = info->bus_formats[0];
+
+	bridge_state->output_bus_cfg.format = format;
+	bridge_state->output_bus_cfg.flags = info->bus_flags;
+
+	if (!samsung_dsim_pixel_output_fmt_supported(format))
+		format = MEDIA_BUS_FMT_RGB888_1X24;
+
+	bridge_state->input_bus_cfg.format = format;
+	bridge_state->input_bus_cfg.flags = info->bus_flags;
+
+	/* The mode fixups done in atomic_check can't be read back */
+	samsung_dsim_fixup_mode(dsi, &crtc_state->adjusted_mode);
+
+	return 0;
+}
+
+static void samsung_dsim_install_state(struct drm_bridge *bridge,
+				       struct drm_bridge_state *bridge_state,
+				       struct drm_crtc_state *crtc_state,
+				       struct drm_connector_state *conn_state)
+{
+	struct samsung_dsim *dsi = bridge_to_dsi(bridge);
+
+	/* No mode_set is run for a state read out from the hardware */
+	drm_mode_copy(&dsi->mode, &crtc_state->adjusted_mode);
+
+	/* Take the reference samsung_dsim_atomic_pre_enable() would have */
+	if (pm_runtime_resume_and_get(dsi->dev) < 0) {
+		dev_err(dsi->dev, "failed to enable DSI device.\n");
+		return;
+	}
+
+	samsung_dsim_write(dsi, DSIM_INTSRC_REG,
+			   samsung_dsim_read(dsi, DSIM_INTSRC_REG));
+	samsung_dsim_unmask_irqs(dsi);
+	samsung_dsim_enable_irq(dsi);
+
+	dsi->state |= DSIM_STATE_ENABLED | DSIM_STATE_INITIALIZED |
+		      DSIM_STATE_VIDOUT_AVAILABLE;
+}
+
 static const struct drm_bridge_funcs samsung_dsim_bridge_funcs = {
 	.atomic_duplicate_state		= drm_atomic_helper_bridge_duplicate_state,
 	.atomic_destroy_state		= drm_atomic_helper_bridge_destroy_state,
@@ -1843,6 +1944,9 @@ static const struct drm_bridge_funcs samsung_dsim_bridge_funcs = {
 	.atomic_post_disable		= samsung_dsim_atomic_post_disable,
 	.mode_set			= samsung_dsim_mode_set,
 	.attach				= samsung_dsim_attach,
+	.atomic_sro_readout_state	= samsung_dsim_readout_state,
+	.atomic_sro_install_state	= samsung_dsim_install_state,
+	.atomic_sro_compare_state	= drm_atomic_helper_bridge_compare_state,
 };
 
 static irqreturn_t samsung_dsim_te_irq_handler(int irq, void *dev_id)
Signature · 1 line
2.43.0
#6 lore raw

RFC PATCH v2 6/6 drm/panel: synaptics-r63353: Support hw state readout

In reply to Dario Binacchi

Take over a panel left enabled by the bootloader without turning it off. The reset line is no longer asserted at probe, since that would turn the panel off, but when the panel is powered on.

---

Changes in v2:
- Rename the hook to sro_enable_resources

 .../gpu/drm/panel/panel-synaptics-r63353.c    | 33 ++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-synaptics-r63353.c +32 -1
index d7f2499c961e..7db770dee73d 100644
@@ -72,6 +72,13 @@ static int r63353_panel_power_on(struct r63353_panel *rpanel)
 	struct device *dev = &dsi->dev;
 	int ret;
 
+	/* The bootloader may have left the panel out of reset */
+	ret = gpiod_direction_output(rpanel->reset_gpio, 0);
+	if (ret) {
+		dev_err(dev, "Failed to assert RESET GPIO (%d)\n", ret);
+		return ret;
+	}
+
 	ret = regulator_enable(rpanel->avdd);
 	if (ret) {
 		dev_err(dev, "Failed to enable avdd regulator (%d)\n", ret);
@@ -188,6 +195,28 @@ static int r63353_panel_unprepare(struct drm_panel *panel)
 	return 0;
 }
 
+static int r63353_panel_sro_enable_resources(struct drm_panel *panel)
+{
+	struct r63353_panel *rpanel = to_r63353_panel(panel);
+	int ret;
+
+	/* A panel held in reset can't be displaying anything */
+	if (!gpiod_get_value_cansleep(rpanel->reset_gpio))
+		return -ENODEV;
+
+	ret = regulator_enable(rpanel->avdd);
+	if (ret)
+		return ret;
+
+	ret = regulator_enable(rpanel->dvdd);
+	if (ret) {
+		regulator_disable(rpanel->avdd);
+		return ret;
+	}
+
+	return 0;
+}
+
 static const struct drm_display_mode sharp_ls068b3sx02_timing = {
 	.clock = 63861,
 	.hdisplay = 640,
@@ -228,6 +257,7 @@ static const struct drm_panel_funcs r63353_panel_funcs = {
 	.prepare = r63353_panel_prepare,
 	.unprepare = r63353_panel_unprepare,
 	.get_modes = r63353_panel_get_modes,
+	.sro_enable_resources = r63353_panel_sro_enable_resources,
 };
 
 static int r63353_panel_probe(struct mipi_dsi_device *dsi)
@@ -261,7 +291,8 @@ static int r63353_panel_probe(struct mipi_dsi_device *dsi)
 	if (IS_ERR(panel->avdd))
 		return PTR_ERR(panel->avdd);
 
-	panel->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+	/* The line is driven when the panel is powered on */
+	panel->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS);
 	if (IS_ERR(panel->reset_gpio)) {
 		dev_err(dev, "failed to get RESET GPIO\n");
 		return PTR_ERR(panel->reset_gpio);
Signature · 1 line
2.43.0