linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel
@ 2020-11-24 12:44 Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 01/80] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Tomi Valkeinen
                   ` (80 more replies)
  0 siblings, 81 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Hi,

v4 of the omapdrm DSI series. Link to v3:

https://www.spinics.net/lists/linux-omap/msg157082.html

There are a lot of changes since v3, but most of them should be in new
patches on top. The main problem has been video mode panels, which are
still not quite working with this series. However, I have pinpointed the
issues quite well (I think), and I have a few small hacks which gets a
video mode panel working (the single one I have).

The problem is with the sequence the dsi host and the panel are
initialized, and I did not figure out how to solve that without adding a
new bridge callback (post_enable). However, the issue could also be
panel specific, omap dsi driver bug, or panel driver bug. This needs
more study and work, but as we don't have any video mode users in
upstream, I think the work can be done on top of this series.

This series, and the hacks (along with a few other hacks) can be found
from:

git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux.git 5.11/dsi

Tested with OMAP4 SDP (command mode panel) and OMAP5 uEVM with a custom
video mode panel setup (with a broken cable which only works in certain
position and when the planets are aligned).

Changes in v4:
- Resolved the comments received in v3, and added the tags

- Lots of new patches continuing the cleanup work. Most of these do not
  help with the video mode as such, but as the issues have been very
  difficult to debug, I've been doing cleanups along the way so that I
  can find the problems more easily.

- Dropped ULPS. Complex feature, doesn't work, would give little
  benefit.

 Tomi

Sebastian Reichel (49):
  Revert "drm/omap: dss: Remove unused omap_dss_device operations"
  drm/omap: drop unused dsi.configure_pins
  drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*
  drm/omap: constify write buffers
  drm/omap: dsi: add generic transfer function
  drm/omap: panel-dsi-cm: convert to transfer API
  drm/omap: dsi: unexport specific data transfer functions
  drm/omap: dsi: drop virtual channel logic
  drm/omap: dsi: simplify write function
  drm/omap: dsi: simplify read functions
  drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg
  drm/omap: dsi: introduce mipi_dsi_host
  drm/omap: panel-dsi-cm: use DSI helpers
  drm/omap: dsi: request VC via mipi_dsi_attach
  drm/omap: panel-dsi-cm: drop hardcoded VC
  drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines
  drm/omap: dsi: drop unused memory_read()
  drm/omap: dsi: drop unused get_te()
  drm/omap: dsi: drop unused enable_te()
  drm/omap: dsi: drop useless sync()
  drm/omap: dsi: use pixel-format and mode from attach
  drm/omap: panel-dsi-cm: use bulk regulator API
  drm/omap: dsi: lp/hs switching support for transfer()
  drm/omap: dsi: move TE GPIO handling into core
  drm/omap: dsi: drop custom enable_te() API
  drm/omap: dsi: do bus locking in host driver
  drm/omap: dsi: untangle ulps ops from enable/disable
  drm/omap: dsi: do ULPS in host driver
  drm/omap: dsi: move panel refresh function to host
  drm/omap: dsi: Reverse direction of the DSS device enable/disable
    operations
  drm/omap: dsi: drop custom panel capability support
  drm/omap: dsi: convert to drm_panel
  drm/omap: drop omapdss-boot-init
  drm/omap: dsi: implement check timings
  drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO
  drm/omap: panel-dsi-cm: support unbinding
  drm/omap: panel-dsi-cm: fix remove()
  drm/omap: remove global dss_device variable
  drm/panel: Move OMAP's DSI command mode panel driver
  drm/omap: dsi: Register a drm_bridge
  drm/omap: remove legacy DSS device operations
  drm/omap: remove unused omap_connector
  drm/omap: simplify omap_display_id
  drm/omap: drop unused DSS next pointer
  drm/omap: drop DSS ops_flags
  drm/omap: drop dssdev display field
  drm/omap: simplify DSI manual update code
  drm/omap: dsi: simplify pin config
  ARM: omap2plus_defconfig: Update for moved DSI command mode panel

Tomi Valkeinen (31):
  drm/omap: squash omapdrm sub-modules into one
  drm/omap: remove unused display.c
  drm/omap: drop unused owner field
  drm/omap: remove dispc_ops
  drm/omap: remove dss_mgr_ops
  drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  drm/panel: panel-dsi-cm: cleanup tear enable
  ARM: dts: omap5: add address-cells & size-cells to dsi
  drm/omap: pll: fix iteration loop check
  drm/omap: dsi: set trans_mode according to client mode_flags
  drm/panel: panel-dsi-cm: set column & page at setup
  drm/omap: dsi: send nop instead of page & column
  drm/omap: dsi: simplify VC handling
  drm/omap: dsi: drop useless channel checks
  drm/omap: dsi: cleanup channel usages
  drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode
  drm/omap: dsi: set LP/HS before update
  drm/omap: dsi: use separate VCs for cmd and video
  drm/panel: panel-dsi-cm: remove extra 'if'
  drm/panel: panel-dsi-cm: add panel database to driver
  drm/panel: panel-dsi-cm: drop unneeded includes
  drm/omap: dsi: move structs & defines to dsi.h
  drm/omap: dsi: move enable/disable to bridge enable/disable
  drm/omap: dsi: display_enable cleanup
  drm/omap: dsi: display_disable cleanup
  drm/omap: dsi: rename dsi_display_* functions
  drm/omap: dsi: cleanup initial vc setup
  drm/omap: dsi: split video mode enable/disable into separate func
  drm/omap: dsi: fix and cleanup ddr_clk_always_on
  drm/omap: dsi: remove ulps support
  drm/omap: dsi: fix DCS_CMD_ENABLE

 arch/arm/boot/dts/omap5.dtsi                  |    6 +
 arch/arm/configs/omap2plus_defconfig          |    2 +-
 drivers/gpu/drm/omapdrm/Kconfig               |  120 +-
 drivers/gpu/drm/omapdrm/Makefile              |   19 +-
 drivers/gpu/drm/omapdrm/displays/Kconfig      |   10 -
 drivers/gpu/drm/omapdrm/displays/Makefile     |    2 -
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 1385 ------------
 drivers/gpu/drm/omapdrm/dss/Kconfig           |  135 --
 drivers/gpu/drm/omapdrm/dss/Makefile          |   20 -
 drivers/gpu/drm/omapdrm/dss/base.c            |   87 +-
 drivers/gpu/drm/omapdrm/dss/dispc.c           |  101 +-
 drivers/gpu/drm/omapdrm/dss/display.c         |   60 -
 drivers/gpu/drm/omapdrm/dss/dpi.c             |    1 -
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 1905 +++++++----------
 drivers/gpu/drm/omapdrm/dss/dsi.h             |  450 ++++
 drivers/gpu/drm/omapdrm/dss/dss.c             |   28 +-
 drivers/gpu/drm/omapdrm/dss/dss.h             |   72 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4.c           |    1 -
 drivers/gpu/drm/omapdrm/dss/hdmi5.c           |    1 -
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |  229 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  338 +--
 drivers/gpu/drm/omapdrm/dss/output.c          |   57 +-
 drivers/gpu/drm/omapdrm/dss/pll.c             |    6 +
 drivers/gpu/drm/omapdrm/dss/sdi.c             |    1 -
 drivers/gpu/drm/omapdrm/dss/venc.c            |    2 -
 drivers/gpu/drm/omapdrm/omap_connector.c      |  157 --
 drivers/gpu/drm/omapdrm/omap_connector.h      |   28 -
 drivers/gpu/drm/omapdrm/omap_crtc.c           |  103 +-
 drivers/gpu/drm/omapdrm/omap_crtc.h           |    2 -
 drivers/gpu/drm/omapdrm/omap_drv.c            |   73 +-
 drivers/gpu/drm/omapdrm/omap_drv.h            |    3 +-
 drivers/gpu/drm/omapdrm/omap_encoder.c        |   59 +-
 drivers/gpu/drm/omapdrm/omap_irq.c            |   34 +-
 drivers/gpu/drm/omapdrm/omap_plane.c          |   12 +-
 drivers/gpu/drm/panel/Kconfig                 |    9 +
 drivers/gpu/drm/panel/Makefile                |    1 +
 drivers/gpu/drm/panel/panel-dsi-cm.c          |  670 ++++++
 37 files changed, 2249 insertions(+), 3940 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/displays/Kconfig
 delete mode 100644 drivers/gpu/drm/omapdrm/displays/Makefile
 delete mode 100644 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/Kconfig
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/Makefile
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/display.c
 create mode 100644 drivers/gpu/drm/omapdrm/dss/dsi.h
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
 delete mode 100644 drivers/gpu/drm/omapdrm/omap_connector.c
 delete mode 100644 drivers/gpu/drm/omapdrm/omap_connector.h
 create mode 100644 drivers/gpu/drm/panel/panel-dsi-cm.c

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply	[flat|nested] 152+ messages in thread

* [PATCH v4 01/80] Revert "drm/omap: dss: Remove unused omap_dss_device operations"
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 02/80] drm/omap: drop unused dsi.configure_pins Tomi Valkeinen
                   ` (79 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This reverts commit e086558ae923 ("drm/omap: dss: Remove unused
omap_dss_device operations")

This is still needed by DSI. E.g. unloading modules without this will
cause a crash.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/base.c     | 26 +++++++++++++++
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  6 ++++
 drivers/gpu/drm/omapdrm/omap_encoder.c | 44 +++++++++++++++++++++++---
 3 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index c7650a7c155d..455b410f7401 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -234,6 +234,18 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 }
 EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
 
+void omapdss_device_pre_enable(struct omap_dss_device *dssdev)
+{
+	if (!dssdev)
+		return;
+
+	omapdss_device_pre_enable(dssdev->next);
+
+	if (dssdev->ops && dssdev->ops->pre_enable)
+		dssdev->ops->pre_enable(dssdev);
+}
+EXPORT_SYMBOL_GPL(omapdss_device_pre_enable);
+
 void omapdss_device_enable(struct omap_dss_device *dssdev)
 {
 	if (!dssdev)
@@ -260,6 +272,20 @@ void omapdss_device_disable(struct omap_dss_device *dssdev)
 }
 EXPORT_SYMBOL_GPL(omapdss_device_disable);
 
+void omapdss_device_post_disable(struct omap_dss_device *dssdev)
+{
+	if (!dssdev)
+		return;
+
+	if (dssdev->ops && dssdev->ops->post_disable)
+		dssdev->ops->post_disable(dssdev);
+
+	omapdss_device_post_disable(dssdev->next);
+
+	dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
+}
+EXPORT_SYMBOL_GPL(omapdss_device_post_disable);
+
 /* -----------------------------------------------------------------------------
  * Components Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index ab19d4af8de7..cbbe10b2b60d 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -342,11 +342,15 @@ struct omap_dss_device_ops {
 	void (*disconnect)(struct omap_dss_device *dssdev,
 			struct omap_dss_device *dst);
 
+	void (*pre_enable)(struct omap_dss_device *dssdev);
 	void (*enable)(struct omap_dss_device *dssdev);
 	void (*disable)(struct omap_dss_device *dssdev);
+	void (*post_disable)(struct omap_dss_device *dssdev);
 
 	int (*check_timings)(struct omap_dss_device *dssdev,
 			     struct drm_display_mode *mode);
+	void (*set_timings)(struct omap_dss_device *dssdev,
+			    const struct drm_display_mode *mode);
 
 	int (*get_modes)(struct omap_dss_device *dssdev,
 			 struct drm_connector *connector);
@@ -445,8 +449,10 @@ int omapdss_device_connect(struct dss_device *dss,
 			   struct omap_dss_device *dst);
 void omapdss_device_disconnect(struct omap_dss_device *src,
 			       struct omap_dss_device *dst);
+void omapdss_device_pre_enable(struct omap_dss_device *dssdev);
 void omapdss_device_enable(struct omap_dss_device *dssdev);
 void omapdss_device_disable(struct omap_dss_device *dssdev);
+void omapdss_device_post_disable(struct omap_dss_device *dssdev);
 
 int omap_dss_get_num_overlay_managers(void);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
index ae4b867a67a3..18a79dde6815 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -113,8 +113,13 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
 	bus_flags = connector->display_info.bus_flags;
 	omap_encoder_update_videomode_flags(&vm, bus_flags);
 
-	/* Set timings for the dss manager. */
+	/* Set timings for all devices in the display pipeline. */
 	dss_mgr_set_timings(output, &vm);
+
+	for (dssdev = output; dssdev; dssdev = dssdev->next) {
+		if (dssdev->ops && dssdev->ops->set_timings)
+			dssdev->ops->set_timings(dssdev, adjusted_mode);
+	}
 }
 
 static void omap_encoder_disable(struct drm_encoder *encoder)
@@ -127,10 +132,26 @@ static void omap_encoder_disable(struct drm_encoder *encoder)
 
 	/*
 	 * Disable the chain of external devices, starting at the one at the
-	 * internal encoder's output. This is used for DSI outputs only, as
-	 * dssdev->next is NULL for all other outputs.
+	 * internal encoder's output.
 	 */
 	omapdss_device_disable(dssdev->next);
+
+	/*
+	 * Disable the internal encoder. This will disable the DSS output. The
+	 * DSI is treated as an exception as DSI pipelines still use the legacy
+	 * flow where the pipeline output controls the encoder.
+	 */
+	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI) {
+		if (dssdev->ops && dssdev->ops->disable)
+			dssdev->ops->disable(dssdev);
+		dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
+	}
+
+	/*
+	 * Perform the post-disable operations on the chain of external devices
+	 * to complete the display pipeline disable.
+	 */
+	omapdss_device_post_disable(dssdev->next);
 }
 
 static void omap_encoder_enable(struct drm_encoder *encoder)
@@ -141,10 +162,23 @@ static void omap_encoder_enable(struct drm_encoder *encoder)
 
 	dev_dbg(dev->dev, "enable(%s)\n", dssdev->name);
 
+	/* Prepare the chain of external devices for pipeline enable. */
+	omapdss_device_pre_enable(dssdev->next);
+
+	/*
+	 * Enable the internal encoder. This will enable the DSS output. The
+	 * DSI is treated as an exception as DSI pipelines still use the legacy
+	 * flow where the pipeline output controls the encoder.
+	 */
+	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI) {
+		if (dssdev->ops && dssdev->ops->enable)
+			dssdev->ops->enable(dssdev);
+		dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
+	}
+
 	/*
 	 * Enable the chain of external devices, starting at the one at the
-	 * internal encoder's output. This is used for DSI outputs only, as
-	 * dssdev->next is NULL for all other outputs.
+	 * internal encoder's output.
 	 */
 	omapdss_device_enable(dssdev->next);
 }
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 02/80] drm/omap: drop unused dsi.configure_pins
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 01/80] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 03/80] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Tomi Valkeinen
                   ` (78 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

The panel-dsi-cm's ddata->pin_config is always NULL, so this
callback is never called. Instead the DSI encoder gets the pin
configuration directly from DT.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 11 -----------
 drivers/gpu/drm/omapdrm/dss/dsi.c               |  1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h           |  2 --
 3 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index faca5c873bde..ff610d2a13fd 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -68,8 +68,6 @@ struct panel_drv_data {
 	int width_mm;
 	int height_mm;
 
-	struct omap_dsi_pin_config pin_config;
-
 	/* runtime variables */
 	bool enabled;
 
@@ -623,15 +621,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 		}
 	}
 
-	if (ddata->pin_config.num_pins > 0) {
-		r = src->ops->dsi.configure_pins(src, &ddata->pin_config);
-		if (r) {
-			dev_err(&ddata->pdev->dev,
-				"failed to configure DSI pins\n");
-			goto err_vddi;
-		}
-	}
-
 	r = src->ops->dsi.set_config(src, &dsi_config);
 	if (r) {
 		dev_err(&ddata->pdev->dev, "failed to configure DSI\n");
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index eeccf40bae41..5598fc8f91db 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4892,7 +4892,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 
 		.enable_hs = dsi_vc_enable_hs,
 
-		.configure_pins = dsi_configure_pins,
 		.set_config = dsi_set_config,
 
 		.enable_video_output = dsi_enable_video_output,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index cbbe10b2b60d..b0424daaceed 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -292,8 +292,6 @@ struct omapdss_dsi_ops {
 	/* bus configuration */
 	int (*set_config)(struct omap_dss_device *dssdev,
 			const struct omap_dss_dsi_config *cfg);
-	int (*configure_pins)(struct omap_dss_device *dssdev,
-			const struct omap_dsi_pin_config *pin_cfg);
 
 	void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
 			bool enable);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 03/80] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 01/80] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 02/80] drm/omap: drop unused dsi.configure_pins Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 04/80] drm/omap: constify write buffers Tomi Valkeinen
                   ` (77 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This replaces OMAP specific enum for pixel format with
common implementation.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 55 ++++++++-----------
 drivers/gpu/drm/omapdrm/dss/omapdss.h         | 13 ++---
 3 files changed, 28 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ff610d2a13fd..b8f3a7aacbf4 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -595,7 +595,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	int r;
 	struct omap_dss_dsi_config dsi_config = {
 		.mode = OMAP_DSS_DSI_CMD_MODE,
-		.pixel_format = OMAP_DSS_DSI_FMT_RGB888,
+		.pixel_format = MIPI_DSI_FMT_RGB888,
 		.vm = &ddata->vm,
 		.hs_clk_min = 150000000,
 		.hs_clk_max = 300000000,
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 5598fc8f91db..86b9d435fb94 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -33,6 +33,7 @@
 #include <linux/component.h>
 #include <linux/sys_soc.h>
 
+#include <drm/drm_mipi_dsi.h>
 #include <video/mipi_display.h>
 
 #include "omapdss.h"
@@ -410,7 +411,7 @@ struct dsi_data {
 
 	struct dss_lcd_mgr_config mgr_config;
 	struct videomode vm;
-	enum omap_dss_dsi_pixel_format pix_fmt;
+	enum mipi_dsi_pixel_format pix_fmt;
 	enum omap_dss_dsi_mode mode;
 	struct omap_dss_dsi_videomode_timings vm_timings;
 
@@ -514,22 +515,6 @@ static inline bool wait_for_bit_change(struct dsi_data *dsi,
 	return false;
 }
 
-static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
-{
-	switch (fmt) {
-	case OMAP_DSS_DSI_FMT_RGB888:
-	case OMAP_DSS_DSI_FMT_RGB666:
-		return 24;
-	case OMAP_DSS_DSI_FMT_RGB666_PACKED:
-		return 18;
-	case OMAP_DSS_DSI_FMT_RGB565:
-		return 16;
-	default:
-		BUG();
-		return 0;
-	}
-}
-
 #ifdef DSI_PERF_MEASURE
 static void dsi_perf_mark_setup(struct dsi_data *dsi)
 {
@@ -3239,7 +3224,7 @@ static void dsi_config_vp_num_line_buffers(struct dsi_data *dsi)
 	int num_line_buffers;
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-		int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+		int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
 		const struct videomode *vm = &dsi->vm;
 		/*
 		 * Don't use line buffers if width is greater than the video
@@ -3370,7 +3355,7 @@ static void dsi_config_cmd_mode_interleaving(struct dsi_data *dsi)
 	int tclk_trail, ths_exit, exiths_clk;
 	bool ddr_alwon;
 	const struct videomode *vm = &dsi->vm;
-	int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+	int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
 	int ndl = dsi->num_lanes_used - 1;
 	int dsi_fclk_hsdiv = dsi->user_dsi_cinfo.mX[HSDIV_DSI] + 1;
 	int hsa_interleave_hs = 0, hsa_interleave_lp = 0;
@@ -3498,7 +3483,7 @@ static int dsi_proto_config(struct dsi_data *dsi)
 	dsi_set_lp_rx_timeout(dsi, 0x1fff, true, true);
 	dsi_set_hs_tx_timeout(dsi, 0x1fff, true, true);
 
-	switch (dsi_get_pixel_size(dsi->pix_fmt)) {
+	switch (mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt)) {
 	case 16:
 		buswidth = 0;
 		break;
@@ -3619,7 +3604,7 @@ static void dsi_proto_timings(struct dsi_data *dsi)
 		int window_sync = dsi->vm_timings.window_sync;
 		bool hsync_end;
 		const struct videomode *vm = &dsi->vm;
-		int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+		int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
 		int tl, t_he, width_bytes;
 
 		hsync_end = dsi->vm_timings.trans_mode == OMAP_DSS_DSI_PULSE_MODE;
@@ -3726,7 +3711,7 @@ static int dsi_configure_pins(struct omap_dss_device *dssdev,
 static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	int bpp = dsi_get_pixel_size(dsi->pix_fmt);
+	int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
 	u8 data_type;
 	u16 word_count;
 	int r;
@@ -3737,16 +3722,16 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
 		switch (dsi->pix_fmt) {
-		case OMAP_DSS_DSI_FMT_RGB888:
+		case MIPI_DSI_FMT_RGB888:
 			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
 			break;
-		case OMAP_DSS_DSI_FMT_RGB666:
+		case MIPI_DSI_FMT_RGB666:
 			data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
 			break;
-		case OMAP_DSS_DSI_FMT_RGB666_PACKED:
+		case MIPI_DSI_FMT_RGB666_PACKED:
 			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_18;
 			break;
-		case OMAP_DSS_DSI_FMT_RGB565:
+		case MIPI_DSI_FMT_RGB565:
 			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16;
 			break;
 		default:
@@ -3824,7 +3809,7 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
 
 	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_VP);
 
-	bytespp	= dsi_get_pixel_size(dsi->pix_fmt) / 8;
+	bytespp	= mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) / 8;
 	bytespl = w * bytespp;
 	bytespf = bytespl * h;
 
@@ -3954,7 +3939,7 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
 
 #ifdef DSI_PERF_MEASURE
 	dsi->update_bytes = dw * dh *
-		dsi_get_pixel_size(dsi->pix_fmt) / 8;
+		mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) / 8;
 #endif
 	dsi_update_screen_dispc(dsi);
 
@@ -4015,7 +4000,7 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
 
 	dsi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 	dsi->mgr_config.video_port_width =
-			dsi_get_pixel_size(dsi->pix_fmt);
+			mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
 	dsi->mgr_config.lcden_sig_polarity = 0;
 
 	dss_mgr_set_lcd_config(&dsi->output, &dsi->mgr_config);
@@ -4353,7 +4338,7 @@ static bool dsi_cm_calc(struct dsi_data *dsi,
 	unsigned long pck, txbyteclk;
 
 	clkin = clk_get_rate(dsi->pll.clkin);
-	bitspp = dsi_get_pixel_size(cfg->pixel_format);
+	bitspp = mipi_dsi_pixel_format_to_bpp(cfg->pixel_format);
 	ndl = dsi->num_lanes_used - 1;
 
 	/*
@@ -4386,7 +4371,7 @@ static bool dsi_vm_calc_blanking(struct dsi_clk_calc_ctx *ctx)
 {
 	struct dsi_data *dsi = ctx->dsi;
 	const struct omap_dss_dsi_config *cfg = ctx->config;
-	int bitspp = dsi_get_pixel_size(cfg->pixel_format);
+	int bitspp = mipi_dsi_pixel_format_to_bpp(cfg->pixel_format);
 	int ndl = dsi->num_lanes_used - 1;
 	unsigned long hsclk = ctx->dsi_cinfo.clkdco / 4;
 	unsigned long byteclk = hsclk / 4;
@@ -4653,7 +4638,7 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
 	unsigned long pll_min;
 	unsigned long pll_max;
 	int ndl = dsi->num_lanes_used - 1;
-	int bitspp = dsi_get_pixel_size(cfg->pixel_format);
+	int bitspp = mipi_dsi_pixel_format_to_bpp(cfg->pixel_format);
 	unsigned long byteclk_min;
 
 	clkin = clk_get_rate(dsi->pll.clkin);
@@ -4699,6 +4684,12 @@ static int dsi_set_config(struct omap_dss_device *dssdev,
 	dsi->pix_fmt = config->pixel_format;
 	dsi->mode = config->mode;
 
+	if (mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) < 0) {
+		DSSERR("invalid pixel format\n");
+		r = -EINVAL;
+		goto err;
+	}
+
 	if (config->mode == OMAP_DSS_DSI_VIDEO_MODE)
 		ok = dsi_vm_calc(dsi, config, &ctx);
 	else
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index b0424daaceed..c4bc1f919ab4 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -12,8 +12,10 @@
 #include <linux/interrupt.h>
 #include <video/videomode.h>
 #include <linux/platform_data/omapdss.h>
-#include <uapi/drm/drm_mode.h>
+
 #include <drm/drm_crtc.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_mode.h>
 
 #define DISPC_IRQ_FRAMEDONE		(1 << 0)
 #define DISPC_IRQ_VSYNC			(1 << 1)
@@ -116,13 +118,6 @@ enum omap_dss_venc_type {
 	OMAP_DSS_VENC_TYPE_SVIDEO,
 };
 
-enum omap_dss_dsi_pixel_format {
-	OMAP_DSS_DSI_FMT_RGB888,
-	OMAP_DSS_DSI_FMT_RGB666,
-	OMAP_DSS_DSI_FMT_RGB666_PACKED,
-	OMAP_DSS_DSI_FMT_RGB565,
-};
-
 enum omap_dss_dsi_mode {
 	OMAP_DSS_DSI_CMD_MODE = 0,
 	OMAP_DSS_DSI_VIDEO_MODE,
@@ -210,7 +205,7 @@ struct omap_dss_dsi_videomode_timings {
 
 struct omap_dss_dsi_config {
 	enum omap_dss_dsi_mode mode;
-	enum omap_dss_dsi_pixel_format pixel_format;
+	enum mipi_dsi_pixel_format pixel_format;
 	const struct videomode *vm;
 
 	unsigned long hs_clk_min, hs_clk_max;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 04/80] drm/omap: constify write buffers
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (2 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 03/80] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 05/80] drm/omap: dsi: add generic transfer function Tomi Valkeinen
                   ` (76 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

The write buffers are not modified, so they can be constant.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 24 ++++++++++++------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 10 +++++-----
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 86b9d435fb94..22d74d762a10 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2601,11 +2601,11 @@ static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel,
 }
 
 static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
-			    u8 *data, u16 len, u8 ecc)
+			    const u8 *data, u16 len, u8 ecc)
 {
 	/*u32 val; */
 	int i;
-	u8 *p;
+	const u8 *p;
 	int r = 0;
 	u8 b1, b2, b3, b4;
 
@@ -2698,7 +2698,7 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
 }
 
 static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
-				      u8 *data, int len,
+				      const u8 *data, int len,
 				      enum dss_dsi_content_type type)
 {
 	int r;
@@ -2729,7 +2729,7 @@ static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
 }
 
 static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
-		u8 *data, int len)
+		const u8 *data, int len)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
@@ -2738,7 +2738,7 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
 }
 
 static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int channel,
-		u8 *data, int len)
+		const u8 *data, int len)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
@@ -2747,7 +2747,7 @@ static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int chann
 }
 
 static int dsi_vc_write_common(struct omap_dss_device *dssdev,
-			       int channel, u8 *data, int len,
+			       int channel, const u8 *data, int len,
 			       enum dss_dsi_content_type type)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
@@ -2776,15 +2776,15 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev,
 	return r;
 }
 
-static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel, u8 *data,
-		int len)
+static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel,
+		const u8 *data, int len)
 {
 	return dsi_vc_write_common(dssdev, channel, data, len,
 			DSS_DSI_CONTENT_DCS);
 }
 
-static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, u8 *data,
-		int len)
+static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel,
+		const u8 *data, int len)
 {
 	return dsi_vc_write_common(dssdev, channel, data, len,
 			DSS_DSI_CONTENT_GENERIC);
@@ -2810,7 +2810,7 @@ static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel,
 }
 
 static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel,
-					    u8 *reqdata, int reqlen)
+					    const u8 *reqdata, int reqlen)
 {
 	u16 data;
 	u8 data_type;
@@ -2983,7 +2983,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c
 }
 
 static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
-		u8 *reqdata, int reqlen, u8 *buf, int buflen)
+		const u8 *reqdata, int reqlen, u8 *buf, int buflen)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index c4bc1f919ab4..8e96ab2f20b6 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -309,18 +309,18 @@ struct omapdss_dsi_ops {
 
 	/* data transfer */
 	int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
-			u8 *data, int len);
+			const u8 *data, int len);
 	int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-			u8 *data, int len);
+			const u8 *data, int len);
 	int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
 			u8 *data, int len);
 
 	int (*gen_write)(struct omap_dss_device *dssdev, int channel,
-			u8 *data, int len);
+			const u8 *data, int len);
 	int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
-			u8 *data, int len);
+			const u8 *data, int len);
 	int (*gen_read)(struct omap_dss_device *dssdev, int channel,
-			u8 *reqdata, int reqlen,
+			const u8 *reqdata, int reqlen,
 			u8 *data, int len);
 
 	int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 05/80] drm/omap: dsi: add generic transfer function
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (3 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 04/80] drm/omap: constify write buffers Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 06/80] drm/omap: panel-dsi-cm: convert to transfer API Tomi Valkeinen
                   ` (75 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This prepares the driver for becoming a mipi_dsi_host implementation,
which provides a generic transfer function instead of all kind of
different read/write functions. The implementation will become more
elegant after unexporting the specific functions in the following
patches.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 54 +++++++++++++++++++++++++++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ++
 2 files changed, 57 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 22d74d762a10..9babe813a303 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4842,6 +4842,58 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
 	}
 }
 
+static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev,
+				 const struct mipi_dsi_msg *msg)
+{
+	/*
+	 * TODO: no_sync can be used to optimize performance by sending e.g.
+	 * column and page information without syncing in between. It's not
+	 * absolutely required, so postpone this feature for now.
+	 */
+	bool no_sync = false;
+	u16 val;
+
+	switch (msg->type) {
+	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:
+		if (no_sync)
+			return dsi_vc_generic_write_nosync(dssdev, msg->channel,
+							   msg->tx_buf,
+							   msg->tx_len);
+		else
+			return dsi_vc_generic_write(dssdev, msg->channel,
+						    msg->tx_buf, msg->tx_len);
+	case MIPI_DSI_DCS_SHORT_WRITE:
+	case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
+	case MIPI_DSI_DCS_LONG_WRITE:
+		if (no_sync)
+			return dsi_vc_dcs_write_nosync(dssdev, msg->channel,
+						       msg->tx_buf,
+						       msg->tx_len);
+		else
+			return dsi_vc_dcs_write(dssdev, msg->channel,
+						msg->tx_buf, msg->tx_len);
+	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
+	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
+	case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
+		return dsi_vc_generic_read(dssdev, msg->channel,
+					   msg->tx_buf, msg->tx_len,
+					   msg->rx_buf, msg->rx_len);
+	case MIPI_DSI_DCS_READ:
+		return dsi_vc_dcs_read(dssdev, msg->channel,
+				       ((u8 *)msg->tx_buf)[0],
+				       msg->rx_buf, msg->rx_len);
+	case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
+		val = le16_to_cpu(*((__le16 *)msg->tx_buf));
+		return dsi_vc_set_max_rx_packet_size(dssdev, msg->channel, val);
+	case MIPI_DSI_NULL_PACKET:
+		return dsi_vc_send_null(to_dsi_data(dssdev), msg->channel);
+	}
+
+	return -EINVAL;
+}
 
 static int dsi_get_clocks(struct dsi_data *dsi)
 {
@@ -4896,6 +4948,8 @@ static const struct omap_dss_device_ops dsi_ops = {
 		.set_vc_id = dsi_set_vc_id,
 		.release_vc = dsi_release_vc,
 
+		.transfer = omap_dsi_transfer,
+
 		.dcs_write = dsi_vc_dcs_write,
 		.dcs_write_nosync = dsi_vc_dcs_write_nosync,
 		.dcs_read = dsi_vc_dcs_read,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 8e96ab2f20b6..654618e5a4e5 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -308,6 +308,9 @@ struct omapdss_dsi_ops {
 	void (*release_vc)(struct omap_dss_device *dssdev, int channel);
 
 	/* data transfer */
+	ssize_t (*transfer)(struct omap_dss_device *dssdev,
+			    const struct mipi_dsi_msg *msg);
+
 	int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
 			const u8 *data, int len);
 	int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 06/80] drm/omap: panel-dsi-cm: convert to transfer API
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (4 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 05/80] drm/omap: dsi: add generic transfer function Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 07/80] drm/omap: dsi: unexport specific data transfer functions Tomi Valkeinen
                   ` (74 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This converts the panel-dsi-cm driver to use the transfer
API instead of specific functions, so that the specific
functions can be unexported and squashed into the generic
transfer function.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 132 +++++++++++++-----
 1 file changed, 95 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index b8f3a7aacbf4..8b2e80129bd8 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -140,45 +140,61 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
 	struct omap_dss_device *src = ddata->src;
-	int r;
-	u8 buf[1];
-
-	r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, buf, 1);
-
-	if (r < 0)
-		return r;
-
-	*data = buf[0];
+	const struct mipi_dsi_msg msg = {
+		.channel = ddata->channel,
+		.type = MIPI_DSI_DCS_READ,
+		.tx_len = 1,
+		.tx_buf = &dcs_cmd,
+		.rx_len = 1,
+		.rx_buf = data
+	};
 
-	return 0;
+	return src->ops->dsi.transfer(src, &msg);
 }
 
 static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
 {
 	struct omap_dss_device *src = ddata->src;
+	const struct mipi_dsi_msg msg = {
+		.channel = ddata->channel,
+		.type = MIPI_DSI_DCS_SHORT_WRITE,
+		.tx_buf = &dcs_cmd,
+		.tx_len = 1,
+	};
 
-	return src->ops->dsi.dcs_write(src, ddata->channel, &dcs_cmd, 1);
+	return src->ops->dsi.transfer(src, &msg);
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
 {
 	struct omap_dss_device *src = ddata->src;
-	u8 buf[2] = { dcs_cmd, param };
+	const u8 buf[] = { dcs_cmd, param };
+	const struct mipi_dsi_msg msg = {
+		.channel = ddata->channel,
+		.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM,
+		.tx_buf = &buf,
+		.tx_len = 2,
+	};
 
-	return src->ops->dsi.dcs_write(src, ddata->channel, buf, 2);
+	return src->ops->dsi.transfer(src, &msg);
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
 	struct omap_dss_device *src = ddata->src;
-	u8 cmd;
 	int r;
+	const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
+	const struct mipi_dsi_msg msg = {
+		.channel = ddata->channel,
+		.type = MIPI_DSI_DCS_SHORT_WRITE,
+		.tx_buf = &cmd,
+		.tx_len = 1,
+	};
 
 	hw_guard_wait(ddata);
 
-	cmd = MIPI_DCS_ENTER_SLEEP_MODE;
-	r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, &cmd, 1);
+	r = src->ops->dsi.transfer(src, &msg);
 	if (r)
 		return r;
 
@@ -233,28 +249,43 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata,
 	u16 y1 = y;
 	u16 y2 = y + h - 1;
 
-	u8 buf[5];
-	buf[0] = MIPI_DCS_SET_COLUMN_ADDRESS;
-	buf[1] = (x1 >> 8) & 0xff;
-	buf[2] = (x1 >> 0) & 0xff;
-	buf[3] = (x2 >> 8) & 0xff;
-	buf[4] = (x2 >> 0) & 0xff;
+	const u8 paramX[] = {
+		MIPI_DCS_SET_COLUMN_ADDRESS,
+		(x1 >> 8) & 0xff,
+		(x1 >> 0) & 0xff,
+		(x2 >> 8) & 0xff,
+		(x2 >> 0) & 0xff,
+	};
 
-	r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf));
-	if (r)
-		return r;
+	const struct mipi_dsi_msg msgX = {
+		.channel = ddata->channel,
+		.type = MIPI_DSI_GENERIC_LONG_WRITE,
+		.tx_buf = paramX,
+		.tx_len = 5,
+	};
+
+	const u8 paramY[] = {
+		MIPI_DCS_SET_PAGE_ADDRESS,
+		(y1 >> 8) & 0xff,
+		(y1 >> 0) & 0xff,
+		(y2 >> 8) & 0xff,
+		(y2 >> 0) & 0xff,
+	};
 
-	buf[0] = MIPI_DCS_SET_PAGE_ADDRESS;
-	buf[1] = (y1 >> 8) & 0xff;
-	buf[2] = (y1 >> 0) & 0xff;
-	buf[3] = (y2 >> 8) & 0xff;
-	buf[4] = (y2 >> 0) & 0xff;
+	const struct mipi_dsi_msg msgY = {
+		.channel = ddata->channel,
+		.type = MIPI_DSI_GENERIC_LONG_WRITE,
+		.tx_buf = paramY,
+		.tx_len = 5,
+	};
 
-	r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf));
+	r = src->ops->dsi.transfer(src, &msgX);
 	if (r)
 		return r;
 
-	src->ops->dsi.bta_sync(src, ddata->channel);
+	r = src->ops->dsi.transfer(src, &msgY);
+	if (r)
+		return r;
 
 	return r;
 }
@@ -991,6 +1022,27 @@ static int dsicm_get_te(struct omap_dss_device *dssdev)
 	return r;
 }
 
+static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
+					u16 size)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_dss_device *src = ddata->src;
+
+	const u8 buf[] = {
+		size & 0xff,
+		size >> 8 & 0xff,
+	};
+
+	const struct mipi_dsi_msg msg = {
+		.channel = ddata->channel,
+		.type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE,
+		.tx_buf = buf,
+		.tx_len = 2,
+	};
+
+	return src->ops->dsi.transfer(src, &msg);
+}
+
 static int dsicm_memory_read(struct omap_dss_device *dssdev,
 		void *buf, size_t size,
 		u16 x, u16 y, u16 w, u16 h)
@@ -1031,17 +1083,23 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
 
 	dsicm_set_update_window(ddata, x, y, w, h);
 
-	r = src->ops->dsi.set_max_rx_packet_size(src, ddata->channel, plen);
+	r = dsicm_set_max_rx_packet_size(dssdev, plen);
 	if (r)
 		goto err2;
 
 	while (buf_used < size) {
 		u8 dcs_cmd = first ? 0x2e : 0x3e;
+		const struct mipi_dsi_msg msg = {
+			.channel = ddata->channel,
+			.type = MIPI_DSI_DCS_READ,
+			.tx_buf = &dcs_cmd,
+			.tx_len = 1,
+			.rx_buf = buf + buf_used,
+			.rx_len = size - buf_used,
+		};
 		first = 0;
 
-		r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd,
-				buf + buf_used, size - buf_used);
-
+		r = src->ops->dsi.transfer(src, &msg);
 		if (r < 0) {
 			dev_err(dssdev->dev, "read error\n");
 			goto err3;
@@ -1065,7 +1123,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
 	r = buf_used;
 
 err3:
-	src->ops->dsi.set_max_rx_packet_size(src, ddata->channel, 1);
+	dsicm_set_max_rx_packet_size(dssdev, 1);
 err2:
 	src->ops->dsi.bus_unlock(src);
 err1:
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 07/80] drm/omap: dsi: unexport specific data transfer functions
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (5 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 06/80] drm/omap: panel-dsi-cm: convert to transfer API Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 08/80] drm/omap: dsi: drop virtual channel logic Tomi Valkeinen
                   ` (73 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

After converting all DSI drivers, unexport the specific transfer
functions.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 12 ------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 20 --------------------
 2 files changed, 32 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 9babe813a303..7391b499848f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4949,18 +4949,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 		.release_vc = dsi_release_vc,
 
 		.transfer = omap_dsi_transfer,
-
-		.dcs_write = dsi_vc_dcs_write,
-		.dcs_write_nosync = dsi_vc_dcs_write_nosync,
-		.dcs_read = dsi_vc_dcs_read,
-
-		.gen_write = dsi_vc_generic_write,
-		.gen_write_nosync = dsi_vc_generic_write_nosync,
-		.gen_read = dsi_vc_generic_read,
-
-		.bta_sync = dsi_vc_send_bta_sync,
-
-		.set_max_rx_packet_size = dsi_vc_set_max_rx_packet_size,
 	},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 654618e5a4e5..9ead877cb24c 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -310,26 +310,6 @@ struct omapdss_dsi_ops {
 	/* data transfer */
 	ssize_t (*transfer)(struct omap_dss_device *dssdev,
 			    const struct mipi_dsi_msg *msg);
-
-	int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
-			const u8 *data, int len);
-	int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
-			const u8 *data, int len);
-	int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
-			u8 *data, int len);
-
-	int (*gen_write)(struct omap_dss_device *dssdev, int channel,
-			const u8 *data, int len);
-	int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
-			const u8 *data, int len);
-	int (*gen_read)(struct omap_dss_device *dssdev, int channel,
-			const u8 *reqdata, int reqlen,
-			u8 *data, int len);
-
-	int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
-
-	int (*set_max_rx_packet_size)(struct omap_dss_device *dssdev,
-			int channel, u16 plen);
 };
 
 struct omap_dss_device_ops {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 08/80] drm/omap: dsi: drop virtual channel logic
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (6 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 07/80] drm/omap: dsi: unexport specific data transfer functions Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 09/80] drm/omap: dsi: simplify write function Tomi Valkeinen
                   ` (72 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This drops the virtual channel logic. Afterwards DSI clients
request their channel number and get the virtual channel with
the same number or -EBUSY if already in use.

The change here is not strictly speaking correct, as it combines the VC
(DSI's "configuration block") and virtual channel ID (the ID sent in the
DSI packets). But as we currently only support a single DSI command mode
panel, this works fine: we always use VC0, and VC ID 0.

This needs more work to support video mode panels, but that can be done
after moving to DRM bridge and panel model, after which we can do that
work with the proper APIs.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 11 ++---
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 46 ++++---------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  4 +-
 3 files changed, 12 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 8b2e80129bd8..ea76a89d1833 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -768,19 +768,12 @@ static int dsicm_connect(struct omap_dss_device *src,
 	struct device *dev = &ddata->pdev->dev;
 	int r;
 
-	r = src->ops->dsi.request_vc(src, &ddata->channel);
+	r = src->ops->dsi.request_vc(src, ddata->channel);
 	if (r) {
 		dev_err(dev, "failed to get virtual channel\n");
 		return r;
 	}
 
-	r = src->ops->dsi.set_vc_id(src, ddata->channel, TCH);
-	if (r) {
-		dev_err(dev, "failed to set VC_ID\n");
-		src->ops->dsi.release_vc(src, ddata->channel);
-		return r;
-	}
-
 	ddata->src = src;
 	return 0;
 }
@@ -1215,6 +1208,8 @@ static int dsicm_probe_of(struct platform_device *pdev)
 	struct display_timing timing;
 	int err;
 
+	ddata->channel = TCH;
+
 	ddata->reset_gpio = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ddata->reset_gpio)) {
 		err = PTR_ERR(ddata->reset_gpio);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 7391b499848f..796f9c35483e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -350,7 +350,6 @@ struct dsi_data {
 		struct omap_dss_device *dssdev;
 		enum fifo_size tx_fifo_size;
 		enum fifo_size rx_fifo_size;
-		int vc_id;
 	} vc[4];
 
 	struct mutex lock;
@@ -2579,7 +2578,7 @@ static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel,
 
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
-	data_id = data_type | dsi->vc[channel].vc_id << 6;
+	data_id = data_type | channel << 6;
 
 	val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
 		FLD_VAL(ecc, 31, 24);
@@ -2683,7 +2682,7 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int channel, u8 data_type,
 		return -EINVAL;
 	}
 
-	data_id = data_type | dsi->vc[channel].vc_id << 6;
+	data_id = data_type | channel << 6;
 
 	r = (data_id << 0) | (data << 8) | (ecc << 24);
 
@@ -4789,45 +4788,19 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
 	}
 }
 
-static int dsi_request_vc(struct omap_dss_device *dssdev, int *channel)
+static int dsi_request_vc(struct omap_dss_device *dssdev, int channel)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
-		if (!dsi->vc[i].dssdev) {
-			dsi->vc[i].dssdev = dssdev;
-			*channel = i;
-			return 0;
-		}
-	}
 
-	DSSERR("cannot get VC for display %s", dssdev->name);
-	return -ENOSPC;
-}
-
-static int dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	if (vc_id < 0 || vc_id > 3) {
-		DSSERR("VC ID out of range\n");
-		return -EINVAL;
-	}
-
-	if (channel < 0 || channel > 3) {
-		DSSERR("Virtual Channel out of range\n");
+	if (channel < 0 || channel > 3)
 		return -EINVAL;
-	}
 
-	if (dsi->vc[channel].dssdev != dssdev) {
-		DSSERR("Virtual Channel not allocated to display %s\n",
-			dssdev->name);
-		return -EINVAL;
+	if (dsi->vc[channel].dssdev) {
+		DSSERR("cannot get VC for display %s", dssdev->name);
+		return -EBUSY;
 	}
 
-	dsi->vc[channel].vc_id = vc_id;
-
+	dsi->vc[channel].dssdev = dssdev;
 	return 0;
 }
 
@@ -4838,7 +4811,6 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
 	if ((channel >= 0 && channel <= 3) &&
 		dsi->vc[channel].dssdev == dssdev) {
 		dsi->vc[channel].dssdev = NULL;
-		dsi->vc[channel].vc_id = 0;
 	}
 }
 
@@ -4945,7 +4917,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 		.enable_te = dsi_enable_te,
 
 		.request_vc = dsi_request_vc,
-		.set_vc_id = dsi_set_vc_id,
 		.release_vc = dsi_release_vc,
 
 		.transfer = omap_dsi_transfer,
@@ -5401,7 +5372,6 @@ static int dsi_probe(struct platform_device *pdev)
 	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
 		dsi->vc[i].source = DSI_VC_SOURCE_L4;
 		dsi->vc[i].dssdev = NULL;
-		dsi->vc[i].vc_id = 0;
 	}
 
 	r = dsi_get_clocks(dsi);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9ead877cb24c..40e1ce9e256e 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -302,9 +302,7 @@ struct omapdss_dsi_ops {
 	void (*disable_video_output)(struct omap_dss_device *dssdev,
 			int channel);
 
-	int (*request_vc)(struct omap_dss_device *dssdev, int *channel);
-	int (*set_vc_id)(struct omap_dss_device *dssdev, int channel,
-			int vc_id);
+	int (*request_vc)(struct omap_dss_device *dssdev, int channel);
 	void (*release_vc)(struct omap_dss_device *dssdev, int channel);
 
 	/* data transfer */
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 09/80] drm/omap: dsi: simplify write function
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (7 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 08/80] drm/omap: dsi: drop virtual channel logic Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 10/80] drm/omap: dsi: simplify read functions Tomi Valkeinen
                   ` (71 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Simplify the write related messages handling by using the functionality
provided by CONFIG_DRM_MIPI_DSI.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/Kconfig |   1 +
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 146 +++++++---------------------
 2 files changed, 34 insertions(+), 113 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
index 2658c521b702..fd7dfa28ce97 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -95,6 +95,7 @@ config OMAP2_DSS_SDI
 config OMAP2_DSS_DSI
 	bool "DSI support"
 	default n
+	select DRM_MIPI_DSI
 	help
 	  MIPI DSI (Display Serial Interface) support.
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 796f9c35483e..e1595c0608f2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2696,97 +2696,50 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
 	return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0);
 }
 
-static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel,
-				      const u8 *data, int len,
-				      enum dss_dsi_content_type type)
-{
-	int r;
-
-	if (len == 0) {
-		BUG_ON(type == DSS_DSI_CONTENT_DCS);
-		r = dsi_vc_send_short(dsi, channel,
-				MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM, 0, 0);
-	} else if (len == 1) {
-		r = dsi_vc_send_short(dsi, channel,
-				type == DSS_DSI_CONTENT_GENERIC ?
-				MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM :
-				MIPI_DSI_DCS_SHORT_WRITE, data[0], 0);
-	} else if (len == 2) {
-		r = dsi_vc_send_short(dsi, channel,
-				type == DSS_DSI_CONTENT_GENERIC ?
-				MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM :
-				MIPI_DSI_DCS_SHORT_WRITE_PARAM,
-				data[0] | (data[1] << 8), 0);
-	} else {
-		r = dsi_vc_send_long(dsi, channel,
-				type == DSS_DSI_CONTENT_GENERIC ?
-				MIPI_DSI_GENERIC_LONG_WRITE :
-				MIPI_DSI_DCS_LONG_WRITE, data, len, 0);
-	}
-
-	return r;
-}
-
-static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
-		const u8 *data, int len)
+static int dsi_vc_write_common(struct omap_dss_device *dssdev,
+			       const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
+	struct mipi_dsi_packet packet;
+	int r;
 
-	return dsi_vc_write_nosync_common(dsi, channel, data, len,
-			DSS_DSI_CONTENT_DCS);
-}
+	r = mipi_dsi_create_packet(&packet, msg);
+	if (r < 0)
+		return r;
 
-static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int channel,
-		const u8 *data, int len)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
+	if (mipi_dsi_packet_format_is_short(msg->type)) {
+		u16 data = packet.header[1] | (packet.header[2] << 8);
 
-	return dsi_vc_write_nosync_common(dsi, channel, data, len,
-			DSS_DSI_CONTENT_GENERIC);
-}
+		r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
+	} else {
+		r = dsi_vc_send_long(dsi, msg->channel, msg->type,
+				     msg->tx_buf, msg->tx_len, 0);
+	}
 
-static int dsi_vc_write_common(struct omap_dss_device *dssdev,
-			       int channel, const u8 *data, int len,
-			       enum dss_dsi_content_type type)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-	int r;
+	if (r < 0)
+		return r;
 
-	r = dsi_vc_write_nosync_common(dsi, channel, data, len, type);
-	if (r)
-		goto err;
+	/*
+	 * TODO: we do not always have to do the BTA sync, for example
+	 * we can improve performance by setting the update window
+	 * information without sending BTA sync between the commands.
+	 * In that case we can return early.
+	 */
 
-	r = dsi_vc_send_bta_sync(dssdev, channel);
-	if (r)
-		goto err;
+	r = dsi_vc_send_bta_sync(dssdev, msg->channel);
+	if (r) {
+		DSSERR("bta sync failed\n");
+		return r;
+	}
 
 	/* RX_FIFO_NOT_EMPTY */
-	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
+	if (REG_GET(dsi, DSI_VC_CTRL(msg->channel), 20, 20)) {
 		DSSERR("rx fifo not empty after write, dumping data:\n");
-		dsi_vc_flush_receive_data(dsi, channel);
-		r = -EIO;
-		goto err;
+		dsi_vc_flush_receive_data(dsi, msg->channel);
+		return -EIO;
 	}
 
 	return 0;
-err:
-	DSSERR("dsi_vc_write_common(ch %d, cmd 0x%02x, len %d) failed\n",
-			channel, data[0], len);
-	return r;
-}
-
-static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel,
-		const u8 *data, int len)
-{
-	return dsi_vc_write_common(dssdev, channel, data, len,
-			DSS_DSI_CONTENT_DCS);
-}
-
-static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel,
-		const u8 *data, int len)
-{
-	return dsi_vc_write_common(dssdev, channel, data, len,
-			DSS_DSI_CONTENT_GENERIC);
 }
 
 static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel,
@@ -3008,15 +2961,6 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
 	return 0;
 }
 
-static int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel,
-		u16 len)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	return dsi_vc_send_short(dsi, channel,
-			MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, len, 0);
-}
-
 static int dsi_enter_ulps(struct dsi_data *dsi)
 {
 	DECLARE_COMPLETION_ONSTACK(completion);
@@ -4817,36 +4761,17 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
 static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev,
 				 const struct mipi_dsi_msg *msg)
 {
-	/*
-	 * TODO: no_sync can be used to optimize performance by sending e.g.
-	 * column and page information without syncing in between. It's not
-	 * absolutely required, so postpone this feature for now.
-	 */
-	bool no_sync = false;
-	u16 val;
-
 	switch (msg->type) {
 	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:
-		if (no_sync)
-			return dsi_vc_generic_write_nosync(dssdev, msg->channel,
-							   msg->tx_buf,
-							   msg->tx_len);
-		else
-			return dsi_vc_generic_write(dssdev, msg->channel,
-						    msg->tx_buf, msg->tx_len);
 	case MIPI_DSI_DCS_SHORT_WRITE:
 	case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
 	case MIPI_DSI_DCS_LONG_WRITE:
-		if (no_sync)
-			return dsi_vc_dcs_write_nosync(dssdev, msg->channel,
-						       msg->tx_buf,
-						       msg->tx_len);
-		else
-			return dsi_vc_dcs_write(dssdev, msg->channel,
-						msg->tx_buf, msg->tx_len);
+	case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
+	case MIPI_DSI_NULL_PACKET:
+		return dsi_vc_write_common(dssdev, msg);
 	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
@@ -4857,11 +4782,6 @@ static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev,
 		return dsi_vc_dcs_read(dssdev, msg->channel,
 				       ((u8 *)msg->tx_buf)[0],
 				       msg->rx_buf, msg->rx_len);
-	case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
-		val = le16_to_cpu(*((__le16 *)msg->tx_buf));
-		return dsi_vc_set_max_rx_packet_size(dssdev, msg->channel, val);
-	case MIPI_DSI_NULL_PACKET:
-		return dsi_vc_send_null(to_dsi_data(dssdev), msg->channel);
 	}
 
 	return -EINVAL;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 10/80] drm/omap: dsi: simplify read functions
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (8 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 09/80] drm/omap: dsi: simplify write function Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 11/80] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg Tomi Valkeinen
                   ` (70 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Simplify the read related message handling by using the functionality
provided by CONFIG_DRM_MIPI_DSI.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 110 +++++++++---------------------
 1 file changed, 34 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index e1595c0608f2..bbdc52ee3559 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2742,60 +2742,6 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev,
 	return 0;
 }
 
-static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel,
-					u8 dcs_cmd)
-{
-	int r;
-
-	if (dsi->debug_read)
-		DSSDBG("dsi_vc_dcs_send_read_request(ch%d, dcs_cmd %x)\n",
-			channel, dcs_cmd);
-
-	r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
-	if (r) {
-		DSSERR("dsi_vc_dcs_send_read_request(ch %d, cmd 0x%02x)"
-			" failed\n", channel, dcs_cmd);
-		return r;
-	}
-
-	return 0;
-}
-
-static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel,
-					    const u8 *reqdata, int reqlen)
-{
-	u16 data;
-	u8 data_type;
-	int r;
-
-	if (dsi->debug_read)
-		DSSDBG("dsi_vc_generic_send_read_request(ch %d, reqlen %d)\n",
-			channel, reqlen);
-
-	if (reqlen == 0) {
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
-		data = 0;
-	} else if (reqlen == 1) {
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
-		data = reqdata[0];
-	} else if (reqlen == 2) {
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
-		data = reqdata[0] | (reqdata[1] << 8);
-	} else {
-		BUG();
-		return -EINVAL;
-	}
-
-	r = dsi_vc_send_short(dsi, channel, data_type, data, 0);
-	if (r) {
-		DSSERR("dsi_vc_generic_send_read_request(ch %d, reqlen %d)"
-			" failed\n", channel, reqlen);
-		return r;
-	}
-
-	return 0;
-}
-
 static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
 			       int buflen, enum dss_dsi_content_type type)
 {
@@ -2904,13 +2850,18 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
 	return r;
 }
 
-static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
-		u8 *buf, int buflen)
+static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
+			   const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
+	u8 dcs_cmd = ((u8 *)msg->tx_buf)[0];
+	u8 channel = msg->channel;
 	int r;
 
-	r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
+	if (dsi->debug_read)
+		DSSDBG("%s(ch %d, cmd %x)\n", __func__, channel, dcs_cmd);
+
+	r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
 	if (r)
 		goto err;
 
@@ -2918,47 +2869,58 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c
 	if (r)
 		goto err;
 
-	r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
+	r = dsi_vc_read_rx_fifo(dsi, channel, msg->rx_buf, msg->rx_len,
 		DSS_DSI_CONTENT_DCS);
 	if (r < 0)
 		goto err;
 
-	if (r != buflen) {
+	if (r != msg->rx_len) {
 		r = -EIO;
 		goto err;
 	}
 
 	return 0;
 err:
-	DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n", channel, dcs_cmd);
+	DSSERR("%s(ch %d, cmd 0x%02x) failed\n", __func__, msg->channel, dcs_cmd);
 	return r;
 }
 
-static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
-		const u8 *reqdata, int reqlen, u8 *buf, int buflen)
+static int dsi_vc_generic_read(struct omap_dss_device *dssdev,
+			       const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
+	struct mipi_dsi_packet packet;
+	u16 data;
 	int r;
 
-	r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen);
+	r = mipi_dsi_create_packet(&packet, msg);
+	if (r < 0)
+		goto err;
+
+	data = packet.header[1] | (packet.header[2] << 8);
+
+	r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
 	if (r)
-		return r;
+		goto err;
 
-	r = dsi_vc_send_bta_sync(dssdev, channel);
+	r = dsi_vc_send_bta_sync(dssdev, msg->channel);
 	if (r)
-		return r;
+		goto err;
 
-	r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen,
+	r = dsi_vc_read_rx_fifo(dsi, msg->channel, msg->rx_buf, msg->rx_len,
 		DSS_DSI_CONTENT_GENERIC);
 	if (r < 0)
-		return r;
+		goto err;
 
-	if (r != buflen) {
+	if (r != msg->rx_len) {
 		r = -EIO;
-		return r;
+		goto err;
 	}
 
 	return 0;
+err:
+	DSSERR("%s(ch %d, reqlen %d) failed\n", __func__,  msg->channel, msg->tx_len);
+	return r;
 }
 
 static int dsi_enter_ulps(struct dsi_data *dsi)
@@ -4775,13 +4737,9 @@ static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev,
 	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
-		return dsi_vc_generic_read(dssdev, msg->channel,
-					   msg->tx_buf, msg->tx_len,
-					   msg->rx_buf, msg->rx_len);
+		return dsi_vc_generic_read(dssdev, msg);
 	case MIPI_DSI_DCS_READ:
-		return dsi_vc_dcs_read(dssdev, msg->channel,
-				       ((u8 *)msg->tx_buf)[0],
-				       msg->rx_buf, msg->rx_len);
+		return dsi_vc_dcs_read(dssdev, msg);
 	}
 
 	return -EINVAL;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 11/80] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (9 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 10/80] drm/omap: dsi: simplify read functions Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 12/80] drm/omap: dsi: introduce mipi_dsi_host Tomi Valkeinen
                   ` (69 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Simplify the DSI encoder by using mipi_dsi_msg for
dsi_vc_send_long and dsi_vc_send_short. Further improvements
require cleaning up the channel allocation code first.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 88 ++++++++++++++-----------------
 1 file changed, 39 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index bbdc52ee3559..b055840b8513 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2599,8 +2599,8 @@ static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel,
 	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
 }
 
-static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
-			    const u8 *data, u16 len, u8 ecc)
+static int dsi_vc_send_long(struct dsi_data *dsi,
+			    const struct mipi_dsi_msg *msg)
 {
 	/*u32 val; */
 	int i;
@@ -2609,20 +2609,20 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
 	u8 b1, b2, b3, b4;
 
 	if (dsi->debug_write)
-		DSSDBG("dsi_vc_send_long, %d bytes\n", len);
+		DSSDBG("dsi_vc_send_long, %d bytes\n", msg->tx_len);
 
 	/* len + header */
-	if (dsi->vc[channel].tx_fifo_size * 32 * 4 < len + 4) {
+	if (dsi->vc[msg->channel].tx_fifo_size * 32 * 4 < msg->tx_len + 4) {
 		DSSERR("unable to send long packet: packet too long.\n");
 		return -EINVAL;
 	}
 
-	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
+	dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
 
-	dsi_vc_write_long_header(dsi, channel, data_type, len, ecc);
+	dsi_vc_write_long_header(dsi, msg->channel, msg->type, msg->tx_len, 0);
 
-	p = data;
-	for (i = 0; i < len >> 2; i++) {
+	p = msg->tx_buf;
+	for (i = 0; i < msg->tx_len >> 2; i++) {
 		if (dsi->debug_write)
 			DSSDBG("\tsending full packet %d\n", i);
 
@@ -2631,10 +2631,10 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
 		b3 = *p++;
 		b4 = *p++;
 
-		dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, b4);
+		dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, b4);
 	}
 
-	i = len % 4;
+	i = msg->tx_len % 4;
 	if (i) {
 		b1 = 0; b2 = 0; b3 = 0;
 
@@ -2656,65 +2656,63 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type,
 			break;
 		}
 
-		dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, 0);
+		dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, 0);
 	}
 
 	return r;
 }
 
-static int dsi_vc_send_short(struct dsi_data *dsi, int channel, u8 data_type,
-			     u16 data, u8 ecc)
+static int dsi_vc_send_short(struct dsi_data *dsi,
+			     const struct mipi_dsi_msg *msg)
 {
+	struct mipi_dsi_packet pkt;
 	u32 r;
-	u8 data_id;
+
+	r = mipi_dsi_create_packet(&pkt, msg);
+	if (r < 0)
+		return r;
 
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	if (dsi->debug_write)
 		DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
-				channel,
-				data_type, data & 0xff, (data >> 8) & 0xff);
+		       msg->channel, msg->type, pkt.header[1], pkt.header[2]);
 
-	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4);
+	dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
 
-	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(channel)), 16, 16)) {
+	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(msg->channel)), 16, 16)) {
 		DSSERR("ERROR FIFO FULL, aborting transfer\n");
 		return -EINVAL;
 	}
 
-	data_id = data_type | channel << 6;
-
-	r = (data_id << 0) | (data << 8) | (ecc << 24);
+	r = pkt.header[3] << 24 | pkt.header[2] << 16 | pkt.header[1] << 8 |
+	    pkt.header[0];
 
-	dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel), r);
+	dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(msg->channel), r);
 
 	return 0;
 }
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
 {
-	return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0);
+	const struct mipi_dsi_msg msg = {
+		.channel = channel,
+		.type = MIPI_DSI_NULL_PACKET,
+	};
+
+	return dsi_vc_send_long(dsi, &msg);
 }
 
 static int dsi_vc_write_common(struct omap_dss_device *dssdev,
 			       const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	struct mipi_dsi_packet packet;
 	int r;
 
-	r = mipi_dsi_create_packet(&packet, msg);
-	if (r < 0)
-		return r;
-
-	if (mipi_dsi_packet_format_is_short(msg->type)) {
-		u16 data = packet.header[1] | (packet.header[2] << 8);
-
-		r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
-	} else {
-		r = dsi_vc_send_long(dsi, msg->channel, msg->type,
-				     msg->tx_buf, msg->tx_len, 0);
-	}
+	if (mipi_dsi_packet_format_is_short(msg->type))
+		r = dsi_vc_send_short(dsi, msg);
+	else
+		r = dsi_vc_send_long(dsi, msg);
 
 	if (r < 0)
 		return r;
@@ -2854,14 +2852,14 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
 			   const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	u8 dcs_cmd = ((u8 *)msg->tx_buf)[0];
+	u8 cmd = ((u8 *)msg->tx_buf)[0];
 	u8 channel = msg->channel;
 	int r;
 
 	if (dsi->debug_read)
-		DSSDBG("%s(ch %d, cmd %x)\n", __func__, channel, dcs_cmd);
+		DSSDBG("%s(ch %d, cmd %x)\n", __func__, channel, cmd);
 
-	r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
+	r = dsi_vc_send_short(dsi, msg);
 	if (r)
 		goto err;
 
@@ -2881,7 +2879,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
 
 	return 0;
 err:
-	DSSERR("%s(ch %d, cmd 0x%02x) failed\n", __func__, msg->channel, dcs_cmd);
+	DSSERR("%s(ch %d, cmd 0x%02x) failed\n", __func__,  msg->channel, cmd);
 	return r;
 }
 
@@ -2889,17 +2887,9 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev,
 			       const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	struct mipi_dsi_packet packet;
-	u16 data;
 	int r;
 
-	r = mipi_dsi_create_packet(&packet, msg);
-	if (r < 0)
-		goto err;
-
-	data = packet.header[1] | (packet.header[2] << 8);
-
-	r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
+	r = dsi_vc_send_short(dsi, msg);
 	if (r)
 		goto err;
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 12/80] drm/omap: dsi: introduce mipi_dsi_host
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (10 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 11/80] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 13/80] drm/omap: panel-dsi-cm: use DSI helpers Tomi Valkeinen
                   ` (68 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This moves from custom platform driver infrastructure to mipi_dsi_host
and mipi_dsi_device. Note, that this is a graduate step and the driver
only uses the devices types and transfer function, but not yet the new
device binding style or drm_panel.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 121 +++++++++---------
 drivers/gpu/drm/omapdrm/dss/dsi.c             |  53 ++++++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |   4 -
 3 files changed, 102 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ea76a89d1833..c3190223d192 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -14,7 +14,6 @@
 #include <linux/interrupt.h>
 #include <linux/jiffies.h>
 #include <linux/module.h>
-#include <linux/platform_device.h>
 #include <linux/sched/signal.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
@@ -39,13 +38,13 @@
 #define DCS_GET_ID3		0xdc
 
 struct panel_drv_data {
+	struct mipi_dsi_device *dsi;
+
 	struct omap_dss_device dssdev;
 	struct omap_dss_device *src;
 
 	struct videomode vm;
 
-	struct platform_device *pdev;
-
 	struct mutex lock;
 
 	struct backlight_device *bldev;
@@ -139,7 +138,7 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
-	struct omap_dss_device *src = ddata->src;
+	struct mipi_dsi_device *dsi = ddata->dsi;
 	const struct mipi_dsi_msg msg = {
 		.channel = ddata->channel,
 		.type = MIPI_DSI_DCS_READ,
@@ -149,12 +148,12 @@ static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 		.rx_buf = data
 	};
 
-	return src->ops->dsi.transfer(src, &msg);
+	return dsi->host->ops->transfer(dsi->host, &msg);
 }
 
 static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
 {
-	struct omap_dss_device *src = ddata->src;
+	struct mipi_dsi_device *dsi = ddata->dsi;
 	const struct mipi_dsi_msg msg = {
 		.channel = ddata->channel,
 		.type = MIPI_DSI_DCS_SHORT_WRITE,
@@ -162,12 +161,12 @@ static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
 		.tx_len = 1,
 	};
 
-	return src->ops->dsi.transfer(src, &msg);
+	return dsi->host->ops->transfer(dsi->host, &msg);
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
 {
-	struct omap_dss_device *src = ddata->src;
+	struct mipi_dsi_device *dsi = ddata->dsi;
 	const u8 buf[] = { dcs_cmd, param };
 	const struct mipi_dsi_msg msg = {
 		.channel = ddata->channel,
@@ -176,13 +175,13 @@ static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
 		.tx_len = 2,
 	};
 
-	return src->ops->dsi.transfer(src, &msg);
+	return dsi->host->ops->transfer(dsi->host, &msg);
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
-	struct omap_dss_device *src = ddata->src;
+	struct mipi_dsi_device *dsi = ddata->dsi;
 	int r;
 	const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
 	const struct mipi_dsi_msg msg = {
@@ -194,7 +193,7 @@ static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 	hw_guard_wait(ddata);
 
-	r = src->ops->dsi.transfer(src, &msg);
+	r = dsi->host->ops->transfer(dsi->host, &msg);
 	if (r)
 		return r;
 
@@ -242,7 +241,7 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3)
 static int dsicm_set_update_window(struct panel_drv_data *ddata,
 		u16 x, u16 y, u16 w, u16 h)
 {
-	struct omap_dss_device *src = ddata->src;
+	struct mipi_dsi_device *dsi = ddata->dsi;
 	int r;
 	u16 x1 = x;
 	u16 x2 = x + w - 1;
@@ -279,11 +278,11 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata,
 		.tx_len = 5,
 	};
 
-	r = src->ops->dsi.transfer(src, &msgX);
+	r = dsi->host->ops->transfer(dsi->host, &msgX);
 	if (r)
 		return r;
 
-	r = src->ops->dsi.transfer(src, &msgY);
+	r = dsi->host->ops->transfer(dsi->host, &msgY);
 	if (r)
 		return r;
 
@@ -326,7 +325,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
 	return 0;
 
 err:
-	dev_err(&ddata->pdev->dev, "enter ULPS failed");
+	dev_err(&ddata->dsi->dev, "enter ULPS failed");
 	dsicm_panel_reset(ddata);
 
 	ddata->ulps_enabled = false;
@@ -349,7 +348,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 
 	r = _dsicm_enable_te(ddata, true);
 	if (r) {
-		dev_err(&ddata->pdev->dev, "failed to re-enable TE");
+		dev_err(&ddata->dsi->dev, "failed to re-enable TE");
 		goto err2;
 	}
 
@@ -363,7 +362,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 	return 0;
 
 err2:
-	dev_err(&ddata->pdev->dev, "failed to exit ULPS");
+	dev_err(&ddata->dsi->dev, "failed to exit ULPS");
 
 	r = dsicm_panel_reset(ddata);
 	if (!r) {
@@ -400,7 +399,7 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
 	else
 		level = 0;
 
-	dev_dbg(&ddata->pdev->dev, "update brightness to %d\n", level);
+	dev_dbg(&ddata->dsi->dev, "update brightness to %d\n", level);
 
 	mutex_lock(&ddata->lock);
 
@@ -637,7 +636,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (ddata->vpnl) {
 		r = regulator_enable(ddata->vpnl);
 		if (r) {
-			dev_err(&ddata->pdev->dev,
+			dev_err(&ddata->dsi->dev,
 				"failed to enable VPNL: %d\n", r);
 			return r;
 		}
@@ -646,7 +645,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (ddata->vddi) {
 		r = regulator_enable(ddata->vddi);
 		if (r) {
-			dev_err(&ddata->pdev->dev,
+			dev_err(&ddata->dsi->dev,
 				"failed to enable VDDI: %d\n", r);
 			goto err_vpnl;
 		}
@@ -654,7 +653,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
 	r = src->ops->dsi.set_config(src, &dsi_config);
 	if (r) {
-		dev_err(&ddata->pdev->dev, "failed to configure DSI\n");
+		dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
 		goto err_vddi;
 	}
 
@@ -701,7 +700,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	ddata->enabled = true;
 
 	if (!ddata->intro_printed) {
-		dev_info(&ddata->pdev->dev, "panel revision %02x.%02x.%02x\n",
+		dev_info(&ddata->dsi->dev, "panel revision %02x.%02x.%02x\n",
 			id1, id2, id3);
 		ddata->intro_printed = true;
 	}
@@ -710,7 +709,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
 	return 0;
 err:
-	dev_err(&ddata->pdev->dev, "error while enabling panel, issuing HW reset\n");
+	dev_err(&ddata->dsi->dev, "error while enabling panel, issuing HW reset\n");
 
 	dsicm_hw_reset(ddata);
 
@@ -737,7 +736,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 		r = dsicm_sleep_in(ddata);
 
 	if (r) {
-		dev_err(&ddata->pdev->dev,
+		dev_err(&ddata->dsi->dev,
 				"error disabling panel, issuing HW reset\n");
 		dsicm_hw_reset(ddata);
 	}
@@ -754,7 +753,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 
 static int dsicm_panel_reset(struct panel_drv_data *ddata)
 {
-	dev_err(&ddata->pdev->dev, "performing LCD reset\n");
+	dev_err(&ddata->dsi->dev, "performing LCD reset\n");
 
 	dsicm_power_off(ddata);
 	dsicm_hw_reset(ddata);
@@ -765,7 +764,7 @@ static int dsicm_connect(struct omap_dss_device *src,
 			 struct omap_dss_device *dst)
 {
 	struct panel_drv_data *ddata = to_panel_data(dst);
-	struct device *dev = &ddata->pdev->dev;
+	struct device *dev = &ddata->dsi->dev;
 	int r;
 
 	r = src->ops->dsi.request_vc(src, ddata->channel);
@@ -810,7 +809,7 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 
 	return;
 err:
-	dev_dbg(&ddata->pdev->dev, "enable failed (%d)\n", r);
+	dev_dbg(&ddata->dsi->dev, "enable failed (%d)\n", r);
 	mutex_unlock(&ddata->lock);
 }
 
@@ -842,7 +841,7 @@ static void dsicm_framedone_cb(int err, void *data)
 	struct panel_drv_data *ddata = data;
 	struct omap_dss_device *src = ddata->src;
 
-	dev_dbg(&ddata->pdev->dev, "framedone, err %d\n", err);
+	dev_dbg(&ddata->dsi->dev, "framedone, err %d\n", err);
 	src->ops->dsi.bus_unlock(src);
 }
 
@@ -866,7 +865,7 @@ static irqreturn_t dsicm_te_isr(int irq, void *data)
 
 	return IRQ_HANDLED;
 err:
-	dev_err(&ddata->pdev->dev, "start update failed\n");
+	dev_err(&ddata->dsi->dev, "start update failed\n");
 	src->ops->dsi.bus_unlock(src);
 	return IRQ_HANDLED;
 }
@@ -877,7 +876,7 @@ static void dsicm_te_timeout_work_callback(struct work_struct *work)
 					te_timeout_work.work);
 	struct omap_dss_device *src = ddata->src;
 
-	dev_err(&ddata->pdev->dev, "TE not received for 250ms!\n");
+	dev_err(&ddata->dsi->dev, "TE not received for 250ms!\n");
 
 	atomic_set(&ddata->do_update, 0);
 	src->ops->dsi.bus_unlock(src);
@@ -890,7 +889,7 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 	struct omap_dss_device *src = ddata->src;
 	int r;
 
-	dev_dbg(&ddata->pdev->dev, "update %d, %d, %d x %d\n", x, y, w, h);
+	dev_dbg(&ddata->dsi->dev, "update %d, %d, %d x %d\n", x, y, w, h);
 
 	mutex_lock(&ddata->lock);
 	src->ops->dsi.bus_lock(src);
@@ -935,14 +934,14 @@ static int dsicm_sync(struct omap_dss_device *dssdev)
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct omap_dss_device *src = ddata->src;
 
-	dev_dbg(&ddata->pdev->dev, "sync\n");
+	dev_dbg(&ddata->dsi->dev, "sync\n");
 
 	mutex_lock(&ddata->lock);
 	src->ops->dsi.bus_lock(src);
 	src->ops->dsi.bus_unlock(src);
 	mutex_unlock(&ddata->lock);
 
-	dev_dbg(&ddata->pdev->dev, "sync done\n");
+	dev_dbg(&ddata->dsi->dev, "sync done\n");
 
 	return 0;
 }
@@ -1019,7 +1018,7 @@ static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
 					u16 size)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *src = ddata->src;
+	struct mipi_dsi_device *dsi = ddata->dsi;
 
 	const u8 buf[] = {
 		size & 0xff,
@@ -1033,7 +1032,7 @@ static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
 		.tx_len = 2,
 	};
 
-	return src->ops->dsi.transfer(src, &msg);
+	return dsi->host->ops->transfer(dsi->host, &msg);
 }
 
 static int dsicm_memory_read(struct omap_dss_device *dssdev,
@@ -1041,6 +1040,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
 		u16 x, u16 y, u16 w, u16 h)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct mipi_dsi_device *dsi = ddata->dsi;
 	struct omap_dss_device *src = ddata->src;
 	int r;
 	int first = 1;
@@ -1092,7 +1092,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
 		};
 		first = 0;
 
-		r = src->ops->dsi.transfer(src, &msg);
+		r = dsi->host->ops->transfer(dsi->host, &msg);
 		if (r < 0) {
 			dev_err(dssdev->dev, "read error\n");
 			goto err3;
@@ -1101,12 +1101,12 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
 		buf_used += r;
 
 		if (r < plen) {
-			dev_err(&ddata->pdev->dev, "short read\n");
+			dev_err(&ddata->dsi->dev, "short read\n");
 			break;
 		}
 
 		if (signal_pending(current)) {
-			dev_err(&ddata->pdev->dev, "signal pending, "
+			dev_err(&ddata->dsi->dev, "signal pending, "
 					"aborting memory read\n");
 			r = -ERESTARTSYS;
 			goto err3;
@@ -1200,28 +1200,28 @@ static const struct omap_dss_driver dsicm_dss_driver = {
 	.memory_read	= dsicm_memory_read,
 };
 
-static int dsicm_probe_of(struct platform_device *pdev)
+static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 {
-	struct device_node *node = pdev->dev.of_node;
+	struct device_node *node = dsi->dev.of_node;
 	struct backlight_device *backlight;
-	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
 	struct display_timing timing;
 	int err;
 
 	ddata->channel = TCH;
 
-	ddata->reset_gpio = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
+	ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ddata->reset_gpio)) {
 		err = PTR_ERR(ddata->reset_gpio);
-		dev_err(&pdev->dev, "reset gpio request failed: %d", err);
+		dev_err(&dsi->dev, "reset gpio request failed: %d", err);
 		return err;
 	}
 
-	ddata->ext_te_gpio = devm_gpiod_get_optional(&pdev->dev, "te",
+	ddata->ext_te_gpio = devm_gpiod_get_optional(&dsi->dev, "te",
 						     GPIOD_IN);
 	if (IS_ERR(ddata->ext_te_gpio)) {
 		err = PTR_ERR(ddata->ext_te_gpio);
-		dev_err(&pdev->dev, "TE gpio request failed: %d", err);
+		dev_err(&dsi->dev, "TE gpio request failed: %d", err);
 		return err;
 	}
 
@@ -1232,7 +1232,7 @@ static int dsicm_probe_of(struct platform_device *pdev)
 			ddata->vm.pixelclock =
 				ddata->vm.hactive * ddata->vm.vactive * 60;
 	} else {
-		dev_warn(&pdev->dev,
+		dev_warn(&dsi->dev,
 			 "failed to get video timing, using defaults\n");
 	}
 
@@ -1242,7 +1242,7 @@ static int dsicm_probe_of(struct platform_device *pdev)
 	ddata->height_mm = 0;
 	of_property_read_u32(node, "height-mm", &ddata->height_mm);
 
-	ddata->vpnl = devm_regulator_get_optional(&pdev->dev, "vpnl");
+	ddata->vpnl = devm_regulator_get_optional(&dsi->dev, "vpnl");
 	if (IS_ERR(ddata->vpnl)) {
 		err = PTR_ERR(ddata->vpnl);
 		if (err == -EPROBE_DEFER)
@@ -1250,7 +1250,7 @@ static int dsicm_probe_of(struct platform_device *pdev)
 		ddata->vpnl = NULL;
 	}
 
-	ddata->vddi = devm_regulator_get_optional(&pdev->dev, "vddi");
+	ddata->vddi = devm_regulator_get_optional(&dsi->dev, "vddi");
 	if (IS_ERR(ddata->vddi)) {
 		err = PTR_ERR(ddata->vddi);
 		if (err == -EPROBE_DEFER)
@@ -1258,7 +1258,7 @@ static int dsicm_probe_of(struct platform_device *pdev)
 		ddata->vddi = NULL;
 	}
 
-	backlight = devm_of_find_backlight(&pdev->dev);
+	backlight = devm_of_find_backlight(&dsi->dev);
 	if (IS_ERR(backlight))
 		return PTR_ERR(backlight);
 
@@ -1273,11 +1273,11 @@ static int dsicm_probe_of(struct platform_device *pdev)
 	return 0;
 }
 
-static int dsicm_probe(struct platform_device *pdev)
+static int dsicm_probe(struct mipi_dsi_device *dsi)
 {
 	struct panel_drv_data *ddata;
 	struct backlight_device *bldev = NULL;
-	struct device *dev = &pdev->dev;
+	struct device *dev = &dsi->dev;
 	struct omap_dss_device *dssdev;
 	int r;
 
@@ -1287,14 +1287,14 @@ static int dsicm_probe(struct platform_device *pdev)
 	if (!ddata)
 		return -ENOMEM;
 
-	platform_set_drvdata(pdev, ddata);
-	ddata->pdev = pdev;
+	mipi_dsi_set_drvdata(dsi, ddata);
+	ddata->dsi = dsi;
 
 	ddata->vm.hactive = 864;
 	ddata->vm.vactive = 480;
 	ddata->vm.pixelclock = 864 * 480 * 60;
 
-	r = dsicm_probe_of(pdev);
+	r = dsicm_probe_of(dsi);
 	if (r)
 		return r;
 
@@ -1376,12 +1376,12 @@ static int dsicm_probe(struct platform_device *pdev)
 	return r;
 }
 
-static int __exit dsicm_remove(struct platform_device *pdev)
+static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
 {
-	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
 
-	dev_dbg(&pdev->dev, "remove\n");
+	dev_dbg(&dsi->dev, "remove\n");
 
 	omapdss_device_unregister(dssdev);
 
@@ -1389,7 +1389,7 @@ static int __exit dsicm_remove(struct platform_device *pdev)
 		dsicm_disable(dssdev);
 	omapdss_device_disconnect(ddata->src, dssdev);
 
-	sysfs_remove_group(&pdev->dev.kobj, &dsicm_attr_group);
+	sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
 
 	if (ddata->extbldev)
 		put_device(&ddata->extbldev->dev);
@@ -1410,7 +1410,7 @@ static const struct of_device_id dsicm_of_match[] = {
 
 MODULE_DEVICE_TABLE(of, dsicm_of_match);
 
-static struct platform_driver dsicm_driver = {
+static struct mipi_dsi_driver dsicm_driver = {
 	.probe = dsicm_probe,
 	.remove = __exit_p(dsicm_remove),
 	.driver = {
@@ -1419,8 +1419,7 @@ static struct platform_driver dsicm_driver = {
 		.suppress_bind_attrs = true,
 	},
 };
-
-module_platform_driver(dsicm_driver);
+module_mipi_dsi_driver(dsicm_driver);
 
 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
 MODULE_DESCRIPTION("Generic DSI Command Mode Panel Driver");
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index b055840b8513..2ba56ca12213 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -334,6 +334,8 @@ struct dsi_data {
 	struct regmap *syscon;
 	struct dss_device *dss;
 
+	struct mipi_dsi_host host;
+
 	struct dispc_clock_info user_dispc_cinfo;
 	struct dss_pll_clock_info user_dsi_cinfo;
 
@@ -432,6 +434,11 @@ static inline struct dsi_data *to_dsi_data(struct omap_dss_device *dssdev)
 	return dev_get_drvdata(dssdev->dev);
 }
 
+static inline struct dsi_data *host_to_omap(struct mipi_dsi_host *host)
+{
+	return container_of(host, struct dsi_data, host);
+}
+
 static inline void dsi_write_reg(struct dsi_data *dsi,
 				 const struct dsi_reg idx, u32 val)
 {
@@ -4710,9 +4717,12 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
 	}
 }
 
-static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev,
-				 const struct mipi_dsi_msg *msg)
+static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
+				      const struct mipi_dsi_msg *msg)
 {
+	struct dsi_data *dsi = host_to_omap(host);
+	struct omap_dss_device *dssdev = &dsi->output;
+
 	switch (msg->type) {
 	case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
 	case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
@@ -4786,11 +4796,29 @@ static const struct omap_dss_device_ops dsi_ops = {
 
 		.request_vc = dsi_request_vc,
 		.release_vc = dsi_release_vc,
-
-		.transfer = omap_dsi_transfer,
 	},
 };
 
+static int omap_dsi_host_attach(struct mipi_dsi_host *host,
+			 struct mipi_dsi_device *dsi)
+{
+	/* TODO: convert driver from custom binding method to this one */
+	return 0;
+}
+
+static int omap_dsi_host_detach(struct mipi_dsi_host *host,
+			 struct mipi_dsi_device *dsi)
+{
+	/* TODO: convert driver from custom binding method to this one */
+	return 0;
+}
+
+static const struct mipi_dsi_host_ops omap_dsi_host_ops = {
+	.attach = omap_dsi_host_attach,
+	.detach = omap_dsi_host_detach,
+	.transfer = omap_dsi_host_transfer,
+};
+
 /* -----------------------------------------------------------------------------
  * PLL
  */
@@ -5259,15 +5287,18 @@ static int dsi_probe(struct platform_device *pdev)
 		dsi->num_lanes_supported = 3;
 	}
 
-	r = of_platform_populate(dev->of_node, NULL, NULL, dev);
-	if (r) {
-		DSSERR("Failed to populate DSI child devices: %d\n", r);
+	dsi->host.ops = &omap_dsi_host_ops;
+	dsi->host.dev = &pdev->dev;
+
+	r = mipi_dsi_host_register(&dsi->host);
+	if (r < 0) {
+		dev_err(&pdev->dev, "failed to register DSI host: %d\n", r);
 		goto err_pm_disable;
 	}
 
 	r = dsi_init_output(dsi);
 	if (r)
-		goto err_of_depopulate;
+		goto err_dsi_host_unregister;
 
 	r = dsi_probe_of(dsi);
 	if (r) {
@@ -5283,8 +5314,8 @@ static int dsi_probe(struct platform_device *pdev)
 
 err_uninit_output:
 	dsi_uninit_output(dsi);
-err_of_depopulate:
-	of_platform_depopulate(dev);
+err_dsi_host_unregister:
+	mipi_dsi_host_unregister(&dsi->host);
 err_pm_disable:
 	pm_runtime_disable(dev);
 	return r;
@@ -5298,7 +5329,7 @@ static int dsi_remove(struct platform_device *pdev)
 
 	dsi_uninit_output(dsi);
 
-	of_platform_depopulate(&pdev->dev);
+	mipi_dsi_host_unregister(&dsi->host);
 
 	pm_runtime_disable(&pdev->dev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 40e1ce9e256e..8cd2c800922e 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -304,10 +304,6 @@ struct omapdss_dsi_ops {
 
 	int (*request_vc)(struct omap_dss_device *dssdev, int channel);
 	void (*release_vc)(struct omap_dss_device *dssdev, int channel);
-
-	/* data transfer */
-	ssize_t (*transfer)(struct omap_dss_device *dssdev,
-			    const struct mipi_dsi_msg *msg);
 };
 
 struct omap_dss_device_ops {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 13/80] drm/omap: panel-dsi-cm: use DSI helpers
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (11 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 12/80] drm/omap: dsi: introduce mipi_dsi_host Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 14/80] drm/omap: dsi: request VC via mipi_dsi_attach Tomi Valkeinen
                   ` (67 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

After converting the driver to mipi_dsi_device we can use the generic
message helpers to simplify the driver a lot.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 125 +++---------------
 1 file changed, 18 insertions(+), 107 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index c3190223d192..ec36e62ddc3a 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -138,62 +138,22 @@ static void hw_guard_wait(struct panel_drv_data *ddata)
 
 static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
 {
-	struct mipi_dsi_device *dsi = ddata->dsi;
-	const struct mipi_dsi_msg msg = {
-		.channel = ddata->channel,
-		.type = MIPI_DSI_DCS_READ,
-		.tx_len = 1,
-		.tx_buf = &dcs_cmd,
-		.rx_len = 1,
-		.rx_buf = data
-	};
-
-	return dsi->host->ops->transfer(dsi->host, &msg);
-}
-
-static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
-{
-	struct mipi_dsi_device *dsi = ddata->dsi;
-	const struct mipi_dsi_msg msg = {
-		.channel = ddata->channel,
-		.type = MIPI_DSI_DCS_SHORT_WRITE,
-		.tx_buf = &dcs_cmd,
-		.tx_len = 1,
-	};
-
-	return dsi->host->ops->transfer(dsi->host, &msg);
+	return mipi_dsi_dcs_read(ddata->dsi, dcs_cmd, data, 1);
 }
 
 static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param)
 {
-	struct mipi_dsi_device *dsi = ddata->dsi;
-	const u8 buf[] = { dcs_cmd, param };
-	const struct mipi_dsi_msg msg = {
-		.channel = ddata->channel,
-		.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM,
-		.tx_buf = &buf,
-		.tx_len = 2,
-	};
-
-	return dsi->host->ops->transfer(dsi->host, &msg);
+	return mipi_dsi_dcs_write(ddata->dsi, dcs_cmd, &param, 1);
 }
 
 static int dsicm_sleep_in(struct panel_drv_data *ddata)
 
 {
-	struct mipi_dsi_device *dsi = ddata->dsi;
 	int r;
-	const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE;
-	const struct mipi_dsi_msg msg = {
-		.channel = ddata->channel,
-		.type = MIPI_DSI_DCS_SHORT_WRITE,
-		.tx_buf = &cmd,
-		.tx_len = 1,
-	};
 
 	hw_guard_wait(ddata);
 
-	r = dsi->host->ops->transfer(dsi->host, &msg);
+	r = mipi_dsi_dcs_enter_sleep_mode(ddata->dsi);
 	if (r)
 		return r;
 
@@ -210,7 +170,7 @@ static int dsicm_sleep_out(struct panel_drv_data *ddata)
 
 	hw_guard_wait(ddata);
 
-	r = dsicm_dcs_write_0(ddata, MIPI_DCS_EXIT_SLEEP_MODE);
+	r = mipi_dsi_dcs_exit_sleep_mode(ddata->dsi);
 	if (r)
 		return r;
 
@@ -248,45 +208,15 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata,
 	u16 y1 = y;
 	u16 y2 = y + h - 1;
 
-	const u8 paramX[] = {
-		MIPI_DCS_SET_COLUMN_ADDRESS,
-		(x1 >> 8) & 0xff,
-		(x1 >> 0) & 0xff,
-		(x2 >> 8) & 0xff,
-		(x2 >> 0) & 0xff,
-	};
-
-	const struct mipi_dsi_msg msgX = {
-		.channel = ddata->channel,
-		.type = MIPI_DSI_GENERIC_LONG_WRITE,
-		.tx_buf = paramX,
-		.tx_len = 5,
-	};
-
-	const u8 paramY[] = {
-		MIPI_DCS_SET_PAGE_ADDRESS,
-		(y1 >> 8) & 0xff,
-		(y1 >> 0) & 0xff,
-		(y2 >> 8) & 0xff,
-		(y2 >> 0) & 0xff,
-	};
-
-	const struct mipi_dsi_msg msgY = {
-		.channel = ddata->channel,
-		.type = MIPI_DSI_GENERIC_LONG_WRITE,
-		.tx_buf = paramY,
-		.tx_len = 5,
-	};
-
-	r = dsi->host->ops->transfer(dsi->host, &msgX);
-	if (r)
+	r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
+	if (r < 0)
 		return r;
 
-	r = dsi->host->ops->transfer(dsi->host, &msgY);
-	if (r)
+	r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
+	if (r < 0)
 		return r;
 
-	return r;
+	return 0;
 }
 
 static void dsicm_queue_ulps_work(struct panel_drv_data *ddata)
@@ -680,12 +610,11 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
-	r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_PIXEL_FORMAT,
-		MIPI_DCS_PIXEL_FMT_24BIT);
+	r = mipi_dsi_dcs_set_pixel_format(ddata->dsi, MIPI_DCS_PIXEL_FMT_24BIT);
 	if (r)
 		goto err;
 
-	r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_DISPLAY_ON);
+	r = mipi_dsi_dcs_set_display_on(ddata->dsi);
 	if (r)
 		goto err;
 
@@ -731,7 +660,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 
 	src->ops->dsi.disable_video_output(src, ddata->channel);
 
-	r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_DISPLAY_OFF);
+	r = mipi_dsi_dcs_set_display_off(ddata->dsi);
 	if (!r)
 		r = dsicm_sleep_in(ddata);
 
@@ -949,12 +878,13 @@ static int dsicm_sync(struct omap_dss_device *dssdev)
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
 	struct omap_dss_device *src = ddata->src;
+	struct mipi_dsi_device *dsi = ddata->dsi;
 	int r;
 
 	if (enable)
-		r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_TEAR_ON, 0);
+		r = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
 	else
-		r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_TEAR_OFF);
+		r = mipi_dsi_dcs_set_tear_off(dsi);
 
 	if (!ddata->ext_te_gpio)
 		src->ops->dsi.enable_te(src, enable);
@@ -1020,19 +950,7 @@ static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
 	struct mipi_dsi_device *dsi = ddata->dsi;
 
-	const u8 buf[] = {
-		size & 0xff,
-		size >> 8 & 0xff,
-	};
-
-	const struct mipi_dsi_msg msg = {
-		.channel = ddata->channel,
-		.type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE,
-		.tx_buf = buf,
-		.tx_len = 2,
-	};
-
-	return dsi->host->ops->transfer(dsi->host, &msg);
+	return mipi_dsi_set_maximum_return_packet_size(dsi, size);
 }
 
 static int dsicm_memory_read(struct omap_dss_device *dssdev,
@@ -1082,17 +1000,10 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev,
 
 	while (buf_used < size) {
 		u8 dcs_cmd = first ? 0x2e : 0x3e;
-		const struct mipi_dsi_msg msg = {
-			.channel = ddata->channel,
-			.type = MIPI_DSI_DCS_READ,
-			.tx_buf = &dcs_cmd,
-			.tx_len = 1,
-			.rx_buf = buf + buf_used,
-			.rx_len = size - buf_used,
-		};
 		first = 0;
 
-		r = dsi->host->ops->transfer(dsi->host, &msg);
+		r = mipi_dsi_dcs_read(dsi, dcs_cmd,
+				      buf + buf_used, size - buf_used);
 		if (r < 0) {
 			dev_err(dssdev->dev, "read error\n");
 			goto err3;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 14/80] drm/omap: dsi: request VC via mipi_dsi_attach
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (12 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 13/80] drm/omap: panel-dsi-cm: use DSI helpers Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 15/80] drm/omap: panel-dsi-cm: drop hardcoded VC Tomi Valkeinen
                   ` (66 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Drop custom request_vc/release_vc callbacks by using the
generic mipi_dsi_attach/mipi_dsi_detach functions.

To use mipi_dsi_attach() we need to fill in the mipi_dsi_device fields,
and some of these fields overlap with the fields in omap_dss_dsi_config.
In later patches the latter will get dropped.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 24 +++++---
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 61 ++++++++-----------
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  3 -
 3 files changed, 41 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ec36e62ddc3a..0a8f289176ab 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -693,14 +693,6 @@ static int dsicm_connect(struct omap_dss_device *src,
 			 struct omap_dss_device *dst)
 {
 	struct panel_drv_data *ddata = to_panel_data(dst);
-	struct device *dev = &ddata->dsi->dev;
-	int r;
-
-	r = src->ops->dsi.request_vc(src, ddata->channel);
-	if (r) {
-		dev_err(dev, "failed to get virtual channel\n");
-		return r;
-	}
 
 	ddata->src = src;
 	return 0;
@@ -711,7 +703,6 @@ static void dsicm_disconnect(struct omap_dss_device *src,
 {
 	struct panel_drv_data *ddata = to_panel_data(dst);
 
-	src->ops->dsi.release_vc(src, ddata->channel);
 	ddata->src = NULL;
 }
 
@@ -1276,8 +1267,21 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 		goto err_bl;
 	}
 
+	dsi->lanes = 2;
+	dsi->format = MIPI_DSI_FMT_RGB888;
+	dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |
+			  MIPI_DSI_MODE_EOT_PACKET;
+	dsi->hs_rate = 300000000;
+	dsi->lp_rate = 10000000;
+
+	r = mipi_dsi_attach(dsi);
+	if (r < 0)
+		goto err_dsi_attach;
+
 	return 0;
 
+err_dsi_attach:
+	sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
 err_bl:
 	destroy_workqueue(ddata->workqueue);
 err_reg:
@@ -1294,6 +1298,8 @@ static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
 
 	dev_dbg(&dsi->dev, "remove\n");
 
+	mipi_dsi_detach(dsi);
+
 	omapdss_device_unregister(dssdev);
 
 	if (omapdss_device_is_enabled(dssdev))
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 2ba56ca12213..25d2af1e1a00 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -349,7 +349,7 @@ struct dsi_data {
 
 	struct {
 		enum dsi_vc_source source;
-		struct omap_dss_device *dssdev;
+		struct mipi_dsi_device *dest;
 		enum fifo_size tx_fifo_size;
 		enum fifo_size rx_fifo_size;
 	} vc[4];
@@ -4691,32 +4691,6 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
 	}
 }
 
-static int dsi_request_vc(struct omap_dss_device *dssdev, int channel)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	if (channel < 0 || channel > 3)
-		return -EINVAL;
-
-	if (dsi->vc[channel].dssdev) {
-		DSSERR("cannot get VC for display %s", dssdev->name);
-		return -EBUSY;
-	}
-
-	dsi->vc[channel].dssdev = dssdev;
-	return 0;
-}
-
-static void dsi_release_vc(struct omap_dss_device *dssdev, int channel)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	if ((channel >= 0 && channel <= 3) &&
-		dsi->vc[channel].dssdev == dssdev) {
-		dsi->vc[channel].dssdev = NULL;
-	}
-}
-
 static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 				      const struct mipi_dsi_msg *msg)
 {
@@ -4793,23 +4767,40 @@ static const struct omap_dss_device_ops dsi_ops = {
 		.update = dsi_update,
 
 		.enable_te = dsi_enable_te,
-
-		.request_vc = dsi_request_vc,
-		.release_vc = dsi_release_vc,
 	},
 };
 
 static int omap_dsi_host_attach(struct mipi_dsi_host *host,
-			 struct mipi_dsi_device *dsi)
+				struct mipi_dsi_device *client)
 {
-	/* TODO: convert driver from custom binding method to this one */
+	struct dsi_data *dsi = host_to_omap(host);
+	unsigned int channel = client->channel;
+
+	if (channel > 3)
+		return -EINVAL;
+
+	if (dsi->vc[channel].dest) {
+		DSSERR("cannot get VC for display %s", dev_name(&client->dev));
+		return -EBUSY;
+	}
+
+	dsi->vc[channel].dest = client;
 	return 0;
 }
 
 static int omap_dsi_host_detach(struct mipi_dsi_host *host,
-			 struct mipi_dsi_device *dsi)
+				struct mipi_dsi_device *client)
 {
-	/* TODO: convert driver from custom binding method to this one */
+	struct dsi_data *dsi = host_to_omap(host);
+	unsigned int channel = client->channel;
+
+	if (channel > 3)
+		return -EINVAL;
+
+	if (dsi->vc[channel].dest != client)
+		return -EINVAL;
+
+	dsi->vc[channel].dest = NULL;
 	return 0;
 }
 
@@ -5267,7 +5258,7 @@ static int dsi_probe(struct platform_device *pdev)
 	/* DSI VCs initialization */
 	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
 		dsi->vc[i].source = DSI_VC_SOURCE_L4;
-		dsi->vc[i].dssdev = NULL;
+		dsi->vc[i].dest = NULL;
 	}
 
 	r = dsi_get_clocks(dsi);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 8cd2c800922e..78041ef922cc 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -301,9 +301,6 @@ struct omapdss_dsi_ops {
 	int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
 	void (*disable_video_output)(struct omap_dss_device *dssdev,
 			int channel);
-
-	int (*request_vc)(struct omap_dss_device *dssdev, int channel);
-	void (*release_vc)(struct omap_dss_device *dssdev, int channel);
 };
 
 struct omap_dss_device_ops {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 15/80] drm/omap: panel-dsi-cm: drop hardcoded VC
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (13 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 14/80] drm/omap: dsi: request VC via mipi_dsi_attach Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 16/80] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Tomi Valkeinen
                   ` (65 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Use dsi->channel everywhere, which originates from DT.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 20 +++++++------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 0a8f289176ab..d7d27757b9ae 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -27,9 +27,6 @@
 
 #include "../dss/omapdss.h"
 
-/* DSI Virtual channel. Hardcoded for now. */
-#define TCH 0
-
 #define DCS_READ_NUM_ERRORS	0x05
 #define DCS_BRIGHTNESS		0x51
 #define DCS_CTRL_DISPLAY	0x53
@@ -73,7 +70,6 @@ struct panel_drv_data {
 	bool te_enabled;
 
 	atomic_t do_update;
-	int channel;
 
 	struct delayed_work te_timeout_work;
 
@@ -274,7 +270,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 		return 0;
 
 	src->ops->enable(src);
-	src->ops->dsi.enable_hs(src, ddata->channel, true);
+	src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
 
 	r = _dsicm_enable_te(ddata, true);
 	if (r) {
@@ -591,7 +587,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
 	dsicm_hw_reset(ddata);
 
-	src->ops->dsi.enable_hs(src, ddata->channel, false);
+	src->ops->dsi.enable_hs(src, ddata->dsi->channel, false);
 
 	r = dsicm_sleep_out(ddata);
 	if (r)
@@ -622,7 +618,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
-	r = src->ops->dsi.enable_video_output(src, ddata->channel);
+	r = src->ops->dsi.enable_video_output(src, ddata->dsi->channel);
 	if (r)
 		goto err;
 
@@ -634,7 +630,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 		ddata->intro_printed = true;
 	}
 
-	src->ops->dsi.enable_hs(src, ddata->channel, true);
+	src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
 
 	return 0;
 err:
@@ -658,7 +654,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 	struct omap_dss_device *src = ddata->src;
 	int r;
 
-	src->ops->dsi.disable_video_output(src, ddata->channel);
+	src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
 
 	r = mipi_dsi_dcs_set_display_off(ddata->dsi);
 	if (!r)
@@ -777,7 +773,7 @@ static irqreturn_t dsicm_te_isr(int irq, void *data)
 	if (old) {
 		cancel_delayed_work(&ddata->te_timeout_work);
 
-		r = src->ops->dsi.update(src, ddata->channel, dsicm_framedone_cb,
+		r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
 				ddata);
 		if (r)
 			goto err;
@@ -834,7 +830,7 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 				msecs_to_jiffies(250));
 		atomic_set(&ddata->do_update, 1);
 	} else {
-		r = src->ops->dsi.update(src, ddata->channel, dsicm_framedone_cb,
+		r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
 				ddata);
 		if (r)
 			goto err;
@@ -1110,8 +1106,6 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 	struct display_timing timing;
 	int err;
 
-	ddata->channel = TCH;
-
 	ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ddata->reset_gpio)) {
 		err = PTR_ERR(ddata->reset_gpio);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 16/80] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (14 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 15/80] drm/omap: panel-dsi-cm: drop hardcoded VC Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 17/80] drm/omap: dsi: drop unused memory_read() Tomi Valkeinen
                   ` (64 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Drop local definition of common MIPI DCS 1.3 defines.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index d7d27757b9ae..53cfa86d95db 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -28,8 +28,6 @@
 #include "../dss/omapdss.h"
 
 #define DCS_READ_NUM_ERRORS	0x05
-#define DCS_BRIGHTNESS		0x51
-#define DCS_CTRL_DISPLAY	0x53
 #define DCS_GET_ID1		0xda
 #define DCS_GET_ID2		0xdb
 #define DCS_GET_ID3		0xdc
@@ -334,7 +332,8 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
 
 		r = dsicm_wake_up(ddata);
 		if (!r)
-			r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, level);
+			r = dsicm_dcs_write_1(
+				ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
 
 		src->ops->dsi.bus_unlock(src);
 	}
@@ -597,11 +596,11 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
-	r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, 0xff);
+	r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff);
 	if (r)
 		goto err;
 
-	r = dsicm_dcs_write_1(ddata, DCS_CTRL_DISPLAY,
+	r = dsicm_dcs_write_1(ddata, MIPI_DCS_WRITE_CONTROL_DISPLAY,
 			(1<<2) | (1<<5));	/* BL | BCTRL */
 	if (r)
 		goto err;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 17/80] drm/omap: dsi: drop unused memory_read()
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (15 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 16/80] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 18/80] drm/omap: dsi: drop unused get_te() Tomi Valkeinen
                   ` (63 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

memory_read is not used, so we can drop the code.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 93 -------------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  4 -
 2 files changed, 97 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 53cfa86d95db..6e3fbf99ff91 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -930,97 +930,6 @@ static int dsicm_get_te(struct omap_dss_device *dssdev)
 	return r;
 }
 
-static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev,
-					u16 size)
-{
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct mipi_dsi_device *dsi = ddata->dsi;
-
-	return mipi_dsi_set_maximum_return_packet_size(dsi, size);
-}
-
-static int dsicm_memory_read(struct omap_dss_device *dssdev,
-		void *buf, size_t size,
-		u16 x, u16 y, u16 w, u16 h)
-{
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct mipi_dsi_device *dsi = ddata->dsi;
-	struct omap_dss_device *src = ddata->src;
-	int r;
-	int first = 1;
-	int plen;
-	unsigned int buf_used = 0;
-
-	if (size < w * h * 3)
-		return -ENOMEM;
-
-	mutex_lock(&ddata->lock);
-
-	if (!ddata->enabled) {
-		r = -ENODEV;
-		goto err1;
-	}
-
-	size = min((u32)w * h * 3,
-		   ddata->vm.hactive * ddata->vm.vactive * 3);
-
-	src->ops->dsi.bus_lock(src);
-
-	r = dsicm_wake_up(ddata);
-	if (r)
-		goto err2;
-
-	/* plen 1 or 2 goes into short packet. until checksum error is fixed,
-	 * use short packets. plen 32 works, but bigger packets seem to cause
-	 * an error. */
-	if (size % 2)
-		plen = 1;
-	else
-		plen = 2;
-
-	dsicm_set_update_window(ddata, x, y, w, h);
-
-	r = dsicm_set_max_rx_packet_size(dssdev, plen);
-	if (r)
-		goto err2;
-
-	while (buf_used < size) {
-		u8 dcs_cmd = first ? 0x2e : 0x3e;
-		first = 0;
-
-		r = mipi_dsi_dcs_read(dsi, dcs_cmd,
-				      buf + buf_used, size - buf_used);
-		if (r < 0) {
-			dev_err(dssdev->dev, "read error\n");
-			goto err3;
-		}
-
-		buf_used += r;
-
-		if (r < plen) {
-			dev_err(&ddata->dsi->dev, "short read\n");
-			break;
-		}
-
-		if (signal_pending(current)) {
-			dev_err(&ddata->dsi->dev, "signal pending, "
-					"aborting memory read\n");
-			r = -ERESTARTSYS;
-			goto err3;
-		}
-	}
-
-	r = buf_used;
-
-err3:
-	dsicm_set_max_rx_packet_size(dssdev, 1);
-err2:
-	src->ops->dsi.bus_unlock(src);
-err1:
-	mutex_unlock(&ddata->lock);
-	return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
 	struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -1093,8 +1002,6 @@ static const struct omap_dss_driver dsicm_dss_driver = {
 
 	.enable_te	= dsicm_enable_te,
 	.get_te		= dsicm_get_te,
-
-	.memory_read	= dsicm_memory_read,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 78041ef922cc..e67928373560 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -389,10 +389,6 @@ struct omap_dss_driver {
 
 	int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
 	int (*get_te)(struct omap_dss_device *dssdev);
-
-	int (*memory_read)(struct omap_dss_device *dssdev,
-			void *buf, size_t size,
-			u16 x, u16 y, u16 w, u16 h);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 18/80] drm/omap: dsi: drop unused get_te()
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (16 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 17/80] drm/omap: dsi: drop unused memory_read() Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 19/80] drm/omap: dsi: drop unused enable_te() Tomi Valkeinen
                   ` (62 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

The get_te() callback is not used, so we can drop the
custom API.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 13 -------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h           |  1 -
 2 files changed, 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 6e3fbf99ff91..b4c666064c85 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -918,18 +918,6 @@ static int dsicm_enable_te(struct omap_dss_device *dssdev, bool enable)
 	return r;
 }
 
-static int dsicm_get_te(struct omap_dss_device *dssdev)
-{
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	int r;
-
-	mutex_lock(&ddata->lock);
-	r = ddata->te_enabled;
-	mutex_unlock(&ddata->lock);
-
-	return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
 	struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -1001,7 +989,6 @@ static const struct omap_dss_driver dsicm_dss_driver = {
 	.sync		= dsicm_sync,
 
 	.enable_te	= dsicm_enable_te,
-	.get_te		= dsicm_get_te,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index e67928373560..aa307f5ab9cf 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -388,7 +388,6 @@ struct omap_dss_driver {
 	int (*sync)(struct omap_dss_device *dssdev);
 
 	int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
-	int (*get_te)(struct omap_dss_device *dssdev);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 19/80] drm/omap: dsi: drop unused enable_te()
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (17 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 18/80] drm/omap: dsi: drop unused get_te() Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 20/80] drm/omap: dsi: drop useless sync() Tomi Valkeinen
                   ` (61 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

enable_te() is not used, so the custom API can be dropped.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 39 -------------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  2 -
 2 files changed, 41 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index b4c666064c85..04d8a0e0e214 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -881,43 +881,6 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 	return r;
 }
 
-static int dsicm_enable_te(struct omap_dss_device *dssdev, bool enable)
-{
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *src = ddata->src;
-	int r;
-
-	mutex_lock(&ddata->lock);
-
-	if (ddata->te_enabled == enable)
-		goto end;
-
-	src->ops->dsi.bus_lock(src);
-
-	if (ddata->enabled) {
-		r = dsicm_wake_up(ddata);
-		if (r)
-			goto err;
-
-		r = _dsicm_enable_te(ddata, enable);
-		if (r)
-			goto err;
-	}
-
-	ddata->te_enabled = enable;
-
-	src->ops->dsi.bus_unlock(src);
-end:
-	mutex_unlock(&ddata->lock);
-
-	return 0;
-err:
-	src->ops->dsi.bus_unlock(src);
-	mutex_unlock(&ddata->lock);
-
-	return r;
-}
-
 static void dsicm_ulps_work(struct work_struct *work)
 {
 	struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
@@ -987,8 +950,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
 static const struct omap_dss_driver dsicm_dss_driver = {
 	.update		= dsicm_update,
 	.sync		= dsicm_sync,
-
-	.enable_te	= dsicm_enable_te,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index aa307f5ab9cf..55d5bca59f81 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -386,8 +386,6 @@ struct omap_dss_driver {
 	int (*update)(struct omap_dss_device *dssdev,
 			       u16 x, u16 y, u16 w, u16 h);
 	int (*sync)(struct omap_dss_device *dssdev);
-
-	int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
 };
 
 struct dss_device *omapdss_get_dss(void);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 20/80] drm/omap: dsi: drop useless sync()
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (18 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 19/80] drm/omap: dsi: drop unused enable_te() Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 21/80] drm/omap: dsi: use pixel-format and mode from attach Tomi Valkeinen
                   ` (60 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

The DSI sync() function only locks the bus and then releases
it again. Currently the only invocation is directly before
update(), which locks the bus anyways.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c    | 18 ------------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h          |  1 -
 drivers/gpu/drm/omapdrm/omap_crtc.c            |  3 ---
 3 files changed, 22 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 04d8a0e0e214..cfc31b777bae 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -844,23 +844,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 	return r;
 }
 
-static int dsicm_sync(struct omap_dss_device *dssdev)
-{
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *src = ddata->src;
-
-	dev_dbg(&ddata->dsi->dev, "sync\n");
-
-	mutex_lock(&ddata->lock);
-	src->ops->dsi.bus_lock(src);
-	src->ops->dsi.bus_unlock(src);
-	mutex_unlock(&ddata->lock);
-
-	dev_dbg(&ddata->dsi->dev, "sync done\n");
-
-	return 0;
-}
-
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
 	struct omap_dss_device *src = ddata->src;
@@ -949,7 +932,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
 
 static const struct omap_dss_driver dsicm_dss_driver = {
 	.update		= dsicm_update,
-	.sync		= dsicm_sync,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 55d5bca59f81..9bbd2c0f3187 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -385,7 +385,6 @@ struct omap_dss_device {
 struct omap_dss_driver {
 	int (*update)(struct omap_dss_device *dssdev,
 			       u16 x, u16 y, u16 w, u16 h);
-	int (*sync)(struct omap_dss_device *dssdev);
 };
 
 struct dss_device *omapdss_get_dss(void);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 328a4a74f534..dac9ccda98df 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -379,9 +379,6 @@ static void omap_crtc_manual_display_update(struct work_struct *data)
 		return;
 	}
 
-	if (dssdrv->sync)
-		dssdrv->sync(dssdev);
-
 	ret = dssdrv->update(dssdev, 0, 0, mode->hdisplay, mode->vdisplay);
 	if (ret < 0) {
 		spin_lock_irq(&dev->event_lock);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 21/80] drm/omap: dsi: use pixel-format and mode from attach
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (19 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 20/80] drm/omap: dsi: drop useless sync() Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 22/80] drm/omap: panel-dsi-cm: use bulk regulator API Tomi Valkeinen
                   ` (59 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

In order to reduce the amount of custom functionality, this moves
handling of pixel format and DSI mode from set_config() to dsi
attach.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 --
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 31 ++++++++++++-------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index cfc31b777bae..78498d863ad5 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -549,8 +549,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	u8 id1, id2, id3;
 	int r;
 	struct omap_dss_dsi_config dsi_config = {
-		.mode = OMAP_DSS_DSI_CMD_MODE,
-		.pixel_format = MIPI_DSI_FMT_RGB888,
 		.vm = &ddata->vm,
 		.hs_clk_min = 150000000,
 		.hs_clk_max = 300000000,
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 25d2af1e1a00..25122f1eaa4b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4578,24 +4578,19 @@ static int dsi_set_config(struct omap_dss_device *dssdev,
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	struct dsi_clk_calc_ctx ctx;
+	struct omap_dss_dsi_config cfg = *config;
 	bool ok;
 	int r;
 
 	mutex_lock(&dsi->lock);
 
-	dsi->pix_fmt = config->pixel_format;
-	dsi->mode = config->mode;
+	cfg.mode = dsi->mode;
+	cfg.pixel_format = dsi->pix_fmt;
 
-	if (mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) < 0) {
-		DSSERR("invalid pixel format\n");
-		r = -EINVAL;
-		goto err;
-	}
-
-	if (config->mode == OMAP_DSS_DSI_VIDEO_MODE)
-		ok = dsi_vm_calc(dsi, config, &ctx);
+	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
+		ok = dsi_vm_calc(dsi, &cfg, &ctx);
 	else
-		ok = dsi_cm_calc(dsi, config, &ctx);
+		ok = dsi_cm_calc(dsi, &cfg, &ctx);
 
 	if (!ok) {
 		DSSERR("failed to find suitable DSI clock settings\n");
@@ -4606,7 +4601,7 @@ static int dsi_set_config(struct omap_dss_device *dssdev,
 	dsi_pll_calc_dsi_fck(dsi, &ctx.dsi_cinfo);
 
 	r = dsi_lp_clock_calc(ctx.dsi_cinfo.clkout[HSDIV_DSI],
-		config->lp_clk_min, config->lp_clk_max, &dsi->user_lp_cinfo);
+		cfg.lp_clk_min, cfg.lp_clk_max, &dsi->user_lp_cinfo);
 	if (r) {
 		DSSERR("failed to find suitable DSI LP clock settings\n");
 		goto err;
@@ -4784,7 +4779,19 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 		return -EBUSY;
 	}
 
+	if (mipi_dsi_pixel_format_to_bpp(client->format) < 0) {
+		DSSERR("invalid pixel format\n");
+		return -EINVAL;
+	}
+
 	dsi->vc[channel].dest = client;
+
+	dsi->pix_fmt = client->format;
+	if (client->mode_flags & MIPI_DSI_MODE_VIDEO)
+		dsi->mode = OMAP_DSS_DSI_VIDEO_MODE;
+	else
+		dsi->mode = OMAP_DSS_DSI_CMD_MODE;
+
 	return 0;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 22/80] drm/omap: panel-dsi-cm: use bulk regulator API
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (20 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 21/80] drm/omap: dsi: use pixel-format and mode from attach Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 23/80] drm/omap: dsi: lp/hs switching support for transfer() Tomi Valkeinen
                   ` (58 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Use bulk regulator API to simplify the code. This also switches
from _optional variant to normal variant, which will provide a
dummy regulator (i.e. if some always-enabled regulator is not
described in DT).

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 65 ++++++-------------
 1 file changed, 21 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 78498d863ad5..feb4098ca227 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -32,6 +32,8 @@
 #define DCS_GET_ID2		0xdb
 #define DCS_GET_ID3		0xdc
 
+#define DCS_REGULATOR_SUPPLY_NUM 2
+
 struct panel_drv_data {
 	struct mipi_dsi_device *dsi;
 
@@ -54,8 +56,7 @@ struct panel_drv_data {
 	struct gpio_desc *reset_gpio;
 	struct gpio_desc *ext_te_gpio;
 
-	struct regulator *vpnl;
-	struct regulator *vddi;
+	struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
 
 	bool use_dsi_backlight;
 
@@ -556,28 +557,16 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 		.lp_clk_max = 10000000,
 	};
 
-	if (ddata->vpnl) {
-		r = regulator_enable(ddata->vpnl);
-		if (r) {
-			dev_err(&ddata->dsi->dev,
-				"failed to enable VPNL: %d\n", r);
-			return r;
-		}
-	}
-
-	if (ddata->vddi) {
-		r = regulator_enable(ddata->vddi);
-		if (r) {
-			dev_err(&ddata->dsi->dev,
-				"failed to enable VDDI: %d\n", r);
-			goto err_vpnl;
-		}
+	r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
+	if (r) {
+		dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
+		return r;
 	}
 
 	r = src->ops->dsi.set_config(src, &dsi_config);
 	if (r) {
 		dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
-		goto err_vddi;
+		goto err_regulators;
 	}
 
 	src->ops->enable(src);
@@ -636,12 +625,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	dsicm_hw_reset(ddata);
 
 	src->ops->dsi.disable(src, true, false);
-err_vddi:
-	if (ddata->vddi)
-		regulator_disable(ddata->vddi);
-err_vpnl:
-	if (ddata->vpnl)
-		regulator_disable(ddata->vpnl);
+err_regulators:
+	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
+	if (r)
+		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
 
 	return r;
 }
@@ -665,10 +652,9 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 
 	src->ops->dsi.disable(src, true, false);
 
-	if (ddata->vddi)
-		regulator_disable(ddata->vddi);
-	if (ddata->vpnl)
-		regulator_disable(ddata->vpnl);
+	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
+	if (r)
+		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
 
 	ddata->enabled = false;
 }
@@ -972,21 +958,12 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 	ddata->height_mm = 0;
 	of_property_read_u32(node, "height-mm", &ddata->height_mm);
 
-	ddata->vpnl = devm_regulator_get_optional(&dsi->dev, "vpnl");
-	if (IS_ERR(ddata->vpnl)) {
-		err = PTR_ERR(ddata->vpnl);
-		if (err == -EPROBE_DEFER)
-			return err;
-		ddata->vpnl = NULL;
-	}
-
-	ddata->vddi = devm_regulator_get_optional(&dsi->dev, "vddi");
-	if (IS_ERR(ddata->vddi)) {
-		err = PTR_ERR(ddata->vddi);
-		if (err == -EPROBE_DEFER)
-			return err;
-		ddata->vddi = NULL;
-	}
+	ddata->supplies[0].supply = "vpnl";
+	ddata->supplies[1].supply = "vddi";
+	err = devm_regulator_bulk_get(&dsi->dev, ARRAY_SIZE(ddata->supplies),
+				      ddata->supplies);
+	if (err)
+		return err;
 
 	backlight = devm_of_find_backlight(&dsi->dev);
 	if (IS_ERR(backlight))
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 23/80] drm/omap: dsi: lp/hs switching support for transfer()
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (21 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 22/80] drm/omap: panel-dsi-cm: use bulk regulator API Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core Tomi Valkeinen
                   ` (57 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Integrate low-power / high-speed bus switching into transfer
function and drop the omapdrm specific enable_hs() callback.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 6 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c               | 9 +++++++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h           | 2 --
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index feb4098ca227..aef5d59181fa 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -269,7 +269,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 		return 0;
 
 	src->ops->enable(src);
-	src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
+	ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
 	r = _dsicm_enable_te(ddata, true);
 	if (r) {
@@ -573,7 +573,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
 	dsicm_hw_reset(ddata);
 
-	src->ops->dsi.enable_hs(src, ddata->dsi->channel, false);
+	ddata->dsi->mode_flags |= MIPI_DSI_MODE_LPM;
 
 	r = dsicm_sleep_out(ddata);
 	if (r)
@@ -616,7 +616,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 		ddata->intro_printed = true;
 	}
 
-	src->ops->dsi.enable_hs(src, ddata->dsi->channel, true);
+	ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
 	return 0;
 err:
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 25122f1eaa4b..352c16a37476 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -329,6 +329,7 @@ struct dsi_data {
 	int irq;
 
 	bool is_enabled;
+	bool in_lp_mode;
 
 	struct clk *dss_clk;
 	struct regmap *syscon;
@@ -2431,6 +2432,8 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
 	/* start the DDR clock by sending a NULL packet */
 	if (dsi->vm_timings.ddr_clk_always_on && enable)
 		dsi_vc_send_null(dsi, channel);
+
+	dsi->in_lp_mode = !enable;
 }
 
 static void dsi_vc_flush_long_data(struct dsi_data *dsi, int channel)
@@ -4692,6 +4695,10 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 	struct dsi_data *dsi = host_to_omap(host);
 	struct omap_dss_device *dssdev = &dsi->output;
 
+	if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode)
+		dsi_vc_enable_hs(dssdev, msg->channel,
+				 !(msg->flags & MIPI_DSI_MSG_USE_LPM));
+
 	switch (msg->type) {
 	case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
 	case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
@@ -4752,8 +4759,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 
 		.disable = dsi_display_disable,
 
-		.enable_hs = dsi_vc_enable_hs,
-
 		.set_config = dsi_set_config,
 
 		.enable_video_output = dsi_enable_video_output,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9bbd2c0f3187..2d44a8e32fcc 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -288,8 +288,6 @@ struct omapdss_dsi_ops {
 	int (*set_config)(struct omap_dss_device *dssdev,
 			const struct omap_dss_dsi_config *cfg);
 
-	void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
-			bool enable);
 	int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
 
 	int (*update)(struct omap_dss_device *dssdev, int channel,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (22 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 23/80] drm/omap: dsi: lp/hs switching support for transfer() Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2021-02-08 17:55   ` Tony Lindgren
  2020-11-24 12:44 ` [PATCH v4 25/80] drm/omap: dsi: drop custom enable_te() API Tomi Valkeinen
                   ` (56 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

In preparation for removing custom DSS calls from the DSI
panel driver, this moves support for external tearing event
GPIOs into the DSI host driver. This way tearing events are
always handled in the core resulting in simplification of
the panel drivers.

The TE GPIO acquisition follows works in the same way as the
exynos DSI implementation.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 103 +-----------
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 146 ++++++++++++++++--
 2 files changed, 141 insertions(+), 108 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index aef5d59181fa..35810ec65b7a 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -54,7 +54,6 @@ struct panel_drv_data {
 
 	/* panel HW configuration from DT or platform data */
 	struct gpio_desc *reset_gpio;
-	struct gpio_desc *ext_te_gpio;
 
 	struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
 
@@ -66,12 +65,6 @@ struct panel_drv_data {
 	/* runtime variables */
 	bool enabled;
 
-	bool te_enabled;
-
-	atomic_t do_update;
-
-	struct delayed_work te_timeout_work;
-
 	bool intro_printed;
 
 	struct workqueue_struct *workqueue;
@@ -83,8 +76,6 @@ struct panel_drv_data {
 
 #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
 
-static irqreturn_t dsicm_te_isr(int irq, void *data);
-static void dsicm_te_timeout_work_callback(struct work_struct *work);
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
 static int dsicm_panel_reset(struct panel_drv_data *ddata);
@@ -240,9 +231,6 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
-	if (ddata->ext_te_gpio)
-		disable_irq(gpiod_to_irq(ddata->ext_te_gpio));
-
 	src->ops->dsi.disable(src, false, true);
 
 	ddata->ulps_enabled = true;
@@ -277,9 +265,6 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 		goto err2;
 	}
 
-	if (ddata->ext_te_gpio)
-		enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
-
 	dsicm_queue_ulps_work(ddata);
 
 	ddata->ulps_enabled = false;
@@ -290,11 +275,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 	dev_err(&ddata->dsi->dev, "failed to exit ULPS");
 
 	r = dsicm_panel_reset(ddata);
-	if (!r) {
-		if (ddata->ext_te_gpio)
-			enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
+	if (!r)
 		ddata->ulps_enabled = false;
-	}
 
 	dsicm_queue_ulps_work(ddata);
 
@@ -600,7 +582,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
-	r = _dsicm_enable_te(ddata, ddata->te_enabled);
+	r = _dsicm_enable_te(ddata, true);
 	if (r)
 		goto err;
 
@@ -744,43 +726,6 @@ static void dsicm_framedone_cb(int err, void *data)
 	src->ops->dsi.bus_unlock(src);
 }
 
-static irqreturn_t dsicm_te_isr(int irq, void *data)
-{
-	struct panel_drv_data *ddata = data;
-	struct omap_dss_device *src = ddata->src;
-	int old;
-	int r;
-
-	old = atomic_cmpxchg(&ddata->do_update, 1, 0);
-
-	if (old) {
-		cancel_delayed_work(&ddata->te_timeout_work);
-
-		r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
-				ddata);
-		if (r)
-			goto err;
-	}
-
-	return IRQ_HANDLED;
-err:
-	dev_err(&ddata->dsi->dev, "start update failed\n");
-	src->ops->dsi.bus_unlock(src);
-	return IRQ_HANDLED;
-}
-
-static void dsicm_te_timeout_work_callback(struct work_struct *work)
-{
-	struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
-					te_timeout_work.work);
-	struct omap_dss_device *src = ddata->src;
-
-	dev_err(&ddata->dsi->dev, "TE not received for 250ms!\n");
-
-	atomic_set(&ddata->do_update, 0);
-	src->ops->dsi.bus_unlock(src);
-}
-
 static int dsicm_update(struct omap_dss_device *dssdev,
 				    u16 x, u16 y, u16 w, u16 h)
 {
@@ -808,16 +753,10 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 	if (r)
 		goto err;
 
-	if (ddata->te_enabled && ddata->ext_te_gpio) {
-		schedule_delayed_work(&ddata->te_timeout_work,
-				msecs_to_jiffies(250));
-		atomic_set(&ddata->do_update, 1);
-	} else {
-		r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
-				ddata);
-		if (r)
-			goto err;
-	}
+	r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
+			ddata);
+	if (r)
+		goto err;
 
 	/* note: no bus_unlock here. unlock is src framedone_cb */
 	mutex_unlock(&ddata->lock);
@@ -839,8 +778,7 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 	else
 		r = mipi_dsi_dcs_set_tear_off(dsi);
 
-	if (!ddata->ext_te_gpio)
-		src->ops->dsi.enable_te(src, enable);
+	src->ops->dsi.enable_te(src, enable);
 
 	/* possible panel bug */
 	msleep(100);
@@ -933,14 +871,6 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 		return err;
 	}
 
-	ddata->ext_te_gpio = devm_gpiod_get_optional(&dsi->dev, "te",
-						     GPIOD_IN);
-	if (IS_ERR(ddata->ext_te_gpio)) {
-		err = PTR_ERR(ddata->ext_te_gpio);
-		dev_err(&dsi->dev, "TE gpio request failed: %d", err);
-		return err;
-	}
-
 	err = of_get_display_timing(node, "panel-timing", &timing);
 	if (!err) {
 		videomode_from_timing(&timing, &ddata->vm);
@@ -1023,25 +953,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 
 	mutex_init(&ddata->lock);
 
-	atomic_set(&ddata->do_update, 0);
-
-	if (ddata->ext_te_gpio) {
-		r = devm_request_irq(dev, gpiod_to_irq(ddata->ext_te_gpio),
-				dsicm_te_isr,
-				IRQF_TRIGGER_RISING,
-				"taal vsync", ddata);
-
-		if (r) {
-			dev_err(dev, "IRQ request failed\n");
-			goto err_reg;
-		}
-
-		INIT_DEFERRABLE_WORK(&ddata->te_timeout_work,
-					dsicm_te_timeout_work_callback);
-
-		dev_dbg(dev, "Using GPIO TE\n");
-	}
-
 	ddata->workqueue = create_singlethread_workqueue("dsicm_wq");
 	if (!ddata->workqueue) {
 		r = -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 352c16a37476..b26cbedd7e76 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -14,7 +14,9 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/semaphore.h>
@@ -368,6 +370,12 @@ struct dsi_data {
 	unsigned int update_bytes;
 #endif
 
+	/* external TE GPIO */
+	struct gpio_desc *te_gpio;
+	int te_irq;
+	struct delayed_work te_timeout_work;
+	atomic_t do_ext_te_update;
+
 	bool te_enabled;
 	bool ulps_enabled;
 
@@ -3826,19 +3834,12 @@ static void dsi_framedone_irq_callback(void *data)
 	dsi_handle_framedone(dsi, 0);
 }
 
-static int dsi_update(struct omap_dss_device *dssdev, int channel,
-		void (*callback)(int, void *), void *data)
+static int _dsi_update(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
 	u16 dw, dh;
 
 	dsi_perf_mark_setup(dsi);
 
-	dsi->update_channel = channel;
-
-	dsi->framedone_callback = callback;
-	dsi->framedone_data = data;
-
 	dw = dsi->vm.hactive;
 	dh = dsi->vm.vactive;
 
@@ -3851,6 +3852,26 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
 	return 0;
 }
 
+static int dsi_update(struct omap_dss_device *dssdev, int channel,
+		void (*callback)(int, void *), void *data)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+
+	dsi->update_channel = channel;
+	dsi->framedone_callback = callback;
+	dsi->framedone_data = data;
+
+	if (dsi->te_enabled && dsi->te_gpio) {
+		schedule_delayed_work(&dsi->te_timeout_work,
+				      msecs_to_jiffies(250));
+		atomic_set(&dsi->do_ext_te_update, 1);
+	} else {
+		_dsi_update(dsi);
+	}
+
+	return 0;
+}
+
 /* Display funcs */
 
 static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
@@ -4094,6 +4115,14 @@ static int dsi_enable_te(struct omap_dss_device *dssdev, bool enable)
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	dsi->te_enabled = enable;
+
+	if (dsi->te_gpio) {
+		if (enable)
+			enable_irq(dsi->te_irq);
+		else
+			disable_irq(dsi->te_irq);
+	}
+
 	return 0;
 }
 
@@ -4770,11 +4799,96 @@ static const struct omap_dss_device_ops dsi_ops = {
 	},
 };
 
+static irqreturn_t omap_dsi_te_irq_handler(int irq, void *dev_id)
+{
+	struct dsi_data *dsi = (struct dsi_data *)dev_id;
+	int old;
+
+	old = atomic_cmpxchg(&dsi->do_ext_te_update, 1, 0);
+	if (old) {
+		cancel_delayed_work(&dsi->te_timeout_work);
+		_dsi_update(dsi);
+	}
+
+	return IRQ_HANDLED;
+}
+
+static void omap_dsi_te_timeout_work_callback(struct work_struct *work)
+{
+	struct dsi_data *dsi =
+		container_of(work, struct dsi_data, te_timeout_work.work);
+	int old;
+
+	old = atomic_cmpxchg(&dsi->do_ext_te_update, 1, 0);
+	if (old) {
+		dev_err(dsi->dev, "TE not received for 250ms!\n");
+		_dsi_update(dsi);
+	}
+}
+
+static int omap_dsi_register_te_irq(struct dsi_data *dsi,
+				    struct mipi_dsi_device *client)
+{
+	int err;
+	int te_irq;
+
+	dsi->te_gpio = gpiod_get(&client->dev, "te-gpios", GPIOD_IN);
+	if (IS_ERR(dsi->te_gpio)) {
+		err = PTR_ERR(dsi->te_gpio);
+
+		if (err == -ENOENT) {
+			dsi->te_gpio = NULL;
+			return 0;
+		}
+
+		dev_err(dsi->dev, "Could not get TE gpio: %d\n", err);
+		return err;
+	}
+
+	te_irq = gpiod_to_irq(dsi->te_gpio);
+	if (te_irq < 0) {
+		gpiod_put(dsi->te_gpio);
+		dsi->te_gpio = NULL;
+		return -EINVAL;
+	}
+
+	dsi->te_irq = te_irq;
+
+	irq_set_status_flags(te_irq, IRQ_NOAUTOEN);
+
+	err = request_threaded_irq(te_irq, NULL, omap_dsi_te_irq_handler,
+				   IRQF_TRIGGER_RISING, "TE", dsi);
+	if (err) {
+		dev_err(dsi->dev, "request irq failed with %d\n", err);
+		gpiod_put(dsi->te_gpio);
+		dsi->te_gpio = NULL;
+		return err;
+	}
+
+	INIT_DEFERRABLE_WORK(&dsi->te_timeout_work,
+			     omap_dsi_te_timeout_work_callback);
+
+	dev_dbg(dsi->dev, "Using GPIO TE\n");
+
+	return 0;
+}
+
+static void omap_dsi_unregister_te_irq(struct dsi_data *dsi)
+{
+	if (dsi->te_gpio) {
+		free_irq(dsi->te_irq, dsi);
+		cancel_delayed_work(&dsi->te_timeout_work);
+		gpiod_put(dsi->te_gpio);
+		dsi->te_gpio = NULL;
+	}
+}
+
 static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 				struct mipi_dsi_device *client)
 {
 	struct dsi_data *dsi = host_to_omap(host);
 	unsigned int channel = client->channel;
+	int r;
 
 	if (channel > 3)
 		return -EINVAL;
@@ -4789,13 +4903,20 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 		return -EINVAL;
 	}
 
-	dsi->vc[channel].dest = client;
+	atomic_set(&dsi->do_ext_te_update, 0);
 
-	dsi->pix_fmt = client->format;
-	if (client->mode_flags & MIPI_DSI_MODE_VIDEO)
+	if (client->mode_flags & MIPI_DSI_MODE_VIDEO) {
 		dsi->mode = OMAP_DSS_DSI_VIDEO_MODE;
-	else
+	} else {
+		r = omap_dsi_register_te_irq(dsi, client);
+		if (r)
+			return r;
+
 		dsi->mode = OMAP_DSS_DSI_CMD_MODE;
+	}
+
+	dsi->vc[channel].dest = client;
+	dsi->pix_fmt = client->format;
 
 	return 0;
 }
@@ -4812,6 +4933,7 @@ static int omap_dsi_host_detach(struct mipi_dsi_host *host,
 	if (dsi->vc[channel].dest != client)
 		return -EINVAL;
 
+	omap_dsi_unregister_te_irq(dsi);
 	dsi->vc[channel].dest = NULL;
 	return 0;
 }
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 25/80] drm/omap: dsi: drop custom enable_te() API
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (23 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 26/80] drm/omap: dsi: do bus locking in host driver Tomi Valkeinen
                   ` (55 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Instead of using the custom enable_te() API, this automatically
enables/disables TE core support when a matching packet is sent
to the panel.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  3 --
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 34 ++++++++++++++-----
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  2 --
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 35810ec65b7a..766edeecdd79 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -769,7 +769,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
-	struct omap_dss_device *src = ddata->src;
 	struct mipi_dsi_device *dsi = ddata->dsi;
 	int r;
 
@@ -778,8 +777,6 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 	else
 		r = mipi_dsi_dcs_set_tear_off(dsi);
 
-	src->ops->dsi.enable_te(src, enable);
-
 	/* possible panel bug */
 	msleep(100);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index b26cbedd7e76..e0d0efffd923 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4110,10 +4110,8 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
 	mutex_unlock(&dsi->lock);
 }
 
-static int dsi_enable_te(struct omap_dss_device *dssdev, bool enable)
+static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
 	dsi->te_enabled = enable;
 
 	if (dsi->te_gpio) {
@@ -4723,6 +4721,7 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 {
 	struct dsi_data *dsi = host_to_omap(host);
 	struct omap_dss_device *dssdev = &dsi->output;
+	int r;
 
 	if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode)
 		dsi_vc_enable_hs(dssdev, msg->channel,
@@ -4738,16 +4737,35 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 	case MIPI_DSI_DCS_LONG_WRITE:
 	case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
 	case MIPI_DSI_NULL_PACKET:
-		return dsi_vc_write_common(dssdev, msg);
+		r = dsi_vc_write_common(dssdev, msg);
+		break;
 	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
-		return dsi_vc_generic_read(dssdev, msg);
+		r = dsi_vc_generic_read(dssdev, msg);
+		break;
 	case MIPI_DSI_DCS_READ:
-		return dsi_vc_dcs_read(dssdev, msg);
+		r = dsi_vc_dcs_read(dssdev, msg);
+		break;
+	default:
+		r = -EINVAL;
+		break;
 	}
 
-	return -EINVAL;
+	if (r < 0)
+		return r;
+
+	if (msg->type == MIPI_DSI_DCS_SHORT_WRITE ||
+	    msg->type == MIPI_DSI_DCS_SHORT_WRITE_PARAM) {
+		u8 cmd = ((u8 *)msg->tx_buf)[0];
+
+		if (cmd == MIPI_DCS_SET_TEAR_OFF)
+			dsi_enable_te(dsi, false);
+		else if (cmd == MIPI_DCS_SET_TEAR_ON)
+			dsi_enable_te(dsi, true);
+	}
+
+	return 0;
 }
 
 static int dsi_get_clocks(struct dsi_data *dsi)
@@ -4794,8 +4812,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 		.disable_video_output = dsi_disable_video_output,
 
 		.update = dsi_update,
-
-		.enable_te = dsi_enable_te,
 	},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 2d44a8e32fcc..1520a5f752b7 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -288,8 +288,6 @@ struct omapdss_dsi_ops {
 	int (*set_config)(struct omap_dss_device *dssdev,
 			const struct omap_dss_dsi_config *cfg);
 
-	int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
-
 	int (*update)(struct omap_dss_device *dssdev, int channel,
 			void (*callback)(int, void *), void *data);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 26/80] drm/omap: dsi: do bus locking in host driver
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (24 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 25/80] drm/omap: dsi: drop custom enable_te() API Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 27/80] drm/omap: dsi: untangle ulps ops from enable/disable Tomi Valkeinen
                   ` (54 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This moves the bus locking into the host driver and unexports
the custom API in preparation for drm_panel support.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 44 +------------------
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 41 +++++++++++------
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  3 --
 3 files changed, 28 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 766edeecdd79..a335c17d3c3b 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -296,7 +296,6 @@ static int dsicm_wake_up(struct panel_drv_data *ddata)
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
-	struct omap_dss_device *src = ddata->src;
 	int r = 0;
 	int level;
 
@@ -311,14 +310,10 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
 	mutex_lock(&ddata->lock);
 
 	if (ddata->enabled) {
-		src->ops->dsi.bus_lock(src);
-
 		r = dsicm_wake_up(ddata);
 		if (!r)
 			r = dsicm_dcs_write_1(
 				ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
-
-		src->ops->dsi.bus_unlock(src);
 	}
 
 	mutex_unlock(&ddata->lock);
@@ -344,21 +339,16 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(dev);
-	struct omap_dss_device *src = ddata->src;
 	u8 errors = 0;
 	int r;
 
 	mutex_lock(&ddata->lock);
 
 	if (ddata->enabled) {
-		src->ops->dsi.bus_lock(src);
-
 		r = dsicm_wake_up(ddata);
 		if (!r)
 			r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
 					&errors);
-
-		src->ops->dsi.bus_unlock(src);
 	} else {
 		r = -ENODEV;
 	}
@@ -375,20 +365,15 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(dev);
-	struct omap_dss_device *src = ddata->src;
 	u8 id1, id2, id3;
 	int r;
 
 	mutex_lock(&ddata->lock);
 
 	if (ddata->enabled) {
-		src->ops->dsi.bus_lock(src);
-
 		r = dsicm_wake_up(ddata);
 		if (!r)
 			r = dsicm_get_id(ddata, &id1, &id2, &id3);
-
-		src->ops->dsi.bus_unlock(src);
 	} else {
 		r = -ENODEV;
 	}
@@ -406,7 +391,6 @@ static ssize_t dsicm_store_ulps(struct device *dev,
 		const char *buf, size_t count)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(dev);
-	struct omap_dss_device *src = ddata->src;
 	unsigned long t;
 	int r;
 
@@ -417,14 +401,10 @@ static ssize_t dsicm_store_ulps(struct device *dev,
 	mutex_lock(&ddata->lock);
 
 	if (ddata->enabled) {
-		src->ops->dsi.bus_lock(src);
-
 		if (t)
 			r = dsicm_enter_ulps(ddata);
 		else
 			r = dsicm_wake_up(ddata);
-
-		src->ops->dsi.bus_unlock(src);
 	}
 
 	mutex_unlock(&ddata->lock);
@@ -454,7 +434,6 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
 		const char *buf, size_t count)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(dev);
-	struct omap_dss_device *src = ddata->src;
 	unsigned long t;
 	int r;
 
@@ -467,9 +446,7 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
 
 	if (ddata->enabled) {
 		/* dsicm_wake_up will restart the timer */
-		src->ops->dsi.bus_lock(src);
 		r = dsicm_wake_up(ddata);
-		src->ops->dsi.bus_unlock(src);
 	}
 
 	mutex_unlock(&ddata->lock);
@@ -670,17 +647,11 @@ static void dsicm_disconnect(struct omap_dss_device *src,
 static void dsicm_enable(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *src = ddata->src;
 	int r;
 
 	mutex_lock(&ddata->lock);
 
-	src->ops->dsi.bus_lock(src);
-
 	r = dsicm_power_on(ddata);
-
-	src->ops->dsi.bus_unlock(src);
-
 	if (r)
 		goto err;
 
@@ -697,7 +668,6 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 static void dsicm_disable(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *src = ddata->src;
 	int r;
 
 	dsicm_bl_power(ddata, false);
@@ -706,24 +676,18 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
 
 	dsicm_cancel_ulps_work(ddata);
 
-	src->ops->dsi.bus_lock(src);
-
 	r = dsicm_wake_up(ddata);
 	if (!r)
 		dsicm_power_off(ddata);
 
-	src->ops->dsi.bus_unlock(src);
-
 	mutex_unlock(&ddata->lock);
 }
 
 static void dsicm_framedone_cb(int err, void *data)
 {
 	struct panel_drv_data *ddata = data;
-	struct omap_dss_device *src = ddata->src;
 
 	dev_dbg(&ddata->dsi->dev, "framedone, err %d\n", err);
-	src->ops->dsi.bus_unlock(src);
 }
 
 static int dsicm_update(struct omap_dss_device *dssdev,
@@ -736,7 +700,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 	dev_dbg(&ddata->dsi->dev, "update %d, %d, %d x %d\n", x, y, w, h);
 
 	mutex_lock(&ddata->lock);
-	src->ops->dsi.bus_lock(src);
 
 	r = dsicm_wake_up(ddata);
 	if (r)
@@ -758,11 +721,10 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 	if (r)
 		goto err;
 
-	/* note: no bus_unlock here. unlock is src framedone_cb */
 	mutex_unlock(&ddata->lock);
+
 	return 0;
 err:
-	src->ops->dsi.bus_unlock(src);
 	mutex_unlock(&ddata->lock);
 	return r;
 }
@@ -788,7 +750,6 @@ static void dsicm_ulps_work(struct work_struct *work)
 	struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
 			ulps_work.work);
 	struct omap_dss_device *dssdev = &ddata->dssdev;
-	struct omap_dss_device *src = ddata->src;
 
 	mutex_lock(&ddata->lock);
 
@@ -797,11 +758,8 @@ static void dsicm_ulps_work(struct work_struct *work)
 		return;
 	}
 
-	src->ops->dsi.bus_lock(src);
-
 	dsicm_enter_ulps(ddata);
 
-	src->ops->dsi.bus_unlock(src);
 	mutex_unlock(&ddata->lock);
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index e0d0efffd923..2a3b63265bb2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -477,17 +477,13 @@ static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx)
 	return __raw_readl(base + idx.idx);
 }
 
-static void dsi_bus_lock(struct omap_dss_device *dssdev)
+static void dsi_bus_lock(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
 	down(&dsi->bus_lock);
 }
 
-static void dsi_bus_unlock(struct omap_dss_device *dssdev)
+static void dsi_bus_unlock(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
 	up(&dsi->bus_lock);
 }
 
@@ -3798,6 +3794,8 @@ static void dsi_handle_framedone(struct dsi_data *dsi, int error)
 		REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
 	}
 
+	dsi_bus_unlock(dsi);
+
 	dsi->framedone_callback(error, dsi->framedone_data);
 
 	if (!error)
@@ -3857,6 +3855,8 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
+	dsi_bus_lock(dsi);
+
 	dsi->update_channel = channel;
 	dsi->framedone_callback = callback;
 	dsi->framedone_data = data;
@@ -4062,7 +4062,7 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
 
 	DSSDBG("dsi_display_enable\n");
 
-	WARN_ON(!dsi_bus_is_locked(dsi));
+	dsi_bus_lock(dsi);
 
 	mutex_lock(&dsi->lock);
 
@@ -4078,6 +4078,8 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
 
 	mutex_unlock(&dsi->lock);
 
+	dsi_bus_unlock(dsi);
+
 	return;
 
 err_init_dsi:
@@ -4094,7 +4096,7 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
 
 	DSSDBG("dsi_display_disable\n");
 
-	WARN_ON(!dsi_bus_is_locked(dsi));
+	dsi_bus_lock(dsi);
 
 	mutex_lock(&dsi->lock);
 
@@ -4108,6 +4110,8 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
 	dsi_runtime_put(dsi);
 
 	mutex_unlock(&dsi->lock);
+
+	dsi_bus_unlock(dsi);
 }
 
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
@@ -4716,10 +4720,9 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
 	}
 }
 
-static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
-				      const struct mipi_dsi_msg *msg)
+static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
+				       const struct mipi_dsi_msg *msg)
 {
-	struct dsi_data *dsi = host_to_omap(host);
 	struct omap_dss_device *dssdev = &dsi->output;
 	int r;
 
@@ -4768,6 +4771,19 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 	return 0;
 }
 
+static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
+				      const struct mipi_dsi_msg *msg)
+{
+	struct dsi_data *dsi = host_to_omap(host);
+	int r;
+
+	dsi_bus_lock(dsi);
+	r = _omap_dsi_host_transfer(dsi, msg);
+	dsi_bus_unlock(dsi);
+
+	return r;
+}
+
 static int dsi_get_clocks(struct dsi_data *dsi)
 {
 	struct clk *clk;
@@ -4801,9 +4817,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 	.enable = dsi_display_enable,
 
 	.dsi = {
-		.bus_lock = dsi_bus_lock,
-		.bus_unlock = dsi_bus_unlock,
-
 		.disable = dsi_display_disable,
 
 		.set_config = dsi_set_config,
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 1520a5f752b7..43eba2ea1f96 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -291,9 +291,6 @@ struct omapdss_dsi_ops {
 	int (*update)(struct omap_dss_device *dssdev, int channel,
 			void (*callback)(int, void *), void *data);
 
-	void (*bus_lock)(struct omap_dss_device *dssdev);
-	void (*bus_unlock)(struct omap_dss_device *dssdev);
-
 	int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
 	void (*disable_video_output)(struct omap_dss_device *dssdev,
 			int channel);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 27/80] drm/omap: dsi: untangle ulps ops from enable/disable
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (25 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 26/80] drm/omap: dsi: do bus locking in host driver Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 28/80] drm/omap: dsi: do ULPS in host driver Tomi Valkeinen
                   ` (53 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Create a custom function pointer for ULPS and use it instead of
reusing disable/enable functions for ULPS mode switch. This allows
us to use the common disable/enable functions pointers for DSI.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  8 +--
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 53 ++++++++++++++-----
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  5 +-
 3 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index a335c17d3c3b..c6c237d15939 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -231,7 +231,7 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
-	src->ops->dsi.disable(src, false, true);
+	src->ops->dsi.ulps(src, true);
 
 	ddata->ulps_enabled = true;
 
@@ -256,7 +256,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 	if (!ddata->ulps_enabled)
 		return 0;
 
-	src->ops->enable(src);
+	src->ops->dsi.ulps(src, false);
 	ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
 	r = _dsicm_enable_te(ddata, true);
@@ -583,7 +583,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
 	dsicm_hw_reset(ddata);
 
-	src->ops->dsi.disable(src, true, false);
+	src->ops->disable(src);
 err_regulators:
 	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
 	if (r)
@@ -609,7 +609,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 		dsicm_hw_reset(ddata);
 	}
 
-	src->ops->dsi.disable(src, true, false);
+	src->ops->disable(src);
 
 	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
 	if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 2a3b63265bb2..fdbc849c8944 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4055,14 +4055,11 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
 	}
 }
 
-static void dsi_display_enable(struct omap_dss_device *dssdev)
+static void _dsi_display_enable(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
-	DSSDBG("dsi_display_enable\n");
-
-	dsi_bus_lock(dsi);
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	mutex_lock(&dsi->lock);
 
@@ -4078,25 +4075,29 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
 
 	mutex_unlock(&dsi->lock);
 
-	dsi_bus_unlock(dsi);
-
 	return;
 
 err_init_dsi:
 	dsi_runtime_put(dsi);
 err_get_dsi:
 	mutex_unlock(&dsi->lock);
-	DSSDBG("dsi_display_enable FAILED\n");
+	DSSDBG("dsi_display_ulps_enable FAILED\n");
 }
 
-static void dsi_display_disable(struct omap_dss_device *dssdev,
-		bool disconnect_lanes, bool enter_ulps)
+static void dsi_display_enable(struct omap_dss_device *dssdev)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	DSSDBG("dsi_display_disable\n");
+	DSSDBG("dsi_display_enable\n");
 
 	dsi_bus_lock(dsi);
+	_dsi_display_enable(dsi);
+	dsi_bus_unlock(dsi);
+}
+
+static void _dsi_display_disable(struct dsi_data *dsi,
+		bool disconnect_lanes, bool enter_ulps)
+{
+	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	mutex_lock(&dsi->lock);
 
@@ -4110,6 +4111,31 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
 	dsi_runtime_put(dsi);
 
 	mutex_unlock(&dsi->lock);
+}
+
+static void dsi_display_disable(struct omap_dss_device *dssdev)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+
+	DSSDBG("dsi_display_disable\n");
+
+	dsi_bus_lock(dsi);
+	_dsi_display_disable(dsi, true, false);
+	dsi_bus_unlock(dsi);
+}
+
+static void dsi_ulps(struct omap_dss_device *dssdev, bool enable)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+
+	DSSDBG("dsi_ulps %d\n", enable);
+
+	dsi_bus_lock(dsi);
+
+	if (enable)
+		_dsi_display_disable(dsi, false, true);
+	else
+		_dsi_display_enable(dsi);
 
 	dsi_bus_unlock(dsi);
 }
@@ -4815,9 +4841,10 @@ static const struct omap_dss_device_ops dsi_ops = {
 	.connect = dsi_connect,
 	.disconnect = dsi_disconnect,
 	.enable = dsi_display_enable,
+	.disable = dsi_display_disable,
 
 	.dsi = {
-		.disable = dsi_display_disable,
+		.ulps = dsi_ulps,
 
 		.set_config = dsi_set_config,
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 43eba2ea1f96..0d82ba34ca89 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -281,10 +281,9 @@ struct omap_dss_writeback_info {
 };
 
 struct omapdss_dsi_ops {
-	void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
-			bool enter_ulps);
-
 	/* bus configuration */
+	void (*ulps)(struct omap_dss_device *dssdev, bool enable);
+
 	int (*set_config)(struct omap_dss_device *dssdev,
 			const struct omap_dss_dsi_config *cfg);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 28/80] drm/omap: dsi: do ULPS in host driver
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (26 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 27/80] drm/omap: dsi: untangle ulps ops from enable/disable Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 29/80] drm/omap: dsi: move panel refresh function to host Tomi Valkeinen
                   ` (52 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Move ULPS handling into the DSI host controller, so that we
no longer need a custom API for the DSI client.

Note that for now ULPS is always disabled.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 266 +-----------------
 drivers/gpu/drm/omapdrm/dss/dsi.c             |  71 +++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |   2 -
 3 files changed, 60 insertions(+), 279 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index c6c237d15939..bd115d601f04 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -16,7 +16,6 @@
 #include <linux/module.h>
 #include <linux/sched/signal.h>
 #include <linux/slab.h>
-#include <linux/workqueue.h>
 #include <linux/of_device.h>
 #include <linux/regulator/consumer.h>
 
@@ -66,22 +65,12 @@ struct panel_drv_data {
 	bool enabled;
 
 	bool intro_printed;
-
-	struct workqueue_struct *workqueue;
-
-	bool ulps_enabled;
-	unsigned int ulps_timeout;
-	struct delayed_work ulps_work;
 };
 
 #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
-static int dsicm_panel_reset(struct panel_drv_data *ddata);
-
-static void dsicm_ulps_work(struct work_struct *work);
-
 static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable)
 {
 	struct backlight_device *backlight;
@@ -205,94 +194,6 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata,
 	return 0;
 }
 
-static void dsicm_queue_ulps_work(struct panel_drv_data *ddata)
-{
-	if (ddata->ulps_timeout > 0)
-		queue_delayed_work(ddata->workqueue, &ddata->ulps_work,
-				msecs_to_jiffies(ddata->ulps_timeout));
-}
-
-static void dsicm_cancel_ulps_work(struct panel_drv_data *ddata)
-{
-	cancel_delayed_work(&ddata->ulps_work);
-}
-
-static int dsicm_enter_ulps(struct panel_drv_data *ddata)
-{
-	struct omap_dss_device *src = ddata->src;
-	int r;
-
-	if (ddata->ulps_enabled)
-		return 0;
-
-	dsicm_cancel_ulps_work(ddata);
-
-	r = _dsicm_enable_te(ddata, false);
-	if (r)
-		goto err;
-
-	src->ops->dsi.ulps(src, true);
-
-	ddata->ulps_enabled = true;
-
-	return 0;
-
-err:
-	dev_err(&ddata->dsi->dev, "enter ULPS failed");
-	dsicm_panel_reset(ddata);
-
-	ddata->ulps_enabled = false;
-
-	dsicm_queue_ulps_work(ddata);
-
-	return r;
-}
-
-static int dsicm_exit_ulps(struct panel_drv_data *ddata)
-{
-	struct omap_dss_device *src = ddata->src;
-	int r;
-
-	if (!ddata->ulps_enabled)
-		return 0;
-
-	src->ops->dsi.ulps(src, false);
-	ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
-
-	r = _dsicm_enable_te(ddata, true);
-	if (r) {
-		dev_err(&ddata->dsi->dev, "failed to re-enable TE");
-		goto err2;
-	}
-
-	dsicm_queue_ulps_work(ddata);
-
-	ddata->ulps_enabled = false;
-
-	return 0;
-
-err2:
-	dev_err(&ddata->dsi->dev, "failed to exit ULPS");
-
-	r = dsicm_panel_reset(ddata);
-	if (!r)
-		ddata->ulps_enabled = false;
-
-	dsicm_queue_ulps_work(ddata);
-
-	return r;
-}
-
-static int dsicm_wake_up(struct panel_drv_data *ddata)
-{
-	if (ddata->ulps_enabled)
-		return dsicm_exit_ulps(ddata);
-
-	dsicm_cancel_ulps_work(ddata);
-	dsicm_queue_ulps_work(ddata);
-	return 0;
-}
-
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
@@ -310,7 +211,6 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
 	mutex_lock(&ddata->lock);
 
 	if (ddata->enabled) {
-		r = dsicm_wake_up(ddata);
 		if (!r)
 			r = dsicm_dcs_write_1(
 				ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
@@ -340,18 +240,12 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(dev);
 	u8 errors = 0;
-	int r;
+	int r = -ENODEV;
 
 	mutex_lock(&ddata->lock);
 
-	if (ddata->enabled) {
-		r = dsicm_wake_up(ddata);
-		if (!r)
-			r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS,
-					&errors);
-	} else {
-		r = -ENODEV;
-	}
+	if (ddata->enabled)
+		r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, &errors);
 
 	mutex_unlock(&ddata->lock);
 
@@ -366,17 +260,12 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(dev);
 	u8 id1, id2, id3;
-	int r;
+	int r = -ENODEV;
 
 	mutex_lock(&ddata->lock);
 
-	if (ddata->enabled) {
-		r = dsicm_wake_up(ddata);
-		if (!r)
-			r = dsicm_get_id(ddata, &id1, &id2, &id3);
-	} else {
-		r = -ENODEV;
-	}
+	if (ddata->enabled)
+		r = dsicm_get_id(ddata, &id1, &id2, &id3);
 
 	mutex_unlock(&ddata->lock);
 
@@ -386,103 +275,12 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
 	return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3);
 }
 
-static ssize_t dsicm_store_ulps(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t count)
-{
-	struct panel_drv_data *ddata = dev_get_drvdata(dev);
-	unsigned long t;
-	int r;
-
-	r = kstrtoul(buf, 0, &t);
-	if (r)
-		return r;
-
-	mutex_lock(&ddata->lock);
-
-	if (ddata->enabled) {
-		if (t)
-			r = dsicm_enter_ulps(ddata);
-		else
-			r = dsicm_wake_up(ddata);
-	}
-
-	mutex_unlock(&ddata->lock);
-
-	if (r)
-		return r;
-
-	return count;
-}
-
-static ssize_t dsicm_show_ulps(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct panel_drv_data *ddata = dev_get_drvdata(dev);
-	unsigned int t;
-
-	mutex_lock(&ddata->lock);
-	t = ddata->ulps_enabled;
-	mutex_unlock(&ddata->lock);
-
-	return snprintf(buf, PAGE_SIZE, "%u\n", t);
-}
-
-static ssize_t dsicm_store_ulps_timeout(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t count)
-{
-	struct panel_drv_data *ddata = dev_get_drvdata(dev);
-	unsigned long t;
-	int r;
-
-	r = kstrtoul(buf, 0, &t);
-	if (r)
-		return r;
-
-	mutex_lock(&ddata->lock);
-	ddata->ulps_timeout = t;
-
-	if (ddata->enabled) {
-		/* dsicm_wake_up will restart the timer */
-		r = dsicm_wake_up(ddata);
-	}
-
-	mutex_unlock(&ddata->lock);
-
-	if (r)
-		return r;
-
-	return count;
-}
-
-static ssize_t dsicm_show_ulps_timeout(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct panel_drv_data *ddata = dev_get_drvdata(dev);
-	unsigned int t;
-
-	mutex_lock(&ddata->lock);
-	t = ddata->ulps_timeout;
-	mutex_unlock(&ddata->lock);
-
-	return snprintf(buf, PAGE_SIZE, "%u\n", t);
-}
-
 static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL);
 static DEVICE_ATTR(hw_revision, S_IRUGO, dsicm_hw_revision_show, NULL);
-static DEVICE_ATTR(ulps, S_IRUGO | S_IWUSR,
-		dsicm_show_ulps, dsicm_store_ulps);
-static DEVICE_ATTR(ulps_timeout, S_IRUGO | S_IWUSR,
-		dsicm_show_ulps_timeout, dsicm_store_ulps_timeout);
 
 static struct attribute *dsicm_attrs[] = {
 	&dev_attr_num_dsi_errors.attr,
 	&dev_attr_hw_revision.attr,
-	&dev_attr_ulps.attr,
-	&dev_attr_ulps_timeout.attr,
 	NULL,
 };
 
@@ -618,15 +416,6 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 	ddata->enabled = false;
 }
 
-static int dsicm_panel_reset(struct panel_drv_data *ddata)
-{
-	dev_err(&ddata->dsi->dev, "performing LCD reset\n");
-
-	dsicm_power_off(ddata);
-	dsicm_hw_reset(ddata);
-	return dsicm_power_on(ddata);
-}
-
 static int dsicm_connect(struct omap_dss_device *src,
 			 struct omap_dss_device *dst)
 {
@@ -668,17 +457,12 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 static void dsicm_disable(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	int r;
 
 	dsicm_bl_power(ddata, false);
 
 	mutex_lock(&ddata->lock);
 
-	dsicm_cancel_ulps_work(ddata);
-
-	r = dsicm_wake_up(ddata);
-	if (!r)
-		dsicm_power_off(ddata);
+	dsicm_power_off(ddata);
 
 	mutex_unlock(&ddata->lock);
 }
@@ -701,10 +485,6 @@ static int dsicm_update(struct omap_dss_device *dssdev,
 
 	mutex_lock(&ddata->lock);
 
-	r = dsicm_wake_up(ddata);
-	if (r)
-		goto err;
-
 	if (!ddata->enabled) {
 		r = 0;
 		goto err;
@@ -745,24 +525,6 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 	return r;
 }
 
-static void dsicm_ulps_work(struct work_struct *work)
-{
-	struct panel_drv_data *ddata = container_of(work, struct panel_drv_data,
-			ulps_work.work);
-	struct omap_dss_device *dssdev = &ddata->dssdev;
-
-	mutex_lock(&ddata->lock);
-
-	if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE || !ddata->enabled) {
-		mutex_unlock(&ddata->lock);
-		return;
-	}
-
-	dsicm_enter_ulps(ddata);
-
-	mutex_unlock(&ddata->lock);
-}
-
 static int dsicm_get_modes(struct omap_dss_device *dssdev,
 			   struct drm_connector *connector)
 {
@@ -860,8 +622,6 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 	else
 		ddata->use_dsi_backlight = true;
 
-	/* TODO: ulps */
-
 	return 0;
 }
 
@@ -908,13 +668,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 
 	mutex_init(&ddata->lock);
 
-	ddata->workqueue = create_singlethread_workqueue("dsicm_wq");
-	if (!ddata->workqueue) {
-		r = -ENOMEM;
-		goto err_reg;
-	}
-	INIT_DELAYED_WORK(&ddata->ulps_work, dsicm_ulps_work);
-
 	dsicm_hw_reset(ddata);
 
 	if (ddata->use_dsi_backlight) {
@@ -954,8 +707,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 err_dsi_attach:
 	sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
 err_bl:
-	destroy_workqueue(ddata->workqueue);
-err_reg:
 	if (ddata->extbldev)
 		put_device(&ddata->extbldev->dev);
 
@@ -982,9 +733,6 @@ static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
 	if (ddata->extbldev)
 		put_device(&ddata->extbldev->dev);
 
-	dsicm_cancel_ulps_work(ddata);
-	destroy_workqueue(ddata->workqueue);
-
 	/* reset, to be sure that the panel is in a valid state */
 	dsicm_hw_reset(ddata);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index fdbc849c8944..5f120cf0fe4e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -207,6 +207,8 @@ struct dsi_reg { u16 module; u16 idx; };
 typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
 struct dsi_data;
 
+static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
+
 static int dsi_display_init_dispc(struct dsi_data *dsi);
 static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
@@ -378,6 +380,9 @@ struct dsi_data {
 
 	bool te_enabled;
 	bool ulps_enabled;
+	bool ulps_auto_idle;
+
+	struct delayed_work ulps_work;
 
 	void (*framedone_callback)(int, void *);
 	void *framedone_data;
@@ -3794,6 +3799,7 @@ static void dsi_handle_framedone(struct dsi_data *dsi, int error)
 		REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
 	}
 
+	dsi_set_ulps_auto(dsi, true);
 	dsi_bus_unlock(dsi);
 
 	dsi->framedone_callback(error, dsi->framedone_data);
@@ -3856,6 +3862,7 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	dsi_bus_lock(dsi);
+	dsi_set_ulps_auto(dsi, false);
 
 	dsi->update_channel = channel;
 	dsi->framedone_callback = callback;
@@ -4124,22 +4131,6 @@ static void dsi_display_disable(struct omap_dss_device *dssdev)
 	dsi_bus_unlock(dsi);
 }
 
-static void dsi_ulps(struct omap_dss_device *dssdev, bool enable)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	DSSDBG("dsi_ulps %d\n", enable);
-
-	dsi_bus_lock(dsi);
-
-	if (enable)
-		_dsi_display_disable(dsi, false, true);
-	else
-		_dsi_display_enable(dsi);
-
-	dsi_bus_unlock(dsi);
-}
-
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
 	dsi->te_enabled = enable;
@@ -4154,6 +4145,42 @@ static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 	return 0;
 }
 
+static void omap_dsi_ulps_work_callback(struct work_struct *work)
+{
+	struct dsi_data *dsi = container_of(work, struct dsi_data,
+					    ulps_work.work);
+
+	dsi_bus_lock(dsi);
+
+	dsi_enable_te(dsi, false);
+
+	_dsi_display_disable(dsi, false, true);
+
+	dsi_bus_unlock(dsi);
+}
+
+static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable)
+{
+	WARN_ON(!dsi_bus_is_locked(dsi));
+
+	if (!dsi->ulps_auto_idle)
+		return;
+
+	if (enable) {
+		schedule_delayed_work(&dsi->ulps_work, msecs_to_jiffies(250));
+	} else {
+		cancel_delayed_work_sync(&dsi->ulps_work);
+
+		if (!dsi->ulps_enabled)
+			return;
+
+		dsi_bus_lock(dsi);
+		_dsi_display_enable(dsi);
+		dsi_enable_te(dsi, true);
+		dsi_bus_unlock(dsi);
+	}
+}
+
 #ifdef PRINT_VERBOSE_VM_TIMINGS
 static void print_dsi_vm(const char *str,
 		const struct omap_dss_dsi_videomode_timings *t)
@@ -4804,7 +4831,9 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 	int r;
 
 	dsi_bus_lock(dsi);
+	dsi_set_ulps_auto(dsi, false);
 	r = _omap_dsi_host_transfer(dsi, msg);
+	dsi_set_ulps_auto(dsi, true);
 	dsi_bus_unlock(dsi);
 
 	return r;
@@ -4844,8 +4873,6 @@ static const struct omap_dss_device_ops dsi_ops = {
 	.disable = dsi_display_disable,
 
 	.dsi = {
-		.ulps = dsi_ulps,
-
 		.set_config = dsi_set_config,
 
 		.enable_video_output = dsi_enable_video_output,
@@ -4974,6 +5001,14 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	dsi->vc[channel].dest = client;
 	dsi->pix_fmt = client->format;
 
+	INIT_DEFERRABLE_WORK(&dsi->ulps_work,
+			     omap_dsi_ulps_work_callback);
+
+	dsi_bus_lock(dsi);
+	dsi->ulps_auto_idle = false;
+	dsi_set_ulps_auto(dsi, true);
+	dsi_bus_unlock(dsi);
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 0d82ba34ca89..524cb87cd9ea 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -282,8 +282,6 @@ struct omap_dss_writeback_info {
 
 struct omapdss_dsi_ops {
 	/* bus configuration */
-	void (*ulps)(struct omap_dss_device *dssdev, bool enable);
-
 	int (*set_config)(struct omap_dss_device *dssdev,
 			const struct omap_dss_dsi_config *cfg);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 29/80] drm/omap: dsi: move panel refresh function to host
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (27 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 28/80] drm/omap: dsi: do ULPS in host driver Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 30/80] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations Tomi Valkeinen
                   ` (51 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This moves the panel refresh/update function from the panel
driver into the DSI host driver to prepare for common drm_panel
support.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 68 --------------
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 91 +++++++++++++++++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h         | 13 +--
 drivers/gpu/drm/omapdrm/omap_crtc.c           | 11 +--
 4 files changed, 88 insertions(+), 95 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index bd115d601f04..98b50220ec31 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -173,27 +173,6 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3)
 	return 0;
 }
 
-static int dsicm_set_update_window(struct panel_drv_data *ddata,
-		u16 x, u16 y, u16 w, u16 h)
-{
-	struct mipi_dsi_device *dsi = ddata->dsi;
-	int r;
-	u16 x1 = x;
-	u16 x2 = x + w - 1;
-	u16 y1 = y;
-	u16 y2 = y + h - 1;
-
-	r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
-	if (r < 0)
-		return r;
-
-	r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
-	if (r < 0)
-		return r;
-
-	return 0;
-}
-
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
@@ -467,48 +446,6 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
 	mutex_unlock(&ddata->lock);
 }
 
-static void dsicm_framedone_cb(int err, void *data)
-{
-	struct panel_drv_data *ddata = data;
-
-	dev_dbg(&ddata->dsi->dev, "framedone, err %d\n", err);
-}
-
-static int dsicm_update(struct omap_dss_device *dssdev,
-				    u16 x, u16 y, u16 w, u16 h)
-{
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *src = ddata->src;
-	int r;
-
-	dev_dbg(&ddata->dsi->dev, "update %d, %d, %d x %d\n", x, y, w, h);
-
-	mutex_lock(&ddata->lock);
-
-	if (!ddata->enabled) {
-		r = 0;
-		goto err;
-	}
-
-	/* XXX no need to send this every frame, but dsi break if not done */
-	r = dsicm_set_update_window(ddata, 0, 0, ddata->vm.hactive,
-				    ddata->vm.vactive);
-	if (r)
-		goto err;
-
-	r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb,
-			ddata);
-	if (r)
-		goto err;
-
-	mutex_unlock(&ddata->lock);
-
-	return 0;
-err:
-	mutex_unlock(&ddata->lock);
-	return r;
-}
-
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
 	struct mipi_dsi_device *dsi = ddata->dsi;
@@ -569,10 +506,6 @@ static const struct omap_dss_device_ops dsicm_ops = {
 	.check_timings	= dsicm_check_timings,
 };
 
-static const struct omap_dss_driver dsicm_dss_driver = {
-	.update		= dsicm_update,
-};
-
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 {
 	struct device_node *node = dsi->dev.of_node;
@@ -653,7 +586,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	dssdev = &ddata->dssdev;
 	dssdev->dev = dev;
 	dssdev->ops = &dsicm_ops;
-	dssdev->driver = &dsicm_dss_driver;
 	dssdev->type = OMAP_DISPLAY_TYPE_DSI;
 	dssdev->display = true;
 	dssdev->owner = THIS_MODULE;
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 5f120cf0fe4e..288f92e95b6e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -214,6 +214,9 @@ static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
 
+static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
+				       const struct mipi_dsi_msg *msg);
+
 /* DSI PLL HSDIV indices */
 #define HSDIV_DISPC	0
 #define HSDIV_DSI	1
@@ -384,9 +387,6 @@ struct dsi_data {
 
 	struct delayed_work ulps_work;
 
-	void (*framedone_callback)(int, void *);
-	void *framedone_data;
-
 	struct delayed_work framedone_timeout_work;
 
 #ifdef DSI_CATCH_MISSING_TE
@@ -3802,8 +3802,6 @@ static void dsi_handle_framedone(struct dsi_data *dsi, int error)
 	dsi_set_ulps_auto(dsi, true);
 	dsi_bus_unlock(dsi);
 
-	dsi->framedone_callback(error, dsi->framedone_data);
-
 	if (!error)
 		dsi_perf_show(dsi, "DISPC");
 }
@@ -3835,6 +3833,8 @@ static void dsi_framedone_irq_callback(void *data)
 
 	cancel_delayed_work(&dsi->framedone_timeout_work);
 
+	DSSDBG("Framedone received!\n");
+
 	dsi_handle_framedone(dsi, 0);
 }
 
@@ -3856,17 +3856,69 @@ static int _dsi_update(struct dsi_data *dsi)
 	return 0;
 }
 
-static int dsi_update(struct omap_dss_device *dssdev, int channel,
-		void (*callback)(int, void *), void *data)
+static int _dsi_update_window(struct dsi_data *dsi, int channel,
+			      int x, int y, int w, int h)
+{
+	int x1 = x, x2 = (x + w - 1);
+	int y1 = y, y2 = (y + h - 1);
+	u8 payloadX[5] = { MIPI_DCS_SET_COLUMN_ADDRESS,
+			   x1 >> 8, x1 & 0xff, x2 >> 8, x2 & 0xff };
+	u8 payloadY[5] = { MIPI_DCS_SET_PAGE_ADDRESS,
+			   y1 >> 8, y1 & 0xff, y2 >> 8, y2 & 0xff };
+	struct mipi_dsi_msg msgX = { 0 }, msgY = { 0 };
+	int ret;
+
+	WARN_ON(!dsi_bus_is_locked(dsi));
+
+	msgX.type = MIPI_DSI_DCS_LONG_WRITE;
+	msgX.channel = channel;
+	msgX.tx_buf = payloadX;
+	msgX.tx_len = sizeof(payloadX);
+
+	msgY.type = MIPI_DSI_DCS_LONG_WRITE;
+	msgY.channel = channel;
+	msgY.tx_buf = payloadY;
+	msgY.tx_len = sizeof(payloadY);
+
+	ret = _omap_dsi_host_transfer(dsi, &msgX);
+	if (ret != 0)
+		return ret;
+
+	return _omap_dsi_host_transfer(dsi, &msgY);
+}
+
+static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
+	int r;
+
+	if (channel > 3)
+		return -EINVAL;
 
 	dsi_bus_lock(dsi);
+
+	if (!dsi->vc[channel].dest) {
+		r = -ENODEV;
+		goto err;
+	}
+
+	if (dsi->vm.hactive == 0 || dsi->vm.vactive == 0) {
+		r = -EINVAL;
+		goto err;
+	}
+
+	DSSDBG("dsi_update_channel: %d", channel);
+
 	dsi_set_ulps_auto(dsi, false);
 
+	r = _dsi_update_window(dsi, channel, 0, 0, dsi->vm.hactive,
+			       dsi->vm.vactive);
+	if (r < 0) {
+		DSSWARN("window update error: %d\n", r);
+		goto err;
+	}
+
 	dsi->update_channel = channel;
-	dsi->framedone_callback = callback;
-	dsi->framedone_data = data;
 
 	if (dsi->te_enabled && dsi->te_gpio) {
 		schedule_delayed_work(&dsi->te_timeout_work,
@@ -3877,6 +3929,25 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
 	}
 
 	return 0;
+
+err:
+	dsi_set_ulps_auto(dsi, true);
+	dsi_bus_unlock(dsi);
+	return r;
+}
+
+static int dsi_update_all(struct omap_dss_device *dssdev)
+{
+	unsigned int i;
+	int r;
+
+	for (i = 0; i < 4; i++) {
+		r = dsi_update_channel(dssdev, i);
+		if (r && r != -ENODEV)
+			return r;
+	}
+
+	return r;
 }
 
 /* Display funcs */
@@ -4878,7 +4949,7 @@ static const struct omap_dss_device_ops dsi_ops = {
 		.enable_video_output = dsi_enable_video_output,
 		.disable_video_output = dsi_disable_video_output,
 
-		.update = dsi_update,
+		.update = dsi_update_all,
 	},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 524cb87cd9ea..de4c779c358a 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -281,13 +281,12 @@ struct omap_dss_writeback_info {
 };
 
 struct omapdss_dsi_ops {
-	/* bus configuration */
+	int (*update)(struct omap_dss_device *dssdev);
+
+	/* legacy API used by omapdss panels */
 	int (*set_config)(struct omap_dss_device *dssdev,
 			const struct omap_dss_dsi_config *cfg);
 
-	int (*update)(struct omap_dss_device *dssdev, int channel,
-			void (*callback)(int, void *), void *data);
-
 	int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
 	void (*disable_video_output)(struct omap_dss_device *dssdev,
 			int channel);
@@ -351,7 +350,6 @@ struct omap_dss_device {
 
 	const char *name;
 
-	const struct omap_dss_driver *driver;
 	const struct omap_dss_device_ops *ops;
 	unsigned long ops_flags;
 	u32 bus_flags;
@@ -372,11 +370,6 @@ struct omap_dss_device {
 	unsigned int of_port;
 };
 
-struct omap_dss_driver {
-	int (*update)(struct omap_dss_device *dssdev,
-			       u16 x, u16 y, u16 w, u16 h);
-};
-
 struct dss_device *omapdss_get_dss(void);
 void omapdss_set_dss(struct dss_device *dss);
 static inline bool omapdss_is_initialized(void)
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index dac9ccda98df..3068e4fffa16 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -362,10 +362,8 @@ static void omap_crtc_manual_display_update(struct work_struct *data)
 {
 	struct omap_crtc *omap_crtc =
 			container_of(data, struct omap_crtc, update_work.work);
-	struct drm_display_mode *mode = &omap_crtc->pipe->crtc->mode;
-	struct omap_dss_device *dssdev = omap_crtc->pipe->output->next;
+	struct omap_dss_device *dssdev = omap_crtc->pipe->output;
 	struct drm_device *dev = omap_crtc->base.dev;
-	const struct omap_dss_driver *dssdrv;
 	int ret;
 
 	if (!dssdev) {
@@ -373,13 +371,12 @@ static void omap_crtc_manual_display_update(struct work_struct *data)
 		return;
 	}
 
-	dssdrv = dssdev->driver;
-	if (!dssdrv || !dssdrv->update) {
-		dev_err_once(dev->dev, "missing or incorrect dssdrv!");
+	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI || !dssdev->ops->dsi.update) {
+		dev_err_once(dev->dev, "no DSI update callback found!");
 		return;
 	}
 
-	ret = dssdrv->update(dssdev, 0, 0, mode->hdisplay, mode->vdisplay);
+	ret = dssdev->ops->dsi.update(dssdev);
 	if (ret < 0) {
 		spin_lock_irq(&dev->event_lock);
 		omap_crtc->pending = false;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 30/80] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (28 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 29/80] drm/omap: dsi: move panel refresh function to host Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 31/80] drm/omap: dsi: drop custom panel capability support Tomi Valkeinen
                   ` (50 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Complete the direction reversal of the DSS device enable/disable
operations started by 19b4200d8f4b ("drm/omap: Reverse direction
of the DSS device enable/disable operations").

This effectively drops the requirement of calling DSS specific
code from the DSI panel driver moving it a bit further to a
standard drm_panel driver.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 74 +++++++++----------
 drivers/gpu/drm/omapdrm/omap_encoder.c        | 28 ++-----
 2 files changed, 45 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 98b50220ec31..6ceff8bb3641 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -285,27 +285,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	struct omap_dss_device *src = ddata->src;
 	u8 id1, id2, id3;
 	int r;
-	struct omap_dss_dsi_config dsi_config = {
-		.vm = &ddata->vm,
-		.hs_clk_min = 150000000,
-		.hs_clk_max = 300000000,
-		.lp_clk_min = 7000000,
-		.lp_clk_max = 10000000,
-	};
-
-	r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
-	if (r) {
-		dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
-		return r;
-	}
-
-	r = src->ops->dsi.set_config(src, &dsi_config);
-	if (r) {
-		dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
-		goto err_regulators;
-	}
-
-	src->ops->enable(src);
 
 	dsicm_hw_reset(ddata);
 
@@ -360,12 +339,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 
 	dsicm_hw_reset(ddata);
 
-	src->ops->disable(src);
-err_regulators:
-	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
-	if (r)
-		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
-
 	return r;
 }
 
@@ -374,6 +347,8 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 	struct omap_dss_device *src = ddata->src;
 	int r;
 
+	ddata->enabled = false;
+
 	src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
 
 	r = mipi_dsi_dcs_set_display_off(ddata->dsi);
@@ -385,14 +360,6 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 				"error disabling panel, issuing HW reset\n");
 		dsicm_hw_reset(ddata);
 	}
-
-	src->ops->disable(src);
-
-	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
-	if (r)
-		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
-
-	ddata->enabled = false;
 }
 
 static int dsicm_connect(struct omap_dss_device *src,
@@ -412,6 +379,29 @@ static void dsicm_disconnect(struct omap_dss_device *src,
 	ddata->src = NULL;
 }
 
+static void dsicm_pre_enable(struct omap_dss_device *dssdev)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_dss_device *src = ddata->src;
+	int r;
+	struct omap_dss_dsi_config dsi_config = {
+		.vm = &ddata->vm,
+		.hs_clk_min = 150000000,
+		.hs_clk_max = 300000000,
+		.lp_clk_min = 7000000,
+		.lp_clk_max = 10000000,
+	};
+
+	r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
+	if (r)
+		dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
+
+	r = src->ops->dsi.set_config(src, &dsi_config);
+	if (r) {
+		dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
+	}
+}
+
 static void dsicm_enable(struct omap_dss_device *dssdev)
 {
 	struct panel_drv_data *ddata = to_panel_data(dssdev);
@@ -446,6 +436,16 @@ static void dsicm_disable(struct omap_dss_device *dssdev)
 	mutex_unlock(&ddata->lock);
 }
 
+static void dsicm_post_disable(struct omap_dss_device *dssdev)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	int r;
+
+	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
+	if (r)
+		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
+}
+
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 {
 	struct mipi_dsi_device *dsi = ddata->dsi;
@@ -499,8 +499,10 @@ static const struct omap_dss_device_ops dsicm_ops = {
 	.connect	= dsicm_connect,
 	.disconnect	= dsicm_disconnect,
 
+	.pre_enable	= dsicm_pre_enable,
 	.enable		= dsicm_enable,
 	.disable	= dsicm_disable,
+	.post_disable	= dsicm_post_disable,
 
 	.get_modes	= dsicm_get_modes,
 	.check_timings	= dsicm_check_timings,
@@ -656,8 +658,6 @@ static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
 
 	omapdss_device_unregister(dssdev);
 
-	if (omapdss_device_is_enabled(dssdev))
-		dsicm_disable(dssdev);
 	omapdss_device_disconnect(ddata->src, dssdev);
 
 	sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
index 18a79dde6815..330296ae8344 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -136,16 +136,10 @@ static void omap_encoder_disable(struct drm_encoder *encoder)
 	 */
 	omapdss_device_disable(dssdev->next);
 
-	/*
-	 * Disable the internal encoder. This will disable the DSS output. The
-	 * DSI is treated as an exception as DSI pipelines still use the legacy
-	 * flow where the pipeline output controls the encoder.
-	 */
-	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI) {
-		if (dssdev->ops && dssdev->ops->disable)
-			dssdev->ops->disable(dssdev);
-		dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
-	}
+	/* Disable the internal encoder. This will disable the DSS output. */
+	if (dssdev->ops && dssdev->ops->disable)
+		dssdev->ops->disable(dssdev);
+	dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
 
 	/*
 	 * Perform the post-disable operations on the chain of external devices
@@ -165,16 +159,10 @@ static void omap_encoder_enable(struct drm_encoder *encoder)
 	/* Prepare the chain of external devices for pipeline enable. */
 	omapdss_device_pre_enable(dssdev->next);
 
-	/*
-	 * Enable the internal encoder. This will enable the DSS output. The
-	 * DSI is treated as an exception as DSI pipelines still use the legacy
-	 * flow where the pipeline output controls the encoder.
-	 */
-	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI) {
-		if (dssdev->ops && dssdev->ops->enable)
-			dssdev->ops->enable(dssdev);
-		dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
-	}
+	/* Enable the internal encoder. This will enable the DSS output. */
+	if (dssdev->ops && dssdev->ops->enable)
+		dssdev->ops->enable(dssdev);
+	dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
 
 	/*
 	 * Enable the chain of external devices, starting at the one at the
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 31/80] drm/omap: dsi: drop custom panel capability support
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (29 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 30/80] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 32/80] drm/omap: dsi: convert to drm_panel Tomi Valkeinen
                   ` (49 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Due to previous changes the DSI encoder gets the capabilities
via DSI client's mode_flags and no longer needs the omapdss
specific caps. The core code now checks if the DSI encoder
is actually configured into command mode instead of just checking
the panel capabilities.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c |  3 ---
 drivers/gpu/drm/omapdrm/dss/dsi.c               |  8 ++++++++
 drivers/gpu/drm/omapdrm/dss/omapdss.h           |  8 +-------
 drivers/gpu/drm/omapdrm/omap_crtc.c             | 17 ++++++++---------
 4 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 6ceff8bb3641..389efed5e9dd 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -594,9 +594,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	dssdev->of_port = 0;
 	dssdev->ops_flags = OMAP_DSS_DEVICE_OP_MODES;
 
-	dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE |
-		OMAP_DSS_DISPLAY_CAP_TEAR_ELIM;
-
 	omapdss_display_init(dssdev);
 	omapdss_device_register(dssdev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 288f92e95b6e..1a5ab2fd1d81 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4731,6 +4731,13 @@ static bool dsi_vm_calc(struct dsi_data *dsi,
 			dsi_vm_calc_pll_cb, ctx);
 }
 
+static bool dsi_is_video_mode(struct omap_dss_device *dssdev)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+
+	return dsi->mode == OMAP_DSS_DSI_VIDEO_MODE;
+}
+
 static int dsi_set_config(struct omap_dss_device *dssdev,
 		const struct omap_dss_dsi_config *config)
 {
@@ -4950,6 +4957,7 @@ static const struct omap_dss_device_ops dsi_ops = {
 		.disable_video_output = dsi_disable_video_output,
 
 		.update = dsi_update_all,
+		.is_video_mode = dsi_is_video_mode,
 	},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index de4c779c358a..4200611525d5 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -123,11 +123,6 @@ enum omap_dss_dsi_mode {
 	OMAP_DSS_DSI_VIDEO_MODE,
 };
 
-enum omap_display_caps {
-	OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE	= 1 << 0,
-	OMAP_DSS_DISPLAY_CAP_TEAR_ELIM		= 1 << 1,
-};
-
 enum omap_dss_display_state {
 	OMAP_DSS_DISPLAY_DISABLED = 0,
 	OMAP_DSS_DISPLAY_ACTIVE,
@@ -282,6 +277,7 @@ struct omap_dss_writeback_info {
 
 struct omapdss_dsi_ops {
 	int (*update)(struct omap_dss_device *dssdev);
+	bool (*is_video_mode)(struct omap_dss_device *dssdev);
 
 	/* legacy API used by omapdss panels */
 	int (*set_config)(struct omap_dss_device *dssdev,
@@ -354,8 +350,6 @@ struct omap_dss_device {
 	unsigned long ops_flags;
 	u32 bus_flags;
 
-	enum omap_display_caps caps;
-
 	enum omap_dss_display_state state;
 
 	/* OMAP DSS output specific fields */
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 3068e4fffa16..f6b968060cf0 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -496,8 +496,7 @@ static enum drm_mode_status omap_crtc_mode_valid(struct drm_crtc *crtc,
 	 * valid DISPC mode. DSI will calculate and configure the
 	 * proper DISPC mode later.
 	 */
-	if (omap_crtc->pipe->output->next == NULL ||
-	    omap_crtc->pipe->output->next->type != OMAP_DISPLAY_TYPE_DSI) {
+	if (omap_crtc->pipe->output->type != OMAP_DISPLAY_TYPE_DSI) {
 		r = priv->dispc_ops->mgr_check_timings(priv->dispc,
 						       omap_crtc->channel,
 						       &vm);
@@ -549,17 +548,17 @@ static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc)
 static bool omap_crtc_is_manually_updated(struct drm_crtc *crtc)
 {
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
-	struct omap_dss_device *display = omap_crtc->pipe->output->next;
+	struct omap_dss_device *dssdev = omap_crtc->pipe->output;
 
-	if (!display)
+	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI ||
+	    !dssdev->ops->dsi.is_video_mode)
 		return false;
 
-	if (display->caps & OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE) {
-		DBG("detected manually updated display!");
-		return true;
-	}
+	if (dssdev->ops->dsi.is_video_mode(dssdev))
+		return false;
 
-	return false;
+	DBG("detected manually updated display!");
+	return true;
 }
 
 static int omap_crtc_atomic_check(struct drm_crtc *crtc,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 32/80] drm/omap: dsi: convert to drm_panel
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (30 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 31/80] drm/omap: dsi: drop custom panel capability support Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 33/80] drm/omap: drop omapdss-boot-init Tomi Valkeinen
                   ` (48 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

This converts the DSI module to expect common drm_panel display
drivers instead of dssdev based ones.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 203 +++++++-----------
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 128 +++++++++--
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |   1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |   8 -
 4 files changed, 182 insertions(+), 158 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 389efed5e9dd..5d6a001f8f71 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -6,8 +6,6 @@
  * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
  */
 
-/* #define DEBUG */
-
 #include <linux/backlight.h>
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
@@ -20,11 +18,14 @@
 #include <linux/regulator/consumer.h>
 
 #include <drm/drm_connector.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
 
+#include <video/display_timing.h>
 #include <video/mipi_display.h>
 #include <video/of_display_timing.h>
-
-#include "../dss/omapdss.h"
+#include <video/videomode.h>
 
 #define DCS_READ_NUM_ERRORS	0x05
 #define DCS_GET_ID1		0xda
@@ -35,11 +36,8 @@
 
 struct panel_drv_data {
 	struct mipi_dsi_device *dsi;
-
-	struct omap_dss_device dssdev;
-	struct omap_dss_device *src;
-
-	struct videomode vm;
+	struct drm_panel panel;
+	struct drm_display_mode mode;
 
 	struct mutex lock;
 
@@ -67,7 +65,10 @@ struct panel_drv_data {
 	bool intro_printed;
 };
 
-#define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
+static inline struct panel_drv_data *panel_to_ddata(struct drm_panel *panel)
+{
+	return container_of(panel, struct panel_drv_data, panel);
+}
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
 
@@ -282,7 +283,6 @@ static void dsicm_hw_reset(struct panel_drv_data *ddata)
 
 static int dsicm_power_on(struct panel_drv_data *ddata)
 {
-	struct omap_dss_device *src = ddata->src;
 	u8 id1, id2, id3;
 	int r;
 
@@ -319,10 +319,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
-	r = src->ops->dsi.enable_video_output(src, ddata->dsi->channel);
-	if (r)
-		goto err;
-
 	ddata->enabled = true;
 
 	if (!ddata->intro_printed) {
@@ -342,15 +338,12 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	return r;
 }
 
-static void dsicm_power_off(struct panel_drv_data *ddata)
+static int dsicm_power_off(struct panel_drv_data *ddata)
 {
-	struct omap_dss_device *src = ddata->src;
 	int r;
 
 	ddata->enabled = false;
 
-	src->ops->dsi.disable_video_output(src, ddata->dsi->channel);
-
 	r = mipi_dsi_dcs_set_display_off(ddata->dsi);
 	if (!r)
 		r = dsicm_sleep_in(ddata);
@@ -360,51 +353,25 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
 				"error disabling panel, issuing HW reset\n");
 		dsicm_hw_reset(ddata);
 	}
-}
-
-static int dsicm_connect(struct omap_dss_device *src,
-			 struct omap_dss_device *dst)
-{
-	struct panel_drv_data *ddata = to_panel_data(dst);
-
-	ddata->src = src;
-	return 0;
-}
 
-static void dsicm_disconnect(struct omap_dss_device *src,
-			     struct omap_dss_device *dst)
-{
-	struct panel_drv_data *ddata = to_panel_data(dst);
-
-	ddata->src = NULL;
+	return r;
 }
 
-static void dsicm_pre_enable(struct omap_dss_device *dssdev)
+static int dsicm_prepare(struct drm_panel *panel)
 {
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	struct omap_dss_device *src = ddata->src;
+	struct panel_drv_data *ddata = panel_to_ddata(panel);
 	int r;
-	struct omap_dss_dsi_config dsi_config = {
-		.vm = &ddata->vm,
-		.hs_clk_min = 150000000,
-		.hs_clk_max = 300000000,
-		.lp_clk_min = 7000000,
-		.lp_clk_max = 10000000,
-	};
 
 	r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
 	if (r)
 		dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
 
-	r = src->ops->dsi.set_config(src, &dsi_config);
-	if (r) {
-		dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
-	}
+	return r;
 }
 
-static void dsicm_enable(struct omap_dss_device *dssdev)
+static int dsicm_enable(struct drm_panel *panel)
 {
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct panel_drv_data *ddata = panel_to_ddata(panel);
 	int r;
 
 	mutex_lock(&ddata->lock);
@@ -417,33 +384,39 @@ static void dsicm_enable(struct omap_dss_device *dssdev)
 
 	dsicm_bl_power(ddata, true);
 
-	return;
+	return 0;
 err:
-	dev_dbg(&ddata->dsi->dev, "enable failed (%d)\n", r);
+	dev_err(&ddata->dsi->dev, "enable failed (%d)\n", r);
 	mutex_unlock(&ddata->lock);
+	return r;
+}
+
+static int dsicm_unprepare(struct drm_panel *panel)
+{
+	struct panel_drv_data *ddata = panel_to_ddata(panel);
+	int r;
+
+	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
+	if (r)
+		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
+
+	return r;
 }
 
-static void dsicm_disable(struct omap_dss_device *dssdev)
+static int dsicm_disable(struct drm_panel *panel)
 {
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct panel_drv_data *ddata = panel_to_ddata(panel);
+	int r;
 
 	dsicm_bl_power(ddata, false);
 
 	mutex_lock(&ddata->lock);
 
-	dsicm_power_off(ddata);
+	r = dsicm_power_off(ddata);
 
 	mutex_unlock(&ddata->lock);
-}
-
-static void dsicm_post_disable(struct omap_dss_device *dssdev)
-{
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	int r;
 
-	r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
-	if (r)
-		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
+	return r;
 }
 
 static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
@@ -462,50 +435,37 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
 	return r;
 }
 
-static int dsicm_get_modes(struct omap_dss_device *dssdev,
+static int dsicm_get_modes(struct drm_panel *panel,
 			   struct drm_connector *connector)
 {
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct panel_drv_data *ddata = panel_to_ddata(panel);
+	struct drm_display_mode *mode;
+
+	mode = drm_mode_duplicate(connector->dev, &ddata->mode);
+	if (!mode) {
+		dev_err(&ddata->dsi->dev, "failed to add mode %ux%ux@%u kHz\n",
+			ddata->mode.hdisplay, ddata->mode.vdisplay,
+			ddata->mode.clock);
+		return -ENOMEM;
+	}
+
+	drm_mode_set_name(mode);
+	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
 
 	connector->display_info.width_mm = ddata->width_mm;
 	connector->display_info.height_mm = ddata->height_mm;
 
-	return omapdss_display_get_modes(connector, &ddata->vm);
-}
-
-static int dsicm_check_timings(struct omap_dss_device *dssdev,
-			       struct drm_display_mode *mode)
-{
-	struct panel_drv_data *ddata = to_panel_data(dssdev);
-	int ret = 0;
-
-	if (mode->hdisplay != ddata->vm.hactive)
-		ret = -EINVAL;
-
-	if (mode->vdisplay != ddata->vm.vactive)
-		ret = -EINVAL;
+	drm_mode_probed_add(connector, mode);
 
-	if (ret) {
-		dev_warn(dssdev->dev, "wrong resolution: %d x %d",
-			 mode->hdisplay, mode->vdisplay);
-		dev_warn(dssdev->dev, "panel resolution: %d x %d",
-			 ddata->vm.hactive, ddata->vm.vactive);
-	}
-
-	return ret;
+	return 1;
 }
 
-static const struct omap_dss_device_ops dsicm_ops = {
-	.connect	= dsicm_connect,
-	.disconnect	= dsicm_disconnect,
-
-	.pre_enable	= dsicm_pre_enable,
-	.enable		= dsicm_enable,
-	.disable	= dsicm_disable,
-	.post_disable	= dsicm_post_disable,
-
-	.get_modes	= dsicm_get_modes,
-	.check_timings	= dsicm_check_timings,
+static const struct drm_panel_funcs dsicm_panel_funcs = {
+	.unprepare = dsicm_unprepare,
+	.disable = dsicm_disable,
+	.prepare = dsicm_prepare,
+	.enable = dsicm_enable,
+	.get_modes = dsicm_get_modes,
 };
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
@@ -514,6 +474,10 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 	struct backlight_device *backlight;
 	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
 	struct display_timing timing;
+	struct videomode vm = {
+		.hactive = 864,
+		.vactive = 480,
+	};
 	int err;
 
 	ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
@@ -525,15 +489,16 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 
 	err = of_get_display_timing(node, "panel-timing", &timing);
 	if (!err) {
-		videomode_from_timing(&timing, &ddata->vm);
-		if (!ddata->vm.pixelclock)
-			ddata->vm.pixelclock =
-				ddata->vm.hactive * ddata->vm.vactive * 60;
+		videomode_from_timing(&timing, &vm);
 	} else {
 		dev_warn(&dsi->dev,
 			 "failed to get video timing, using defaults\n");
 	}
 
+	if (!vm.pixelclock)
+		vm.pixelclock = vm.hactive * vm.vactive * 60;
+	drm_display_mode_from_videomode(&vm, &ddata->mode);
+
 	ddata->width_mm = 0;
 	of_property_read_u32(node, "width-mm", &ddata->width_mm);
 
@@ -565,7 +530,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	struct panel_drv_data *ddata;
 	struct backlight_device *bldev = NULL;
 	struct device *dev = &dsi->dev;
-	struct omap_dss_device *dssdev;
 	int r;
 
 	dev_dbg(dev, "probe\n");
@@ -577,30 +541,17 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	mipi_dsi_set_drvdata(dsi, ddata);
 	ddata->dsi = dsi;
 
-	ddata->vm.hactive = 864;
-	ddata->vm.vactive = 480;
-	ddata->vm.pixelclock = 864 * 480 * 60;
-
 	r = dsicm_probe_of(dsi);
 	if (r)
 		return r;
 
-	dssdev = &ddata->dssdev;
-	dssdev->dev = dev;
-	dssdev->ops = &dsicm_ops;
-	dssdev->type = OMAP_DISPLAY_TYPE_DSI;
-	dssdev->display = true;
-	dssdev->owner = THIS_MODULE;
-	dssdev->of_port = 0;
-	dssdev->ops_flags = OMAP_DSS_DEVICE_OP_MODES;
-
-	omapdss_display_init(dssdev);
-	omapdss_device_register(dssdev);
-
 	mutex_init(&ddata->lock);
 
 	dsicm_hw_reset(ddata);
 
+	drm_panel_init(&ddata->panel, dev, &dsicm_panel_funcs,
+		       DRM_MODE_CONNECTOR_DSI);
+
 	if (ddata->use_dsi_backlight) {
 		struct backlight_properties props = { 0 };
 		props.max_brightness = 255;
@@ -629,6 +580,8 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	dsi->hs_rate = 300000000;
 	dsi->lp_rate = 10000000;
 
+	drm_panel_add(&ddata->panel);
+
 	r = mipi_dsi_attach(dsi);
 	if (r < 0)
 		goto err_dsi_attach;
@@ -636,6 +589,7 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	return 0;
 
 err_dsi_attach:
+	drm_panel_remove(&ddata->panel);
 	sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
 err_bl:
 	if (ddata->extbldev)
@@ -647,15 +601,12 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
 {
 	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
-	struct omap_dss_device *dssdev = &ddata->dssdev;
 
 	dev_dbg(&dsi->dev, "remove\n");
 
 	mipi_dsi_detach(dsi);
 
-	omapdss_device_unregister(dssdev);
-
-	omapdss_device_disconnect(ddata->src, dssdev);
+	drm_panel_remove(&ddata->panel);
 
 	sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
 
@@ -669,7 +620,7 @@ static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
 }
 
 static const struct of_device_id dsicm_of_match[] = {
-	{ .compatible = "omapdss,panel-dsi-cm", },
+	{ .compatible = "panel-dsi-cm", },
 	{},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 1a5ab2fd1d81..93900739237e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -36,6 +36,7 @@
 #include <linux/sys_soc.h>
 
 #include <drm/drm_mipi_dsi.h>
+#include <drm/drm_panel.h>
 #include <video/mipi_display.h>
 
 #include "omapdss.h"
@@ -217,6 +218,8 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
 static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
 				       const struct mipi_dsi_msg *msg);
 
+static void dsi_display_disable(struct omap_dss_device *dssdev);
+
 /* DSI PLL HSDIV indices */
 #define HSDIV_DISPC	0
 #define HSDIV_DSI	1
@@ -384,6 +387,7 @@ struct dsi_data {
 	bool te_enabled;
 	bool ulps_enabled;
 	bool ulps_auto_idle;
+	bool video_enabled;
 
 	struct delayed_work ulps_work;
 
@@ -424,6 +428,8 @@ struct dsi_data {
 
 	unsigned int scp_clk_refcount;
 
+	struct omap_dss_dsi_config config;
+
 	struct dss_lcd_mgr_config mgr_config;
 	struct videomode vm;
 	enum mipi_dsi_pixel_format pix_fmt;
@@ -3622,7 +3628,7 @@ static int dsi_configure_pins(struct omap_dss_device *dssdev,
 	return 0;
 }
 
-static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
+static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
@@ -3631,8 +3637,10 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 	int r;
 
 	r = dsi_display_init_dispc(dsi);
-	if (r)
-		return r;
+	if (r) {
+		dev_err(dsi->dev, "failed to init dispc!\n");
+		return;
+	}
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
 		switch (dsi->pix_fmt) {
@@ -3672,7 +3680,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 	if (r)
 		goto err_mgr_enable;
 
-	return 0;
+	return;
 
 err_mgr_enable:
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
@@ -3681,7 +3689,8 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 	}
 err_pix_fmt:
 	dsi_display_uninit_dispc(dsi);
-	return r;
+	dev_err(dsi->dev, "failed to enable DSI encoder!\n");
+	return;
 }
 
 static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel)
@@ -3704,6 +3713,25 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
 	dsi_display_uninit_dispc(dsi);
 }
 
+static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+	unsigned int i;
+
+	dsi_bus_lock(dsi);
+	dsi->video_enabled = false;
+
+	for (i = 0; i < 4; i++) {
+		if (!dsi->vc[i].dest)
+			continue;
+		dsi_disable_video_output(dssdev, i);
+	}
+
+	dsi_display_disable(dssdev);
+
+	dsi_bus_unlock(dsi);
+}
+
 static void dsi_update_screen_dispc(struct dsi_data *dsi)
 {
 	unsigned int bytespp;
@@ -3897,6 +3925,11 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
 
 	dsi_bus_lock(dsi);
 
+	if (!dsi->video_enabled) {
+		r = -EIO;
+		goto err;
+	}
+
 	if (!dsi->vc[channel].dest) {
 		r = -ENODEV;
 		goto err;
@@ -4167,8 +4200,30 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	DSSDBG("dsi_display_enable\n");
 
-	dsi_bus_lock(dsi);
+	WARN_ON(!dsi_bus_is_locked(dsi));
+
 	_dsi_display_enable(dsi);
+}
+
+static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+	unsigned int i;
+
+	dsi_bus_lock(dsi);
+
+	dsi_display_enable(dssdev);
+
+	for (i = 0; i < 4; i++) {
+		if (!dsi->vc[i].dest)
+			continue;
+		dsi_enable_video_output(dssdev, i);
+	}
+
+	dsi->video_enabled = true;
+
+	dsi_set_ulps_auto(dsi, true);
+
 	dsi_bus_unlock(dsi);
 }
 
@@ -4195,11 +4250,11 @@ static void dsi_display_disable(struct omap_dss_device *dssdev)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
+	WARN_ON(!dsi_bus_is_locked(dsi));
+
 	DSSDBG("dsi_display_disable\n");
 
-	dsi_bus_lock(dsi);
 	_dsi_display_disable(dsi, true, false);
-	dsi_bus_unlock(dsi);
 }
 
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
@@ -4739,14 +4794,18 @@ static bool dsi_is_video_mode(struct omap_dss_device *dssdev)
 }
 
 static int dsi_set_config(struct omap_dss_device *dssdev,
-		const struct omap_dss_dsi_config *config)
+		const struct drm_display_mode *mode)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	struct dsi_clk_calc_ctx ctx;
-	struct omap_dss_dsi_config cfg = *config;
+	struct videomode vm;
+	struct omap_dss_dsi_config cfg = dsi->config;
 	bool ok;
 	int r;
 
+	drm_display_mode_to_videomode(mode, &vm);
+	cfg.vm = &vm;
+
 	mutex_lock(&dsi->lock);
 
 	cfg.mode = dsi->mode;
@@ -4909,9 +4968,15 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 	int r;
 
 	dsi_bus_lock(dsi);
-	dsi_set_ulps_auto(dsi, false);
-	r = _omap_dsi_host_transfer(dsi, msg);
-	dsi_set_ulps_auto(dsi, true);
+
+	if (dsi->video_enabled) {
+		dsi_set_ulps_auto(dsi, false);
+		r = _omap_dsi_host_transfer(dsi, msg);
+		dsi_set_ulps_auto(dsi, true);
+	} else {
+		r = -EIO;
+	}
+
 	dsi_bus_unlock(dsi);
 
 	return r;
@@ -4932,6 +4997,23 @@ static int dsi_get_clocks(struct dsi_data *dsi)
 	return 0;
 }
 
+static void dsi_set_timings(struct omap_dss_device *dssdev,
+			    const struct drm_display_mode *mode)
+{
+	DSSDBG("dsi_set_timings\n");
+	dsi_set_config(dssdev, mode);
+}
+
+static int dsi_check_timings(struct omap_dss_device *dssdev,
+			     struct drm_display_mode *mode)
+{
+	DSSDBG("dsi_check_timings\n");
+
+	/* TODO */
+
+	return 0;
+}
+
 static int dsi_connect(struct omap_dss_device *src,
 		       struct omap_dss_device *dst)
 {
@@ -4947,15 +5029,13 @@ static void dsi_disconnect(struct omap_dss_device *src,
 static const struct omap_dss_device_ops dsi_ops = {
 	.connect = dsi_connect,
 	.disconnect = dsi_disconnect,
-	.enable = dsi_display_enable,
-	.disable = dsi_display_disable,
+	.enable = dsi_enable_video_outputs,
+	.disable = dsi_disable_video_outputs,
 
-	.dsi = {
-		.set_config = dsi_set_config,
-
-		.enable_video_output = dsi_enable_video_output,
-		.disable_video_output = dsi_disable_video_output,
+	.check_timings = dsi_check_timings,
+	.set_timings = dsi_set_timings,
 
+	.dsi = {
 		.update = dsi_update_all,
 		.is_video_mode = dsi_is_video_mode,
 	},
@@ -5083,10 +5163,12 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	INIT_DEFERRABLE_WORK(&dsi->ulps_work,
 			     omap_dsi_ulps_work_callback);
 
-	dsi_bus_lock(dsi);
+	dsi->config.hs_clk_min = 150000000; // TODO: get from client?
+	dsi->config.hs_clk_max = client->hs_rate;
+	dsi->config.lp_clk_min = 7000000; // TODO: get from client?
+	dsi->config.lp_clk_max = client->lp_rate;
+
 	dsi->ulps_auto_idle = false;
-	dsi_set_ulps_auto(dsi, true);
-	dsi_bus_unlock(dsi);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
index 72a7da7bfff1..18560ca4bbb0 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
@@ -174,7 +174,6 @@ static const struct of_device_id omapdss_of_match[] __initconst = {
 };
 
 static const struct of_device_id omapdss_of_fixups_whitelist[] __initconst = {
-	{ .compatible = "panel-dsi-cm" },
 	{},
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 4200611525d5..3ee3063b6a2d 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -278,14 +278,6 @@ struct omap_dss_writeback_info {
 struct omapdss_dsi_ops {
 	int (*update)(struct omap_dss_device *dssdev);
 	bool (*is_video_mode)(struct omap_dss_device *dssdev);
-
-	/* legacy API used by omapdss panels */
-	int (*set_config)(struct omap_dss_device *dssdev,
-			const struct omap_dss_dsi_config *cfg);
-
-	int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
-	void (*disable_video_output)(struct omap_dss_device *dssdev,
-			int channel);
 };
 
 struct omap_dss_device_ops {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 33/80] drm/omap: drop omapdss-boot-init
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (31 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 32/80] drm/omap: dsi: convert to drm_panel Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 34/80] drm/omap: dsi: implement check timings Tomi Valkeinen
                   ` (47 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

The table of compatible values needed to be prefixed with "omapdss,"
is empty, so all of this code is doing nothing now. Let's drop it.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/Kconfig           |   4 -
 drivers/gpu/drm/omapdrm/dss/Makefile          |   2 -
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   | 228 ------------------
 3 files changed, 234 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c

diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
index fd7dfa28ce97..6ec80771af3d 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -1,7 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
-config OMAP2_DSS_INIT
-	bool
-
 config OMAP_DSS_BASE
 	tristate
 
@@ -9,7 +6,6 @@ menuconfig OMAP2_DSS
 	tristate "OMAP2+ Display Subsystem support"
 	select OMAP_DSS_BASE
 	select VIDEOMODE_HELPERS
-	select OMAP2_DSS_INIT
 	select HDMI
 	help
 	  OMAP2+ Display Subsystem support.
diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile
index f967e6948f2e..811966cd7468 100644
--- a/drivers/gpu/drm/omapdrm/dss/Makefile
+++ b/drivers/gpu/drm/omapdrm/dss/Makefile
@@ -1,6 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
-
 obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o
 omapdss-base-y := base.o display.o output.o
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
deleted file mode 100644
index 18560ca4bbb0..000000000000
--- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
+++ /dev/null
@@ -1,228 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
- * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
- */
-
-/*
- * As omapdss panel drivers are omapdss specific, but we want to define the
- * DT-data in generic manner, we convert the compatible strings of the panel and
- * encoder nodes from "panel-foo" to "omapdss,panel-foo". This way we can have
- * both correct DT data and omapdss specific drivers.
- *
- * When we get generic panel drivers to the kernel, this file will be removed.
- */
-
-#include <linux/kernel.h>
-#include <linux/of.h>
-#include <linux/of_graph.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-
-static struct list_head dss_conv_list __initdata;
-
-static const char prefix[] __initconst = "omapdss,";
-
-struct dss_conv_node {
-	struct list_head list;
-	struct device_node *node;
-	bool root;
-};
-
-static int __init omapdss_count_strings(const struct property *prop)
-{
-	const char *p = prop->value;
-	int l = 0, total = 0;
-	int i;
-
-	for (i = 0; total < prop->length; total += l, p += l, i++)
-		l = strlen(p) + 1;
-
-	return i;
-}
-
-static void __init omapdss_update_prop(struct device_node *node, char *compat,
-	int len)
-{
-	struct property *prop;
-
-	prop = kzalloc(sizeof(*prop), GFP_KERNEL);
-	if (!prop)
-		return;
-
-	prop->name = "compatible";
-	prop->value = compat;
-	prop->length = len;
-
-	of_update_property(node, prop);
-}
-
-static void __init omapdss_prefix_strcpy(char *dst, int dst_len,
-	const char *src, int src_len)
-{
-	size_t total = 0;
-
-	while (total < src_len) {
-		size_t l = strlen(src) + 1;
-
-		strcpy(dst, prefix);
-		dst += strlen(prefix);
-
-		strcpy(dst, src);
-		dst += l;
-
-		src += l;
-		total += l;
-	}
-}
-
-/* prepend compatible property strings with "omapdss," */
-static void __init omapdss_omapify_node(struct device_node *node)
-{
-	struct property *prop;
-	char *new_compat;
-	int num_strs;
-	int new_len;
-
-	prop = of_find_property(node, "compatible", NULL);
-
-	if (!prop || !prop->value)
-		return;
-
-	if (strnlen(prop->value, prop->length) >= prop->length)
-		return;
-
-	/* is it already prefixed? */
-	if (strncmp(prefix, prop->value, strlen(prefix)) == 0)
-		return;
-
-	num_strs = omapdss_count_strings(prop);
-
-	new_len = prop->length + strlen(prefix) * num_strs;
-	new_compat = kmalloc(new_len, GFP_KERNEL);
-
-	omapdss_prefix_strcpy(new_compat, new_len, prop->value, prop->length);
-
-	omapdss_update_prop(node, new_compat, new_len);
-}
-
-static void __init omapdss_add_to_list(struct device_node *node, bool root)
-{
-	struct dss_conv_node *n = kmalloc(sizeof(*n), GFP_KERNEL);
-	if (n) {
-		n->node = node;
-		n->root = root;
-		list_add(&n->list, &dss_conv_list);
-	}
-}
-
-static bool __init omapdss_list_contains(const struct device_node *node)
-{
-	struct dss_conv_node *n;
-
-	list_for_each_entry(n, &dss_conv_list, list) {
-		if (n->node == node)
-			return true;
-	}
-
-	return false;
-}
-
-static void __init omapdss_walk_device(struct device_node *node, bool root)
-{
-	struct device_node *n;
-
-	omapdss_add_to_list(node, root);
-
-	/*
-	 * of_graph_get_remote_port_parent() prints an error if there is no
-	 * port/ports node. To avoid that, check first that there's the node.
-	 */
-	n = of_get_child_by_name(node, "ports");
-	if (!n)
-		n = of_get_child_by_name(node, "port");
-	if (!n)
-		return;
-
-	of_node_put(n);
-
-	n = NULL;
-	while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
-		struct device_node *pn;
-
-		pn = of_graph_get_remote_port_parent(n);
-
-		if (!pn)
-			continue;
-
-		if (!of_device_is_available(pn) || omapdss_list_contains(pn)) {
-			of_node_put(pn);
-			continue;
-		}
-
-		omapdss_walk_device(pn, false);
-	}
-}
-
-static const struct of_device_id omapdss_of_match[] __initconst = {
-	{ .compatible = "ti,omap2-dss", },
-	{ .compatible = "ti,omap3-dss", },
-	{ .compatible = "ti,omap4-dss", },
-	{ .compatible = "ti,omap5-dss", },
-	{ .compatible = "ti,dra7-dss", },
-	{},
-};
-
-static const struct of_device_id omapdss_of_fixups_whitelist[] __initconst = {
-	{},
-};
-
-static void __init omapdss_find_children(struct device_node *np)
-{
-	struct device_node *child;
-
-	for_each_available_child_of_node(np, child) {
-		if (!of_find_property(child, "compatible", NULL))
-			continue;
-
-		omapdss_walk_device(child, true);
-
-		if (of_device_is_compatible(child, "ti,sysc"))
-			omapdss_find_children(child);
-	}
-}
-
-static int __init omapdss_boot_init(void)
-{
-	struct device_node *dss;
-
-	INIT_LIST_HEAD(&dss_conv_list);
-
-	dss = of_find_matching_node(NULL, omapdss_of_match);
-
-	if (dss == NULL || !of_device_is_available(dss))
-		goto put_node;
-
-	omapdss_walk_device(dss, true);
-	omapdss_find_children(dss);
-
-	while (!list_empty(&dss_conv_list)) {
-		struct dss_conv_node *n;
-
-		n = list_first_entry(&dss_conv_list, struct dss_conv_node,
-			list);
-
-		if (of_match_node(omapdss_of_fixups_whitelist, n->node))
-			omapdss_omapify_node(n->node);
-
-		list_del(&n->list);
-		of_node_put(n->node);
-		kfree(n);
-	}
-
-put_node:
-	of_node_put(dss);
-	return 0;
-}
-
-subsys_initcall(omapdss_boot_init);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 34/80] drm/omap: dsi: implement check timings
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (32 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 33/80] drm/omap: drop omapdss-boot-init Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 35/80] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO Tomi Valkeinen
                   ` (46 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Implement check timings, which will check if it's possible to
configure the clocks for the provided mode using the same code
as the set_config() hook.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 70 +++++++++++++++++++------------
 1 file changed, 44 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 93900739237e..549386f3897b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -280,6 +280,11 @@ struct dsi_isr_tables {
 	struct dsi_isr_data isr_table_cio[DSI_MAX_NR_ISRS];
 };
 
+struct dsi_lp_clock_info {
+	unsigned long lp_clk;
+	u16 lp_clk_div;
+};
+
 struct dsi_clk_calc_ctx {
 	struct dsi_data *dsi;
 	struct dss_pll *pll;
@@ -294,16 +299,12 @@ struct dsi_clk_calc_ctx {
 
 	struct dss_pll_clock_info dsi_cinfo;
 	struct dispc_clock_info dispc_cinfo;
+	struct dsi_lp_clock_info lp_cinfo;
 
 	struct videomode vm;
 	struct omap_dss_dsi_videomode_timings dsi_vm;
 };
 
-struct dsi_lp_clock_info {
-	unsigned long lp_clk;
-	u16 lp_clk_div;
-};
-
 struct dsi_module_id_data {
 	u32 address;
 	int id;
@@ -4793,44 +4794,55 @@ static bool dsi_is_video_mode(struct omap_dss_device *dssdev)
 	return dsi->mode == OMAP_DSS_DSI_VIDEO_MODE;
 }
 
-static int dsi_set_config(struct omap_dss_device *dssdev,
-		const struct drm_display_mode *mode)
+static int __dsi_calc_config(struct dsi_data *dsi,
+		const struct drm_display_mode *mode,
+		struct dsi_clk_calc_ctx *ctx)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-	struct dsi_clk_calc_ctx ctx;
-	struct videomode vm;
 	struct omap_dss_dsi_config cfg = dsi->config;
+	struct videomode vm;
 	bool ok;
 	int r;
 
 	drm_display_mode_to_videomode(mode, &vm);
-	cfg.vm = &vm;
-
-	mutex_lock(&dsi->lock);
 
+	cfg.vm = &vm;
 	cfg.mode = dsi->mode;
 	cfg.pixel_format = dsi->pix_fmt;
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
-		ok = dsi_vm_calc(dsi, &cfg, &ctx);
+		ok = dsi_vm_calc(dsi, &cfg, ctx);
 	else
-		ok = dsi_cm_calc(dsi, &cfg, &ctx);
+		ok = dsi_cm_calc(dsi, &cfg, ctx);
 
-	if (!ok) {
-		DSSERR("failed to find suitable DSI clock settings\n");
-		r = -EINVAL;
-		goto err;
-	}
+	if (!ok)
+		return -EINVAL;
+
+	dsi_pll_calc_dsi_fck(dsi, &ctx->dsi_cinfo);
 
-	dsi_pll_calc_dsi_fck(dsi, &ctx.dsi_cinfo);
+	r = dsi_lp_clock_calc(ctx->dsi_cinfo.clkout[HSDIV_DSI],
+		cfg.lp_clk_min, cfg.lp_clk_max, &ctx->lp_cinfo);
+	if (r)
+		return r;
+
+	return 0;
+}
 
-	r = dsi_lp_clock_calc(ctx.dsi_cinfo.clkout[HSDIV_DSI],
-		cfg.lp_clk_min, cfg.lp_clk_max, &dsi->user_lp_cinfo);
+static int dsi_set_config(struct omap_dss_device *dssdev,
+		const struct drm_display_mode *mode)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+	struct dsi_clk_calc_ctx ctx;
+	int r;
+
+	mutex_lock(&dsi->lock);
+
+	r = __dsi_calc_config(dsi, mode, &ctx);
 	if (r) {
-		DSSERR("failed to find suitable DSI LP clock settings\n");
+		DSSERR("failed to find suitable DSI clock settings\n");
 		goto err;
 	}
 
+	dsi->user_lp_cinfo = ctx.lp_cinfo;
 	dsi->user_dsi_cinfo = ctx.dsi_cinfo;
 	dsi->user_dispc_cinfo = ctx.dispc_cinfo;
 
@@ -5007,11 +5019,17 @@ static void dsi_set_timings(struct omap_dss_device *dssdev,
 static int dsi_check_timings(struct omap_dss_device *dssdev,
 			     struct drm_display_mode *mode)
 {
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+	struct dsi_clk_calc_ctx ctx;
+	int r;
+
 	DSSDBG("dsi_check_timings\n");
 
-	/* TODO */
+	mutex_lock(&dsi->lock);
+	r = __dsi_calc_config(dsi, mode, &ctx);
+	mutex_unlock(&dsi->lock);
 
-	return 0;
+	return r;
 }
 
 static int dsi_connect(struct omap_dss_device *src,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 35/80] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (33 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 34/80] drm/omap: dsi: implement check timings Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 36/80] drm/omap: panel-dsi-cm: support unbinding Tomi Valkeinen
                   ` (45 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Use DEVICE_ATTR_RO helper instead of plain DEVICE_ATTR,
which makes the code a bit shorter and easier to read.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 5d6a001f8f71..c50cefab6f3f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -215,7 +215,7 @@ static const struct backlight_ops dsicm_bl_ops = {
 	.update_status  = dsicm_bl_update_status,
 };
 
-static ssize_t dsicm_num_errors_show(struct device *dev,
+static ssize_t num_dsi_errors_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(dev);
@@ -235,7 +235,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
 	return snprintf(buf, PAGE_SIZE, "%d\n", errors);
 }
 
-static ssize_t dsicm_hw_revision_show(struct device *dev,
+static ssize_t hw_revision_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(dev);
@@ -255,8 +255,8 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
 	return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3);
 }
 
-static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL);
-static DEVICE_ATTR(hw_revision, S_IRUGO, dsicm_hw_revision_show, NULL);
+static DEVICE_ATTR_RO(num_dsi_errors);
+static DEVICE_ATTR_RO(hw_revision);
 
 static struct attribute *dsicm_attrs[] = {
 	&dev_attr_num_dsi_errors.attr,
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 36/80] drm/omap: panel-dsi-cm: support unbinding
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (34 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 35/80] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 37/80] drm/omap: panel-dsi-cm: fix remove() Tomi Valkeinen
                   ` (44 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Now, that the driver implements the common DRM panel API
the unbind no longer needs to be suppressed.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index c50cefab6f3f..19d629a976c5 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -598,7 +598,7 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	return r;
 }
 
-static int __exit dsicm_remove(struct mipi_dsi_device *dsi)
+static int dsicm_remove(struct mipi_dsi_device *dsi)
 {
 	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
 
@@ -628,11 +628,10 @@ MODULE_DEVICE_TABLE(of, dsicm_of_match);
 
 static struct mipi_dsi_driver dsicm_driver = {
 	.probe = dsicm_probe,
-	.remove = __exit_p(dsicm_remove),
+	.remove = dsicm_remove,
 	.driver = {
 		.name = "panel-dsi-cm",
 		.of_match_table = dsicm_of_match,
-		.suppress_bind_attrs = true,
 	},
 };
 module_mipi_dsi_driver(dsicm_driver);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 37/80] drm/omap: panel-dsi-cm: fix remove()
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (35 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 36/80] drm/omap: panel-dsi-cm: support unbinding Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 38/80] drm/omap: remove global dss_device variable Tomi Valkeinen
                   ` (43 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Do not try to reset the panel after DSI has been
detached, since the DSI clocks may have been disabled
at this point. The panel will be disabled and unprepared
before being removed and a reset will be done when being
probed again.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 19d629a976c5..35a0c7da1974 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -613,9 +613,6 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
 	if (ddata->extbldev)
 		put_device(&ddata->extbldev->dev);
 
-	/* reset, to be sure that the panel is in a valid state */
-	dsicm_hw_reset(ddata);
-
 	return 0;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 38/80] drm/omap: remove global dss_device variable
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (36 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 37/80] drm/omap: panel-dsi-cm: fix remove() Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 39/80] drm/panel: Move OMAP's DSI command mode panel driver Tomi Valkeinen
                   ` (42 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

We can simply provide the device to the omapdrm driver
via pdata. omapdss_is_initialized() is no longer required
(even before this patch), since omapdrm device is only
registered after the pointer is initialized.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/base.c    | 14 --------------
 drivers/gpu/drm/omapdrm/dss/dss.c     |  9 ++++-----
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  9 +++------
 drivers/gpu/drm/omapdrm/omap_drv.c    |  6 ++----
 4 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index 455b410f7401..8e08c49b4f97 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -16,20 +16,6 @@
 #include "dss.h"
 #include "omapdss.h"
 
-static struct dss_device *dss_device;
-
-struct dss_device *omapdss_get_dss(void)
-{
-	return dss_device;
-}
-EXPORT_SYMBOL(omapdss_get_dss);
-
-void omapdss_set_dss(struct dss_device *dss)
-{
-	dss_device = dss;
-}
-EXPORT_SYMBOL(omapdss_set_dss);
-
 struct dispc_device *dispc_get_dispc(struct dss_device *dss)
 {
 	return dss->dispc;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 6ccbc29c4ce4..6e86f4e67a2c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1305,6 +1305,7 @@ static int dss_bind(struct device *dev)
 {
 	struct dss_device *dss = dev_get_drvdata(dev);
 	struct platform_device *drm_pdev;
+	struct dss_pdata pdata;
 	int r;
 
 	r = component_bind_all(dev, NULL);
@@ -1313,9 +1314,9 @@ static int dss_bind(struct device *dev)
 
 	pm_set_vt_switch(0);
 
-	omapdss_set_dss(dss);
-
-	drm_pdev = platform_device_register_simple("omapdrm", 0, NULL, 0);
+	pdata.dss = dss;
+	drm_pdev = platform_device_register_data(NULL, "omapdrm", 0,
+						 &pdata, sizeof(pdata));
 	if (IS_ERR(drm_pdev)) {
 		component_unbind_all(dev, NULL);
 		return PTR_ERR(drm_pdev);
@@ -1332,8 +1333,6 @@ static void dss_unbind(struct device *dev)
 
 	platform_device_unregister(dss->drm_pdev);
 
-	omapdss_set_dss(NULL);
-
 	component_unbind_all(dev, NULL);
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 3ee3063b6a2d..42d1ec3aaf0c 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -356,12 +356,9 @@ struct omap_dss_device {
 	unsigned int of_port;
 };
 
-struct dss_device *omapdss_get_dss(void);
-void omapdss_set_dss(struct dss_device *dss);
-static inline bool omapdss_is_initialized(void)
-{
-	return !!omapdss_get_dss();
-}
+struct dss_pdata {
+	struct dss_device *dss;
+};
 
 void omapdss_display_init(struct omap_dss_device *dssdev);
 int omapdss_display_get_modes(struct drm_connector *connector,
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 53d5e184ee77..b342f5b6ced0 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -577,6 +577,7 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
 static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 {
 	const struct soc_device_attribute *soc;
+	struct dss_pdata *pdata = dev->platform_data;
 	struct drm_device *ddev;
 	int ret;
 
@@ -591,7 +592,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 	ddev->dev_private = priv;
 
 	priv->dev = dev;
-	priv->dss = omapdss_get_dss();
+	priv->dss = pdata->dss;
 	priv->dispc = dispc_get_dispc(priv->dss);
 	priv->dispc_ops = dispc_get_ops(priv->dss);
 
@@ -686,9 +687,6 @@ static int pdev_probe(struct platform_device *pdev)
 	struct omap_drm_private *priv;
 	int ret;
 
-	if (omapdss_is_initialized() == false)
-		return -EPROBE_DEFER;
-
 	ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 39/80] drm/panel: Move OMAP's DSI command mode panel driver
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (37 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 38/80] drm/omap: remove global dss_device variable Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2021-01-08 21:23   ` Dixit, Ashutosh
  2020-11-24 12:44 ` [PATCH v4 40/80] drm/omap: dsi: Register a drm_bridge Tomi Valkeinen
                   ` (41 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel,
	Tomi Valkeinen, Thierry Reding, Sam Ravnborg

From: Sebastian Reichel <sebastian.reichel@collabora.com>

The panel driver is no longer using any OMAP specific APIs, so
let's move it into the generic panel directory.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/Kconfig                        |  1 -
 drivers/gpu/drm/omapdrm/Makefile                       |  1 -
 drivers/gpu/drm/omapdrm/displays/Kconfig               | 10 ----------
 drivers/gpu/drm/omapdrm/displays/Makefile              |  2 --
 drivers/gpu/drm/panel/Kconfig                          |  9 +++++++++
 drivers/gpu/drm/panel/Makefile                         |  1 +
 .../gpu/drm/{omapdrm/displays => panel}/panel-dsi-cm.c |  0
 7 files changed, 10 insertions(+), 14 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/displays/Kconfig
 delete mode 100644 drivers/gpu/drm/omapdrm/displays/Makefile
 rename drivers/gpu/drm/{omapdrm/displays => panel}/panel-dsi-cm.c (100%)

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index 5417e7a47072..cea3f44ea6d4 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -12,6 +12,5 @@ config DRM_OMAP
 if DRM_OMAP
 
 source "drivers/gpu/drm/omapdrm/dss/Kconfig"
-source "drivers/gpu/drm/omapdrm/displays/Kconfig"
 
 endif
diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index f115253115c5..66a73eae6f7c 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -5,7 +5,6 @@
 #
 
 obj-y += dss/
-obj-y += displays/
 
 omapdrm-y := omap_drv.o \
 	omap_irq.o \
diff --git a/drivers/gpu/drm/omapdrm/displays/Kconfig b/drivers/gpu/drm/omapdrm/displays/Kconfig
deleted file mode 100644
index f2be594c7eff..000000000000
--- a/drivers/gpu/drm/omapdrm/displays/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-menu "OMAPDRM External Display Device Drivers"
-
-config DRM_OMAP_PANEL_DSI_CM
-	tristate "Generic DSI Command Mode Panel"
-	depends on BACKLIGHT_CLASS_DEVICE
-	help
-	  Driver for generic DSI command mode panels.
-
-endmenu
diff --git a/drivers/gpu/drm/omapdrm/displays/Makefile b/drivers/gpu/drm/omapdrm/displays/Makefile
deleted file mode 100644
index 488ddf153613..000000000000
--- a/drivers/gpu/drm/omapdrm/displays/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_DRM_OMAP_PANEL_DSI_CM) += panel-dsi-cm.o
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index b9dbedf8f15e..a71f95afc52e 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -48,6 +48,15 @@ config DRM_PANEL_BOE_TV101WUM_NL6
 	  Say Y here if you want to support for BOE TV101WUM and AUO KD101N80
 	  45NA WUXGA PANEL DSI Video Mode panel
 
+config DRM_PANEL_DSI_CM
+	tristate "Generic DSI command mode panels"
+	depends on OF
+	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  DRM panel driver for DSI command mode panels with support for
+	  embedded and external backlights.
+
 config DRM_PANEL_LVDS
 	tristate "Generic LVDS panel driver"
 	depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 2ba560bca61d..c553e968e9a9 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o
 obj-$(CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596) += panel-asus-z00t-tm5p5-n35596.o
 obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o
 obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o
+obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o
 obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
 obj-$(CONFIG_DRM_PANEL_ELIDA_KD35T133) += panel-elida-kd35t133.o
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
similarity index 100%
rename from drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
rename to drivers/gpu/drm/panel/panel-dsi-cm.c
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 40/80] drm/omap: dsi: Register a drm_bridge
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (38 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 39/80] drm/panel: Move OMAP's DSI command mode panel driver Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:44 ` [PATCH v4 41/80] drm/omap: remove legacy DSS device operations Tomi Valkeinen
                   ` (40 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

In order to integrate with a chain of drm_bridge, the internal DSI
output has to expose its operations through the drm_bridge API.
Register a bridge at initialisation time to do so and remove the
omap_dss_device operations that are now unused.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 134 ++++++++++++++++++++----------
 1 file changed, 89 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 549386f3897b..fcb51aedf847 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -35,6 +35,7 @@
 #include <linux/component.h>
 #include <linux/sys_soc.h>
 
+#include <drm/drm_bridge.h>
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_panel.h>
 #include <video/mipi_display.h>
@@ -438,6 +439,7 @@ struct dsi_data {
 	struct omap_dss_dsi_videomode_timings vm_timings;
 
 	struct omap_dss_device output;
+	struct drm_bridge bridge;
 };
 
 struct dsi_packet_sent_handler_data {
@@ -450,6 +452,9 @@ static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
 #endif
 
+#define drm_bridge_to_dsi(bridge) \
+	container_of(bridge, struct dsi_data, bridge)
+
 static inline struct dsi_data *to_dsi_data(struct omap_dss_device *dssdev)
 {
 	return dev_get_drvdata(dssdev->dev);
@@ -5009,50 +5014,7 @@ static int dsi_get_clocks(struct dsi_data *dsi)
 	return 0;
 }
 
-static void dsi_set_timings(struct omap_dss_device *dssdev,
-			    const struct drm_display_mode *mode)
-{
-	DSSDBG("dsi_set_timings\n");
-	dsi_set_config(dssdev, mode);
-}
-
-static int dsi_check_timings(struct omap_dss_device *dssdev,
-			     struct drm_display_mode *mode)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-	struct dsi_clk_calc_ctx ctx;
-	int r;
-
-	DSSDBG("dsi_check_timings\n");
-
-	mutex_lock(&dsi->lock);
-	r = __dsi_calc_config(dsi, mode, &ctx);
-	mutex_unlock(&dsi->lock);
-
-	return r;
-}
-
-static int dsi_connect(struct omap_dss_device *src,
-		       struct omap_dss_device *dst)
-{
-	return omapdss_device_connect(dst->dss, dst, dst->next);
-}
-
-static void dsi_disconnect(struct omap_dss_device *src,
-			   struct omap_dss_device *dst)
-{
-	omapdss_device_disconnect(dst, dst->next);
-}
-
 static const struct omap_dss_device_ops dsi_ops = {
-	.connect = dsi_connect,
-	.disconnect = dsi_disconnect,
-	.enable = dsi_enable_video_outputs,
-	.disable = dsi_disable_video_outputs,
-
-	.check_timings = dsi_check_timings,
-	.set_timings = dsi_set_timings,
-
 	.dsi = {
 		.update = dsi_update_all,
 		.is_video_mode = dsi_is_video_mode,
@@ -5392,6 +5354,83 @@ static const struct component_ops dsi_component_ops = {
 	.unbind	= dsi_unbind,
 };
 
+/* -----------------------------------------------------------------------------
+ * DRM Bridge Operations
+ */
+
+static int dsi_bridge_attach(struct drm_bridge *bridge,
+			     enum drm_bridge_attach_flags flags)
+{
+	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
+		return -EINVAL;
+
+	return drm_bridge_attach(bridge->encoder, dsi->output.next_bridge,
+				 bridge, flags);
+}
+
+static enum drm_mode_status
+dsi_bridge_mode_valid(struct drm_bridge *bridge,
+		      const struct drm_display_info *info,
+		      const struct drm_display_mode *mode)
+{
+	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+	struct dsi_clk_calc_ctx ctx;
+	int r;
+
+	mutex_lock(&dsi->lock);
+	r = __dsi_calc_config(dsi, mode, &ctx);
+	mutex_unlock(&dsi->lock);
+
+	return r ? MODE_CLOCK_RANGE : MODE_OK;
+}
+
+static void dsi_bridge_mode_set(struct drm_bridge *bridge,
+				const struct drm_display_mode *mode,
+				const struct drm_display_mode *adjusted_mode)
+{
+	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+	dsi_set_config(&dsi->output, adjusted_mode);
+}
+
+static void dsi_bridge_enable(struct drm_bridge *bridge)
+{
+	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+	dsi_enable_video_outputs(&dsi->output);
+}
+
+static void dsi_bridge_disable(struct drm_bridge *bridge)
+{
+	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+
+	dsi_disable_video_outputs(&dsi->output);
+}
+
+static const struct drm_bridge_funcs dsi_bridge_funcs = {
+	.attach = dsi_bridge_attach,
+	.mode_valid = dsi_bridge_mode_valid,
+	.mode_set = dsi_bridge_mode_set,
+	.enable = dsi_bridge_enable,
+	.disable = dsi_bridge_disable,
+};
+
+static void dsi_bridge_init(struct dsi_data *dsi)
+{
+	dsi->bridge.funcs = &dsi_bridge_funcs;
+	dsi->bridge.of_node = dsi->host.dev->of_node;
+	dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;
+
+	drm_bridge_add(&dsi->bridge);
+}
+
+static void dsi_bridge_cleanup(struct dsi_data *dsi)
+{
+	drm_bridge_remove(&dsi->bridge);
+}
+
 /* -----------------------------------------------------------------------------
  * Probe & Remove, Suspend & Resume
  */
@@ -5401,6 +5440,8 @@ static int dsi_init_output(struct dsi_data *dsi)
 	struct omap_dss_device *out = &dsi->output;
 	int r;
 
+	dsi_bridge_init(dsi);
+
 	out->dev = dsi->dev;
 	out->id = dsi->module_id == 0 ?
 			OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
@@ -5415,9 +5456,11 @@ static int dsi_init_output(struct dsi_data *dsi)
 		       | DRM_BUS_FLAG_DE_HIGH
 		       | DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE;
 
-	r = omapdss_device_init_output(out, NULL);
-	if (r < 0)
+	r = omapdss_device_init_output(out, &dsi->bridge);
+	if (r < 0) {
+		dsi_bridge_cleanup(dsi);
 		return r;
+	}
 
 	omapdss_device_register(out);
 
@@ -5430,6 +5473,7 @@ static void dsi_uninit_output(struct dsi_data *dsi)
 
 	omapdss_device_unregister(out);
 	omapdss_device_cleanup_output(out);
+	dsi_bridge_cleanup(dsi);
 }
 
 static int dsi_probe_of(struct dsi_data *dsi)
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 41/80] drm/omap: remove legacy DSS device operations
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (39 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 40/80] drm/omap: dsi: Register a drm_bridge Tomi Valkeinen
@ 2020-11-24 12:44 ` Tomi Valkeinen
  2020-11-24 12:45 ` [PATCH v4 42/80] drm/omap: remove unused omap_connector Tomi Valkeinen
                   ` (39 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:44 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

All DSS devices have been converted to bridge API, so
the device operations are always NULL. This removes
the device ops function pointers and all code using it.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/base.c       | 66 ------------------------
 drivers/gpu/drm/omapdrm/dss/dss.c        |  8 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h    | 34 ------------
 drivers/gpu/drm/omapdrm/omap_connector.c | 29 -----------
 drivers/gpu/drm/omapdrm/omap_encoder.c   | 56 --------------------
 5 files changed, 193 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index 8e08c49b4f97..c2791305c332 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -161,8 +161,6 @@ int omapdss_device_connect(struct dss_device *dss,
 			   struct omap_dss_device *src,
 			   struct omap_dss_device *dst)
 {
-	int ret;
-
 	dev_dbg(&dss->pdev->dev, "connect(%s, %s)\n",
 		src ? dev_name(src->dev) : "NULL",
 		dst ? dev_name(dst->dev) : "NULL");
@@ -181,14 +179,6 @@ int omapdss_device_connect(struct dss_device *dss,
 
 	dst->dss = dss;
 
-	if (dst->ops && dst->ops->connect) {
-		ret = dst->ops->connect(src, dst);
-		if (ret < 0) {
-			dst->dss = NULL;
-			return ret;
-		}
-	}
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(omapdss_device_connect);
@@ -212,66 +202,10 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 		return;
 	}
 
-	WARN_ON(dst->state != OMAP_DSS_DISPLAY_DISABLED);
-
-	if (dst->ops && dst->ops->disconnect)
-		dst->ops->disconnect(src, dst);
 	dst->dss = NULL;
 }
 EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
 
-void omapdss_device_pre_enable(struct omap_dss_device *dssdev)
-{
-	if (!dssdev)
-		return;
-
-	omapdss_device_pre_enable(dssdev->next);
-
-	if (dssdev->ops && dssdev->ops->pre_enable)
-		dssdev->ops->pre_enable(dssdev);
-}
-EXPORT_SYMBOL_GPL(omapdss_device_pre_enable);
-
-void omapdss_device_enable(struct omap_dss_device *dssdev)
-{
-	if (!dssdev)
-		return;
-
-	if (dssdev->ops && dssdev->ops->enable)
-		dssdev->ops->enable(dssdev);
-
-	omapdss_device_enable(dssdev->next);
-
-	dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
-}
-EXPORT_SYMBOL_GPL(omapdss_device_enable);
-
-void omapdss_device_disable(struct omap_dss_device *dssdev)
-{
-	if (!dssdev)
-		return;
-
-	omapdss_device_disable(dssdev->next);
-
-	if (dssdev->ops && dssdev->ops->disable)
-		dssdev->ops->disable(dssdev);
-}
-EXPORT_SYMBOL_GPL(omapdss_device_disable);
-
-void omapdss_device_post_disable(struct omap_dss_device *dssdev)
-{
-	if (!dssdev)
-		return;
-
-	if (dssdev->ops && dssdev->ops->post_disable)
-		dssdev->ops->post_disable(dssdev);
-
-	omapdss_device_post_disable(dssdev->next);
-
-	dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
-}
-EXPORT_SYMBOL_GPL(omapdss_device_post_disable);
-
 /* -----------------------------------------------------------------------------
  * Components Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 6e86f4e67a2c..6a160138bf88 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1565,15 +1565,7 @@ static int dss_remove(struct platform_device *pdev)
 
 static void dss_shutdown(struct platform_device *pdev)
 {
-	struct omap_dss_device *dssdev = NULL;
-
 	DSSDBG("shutdown\n");
-
-	for_each_dss_output(dssdev) {
-		if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE &&
-		    dssdev->ops && dssdev->ops->disable)
-			dssdev->ops->disable(dssdev);
-	}
 }
 
 static int dss_runtime_suspend(struct device *dev)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 42d1ec3aaf0c..5d6edec5a427 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -123,11 +123,6 @@ enum omap_dss_dsi_mode {
 	OMAP_DSS_DSI_VIDEO_MODE,
 };
 
-enum omap_dss_display_state {
-	OMAP_DSS_DISPLAY_DISABLED = 0,
-	OMAP_DSS_DISPLAY_ACTIVE,
-};
-
 enum omap_dss_rotation_type {
 	OMAP_DSS_ROT_NONE	= 0,
 	OMAP_DSS_ROT_TILER	= 1 << 0,
@@ -281,24 +276,6 @@ struct omapdss_dsi_ops {
 };
 
 struct omap_dss_device_ops {
-	int (*connect)(struct omap_dss_device *dssdev,
-			struct omap_dss_device *dst);
-	void (*disconnect)(struct omap_dss_device *dssdev,
-			struct omap_dss_device *dst);
-
-	void (*pre_enable)(struct omap_dss_device *dssdev);
-	void (*enable)(struct omap_dss_device *dssdev);
-	void (*disable)(struct omap_dss_device *dssdev);
-	void (*post_disable)(struct omap_dss_device *dssdev);
-
-	int (*check_timings)(struct omap_dss_device *dssdev,
-			     struct drm_display_mode *mode);
-	void (*set_timings)(struct omap_dss_device *dssdev,
-			    const struct drm_display_mode *mode);
-
-	int (*get_modes)(struct omap_dss_device *dssdev,
-			 struct drm_connector *connector);
-
 	const struct omapdss_dsi_ops dsi;
 };
 
@@ -342,8 +319,6 @@ struct omap_dss_device {
 	unsigned long ops_flags;
 	u32 bus_flags;
 
-	enum omap_dss_display_state state;
-
 	/* OMAP DSS output specific fields */
 
 	/* DISPC channel for this output */
@@ -374,10 +349,6 @@ int omapdss_device_connect(struct dss_device *dss,
 			   struct omap_dss_device *dst);
 void omapdss_device_disconnect(struct omap_dss_device *src,
 			       struct omap_dss_device *dst);
-void omapdss_device_pre_enable(struct omap_dss_device *dssdev);
-void omapdss_device_enable(struct omap_dss_device *dssdev);
-void omapdss_device_disable(struct omap_dss_device *dssdev);
-void omapdss_device_post_disable(struct omap_dss_device *dssdev);
 
 int omap_dss_get_num_overlay_managers(void);
 
@@ -397,11 +368,6 @@ int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
 int omapdss_compat_init(void);
 void omapdss_compat_uninit(void);
 
-static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
-{
-	return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
-}
-
 enum dss_writeback_channel {
 	DSS_WB_LCD1_MGR =	0,
 	DSS_WB_LCD2_MGR =	1,
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c
index de95dc1b861c..c6d9b4268841 100644
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ b/drivers/gpu/drm/omapdrm/omap_connector.c
@@ -43,24 +43,8 @@ static void omap_connector_destroy(struct drm_connector *connector)
 
 static int omap_connector_get_modes(struct drm_connector *connector)
 {
-	struct omap_connector *omap_connector = to_omap_connector(connector);
-	struct omap_dss_device *dssdev = NULL;
-	struct omap_dss_device *d;
-
 	DBG("%s", connector->name);
 
-	/*
-	 * If the display pipeline reports modes (e.g. with a fixed resolution
-	 * panel or an analog TV output), query it.
-	 */
-	for (d = omap_connector->output; d; d = d->next) {
-		if (d->ops_flags & OMAP_DSS_DEVICE_OP_MODES)
-			dssdev = d;
-	}
-
-	if (dssdev)
-		return dssdev->ops->get_modes(dssdev, connector);
-
 	/* We can't retrieve modes. The KMS core will add the default modes. */
 	return 0;
 }
@@ -69,19 +53,6 @@ enum drm_mode_status omap_connector_mode_fixup(struct omap_dss_device *dssdev,
 					const struct drm_display_mode *mode,
 					struct drm_display_mode *adjusted_mode)
 {
-	int ret;
-
-	drm_mode_copy(adjusted_mode, mode);
-
-	for (; dssdev; dssdev = dssdev->next) {
-		if (!dssdev->ops || !dssdev->ops->check_timings)
-			continue;
-
-		ret = dssdev->ops->check_timings(dssdev, adjusted_mode);
-		if (ret)
-			return MODE_BAD;
-	}
-
 	return MODE_OK;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
index 330296ae8344..ef28dfa49ca1 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -115,60 +115,6 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
 
 	/* Set timings for all devices in the display pipeline. */
 	dss_mgr_set_timings(output, &vm);
-
-	for (dssdev = output; dssdev; dssdev = dssdev->next) {
-		if (dssdev->ops && dssdev->ops->set_timings)
-			dssdev->ops->set_timings(dssdev, adjusted_mode);
-	}
-}
-
-static void omap_encoder_disable(struct drm_encoder *encoder)
-{
-	struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
-	struct omap_dss_device *dssdev = omap_encoder->output;
-	struct drm_device *dev = encoder->dev;
-
-	dev_dbg(dev->dev, "disable(%s)\n", dssdev->name);
-
-	/*
-	 * Disable the chain of external devices, starting at the one at the
-	 * internal encoder's output.
-	 */
-	omapdss_device_disable(dssdev->next);
-
-	/* Disable the internal encoder. This will disable the DSS output. */
-	if (dssdev->ops && dssdev->ops->disable)
-		dssdev->ops->disable(dssdev);
-	dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
-
-	/*
-	 * Perform the post-disable operations on the chain of external devices
-	 * to complete the display pipeline disable.
-	 */
-	omapdss_device_post_disable(dssdev->next);
-}
-
-static void omap_encoder_enable(struct drm_encoder *encoder)
-{
-	struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
-	struct omap_dss_device *dssdev = omap_encoder->output;
-	struct drm_device *dev = encoder->dev;
-
-	dev_dbg(dev->dev, "enable(%s)\n", dssdev->name);
-
-	/* Prepare the chain of external devices for pipeline enable. */
-	omapdss_device_pre_enable(dssdev->next);
-
-	/* Enable the internal encoder. This will enable the DSS output. */
-	if (dssdev->ops && dssdev->ops->enable)
-		dssdev->ops->enable(dssdev);
-	dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
-
-	/*
-	 * Enable the chain of external devices, starting at the one at the
-	 * internal encoder's output.
-	 */
-	omapdss_device_enable(dssdev->next);
 }
 
 static int omap_encoder_atomic_check(struct drm_encoder *encoder,
@@ -191,8 +137,6 @@ static int omap_encoder_atomic_check(struct drm_encoder *encoder,
 
 static const struct drm_encoder_helper_funcs omap_encoder_helper_funcs = {
 	.mode_set = omap_encoder_mode_set,
-	.disable = omap_encoder_disable,
-	.enable = omap_encoder_enable,
 	.atomic_check = omap_encoder_atomic_check,
 };
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 42/80] drm/omap: remove unused omap_connector
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (40 preceding siblings ...)
  2020-11-24 12:44 ` [PATCH v4 41/80] drm/omap: remove legacy DSS device operations Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 12:45 ` [PATCH v4 43/80] drm/omap: simplify omap_display_id Tomi Valkeinen
                   ` (38 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Remove unused code. Connectors are now created via drm_bridge_connector_init()
and no longer OMAP specific.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/Makefile         |   1 -
 drivers/gpu/drm/omapdrm/omap_connector.c | 128 -----------------------
 drivers/gpu/drm/omapdrm/omap_connector.h |  28 -----
 drivers/gpu/drm/omapdrm/omap_drv.c       |  19 ++--
 drivers/gpu/drm/omapdrm/omap_drv.h       |   1 -
 drivers/gpu/drm/omapdrm/omap_encoder.c   |  19 ----
 6 files changed, 6 insertions(+), 190 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/omap_connector.c
 delete mode 100644 drivers/gpu/drm/omapdrm/omap_connector.h

diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index 66a73eae6f7c..2a404e045b78 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -12,7 +12,6 @@ omapdrm-y := omap_drv.o \
 	omap_crtc.o \
 	omap_plane.o \
 	omap_encoder.o \
-	omap_connector.o \
 	omap_fb.o \
 	omap_gem.o \
 	omap_gem_dmabuf.o \
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c
deleted file mode 100644
index c6d9b4268841..000000000000
--- a/drivers/gpu/drm/omapdrm/omap_connector.c
+++ /dev/null
@@ -1,128 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- * Author: Rob Clark <rob@ti.com>
- */
-
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_crtc.h>
-#include <drm/drm_probe_helper.h>
-
-#include "omap_drv.h"
-
-/*
- * connector funcs
- */
-
-#define to_omap_connector(x) container_of(x, struct omap_connector, base)
-
-struct omap_connector {
-	struct drm_connector base;
-	struct omap_dss_device *output;
-};
-
-static enum drm_connector_status omap_connector_detect(
-		struct drm_connector *connector, bool force)
-{
-	return connector_status_connected;
-}
-
-static void omap_connector_destroy(struct drm_connector *connector)
-{
-	struct omap_connector *omap_connector = to_omap_connector(connector);
-
-	DBG("%s", connector->name);
-
-	drm_connector_unregister(connector);
-	drm_connector_cleanup(connector);
-
-	omapdss_device_put(omap_connector->output);
-
-	kfree(omap_connector);
-}
-
-static int omap_connector_get_modes(struct drm_connector *connector)
-{
-	DBG("%s", connector->name);
-
-	/* We can't retrieve modes. The KMS core will add the default modes. */
-	return 0;
-}
-
-enum drm_mode_status omap_connector_mode_fixup(struct omap_dss_device *dssdev,
-					const struct drm_display_mode *mode,
-					struct drm_display_mode *adjusted_mode)
-{
-	return MODE_OK;
-}
-
-static enum drm_mode_status omap_connector_mode_valid(struct drm_connector *connector,
-				 struct drm_display_mode *mode)
-{
-	struct omap_connector *omap_connector = to_omap_connector(connector);
-	struct drm_display_mode new_mode = {};
-	enum drm_mode_status status;
-
-	status = omap_connector_mode_fixup(omap_connector->output, mode,
-					   &new_mode);
-	if (status != MODE_OK)
-		goto done;
-
-	/* Check if vrefresh is still valid. */
-	if (drm_mode_vrefresh(mode) != drm_mode_vrefresh(&new_mode))
-		status = MODE_NOCLOCK;
-
-done:
-	DBG("connector: mode %s: " DRM_MODE_FMT,
-			(status == MODE_OK) ? "valid" : "invalid",
-			DRM_MODE_ARG(mode));
-
-	return status;
-}
-
-static const struct drm_connector_funcs omap_connector_funcs = {
-	.reset = drm_atomic_helper_connector_reset,
-	.detect = omap_connector_detect,
-	.fill_modes = drm_helper_probe_single_connector_modes,
-	.destroy = omap_connector_destroy,
-	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
-	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-};
-
-static const struct drm_connector_helper_funcs omap_connector_helper_funcs = {
-	.get_modes = omap_connector_get_modes,
-	.mode_valid = omap_connector_mode_valid,
-};
-
-/* initialize connector */
-struct drm_connector *omap_connector_init(struct drm_device *dev,
-					  struct omap_dss_device *output,
-					  struct drm_encoder *encoder)
-{
-	struct drm_connector *connector = NULL;
-	struct omap_connector *omap_connector;
-
-	DBG("%s", output->name);
-
-	omap_connector = kzalloc(sizeof(*omap_connector), GFP_KERNEL);
-	if (!omap_connector)
-		goto fail;
-
-	omap_connector->output = omapdss_device_get(output);
-
-	connector = &omap_connector->base;
-	connector->interlace_allowed = 1;
-	connector->doublescan_allowed = 0;
-
-	drm_connector_init(dev, connector, &omap_connector_funcs,
-			   DRM_MODE_CONNECTOR_DSI);
-	drm_connector_helper_add(connector, &omap_connector_helper_funcs);
-
-	return connector;
-
-fail:
-	if (connector)
-		omap_connector_destroy(connector);
-
-	return NULL;
-}
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.h b/drivers/gpu/drm/omapdrm/omap_connector.h
deleted file mode 100644
index 0ecd4f1655b7..000000000000
--- a/drivers/gpu/drm/omapdrm/omap_connector.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * omap_connector.h -- OMAP DRM Connector
- *
- * Copyright (C) 2011 Texas Instruments
- * Author: Rob Clark <rob@ti.com>
- */
-
-#ifndef __OMAPDRM_CONNECTOR_H__
-#define __OMAPDRM_CONNECTOR_H__
-
-#include <linux/types.h>
-
-enum drm_mode_status;
-
-struct drm_connector;
-struct drm_device;
-struct drm_encoder;
-struct omap_dss_device;
-
-struct drm_connector *omap_connector_init(struct drm_device *dev,
-					  struct omap_dss_device *output,
-					  struct drm_encoder *encoder);
-enum drm_mode_status omap_connector_mode_fixup(struct omap_dss_device *dssdev,
-					const struct drm_display_mode *mode,
-					struct drm_display_mode *adjusted_mode);
-
-#endif /* __OMAPDRM_CONNECTOR_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index b342f5b6ced0..20b5b4e9071c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -332,19 +332,12 @@ static int omap_modeset_init(struct drm_device *dev)
 		struct drm_encoder *encoder = pipe->encoder;
 		struct drm_crtc *crtc;
 
-		if (pipe->output->next) {
-			pipe->connector = omap_connector_init(dev, pipe->output,
-							      encoder);
-			if (!pipe->connector)
-				return -ENOMEM;
-		} else {
-			pipe->connector = drm_bridge_connector_init(dev, encoder);
-			if (IS_ERR(pipe->connector)) {
-				dev_err(priv->dev,
-					"unable to create bridge connector for %s\n",
-					pipe->output->name);
-				return PTR_ERR(pipe->connector);
-			}
+		pipe->connector = drm_bridge_connector_init(dev, encoder);
+		if (IS_ERR(pipe->connector)) {
+			dev_err(priv->dev,
+				"unable to create bridge connector for %s\n",
+				pipe->output->name);
+			return PTR_ERR(pipe->connector);
 		}
 
 		drm_connector_attach_encoder(pipe->connector, encoder);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 8a1fac680138..93d171ffd26d 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -16,7 +16,6 @@
 #include <drm/drm_gem.h>
 #include <drm/omap_drm.h>
 
-#include "omap_connector.h"
 #include "omap_crtc.h"
 #include "omap_encoder.h"
 #include "omap_fb.h"
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
index ef28dfa49ca1..5da7e028ddf2 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -117,27 +117,8 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
 	dss_mgr_set_timings(output, &vm);
 }
 
-static int omap_encoder_atomic_check(struct drm_encoder *encoder,
-				     struct drm_crtc_state *crtc_state,
-				     struct drm_connector_state *conn_state)
-{
-	struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
-	enum drm_mode_status status;
-
-	status = omap_connector_mode_fixup(omap_encoder->output,
-					   &crtc_state->mode,
-					   &crtc_state->adjusted_mode);
-	if (status != MODE_OK) {
-		dev_err(encoder->dev->dev, "invalid timings: %d\n", status);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
 static const struct drm_encoder_helper_funcs omap_encoder_helper_funcs = {
 	.mode_set = omap_encoder_mode_set,
-	.atomic_check = omap_encoder_atomic_check,
 };
 
 /* initialize encoder */
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 43/80] drm/omap: simplify omap_display_id
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (41 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 42/80] drm/omap: remove unused omap_connector Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 12:45 ` [PATCH v4 44/80] drm/omap: drop unused DSS next pointer Tomi Valkeinen
                   ` (37 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

We no longer need to check for the DSS API, since all encoders,
panels and connectors have been converted to the bridge API.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 20b5b4e9071c..dbb8e95234b3 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -206,14 +206,7 @@ static int omap_display_id(struct omap_dss_device *output)
 {
 	struct device_node *node = NULL;
 
-	if (output->next) {
-		struct omap_dss_device *display = output;
-
-		while (display->next)
-			display = display->next;
-
-		node = display->dev->of_node;
-	} else if (output->bridge) {
+	if (output->bridge) {
 		struct drm_bridge *bridge = output->bridge;
 
 		while (drm_bridge_get_next_bridge(bridge))
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 44/80] drm/omap: drop unused DSS next pointer
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (42 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 43/80] drm/omap: simplify omap_display_id Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 12:45 ` [PATCH v4 45/80] drm/omap: drop DSS ops_flags Tomi Valkeinen
                   ` (36 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Since all encoders and panels are using the bridge API now,
we next pointer is no longer useful and can be dropped.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/base.c     |  2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  1 -
 drivers/gpu/drm/omapdrm/dss/output.c   | 13 +------------
 drivers/gpu/drm/omapdrm/omap_encoder.c |  4 ----
 4 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index c2791305c332..6e948ea9e42b 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -135,7 +135,7 @@ struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from)
 			goto done;
 		}
 
-		if (dssdev->id && (dssdev->next || dssdev->bridge))
+		if (dssdev->id && dssdev->bridge)
 			goto done;
 	}
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 5d6edec5a427..1f02d3e406dc 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -293,7 +293,6 @@ struct omap_dss_device {
 	struct module *owner;
 
 	struct dss_device *dss;
-	struct omap_dss_device *next;
 	struct drm_bridge *bridge;
 	struct drm_bridge *next_bridge;
 	struct drm_panel *panel;
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index ce21c798cca6..40cb353572f6 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -30,7 +30,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 		return 0;
 	}
 
-	out->next = omapdss_find_device_by_node(remote_node);
 	out->bridge = of_drm_find_bridge(remote_node);
 	out->panel = of_drm_find_panel(remote_node);
 	if (IS_ERR(out->panel))
@@ -38,12 +37,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 
 	of_node_put(remote_node);
 
-	if (out->next && out->type != out->next->type) {
-		dev_err(out->dev, "output type and display type don't match\n");
-		ret = -EINVAL;
-		goto error;
-	}
-
 	if (out->panel) {
 		struct drm_bridge *bridge;
 
@@ -69,7 +62,7 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 		out->bridge = local_bridge;
 	}
 
-	if (!out->next && !out->bridge) {
+	if (!out->bridge) {
 		ret = -EPROBE_DEFER;
 		goto error;
 	}
@@ -78,7 +71,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 
 error:
 	omapdss_device_cleanup_output(out);
-	out->next = NULL;
 	return ret;
 }
 EXPORT_SYMBOL(omapdss_device_init_output);
@@ -88,9 +80,6 @@ void omapdss_device_cleanup_output(struct omap_dss_device *out)
 	if (out->bridge && out->panel)
 		drm_panel_bridge_remove(out->next_bridge ?
 					out->next_bridge : out->bridge);
-
-	if (out->next)
-		omapdss_device_put(out->next);
 }
 EXPORT_SYMBOL(omapdss_device_cleanup_output);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
index 5da7e028ddf2..e24411fb9dac 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -75,7 +75,6 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
 {
 	struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
 	struct omap_dss_device *output = omap_encoder->output;
-	struct omap_dss_device *dssdev;
 	struct drm_device *dev = encoder->dev;
 	struct drm_connector *connector;
 	struct drm_bridge *bridge;
@@ -98,9 +97,6 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
 	 *
 	 * A better solution is to use DRM's bus-flags through the whole driver.
 	 */
-	for (dssdev = output; dssdev; dssdev = dssdev->next)
-		omap_encoder_update_videomode_flags(&vm, dssdev->bus_flags);
-
 	for (bridge = output->bridge; bridge;
 	     bridge = drm_bridge_get_next_bridge(bridge)) {
 		if (!bridge->timings)
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 45/80] drm/omap: drop DSS ops_flags
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (43 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 44/80] drm/omap: drop unused DSS next pointer Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 12:45 ` [PATCH v4 46/80] drm/omap: drop dssdev display field Tomi Valkeinen
                   ` (35 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

The omapdss device's ops_flags field is no longer
used and can be dropped.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 9 ---------
 drivers/gpu/drm/omapdrm/dss/venc.c    | 1 -
 2 files changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 1f02d3e406dc..916c55101629 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -279,14 +279,6 @@ struct omap_dss_device_ops {
 	const struct omapdss_dsi_ops dsi;
 };
 
-/**
- * enum omap_dss_device_ops_flag - Indicates which device ops are supported
- * @OMAP_DSS_DEVICE_OP_MODES: The device supports reading modes
- */
-enum omap_dss_device_ops_flag {
-	OMAP_DSS_DEVICE_OP_MODES = BIT(3),
-};
-
 struct omap_dss_device {
 	struct device *dev;
 
@@ -315,7 +307,6 @@ struct omap_dss_device {
 	const char *name;
 
 	const struct omap_dss_device_ops *ops;
-	unsigned long ops_flags;
 	u32 bus_flags;
 
 	/* OMAP DSS output specific fields */
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 5c027c81760f..6e418a0f7572 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -732,7 +732,6 @@ static int venc_init_output(struct venc_device *venc)
 	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
 	out->owner = THIS_MODULE;
 	out->of_port = 0;
-	out->ops_flags = OMAP_DSS_DEVICE_OP_MODES;
 
 	r = omapdss_device_init_output(out, &venc->bridge);
 	if (r < 0) {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 46/80] drm/omap: drop dssdev display field
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (44 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 45/80] drm/omap: drop DSS ops_flags Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 12:45 ` [PATCH v4 47/80] drm/omap: simplify DSI manual update code Tomi Valkeinen
                   ` (34 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

All displays are now using a drm_panel or a drm_bridge that models the
connector instead of dssdev, so this field is always 0 and can be
dropped.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/base.c    | 2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 6 ------
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index 6e948ea9e42b..d0d5d9c8ca76 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -198,7 +198,7 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 	}
 
 	if (!dst->id && !omapdss_device_is_connected(dst)) {
-		WARN_ON(!dst->display);
+		WARN_ON(1);
 		return;
 	}
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 916c55101629..c2199c4946ec 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -298,12 +298,6 @@ struct omap_dss_device {
 	 */
 	enum omap_display_type type;
 
-	/*
-	 * True if the device is a display (panel or connector) at the end of
-	 * the pipeline, false otherwise.
-	 */
-	bool display;
-
 	const char *name;
 
 	const struct omap_dss_device_ops *ops;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 47/80] drm/omap: simplify DSI manual update code
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (45 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 46/80] drm/omap: drop dssdev display field Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 12:45 ` [PATCH v4 48/80] drm/omap: dsi: simplify pin config Tomi Valkeinen
                   ` (33 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Move dsi_ops into the main structure, since all other ops
are gone. Instead of checking the device type we can simply
check if dsi_ops are set.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 10 ++++------
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  6 +-----
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 16 ++++------------
 3 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index fcb51aedf847..71dde45ada10 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5014,11 +5014,9 @@ static int dsi_get_clocks(struct dsi_data *dsi)
 	return 0;
 }
 
-static const struct omap_dss_device_ops dsi_ops = {
-	.dsi = {
-		.update = dsi_update_all,
-		.is_video_mode = dsi_is_video_mode,
-	},
+static const struct omapdss_dsi_ops dsi_ops = {
+	.update = dsi_update_all,
+	.is_video_mode = dsi_is_video_mode,
 };
 
 static irqreturn_t omap_dsi_te_irq_handler(int irq, void *dev_id)
@@ -5449,7 +5447,7 @@ static int dsi_init_output(struct dsi_data *dsi)
 	out->type = OMAP_DISPLAY_TYPE_DSI;
 	out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
 	out->dispc_channel = dsi_get_channel(dsi);
-	out->ops = &dsi_ops;
+	out->dsi_ops = &dsi_ops;
 	out->owner = THIS_MODULE;
 	out->of_port = 0;
 	out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index c2199c4946ec..a1236b8ef7ea 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -275,10 +275,6 @@ struct omapdss_dsi_ops {
 	bool (*is_video_mode)(struct omap_dss_device *dssdev);
 };
 
-struct omap_dss_device_ops {
-	const struct omapdss_dsi_ops dsi;
-};
-
 struct omap_dss_device {
 	struct device *dev;
 
@@ -300,7 +296,7 @@ struct omap_dss_device {
 
 	const char *name;
 
-	const struct omap_dss_device_ops *ops;
+	const struct omapdss_dsi_ops *dsi_ops;
 	u32 bus_flags;
 
 	/* OMAP DSS output specific fields */
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index f6b968060cf0..5ab557c477ef 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -366,17 +366,10 @@ static void omap_crtc_manual_display_update(struct work_struct *data)
 	struct drm_device *dev = omap_crtc->base.dev;
 	int ret;
 
-	if (!dssdev) {
-		dev_err_once(dev->dev, "missing display dssdev!");
+	if (!dssdev || !dssdev->dsi_ops || !dssdev->dsi_ops->update)
 		return;
-	}
-
-	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI || !dssdev->ops->dsi.update) {
-		dev_err_once(dev->dev, "no DSI update callback found!");
-		return;
-	}
 
-	ret = dssdev->ops->dsi.update(dssdev);
+	ret = dssdev->dsi_ops->update(dssdev);
 	if (ret < 0) {
 		spin_lock_irq(&dev->event_lock);
 		omap_crtc->pending = false;
@@ -550,11 +543,10 @@ static bool omap_crtc_is_manually_updated(struct drm_crtc *crtc)
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 	struct omap_dss_device *dssdev = omap_crtc->pipe->output;
 
-	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI ||
-	    !dssdev->ops->dsi.is_video_mode)
+	if (!dssdev || !dssdev->dsi_ops || !dssdev->dsi_ops->is_video_mode)
 		return false;
 
-	if (dssdev->ops->dsi.is_video_mode(dssdev))
+	if (dssdev->dsi_ops->is_video_mode(dssdev))
 		return false;
 
 	DBG("detected manually updated display!");
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 48/80] drm/omap: dsi: simplify pin config
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (46 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 47/80] drm/omap: simplify DSI manual update code Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 12:45 ` [PATCH v4 49/80] ARM: omap2plus_defconfig: Update for moved DSI command mode panel Tomi Valkeinen
                   ` (32 subsequent siblings)
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

Simplify DSI pin config, which always originates from DT
nowadays. With the code being fully contained in the DSI
encoder, we can drop the public structure.

Since the function is no longer exposed, it now directly
takes the private DSI data pointer. This drops a pointless
conversion and means the pins can be configured earlier.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 37 ++++++++++-----------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 15 -----------
 2 files changed, 13 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 71dde45ada10..1ea490e4fc9d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3568,12 +3568,9 @@ static void dsi_proto_timings(struct dsi_data *dsi)
 	}
 }
 
-static int dsi_configure_pins(struct omap_dss_device *dssdev,
-		const struct omap_dsi_pin_config *pin_cfg)
+static int dsi_configure_pins(struct dsi_data *dsi,
+		int num_pins, const u32 *pins)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-	int num_pins;
-	const int *pins;
 	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
 	int num_lanes;
 	int i;
@@ -3586,9 +3583,6 @@ static int dsi_configure_pins(struct omap_dss_device *dssdev,
 		DSI_LANE_DATA4,
 	};
 
-	num_pins = pin_cfg->num_pins;
-	pins = pin_cfg->pins;
-
 	if (num_pins < 4 || num_pins > dsi->num_lanes_supported * 2
 			|| num_pins % 2 != 0)
 		return -EINVAL;
@@ -3600,15 +3594,15 @@ static int dsi_configure_pins(struct omap_dss_device *dssdev,
 
 	for (i = 0; i < num_pins; i += 2) {
 		u8 lane, pol;
-		int dx, dy;
+		u32 dx, dy;
 
 		dx = pins[i];
 		dy = pins[i + 1];
 
-		if (dx < 0 || dx >= dsi->num_lanes_supported * 2)
+		if (dx >= dsi->num_lanes_supported * 2)
 			return -EINVAL;
 
-		if (dy < 0 || dy >= dsi->num_lanes_supported * 2)
+		if (dy >= dsi->num_lanes_supported * 2)
 			return -EINVAL;
 
 		if (dx & 1) {
@@ -5480,9 +5474,8 @@ static int dsi_probe_of(struct dsi_data *dsi)
 	struct property *prop;
 	u32 lane_arr[10];
 	int len, num_pins;
-	int r, i;
+	int r;
 	struct device_node *ep;
-	struct omap_dsi_pin_config pin_cfg;
 
 	ep = of_graph_get_endpoint_by_regs(node, 0, 0);
 	if (!ep)
@@ -5510,11 +5503,7 @@ static int dsi_probe_of(struct dsi_data *dsi)
 		goto err;
 	}
 
-	pin_cfg.num_pins = num_pins;
-	for (i = 0; i < num_pins; ++i)
-		pin_cfg.pins[i] = (int)lane_arr[i];
-
-	r = dsi_configure_pins(&dsi->output, &pin_cfg);
+	r = dsi_configure_pins(dsi, num_pins, lane_arr);
 	if (r) {
 		dev_err(dsi->dev, "failed to configure pins");
 		goto err;
@@ -5727,6 +5716,12 @@ static int dsi_probe(struct platform_device *pdev)
 	dsi->host.ops = &omap_dsi_host_ops;
 	dsi->host.dev = &pdev->dev;
 
+	r = dsi_probe_of(dsi);
+	if (r) {
+		DSSERR("Invalid DSI DT data\n");
+		goto err_pm_disable;
+	}
+
 	r = mipi_dsi_host_register(&dsi->host);
 	if (r < 0) {
 		dev_err(&pdev->dev, "failed to register DSI host: %d\n", r);
@@ -5737,12 +5732,6 @@ static int dsi_probe(struct platform_device *pdev)
 	if (r)
 		goto err_dsi_host_unregister;
 
-	r = dsi_probe_of(dsi);
-	if (r) {
-		DSSERR("Invalid DSI DT data\n");
-		goto err_uninit_output;
-	}
-
 	r = component_add(&pdev->dev, &dsi_component_ops);
 	if (r)
 		goto err_uninit_output;
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index a1236b8ef7ea..4a0826c8fed5 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -243,21 +243,6 @@ struct omap_overlay_manager_info {
 	struct omap_dss_cpr_coefs cpr_coefs;
 };
 
-/* 22 pins means 1 clk lane and 10 data lanes */
-#define OMAP_DSS_MAX_DSI_PINS 22
-
-struct omap_dsi_pin_config {
-	int num_pins;
-	/*
-	 * pin numbers in the following order:
-	 * clk+, clk-
-	 * data1+, data1-
-	 * data2+, data2-
-	 * ...
-	 */
-	int pins[OMAP_DSS_MAX_DSI_PINS];
-};
-
 struct omap_dss_writeback_info {
 	u32 paddr;
 	u32 p_uv_addr;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 49/80] ARM: omap2plus_defconfig: Update for moved DSI command mode panel
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (47 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 48/80] drm/omap: dsi: simplify pin config Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  8:46   ` Tony Lindgren
  2020-11-24 12:45 ` [PATCH v4 50/80] drm/omap: squash omapdrm sub-modules into one Tomi Valkeinen
                   ` (31 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Sebastian Reichel, Tomi Valkeinen

From: Sebastian Reichel <sebastian.reichel@collabora.com>

The DSI command mode panel is no longer specific
to OMAP and thus the config option has been renamed
slightly.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 arch/arm/configs/omap2plus_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 34793aabdb65..1857717a49bf 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -369,8 +369,8 @@ CONFIG_DRM_OMAP=m
 CONFIG_OMAP5_DSS_HDMI=y
 CONFIG_OMAP2_DSS_SDI=y
 CONFIG_OMAP2_DSS_DSI=y
-CONFIG_DRM_OMAP_PANEL_DSI_CM=m
 CONFIG_DRM_TILCDC=m
+CONFIG_DRM_PANEL_DSI_CM=m
 CONFIG_DRM_PANEL_SIMPLE=m
 CONFIG_DRM_PANEL_LG_LB035Q02=m
 CONFIG_DRM_PANEL_NEC_NL8048HL11=m
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 50/80] drm/omap: squash omapdrm sub-modules into one
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (48 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 49/80] ARM: omap2plus_defconfig: Update for moved DSI command mode panel Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-14 12:53   ` Sebastian Reichel
  2020-11-24 12:45 ` [PATCH v4 51/80] drm/omap: remove unused display.c Tomi Valkeinen
                   ` (30 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

At the moment we have three different modules: omapdss-base, omapdss,
omapdrm. This setup is finally obsolete, as the last omapdrm specific
panel has been converted to DRM panel.

We can thus remove omapdss-base and omapdss, and just compile everything
into omapdrm.ko.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/Kconfig       | 119 ++++++++++++++++++++++-
 drivers/gpu/drm/omapdrm/Makefile      |  17 +++-
 drivers/gpu/drm/omapdrm/dss/Kconfig   | 132 --------------------------
 drivers/gpu/drm/omapdrm/dss/Makefile  |  18 ----
 drivers/gpu/drm/omapdrm/dss/base.c    |  24 +----
 drivers/gpu/drm/omapdrm/dss/display.c |   2 -
 drivers/gpu/drm/omapdrm/dss/dss.c     |  11 +--
 drivers/gpu/drm/omapdrm/dss/omapdss.h |   3 +
 drivers/gpu/drm/omapdrm/dss/output.c  |  11 ---
 drivers/gpu/drm/omapdrm/omap_drv.c    |  20 +++-
 10 files changed, 155 insertions(+), 202 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/Kconfig
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/Makefile

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index cea3f44ea6d4..e7281da5bc6a 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -5,12 +5,129 @@ config DRM_OMAP
 	depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
 	select OMAP2_DSS
 	select DRM_KMS_HELPER
+	select VIDEOMODE_HELPERS
+	select HDMI
 	default n
 	help
 	  DRM display driver for OMAP2/3/4 based boards.
 
 if DRM_OMAP
 
-source "drivers/gpu/drm/omapdrm/dss/Kconfig"
+config OMAP2_DSS_DEBUG
+	bool "Debug support"
+	default n
+	help
+	  This enables printing of debug messages. Alternatively, debug messages
+	  can also be enabled by setting CONFIG_DYNAMIC_DEBUG and then setting
+	  appropriate flags in <debugfs>/dynamic_debug/control.
+
+config OMAP2_DSS_DEBUGFS
+	bool "Debugfs filesystem support"
+	depends on DEBUG_FS
+	default n
+	help
+	  This enables debugfs for OMAPDSS at <debugfs>/omapdss. This enables
+	  querying about clock configuration and register configuration of dss,
+	  dispc, dsi, hdmi and rfbi.
+
+config OMAP2_DSS_COLLECT_IRQ_STATS
+	bool "Collect DSS IRQ statistics"
+	depends on OMAP2_DSS_DEBUGFS
+	default n
+	help
+	  Collect DSS IRQ statistics, printable via debugfs.
+
+	  The statistics can be found from
+	  <debugfs>/omapdss/dispc_irq for DISPC interrupts, and
+	  <debugfs>/omapdss/dsi_irq for DSI interrupts.
+
+config OMAP2_DSS_DPI
+	bool "DPI support"
+	default y
+	help
+	  DPI Interface. This is the Parallel Display Interface.
+
+config OMAP2_DSS_VENC
+	bool "VENC support"
+	default y
+	help
+	  OMAP Video Encoder support for S-Video and composite TV-out.
+
+config OMAP2_DSS_HDMI_COMMON
+	bool
+
+config OMAP4_DSS_HDMI
+	bool "HDMI support for OMAP4"
+	default y
+	select OMAP2_DSS_HDMI_COMMON
+	help
+	  HDMI support for OMAP4 based SoCs.
+
+config OMAP4_DSS_HDMI_CEC
+	bool "Enable HDMI CEC support for OMAP4"
+	depends on OMAP4_DSS_HDMI
+	select CEC_CORE
+	default y
+	help
+	  When selected the HDMI transmitter will support the CEC feature.
+
+config OMAP5_DSS_HDMI
+	bool "HDMI support for OMAP5"
+	default n
+	select OMAP2_DSS_HDMI_COMMON
+	help
+	  HDMI Interface for OMAP5 and similar cores. This adds the High
+	  Definition Multimedia Interface. See http://www.hdmi.org/ for HDMI
+	  specification.
+
+config OMAP2_DSS_SDI
+	bool "SDI support"
+	default n
+	help
+	  SDI (Serial Display Interface) support.
+
+	  SDI is a high speed one-way display serial bus between the host
+	  processor and a display.
+
+config OMAP2_DSS_DSI
+	bool "DSI support"
+	default n
+	select DRM_MIPI_DSI
+	help
+	  MIPI DSI (Display Serial Interface) support.
+
+	  DSI is a high speed half-duplex serial interface between the host
+	  processor and a peripheral, such as a display or a framebuffer chip.
+
+	  See http://www.mipi.org/ for DSI specifications.
+
+config OMAP2_DSS_MIN_FCK_PER_PCK
+	int "Minimum FCK/PCK ratio (for scaling)"
+	range 0 32
+	default 0
+	help
+	  This can be used to adjust the minimum FCK/PCK ratio.
+
+	  With this you can make sure that DISPC FCK is at least
+	  n x PCK. Video plane scaling requires higher FCK than
+	  normally.
+
+	  If this is set to 0, there's no extra constraint on the
+	  DISPC FCK. However, the FCK will at minimum be
+	  2xPCK (if active matrix) or 3xPCK (if passive matrix).
+
+	  Max FCK is 173MHz, so this doesn't work if your PCK
+	  is very high.
+
+config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
+	bool "Sleep 20ms after VENC reset"
+	default y
+	help
+	  There is a 20ms sleep after VENC reset which seemed to fix the
+	  reset. The reason for the bug is unclear, and it's also unclear
+	  on what platforms this happens.
+
+	  This option enables the sleep, and is enabled by default. You can
+	  disable the sleep if it doesn't cause problems on your platform.
 
 endif
diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index 2a404e045b78..33fe7e937680 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -4,8 +4,6 @@
 # Direct Rendering Infrastructure (DRI)
 #
 
-obj-y += dss/
-
 omapdrm-y := omap_drv.o \
 	omap_irq.o \
 	omap_debugfs.o \
@@ -20,4 +18,17 @@ omapdrm-y := omap_drv.o \
 
 omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
 
-obj-$(CONFIG_DRM_OMAP)	+= omapdrm.o
+omapdrm-y += dss/base.o dss/display.o dss/output.o dss/dss.o dss/dispc.o \
+		dss/dispc_coefs.o dss/pll.o dss/video-pll.o
+omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
+omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
+omapdrm-$(CONFIG_OMAP2_DSS_SDI) += dss/sdi.o
+omapdrm-$(CONFIG_OMAP2_DSS_DSI) += dss/dsi.o
+omapdrm-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += dss/hdmi_common.o dss/hdmi_wp.o \
+		dss/hdmi_pll.o dss/hdmi_phy.o
+omapdrm-$(CONFIG_OMAP4_DSS_HDMI) += dss/hdmi4.o dss/hdmi4_core.o
+omapdrm-$(CONFIG_OMAP4_DSS_HDMI_CEC) += dss/hdmi4_cec.o
+omapdrm-$(CONFIG_OMAP5_DSS_HDMI) += dss/hdmi5.o dss/hdmi5_core.o
+ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
+
+obj-$(CONFIG_DRM_OMAP) += omapdrm.o
diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
deleted file mode 100644
index 6ec80771af3d..000000000000
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ /dev/null
@@ -1,132 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config OMAP_DSS_BASE
-	tristate
-
-menuconfig OMAP2_DSS
-	tristate "OMAP2+ Display Subsystem support"
-	select OMAP_DSS_BASE
-	select VIDEOMODE_HELPERS
-	select HDMI
-	help
-	  OMAP2+ Display Subsystem support.
-
-if OMAP2_DSS
-
-config OMAP2_DSS_DEBUG
-	bool "Debug support"
-	default n
-	help
-	  This enables printing of debug messages. Alternatively, debug messages
-	  can also be enabled by setting CONFIG_DYNAMIC_DEBUG and then setting
-	  appropriate flags in <debugfs>/dynamic_debug/control.
-
-config OMAP2_DSS_DEBUGFS
-	bool "Debugfs filesystem support"
-	depends on DEBUG_FS
-	default n
-	help
-	  This enables debugfs for OMAPDSS at <debugfs>/omapdss. This enables
-	  querying about clock configuration and register configuration of dss,
-	  dispc, dsi, hdmi and rfbi.
-
-config OMAP2_DSS_COLLECT_IRQ_STATS
-	bool "Collect DSS IRQ statistics"
-	depends on OMAP2_DSS_DEBUGFS
-	default n
-	help
-	  Collect DSS IRQ statistics, printable via debugfs.
-
-	  The statistics can be found from
-	  <debugfs>/omapdss/dispc_irq for DISPC interrupts, and
-	  <debugfs>/omapdss/dsi_irq for DSI interrupts.
-
-config OMAP2_DSS_DPI
-	bool "DPI support"
-	default y
-	help
-	  DPI Interface. This is the Parallel Display Interface.
-
-config OMAP2_DSS_VENC
-	bool "VENC support"
-	default y
-	help
-	  OMAP Video Encoder support for S-Video and composite TV-out.
-
-config OMAP2_DSS_HDMI_COMMON
-	bool
-
-config OMAP4_DSS_HDMI
-	bool "HDMI support for OMAP4"
-	default y
-	select OMAP2_DSS_HDMI_COMMON
-	help
-	  HDMI support for OMAP4 based SoCs.
-
-config OMAP4_DSS_HDMI_CEC
-	bool "Enable HDMI CEC support for OMAP4"
-	depends on OMAP4_DSS_HDMI
-	select CEC_CORE
-	default y
-	help
-	  When selected the HDMI transmitter will support the CEC feature.
-
-config OMAP5_DSS_HDMI
-	bool "HDMI support for OMAP5"
-	default n
-	select OMAP2_DSS_HDMI_COMMON
-	help
-	  HDMI Interface for OMAP5 and similar cores. This adds the High
-	  Definition Multimedia Interface. See http://www.hdmi.org/ for HDMI
-	  specification.
-
-config OMAP2_DSS_SDI
-	bool "SDI support"
-	default n
-	help
-	  SDI (Serial Display Interface) support.
-
-	  SDI is a high speed one-way display serial bus between the host
-	  processor and a display.
-
-config OMAP2_DSS_DSI
-	bool "DSI support"
-	default n
-	select DRM_MIPI_DSI
-	help
-	  MIPI DSI (Display Serial Interface) support.
-
-	  DSI is a high speed half-duplex serial interface between the host
-	  processor and a peripheral, such as a display or a framebuffer chip.
-
-	  See http://www.mipi.org/ for DSI specifications.
-
-config OMAP2_DSS_MIN_FCK_PER_PCK
-	int "Minimum FCK/PCK ratio (for scaling)"
-	range 0 32
-	default 0
-	help
-	  This can be used to adjust the minimum FCK/PCK ratio.
-
-	  With this you can make sure that DISPC FCK is at least
-	  n x PCK. Video plane scaling requires higher FCK than
-	  normally.
-
-	  If this is set to 0, there's no extra constraint on the
-	  DISPC FCK. However, the FCK will at minimum be
-	  2xPCK (if active matrix) or 3xPCK (if passive matrix).
-
-	  Max FCK is 173MHz, so this doesn't work if your PCK
-	  is very high.
-
-config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
-	bool "Sleep 20ms after VENC reset"
-	default y
-	help
-	  There is a 20ms sleep after VENC reset which seemed to fix the
-	  reset. The reason for the bug is unclear, and it's also unclear
-	  on what platforms this happens.
-
-	  This option enables the sleep, and is enabled by default. You can
-	  disable the sleep if it doesn't cause problems on your platform.
-
-endif
diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile
deleted file mode 100644
index 811966cd7468..000000000000
--- a/drivers/gpu/drm/omapdrm/dss/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o
-omapdss-base-y := base.o display.o output.o
-
-obj-$(CONFIG_OMAP2_DSS) += omapdss.o
-# Core DSS files
-omapdss-y := dss.o dispc.o dispc_coefs.o \
-	pll.o video-pll.o
-omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
-omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
-omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
-omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o
-omapdss-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += hdmi_common.o hdmi_wp.o hdmi_pll.o \
-	hdmi_phy.o
-omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi4_core.o
-omapdss-$(CONFIG_OMAP4_DSS_HDMI_CEC) += hdmi4_cec.o
-omapdss-$(CONFIG_OMAP5_DSS_HDMI) += hdmi5.o hdmi5_core.o
-ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index d0d5d9c8ca76..6c57d9292415 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -20,14 +20,11 @@ struct dispc_device *dispc_get_dispc(struct dss_device *dss)
 {
 	return dss->dispc;
 }
-EXPORT_SYMBOL(dispc_get_dispc);
 
 const struct dispc_ops *dispc_get_ops(struct dss_device *dss)
 {
 	return dss->dispc_ops;
 }
-EXPORT_SYMBOL(dispc_get_ops);
-
 
 /* -----------------------------------------------------------------------------
  * OMAP DSS Devices Handling
@@ -42,7 +39,6 @@ void omapdss_device_register(struct omap_dss_device *dssdev)
 	list_add_tail(&dssdev->list, &omapdss_devices_list);
 	mutex_unlock(&omapdss_devices_lock);
 }
-EXPORT_SYMBOL_GPL(omapdss_device_register);
 
 void omapdss_device_unregister(struct omap_dss_device *dssdev)
 {
@@ -50,7 +46,6 @@ void omapdss_device_unregister(struct omap_dss_device *dssdev)
 	list_del(&dssdev->list);
 	mutex_unlock(&omapdss_devices_lock);
 }
-EXPORT_SYMBOL_GPL(omapdss_device_unregister);
 
 static bool omapdss_device_is_registered(struct device_node *node)
 {
@@ -72,24 +67,16 @@ static bool omapdss_device_is_registered(struct device_node *node)
 
 struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev)
 {
-	if (!try_module_get(dssdev->owner))
+	if (get_device(dssdev->dev) == NULL)
 		return NULL;
 
-	if (get_device(dssdev->dev) == NULL) {
-		module_put(dssdev->owner);
-		return NULL;
-	}
-
 	return dssdev;
 }
-EXPORT_SYMBOL(omapdss_device_get);
 
 void omapdss_device_put(struct omap_dss_device *dssdev)
 {
 	put_device(dssdev->dev);
-	module_put(dssdev->owner);
 }
-EXPORT_SYMBOL(omapdss_device_put);
 
 struct omap_dss_device *omapdss_find_device_by_node(struct device_node *node)
 {
@@ -150,7 +137,6 @@ struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from)
 	mutex_unlock(&omapdss_devices_lock);
 	return dssdev;
 }
-EXPORT_SYMBOL(omapdss_device_next_output);
 
 static bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
 {
@@ -181,7 +167,6 @@ int omapdss_device_connect(struct dss_device *dss,
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(omapdss_device_connect);
 
 void omapdss_device_disconnect(struct omap_dss_device *src,
 			       struct omap_dss_device *dst)
@@ -204,7 +189,6 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
 
 	dst->dss = NULL;
 }
-EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
 
 /* -----------------------------------------------------------------------------
  * Components Handling
@@ -290,7 +274,6 @@ void omapdss_gather_components(struct device *dev)
 	for_each_available_child_of_node(dev->of_node, child)
 		omapdss_walk_device(dev, child, true);
 }
-EXPORT_SYMBOL(omapdss_gather_components);
 
 static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
 {
@@ -315,8 +298,3 @@ bool omapdss_stack_is_ready(void)
 
 	return true;
 }
-EXPORT_SYMBOL(omapdss_stack_is_ready);
-
-MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
-MODULE_DESCRIPTION("OMAP Display Subsystem Base");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
index 3b82158b1bfd..7b7ee2019eae 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -38,7 +38,6 @@ void omapdss_display_init(struct omap_dss_device *dssdev)
 		dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
 					      "display%u", id);
 }
-EXPORT_SYMBOL_GPL(omapdss_display_init);
 
 int omapdss_display_get_modes(struct drm_connector *connector,
 			      const struct videomode *vm)
@@ -57,4 +56,3 @@ int omapdss_display_get_modes(struct drm_connector *connector,
 
 	return 1;
 }
-EXPORT_SYMBOL_GPL(omapdss_display_get_modes);
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 6a160138bf88..2d566ff81c55 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1638,21 +1638,14 @@ static struct platform_driver * const omap_dss_drivers[] = {
 #endif
 };
 
-static int __init omap_dss_init(void)
+int __init omap_dss_init(void)
 {
 	return platform_register_drivers(omap_dss_drivers,
 					 ARRAY_SIZE(omap_dss_drivers));
 }
 
-static void __exit omap_dss_exit(void)
+void omap_dss_exit(void)
 {
 	platform_unregister_drivers(omap_dss_drivers,
 				    ARRAY_SIZE(omap_dss_drivers));
 }
-
-module_init(omap_dss_init);
-module_exit(omap_dss_exit);
-
-MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
-MODULE_DESCRIPTION("OMAP2/3/4/5 Display Subsystem");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 4a0826c8fed5..4e7ae164de4f 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -458,4 +458,7 @@ const struct dispc_ops *dispc_get_ops(struct dss_device *dss);
 bool omapdss_stack_is_ready(void);
 void omapdss_gather_components(struct device *dev);
 
+int omap_dss_init(void);
+void omap_dss_exit(void);
+
 #endif /* __OMAP_DRM_DSS_H */
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index 40cb353572f6..7a14d2b5b2f7 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -73,7 +73,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 	omapdss_device_cleanup_output(out);
 	return ret;
 }
-EXPORT_SYMBOL(omapdss_device_init_output);
 
 void omapdss_device_cleanup_output(struct omap_dss_device *out)
 {
@@ -81,7 +80,6 @@ void omapdss_device_cleanup_output(struct omap_dss_device *out)
 		drm_panel_bridge_remove(out->next_bridge ?
 					out->next_bridge : out->bridge);
 }
-EXPORT_SYMBOL(omapdss_device_cleanup_output);
 
 int dss_install_mgr_ops(struct dss_device *dss,
 			const struct dss_mgr_ops *mgr_ops,
@@ -95,14 +93,12 @@ int dss_install_mgr_ops(struct dss_device *dss,
 
 	return 0;
 }
-EXPORT_SYMBOL(dss_install_mgr_ops);
 
 void dss_uninstall_mgr_ops(struct dss_device *dss)
 {
 	dss->mgr_ops = NULL;
 	dss->mgr_ops_priv = NULL;
 }
-EXPORT_SYMBOL(dss_uninstall_mgr_ops);
 
 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
 			 const struct videomode *vm)
@@ -110,7 +106,6 @@ void dss_mgr_set_timings(struct omap_dss_device *dssdev,
 	dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv,
 					  dssdev->dispc_channel, vm);
 }
-EXPORT_SYMBOL(dss_mgr_set_timings);
 
 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
 		const struct dss_lcd_mgr_config *config)
@@ -118,28 +113,24 @@ void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
 	dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv,
 					     dssdev->dispc_channel, config);
 }
-EXPORT_SYMBOL(dss_mgr_set_lcd_config);
 
 int dss_mgr_enable(struct omap_dss_device *dssdev)
 {
 	return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv,
 					    dssdev->dispc_channel);
 }
-EXPORT_SYMBOL(dss_mgr_enable);
 
 void dss_mgr_disable(struct omap_dss_device *dssdev)
 {
 	dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv,
 				      dssdev->dispc_channel);
 }
-EXPORT_SYMBOL(dss_mgr_disable);
 
 void dss_mgr_start_update(struct omap_dss_device *dssdev)
 {
 	dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv,
 					   dssdev->dispc_channel);
 }
-EXPORT_SYMBOL(dss_mgr_start_update);
 
 int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data)
@@ -150,7 +141,6 @@ int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
 							dssdev->dispc_channel,
 							handler, data);
 }
-EXPORT_SYMBOL(dss_mgr_register_framedone_handler);
 
 void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data)
@@ -161,4 +151,3 @@ void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
 						   dssdev->dispc_channel,
 						   handler, data);
 }
-EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index dbb8e95234b3..b6ba4a43f217 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -741,9 +741,21 @@ static struct platform_driver * const drivers[] = {
 
 static int __init omap_drm_init(void)
 {
+	int r;
+
 	DBG("init");
 
-	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
+	r = omap_dss_init();
+	if (r)
+		return r;
+
+	r = platform_register_drivers(drivers, ARRAY_SIZE(drivers));
+	if (r) {
+		omap_dss_exit();
+		return r;
+	}
+
+	return 0;
 }
 
 static void __exit omap_drm_fini(void)
@@ -751,13 +763,15 @@ static void __exit omap_drm_fini(void)
 	DBG("fini");
 
 	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
+
+	omap_dss_exit();
 }
 
-/* need late_initcall() so we load after dss_driver's are loaded */
-late_initcall(omap_drm_init);
+module_init(omap_drm_init);
 module_exit(omap_drm_fini);
 
 MODULE_AUTHOR("Rob Clark <rob@ti.com>");
+MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
 MODULE_DESCRIPTION("OMAP DRM Display Driver");
 MODULE_ALIAS("platform:" DRIVER_NAME);
 MODULE_LICENSE("GPL v2");
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 51/80] drm/omap: remove unused display.c
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (49 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 50/80] drm/omap: squash omapdrm sub-modules into one Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-14 12:53   ` Sebastian Reichel
  2020-11-24 12:45 ` [PATCH v4 52/80] drm/omap: drop unused owner field Tomi Valkeinen
                   ` (29 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

The functions in display.c are not used, so drop the file.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/Makefile      |  2 +-
 drivers/gpu/drm/omapdrm/dss/display.c | 58 ---------------------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 --
 3 files changed, 1 insertion(+), 63 deletions(-)
 delete mode 100644 drivers/gpu/drm/omapdrm/dss/display.c

diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index 33fe7e937680..21e8277ff88f 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -18,7 +18,7 @@ omapdrm-y := omap_drv.o \
 
 omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
 
-omapdrm-y += dss/base.o dss/display.o dss/output.o dss/dss.o dss/dispc.o \
+omapdrm-y += dss/base.o dss/output.o dss/dss.o dss/dispc.o \
 		dss/dispc_coefs.o dss/pll.o dss/video-pll.o
 omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
 omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
deleted file mode 100644
index 7b7ee2019eae..000000000000
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ /dev/null
@@ -1,58 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2009 Nokia Corporation
- * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
- *
- * Some code and ideas taken from drivers/video/omap/ driver
- * by Imre Deak.
- */
-
-#define DSS_SUBSYS_NAME "DISPLAY"
-
-#include <linux/kernel.h>
-#include <linux/of.h>
-
-#include <drm/drm_connector.h>
-#include <drm/drm_modes.h>
-
-#include "omapdss.h"
-
-static int disp_num_counter;
-
-void omapdss_display_init(struct omap_dss_device *dssdev)
-{
-	int id;
-
-	/*
-	 * Note: this presumes that all displays either have an DT alias, or
-	 * none has.
-	 */
-	id = of_alias_get_id(dssdev->dev->of_node, "display");
-	if (id < 0)
-		id = disp_num_counter++;
-
-	/* Use 'label' property for name, if it exists */
-	of_property_read_string(dssdev->dev->of_node, "label", &dssdev->name);
-
-	if (dssdev->name == NULL)
-		dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
-					      "display%u", id);
-}
-
-int omapdss_display_get_modes(struct drm_connector *connector,
-			      const struct videomode *vm)
-{
-	struct drm_display_mode *mode;
-
-	mode = drm_mode_create(connector->dev);
-	if (!mode)
-		return 0;
-
-	drm_display_mode_from_videomode(vm, mode);
-
-	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
-	drm_mode_set_name(mode);
-	drm_mode_probed_add(connector, mode);
-
-	return 1;
-}
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 4e7ae164de4f..90e41c635e45 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -300,10 +300,6 @@ struct dss_pdata {
 	struct dss_device *dss;
 };
 
-void omapdss_display_init(struct omap_dss_device *dssdev);
-int omapdss_display_get_modes(struct drm_connector *connector,
-			      const struct videomode *vm);
-
 void omapdss_device_register(struct omap_dss_device *dssdev);
 void omapdss_device_unregister(struct omap_dss_device *dssdev);
 struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 52/80] drm/omap: drop unused owner field
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (50 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 51/80] drm/omap: remove unused display.c Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-14 12:53   ` Sebastian Reichel
  2020-11-24 12:45 ` [PATCH v4 53/80] drm/omap: remove dispc_ops Tomi Valkeinen
                   ` (28 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

dssdev->owner is set, but never used. We can drop the field.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dpi.c     | 1 -
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 1 -
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 1 -
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 --
 drivers/gpu/drm/omapdrm/dss/sdi.c     | 1 -
 drivers/gpu/drm/omapdrm/dss/venc.c    | 1 -
 7 files changed, 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 1d2992daef40..030f997eccd0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -641,7 +641,6 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
 	out->type = OMAP_DISPLAY_TYPE_DPI;
 	out->dispc_channel = dpi_get_channel(dpi);
 	out->of_port = port_num;
-	out->owner = THIS_MODULE;
 
 	r = omapdss_device_init_output(out, &dpi->bridge);
 	if (r < 0) {
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 1ea490e4fc9d..c3592c6db977 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5442,7 +5442,6 @@ static int dsi_init_output(struct dsi_data *dsi)
 	out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
 	out->dispc_channel = dsi_get_channel(dsi);
 	out->dsi_ops = &dsi_ops;
-	out->owner = THIS_MODULE;
 	out->of_port = 0;
 	out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE
 		       | DRM_BUS_FLAG_DE_HIGH
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index a14fbf06cb30..13701571d59b 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -707,7 +707,6 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
 	out->type = OMAP_DISPLAY_TYPE_HDMI;
 	out->name = "hdmi.0";
 	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-	out->owner = THIS_MODULE;
 	out->of_port = 0;
 
 	r = omapdss_device_init_output(out, &hdmi->bridge);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index b738d9750686..5d627caf90f2 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -681,7 +681,6 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
 	out->type = OMAP_DISPLAY_TYPE_HDMI;
 	out->name = "hdmi.0";
 	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-	out->owner = THIS_MODULE;
 	out->of_port = 0;
 
 	r = omapdss_device_init_output(out, &hdmi->bridge);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 90e41c635e45..4442e49ffc5c 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -263,8 +263,6 @@ struct omapdss_dsi_ops {
 struct omap_dss_device {
 	struct device *dev;
 
-	struct module *owner;
-
 	struct dss_device *dss;
 	struct drm_bridge *bridge;
 	struct drm_bridge *next_bridge;
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index 033fd30074b0..35827b4487bd 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -314,7 +314,6 @@ static int sdi_init_output(struct sdi_device *sdi)
 	out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
 	/* We have SDI only on OMAP3, where it's on port 1 */
 	out->of_port = 1;
-	out->owner = THIS_MODULE;
 	out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE	/* 15.5.9.1.2 */
 		       | DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index 6e418a0f7572..8ecffe5bbd29 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -730,7 +730,6 @@ static int venc_init_output(struct venc_device *venc)
 	out->type = OMAP_DISPLAY_TYPE_VENC;
 	out->name = "venc.0";
 	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
-	out->owner = THIS_MODULE;
 	out->of_port = 0;
 
 	r = omapdss_device_init_output(out, &venc->bridge);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 53/80] drm/omap: remove dispc_ops
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (51 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 52/80] drm/omap: drop unused owner field Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-14 12:54   ` Sebastian Reichel
  2020-11-24 12:45 ` [PATCH v4 54/80] drm/omap: remove dss_mgr_ops Tomi Valkeinen
                   ` (27 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

dispc_ops was created to help with the multi-module architecture and
giving us the possibility of multiple dispc implementations. Neither of
these is valid anymore, and we can remove dispc_ops and use direct
calls to dispc.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/base.c    |   5 --
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 101 +++++++-------------------
 drivers/gpu/drm/omapdrm/dss/dss.h     |  71 +++++++++++++++++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  71 ------------------
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  30 ++++----
 drivers/gpu/drm/omapdrm/omap_drv.c    |  15 ++--
 drivers/gpu/drm/omapdrm/omap_drv.h    |   2 +-
 drivers/gpu/drm/omapdrm/omap_irq.c    |  34 ++++-----
 drivers/gpu/drm/omapdrm/omap_plane.c  |  12 +--
 9 files changed, 143 insertions(+), 198 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
index 6c57d9292415..ee71b05ef567 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -21,11 +21,6 @@ struct dispc_device *dispc_get_dispc(struct dss_device *dss)
 	return dss->dispc;
 }
 
-const struct dispc_ops *dispc_get_ops(struct dss_device *dss)
-{
-	return dss->dispc_ops;
-}
-
 /* -----------------------------------------------------------------------------
  * OMAP DSS Devices Handling
  */
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 48593932bddf..509bac99cb57 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -351,8 +351,6 @@ static unsigned long dispc_plane_pclk_rate(struct dispc_device *dispc,
 static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
 					   enum omap_plane_id plane);
 
-static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
-
 static inline void dispc_write_reg(struct dispc_device *dispc, u16 idx, u32 val)
 {
 	__raw_writel(val, dispc->base + idx);
@@ -379,12 +377,12 @@ static void mgr_fld_write(struct dispc_device *dispc, enum omap_channel channel,
 	REG_FLD_MOD(dispc, rfld->reg, val, rfld->high, rfld->low);
 }
 
-static int dispc_get_num_ovls(struct dispc_device *dispc)
+int dispc_get_num_ovls(struct dispc_device *dispc)
 {
 	return dispc->feat->num_ovls;
 }
 
-static int dispc_get_num_mgrs(struct dispc_device *dispc)
+int dispc_get_num_mgrs(struct dispc_device *dispc)
 {
 	return dispc->feat->num_mgrs;
 }
@@ -667,13 +665,13 @@ void dispc_runtime_put(struct dispc_device *dispc)
 	WARN_ON(r < 0 && r != -ENOSYS);
 }
 
-static u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
+u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
 				   enum omap_channel channel)
 {
 	return mgr_desc[channel].vsync_irq;
 }
 
-static u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
+u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
 				       enum omap_channel channel)
 {
 	if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc->feat->no_framedone_tv)
@@ -682,18 +680,18 @@ static u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
 	return mgr_desc[channel].framedone_irq;
 }
 
-static u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
+u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
 				       enum omap_channel channel)
 {
 	return mgr_desc[channel].sync_lost_irq;
 }
 
-static u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
+u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
 {
 	return DISPC_IRQ_FRAMEDONEWB;
 }
 
-static void dispc_mgr_enable(struct dispc_device *dispc,
+void dispc_mgr_enable(struct dispc_device *dispc,
 			     enum omap_channel channel, bool enable)
 {
 	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_ENABLE, enable);
@@ -707,13 +705,13 @@ static bool dispc_mgr_is_enabled(struct dispc_device *dispc,
 	return !!mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
 }
 
-static bool dispc_mgr_go_busy(struct dispc_device *dispc,
+bool dispc_mgr_go_busy(struct dispc_device *dispc,
 			      enum omap_channel channel)
 {
 	return mgr_fld_read(dispc, channel, DISPC_MGR_FLD_GO) == 1;
 }
 
-static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
+void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
 {
 	WARN_ON(!dispc_mgr_is_enabled(dispc, channel));
 	WARN_ON(dispc_mgr_go_busy(dispc, channel));
@@ -723,12 +721,12 @@ static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
 	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_GO, 1);
 }
 
-static bool dispc_wb_go_busy(struct dispc_device *dispc)
+bool dispc_wb_go_busy(struct dispc_device *dispc)
 {
 	return REG_GET(dispc, DISPC_CONTROL2, 6, 6) == 1;
 }
 
-static void dispc_wb_go(struct dispc_device *dispc)
+void dispc_wb_go(struct dispc_device *dispc)
 {
 	enum omap_plane_id plane = OMAP_DSS_WB;
 	bool enable, go;
@@ -1282,7 +1280,7 @@ static bool dispc_ovl_color_mode_supported(struct dispc_device *dispc,
 	return false;
 }
 
-static const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
+const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
 					    enum omap_plane_id plane)
 {
 	return dispc->feat->supported_color_modes[plane];
@@ -2761,7 +2759,7 @@ static int dispc_ovl_setup_common(struct dispc_device *dispc,
 	return 0;
 }
 
-static int dispc_ovl_setup(struct dispc_device *dispc,
+int dispc_ovl_setup(struct dispc_device *dispc,
 			   enum omap_plane_id plane,
 			   const struct omap_overlay_info *oi,
 			   const struct videomode *vm, bool mem_to_mem,
@@ -2788,7 +2786,7 @@ static int dispc_ovl_setup(struct dispc_device *dispc,
 	return r;
 }
 
-static int dispc_wb_setup(struct dispc_device *dispc,
+int dispc_wb_setup(struct dispc_device *dispc,
 		   const struct omap_dss_writeback_info *wi,
 		   bool mem_to_mem, const struct videomode *vm,
 		   enum dss_writeback_channel channel_in)
@@ -2871,12 +2869,12 @@ static int dispc_wb_setup(struct dispc_device *dispc,
 	return 0;
 }
 
-static bool dispc_has_writeback(struct dispc_device *dispc)
+bool dispc_has_writeback(struct dispc_device *dispc)
 {
 	return dispc->feat->has_writeback;
 }
 
-static int dispc_ovl_enable(struct dispc_device *dispc,
+int dispc_ovl_enable(struct dispc_device *dispc,
 			    enum omap_plane_id plane, bool enable)
 {
 	DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
@@ -2967,7 +2965,7 @@ static void dispc_mgr_enable_alpha_fixed_zorder(struct dispc_device *dispc,
 		REG_FLD_MOD(dispc, DISPC_CONFIG, enable, 19, 19);
 }
 
-static void dispc_mgr_setup(struct dispc_device *dispc,
+void dispc_mgr_setup(struct dispc_device *dispc,
 			    enum omap_channel channel,
 			    const struct omap_overlay_manager_info *info)
 {
@@ -3046,7 +3044,7 @@ static void dispc_mgr_enable_stallmode(struct dispc_device *dispc,
 	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_STALLMODE, enable);
 }
 
-static void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
+void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
 				     enum omap_channel channel,
 				     const struct dss_lcd_mgr_config *config)
 {
@@ -3095,7 +3093,7 @@ static bool _dispc_mgr_pclk_ok(struct dispc_device *dispc,
 		return pclk <= dispc->feat->max_tv_pclk;
 }
 
-static int dispc_mgr_check_timings(struct dispc_device *dispc,
+int dispc_mgr_check_timings(struct dispc_device *dispc,
 				   enum omap_channel channel,
 				   const struct videomode *vm)
 {
@@ -3188,7 +3186,7 @@ static int vm_flag_to_int(enum display_flags flags, enum display_flags high,
 }
 
 /* change name to mode? */
-static void dispc_mgr_set_timings(struct dispc_device *dispc,
+void dispc_mgr_set_timings(struct dispc_device *dispc,
 				  enum omap_channel channel,
 				  const struct videomode *vm)
 {
@@ -3732,17 +3730,17 @@ int dispc_mgr_get_clock_div(struct dispc_device *dispc,
 	return 0;
 }
 
-static u32 dispc_read_irqstatus(struct dispc_device *dispc)
+u32 dispc_read_irqstatus(struct dispc_device *dispc)
 {
 	return dispc_read_reg(dispc, DISPC_IRQSTATUS);
 }
 
-static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
+void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
 {
 	dispc_write_reg(dispc, DISPC_IRQSTATUS, mask);
 }
 
-static void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
+void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
 {
 	u32 old_mask = dispc_read_reg(dispc, DISPC_IRQENABLE);
 
@@ -3766,7 +3764,7 @@ void dispc_disable_sidle(struct dispc_device *dispc)
 	REG_FLD_MOD(dispc, DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
 }
 
-static u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
+u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
 				enum omap_channel channel)
 {
 	const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
@@ -3821,7 +3819,7 @@ static const struct drm_color_lut dispc_mgr_gamma_default_lut[] = {
 	{ .red = U16_MAX, .green = U16_MAX, .blue = U16_MAX, },
 };
 
-static void dispc_mgr_set_gamma(struct dispc_device *dispc,
+void dispc_mgr_set_gamma(struct dispc_device *dispc,
 				enum omap_channel channel,
 				const struct drm_color_lut *lut,
 				unsigned int length)
@@ -4479,7 +4477,7 @@ static irqreturn_t dispc_irq_handler(int irq, void *arg)
 	return dispc->user_handler(irq, dispc->user_data);
 }
 
-static int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
+int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
 			     void *dev_id)
 {
 	int r;
@@ -4503,7 +4501,7 @@ static int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
 	return r;
 }
 
-static void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
+void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
 {
 	devm_free_irq(&dispc->pdev->dev, dispc->irq, dispc);
 
@@ -4511,7 +4509,7 @@ static void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
 	dispc->user_data = NULL;
 }
 
-static u32 dispc_get_memory_bandwidth_limit(struct dispc_device *dispc)
+u32 dispc_get_memory_bandwidth_limit(struct dispc_device *dispc)
 {
 	u32 limit = 0;
 
@@ -4681,47 +4679,6 @@ static void dispc_errata_i734_wa(struct dispc_device *dispc)
 	REG_FLD_MOD(dispc, DISPC_CONFIG, gatestate, 8, 4);
 }
 
-static const struct dispc_ops dispc_ops = {
-	.read_irqstatus = dispc_read_irqstatus,
-	.clear_irqstatus = dispc_clear_irqstatus,
-	.write_irqenable = dispc_write_irqenable,
-
-	.request_irq = dispc_request_irq,
-	.free_irq = dispc_free_irq,
-
-	.runtime_get = dispc_runtime_get,
-	.runtime_put = dispc_runtime_put,
-
-	.get_num_ovls = dispc_get_num_ovls,
-	.get_num_mgrs = dispc_get_num_mgrs,
-
-	.get_memory_bandwidth_limit = dispc_get_memory_bandwidth_limit,
-
-	.mgr_enable = dispc_mgr_enable,
-	.mgr_is_enabled = dispc_mgr_is_enabled,
-	.mgr_get_vsync_irq = dispc_mgr_get_vsync_irq,
-	.mgr_get_framedone_irq = dispc_mgr_get_framedone_irq,
-	.mgr_get_sync_lost_irq = dispc_mgr_get_sync_lost_irq,
-	.mgr_go_busy = dispc_mgr_go_busy,
-	.mgr_go = dispc_mgr_go,
-	.mgr_set_lcd_config = dispc_mgr_set_lcd_config,
-	.mgr_check_timings = dispc_mgr_check_timings,
-	.mgr_set_timings = dispc_mgr_set_timings,
-	.mgr_setup = dispc_mgr_setup,
-	.mgr_gamma_size = dispc_mgr_gamma_size,
-	.mgr_set_gamma = dispc_mgr_set_gamma,
-
-	.ovl_enable = dispc_ovl_enable,
-	.ovl_setup = dispc_ovl_setup,
-	.ovl_get_color_modes = dispc_ovl_get_color_modes,
-
-	.wb_get_framedone_irq = dispc_wb_get_framedone_irq,
-	.wb_setup = dispc_wb_setup,
-	.has_writeback = dispc_has_writeback,
-	.wb_go_busy = dispc_wb_go_busy,
-	.wb_go = dispc_wb_go,
-};
-
 /* DISPC HW IP initialisation */
 static const struct of_device_id dispc_of_match[] = {
 	{ .compatible = "ti,omap2-dispc", .data = &omap24xx_dispc_feats },
@@ -4823,7 +4780,6 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 	dispc_runtime_put(dispc);
 
 	dss->dispc = dispc;
-	dss->dispc_ops = &dispc_ops;
 
 	dispc->debugfs = dss_debugfs_create_file(dss, "dispc", dispc_dump_regs,
 						 dispc);
@@ -4845,7 +4801,6 @@ static void dispc_unbind(struct device *dev, struct device *master, void *data)
 	dss_debugfs_remove_file(dispc->debugfs);
 
 	dss->dispc = NULL;
-	dss->dispc_ops = NULL;
 
 	pm_runtime_disable(dev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 2b404bcb41dd..96f702314c8c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -257,7 +257,6 @@ struct dss_device {
 	struct dss_pll	*video2_pll;
 
 	struct dispc_device *dispc;
-	const struct dispc_ops *dispc_ops;
 	const struct dss_mgr_ops *mgr_ops;
 	struct omap_drm_private *mgr_ops_priv;
 };
@@ -393,6 +392,76 @@ void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s);
 int dispc_runtime_get(struct dispc_device *dispc);
 void dispc_runtime_put(struct dispc_device *dispc);
 
+int dispc_get_num_ovls(struct dispc_device *dispc);
+int dispc_get_num_mgrs(struct dispc_device *dispc);
+
+const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
+					    enum omap_plane_id plane);
+
+u32 dispc_read_irqstatus(struct dispc_device *dispc);
+void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
+void dispc_write_irqenable(struct dispc_device *dispc, u32 mask);
+
+int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
+			     void *dev_id);
+void dispc_free_irq(struct dispc_device *dispc, void *dev_id);
+
+u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
+				   enum omap_channel channel);
+u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
+				       enum omap_channel channel);
+u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
+				       enum omap_channel channel);
+u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc);
+
+u32 dispc_get_memory_bandwidth_limit(struct dispc_device *dispc);
+
+void dispc_mgr_enable(struct dispc_device *dispc,
+			     enum omap_channel channel, bool enable);
+
+bool dispc_mgr_go_busy(struct dispc_device *dispc,
+			      enum omap_channel channel);
+
+void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel);
+
+void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
+				     enum omap_channel channel,
+				     const struct dss_lcd_mgr_config *config);
+void dispc_mgr_set_timings(struct dispc_device *dispc,
+				  enum omap_channel channel,
+				  const struct videomode *vm);
+void dispc_mgr_setup(struct dispc_device *dispc,
+			    enum omap_channel channel,
+			    const struct omap_overlay_manager_info *info);
+
+int dispc_mgr_check_timings(struct dispc_device *dispc,
+				   enum omap_channel channel,
+				   const struct videomode *vm);
+
+u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
+				enum omap_channel channel);
+void dispc_mgr_set_gamma(struct dispc_device *dispc,
+				enum omap_channel channel,
+				const struct drm_color_lut *lut,
+				unsigned int length);
+
+int dispc_ovl_setup(struct dispc_device *dispc,
+			   enum omap_plane_id plane,
+			   const struct omap_overlay_info *oi,
+			   const struct videomode *vm, bool mem_to_mem,
+			   enum omap_channel channel);
+
+int dispc_ovl_enable(struct dispc_device *dispc,
+			    enum omap_plane_id plane, bool enable);
+
+bool dispc_has_writeback(struct dispc_device *dispc);
+int dispc_wb_setup(struct dispc_device *dispc,
+		   const struct omap_dss_writeback_info *wi,
+		   bool mem_to_mem, const struct videomode *vm,
+		   enum dss_writeback_channel channel_in);
+bool dispc_wb_go_busy(struct dispc_device *dispc);
+void dispc_wb_go(struct dispc_device *dispc);
+
 void dispc_enable_sidle(struct dispc_device *dispc);
 void dispc_disable_sidle(struct dispc_device *dispc);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 4442e49ffc5c..fba5f05e5e48 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -376,78 +376,7 @@ int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
 void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
 		void (*handler)(void *), void *data);
 
-/* dispc ops */
-
-struct dispc_ops {
-	u32 (*read_irqstatus)(struct dispc_device *dispc);
-	void (*clear_irqstatus)(struct dispc_device *dispc, u32 mask);
-	void (*write_irqenable)(struct dispc_device *dispc, u32 mask);
-
-	int (*request_irq)(struct dispc_device *dispc, irq_handler_t handler,
-			   void *dev_id);
-	void (*free_irq)(struct dispc_device *dispc, void *dev_id);
-
-	int (*runtime_get)(struct dispc_device *dispc);
-	void (*runtime_put)(struct dispc_device *dispc);
-
-	int (*get_num_ovls)(struct dispc_device *dispc);
-	int (*get_num_mgrs)(struct dispc_device *dispc);
-
-	u32 (*get_memory_bandwidth_limit)(struct dispc_device *dispc);
-
-	void (*mgr_enable)(struct dispc_device *dispc,
-			   enum omap_channel channel, bool enable);
-	bool (*mgr_is_enabled)(struct dispc_device *dispc,
-			       enum omap_channel channel);
-	u32 (*mgr_get_vsync_irq)(struct dispc_device *dispc,
-				 enum omap_channel channel);
-	u32 (*mgr_get_framedone_irq)(struct dispc_device *dispc,
-				     enum omap_channel channel);
-	u32 (*mgr_get_sync_lost_irq)(struct dispc_device *dispc,
-				     enum omap_channel channel);
-	bool (*mgr_go_busy)(struct dispc_device *dispc,
-			    enum omap_channel channel);
-	void (*mgr_go)(struct dispc_device *dispc, enum omap_channel channel);
-	void (*mgr_set_lcd_config)(struct dispc_device *dispc,
-				   enum omap_channel channel,
-				   const struct dss_lcd_mgr_config *config);
-	int (*mgr_check_timings)(struct dispc_device *dispc,
-				 enum omap_channel channel,
-				 const struct videomode *vm);
-	void (*mgr_set_timings)(struct dispc_device *dispc,
-				enum omap_channel channel,
-				const struct videomode *vm);
-	void (*mgr_setup)(struct dispc_device *dispc, enum omap_channel channel,
-			  const struct omap_overlay_manager_info *info);
-	u32 (*mgr_gamma_size)(struct dispc_device *dispc,
-			      enum omap_channel channel);
-	void (*mgr_set_gamma)(struct dispc_device *dispc,
-			      enum omap_channel channel,
-			      const struct drm_color_lut *lut,
-			      unsigned int length);
-
-	int (*ovl_enable)(struct dispc_device *dispc, enum omap_plane_id plane,
-			  bool enable);
-	int (*ovl_setup)(struct dispc_device *dispc, enum omap_plane_id plane,
-			 const struct omap_overlay_info *oi,
-			 const struct videomode *vm, bool mem_to_mem,
-			 enum omap_channel channel);
-
-	const u32 *(*ovl_get_color_modes)(struct dispc_device *dispc,
-					  enum omap_plane_id plane);
-
-	u32 (*wb_get_framedone_irq)(struct dispc_device *dispc);
-	int (*wb_setup)(struct dispc_device *dispc,
-		const struct omap_dss_writeback_info *wi,
-		bool mem_to_mem, const struct videomode *vm,
-		enum dss_writeback_channel channel_in);
-	bool (*has_writeback)(struct dispc_device *dispc);
-	bool (*wb_go_busy)(struct dispc_device *dispc);
-	void (*wb_go)(struct dispc_device *dispc);
-};
-
 struct dispc_device *dispc_get_dispc(struct dss_device *dss);
-const struct dispc_ops *dispc_get_ops(struct dss_device *dss);
 
 bool omapdss_stack_is_ready(void);
 void omapdss_gather_components(struct device *dev);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 5ab557c477ef..0bf5cef579b5 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -103,7 +103,7 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
 static void omap_crtc_dss_start_update(struct omap_drm_private *priv,
 				       enum omap_channel channel)
 {
-	priv->dispc_ops->mgr_enable(priv->dispc, channel, true);
+	dispc_mgr_enable(priv->dispc, channel, true);
 }
 
 /* Called only from the encoder enable/disable and suspend/resume handlers. */
@@ -128,7 +128,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 	}
 
 	if (omap_crtc->pipe->output->type == OMAP_DISPLAY_TYPE_HDMI) {
-		priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
+		dispc_mgr_enable(priv->dispc, channel, enable);
 		omap_crtc->enabled = enable;
 		return;
 	}
@@ -141,9 +141,9 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 		omap_crtc->ignore_digit_sync_lost = true;
 	}
 
-	framedone_irq = priv->dispc_ops->mgr_get_framedone_irq(priv->dispc,
+	framedone_irq = dispc_mgr_get_framedone_irq(priv->dispc,
 							       channel);
-	vsync_irq = priv->dispc_ops->mgr_get_vsync_irq(priv->dispc, channel);
+	vsync_irq = dispc_mgr_get_vsync_irq(priv->dispc, channel);
 
 	if (enable) {
 		wait = omap_irq_wait_init(dev, vsync_irq, 1);
@@ -163,7 +163,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 			wait = omap_irq_wait_init(dev, vsync_irq, 2);
 	}
 
-	priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
+	dispc_mgr_enable(priv->dispc, channel, enable);
 	omap_crtc->enabled = enable;
 
 	ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100));
@@ -186,7 +186,7 @@ static int omap_crtc_dss_enable(struct omap_drm_private *priv,
 	struct drm_crtc *crtc = priv->channels[channel]->crtc;
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
-	priv->dispc_ops->mgr_set_timings(priv->dispc, omap_crtc->channel,
+	dispc_mgr_set_timings(priv->dispc, omap_crtc->channel,
 					 &omap_crtc->vm);
 	omap_crtc_set_enabled(&omap_crtc->base, true);
 
@@ -221,7 +221,7 @@ static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
 	DBG("%s", omap_crtc->name);
-	priv->dispc_ops->mgr_set_lcd_config(priv->dispc, omap_crtc->channel,
+	dispc_mgr_set_lcd_config(priv->dispc, omap_crtc->channel,
 					    config);
 }
 
@@ -300,7 +300,7 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
 	 * If the dispc is busy we're racing the flush operation. Try again on
 	 * the next vblank interrupt.
 	 */
-	if (priv->dispc_ops->mgr_go_busy(priv->dispc, omap_crtc->channel)) {
+	if (dispc_mgr_go_busy(priv->dispc, omap_crtc->channel)) {
 		spin_unlock(&crtc->dev->event_lock);
 		return;
 	}
@@ -391,7 +391,7 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
 	info.partial_alpha_enabled = false;
 	info.cpr_enable = false;
 
-	priv->dispc_ops->mgr_setup(priv->dispc, omap_crtc->channel, &info);
+	dispc_mgr_setup(priv->dispc, omap_crtc->channel, &info);
 }
 
 /* -----------------------------------------------------------------------------
@@ -432,7 +432,7 @@ static void omap_crtc_atomic_enable(struct drm_crtc *crtc,
 
 	DBG("%s", omap_crtc->name);
 
-	priv->dispc_ops->runtime_get(priv->dispc);
+	dispc_runtime_get(priv->dispc);
 
 	/* manual updated display will not trigger vsync irq */
 	if (omap_state->manually_updated)
@@ -471,7 +471,7 @@ static void omap_crtc_atomic_disable(struct drm_crtc *crtc,
 
 	drm_crtc_vblank_off(crtc);
 
-	priv->dispc_ops->runtime_put(priv->dispc);
+	dispc_runtime_put(priv->dispc);
 }
 
 static enum drm_mode_status omap_crtc_mode_valid(struct drm_crtc *crtc,
@@ -490,7 +490,7 @@ static enum drm_mode_status omap_crtc_mode_valid(struct drm_crtc *crtc,
 	 * proper DISPC mode later.
 	 */
 	if (omap_crtc->pipe->output->type != OMAP_DISPLAY_TYPE_DSI) {
-		r = priv->dispc_ops->mgr_check_timings(priv->dispc,
+		r = dispc_mgr_check_timings(priv->dispc,
 						       omap_crtc->channel,
 						       &vm);
 		if (r)
@@ -605,7 +605,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 			length = crtc->state->gamma_lut->length /
 				sizeof(*lut);
 		}
-		priv->dispc_ops->mgr_set_gamma(priv->dispc, omap_crtc->channel,
+		dispc_mgr_set_gamma(priv->dispc, omap_crtc->channel,
 					       lut, length);
 	}
 
@@ -630,7 +630,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 	WARN_ON(ret != 0);
 
 	spin_lock_irq(&crtc->dev->event_lock);
-	priv->dispc_ops->mgr_go(priv->dispc, omap_crtc->channel);
+	dispc_mgr_go(priv->dispc, omap_crtc->channel);
 	omap_crtc_arm_event(crtc);
 	spin_unlock_irq(&crtc->dev->event_lock);
 }
@@ -821,7 +821,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 	 * extracted with dispc_mgr_gamma_size(). If it returns 0
 	 * gamma table is not supported.
 	 */
-	if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
+	if (dispc_mgr_gamma_size(priv->dispc, channel)) {
 		unsigned int gamma_lut_size = 256;
 
 		drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index b6ba4a43f217..46cb088c2977 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -69,7 +69,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
 	struct drm_device *dev = old_state->dev;
 	struct omap_drm_private *priv = dev->dev_private;
 
-	priv->dispc_ops->runtime_get(priv->dispc);
+	dispc_runtime_get(priv->dispc);
 
 	/* Apply the atomic update. */
 	drm_atomic_helper_commit_modeset_disables(dev, old_state);
@@ -113,7 +113,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
 
 	drm_atomic_helper_cleanup_planes(dev, old_state);
 
-	priv->dispc_ops->runtime_put(priv->dispc);
+	dispc_runtime_put(priv->dispc);
 }
 
 static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs = {
@@ -192,7 +192,7 @@ static int omap_compare_pipelines(const void *a, const void *b)
 static int omap_modeset_init_properties(struct drm_device *dev)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
+	unsigned int num_planes = dispc_get_num_ovls(priv->dispc);
 
 	priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0,
 						      num_planes - 1);
@@ -221,8 +221,8 @@ static int omap_display_id(struct omap_dss_device *output)
 static int omap_modeset_init(struct drm_device *dev)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
-	int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
+	int num_ovls = dispc_get_num_ovls(priv->dispc);
+	int num_mgrs = dispc_get_num_mgrs(priv->dispc);
 	unsigned int i;
 	int ret;
 	u32 plane_crtc_mask;
@@ -580,7 +580,6 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 	priv->dev = dev;
 	priv->dss = pdata->dss;
 	priv->dispc = dispc_get_dispc(priv->dss);
-	priv->dispc_ops = dispc_get_ops(priv->dss);
 
 	omap_crtc_pre_init(priv);
 
@@ -592,9 +591,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 	INIT_LIST_HEAD(&priv->obj_list);
 
 	/* Get memory bandwidth limits */
-	if (priv->dispc_ops->get_memory_bandwidth_limit)
-		priv->max_bandwidth =
-			priv->dispc_ops->get_memory_bandwidth_limit(priv->dispc);
+	priv->max_bandwidth = dispc_get_memory_bandwidth_limit(priv->dispc);
 
 	omap_gem_init(ddev);
 
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 93d171ffd26d..6e69358f624c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -12,6 +12,7 @@
 #include <linux/workqueue.h>
 
 #include "dss/omapdss.h"
+#include "dss/dss.h"
 
 #include <drm/drm_gem.h>
 #include <drm/omap_drm.h>
@@ -46,7 +47,6 @@ struct omap_drm_private {
 
 	struct dss_device *dss;
 	struct dispc_device *dispc;
-	const struct dispc_ops *dispc_ops;
 
 	unsigned int num_pipes;
 	struct omap_drm_pipeline pipes[8];
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
index 382bcdc72ac0..981387220765 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.c
+++ b/drivers/gpu/drm/omapdrm/omap_irq.c
@@ -29,7 +29,7 @@ static void omap_irq_update(struct drm_device *dev)
 
 	DBG("irqmask=%08x", irqmask);
 
-	priv->dispc_ops->write_irqenable(priv->dispc, irqmask);
+	dispc_write_irqenable(priv->dispc, irqmask);
 }
 
 static void omap_irq_wait_handler(struct omap_irq_wait *wait)
@@ -83,7 +83,7 @@ int omap_irq_enable_framedone(struct drm_crtc *crtc, bool enable)
 	unsigned long flags;
 	enum omap_channel channel = omap_crtc_channel(crtc);
 	int framedone_irq =
-		priv->dispc_ops->mgr_get_framedone_irq(priv->dispc, channel);
+		dispc_mgr_get_framedone_irq(priv->dispc, channel);
 
 	DBG("dev=%p, crtc=%u, enable=%d", dev, channel, enable);
 
@@ -121,7 +121,7 @@ int omap_irq_enable_vblank(struct drm_crtc *crtc)
 	DBG("dev=%p, crtc=%u", dev, channel);
 
 	spin_lock_irqsave(&priv->wait_lock, flags);
-	priv->irq_mask |= priv->dispc_ops->mgr_get_vsync_irq(priv->dispc,
+	priv->irq_mask |= dispc_mgr_get_vsync_irq(priv->dispc,
 							     channel);
 	omap_irq_update(dev);
 	spin_unlock_irqrestore(&priv->wait_lock, flags);
@@ -148,7 +148,7 @@ void omap_irq_disable_vblank(struct drm_crtc *crtc)
 	DBG("dev=%p, crtc=%u", dev, channel);
 
 	spin_lock_irqsave(&priv->wait_lock, flags);
-	priv->irq_mask &= ~priv->dispc_ops->mgr_get_vsync_irq(priv->dispc,
+	priv->irq_mask &= ~dispc_mgr_get_vsync_irq(priv->dispc,
 							      channel);
 	omap_irq_update(dev);
 	spin_unlock_irqrestore(&priv->wait_lock, flags);
@@ -213,9 +213,9 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
 	unsigned int id;
 	u32 irqstatus;
 
-	irqstatus = priv->dispc_ops->read_irqstatus(priv->dispc);
-	priv->dispc_ops->clear_irqstatus(priv->dispc, irqstatus);
-	priv->dispc_ops->read_irqstatus(priv->dispc);	/* flush posted write */
+	irqstatus = dispc_read_irqstatus(priv->dispc);
+	dispc_clear_irqstatus(priv->dispc, irqstatus);
+	dispc_read_irqstatus(priv->dispc);	/* flush posted write */
 
 	VERB("irqs: %08x", irqstatus);
 
@@ -223,15 +223,15 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
 		struct drm_crtc *crtc = priv->pipes[id].crtc;
 		enum omap_channel channel = omap_crtc_channel(crtc);
 
-		if (irqstatus & priv->dispc_ops->mgr_get_vsync_irq(priv->dispc, channel)) {
+		if (irqstatus & dispc_mgr_get_vsync_irq(priv->dispc, channel)) {
 			drm_handle_vblank(dev, id);
 			omap_crtc_vblank_irq(crtc);
 		}
 
-		if (irqstatus & priv->dispc_ops->mgr_get_sync_lost_irq(priv->dispc, channel))
+		if (irqstatus & dispc_mgr_get_sync_lost_irq(priv->dispc, channel))
 			omap_crtc_error_irq(crtc, irqstatus);
 
-		if (irqstatus & priv->dispc_ops->mgr_get_framedone_irq(priv->dispc, channel))
+		if (irqstatus & dispc_mgr_get_framedone_irq(priv->dispc, channel))
 			omap_crtc_framedone_irq(crtc, irqstatus);
 	}
 
@@ -265,7 +265,7 @@ static const u32 omap_underflow_irqs[] = {
 int omap_drm_irq_install(struct drm_device *dev)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	unsigned int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
+	unsigned int num_mgrs = dispc_get_num_mgrs(priv->dispc);
 	unsigned int max_planes;
 	unsigned int i;
 	int ret;
@@ -283,13 +283,13 @@ int omap_drm_irq_install(struct drm_device *dev)
 	}
 
 	for (i = 0; i < num_mgrs; ++i)
-		priv->irq_mask |= priv->dispc_ops->mgr_get_sync_lost_irq(priv->dispc, i);
+		priv->irq_mask |= dispc_mgr_get_sync_lost_irq(priv->dispc, i);
 
-	priv->dispc_ops->runtime_get(priv->dispc);
-	priv->dispc_ops->clear_irqstatus(priv->dispc, 0xffffffff);
-	priv->dispc_ops->runtime_put(priv->dispc);
+	dispc_runtime_get(priv->dispc);
+	dispc_clear_irqstatus(priv->dispc, 0xffffffff);
+	dispc_runtime_put(priv->dispc);
 
-	ret = priv->dispc_ops->request_irq(priv->dispc, omap_irq_handler, dev);
+	ret = dispc_request_irq(priv->dispc, omap_irq_handler, dev);
 	if (ret < 0)
 		return ret;
 
@@ -307,5 +307,5 @@ void omap_drm_irq_uninstall(struct drm_device *dev)
 
 	dev->irq_enabled = false;
 
-	priv->dispc_ops->free_irq(priv->dispc, dev);
+	dispc_free_irq(priv->dispc, dev);
 }
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
index 73ec99819a3d..88d2a986d880 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -70,17 +70,17 @@ static void omap_plane_atomic_update(struct drm_plane *plane,
 			&info.paddr, &info.p_uv_addr);
 
 	/* and finally, update omapdss: */
-	ret = priv->dispc_ops->ovl_setup(priv->dispc, omap_plane->id, &info,
+	ret = dispc_ovl_setup(priv->dispc, omap_plane->id, &info,
 			      omap_crtc_timings(state->crtc), false,
 			      omap_crtc_channel(state->crtc));
 	if (ret) {
 		dev_err(plane->dev->dev, "Failed to setup plane %s\n",
 			omap_plane->name);
-		priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, false);
+		dispc_ovl_enable(priv->dispc, omap_plane->id, false);
 		return;
 	}
 
-	priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, true);
+	dispc_ovl_enable(priv->dispc, omap_plane->id, true);
 }
 
 static void omap_plane_atomic_disable(struct drm_plane *plane,
@@ -93,7 +93,7 @@ static void omap_plane_atomic_disable(struct drm_plane *plane,
 	plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY
 			   ? 0 : omap_plane->id;
 
-	priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, false);
+	dispc_ovl_enable(priv->dispc, omap_plane->id, false);
 }
 
 static int omap_plane_atomic_check(struct drm_plane *plane,
@@ -252,7 +252,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 		u32 possible_crtcs)
 {
 	struct omap_drm_private *priv = dev->dev_private;
-	unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
+	unsigned int num_planes = dispc_get_num_ovls(priv->dispc);
 	struct drm_plane *plane;
 	struct omap_plane *omap_plane;
 	enum omap_plane_id id;
@@ -271,7 +271,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 	if (!omap_plane)
 		return ERR_PTR(-ENOMEM);
 
-	formats = priv->dispc_ops->ovl_get_color_modes(priv->dispc, id);
+	formats = dispc_ovl_get_color_modes(priv->dispc, id);
 	for (nformats = 0; formats[nformats]; ++nformats)
 		;
 	omap_plane->id = id;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 54/80] drm/omap: remove dss_mgr_ops
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (52 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 53/80] drm/omap: remove dispc_ops Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-14 12:54   ` Sebastian Reichel
  2020-11-24 12:45 ` [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI Tomi Valkeinen
                   ` (26 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

dss_mgr_ops was needed with the multi-module architecture, but is no
longer needed. We can thus remove it and use direct calls.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.h     |  1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 42 +++++++++++----------------
 drivers/gpu/drm/omapdrm/dss/output.c  | 33 +++++----------------
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 38 +++++-------------------
 drivers/gpu/drm/omapdrm/omap_crtc.h   |  2 --
 drivers/gpu/drm/omapdrm/omap_drv.c    |  4 +--
 6 files changed, 33 insertions(+), 87 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
index 96f702314c8c..a547527bb2f3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -257,7 +257,6 @@ struct dss_device {
 	struct dss_pll	*video2_pll;
 
 	struct dispc_device *dispc;
-	const struct dss_mgr_ops *mgr_ops;
 	struct omap_drm_private *mgr_ops_priv;
 };
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index fba5f05e5e48..9df322ca467d 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -338,31 +338,23 @@ enum dss_writeback_channel {
 	DSS_WB_LCD3_MGR =	7,
 };
 
-struct dss_mgr_ops {
-	void (*start_update)(struct omap_drm_private *priv,
-			     enum omap_channel channel);
-	int (*enable)(struct omap_drm_private *priv,
-		      enum omap_channel channel);
-	void (*disable)(struct omap_drm_private *priv,
-			enum omap_channel channel);
-	void (*set_timings)(struct omap_drm_private *priv,
-			    enum omap_channel channel,
-			    const struct videomode *vm);
-	void (*set_lcd_config)(struct omap_drm_private *priv,
-			       enum omap_channel channel,
-			       const struct dss_lcd_mgr_config *config);
-	int (*register_framedone_handler)(struct omap_drm_private *priv,
-			enum omap_channel channel,
-			void (*handler)(void *), void *data);
-	void (*unregister_framedone_handler)(struct omap_drm_private *priv,
-			enum omap_channel channel,
-			void (*handler)(void *), void *data);
-};
-
-int dss_install_mgr_ops(struct dss_device *dss,
-			const struct dss_mgr_ops *mgr_ops,
-			struct omap_drm_private *priv);
-void dss_uninstall_mgr_ops(struct dss_device *dss);
+void omap_crtc_dss_start_update(struct omap_drm_private *priv,
+				       enum omap_channel channel);
+void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable);
+int omap_crtc_dss_enable(struct omap_drm_private *priv, enum omap_channel channel);
+void omap_crtc_dss_disable(struct omap_drm_private *priv, enum omap_channel channel);
+void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
+		enum omap_channel channel,
+		const struct videomode *vm);
+void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
+		enum omap_channel channel,
+		const struct dss_lcd_mgr_config *config);
+int omap_crtc_dss_register_framedone(
+		struct omap_drm_private *priv, enum omap_channel channel,
+		void (*handler)(void *), void *data);
+void omap_crtc_dss_unregister_framedone(
+		struct omap_drm_private *priv, enum omap_channel channel,
+		void (*handler)(void *), void *data);
 
 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
 		const struct videomode *vm);
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index 7a14d2b5b2f7..2121c947947b 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -81,54 +81,35 @@ void omapdss_device_cleanup_output(struct omap_dss_device *out)
 					out->next_bridge : out->bridge);
 }
 
-int dss_install_mgr_ops(struct dss_device *dss,
-			const struct dss_mgr_ops *mgr_ops,
-			struct omap_drm_private *priv)
-{
-	if (dss->mgr_ops)
-		return -EBUSY;
-
-	dss->mgr_ops = mgr_ops;
-	dss->mgr_ops_priv = priv;
-
-	return 0;
-}
-
-void dss_uninstall_mgr_ops(struct dss_device *dss)
-{
-	dss->mgr_ops = NULL;
-	dss->mgr_ops_priv = NULL;
-}
-
 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
 			 const struct videomode *vm)
 {
-	dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv,
+	omap_crtc_dss_set_timings(dssdev->dss->mgr_ops_priv,
 					  dssdev->dispc_channel, vm);
 }
 
 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
 		const struct dss_lcd_mgr_config *config)
 {
-	dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv,
+	omap_crtc_dss_set_lcd_config(dssdev->dss->mgr_ops_priv,
 					     dssdev->dispc_channel, config);
 }
 
 int dss_mgr_enable(struct omap_dss_device *dssdev)
 {
-	return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv,
+	return omap_crtc_dss_enable(dssdev->dss->mgr_ops_priv,
 					    dssdev->dispc_channel);
 }
 
 void dss_mgr_disable(struct omap_dss_device *dssdev)
 {
-	dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv,
+	omap_crtc_dss_disable(dssdev->dss->mgr_ops_priv,
 				      dssdev->dispc_channel);
 }
 
 void dss_mgr_start_update(struct omap_dss_device *dssdev)
 {
-	dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv,
+	omap_crtc_dss_start_update(dssdev->dss->mgr_ops_priv,
 					   dssdev->dispc_channel);
 }
 
@@ -137,7 +118,7 @@ int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
 {
 	struct dss_device *dss = dssdev->dss;
 
-	return dss->mgr_ops->register_framedone_handler(dss->mgr_ops_priv,
+	return omap_crtc_dss_register_framedone(dss->mgr_ops_priv,
 							dssdev->dispc_channel,
 							handler, data);
 }
@@ -147,7 +128,7 @@ void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
 {
 	struct dss_device *dss = dssdev->dss;
 
-	dss->mgr_ops->unregister_framedone_handler(dss->mgr_ops_priv,
+	omap_crtc_dss_unregister_framedone(dss->mgr_ops_priv,
 						   dssdev->dispc_channel,
 						   handler, data);
 }
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 0bf5cef579b5..e3259338afb9 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -100,14 +100,14 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
  * the upstream part of the video pipe.
  */
 
-static void omap_crtc_dss_start_update(struct omap_drm_private *priv,
+void omap_crtc_dss_start_update(struct omap_drm_private *priv,
 				       enum omap_channel channel)
 {
 	dispc_mgr_enable(priv->dispc, channel, true);
 }
 
 /* Called only from the encoder enable/disable and suspend/resume handlers. */
-static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
+void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 {
 	struct omap_crtc_state *omap_state = to_omap_crtc_state(crtc->state);
 	struct drm_device *dev = crtc->dev;
@@ -180,8 +180,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 }
 
 
-static int omap_crtc_dss_enable(struct omap_drm_private *priv,
-				enum omap_channel channel)
+int omap_crtc_dss_enable(struct omap_drm_private *priv, enum omap_channel channel)
 {
 	struct drm_crtc *crtc = priv->channels[channel]->crtc;
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
@@ -193,8 +192,7 @@ static int omap_crtc_dss_enable(struct omap_drm_private *priv,
 	return 0;
 }
 
-static void omap_crtc_dss_disable(struct omap_drm_private *priv,
-				  enum omap_channel channel)
+void omap_crtc_dss_disable(struct omap_drm_private *priv, enum omap_channel channel)
 {
 	struct drm_crtc *crtc = priv->channels[channel]->crtc;
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
@@ -202,7 +200,7 @@ static void omap_crtc_dss_disable(struct omap_drm_private *priv,
 	omap_crtc_set_enabled(&omap_crtc->base, false);
 }
 
-static void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
+void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
 		enum omap_channel channel,
 		const struct videomode *vm)
 {
@@ -213,7 +211,7 @@ static void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
 	omap_crtc->vm = *vm;
 }
 
-static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
+void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
 		enum omap_channel channel,
 		const struct dss_lcd_mgr_config *config)
 {
@@ -225,7 +223,7 @@ static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
 					    config);
 }
 
-static int omap_crtc_dss_register_framedone(
+int omap_crtc_dss_register_framedone(
 		struct omap_drm_private *priv, enum omap_channel channel,
 		void (*handler)(void *), void *data)
 {
@@ -244,7 +242,7 @@ static int omap_crtc_dss_register_framedone(
 	return 0;
 }
 
-static void omap_crtc_dss_unregister_framedone(
+void omap_crtc_dss_unregister_framedone(
 		struct omap_drm_private *priv, enum omap_channel channel,
 		void (*handler)(void *), void *data)
 {
@@ -261,16 +259,6 @@ static void omap_crtc_dss_unregister_framedone(
 	omap_crtc->framedone_handler_data = NULL;
 }
 
-static const struct dss_mgr_ops mgr_ops = {
-	.start_update = omap_crtc_dss_start_update,
-	.enable = omap_crtc_dss_enable,
-	.disable = omap_crtc_dss_disable,
-	.set_timings = omap_crtc_dss_set_timings,
-	.set_lcd_config = omap_crtc_dss_set_lcd_config,
-	.register_framedone_handler = omap_crtc_dss_register_framedone,
-	.unregister_framedone_handler = omap_crtc_dss_unregister_framedone,
-};
-
 /* -----------------------------------------------------------------------------
  * Setup, Flush and Page Flip
  */
@@ -753,16 +741,6 @@ static const char *channel_names[] = {
 	[OMAP_DSS_CHANNEL_LCD3] = "lcd3",
 };
 
-void omap_crtc_pre_init(struct omap_drm_private *priv)
-{
-	dss_install_mgr_ops(priv->dss, &mgr_ops, priv);
-}
-
-void omap_crtc_pre_uninit(struct omap_drm_private *priv)
-{
-	dss_uninstall_mgr_ops(priv->dss);
-}
-
 /* initialize crtc */
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 				struct omap_drm_pipeline *pipe,
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h b/drivers/gpu/drm/omapdrm/omap_crtc.h
index 2fd57751ae2b..a8b9cbee86e0 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.h
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
@@ -22,8 +22,6 @@ struct videomode;
 
 struct videomode *omap_crtc_timings(struct drm_crtc *crtc);
 enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
-void omap_crtc_pre_init(struct omap_drm_private *priv);
-void omap_crtc_pre_uninit(struct omap_drm_private *priv);
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 				struct omap_drm_pipeline *pipe,
 				struct drm_plane *plane);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 46cb088c2977..da7183e98e3f 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -581,7 +581,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 	priv->dss = pdata->dss;
 	priv->dispc = dispc_get_dispc(priv->dss);
 
-	omap_crtc_pre_init(priv);
+	priv->dss->mgr_ops_priv = priv;
 
 	soc = soc_device_match(omapdrm_soc_devices);
 	priv->omaprev = soc ? (unsigned int)soc->data : 0;
@@ -634,7 +634,6 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 	omap_gem_deinit(ddev);
 	destroy_workqueue(priv->wq);
 	omap_disconnect_pipelines(ddev);
-	omap_crtc_pre_uninit(priv);
 	drm_dev_put(ddev);
 	return ret;
 }
@@ -660,7 +659,6 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
 	destroy_workqueue(priv->wq);
 
 	omap_disconnect_pipelines(ddev);
-	omap_crtc_pre_uninit(priv);
 
 	drm_dev_put(ddev);
 }
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (53 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 54/80] drm/omap: remove dss_mgr_ops Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 16:18   ` Sam Ravnborg
                     ` (2 more replies)
  2020-11-24 12:45 ` [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
                   ` (25 subsequent siblings)
  80 siblings, 3 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Use the common MIPI_DCS_GET_ERROR_COUNT_ON_DSI define instead of
driver's own.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index 35a0c7da1974..cb0d27a38555 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -27,7 +27,6 @@
 #include <video/of_display_timing.h>
 #include <video/videomode.h>
 
-#define DCS_READ_NUM_ERRORS	0x05
 #define DCS_GET_ID1		0xda
 #define DCS_GET_ID2		0xdb
 #define DCS_GET_ID3		0xdc
@@ -225,7 +224,7 @@ static ssize_t num_dsi_errors_show(struct device *dev,
 	mutex_lock(&ddata->lock);
 
 	if (ddata->enabled)
-		r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, &errors);
+		r = dsicm_dcs_read_1(ddata, MIPI_DCS_GET_ERROR_COUNT_ON_DSI, &errors);
 
 	mutex_unlock(&ddata->lock);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (54 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 17:25   ` Sam Ravnborg
                     ` (2 more replies)
  2020-11-24 12:45 ` [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi Tomi Valkeinen
                   ` (24 subsequent siblings)
  80 siblings, 3 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Simplify the code by moving code from _dsicm_enable_te() into
dsicm_power_on().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index cb0d27a38555..59e8e6b18e97 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -69,8 +69,6 @@ static inline struct panel_drv_data *panel_to_ddata(struct drm_panel *panel)
 	return container_of(panel, struct panel_drv_data, panel);
 }
 
-static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
-
 static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable)
 {
 	struct backlight_device *backlight;
@@ -314,10 +312,13 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
-	r = _dsicm_enable_te(ddata, true);
+	r = mipi_dsi_dcs_set_tear_on(ddata->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
 	if (r)
 		goto err;
 
+	/* possible panel bug */
+	msleep(100);
+
 	ddata->enabled = true;
 
 	if (!ddata->intro_printed) {
@@ -418,22 +419,6 @@ static int dsicm_disable(struct drm_panel *panel)
 	return r;
 }
 
-static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
-{
-	struct mipi_dsi_device *dsi = ddata->dsi;
-	int r;
-
-	if (enable)
-		r = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
-	else
-		r = mipi_dsi_dcs_set_tear_off(dsi);
-
-	/* possible panel bug */
-	msleep(100);
-
-	return r;
-}
-
 static int dsicm_get_modes(struct drm_panel *panel,
 			   struct drm_connector *connector)
 {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (55 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-30  9:53   ` Laurent Pinchart
  2020-12-14 12:55   ` Sebastian Reichel
  2020-11-24 12:45 ` [PATCH v4 58/80] drm/omap: pll: fix iteration loop check Tomi Valkeinen
                   ` (23 subsequent siblings)
  80 siblings, 2 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Add address-cells & size-cells to DSI nodes so that board files do not
need to define them.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
---
 arch/arm/boot/dts/omap5.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 2bf2e5839a7f..e6f6947965ef 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -517,6 +517,9 @@ dsi1: encoder@0 {
 						clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>,
 							 <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>;
 						clock-names = "fck", "sys_clk";
+
+						#address-cells = <1>;
+						#size-cells = <0>;
 					};
 				};
 
@@ -549,6 +552,9 @@ dsi2: encoder@0 {
 						clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>,
 							 <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>;
 						clock-names = "fck", "sys_clk";
+
+						#address-cells = <1>;
+						#size-cells = <0>;
 					};
 				};
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 58/80] drm/omap: pll: fix iteration loop check
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (56 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-30  9:54   ` Laurent Pinchart
  2020-12-14 12:55   ` Sebastian Reichel
  2020-11-24 12:45 ` [PATCH v4 59/80] drm/omap: dsi: set trans_mode according to client mode_flags Tomi Valkeinen
                   ` (22 subsequent siblings)
  80 siblings, 2 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

If the PLL calc function is given bad parameters, n_start/m_start may be
higher than n_stop/m_stop, which leads to the loops iterating through
the whole u32 number space.

Fix this by failing early on such cases.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/pll.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c
index 1212f3cc52d1..12926218c436 100644
--- a/drivers/gpu/drm/omapdrm/dss/pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/pll.c
@@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
 	n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max);
 	n_inc = 1;
 
+	if (n_start > n_stop)
+		return false;
+
 	if (hw->errata_i886) {
 		swap(n_start, n_stop);
 		n_inc = -1;
@@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
 				hw->m_max);
 		m_inc = 1;
 
+		if (m_start > m_stop)
+			continue;
+
 		if (hw->errata_i886) {
 			swap(m_start, m_stop);
 			m_inc = -1;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 59/80] drm/omap: dsi: set trans_mode according to client mode_flags
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (57 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 58/80] drm/omap: pll: fix iteration loop check Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-30  9:55   ` Laurent Pinchart
  2020-12-14 12:56   ` Sebastian Reichel
  2020-11-24 12:45 ` [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
                   ` (21 subsequent siblings)
  80 siblings, 2 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

The DSI host driver currently ignores the video mode flags in
client->mode_flags. Add the code to take the transfer mode from client's
mode_flags.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c3592c6db977..7fee9cf8782d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5140,6 +5140,13 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	dsi->config.lp_clk_min = 7000000; // TODO: get from client?
 	dsi->config.lp_clk_max = client->lp_rate;
 
+	if (client->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
+		dsi->config.trans_mode = OMAP_DSS_DSI_BURST_MODE;
+	else if (client->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)
+		dsi->config.trans_mode = OMAP_DSS_DSI_PULSE_MODE;
+	else
+		dsi->config.trans_mode = OMAP_DSS_DSI_EVENT_MODE;
+
 	dsi->ulps_auto_idle = false;
 
 	return 0;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (58 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 59/80] drm/omap: dsi: set trans_mode according to client mode_flags Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 17:30   ` Sam Ravnborg
                     ` (2 more replies)
  2020-11-24 12:45 ` [PATCH v4 61/80] drm/omap: dsi: send nop instead of page & column Tomi Valkeinen
                   ` (20 subsequent siblings)
  80 siblings, 3 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Set the column & page address once during setup, instead of relying the
DSI host driver to set those.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index 59e8e6b18e97..1e7f73340736 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -171,6 +171,26 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3)
 	return 0;
 }
 
+static int dsicm_set_update_window(struct panel_drv_data *ddata)
+{
+	struct mipi_dsi_device *dsi = ddata->dsi;
+	int r;
+	u16 x1 = 0;
+	u16 x2 = ddata->mode.hdisplay - 1;
+	u16 y1 = 0;
+	u16 y2 = ddata->mode.vdisplay - 1;
+
+	r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
+	if (r < 0)
+		return r;
+
+	r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
+	if (r < 0)
+		return r;
+
+	return 0;
+}
+
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
@@ -308,6 +328,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
 	if (r)
 		goto err;
 
+	r = dsicm_set_update_window(ddata);
+	if (r)
+		goto err;
+
 	r = mipi_dsi_dcs_set_display_on(ddata->dsi);
 	if (r)
 		goto err;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 61/80] drm/omap: dsi: send nop instead of page & column
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (59 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-30  9:58   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 62/80] drm/omap: dsi: simplify VC handling Tomi Valkeinen
                   ` (19 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

The OMAP DSI command mode panel driver used to send page & column
address before each frame update, and this code was moved into the DSI
host driver when converting it to the DRM bridge model.

However, it's not really required to send the page & column address
before each frame. It's also something that doesn't really belong to the
DSI host driver, so we should drop the code.

That said, frame updates break if we don't send _something_ between the
frames. A NOP command does the trick.

It is not clear if this behavior is as expected from a DSI command mode
frame transfer, or is it a feature/issue with OMAP DSI driver, or a
feature/issue in the command mode panel used. So this probably needs to
be revisited later.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 41 +++++++++----------------------
 1 file changed, 12 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 7fee9cf8782d..746c2149fbbd 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3884,35 +3884,19 @@ static int _dsi_update(struct dsi_data *dsi)
 	return 0;
 }
 
-static int _dsi_update_window(struct dsi_data *dsi, int channel,
-			      int x, int y, int w, int h)
-{
-	int x1 = x, x2 = (x + w - 1);
-	int y1 = y, y2 = (y + h - 1);
-	u8 payloadX[5] = { MIPI_DCS_SET_COLUMN_ADDRESS,
-			   x1 >> 8, x1 & 0xff, x2 >> 8, x2 & 0xff };
-	u8 payloadY[5] = { MIPI_DCS_SET_PAGE_ADDRESS,
-			   y1 >> 8, y1 & 0xff, y2 >> 8, y2 & 0xff };
-	struct mipi_dsi_msg msgX = { 0 }, msgY = { 0 };
-	int ret;
+static int _dsi_send_nop(struct dsi_data *dsi, int channel)
+{
+	const u8 payload[] = { MIPI_DCS_NOP };
+	const struct mipi_dsi_msg msg = {
+		.channel = channel,
+		.type = MIPI_DSI_DCS_SHORT_WRITE,
+		.tx_len = 1,
+		.tx_buf = payload,
+	};
 
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
-	msgX.type = MIPI_DSI_DCS_LONG_WRITE;
-	msgX.channel = channel;
-	msgX.tx_buf = payloadX;
-	msgX.tx_len = sizeof(payloadX);
-
-	msgY.type = MIPI_DSI_DCS_LONG_WRITE;
-	msgY.channel = channel;
-	msgY.tx_buf = payloadY;
-	msgY.tx_len = sizeof(payloadY);
-
-	ret = _omap_dsi_host_transfer(dsi, &msgX);
-	if (ret != 0)
-		return ret;
-
-	return _omap_dsi_host_transfer(dsi, &msgY);
+	return _omap_dsi_host_transfer(dsi, &msg);
 }
 
 static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
@@ -3944,10 +3928,9 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
 
 	dsi_set_ulps_auto(dsi, false);
 
-	r = _dsi_update_window(dsi, channel, 0, 0, dsi->vm.hactive,
-			       dsi->vm.vactive);
+	r = _dsi_send_nop(dsi, channel);
 	if (r < 0) {
-		DSSWARN("window update error: %d\n", r);
+		DSSWARN("failed to send nop between frames: %d\n", r);
 		goto err;
 	}
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 62/80] drm/omap: dsi: simplify VC handling
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (60 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 61/80] drm/omap: dsi: send nop instead of page & column Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-30 10:00   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 63/80] drm/omap: dsi: drop useless channel checks Tomi Valkeinen
                   ` (18 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

The VC handling has gotten quite tangled up. As the first step to clean
it up, lets define that we only support a single DSI peripheral (which
was really already the case), and we always use VC0 (define VC_DEFAULT
0) register block to send data to the peripheral.

We can thus have a single mipi_dsi_device pointer and remove the for
loops which made passes over all the four VCs (just the first one was
ever used).

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 49 ++++++++-----------------------
 1 file changed, 13 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 746c2149fbbd..63338324c564 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -360,9 +360,10 @@ struct dsi_data {
 	bool vdds_dsi_enabled;
 	struct regulator *vdds_dsi_reg;
 
+	struct mipi_dsi_device *dsidev;
+
 	struct {
 		enum dsi_vc_source source;
-		struct mipi_dsi_device *dest;
 		enum fifo_size tx_fifo_size;
 		enum fifo_size rx_fifo_size;
 	} vc[4];
@@ -452,6 +453,8 @@ static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
 #endif
 
+#define VC_DEFAULT 0
+
 #define drm_bridge_to_dsi(bridge) \
 	container_of(bridge, struct dsi_data, bridge)
 
@@ -3716,16 +3719,11 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
 static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	unsigned int i;
 
 	dsi_bus_lock(dsi);
 	dsi->video_enabled = false;
 
-	for (i = 0; i < 4; i++) {
-		if (!dsi->vc[i].dest)
-			continue;
-		dsi_disable_video_output(dssdev, i);
-	}
+	dsi_disable_video_output(dssdev, VC_DEFAULT);
 
 	dsi_display_disable(dssdev);
 
@@ -3914,11 +3912,6 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
 		goto err;
 	}
 
-	if (!dsi->vc[channel].dest) {
-		r = -ENODEV;
-		goto err;
-	}
-
 	if (dsi->vm.hactive == 0 || dsi->vm.vactive == 0) {
 		r = -EINVAL;
 		goto err;
@@ -3954,16 +3947,7 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
 
 static int dsi_update_all(struct omap_dss_device *dssdev)
 {
-	unsigned int i;
-	int r;
-
-	for (i = 0; i < 4; i++) {
-		r = dsi_update_channel(dssdev, i);
-		if (r && r != -ENODEV)
-			return r;
-	}
-
-	return r;
+	return dsi_update_channel(dssdev, VC_DEFAULT);
 }
 
 /* Display funcs */
@@ -4191,17 +4175,12 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
 static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
-	unsigned int i;
 
 	dsi_bus_lock(dsi);
 
 	dsi_display_enable(dssdev);
 
-	for (i = 0; i < 4; i++) {
-		if (!dsi->vc[i].dest)
-			continue;
-		dsi_enable_video_output(dssdev, i);
-	}
+	dsi_enable_video_output(dssdev, VC_DEFAULT);
 
 	dsi->video_enabled = true;
 
@@ -5090,8 +5069,8 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	if (channel > 3)
 		return -EINVAL;
 
-	if (dsi->vc[channel].dest) {
-		DSSERR("cannot get VC for display %s", dev_name(&client->dev));
+	if (dsi->dsidev) {
+		DSSERR("dsi client already attached\n");
 		return -EBUSY;
 	}
 
@@ -5112,7 +5091,7 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 		dsi->mode = OMAP_DSS_DSI_CMD_MODE;
 	}
 
-	dsi->vc[channel].dest = client;
+	dsi->dsidev = client;
 	dsi->pix_fmt = client->format;
 
 	INIT_DEFERRABLE_WORK(&dsi->ulps_work,
@@ -5144,11 +5123,11 @@ static int omap_dsi_host_detach(struct mipi_dsi_host *host,
 	if (channel > 3)
 		return -EINVAL;
 
-	if (dsi->vc[channel].dest != client)
+	if (WARN_ON(dsi->dsidev != client))
 		return -EINVAL;
 
 	omap_dsi_unregister_te_irq(dsi);
-	dsi->vc[channel].dest = NULL;
+	dsi->dsidev = NULL;
 	return 0;
 }
 
@@ -5680,10 +5659,8 @@ static int dsi_probe(struct platform_device *pdev)
 	}
 
 	/* DSI VCs initialization */
-	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
+	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++)
 		dsi->vc[i].source = DSI_VC_SOURCE_L4;
-		dsi->vc[i].dest = NULL;
-	}
 
 	r = dsi_get_clocks(dsi);
 	if (r)
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 63/80] drm/omap: dsi: drop useless channel checks
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (61 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 62/80] drm/omap: dsi: simplify VC handling Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:14   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 64/80] drm/omap: dsi: cleanup channel usages Tomi Valkeinen
                   ` (17 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

A DSI peripheral can have virtual channel ID of 0-3. This should be
always the case, and there's no need in the driver to validate the
channel.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 63338324c564..fbf05097612f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3902,9 +3902,6 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
-	if (channel > 3)
-		return -EINVAL;
-
 	dsi_bus_lock(dsi);
 
 	if (!dsi->video_enabled) {
@@ -5063,12 +5060,8 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 				struct mipi_dsi_device *client)
 {
 	struct dsi_data *dsi = host_to_omap(host);
-	unsigned int channel = client->channel;
 	int r;
 
-	if (channel > 3)
-		return -EINVAL;
-
 	if (dsi->dsidev) {
 		DSSERR("dsi client already attached\n");
 		return -EBUSY;
@@ -5118,10 +5111,6 @@ static int omap_dsi_host_detach(struct mipi_dsi_host *host,
 				struct mipi_dsi_device *client)
 {
 	struct dsi_data *dsi = host_to_omap(host);
-	unsigned int channel = client->channel;
-
-	if (channel > 3)
-		return -EINVAL;
 
 	if (WARN_ON(dsi->dsidev != client))
 		return -EINVAL;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 64/80] drm/omap: dsi: cleanup channel usages
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (62 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 63/80] drm/omap: dsi: drop useless channel checks Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:17   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 65/80] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode Tomi Valkeinen
                   ` (16 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

The "channel" usage in omap dsi driver is super confusing. We have three
different "channels":

1) DSI virtual channel ID. This is a number from 0 to 3, included in the
packet payload.

2) VC. This is a register block in the DSI IP. There are four of those
blocks. A VC is a DSI "pipeline", with defined fifo settings, data
source (cpu or dispc), and some other settings. It has no relation to
the 1).

3) dispc channel. It's the "pipeline" number dispc uses to send pixel
data.

To clean this up use the following names for each of the above: 1)
"channel" 2) "vc" 3) "dispc_channel"

This patch is mostly about renaming things, but as in some places 1) and
2) have gotten mixed up, additional changes were needed to untangle
them. This is mostly just adding a new parameter to some functions so
that we pass both the vc and the channel.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 315 +++++++++++++++---------------
 1 file changed, 158 insertions(+), 157 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index fbf05097612f..4ac82166edc3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -214,9 +214,9 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
 static int dsi_display_init_dispc(struct dsi_data *dsi);
 static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
-static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
+static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel);
 
-static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
+static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
 				       const struct mipi_dsi_msg *msg);
 
 static void dsi_display_disable(struct omap_dss_device *dssdev);
@@ -376,7 +376,7 @@ struct dsi_data {
 	/* space for a copy used by the interrupt handler */
 	struct dsi_isr_tables isr_tables_copy;
 
-	int update_channel;
+	int update_vc;
 #ifdef DSI_PERF_MEASURE
 	unsigned int update_bytes;
 #endif
@@ -639,7 +639,7 @@ static void print_irq_status(u32 status)
 #undef PIS
 }
 
-static void print_irq_status_vc(int channel, u32 status)
+static void print_irq_status_vc(int vc, u32 status)
 {
 	if (status == 0)
 		return;
@@ -650,7 +650,7 @@ static void print_irq_status_vc(int channel, u32 status)
 #define PIS(x) (status & DSI_VC_IRQ_##x) ? (#x " ") : ""
 
 	pr_debug("DSI VC(%d) IRQ 0x%x: %s%s%s%s%s%s%s%s%s\n",
-		channel,
+		vc,
 		status,
 		PIS(CS),
 		PIS(ECC_CORR),
@@ -1031,7 +1031,7 @@ static int dsi_unregister_isr(struct dsi_data *dsi, omap_dsi_isr_t isr,
 	return r;
 }
 
-static int dsi_register_isr_vc(struct dsi_data *dsi, int channel,
+static int dsi_register_isr_vc(struct dsi_data *dsi, int vc,
 			       omap_dsi_isr_t isr, void *arg, u32 mask)
 {
 	unsigned long flags;
@@ -1040,18 +1040,18 @@ static int dsi_register_isr_vc(struct dsi_data *dsi, int channel,
 	spin_lock_irqsave(&dsi->irq_lock, flags);
 
 	r = _dsi_register_isr(isr, arg, mask,
-			dsi->isr_tables.isr_table_vc[channel],
-			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
+			dsi->isr_tables.isr_table_vc[vc],
+			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]));
 
 	if (r == 0)
-		_omap_dsi_set_irqs_vc(dsi, channel);
+		_omap_dsi_set_irqs_vc(dsi, vc);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 
 	return r;
 }
 
-static int dsi_unregister_isr_vc(struct dsi_data *dsi, int channel,
+static int dsi_unregister_isr_vc(struct dsi_data *dsi, int vc,
 				 omap_dsi_isr_t isr, void *arg, u32 mask)
 {
 	unsigned long flags;
@@ -1060,11 +1060,11 @@ static int dsi_unregister_isr_vc(struct dsi_data *dsi, int channel,
 	spin_lock_irqsave(&dsi->irq_lock, flags);
 
 	r = _dsi_unregister_isr(isr, arg, mask,
-			dsi->isr_tables.isr_table_vc[channel],
-			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
+			dsi->isr_tables.isr_table_vc[vc],
+			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]));
 
 	if (r == 0)
-		_omap_dsi_set_irqs_vc(dsi, channel);
+		_omap_dsi_set_irqs_vc(dsi, vc);
 
 	spin_unlock_irqrestore(&dsi->irq_lock, flags);
 
@@ -2232,9 +2232,9 @@ static int dsi_force_tx_stop_mode_io(struct dsi_data *dsi)
 	return 0;
 }
 
-static bool dsi_vc_is_enabled(struct dsi_data *dsi, int channel)
+static bool dsi_vc_is_enabled(struct dsi_data *dsi, int vc)
 {
-	return REG_GET(dsi, DSI_VC_CTRL(channel), 0, 0);
+	return REG_GET(dsi, DSI_VC_CTRL(vc), 0, 0);
 }
 
 static void dsi_packet_sent_handler_vp(void *data, u32 mask)
@@ -2242,14 +2242,14 @@ static void dsi_packet_sent_handler_vp(void *data, u32 mask)
 	struct dsi_packet_sent_handler_data *vp_data =
 		(struct dsi_packet_sent_handler_data *) data;
 	struct dsi_data *dsi = vp_data->dsi;
-	const int channel = dsi->update_channel;
+	const int vc = dsi->update_vc;
 	u8 bit = dsi->te_enabled ? 30 : 31;
 
-	if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit) == 0)
+	if (REG_GET(dsi, DSI_VC_TE(vc), bit, bit) == 0)
 		complete(vp_data->completion);
 }
 
-static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel)
+static int dsi_sync_vc_vp(struct dsi_data *dsi, int vc)
 {
 	DECLARE_COMPLETION_ONSTACK(completion);
 	struct dsi_packet_sent_handler_data vp_data = {
@@ -2261,13 +2261,13 @@ static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel)
 
 	bit = dsi->te_enabled ? 30 : 31;
 
-	r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
+	r = dsi_register_isr_vc(dsi, vc, dsi_packet_sent_handler_vp,
 		&vp_data, DSI_VC_IRQ_PACKET_SENT);
 	if (r)
 		goto err0;
 
 	/* Wait for completion only if TE_EN/TE_START is still set */
-	if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit)) {
+	if (REG_GET(dsi, DSI_VC_TE(vc), bit, bit)) {
 		if (wait_for_completion_timeout(&completion,
 				msecs_to_jiffies(10)) == 0) {
 			DSSERR("Failed to complete previous frame transfer\n");
@@ -2276,12 +2276,12 @@ static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel)
 		}
 	}
 
-	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
+	dsi_unregister_isr_vc(dsi, vc, dsi_packet_sent_handler_vp,
 		&vp_data, DSI_VC_IRQ_PACKET_SENT);
 
 	return 0;
 err1:
-	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
+	dsi_unregister_isr_vc(dsi, vc, dsi_packet_sent_handler_vp,
 		&vp_data, DSI_VC_IRQ_PACKET_SENT);
 err0:
 	return r;
@@ -2292,13 +2292,13 @@ static void dsi_packet_sent_handler_l4(void *data, u32 mask)
 	struct dsi_packet_sent_handler_data *l4_data =
 		(struct dsi_packet_sent_handler_data *) data;
 	struct dsi_data *dsi = l4_data->dsi;
-	const int channel = dsi->update_channel;
+	const int vc = dsi->update_vc;
 
-	if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5) == 0)
+	if (REG_GET(dsi, DSI_VC_CTRL(vc), 5, 5) == 0)
 		complete(l4_data->completion);
 }
 
-static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel)
+static int dsi_sync_vc_l4(struct dsi_data *dsi, int vc)
 {
 	DECLARE_COMPLETION_ONSTACK(completion);
 	struct dsi_packet_sent_handler_data l4_data = {
@@ -2307,13 +2307,13 @@ static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel)
 	};
 	int r = 0;
 
-	r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
+	r = dsi_register_isr_vc(dsi, vc, dsi_packet_sent_handler_l4,
 		&l4_data, DSI_VC_IRQ_PACKET_SENT);
 	if (r)
 		goto err0;
 
 	/* Wait for completion only if TX_FIFO_NOT_EMPTY is still set */
-	if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5)) {
+	if (REG_GET(dsi, DSI_VC_CTRL(vc), 5, 5)) {
 		if (wait_for_completion_timeout(&completion,
 				msecs_to_jiffies(10)) == 0) {
 			DSSERR("Failed to complete previous l4 transfer\n");
@@ -2322,47 +2322,47 @@ static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel)
 		}
 	}
 
-	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
+	dsi_unregister_isr_vc(dsi, vc, dsi_packet_sent_handler_l4,
 		&l4_data, DSI_VC_IRQ_PACKET_SENT);
 
 	return 0;
 err1:
-	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
+	dsi_unregister_isr_vc(dsi, vc, dsi_packet_sent_handler_l4,
 		&l4_data, DSI_VC_IRQ_PACKET_SENT);
 err0:
 	return r;
 }
 
-static int dsi_sync_vc(struct dsi_data *dsi, int channel)
+static int dsi_sync_vc(struct dsi_data *dsi, int vc)
 {
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	WARN_ON(in_interrupt());
 
-	if (!dsi_vc_is_enabled(dsi, channel))
+	if (!dsi_vc_is_enabled(dsi, vc))
 		return 0;
 
-	switch (dsi->vc[channel].source) {
+	switch (dsi->vc[vc].source) {
 	case DSI_VC_SOURCE_VP:
-		return dsi_sync_vc_vp(dsi, channel);
+		return dsi_sync_vc_vp(dsi, vc);
 	case DSI_VC_SOURCE_L4:
-		return dsi_sync_vc_l4(dsi, channel);
+		return dsi_sync_vc_l4(dsi, vc);
 	default:
 		BUG();
 		return -EINVAL;
 	}
 }
 
-static int dsi_vc_enable(struct dsi_data *dsi, int channel, bool enable)
+static int dsi_vc_enable(struct dsi_data *dsi, int vc, bool enable)
 {
-	DSSDBG("dsi_vc_enable channel %d, enable %d\n",
-			channel, enable);
+	DSSDBG("dsi_vc_enable vc %d, enable %d\n",
+			vc, enable);
 
 	enable = enable ? 1 : 0;
 
-	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 0, 0);
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 0, 0);
 
-	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 0, enable)) {
+	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(vc), 0, enable)) {
 		DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
 		return -EIO;
 	}
@@ -2370,17 +2370,17 @@ static int dsi_vc_enable(struct dsi_data *dsi, int channel, bool enable)
 	return 0;
 }
 
-static void dsi_vc_initial_config(struct dsi_data *dsi, int channel)
+static void dsi_vc_initial_config(struct dsi_data *dsi, int vc)
 {
 	u32 r;
 
-	DSSDBG("Initial config of virtual channel %d", channel);
+	DSSDBG("Initial config of VC %d", vc);
 
-	r = dsi_read_reg(dsi, DSI_VC_CTRL(channel));
+	r = dsi_read_reg(dsi, DSI_VC_CTRL(vc));
 
 	if (FLD_GET(r, 15, 15)) /* VC_BUSY */
 		DSSERR("VC(%d) busy when trying to configure it!\n",
-				channel);
+				vc);
 
 	r = FLD_MOD(r, 0, 1, 1); /* SOURCE, 0 = L4 */
 	r = FLD_MOD(r, 0, 2, 2); /* BTA_SHORT_EN  */
@@ -2395,76 +2395,76 @@ static void dsi_vc_initial_config(struct dsi_data *dsi, int channel)
 	r = FLD_MOD(r, 4, 29, 27); /* DMA_RX_REQ_NB = no dma */
 	r = FLD_MOD(r, 4, 23, 21); /* DMA_TX_REQ_NB = no dma */
 
-	dsi_write_reg(dsi, DSI_VC_CTRL(channel), r);
+	dsi_write_reg(dsi, DSI_VC_CTRL(vc), r);
 
-	dsi->vc[channel].source = DSI_VC_SOURCE_L4;
+	dsi->vc[vc].source = DSI_VC_SOURCE_L4;
 }
 
-static int dsi_vc_config_source(struct dsi_data *dsi, int channel,
+static int dsi_vc_config_source(struct dsi_data *dsi, int vc,
 				enum dsi_vc_source source)
 {
-	if (dsi->vc[channel].source == source)
+	if (dsi->vc[vc].source == source)
 		return 0;
 
-	DSSDBG("Source config of virtual channel %d", channel);
+	DSSDBG("Source config of VC %d", vc);
 
-	dsi_sync_vc(dsi, channel);
+	dsi_sync_vc(dsi, vc);
 
-	dsi_vc_enable(dsi, channel, 0);
+	dsi_vc_enable(dsi, vc, 0);
 
 	/* VC_BUSY */
-	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 15, 0)) {
-		DSSERR("vc(%d) busy when trying to config for VP\n", channel);
+	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(vc), 15, 0)) {
+		DSSERR("vc(%d) busy when trying to config for VP\n", vc);
 		return -EIO;
 	}
 
 	/* SOURCE, 0 = L4, 1 = video port */
-	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), source, 1, 1);
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), source, 1, 1);
 
 	/* DCS_CMD_ENABLE */
 	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) {
 		bool enable = source == DSI_VC_SOURCE_VP;
-		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 30, 30);
+		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 30, 30);
 	}
 
-	dsi_vc_enable(dsi, channel, 1);
+	dsi_vc_enable(dsi, vc, 1);
 
-	dsi->vc[channel].source = source;
+	dsi->vc[vc].source = source;
 
 	return 0;
 }
 
-static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
+static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
 		bool enable)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
-	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable);
+	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", vc, enable);
 
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
-	dsi_vc_enable(dsi, channel, 0);
+	dsi_vc_enable(dsi, vc, 0);
 	dsi_if_enable(dsi, 0);
 
-	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 9, 9);
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 9, 9);
 
-	dsi_vc_enable(dsi, channel, 1);
+	dsi_vc_enable(dsi, vc, 1);
 	dsi_if_enable(dsi, 1);
 
 	dsi_force_tx_stop_mode_io(dsi);
 
 	/* start the DDR clock by sending a NULL packet */
 	if (dsi->vm_timings.ddr_clk_always_on && enable)
-		dsi_vc_send_null(dsi, channel);
+		dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
 
 	dsi->in_lp_mode = !enable;
 }
 
-static void dsi_vc_flush_long_data(struct dsi_data *dsi, int channel)
+static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
 {
-	while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
+	while (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
 		u32 val;
-		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
+		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc));
 		DSSDBG("\t\tb1 %#02x b2 %#02x b3 %#02x b4 %#02x\n",
 				(val >> 0) & 0xff,
 				(val >> 8) & 0xff,
@@ -2510,13 +2510,13 @@ static void dsi_show_rx_ack_with_err(u16 err)
 		DSSERR("\t\tDSI Protocol Violation\n");
 }
 
-static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel)
+static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int vc)
 {
 	/* RX_FIFO_NOT_EMPTY */
-	while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
+	while (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
 		u32 val;
 		u8 dt;
-		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
+		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc));
 		DSSERR("\trawval %#08x\n", val);
 		dt = FLD_GET(val, 5, 0);
 		if (dt == MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT) {
@@ -2531,7 +2531,7 @@ static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel)
 		} else if (dt == MIPI_DSI_RX_DCS_LONG_READ_RESPONSE) {
 			DSSERR("\tDCS long response, len %d\n",
 					FLD_GET(val, 23, 8));
-			dsi_vc_flush_long_data(dsi, channel);
+			dsi_vc_flush_long_data(dsi, vc);
 		} else {
 			DSSERR("\tunknown datatype 0x%02x\n", dt);
 		}
@@ -2539,35 +2539,35 @@ static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel)
 	return 0;
 }
 
-static int dsi_vc_send_bta(struct dsi_data *dsi, int channel)
+static int dsi_vc_send_bta(struct dsi_data *dsi, int vc)
 {
 	if (dsi->debug_write || dsi->debug_read)
-		DSSDBG("dsi_vc_send_bta %d\n", channel);
+		DSSDBG("dsi_vc_send_bta %d\n", vc);
 
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	/* RX_FIFO_NOT_EMPTY */
-	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
+	if (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
 		DSSERR("rx fifo not empty when sending BTA, dumping data:\n");
-		dsi_vc_flush_receive_data(dsi, channel);
+		dsi_vc_flush_receive_data(dsi, vc);
 	}
 
-	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 6, 6); /* BTA_EN */
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 6, 6); /* BTA_EN */
 
 	/* flush posted write */
-	dsi_read_reg(dsi, DSI_VC_CTRL(channel));
+	dsi_read_reg(dsi, DSI_VC_CTRL(vc));
 
 	return 0;
 }
 
-static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
+static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int vc)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	DECLARE_COMPLETION_ONSTACK(completion);
 	int r = 0;
 	u32 err;
 
-	r = dsi_register_isr_vc(dsi, channel, dsi_completion_handler,
+	r = dsi_register_isr_vc(dsi, vc, dsi_completion_handler,
 			&completion, DSI_VC_IRQ_BTA);
 	if (r)
 		goto err0;
@@ -2577,7 +2577,7 @@ static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
 	if (r)
 		goto err1;
 
-	r = dsi_vc_send_bta(dsi, channel);
+	r = dsi_vc_send_bta(dsi, vc);
 	if (r)
 		goto err2;
 
@@ -2598,14 +2598,15 @@ static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
 	dsi_unregister_isr(dsi, dsi_completion_handler, &completion,
 			DSI_IRQ_ERROR_MASK);
 err1:
-	dsi_unregister_isr_vc(dsi, channel, dsi_completion_handler,
+	dsi_unregister_isr_vc(dsi, vc, dsi_completion_handler,
 			&completion, DSI_VC_IRQ_BTA);
 err0:
 	return r;
 }
 
-static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel,
-					    u8 data_type, u16 len, u8 ecc)
+static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int vc,
+					    int channel, u8 data_type, u16 len,
+					    u8 ecc)
 {
 	u32 val;
 	u8 data_id;
@@ -2615,12 +2616,12 @@ static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel,
 	data_id = data_type | channel << 6;
 
 	val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
-		FLD_VAL(ecc, 31, 24);
+	      FLD_VAL(ecc, 31, 24);
 
-	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_HEADER(channel), val);
+	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_HEADER(vc), val);
 }
 
-static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel,
+static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int vc,
 					     u8 b1, u8 b2, u8 b3, u8 b4)
 {
 	u32 val;
@@ -2630,10 +2631,10 @@ static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel,
 /*	DSSDBG("\twriting %02x, %02x, %02x, %02x (%#010x)\n",
 			b1, b2, b3, b4, val); */
 
-	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
+	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(vc), val);
 }
 
-static int dsi_vc_send_long(struct dsi_data *dsi,
+static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
 			    const struct mipi_dsi_msg *msg)
 {
 	/*u32 val; */
@@ -2646,14 +2647,14 @@ static int dsi_vc_send_long(struct dsi_data *dsi,
 		DSSDBG("dsi_vc_send_long, %d bytes\n", msg->tx_len);
 
 	/* len + header */
-	if (dsi->vc[msg->channel].tx_fifo_size * 32 * 4 < msg->tx_len + 4) {
+	if (dsi->vc[vc].tx_fifo_size * 32 * 4 < msg->tx_len + 4) {
 		DSSERR("unable to send long packet: packet too long.\n");
 		return -EINVAL;
 	}
 
-	dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
+	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
 
-	dsi_vc_write_long_header(dsi, msg->channel, msg->type, msg->tx_len, 0);
+	dsi_vc_write_long_header(dsi, vc, msg->channel, msg->type, msg->tx_len, 0);
 
 	p = msg->tx_buf;
 	for (i = 0; i < msg->tx_len >> 2; i++) {
@@ -2665,7 +2666,7 @@ static int dsi_vc_send_long(struct dsi_data *dsi,
 		b3 = *p++;
 		b4 = *p++;
 
-		dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, b4);
+		dsi_vc_write_long_payload(dsi, vc, b1, b2, b3, b4);
 	}
 
 	i = msg->tx_len % 4;
@@ -2690,13 +2691,13 @@ static int dsi_vc_send_long(struct dsi_data *dsi,
 			break;
 		}
 
-		dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, 0);
+		dsi_vc_write_long_payload(dsi, vc, b1, b2, b3, 0);
 	}
 
 	return r;
 }
 
-static int dsi_vc_send_short(struct dsi_data *dsi,
+static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
 			     const struct mipi_dsi_msg *msg)
 {
 	struct mipi_dsi_packet pkt;
@@ -2710,11 +2711,11 @@ static int dsi_vc_send_short(struct dsi_data *dsi,
 
 	if (dsi->debug_write)
 		DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
-		       msg->channel, msg->type, pkt.header[1], pkt.header[2]);
+		       vc, msg->type, pkt.header[1], pkt.header[2]);
 
-	dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
+	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
 
-	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(msg->channel)), 16, 16)) {
+	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(vc)), 16, 16)) {
 		DSSERR("ERROR FIFO FULL, aborting transfer\n");
 		return -EINVAL;
 	}
@@ -2722,31 +2723,31 @@ static int dsi_vc_send_short(struct dsi_data *dsi,
 	r = pkt.header[3] << 24 | pkt.header[2] << 16 | pkt.header[1] << 8 |
 	    pkt.header[0];
 
-	dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(msg->channel), r);
+	dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc), r);
 
 	return 0;
 }
 
-static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
+static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel)
 {
 	const struct mipi_dsi_msg msg = {
 		.channel = channel,
 		.type = MIPI_DSI_NULL_PACKET,
 	};
 
-	return dsi_vc_send_long(dsi, &msg);
+	return dsi_vc_send_long(dsi, vc, &msg);
 }
 
-static int dsi_vc_write_common(struct omap_dss_device *dssdev,
+static int dsi_vc_write_common(struct omap_dss_device *dssdev, int vc,
 			       const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
 	if (mipi_dsi_packet_format_is_short(msg->type))
-		r = dsi_vc_send_short(dsi, msg);
+		r = dsi_vc_send_short(dsi, vc, msg);
 	else
-		r = dsi_vc_send_long(dsi, msg);
+		r = dsi_vc_send_long(dsi, vc, msg);
 
 	if (r < 0)
 		return r;
@@ -2758,23 +2759,23 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev,
 	 * In that case we can return early.
 	 */
 
-	r = dsi_vc_send_bta_sync(dssdev, msg->channel);
+	r = dsi_vc_send_bta_sync(dssdev, vc);
 	if (r) {
 		DSSERR("bta sync failed\n");
 		return r;
 	}
 
 	/* RX_FIFO_NOT_EMPTY */
-	if (REG_GET(dsi, DSI_VC_CTRL(msg->channel), 20, 20)) {
+	if (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
 		DSSERR("rx fifo not empty after write, dumping data:\n");
-		dsi_vc_flush_receive_data(dsi, msg->channel);
+		dsi_vc_flush_receive_data(dsi, vc);
 		return -EIO;
 	}
 
 	return 0;
 }
 
-static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
+static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int vc, u8 *buf,
 			       int buflen, enum dss_dsi_content_type type)
 {
 	u32 val;
@@ -2782,13 +2783,13 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
 	int r;
 
 	/* RX_FIFO_NOT_EMPTY */
-	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20) == 0) {
+	if (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20) == 0) {
 		DSSERR("RX fifo empty when trying to read.\n");
 		r = -EIO;
 		goto err;
 	}
 
-	val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
+	val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc));
 	if (dsi->debug_read)
 		DSSDBG("\theader: %08x\n", val);
 	dt = FLD_GET(val, 5, 0);
@@ -2852,7 +2853,7 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
 		for (w = 0; w < len + 2;) {
 			int b;
 			val = dsi_read_reg(dsi,
-				DSI_VC_SHORT_PACKET_HEADER(channel));
+				DSI_VC_SHORT_PACKET_HEADER(vc));
 			if (dsi->debug_read)
 				DSSDBG("\t\t%02x %02x %02x %02x\n",
 						(val >> 0) & 0xff,
@@ -2876,32 +2877,31 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
 	}
 
 err:
-	DSSERR("dsi_vc_read_rx_fifo(ch %d type %s) failed\n", channel,
+	DSSERR("dsi_vc_read_rx_fifo(vc %d type %s) failed\n", vc,
 		type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" : "DCS");
 
 	return r;
 }
 
-static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
+static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int vc,
 			   const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	u8 cmd = ((u8 *)msg->tx_buf)[0];
-	u8 channel = msg->channel;
 	int r;
 
 	if (dsi->debug_read)
-		DSSDBG("%s(ch %d, cmd %x)\n", __func__, channel, cmd);
+		DSSDBG("%s(ch %d, cmd %x)\n", __func__, vc, cmd);
 
-	r = dsi_vc_send_short(dsi, msg);
+	r = dsi_vc_send_short(dsi, vc, msg);
 	if (r)
 		goto err;
 
-	r = dsi_vc_send_bta_sync(dssdev, channel);
+	r = dsi_vc_send_bta_sync(dssdev, vc);
 	if (r)
 		goto err;
 
-	r = dsi_vc_read_rx_fifo(dsi, channel, msg->rx_buf, msg->rx_len,
+	r = dsi_vc_read_rx_fifo(dsi, vc, msg->rx_buf, msg->rx_len,
 		DSS_DSI_CONTENT_DCS);
 	if (r < 0)
 		goto err;
@@ -2913,25 +2913,25 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
 
 	return 0;
 err:
-	DSSERR("%s(ch %d, cmd 0x%02x) failed\n", __func__,  msg->channel, cmd);
+	DSSERR("%s(ch %d, cmd 0x%02x) failed\n", __func__,  vc, cmd);
 	return r;
 }
 
-static int dsi_vc_generic_read(struct omap_dss_device *dssdev,
+static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int vc,
 			       const struct mipi_dsi_msg *msg)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
-	r = dsi_vc_send_short(dsi, msg);
+	r = dsi_vc_send_short(dsi, vc, msg);
 	if (r)
 		goto err;
 
-	r = dsi_vc_send_bta_sync(dssdev, msg->channel);
+	r = dsi_vc_send_bta_sync(dssdev, vc);
 	if (r)
 		goto err;
 
-	r = dsi_vc_read_rx_fifo(dsi, msg->channel, msg->rx_buf, msg->rx_len,
+	r = dsi_vc_read_rx_fifo(dsi, vc, msg->rx_buf, msg->rx_len,
 		DSS_DSI_CONTENT_GENERIC);
 	if (r < 0)
 		goto err;
@@ -2943,7 +2943,7 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev,
 
 	return 0;
 err:
-	DSSERR("%s(ch %d, reqlen %d) failed\n", __func__,  msg->channel, msg->tx_len);
+	DSSERR("%s(ch %d, reqlen %d) failed\n", __func__,  vc, msg->tx_len);
 	return r;
 }
 
@@ -3631,7 +3631,7 @@ static int dsi_configure_pins(struct dsi_data *dsi,
 	return 0;
 }
 
-static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
+static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
@@ -3665,17 +3665,17 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 		}
 
 		dsi_if_enable(dsi, false);
-		dsi_vc_enable(dsi, channel, false);
+		dsi_vc_enable(dsi, vc, false);
 
 		/* MODE, 1 = video mode */
-		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 4, 4);
+		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 4, 4);
 
 		word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
 
-		dsi_vc_write_long_header(dsi, channel, data_type,
+		dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, data_type,
 				word_count, 0);
 
-		dsi_vc_enable(dsi, channel, true);
+		dsi_vc_enable(dsi, vc, true);
 		dsi_if_enable(dsi, true);
 	}
 
@@ -3688,7 +3688,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 err_mgr_enable:
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
 		dsi_if_enable(dsi, false);
-		dsi_vc_enable(dsi, channel, false);
+		dsi_vc_enable(dsi, vc, false);
 	}
 err_pix_fmt:
 	dsi_display_uninit_dispc(dsi);
@@ -3696,18 +3696,18 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 	return;
 }
 
-static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel)
+static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
 		dsi_if_enable(dsi, false);
-		dsi_vc_enable(dsi, channel, false);
+		dsi_vc_enable(dsi, vc, false);
 
 		/* MODE, 0 = command mode */
-		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 0, 4, 4);
+		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);
 
-		dsi_vc_enable(dsi, channel, true);
+		dsi_vc_enable(dsi, vc, true);
 		dsi_if_enable(dsi, true);
 	}
 
@@ -3740,14 +3740,14 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
 	unsigned int packet_len;
 	u32 l;
 	int r;
-	const unsigned channel = dsi->update_channel;
+	const unsigned vc = dsi->update_vc;
 	const unsigned int line_buf_size = dsi->line_buffer_size;
 	u16 w = dsi->vm.hactive;
 	u16 h = dsi->vm.vactive;
 
 	DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h);
 
-	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_VP);
+	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_VP);
 
 	bytespp	= mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) / 8;
 	bytespl = w * bytespp;
@@ -3768,16 +3768,16 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
 		total_len += (bytespf % packet_payload) + 1;
 
 	l = FLD_VAL(total_len, 23, 0); /* TE_SIZE */
-	dsi_write_reg(dsi, DSI_VC_TE(channel), l);
+	dsi_write_reg(dsi, DSI_VC_TE(vc), l);
 
-	dsi_vc_write_long_header(dsi, channel, MIPI_DSI_DCS_LONG_WRITE,
+	dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, MIPI_DSI_DCS_LONG_WRITE,
 		packet_len, 0);
 
 	if (dsi->te_enabled)
 		l = FLD_MOD(l, 1, 30, 30); /* TE_EN */
 	else
 		l = FLD_MOD(l, 1, 31, 31); /* TE_START */
-	dsi_write_reg(dsi, DSI_VC_TE(channel), l);
+	dsi_write_reg(dsi, DSI_VC_TE(vc), l);
 
 	/* We put SIDLEMODE to no-idle for the duration of the transfer,
 	 * because DSS interrupts are not capable of waking up the CPU and the
@@ -3800,7 +3800,7 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
 		 * for TE is longer than the timer allows */
 		REG_FLD_MOD(dsi, DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */
 
-		dsi_vc_send_bta(dsi, channel);
+		dsi_vc_send_bta(dsi, vc);
 
 #ifdef DSI_CATCH_MISSING_TE
 		mod_timer(&dsi->te_timer, jiffies + msecs_to_jiffies(250));
@@ -3882,7 +3882,7 @@ static int _dsi_update(struct dsi_data *dsi)
 	return 0;
 }
 
-static int _dsi_send_nop(struct dsi_data *dsi, int channel)
+static int _dsi_send_nop(struct dsi_data *dsi, int vc, int channel)
 {
 	const u8 payload[] = { MIPI_DCS_NOP };
 	const struct mipi_dsi_msg msg = {
@@ -3894,10 +3894,10 @@ static int _dsi_send_nop(struct dsi_data *dsi, int channel)
 
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
-	return _omap_dsi_host_transfer(dsi, &msg);
+	return _omap_dsi_host_transfer(dsi, vc, &msg);
 }
 
-static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
+static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
@@ -3914,17 +3914,17 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
 		goto err;
 	}
 
-	DSSDBG("dsi_update_channel: %d", channel);
+	DSSDBG("dsi_update_channel: %d", vc);
 
 	dsi_set_ulps_auto(dsi, false);
 
-	r = _dsi_send_nop(dsi, channel);
+	r = _dsi_send_nop(dsi, vc, dsi->dsidev->channel);
 	if (r < 0) {
 		DSSWARN("failed to send nop between frames: %d\n", r);
 		goto err;
 	}
 
-	dsi->update_channel = channel;
+	dsi->update_vc = vc;
 
 	if (dsi->te_enabled && dsi->te_gpio) {
 		schedule_delayed_work(&dsi->te_timeout_work,
@@ -3973,10 +3973,10 @@ static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
 
 static int dsi_display_init_dispc(struct dsi_data *dsi)
 {
-	enum omap_channel channel = dsi->output.dispc_channel;
+	enum omap_channel dispc_channel = dsi->output.dispc_channel;
 	int r;
 
-	dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
+	dss_select_lcd_clk_source(dsi->dss, dispc_channel, dsi->module_id == 0 ?
 			DSS_CLK_SRC_PLL1_1 :
 			DSS_CLK_SRC_PLL2_1);
 
@@ -4012,19 +4012,19 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
 		dss_mgr_unregister_framedone_handler(&dsi->output,
 				dsi_framedone_irq_callback, dsi);
 err:
-	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
+	dss_select_lcd_clk_source(dsi->dss, dispc_channel, DSS_CLK_SRC_FCK);
 	return r;
 }
 
 static void dsi_display_uninit_dispc(struct dsi_data *dsi)
 {
-	enum omap_channel channel = dsi->output.dispc_channel;
+	enum omap_channel dispc_channel = dsi->output.dispc_channel;
 
 	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
 		dss_mgr_unregister_framedone_handler(&dsi->output,
 				dsi_framedone_irq_callback, dsi);
 
-	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
+	dss_select_lcd_clk_source(dsi->dss, dispc_channel, DSS_CLK_SRC_FCK);
 }
 
 static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
@@ -4841,12 +4841,12 @@ static int dsi_set_config(struct omap_dss_device *dssdev,
 }
 
 /*
- * Return a hardcoded channel for the DSI output. This should work for
+ * Return a hardcoded dispc channel for the DSI output. This should work for
  * current use cases, but this can be later expanded to either resolve
  * the channel in some more dynamic manner, or get the channel as a user
  * parameter.
  */
-static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
+static enum omap_channel dsi_get_dispc_channel(struct dsi_data *dsi)
 {
 	switch (dsi->data->model) {
 	case DSI_MODEL_OMAP3:
@@ -4880,14 +4880,14 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
 	}
 }
 
-static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
+static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
 				       const struct mipi_dsi_msg *msg)
 {
 	struct omap_dss_device *dssdev = &dsi->output;
 	int r;
 
 	if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode)
-		dsi_vc_enable_hs(dssdev, msg->channel,
+		dsi_vc_enable_hs(dssdev, vc,
 				 !(msg->flags & MIPI_DSI_MSG_USE_LPM));
 
 	switch (msg->type) {
@@ -4900,15 +4900,15 @@ static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
 	case MIPI_DSI_DCS_LONG_WRITE:
 	case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
 	case MIPI_DSI_NULL_PACKET:
-		r = dsi_vc_write_common(dssdev, msg);
+		r = dsi_vc_write_common(dssdev, vc, msg);
 		break;
 	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
-		r = dsi_vc_generic_read(dssdev, msg);
+		r = dsi_vc_generic_read(dssdev, vc, msg);
 		break;
 	case MIPI_DSI_DCS_READ:
-		r = dsi_vc_dcs_read(dssdev, msg);
+		r = dsi_vc_dcs_read(dssdev, vc, msg);
 		break;
 	default:
 		r = -EINVAL;
@@ -4936,12 +4936,13 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 {
 	struct dsi_data *dsi = host_to_omap(host);
 	int r;
+	int vc = VC_DEFAULT;
 
 	dsi_bus_lock(dsi);
 
 	if (dsi->video_enabled) {
 		dsi_set_ulps_auto(dsi, false);
-		r = _omap_dsi_host_transfer(dsi, msg);
+		r = _omap_dsi_host_transfer(dsi, vc, msg);
 		dsi_set_ulps_auto(dsi, true);
 	} else {
 		r = -EIO;
@@ -5398,7 +5399,7 @@ static int dsi_init_output(struct dsi_data *dsi)
 
 	out->type = OMAP_DISPLAY_TYPE_DSI;
 	out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
-	out->dispc_channel = dsi_get_channel(dsi);
+	out->dispc_channel = dsi_get_dispc_channel(dsi);
 	out->dsi_ops = &dsi_ops;
 	out->of_port = 0;
 	out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 65/80] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (63 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 64/80] drm/omap: dsi: cleanup channel usages Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:18   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 66/80] drm/omap: dsi: set LP/HS before update Tomi Valkeinen
                   ` (15 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Simplify and optimize dsi_vc_enable_hs() so that it can be called
without checking the current HS/LP mode. Make dsi_vc_enable_hs() return
if the VC is already in the correct mode.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 4ac82166edc3..c3f13226ac26 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -341,7 +341,6 @@ struct dsi_data {
 	int irq;
 
 	bool is_enabled;
-	bool in_lp_mode;
 
 	struct clk *dss_clk;
 	struct regmap *syscon;
@@ -2441,6 +2440,9 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
 
 	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", vc, enable);
 
+	if (REG_GET(dsi, DSI_VC_CTRL(vc), 9, 9) == enable)
+		return;
+
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	dsi_vc_enable(dsi, vc, 0);
@@ -2456,8 +2458,6 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
 	/* start the DDR clock by sending a NULL packet */
 	if (dsi->vm_timings.ddr_clk_always_on && enable)
 		dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
-
-	dsi->in_lp_mode = !enable;
 }
 
 static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
@@ -4886,9 +4886,7 @@ static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
 	struct omap_dss_device *dssdev = &dsi->output;
 	int r;
 
-	if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode)
-		dsi_vc_enable_hs(dssdev, vc,
-				 !(msg->flags & MIPI_DSI_MSG_USE_LPM));
+	dsi_vc_enable_hs(dssdev, vc, !(msg->flags & MIPI_DSI_MSG_USE_LPM));
 
 	switch (msg->type) {
 	case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 66/80] drm/omap: dsi: set LP/HS before update
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (64 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 65/80] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:20   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 67/80] drm/omap: dsi: use separate VCs for cmd and video Tomi Valkeinen
                   ` (14 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

We currently use a single VC for sending commands and pixel data. The
LP/HS mode for pixel data is correct by accident, as we have set the VC
to HS already earlier.

However, if we use a different VC for video data, the VC is in LP mode.
Fix this by always setting the LP/HS mode before starting a frame
update.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c3f13226ac26..41d6231d6e31 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3918,6 +3918,8 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
 
 	dsi_set_ulps_auto(dsi, false);
 
+	dsi_vc_enable_hs(dssdev, vc, !(dsi->dsidev->mode_flags & MIPI_DSI_MODE_LPM));
+
 	r = _dsi_send_nop(dsi, vc, dsi->dsidev->channel);
 	if (r < 0) {
 		DSSWARN("failed to send nop between frames: %d\n", r);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 67/80] drm/omap: dsi: use separate VCs for cmd and video
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (65 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 66/80] drm/omap: dsi: set LP/HS before update Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:21   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
                   ` (13 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

For command mode panels we can use a single VC for sending command and
video data, even if we have to change the data source for that VC when
going from command to video or vice versa.

However, with video mode panels we want to keep the pixel data VC
enabled, and use another VC for command data, and the commands will get
interleaved into the pixel data.

This patch makes the driver use VC0 for commands and VC1 for video.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 41d6231d6e31..019814a0a264 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -452,7 +452,9 @@ static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
 #endif
 
-#define VC_DEFAULT 0
+/* Note: for some reason video mode seems to work only if VC_VIDEO is 0 */
+#define VC_VIDEO	0
+#define VC_CMD		1
 
 #define drm_bridge_to_dsi(bridge) \
 	container_of(bridge, struct dsi_data, bridge)
@@ -3723,7 +3725,7 @@ static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
 	dsi_bus_lock(dsi);
 	dsi->video_enabled = false;
 
-	dsi_disable_video_output(dssdev, VC_DEFAULT);
+	dsi_disable_video_output(dssdev, VC_VIDEO);
 
 	dsi_display_disable(dssdev);
 
@@ -3946,7 +3948,7 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
 
 static int dsi_update_all(struct omap_dss_device *dssdev)
 {
-	return dsi_update_channel(dssdev, VC_DEFAULT);
+	return dsi_update_channel(dssdev, VC_VIDEO);
 }
 
 /* Display funcs */
@@ -4179,7 +4181,7 @@ static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
 
 	dsi_display_enable(dssdev);
 
-	dsi_enable_video_output(dssdev, VC_DEFAULT);
+	dsi_enable_video_output(dssdev, VC_VIDEO);
 
 	dsi->video_enabled = true;
 
@@ -4936,7 +4938,7 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 {
 	struct dsi_data *dsi = host_to_omap(host);
 	int r;
-	int vc = VC_DEFAULT;
+	int vc = VC_CMD;
 
 	dsi_bus_lock(dsi);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if'
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (66 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 67/80] drm/omap: dsi: use separate VCs for cmd and video Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 17:34   ` Sam Ravnborg
                     ` (2 more replies)
  2020-11-24 12:45 ` [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver Tomi Valkeinen
                   ` (12 subsequent siblings)
  80 siblings, 3 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

We have a useless 'if' in the dsicm_bl_update_status(), a left over from
the conversion to DRM model. Drop the if.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index 1e7f73340736..c17ed728c695 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -194,7 +194,7 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata)
 static int dsicm_bl_update_status(struct backlight_device *dev)
 {
 	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
-	int r = 0;
+	int r;
 	int level;
 
 	if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
@@ -207,11 +207,9 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
 
 	mutex_lock(&ddata->lock);
 
-	if (ddata->enabled) {
-		if (!r)
-			r = dsicm_dcs_write_1(
-				ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
-	}
+	if (ddata->enabled)
+		r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
+				      level);
 
 	mutex_unlock(&ddata->lock);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (67 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 17:35   ` Sam Ravnborg
  2020-12-01  0:23   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes Tomi Valkeinen
                   ` (11 subsequent siblings)
  80 siblings, 2 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Add a panel database to the driver instead of reading propertes from DT
data. This is similar to panel-simple, and I believe it's more future
safe way to handle the panels.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 107 +++++++++++++++++----------
 1 file changed, 69 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index c17ed728c695..ec87b785871f 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -22,10 +22,7 @@
 #include <drm/drm_modes.h>
 #include <drm/drm_panel.h>
 
-#include <video/display_timing.h>
 #include <video/mipi_display.h>
-#include <video/of_display_timing.h>
-#include <video/videomode.h>
 
 #define DCS_GET_ID1		0xda
 #define DCS_GET_ID2		0xdb
@@ -33,6 +30,18 @@
 
 #define DCS_REGULATOR_SUPPLY_NUM 2
 
+static const struct of_device_id dsicm_of_match[];
+
+struct dsic_panel_data {
+	u32 xres;
+	u32 yres;
+	u32 refresh;
+	u32 width_mm;
+	u32 height_mm;
+	u32 max_hs_rate;
+	u32 max_lp_rate;
+};
+
 struct panel_drv_data {
 	struct mipi_dsi_device *dsi;
 	struct drm_panel panel;
@@ -48,16 +57,14 @@ struct panel_drv_data {
 					 */
 	unsigned long	hw_guard_wait;	/* max guard time in jiffies */
 
-	/* panel HW configuration from DT or platform data */
+	const struct dsic_panel_data *panel_data;
+
 	struct gpio_desc *reset_gpio;
 
 	struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
 
 	bool use_dsi_backlight;
 
-	int width_mm;
-	int height_mm;
-
 	/* runtime variables */
 	bool enabled;
 
@@ -455,11 +462,8 @@ static int dsicm_get_modes(struct drm_panel *panel,
 		return -ENOMEM;
 	}
 
-	drm_mode_set_name(mode);
-	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
-
-	connector->display_info.width_mm = ddata->width_mm;
-	connector->display_info.height_mm = ddata->height_mm;
+	connector->display_info.width_mm = ddata->panel_data->width_mm;
+	connector->display_info.height_mm = ddata->panel_data->height_mm;
 
 	drm_mode_probed_add(connector, mode);
 
@@ -476,15 +480,10 @@ static const struct drm_panel_funcs dsicm_panel_funcs = {
 
 static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 {
-	struct device_node *node = dsi->dev.of_node;
 	struct backlight_device *backlight;
 	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
-	struct display_timing timing;
-	struct videomode vm = {
-		.hactive = 864,
-		.vactive = 480,
-	};
 	int err;
+	struct drm_display_mode *mode = &ddata->mode;
 
 	ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ddata->reset_gpio)) {
@@ -493,23 +492,16 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 		return err;
 	}
 
-	err = of_get_display_timing(node, "panel-timing", &timing);
-	if (!err) {
-		videomode_from_timing(&timing, &vm);
-	} else {
-		dev_warn(&dsi->dev,
-			 "failed to get video timing, using defaults\n");
-	}
-
-	if (!vm.pixelclock)
-		vm.pixelclock = vm.hactive * vm.vactive * 60;
-	drm_display_mode_from_videomode(&vm, &ddata->mode);
-
-	ddata->width_mm = 0;
-	of_property_read_u32(node, "width-mm", &ddata->width_mm);
-
-	ddata->height_mm = 0;
-	of_property_read_u32(node, "height-mm", &ddata->height_mm);
+	mode->hdisplay = mode->hsync_start = mode->hsync_end = mode->htotal =
+		ddata->panel_data->xres;
+	mode->vdisplay = mode->vsync_start = mode->vsync_end = mode->vtotal =
+		ddata->panel_data->yres;
+	mode->clock = ddata->panel_data->xres * ddata->panel_data->yres *
+		ddata->panel_data->refresh / 1000;
+	mode->width_mm = ddata->panel_data->width_mm;
+	mode->height_mm = ddata->panel_data->height_mm;
+	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+	drm_mode_set_name(mode);
 
 	ddata->supplies[0].supply = "vpnl";
 	ddata->supplies[1].supply = "vddi";
@@ -536,6 +528,7 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	struct panel_drv_data *ddata;
 	struct backlight_device *bldev = NULL;
 	struct device *dev = &dsi->dev;
+	const struct of_device_id *id;
 	int r;
 
 	dev_dbg(dev, "probe\n");
@@ -547,6 +540,12 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	mipi_dsi_set_drvdata(dsi, ddata);
 	ddata->dsi = dsi;
 
+	id = of_match_node(dsicm_of_match, dev->of_node);
+	if (!id)
+		return -ENODEV;
+
+	ddata->panel_data = id->data;
+
 	r = dsicm_probe_of(dsi);
 	if (r)
 		return r;
@@ -583,8 +582,8 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	dsi->format = MIPI_DSI_FMT_RGB888;
 	dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |
 			  MIPI_DSI_MODE_EOT_PACKET;
-	dsi->hs_rate = 300000000;
-	dsi->lp_rate = 10000000;
+	dsi->hs_rate = ddata->panel_data->max_hs_rate;
+	dsi->lp_rate = ddata->panel_data->max_lp_rate;
 
 	drm_panel_add(&ddata->panel);
 
@@ -622,8 +621,40 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
 	return 0;
 }
 
+static const struct dsic_panel_data taal_data = {
+	.xres = 864,
+	.yres = 480,
+	.refresh = 60,
+	.width_mm = 0,
+	.height_mm = 0,
+	.max_hs_rate = 300000000,
+	.max_lp_rate = 10000000,
+};
+
+static const struct dsic_panel_data himalaya_data = {
+	.xres = 480,
+	.yres = 864,
+	.refresh = 60,
+	.width_mm = 49,
+	.height_mm = 88,
+	.max_hs_rate = 300000000,
+	.max_lp_rate = 10000000,
+};
+
+static const struct dsic_panel_data droid4_data = {
+	.xres = 540,
+	.yres = 960,
+	.refresh = 60,
+	.width_mm = 50,
+	.height_mm = 89,
+	.max_hs_rate = 300000000,
+	.max_lp_rate = 10000000,
+};
+
 static const struct of_device_id dsicm_of_match[] = {
-	{ .compatible = "panel-dsi-cm", },
+	{ .compatible = "tpo,taal", .data = &taal_data },
+	{ .compatible = "nokia,himalaya", &himalaya_data },
+	{ .compatible = "motorola,droid4-panel", &droid4_data },
 	{},
 };
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (68 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-11-24 17:36   ` Sam Ravnborg
  2020-12-01  0:27   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 71/80] drm/omap: dsi: move structs & defines to dsi.h Tomi Valkeinen
                   ` (10 subsequent siblings)
  80 siblings, 2 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Drop unneeded includes.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index ec87b785871f..91ed8237a1c2 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -9,12 +9,7 @@
 #include <linux/backlight.h>
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
-#include <linux/interrupt.h>
 #include <linux/jiffies.h>
-#include <linux/module.h>
-#include <linux/sched/signal.h>
-#include <linux/slab.h>
-#include <linux/of_device.h>
 #include <linux/regulator/consumer.h>
 
 #include <drm/drm_connector.h>
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 71/80] drm/omap: dsi: move structs & defines to dsi.h
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (69 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:31   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 72/80] drm/omap: dsi: move enable/disable to bridge enable/disable Tomi Valkeinen
                   ` (9 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Move structs and defines to a private dsi.h header file to make dsi.c a
bit easier to navigate. Also move the (now) private structs and defines
from omapdss.h to dsi.h.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 384 +---------------------
 drivers/gpu/drm/omapdrm/dss/dsi.h     | 456 ++++++++++++++++++++++++++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  64 ----
 3 files changed, 457 insertions(+), 447 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/dss/dsi.h

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 019814a0a264..a01e09c9b477 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -45,73 +45,7 @@
 
 #define DSI_CATCH_MISSING_TE
 
-struct dsi_reg { u16 module; u16 idx; };
-
-#define DSI_REG(mod, idx)		((const struct dsi_reg) { mod, idx })
-
-/* DSI Protocol Engine */
-
-#define DSI_PROTO			0
-#define DSI_PROTO_SZ			0x200
-
-#define DSI_REVISION			DSI_REG(DSI_PROTO, 0x0000)
-#define DSI_SYSCONFIG			DSI_REG(DSI_PROTO, 0x0010)
-#define DSI_SYSSTATUS			DSI_REG(DSI_PROTO, 0x0014)
-#define DSI_IRQSTATUS			DSI_REG(DSI_PROTO, 0x0018)
-#define DSI_IRQENABLE			DSI_REG(DSI_PROTO, 0x001C)
-#define DSI_CTRL			DSI_REG(DSI_PROTO, 0x0040)
-#define DSI_GNQ				DSI_REG(DSI_PROTO, 0x0044)
-#define DSI_COMPLEXIO_CFG1		DSI_REG(DSI_PROTO, 0x0048)
-#define DSI_COMPLEXIO_IRQ_STATUS	DSI_REG(DSI_PROTO, 0x004C)
-#define DSI_COMPLEXIO_IRQ_ENABLE	DSI_REG(DSI_PROTO, 0x0050)
-#define DSI_CLK_CTRL			DSI_REG(DSI_PROTO, 0x0054)
-#define DSI_TIMING1			DSI_REG(DSI_PROTO, 0x0058)
-#define DSI_TIMING2			DSI_REG(DSI_PROTO, 0x005C)
-#define DSI_VM_TIMING1			DSI_REG(DSI_PROTO, 0x0060)
-#define DSI_VM_TIMING2			DSI_REG(DSI_PROTO, 0x0064)
-#define DSI_VM_TIMING3			DSI_REG(DSI_PROTO, 0x0068)
-#define DSI_CLK_TIMING			DSI_REG(DSI_PROTO, 0x006C)
-#define DSI_TX_FIFO_VC_SIZE		DSI_REG(DSI_PROTO, 0x0070)
-#define DSI_RX_FIFO_VC_SIZE		DSI_REG(DSI_PROTO, 0x0074)
-#define DSI_COMPLEXIO_CFG2		DSI_REG(DSI_PROTO, 0x0078)
-#define DSI_RX_FIFO_VC_FULLNESS		DSI_REG(DSI_PROTO, 0x007C)
-#define DSI_VM_TIMING4			DSI_REG(DSI_PROTO, 0x0080)
-#define DSI_TX_FIFO_VC_EMPTINESS	DSI_REG(DSI_PROTO, 0x0084)
-#define DSI_VM_TIMING5			DSI_REG(DSI_PROTO, 0x0088)
-#define DSI_VM_TIMING6			DSI_REG(DSI_PROTO, 0x008C)
-#define DSI_VM_TIMING7			DSI_REG(DSI_PROTO, 0x0090)
-#define DSI_STOPCLK_TIMING		DSI_REG(DSI_PROTO, 0x0094)
-#define DSI_VC_CTRL(n)			DSI_REG(DSI_PROTO, 0x0100 + (n * 0x20))
-#define DSI_VC_TE(n)			DSI_REG(DSI_PROTO, 0x0104 + (n * 0x20))
-#define DSI_VC_LONG_PACKET_HEADER(n)	DSI_REG(DSI_PROTO, 0x0108 + (n * 0x20))
-#define DSI_VC_LONG_PACKET_PAYLOAD(n)	DSI_REG(DSI_PROTO, 0x010C + (n * 0x20))
-#define DSI_VC_SHORT_PACKET_HEADER(n)	DSI_REG(DSI_PROTO, 0x0110 + (n * 0x20))
-#define DSI_VC_IRQSTATUS(n)		DSI_REG(DSI_PROTO, 0x0118 + (n * 0x20))
-#define DSI_VC_IRQENABLE(n)		DSI_REG(DSI_PROTO, 0x011C + (n * 0x20))
-
-/* DSIPHY_SCP */
-
-#define DSI_PHY				1
-#define DSI_PHY_OFFSET			0x200
-#define DSI_PHY_SZ			0x40
-
-#define DSI_DSIPHY_CFG0			DSI_REG(DSI_PHY, 0x0000)
-#define DSI_DSIPHY_CFG1			DSI_REG(DSI_PHY, 0x0004)
-#define DSI_DSIPHY_CFG2			DSI_REG(DSI_PHY, 0x0008)
-#define DSI_DSIPHY_CFG5			DSI_REG(DSI_PHY, 0x0014)
-#define DSI_DSIPHY_CFG10		DSI_REG(DSI_PHY, 0x0028)
-
-/* DSI_PLL_CTRL_SCP */
-
-#define DSI_PLL				2
-#define DSI_PLL_OFFSET			0x300
-#define DSI_PLL_SZ			0x20
-
-#define DSI_PLL_CONTROL			DSI_REG(DSI_PLL, 0x0000)
-#define DSI_PLL_STATUS			DSI_REG(DSI_PLL, 0x0004)
-#define DSI_PLL_GO			DSI_REG(DSI_PLL, 0x0008)
-#define DSI_PLL_CONFIGURATION1		DSI_REG(DSI_PLL, 0x000C)
-#define DSI_PLL_CONFIGURATION2		DSI_REG(DSI_PLL, 0x0010)
+#include "dsi.h"
 
 #define REG_GET(dsi, idx, start, end) \
 	FLD_GET(dsi_read_reg(dsi, idx), start, end)
@@ -119,96 +53,6 @@ struct dsi_reg { u16 module; u16 idx; };
 #define REG_FLD_MOD(dsi, idx, val, start, end) \
 	dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, end))
 
-/* Global interrupts */
-#define DSI_IRQ_VC0		(1 << 0)
-#define DSI_IRQ_VC1		(1 << 1)
-#define DSI_IRQ_VC2		(1 << 2)
-#define DSI_IRQ_VC3		(1 << 3)
-#define DSI_IRQ_WAKEUP		(1 << 4)
-#define DSI_IRQ_RESYNC		(1 << 5)
-#define DSI_IRQ_PLL_LOCK	(1 << 7)
-#define DSI_IRQ_PLL_UNLOCK	(1 << 8)
-#define DSI_IRQ_PLL_RECALL	(1 << 9)
-#define DSI_IRQ_COMPLEXIO_ERR	(1 << 10)
-#define DSI_IRQ_HS_TX_TIMEOUT	(1 << 14)
-#define DSI_IRQ_LP_RX_TIMEOUT	(1 << 15)
-#define DSI_IRQ_TE_TRIGGER	(1 << 16)
-#define DSI_IRQ_ACK_TRIGGER	(1 << 17)
-#define DSI_IRQ_SYNC_LOST	(1 << 18)
-#define DSI_IRQ_LDO_POWER_GOOD	(1 << 19)
-#define DSI_IRQ_TA_TIMEOUT	(1 << 20)
-#define DSI_IRQ_ERROR_MASK \
-	(DSI_IRQ_HS_TX_TIMEOUT | DSI_IRQ_LP_RX_TIMEOUT | DSI_IRQ_SYNC_LOST | \
-	DSI_IRQ_TA_TIMEOUT)
-#define DSI_IRQ_CHANNEL_MASK	0xf
-
-/* Virtual channel interrupts */
-#define DSI_VC_IRQ_CS		(1 << 0)
-#define DSI_VC_IRQ_ECC_CORR	(1 << 1)
-#define DSI_VC_IRQ_PACKET_SENT	(1 << 2)
-#define DSI_VC_IRQ_FIFO_TX_OVF	(1 << 3)
-#define DSI_VC_IRQ_FIFO_RX_OVF	(1 << 4)
-#define DSI_VC_IRQ_BTA		(1 << 5)
-#define DSI_VC_IRQ_ECC_NO_CORR	(1 << 6)
-#define DSI_VC_IRQ_FIFO_TX_UDF	(1 << 7)
-#define DSI_VC_IRQ_PP_BUSY_CHANGE (1 << 8)
-#define DSI_VC_IRQ_ERROR_MASK \
-	(DSI_VC_IRQ_CS | DSI_VC_IRQ_ECC_CORR | DSI_VC_IRQ_FIFO_TX_OVF | \
-	DSI_VC_IRQ_FIFO_RX_OVF | DSI_VC_IRQ_ECC_NO_CORR | \
-	DSI_VC_IRQ_FIFO_TX_UDF)
-
-/* ComplexIO interrupts */
-#define DSI_CIO_IRQ_ERRSYNCESC1		(1 << 0)
-#define DSI_CIO_IRQ_ERRSYNCESC2		(1 << 1)
-#define DSI_CIO_IRQ_ERRSYNCESC3		(1 << 2)
-#define DSI_CIO_IRQ_ERRSYNCESC4		(1 << 3)
-#define DSI_CIO_IRQ_ERRSYNCESC5		(1 << 4)
-#define DSI_CIO_IRQ_ERRESC1		(1 << 5)
-#define DSI_CIO_IRQ_ERRESC2		(1 << 6)
-#define DSI_CIO_IRQ_ERRESC3		(1 << 7)
-#define DSI_CIO_IRQ_ERRESC4		(1 << 8)
-#define DSI_CIO_IRQ_ERRESC5		(1 << 9)
-#define DSI_CIO_IRQ_ERRCONTROL1		(1 << 10)
-#define DSI_CIO_IRQ_ERRCONTROL2		(1 << 11)
-#define DSI_CIO_IRQ_ERRCONTROL3		(1 << 12)
-#define DSI_CIO_IRQ_ERRCONTROL4		(1 << 13)
-#define DSI_CIO_IRQ_ERRCONTROL5		(1 << 14)
-#define DSI_CIO_IRQ_STATEULPS1		(1 << 15)
-#define DSI_CIO_IRQ_STATEULPS2		(1 << 16)
-#define DSI_CIO_IRQ_STATEULPS3		(1 << 17)
-#define DSI_CIO_IRQ_STATEULPS4		(1 << 18)
-#define DSI_CIO_IRQ_STATEULPS5		(1 << 19)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP0_1	(1 << 20)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP1_1	(1 << 21)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP0_2	(1 << 22)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP1_2	(1 << 23)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP0_3	(1 << 24)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP1_3	(1 << 25)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP0_4	(1 << 26)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP1_4	(1 << 27)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP0_5	(1 << 28)
-#define DSI_CIO_IRQ_ERRCONTENTIONLP1_5	(1 << 29)
-#define DSI_CIO_IRQ_ULPSACTIVENOT_ALL0	(1 << 30)
-#define DSI_CIO_IRQ_ULPSACTIVENOT_ALL1	(1 << 31)
-#define DSI_CIO_IRQ_ERROR_MASK \
-	(DSI_CIO_IRQ_ERRSYNCESC1 | DSI_CIO_IRQ_ERRSYNCESC2 | \
-	 DSI_CIO_IRQ_ERRSYNCESC3 | DSI_CIO_IRQ_ERRSYNCESC4 | \
-	 DSI_CIO_IRQ_ERRSYNCESC5 | \
-	 DSI_CIO_IRQ_ERRESC1 | DSI_CIO_IRQ_ERRESC2 | \
-	 DSI_CIO_IRQ_ERRESC3 | DSI_CIO_IRQ_ERRESC4 | \
-	 DSI_CIO_IRQ_ERRESC5 | \
-	 DSI_CIO_IRQ_ERRCONTROL1 | DSI_CIO_IRQ_ERRCONTROL2 | \
-	 DSI_CIO_IRQ_ERRCONTROL3 | DSI_CIO_IRQ_ERRCONTROL4 | \
-	 DSI_CIO_IRQ_ERRCONTROL5 | \
-	 DSI_CIO_IRQ_ERRCONTENTIONLP0_1 | DSI_CIO_IRQ_ERRCONTENTIONLP1_1 | \
-	 DSI_CIO_IRQ_ERRCONTENTIONLP0_2 | DSI_CIO_IRQ_ERRCONTENTIONLP1_2 | \
-	 DSI_CIO_IRQ_ERRCONTENTIONLP0_3 | DSI_CIO_IRQ_ERRCONTENTIONLP1_3 | \
-	 DSI_CIO_IRQ_ERRCONTENTIONLP0_4 | DSI_CIO_IRQ_ERRCONTENTIONLP1_4 | \
-	 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
-
-typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
-struct dsi_data;
-
 static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
 
 static int dsi_display_init_dispc(struct dsi_data *dsi);
@@ -221,232 +65,6 @@ static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
 
 static void dsi_display_disable(struct omap_dss_device *dssdev);
 
-/* DSI PLL HSDIV indices */
-#define HSDIV_DISPC	0
-#define HSDIV_DSI	1
-
-#define DSI_MAX_NR_ISRS                2
-#define DSI_MAX_NR_LANES	5
-
-enum dsi_model {
-	DSI_MODEL_OMAP3,
-	DSI_MODEL_OMAP4,
-	DSI_MODEL_OMAP5,
-};
-
-enum dsi_lane_function {
-	DSI_LANE_UNUSED	= 0,
-	DSI_LANE_CLK,
-	DSI_LANE_DATA1,
-	DSI_LANE_DATA2,
-	DSI_LANE_DATA3,
-	DSI_LANE_DATA4,
-};
-
-struct dsi_lane_config {
-	enum dsi_lane_function function;
-	u8 polarity;
-};
-
-struct dsi_isr_data {
-	omap_dsi_isr_t	isr;
-	void		*arg;
-	u32		mask;
-};
-
-enum fifo_size {
-	DSI_FIFO_SIZE_0		= 0,
-	DSI_FIFO_SIZE_32	= 1,
-	DSI_FIFO_SIZE_64	= 2,
-	DSI_FIFO_SIZE_96	= 3,
-	DSI_FIFO_SIZE_128	= 4,
-};
-
-enum dsi_vc_source {
-	DSI_VC_SOURCE_L4 = 0,
-	DSI_VC_SOURCE_VP,
-};
-
-struct dsi_irq_stats {
-	unsigned long last_reset;
-	unsigned int irq_count;
-	unsigned int dsi_irqs[32];
-	unsigned int vc_irqs[4][32];
-	unsigned int cio_irqs[32];
-};
-
-struct dsi_isr_tables {
-	struct dsi_isr_data isr_table[DSI_MAX_NR_ISRS];
-	struct dsi_isr_data isr_table_vc[4][DSI_MAX_NR_ISRS];
-	struct dsi_isr_data isr_table_cio[DSI_MAX_NR_ISRS];
-};
-
-struct dsi_lp_clock_info {
-	unsigned long lp_clk;
-	u16 lp_clk_div;
-};
-
-struct dsi_clk_calc_ctx {
-	struct dsi_data *dsi;
-	struct dss_pll *pll;
-
-	/* inputs */
-
-	const struct omap_dss_dsi_config *config;
-
-	unsigned long req_pck_min, req_pck_nom, req_pck_max;
-
-	/* outputs */
-
-	struct dss_pll_clock_info dsi_cinfo;
-	struct dispc_clock_info dispc_cinfo;
-	struct dsi_lp_clock_info lp_cinfo;
-
-	struct videomode vm;
-	struct omap_dss_dsi_videomode_timings dsi_vm;
-};
-
-struct dsi_module_id_data {
-	u32 address;
-	int id;
-};
-
-enum dsi_quirks {
-	DSI_QUIRK_PLL_PWR_BUG = (1 << 0),	/* DSI-PLL power command 0x3 is not working */
-	DSI_QUIRK_DCS_CMD_CONFIG_VC = (1 << 1),
-	DSI_QUIRK_VC_OCP_WIDTH = (1 << 2),
-	DSI_QUIRK_REVERSE_TXCLKESC = (1 << 3),
-	DSI_QUIRK_GNQ = (1 << 4),
-	DSI_QUIRK_PHY_DCC = (1 << 5),
-};
-
-struct dsi_of_data {
-	enum dsi_model model;
-	const struct dss_pll_hw *pll_hw;
-	const struct dsi_module_id_data *modules;
-	unsigned int max_fck_freq;
-	unsigned int max_pll_lpdiv;
-	enum dsi_quirks quirks;
-};
-
-struct dsi_data {
-	struct device *dev;
-	void __iomem *proto_base;
-	void __iomem *phy_base;
-	void __iomem *pll_base;
-
-	const struct dsi_of_data *data;
-	int module_id;
-
-	int irq;
-
-	bool is_enabled;
-
-	struct clk *dss_clk;
-	struct regmap *syscon;
-	struct dss_device *dss;
-
-	struct mipi_dsi_host host;
-
-	struct dispc_clock_info user_dispc_cinfo;
-	struct dss_pll_clock_info user_dsi_cinfo;
-
-	struct dsi_lp_clock_info user_lp_cinfo;
-	struct dsi_lp_clock_info current_lp_cinfo;
-
-	struct dss_pll pll;
-
-	bool vdds_dsi_enabled;
-	struct regulator *vdds_dsi_reg;
-
-	struct mipi_dsi_device *dsidev;
-
-	struct {
-		enum dsi_vc_source source;
-		enum fifo_size tx_fifo_size;
-		enum fifo_size rx_fifo_size;
-	} vc[4];
-
-	struct mutex lock;
-	struct semaphore bus_lock;
-
-	spinlock_t irq_lock;
-	struct dsi_isr_tables isr_tables;
-	/* space for a copy used by the interrupt handler */
-	struct dsi_isr_tables isr_tables_copy;
-
-	int update_vc;
-#ifdef DSI_PERF_MEASURE
-	unsigned int update_bytes;
-#endif
-
-	/* external TE GPIO */
-	struct gpio_desc *te_gpio;
-	int te_irq;
-	struct delayed_work te_timeout_work;
-	atomic_t do_ext_te_update;
-
-	bool te_enabled;
-	bool ulps_enabled;
-	bool ulps_auto_idle;
-	bool video_enabled;
-
-	struct delayed_work ulps_work;
-
-	struct delayed_work framedone_timeout_work;
-
-#ifdef DSI_CATCH_MISSING_TE
-	struct timer_list te_timer;
-#endif
-
-	unsigned long cache_req_pck;
-	unsigned long cache_clk_freq;
-	struct dss_pll_clock_info cache_cinfo;
-
-	u32		errors;
-	spinlock_t	errors_lock;
-#ifdef DSI_PERF_MEASURE
-	ktime_t perf_setup_time;
-	ktime_t perf_start_time;
-#endif
-	int debug_read;
-	int debug_write;
-	struct {
-		struct dss_debugfs_entry *irqs;
-		struct dss_debugfs_entry *regs;
-		struct dss_debugfs_entry *clks;
-	} debugfs;
-
-#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-	spinlock_t irq_stats_lock;
-	struct dsi_irq_stats irq_stats;
-#endif
-
-	unsigned int num_lanes_supported;
-	unsigned int line_buffer_size;
-
-	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
-	unsigned int num_lanes_used;
-
-	unsigned int scp_clk_refcount;
-
-	struct omap_dss_dsi_config config;
-
-	struct dss_lcd_mgr_config mgr_config;
-	struct videomode vm;
-	enum mipi_dsi_pixel_format pix_fmt;
-	enum omap_dss_dsi_mode mode;
-	struct omap_dss_dsi_videomode_timings vm_timings;
-
-	struct omap_dss_device output;
-	struct drm_bridge bridge;
-};
-
-struct dsi_packet_sent_handler_data {
-	struct dsi_data *dsi;
-	struct completion *completion;
-};
-
 #ifdef DSI_PERF_MEASURE
 static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h b/drivers/gpu/drm/omapdrm/dss/dsi.h
new file mode 100644
index 000000000000..7cc2cc748ed9
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
@@ -0,0 +1,456 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
+ */
+
+#ifndef __OMAP_DRM_DSS_DSI_H
+#define __OMAP_DRM_DSS_DSI_H
+
+#include <drm/drm_mipi_dsi.h>
+
+struct dsi_reg { u16 module; u16 idx; };
+
+#define DSI_REG(mod, idx)		((const struct dsi_reg) { mod, idx })
+
+/* DSI Protocol Engine */
+
+#define DSI_PROTO			0
+#define DSI_PROTO_SZ			0x200
+
+#define DSI_REVISION			DSI_REG(DSI_PROTO, 0x0000)
+#define DSI_SYSCONFIG			DSI_REG(DSI_PROTO, 0x0010)
+#define DSI_SYSSTATUS			DSI_REG(DSI_PROTO, 0x0014)
+#define DSI_IRQSTATUS			DSI_REG(DSI_PROTO, 0x0018)
+#define DSI_IRQENABLE			DSI_REG(DSI_PROTO, 0x001C)
+#define DSI_CTRL			DSI_REG(DSI_PROTO, 0x0040)
+#define DSI_GNQ				DSI_REG(DSI_PROTO, 0x0044)
+#define DSI_COMPLEXIO_CFG1		DSI_REG(DSI_PROTO, 0x0048)
+#define DSI_COMPLEXIO_IRQ_STATUS	DSI_REG(DSI_PROTO, 0x004C)
+#define DSI_COMPLEXIO_IRQ_ENABLE	DSI_REG(DSI_PROTO, 0x0050)
+#define DSI_CLK_CTRL			DSI_REG(DSI_PROTO, 0x0054)
+#define DSI_TIMING1			DSI_REG(DSI_PROTO, 0x0058)
+#define DSI_TIMING2			DSI_REG(DSI_PROTO, 0x005C)
+#define DSI_VM_TIMING1			DSI_REG(DSI_PROTO, 0x0060)
+#define DSI_VM_TIMING2			DSI_REG(DSI_PROTO, 0x0064)
+#define DSI_VM_TIMING3			DSI_REG(DSI_PROTO, 0x0068)
+#define DSI_CLK_TIMING			DSI_REG(DSI_PROTO, 0x006C)
+#define DSI_TX_FIFO_VC_SIZE		DSI_REG(DSI_PROTO, 0x0070)
+#define DSI_RX_FIFO_VC_SIZE		DSI_REG(DSI_PROTO, 0x0074)
+#define DSI_COMPLEXIO_CFG2		DSI_REG(DSI_PROTO, 0x0078)
+#define DSI_RX_FIFO_VC_FULLNESS		DSI_REG(DSI_PROTO, 0x007C)
+#define DSI_VM_TIMING4			DSI_REG(DSI_PROTO, 0x0080)
+#define DSI_TX_FIFO_VC_EMPTINESS	DSI_REG(DSI_PROTO, 0x0084)
+#define DSI_VM_TIMING5			DSI_REG(DSI_PROTO, 0x0088)
+#define DSI_VM_TIMING6			DSI_REG(DSI_PROTO, 0x008C)
+#define DSI_VM_TIMING7			DSI_REG(DSI_PROTO, 0x0090)
+#define DSI_STOPCLK_TIMING		DSI_REG(DSI_PROTO, 0x0094)
+#define DSI_VC_CTRL(n)			DSI_REG(DSI_PROTO, 0x0100 + (n * 0x20))
+#define DSI_VC_TE(n)			DSI_REG(DSI_PROTO, 0x0104 + (n * 0x20))
+#define DSI_VC_LONG_PACKET_HEADER(n)	DSI_REG(DSI_PROTO, 0x0108 + (n * 0x20))
+#define DSI_VC_LONG_PACKET_PAYLOAD(n)	DSI_REG(DSI_PROTO, 0x010C + (n * 0x20))
+#define DSI_VC_SHORT_PACKET_HEADER(n)	DSI_REG(DSI_PROTO, 0x0110 + (n * 0x20))
+#define DSI_VC_IRQSTATUS(n)		DSI_REG(DSI_PROTO, 0x0118 + (n * 0x20))
+#define DSI_VC_IRQENABLE(n)		DSI_REG(DSI_PROTO, 0x011C + (n * 0x20))
+
+/* DSIPHY_SCP */
+
+#define DSI_PHY				1
+#define DSI_PHY_OFFSET			0x200
+#define DSI_PHY_SZ			0x40
+
+#define DSI_DSIPHY_CFG0			DSI_REG(DSI_PHY, 0x0000)
+#define DSI_DSIPHY_CFG1			DSI_REG(DSI_PHY, 0x0004)
+#define DSI_DSIPHY_CFG2			DSI_REG(DSI_PHY, 0x0008)
+#define DSI_DSIPHY_CFG5			DSI_REG(DSI_PHY, 0x0014)
+#define DSI_DSIPHY_CFG10		DSI_REG(DSI_PHY, 0x0028)
+
+/* DSI_PLL_CTRL_SCP */
+
+#define DSI_PLL				2
+#define DSI_PLL_OFFSET			0x300
+#define DSI_PLL_SZ			0x20
+
+#define DSI_PLL_CONTROL			DSI_REG(DSI_PLL, 0x0000)
+#define DSI_PLL_STATUS			DSI_REG(DSI_PLL, 0x0004)
+#define DSI_PLL_GO			DSI_REG(DSI_PLL, 0x0008)
+#define DSI_PLL_CONFIGURATION1		DSI_REG(DSI_PLL, 0x000C)
+#define DSI_PLL_CONFIGURATION2		DSI_REG(DSI_PLL, 0x0010)
+
+/* Global interrupts */
+#define DSI_IRQ_VC0		(1 << 0)
+#define DSI_IRQ_VC1		(1 << 1)
+#define DSI_IRQ_VC2		(1 << 2)
+#define DSI_IRQ_VC3		(1 << 3)
+#define DSI_IRQ_WAKEUP		(1 << 4)
+#define DSI_IRQ_RESYNC		(1 << 5)
+#define DSI_IRQ_PLL_LOCK	(1 << 7)
+#define DSI_IRQ_PLL_UNLOCK	(1 << 8)
+#define DSI_IRQ_PLL_RECALL	(1 << 9)
+#define DSI_IRQ_COMPLEXIO_ERR	(1 << 10)
+#define DSI_IRQ_HS_TX_TIMEOUT	(1 << 14)
+#define DSI_IRQ_LP_RX_TIMEOUT	(1 << 15)
+#define DSI_IRQ_TE_TRIGGER	(1 << 16)
+#define DSI_IRQ_ACK_TRIGGER	(1 << 17)
+#define DSI_IRQ_SYNC_LOST	(1 << 18)
+#define DSI_IRQ_LDO_POWER_GOOD	(1 << 19)
+#define DSI_IRQ_TA_TIMEOUT	(1 << 20)
+#define DSI_IRQ_ERROR_MASK \
+	(DSI_IRQ_HS_TX_TIMEOUT | DSI_IRQ_LP_RX_TIMEOUT | DSI_IRQ_SYNC_LOST | \
+	DSI_IRQ_TA_TIMEOUT)
+#define DSI_IRQ_CHANNEL_MASK	0xf
+
+/* Virtual channel interrupts */
+#define DSI_VC_IRQ_CS		(1 << 0)
+#define DSI_VC_IRQ_ECC_CORR	(1 << 1)
+#define DSI_VC_IRQ_PACKET_SENT	(1 << 2)
+#define DSI_VC_IRQ_FIFO_TX_OVF	(1 << 3)
+#define DSI_VC_IRQ_FIFO_RX_OVF	(1 << 4)
+#define DSI_VC_IRQ_BTA		(1 << 5)
+#define DSI_VC_IRQ_ECC_NO_CORR	(1 << 6)
+#define DSI_VC_IRQ_FIFO_TX_UDF	(1 << 7)
+#define DSI_VC_IRQ_PP_BUSY_CHANGE (1 << 8)
+#define DSI_VC_IRQ_ERROR_MASK \
+	(DSI_VC_IRQ_CS | DSI_VC_IRQ_ECC_CORR | DSI_VC_IRQ_FIFO_TX_OVF | \
+	DSI_VC_IRQ_FIFO_RX_OVF | DSI_VC_IRQ_ECC_NO_CORR | \
+	DSI_VC_IRQ_FIFO_TX_UDF)
+
+/* ComplexIO interrupts */
+#define DSI_CIO_IRQ_ERRSYNCESC1		(1 << 0)
+#define DSI_CIO_IRQ_ERRSYNCESC2		(1 << 1)
+#define DSI_CIO_IRQ_ERRSYNCESC3		(1 << 2)
+#define DSI_CIO_IRQ_ERRSYNCESC4		(1 << 3)
+#define DSI_CIO_IRQ_ERRSYNCESC5		(1 << 4)
+#define DSI_CIO_IRQ_ERRESC1		(1 << 5)
+#define DSI_CIO_IRQ_ERRESC2		(1 << 6)
+#define DSI_CIO_IRQ_ERRESC3		(1 << 7)
+#define DSI_CIO_IRQ_ERRESC4		(1 << 8)
+#define DSI_CIO_IRQ_ERRESC5		(1 << 9)
+#define DSI_CIO_IRQ_ERRCONTROL1		(1 << 10)
+#define DSI_CIO_IRQ_ERRCONTROL2		(1 << 11)
+#define DSI_CIO_IRQ_ERRCONTROL3		(1 << 12)
+#define DSI_CIO_IRQ_ERRCONTROL4		(1 << 13)
+#define DSI_CIO_IRQ_ERRCONTROL5		(1 << 14)
+#define DSI_CIO_IRQ_STATEULPS1		(1 << 15)
+#define DSI_CIO_IRQ_STATEULPS2		(1 << 16)
+#define DSI_CIO_IRQ_STATEULPS3		(1 << 17)
+#define DSI_CIO_IRQ_STATEULPS4		(1 << 18)
+#define DSI_CIO_IRQ_STATEULPS5		(1 << 19)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP0_1	(1 << 20)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP1_1	(1 << 21)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP0_2	(1 << 22)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP1_2	(1 << 23)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP0_3	(1 << 24)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP1_3	(1 << 25)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP0_4	(1 << 26)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP1_4	(1 << 27)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP0_5	(1 << 28)
+#define DSI_CIO_IRQ_ERRCONTENTIONLP1_5	(1 << 29)
+#define DSI_CIO_IRQ_ULPSACTIVENOT_ALL0	(1 << 30)
+#define DSI_CIO_IRQ_ULPSACTIVENOT_ALL1	(1 << 31)
+#define DSI_CIO_IRQ_ERROR_MASK \
+	(DSI_CIO_IRQ_ERRSYNCESC1 | DSI_CIO_IRQ_ERRSYNCESC2 | \
+	 DSI_CIO_IRQ_ERRSYNCESC3 | DSI_CIO_IRQ_ERRSYNCESC4 | \
+	 DSI_CIO_IRQ_ERRSYNCESC5 | \
+	 DSI_CIO_IRQ_ERRESC1 | DSI_CIO_IRQ_ERRESC2 | \
+	 DSI_CIO_IRQ_ERRESC3 | DSI_CIO_IRQ_ERRESC4 | \
+	 DSI_CIO_IRQ_ERRESC5 | \
+	 DSI_CIO_IRQ_ERRCONTROL1 | DSI_CIO_IRQ_ERRCONTROL2 | \
+	 DSI_CIO_IRQ_ERRCONTROL3 | DSI_CIO_IRQ_ERRCONTROL4 | \
+	 DSI_CIO_IRQ_ERRCONTROL5 | \
+	 DSI_CIO_IRQ_ERRCONTENTIONLP0_1 | DSI_CIO_IRQ_ERRCONTENTIONLP1_1 | \
+	 DSI_CIO_IRQ_ERRCONTENTIONLP0_2 | DSI_CIO_IRQ_ERRCONTENTIONLP1_2 | \
+	 DSI_CIO_IRQ_ERRCONTENTIONLP0_3 | DSI_CIO_IRQ_ERRCONTENTIONLP1_3 | \
+	 DSI_CIO_IRQ_ERRCONTENTIONLP0_4 | DSI_CIO_IRQ_ERRCONTENTIONLP1_4 | \
+	 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
+
+enum omap_dss_dsi_mode {
+	OMAP_DSS_DSI_CMD_MODE = 0,
+	OMAP_DSS_DSI_VIDEO_MODE,
+};
+
+enum omap_dss_dsi_trans_mode {
+	/* Sync Pulses: both sync start and end packets sent */
+	OMAP_DSS_DSI_PULSE_MODE,
+	/* Sync Events: only sync start packets sent */
+	OMAP_DSS_DSI_EVENT_MODE,
+	/* Burst: only sync start packets sent, pixels are time compressed */
+	OMAP_DSS_DSI_BURST_MODE,
+};
+
+struct omap_dss_dsi_videomode_timings {
+	unsigned long hsclk;
+
+	unsigned int ndl;
+	unsigned int bitspp;
+
+	/* pixels */
+	u16 hact;
+	/* lines */
+	u16 vact;
+
+	/* DSI video mode blanking data */
+	/* Unit: byte clock cycles */
+	u16 hss;
+	u16 hsa;
+	u16 hse;
+	u16 hfp;
+	u16 hbp;
+	/* Unit: line clocks */
+	u16 vsa;
+	u16 vfp;
+	u16 vbp;
+
+	/* DSI blanking modes */
+	int blanking_mode;
+	int hsa_blanking_mode;
+	int hbp_blanking_mode;
+	int hfp_blanking_mode;
+
+	enum omap_dss_dsi_trans_mode trans_mode;
+
+	bool ddr_clk_always_on;
+	int window_sync;
+};
+
+struct omap_dss_dsi_config {
+	enum omap_dss_dsi_mode mode;
+	enum mipi_dsi_pixel_format pixel_format;
+	const struct videomode *vm;
+
+	unsigned long hs_clk_min, hs_clk_max;
+	unsigned long lp_clk_min, lp_clk_max;
+
+	bool ddr_clk_always_on;
+	enum omap_dss_dsi_trans_mode trans_mode;
+};
+
+/* DSI PLL HSDIV indices */
+#define HSDIV_DISPC	0
+#define HSDIV_DSI	1
+
+#define DSI_MAX_NR_ISRS                2
+#define DSI_MAX_NR_LANES	5
+
+enum dsi_model {
+	DSI_MODEL_OMAP3,
+	DSI_MODEL_OMAP4,
+	DSI_MODEL_OMAP5,
+};
+
+enum dsi_lane_function {
+	DSI_LANE_UNUSED	= 0,
+	DSI_LANE_CLK,
+	DSI_LANE_DATA1,
+	DSI_LANE_DATA2,
+	DSI_LANE_DATA3,
+	DSI_LANE_DATA4,
+};
+
+struct dsi_lane_config {
+	enum dsi_lane_function function;
+	u8 polarity;
+};
+
+typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
+
+struct dsi_isr_data {
+	omap_dsi_isr_t	isr;
+	void		*arg;
+	u32		mask;
+};
+
+enum fifo_size {
+	DSI_FIFO_SIZE_0		= 0,
+	DSI_FIFO_SIZE_32	= 1,
+	DSI_FIFO_SIZE_64	= 2,
+	DSI_FIFO_SIZE_96	= 3,
+	DSI_FIFO_SIZE_128	= 4,
+};
+
+enum dsi_vc_source {
+	DSI_VC_SOURCE_L4 = 0,
+	DSI_VC_SOURCE_VP,
+};
+
+struct dsi_irq_stats {
+	unsigned long last_reset;
+	unsigned int irq_count;
+	unsigned int dsi_irqs[32];
+	unsigned int vc_irqs[4][32];
+	unsigned int cio_irqs[32];
+};
+
+struct dsi_isr_tables {
+	struct dsi_isr_data isr_table[DSI_MAX_NR_ISRS];
+	struct dsi_isr_data isr_table_vc[4][DSI_MAX_NR_ISRS];
+	struct dsi_isr_data isr_table_cio[DSI_MAX_NR_ISRS];
+};
+
+struct dsi_lp_clock_info {
+	unsigned long lp_clk;
+	u16 lp_clk_div;
+};
+
+struct dsi_clk_calc_ctx {
+	struct dsi_data *dsi;
+	struct dss_pll *pll;
+
+	/* inputs */
+
+	const struct omap_dss_dsi_config *config;
+
+	unsigned long req_pck_min, req_pck_nom, req_pck_max;
+
+	/* outputs */
+
+	struct dss_pll_clock_info dsi_cinfo;
+	struct dispc_clock_info dispc_cinfo;
+	struct dsi_lp_clock_info lp_cinfo;
+
+	struct videomode vm;
+	struct omap_dss_dsi_videomode_timings dsi_vm;
+};
+
+struct dsi_module_id_data {
+	u32 address;
+	int id;
+};
+
+enum dsi_quirks {
+	DSI_QUIRK_PLL_PWR_BUG = (1 << 0),	/* DSI-PLL power command 0x3 is not working */
+	DSI_QUIRK_DCS_CMD_CONFIG_VC = (1 << 1),
+	DSI_QUIRK_VC_OCP_WIDTH = (1 << 2),
+	DSI_QUIRK_REVERSE_TXCLKESC = (1 << 3),
+	DSI_QUIRK_GNQ = (1 << 4),
+	DSI_QUIRK_PHY_DCC = (1 << 5),
+};
+
+struct dsi_of_data {
+	enum dsi_model model;
+	const struct dss_pll_hw *pll_hw;
+	const struct dsi_module_id_data *modules;
+	unsigned int max_fck_freq;
+	unsigned int max_pll_lpdiv;
+	enum dsi_quirks quirks;
+};
+
+struct dsi_data {
+	struct device *dev;
+	void __iomem *proto_base;
+	void __iomem *phy_base;
+	void __iomem *pll_base;
+
+	const struct dsi_of_data *data;
+	int module_id;
+
+	int irq;
+
+	bool is_enabled;
+
+	struct clk *dss_clk;
+	struct regmap *syscon;
+	struct dss_device *dss;
+
+	struct mipi_dsi_host host;
+
+	struct dispc_clock_info user_dispc_cinfo;
+	struct dss_pll_clock_info user_dsi_cinfo;
+
+	struct dsi_lp_clock_info user_lp_cinfo;
+	struct dsi_lp_clock_info current_lp_cinfo;
+
+	struct dss_pll pll;
+
+	bool vdds_dsi_enabled;
+	struct regulator *vdds_dsi_reg;
+
+	struct mipi_dsi_device *dsidev;
+
+	struct {
+		enum dsi_vc_source source;
+		enum fifo_size tx_fifo_size;
+		enum fifo_size rx_fifo_size;
+	} vc[4];
+
+	struct mutex lock;
+	struct semaphore bus_lock;
+
+	spinlock_t irq_lock;
+	struct dsi_isr_tables isr_tables;
+	/* space for a copy used by the interrupt handler */
+	struct dsi_isr_tables isr_tables_copy;
+
+	int update_vc;
+#ifdef DSI_PERF_MEASURE
+	unsigned int update_bytes;
+#endif
+
+	/* external TE GPIO */
+	struct gpio_desc *te_gpio;
+	int te_irq;
+	struct delayed_work te_timeout_work;
+	atomic_t do_ext_te_update;
+
+	bool te_enabled;
+	bool ulps_enabled;
+	bool ulps_auto_idle;
+	bool video_enabled;
+
+	struct delayed_work ulps_work;
+
+	struct delayed_work framedone_timeout_work;
+
+#ifdef DSI_CATCH_MISSING_TE
+	struct timer_list te_timer;
+#endif
+
+	unsigned long cache_req_pck;
+	unsigned long cache_clk_freq;
+	struct dss_pll_clock_info cache_cinfo;
+
+	u32		errors;
+	spinlock_t	errors_lock;
+#ifdef DSI_PERF_MEASURE
+	ktime_t perf_setup_time;
+	ktime_t perf_start_time;
+#endif
+	int debug_read;
+	int debug_write;
+	struct {
+		struct dss_debugfs_entry *irqs;
+		struct dss_debugfs_entry *regs;
+		struct dss_debugfs_entry *clks;
+	} debugfs;
+
+#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
+	spinlock_t irq_stats_lock;
+	struct dsi_irq_stats irq_stats;
+#endif
+
+	unsigned int num_lanes_supported;
+	unsigned int line_buffer_size;
+
+	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
+	unsigned int num_lanes_used;
+
+	unsigned int scp_clk_refcount;
+
+	struct omap_dss_dsi_config config;
+
+	struct dss_lcd_mgr_config mgr_config;
+	struct videomode vm;
+	enum mipi_dsi_pixel_format pix_fmt;
+	enum omap_dss_dsi_mode mode;
+	struct omap_dss_dsi_videomode_timings vm_timings;
+
+	struct omap_dss_device output;
+	struct drm_bridge bridge;
+};
+
+struct dsi_packet_sent_handler_data {
+	struct dsi_data *dsi;
+	struct completion *completion;
+};
+
+#endif /* __OMAP_DRM_DSS_DSI_H */
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9df322ca467d..6ecaa060ff4b 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -14,7 +14,6 @@
 #include <linux/platform_data/omapdss.h>
 
 #include <drm/drm_crtc.h>
-#include <drm/drm_mipi_dsi.h>
 #include <drm/drm_mode.h>
 
 #define DISPC_IRQ_FRAMEDONE		(1 << 0)
@@ -118,11 +117,6 @@ enum omap_dss_venc_type {
 	OMAP_DSS_VENC_TYPE_SVIDEO,
 };
 
-enum omap_dss_dsi_mode {
-	OMAP_DSS_DSI_CMD_MODE = 0,
-	OMAP_DSS_DSI_VIDEO_MODE,
-};
-
 enum omap_dss_rotation_type {
 	OMAP_DSS_ROT_NONE	= 0,
 	OMAP_DSS_ROT_TILER	= 1 << 0,
@@ -147,64 +141,6 @@ enum omap_dss_output_id {
 	OMAP_DSS_OUTPUT_HDMI	= 1 << 6,
 };
 
-/* DSI */
-
-enum omap_dss_dsi_trans_mode {
-	/* Sync Pulses: both sync start and end packets sent */
-	OMAP_DSS_DSI_PULSE_MODE,
-	/* Sync Events: only sync start packets sent */
-	OMAP_DSS_DSI_EVENT_MODE,
-	/* Burst: only sync start packets sent, pixels are time compressed */
-	OMAP_DSS_DSI_BURST_MODE,
-};
-
-struct omap_dss_dsi_videomode_timings {
-	unsigned long hsclk;
-
-	unsigned int ndl;
-	unsigned int bitspp;
-
-	/* pixels */
-	u16 hact;
-	/* lines */
-	u16 vact;
-
-	/* DSI video mode blanking data */
-	/* Unit: byte clock cycles */
-	u16 hss;
-	u16 hsa;
-	u16 hse;
-	u16 hfp;
-	u16 hbp;
-	/* Unit: line clocks */
-	u16 vsa;
-	u16 vfp;
-	u16 vbp;
-
-	/* DSI blanking modes */
-	int blanking_mode;
-	int hsa_blanking_mode;
-	int hbp_blanking_mode;
-	int hfp_blanking_mode;
-
-	enum omap_dss_dsi_trans_mode trans_mode;
-
-	bool ddr_clk_always_on;
-	int window_sync;
-};
-
-struct omap_dss_dsi_config {
-	enum omap_dss_dsi_mode mode;
-	enum mipi_dsi_pixel_format pixel_format;
-	const struct videomode *vm;
-
-	unsigned long hs_clk_min, hs_clk_max;
-	unsigned long lp_clk_min, lp_clk_max;
-
-	bool ddr_clk_always_on;
-	enum omap_dss_dsi_trans_mode trans_mode;
-};
-
 struct omap_dss_cpr_coefs {
 	s16 rr, rg, rb;
 	s16 gr, gg, gb;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 72/80] drm/omap: dsi: move enable/disable to bridge enable/disable
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (70 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 71/80] drm/omap: dsi: move structs & defines to dsi.h Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:32   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 73/80] drm/omap: dsi: display_enable cleanup Tomi Valkeinen
                   ` (8 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Clean up the code by inlining dsi_enable_video_outputs and
dsi_disable_video_outputs functions.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 55 +++++++++++++------------------
 1 file changed, 22 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a01e09c9b477..4f79d6c664ff 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3336,20 +3336,6 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
 	dsi_display_uninit_dispc(dsi);
 }
 
-static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	dsi_bus_lock(dsi);
-	dsi->video_enabled = false;
-
-	dsi_disable_video_output(dssdev, VC_VIDEO);
-
-	dsi_display_disable(dssdev);
-
-	dsi_bus_unlock(dsi);
-}
-
 static void dsi_update_screen_dispc(struct dsi_data *dsi)
 {
 	unsigned int bytespp;
@@ -3791,23 +3777,6 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
 	_dsi_display_enable(dsi);
 }
 
-static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	dsi_bus_lock(dsi);
-
-	dsi_display_enable(dssdev);
-
-	dsi_enable_video_output(dssdev, VC_VIDEO);
-
-	dsi->video_enabled = true;
-
-	dsi_set_ulps_auto(dsi, true);
-
-	dsi_bus_unlock(dsi);
-}
-
 static void _dsi_display_disable(struct dsi_data *dsi,
 		bool disconnect_lanes, bool enter_ulps)
 {
@@ -4969,15 +4938,35 @@ static void dsi_bridge_mode_set(struct drm_bridge *bridge,
 static void dsi_bridge_enable(struct drm_bridge *bridge)
 {
 	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+	struct omap_dss_device *dssdev = &dsi->output;
 
-	dsi_enable_video_outputs(&dsi->output);
+	dsi_bus_lock(dsi);
+
+	dsi_display_enable(dssdev);
+
+	dsi_enable_video_output(dssdev, VC_VIDEO);
+
+	dsi->video_enabled = true;
+
+	dsi_set_ulps_auto(dsi, true);
+
+	dsi_bus_unlock(dsi);
 }
 
 static void dsi_bridge_disable(struct drm_bridge *bridge)
 {
 	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
+	struct omap_dss_device *dssdev = &dsi->output;
+
+	dsi_bus_lock(dsi);
+
+	dsi->video_enabled = false;
+
+	dsi_disable_video_output(dssdev, VC_VIDEO);
 
-	dsi_disable_video_outputs(&dsi->output);
+	dsi_display_disable(dssdev);
+
+	dsi_bus_unlock(dsi);
 }
 
 static const struct drm_bridge_funcs dsi_bridge_funcs = {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 73/80] drm/omap: dsi: display_enable cleanup
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (71 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 72/80] drm/omap: dsi: move enable/disable to bridge enable/disable Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:32   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 74/80] drm/omap: dsi: display_disable cleanup Tomi Valkeinen
                   ` (7 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

We can drop dsi_display_enable(), which just calls
_dsi_display_enable(), and rename _dsi_display_enable() to
dsi_display_enable().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 4f79d6c664ff..e50418db71ef 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3738,7 +3738,7 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
 	}
 }
 
-static void _dsi_display_enable(struct dsi_data *dsi)
+static void dsi_display_enable(struct dsi_data *dsi)
 {
 	int r;
 
@@ -3767,16 +3767,6 @@ static void _dsi_display_enable(struct dsi_data *dsi)
 	DSSDBG("dsi_display_ulps_enable FAILED\n");
 }
 
-static void dsi_display_enable(struct omap_dss_device *dssdev)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-	DSSDBG("dsi_display_enable\n");
-
-	WARN_ON(!dsi_bus_is_locked(dsi));
-
-	_dsi_display_enable(dsi);
-}
-
 static void _dsi_display_disable(struct dsi_data *dsi,
 		bool disconnect_lanes, bool enter_ulps)
 {
@@ -3851,7 +3841,7 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable)
 			return;
 
 		dsi_bus_lock(dsi);
-		_dsi_display_enable(dsi);
+		dsi_display_enable(dsi);
 		dsi_enable_te(dsi, true);
 		dsi_bus_unlock(dsi);
 	}
@@ -4942,7 +4932,7 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
 
 	dsi_bus_lock(dsi);
 
-	dsi_display_enable(dssdev);
+	dsi_display_enable(dsi);
 
 	dsi_enable_video_output(dssdev, VC_VIDEO);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 74/80] drm/omap: dsi: display_disable cleanup
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (72 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 73/80] drm/omap: dsi: display_enable cleanup Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:33   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 75/80] drm/omap: dsi: rename dsi_display_* functions Tomi Valkeinen
                   ` (6 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

We can drop dsi_display_disable() which just calls
_dsi_display_disable(), and rename _dsi_display_disable() to
dsi_display_disable().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index e50418db71ef..d23fc43f1d1e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -63,8 +63,6 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel);
 static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
 				       const struct mipi_dsi_msg *msg);
 
-static void dsi_display_disable(struct omap_dss_device *dssdev);
-
 #ifdef DSI_PERF_MEASURE
 static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
@@ -3767,7 +3765,7 @@ static void dsi_display_enable(struct dsi_data *dsi)
 	DSSDBG("dsi_display_ulps_enable FAILED\n");
 }
 
-static void _dsi_display_disable(struct dsi_data *dsi,
+static void dsi_display_disable(struct dsi_data *dsi,
 		bool disconnect_lanes, bool enter_ulps)
 {
 	WARN_ON(!dsi_bus_is_locked(dsi));
@@ -3786,17 +3784,6 @@ static void _dsi_display_disable(struct dsi_data *dsi,
 	mutex_unlock(&dsi->lock);
 }
 
-static void dsi_display_disable(struct omap_dss_device *dssdev)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	WARN_ON(!dsi_bus_is_locked(dsi));
-
-	DSSDBG("dsi_display_disable\n");
-
-	_dsi_display_disable(dsi, true, false);
-}
-
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
 	dsi->te_enabled = enable;
@@ -3820,7 +3807,7 @@ static void omap_dsi_ulps_work_callback(struct work_struct *work)
 
 	dsi_enable_te(dsi, false);
 
-	_dsi_display_disable(dsi, false, true);
+	dsi_display_disable(dsi, false, true);
 
 	dsi_bus_unlock(dsi);
 }
@@ -4954,7 +4941,7 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
 
 	dsi_disable_video_output(dssdev, VC_VIDEO);
 
-	dsi_display_disable(dssdev);
+	dsi_display_disable(dsi, true, false);
 
 	dsi_bus_unlock(dsi);
 }
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 75/80] drm/omap: dsi: rename dsi_display_* functions
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (73 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 74/80] drm/omap: dsi: display_disable cleanup Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:34   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 76/80] drm/omap: dsi: cleanup initial vc setup Tomi Valkeinen
                   ` (5 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

The function names have evolved to be very confusing, and bunch of them
have "display" in them even if the function doesn't deal with display as
such (e.g. dsi_display_enable which just enables the DSI interface).
Rename them by dropping the "display".

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 36 +++++++++++++++----------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index d23fc43f1d1e..ff8ace957291 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -55,8 +55,8 @@
 
 static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
 
-static int dsi_display_init_dispc(struct dsi_data *dsi);
-static void dsi_display_uninit_dispc(struct dsi_data *dsi);
+static int dsi_init_dispc(struct dsi_data *dsi);
+static void dsi_uninit_dispc(struct dsi_data *dsi);
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel);
 
@@ -3257,7 +3257,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
 	u16 word_count;
 	int r;
 
-	r = dsi_display_init_dispc(dsi);
+	r = dsi_init_dispc(dsi);
 	if (r) {
 		dev_err(dsi->dev, "failed to init dispc!\n");
 		return;
@@ -3309,7 +3309,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
 		dsi_vc_enable(dsi, vc, false);
 	}
 err_pix_fmt:
-	dsi_display_uninit_dispc(dsi);
+	dsi_uninit_dispc(dsi);
 	dev_err(dsi->dev, "failed to enable DSI encoder!\n");
 	return;
 }
@@ -3331,7 +3331,7 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
 
 	dss_mgr_disable(&dsi->output);
 
-	dsi_display_uninit_dispc(dsi);
+	dsi_uninit_dispc(dsi);
 }
 
 static void dsi_update_screen_dispc(struct dsi_data *dsi)
@@ -3577,7 +3577,7 @@ static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
 	return 0;
 }
 
-static int dsi_display_init_dispc(struct dsi_data *dsi)
+static int dsi_init_dispc(struct dsi_data *dsi)
 {
 	enum omap_channel dispc_channel = dsi->output.dispc_channel;
 	int r;
@@ -3622,7 +3622,7 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
 	return r;
 }
 
-static void dsi_display_uninit_dispc(struct dsi_data *dsi)
+static void dsi_uninit_dispc(struct dsi_data *dsi)
 {
 	enum omap_channel dispc_channel = dsi->output.dispc_channel;
 
@@ -3649,7 +3649,7 @@ static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
 	return 0;
 }
 
-static int dsi_display_init_dsi(struct dsi_data *dsi)
+static int dsi_init_dsi(struct dsi_data *dsi)
 {
 	int r;
 
@@ -3713,7 +3713,7 @@ static int dsi_display_init_dsi(struct dsi_data *dsi)
 	return r;
 }
 
-static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
+static void dsi_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
 				   bool enter_ulps)
 {
 	if (enter_ulps && !dsi->ulps_enabled)
@@ -3736,7 +3736,7 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
 	}
 }
 
-static void dsi_display_enable(struct dsi_data *dsi)
+static void dsi_enable(struct dsi_data *dsi)
 {
 	int r;
 
@@ -3750,7 +3750,7 @@ static void dsi_display_enable(struct dsi_data *dsi)
 
 	_dsi_initialize_irq(dsi);
 
-	r = dsi_display_init_dsi(dsi);
+	r = dsi_init_dsi(dsi);
 	if (r)
 		goto err_init_dsi;
 
@@ -3762,10 +3762,10 @@ static void dsi_display_enable(struct dsi_data *dsi)
 	dsi_runtime_put(dsi);
 err_get_dsi:
 	mutex_unlock(&dsi->lock);
-	DSSDBG("dsi_display_ulps_enable FAILED\n");
+	DSSDBG("dsi_enable FAILED\n");
 }
 
-static void dsi_display_disable(struct dsi_data *dsi,
+static void dsi_disable(struct dsi_data *dsi,
 		bool disconnect_lanes, bool enter_ulps)
 {
 	WARN_ON(!dsi_bus_is_locked(dsi));
@@ -3777,7 +3777,7 @@ static void dsi_display_disable(struct dsi_data *dsi,
 	dsi_sync_vc(dsi, 2);
 	dsi_sync_vc(dsi, 3);
 
-	dsi_display_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
+	dsi_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
 
 	dsi_runtime_put(dsi);
 
@@ -3807,7 +3807,7 @@ static void omap_dsi_ulps_work_callback(struct work_struct *work)
 
 	dsi_enable_te(dsi, false);
 
-	dsi_display_disable(dsi, false, true);
+	dsi_disable(dsi, false, true);
 
 	dsi_bus_unlock(dsi);
 }
@@ -3828,7 +3828,7 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable)
 			return;
 
 		dsi_bus_lock(dsi);
-		dsi_display_enable(dsi);
+		dsi_enable(dsi);
 		dsi_enable_te(dsi, true);
 		dsi_bus_unlock(dsi);
 	}
@@ -4919,7 +4919,7 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
 
 	dsi_bus_lock(dsi);
 
-	dsi_display_enable(dsi);
+	dsi_enable(dsi);
 
 	dsi_enable_video_output(dssdev, VC_VIDEO);
 
@@ -4941,7 +4941,7 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
 
 	dsi_disable_video_output(dssdev, VC_VIDEO);
 
-	dsi_display_disable(dsi, true, false);
+	dsi_disable(dsi, true, false);
 
 	dsi_bus_unlock(dsi);
 }
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 76/80] drm/omap: dsi: cleanup initial vc setup
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (74 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 75/80] drm/omap: dsi: rename dsi_display_* functions Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:36   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 77/80] drm/omap: dsi: split video mode enable/disable into separate func Tomi Valkeinen
                   ` (4 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

As we now have a fixed setup for VCs (VC0 for video stream, VC1 for
commands), we can simplify the VC setup.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 85 +++++++++++--------------------
 1 file changed, 31 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index ff8ace957291..27d0d119668b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2017,40 +2017,6 @@ static void dsi_vc_initial_config(struct dsi_data *dsi, int vc)
 	dsi->vc[vc].source = DSI_VC_SOURCE_L4;
 }
 
-static int dsi_vc_config_source(struct dsi_data *dsi, int vc,
-				enum dsi_vc_source source)
-{
-	if (dsi->vc[vc].source == source)
-		return 0;
-
-	DSSDBG("Source config of VC %d", vc);
-
-	dsi_sync_vc(dsi, vc);
-
-	dsi_vc_enable(dsi, vc, 0);
-
-	/* VC_BUSY */
-	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(vc), 15, 0)) {
-		DSSERR("vc(%d) busy when trying to config for VP\n", vc);
-		return -EIO;
-	}
-
-	/* SOURCE, 0 = L4, 1 = video port */
-	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), source, 1, 1);
-
-	/* DCS_CMD_ENABLE */
-	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) {
-		bool enable = source == DSI_VC_SOURCE_VP;
-		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 30, 30);
-	}
-
-	dsi_vc_enable(dsi, vc, 1);
-
-	dsi->vc[vc].source = source;
-
-	return 0;
-}
-
 static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
 		bool enable)
 {
@@ -2072,10 +2038,6 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
 	dsi_if_enable(dsi, 1);
 
 	dsi_force_tx_stop_mode_io(dsi);
-
-	/* start the DDR clock by sending a NULL packet */
-	if (dsi->vm_timings.ddr_clk_always_on && enable)
-		dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
 }
 
 static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
@@ -2270,8 +2232,6 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
 		return -EINVAL;
 	}
 
-	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
-
 	dsi_vc_write_long_header(dsi, vc, msg->channel, msg->type, msg->tx_len, 0);
 
 	p = msg->tx_buf;
@@ -2331,8 +2291,6 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
 		DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
 		       vc, msg->type, pkt.header[1], pkt.header[2]);
 
-	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
-
 	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(vc)), 16, 16)) {
 		DSSERR("ERROR FIFO FULL, aborting transfer\n");
 		return -EINVAL;
@@ -3351,8 +3309,6 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
 
 	DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h);
 
-	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_VP);
-
 	bytespp	= mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) / 8;
 	bytespl = w * bytespp;
 	bytespf = bytespl * h;
@@ -3522,9 +3478,7 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
 
 	dsi_set_ulps_auto(dsi, false);
 
-	dsi_vc_enable_hs(dssdev, vc, !(dsi->dsidev->mode_flags & MIPI_DSI_MODE_LPM));
-
-	r = _dsi_send_nop(dsi, vc, dsi->dsidev->channel);
+	r = _dsi_send_nop(dsi, VC_CMD, dsi->dsidev->channel);
 	if (r < 0) {
 		DSSWARN("failed to send nop between frames: %d\n", r);
 		goto err;
@@ -3649,6 +3603,35 @@ static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
 	return 0;
 }
 
+static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
+{
+	/* Setup VC_CMD for LP and cpu transfers */
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_CMD), 0, 9, 9); /* LP */
+
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_CMD), 0, 1, 1); /* SOURCE_L4 */
+	dsi->vc[VC_CMD].source = DSI_VC_SOURCE_L4;
+
+	/* Setup VC_VIDEO for HS and dispc transfers */
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 9, 9); /* HS */
+
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 1, 1); /* SOURCE_VP */
+	dsi->vc[VC_VIDEO].source = DSI_VC_SOURCE_VP;
+
+	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC)
+		REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 30, 30); /* DCS_CMD_ENABLE */
+
+	dsi_vc_enable(dsi, VC_CMD, 1);
+	dsi_vc_enable(dsi, VC_VIDEO, 1);
+
+	dsi_if_enable(dsi, 1);
+
+	dsi_force_tx_stop_mode_io(dsi);
+
+	/* start the DDR clock by sending a NULL packet */
+	if (dsi->vm_timings.ddr_clk_always_on)
+		dsi_vc_send_null(dsi, VC_CMD, dsi->dsidev->channel);
+}
+
 static int dsi_init_dsi(struct dsi_data *dsi)
 {
 	int r;
@@ -3691,13 +3674,7 @@ static int dsi_init_dsi(struct dsi_data *dsi)
 	if (r)
 		goto err3;
 
-	/* enable interface */
-	dsi_vc_enable(dsi, 0, 1);
-	dsi_vc_enable(dsi, 1, 1);
-	dsi_vc_enable(dsi, 2, 1);
-	dsi_vc_enable(dsi, 3, 1);
-	dsi_if_enable(dsi, 1);
-	dsi_force_tx_stop_mode_io(dsi);
+	dsi_setup_dsi_vcs(dsi);
 
 	return 0;
 err3:
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 77/80] drm/omap: dsi: split video mode enable/disable into separate func
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (75 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 76/80] drm/omap: dsi: cleanup initial vc setup Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:37   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 78/80] drm/omap: dsi: fix and cleanup ddr_clk_always_on Tomi Valkeinen
                   ` (3 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Clean up the code by separating video-mode enable/disable code into
functions of their own.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 101 +++++++++++++++++-------------
 1 file changed, 57 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 27d0d119668b..6d20245495ac 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3207,12 +3207,61 @@ static int dsi_configure_pins(struct dsi_data *dsi,
 	return 0;
 }
 
-static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
+static int dsi_enable_video_mode(struct dsi_data *dsi, int vc)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
 	u8 data_type;
 	u16 word_count;
+
+	switch (dsi->pix_fmt) {
+	case MIPI_DSI_FMT_RGB888:
+		data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
+		break;
+	case MIPI_DSI_FMT_RGB666:
+		data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
+		break;
+	case MIPI_DSI_FMT_RGB666_PACKED:
+		data_type = MIPI_DSI_PACKED_PIXEL_STREAM_18;
+		break;
+	case MIPI_DSI_FMT_RGB565:
+		data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	dsi_if_enable(dsi, false);
+	dsi_vc_enable(dsi, vc, false);
+
+	/* MODE, 1 = video mode */
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 4, 4);
+
+	word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
+
+	dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, data_type,
+			word_count, 0);
+
+	dsi_vc_enable(dsi, vc, true);
+	dsi_if_enable(dsi, true);
+
+	return 0;
+}
+
+static void dsi_disable_video_mode(struct dsi_data *dsi, int vc)
+{
+	dsi_if_enable(dsi, false);
+	dsi_vc_enable(dsi, vc, false);
+
+	/* MODE, 0 = command mode */
+	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);
+
+	dsi_vc_enable(dsi, vc, true);
+	dsi_if_enable(dsi, true);
+}
+
+static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
 	r = dsi_init_dispc(dsi);
@@ -3222,37 +3271,9 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
 	}
 
 	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-		switch (dsi->pix_fmt) {
-		case MIPI_DSI_FMT_RGB888:
-			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
-			break;
-		case MIPI_DSI_FMT_RGB666:
-			data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
-			break;
-		case MIPI_DSI_FMT_RGB666_PACKED:
-			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_18;
-			break;
-		case MIPI_DSI_FMT_RGB565:
-			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16;
-			break;
-		default:
-			r = -EINVAL;
-			goto err_pix_fmt;
-		}
-
-		dsi_if_enable(dsi, false);
-		dsi_vc_enable(dsi, vc, false);
-
-		/* MODE, 1 = video mode */
-		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 4, 4);
-
-		word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
-
-		dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, data_type,
-				word_count, 0);
-
-		dsi_vc_enable(dsi, vc, true);
-		dsi_if_enable(dsi, true);
+		r = dsi_enable_video_mode(dsi, vc);
+		if (r)
+			goto err_video_mode;
 	}
 
 	r = dss_mgr_enable(&dsi->output);
@@ -3266,7 +3287,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
 		dsi_if_enable(dsi, false);
 		dsi_vc_enable(dsi, vc, false);
 	}
-err_pix_fmt:
+err_video_mode:
 	dsi_uninit_dispc(dsi);
 	dev_err(dsi->dev, "failed to enable DSI encoder!\n");
 	return;
@@ -3276,16 +3297,8 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
 {
 	struct dsi_data *dsi = to_dsi_data(dssdev);
 
-	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-		dsi_if_enable(dsi, false);
-		dsi_vc_enable(dsi, vc, false);
-
-		/* MODE, 0 = command mode */
-		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);
-
-		dsi_vc_enable(dsi, vc, true);
-		dsi_if_enable(dsi, true);
-	}
+	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
+		dsi_disable_video_mode(dsi, vc);
 
 	dss_mgr_disable(&dsi->output);
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 78/80] drm/omap: dsi: fix and cleanup ddr_clk_always_on
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (76 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 77/80] drm/omap: dsi: split video mode enable/disable into separate func Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:38   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 79/80] drm/omap: dsi: remove ulps support Tomi Valkeinen
                   ` (2 subsequent siblings)
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

The driver ignores MIPI_DSI_CLOCK_NON_CONTINUOUS, and always uses
non-continuous clock.

Fix this by using MIPI_DSI_CLOCK_NON_CONTINUOUS and at the same time,
drop ddr_clk_always_on field which seems pretty useless.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 12 +++++-------
 drivers/gpu/drm/omapdrm/dss/dsi.h |  2 --
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 6d20245495ac..6e9c99402540 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1734,11 +1734,10 @@ static int dsi_cio_init(struct dsi_data *dsi)
 
 	dsi_cio_timings(dsi);
 
-	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
-		/* DDR_CLK_ALWAYS_ON */
-		REG_FLD_MOD(dsi, DSI_CLK_CTRL,
-			dsi->vm_timings.ddr_clk_always_on, 13, 13);
-	}
+	/* DDR_CLK_ALWAYS_ON */
+	REG_FLD_MOD(dsi, DSI_CLK_CTRL,
+		    !(dsi->dsidev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS),
+		    13, 13);
 
 	dsi->ulps_enabled = false;
 
@@ -3641,7 +3640,7 @@ static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
 	dsi_force_tx_stop_mode_io(dsi);
 
 	/* start the DDR clock by sending a NULL packet */
-	if (dsi->vm_timings.ddr_clk_always_on)
+	if (!(dsi->dsidev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS))
 		dsi_vc_send_null(dsi, VC_CMD, dsi->dsidev->channel);
 }
 
@@ -4150,7 +4149,6 @@ static bool dsi_vm_calc_blanking(struct dsi_clk_calc_ctx *ctx)
 	dsi_vm->hfp_blanking_mode = 1;
 	dsi_vm->hbp_blanking_mode = 1;
 
-	dsi_vm->ddr_clk_always_on = cfg->ddr_clk_always_on;
 	dsi_vm->window_sync = 4;
 
 	/* setup DISPC videomode */
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h b/drivers/gpu/drm/omapdrm/dss/dsi.h
index 7cc2cc748ed9..3543828e30eb 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.h
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
@@ -209,7 +209,6 @@ struct omap_dss_dsi_videomode_timings {
 
 	enum omap_dss_dsi_trans_mode trans_mode;
 
-	bool ddr_clk_always_on;
 	int window_sync;
 };
 
@@ -221,7 +220,6 @@ struct omap_dss_dsi_config {
 	unsigned long hs_clk_min, hs_clk_max;
 	unsigned long lp_clk_min, lp_clk_max;
 
-	bool ddr_clk_always_on;
 	enum omap_dss_dsi_trans_mode trans_mode;
 };
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 79/80] drm/omap: dsi: remove ulps support
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (77 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 78/80] drm/omap: dsi: fix and cleanup ddr_clk_always_on Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:39   ` Laurent Pinchart
  2020-11-24 12:45 ` [PATCH v4 80/80] drm/omap: dsi: fix DCS_CMD_ENABLE Tomi Valkeinen
  2020-11-30  9:39 ` [PATCH v4 81/80] drm/omap: dsi: allow DSI commands to be sent early Tomi Valkeinen
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

ULPS doesn't work, and I have been unable to get it to work. As ULPS is
a minor power-saving feature which requires substantial amount of
non-trivial code, and we have trouble just getting and
keeping DSI working at all, remove ULPS support.

When the DSI driver works reliably for command and video mode displays,
someone interested can add it back.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 297 +-----------------------------
 drivers/gpu/drm/omapdrm/dss/dsi.h |   4 -
 2 files changed, 8 insertions(+), 293 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 6e9c99402540..ffecacd7350a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -53,8 +53,6 @@
 #define REG_FLD_MOD(dsi, idx, val, start, end) \
 	dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, end))
 
-static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
-
 static int dsi_init_dispc(struct dsi_data *dsi);
 static void dsi_uninit_dispc(struct dsi_data *dsi);
 
@@ -688,44 +686,6 @@ static int dsi_unregister_isr_vc(struct dsi_data *dsi, int vc,
 	return r;
 }
 
-static int dsi_register_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
-				void *arg, u32 mask)
-{
-	unsigned long flags;
-	int r;
-
-	spin_lock_irqsave(&dsi->irq_lock, flags);
-
-	r = _dsi_register_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio,
-			ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
-
-	if (r == 0)
-		_omap_dsi_set_irqs_cio(dsi);
-
-	spin_unlock_irqrestore(&dsi->irq_lock, flags);
-
-	return r;
-}
-
-static int dsi_unregister_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
-				  void *arg, u32 mask)
-{
-	unsigned long flags;
-	int r;
-
-	spin_lock_irqsave(&dsi->irq_lock, flags);
-
-	r = _dsi_unregister_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio,
-			ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
-
-	if (r == 0)
-		_omap_dsi_set_irqs_cio(dsi);
-
-	spin_unlock_irqrestore(&dsi->irq_lock, flags);
-
-	return r;
-}
-
 static u32 dsi_get_errors(struct dsi_data *dsi)
 {
 	unsigned long flags;
@@ -1450,56 +1410,6 @@ static void dsi_cio_timings(struct dsi_data *dsi)
 	dsi_write_reg(dsi, DSI_DSIPHY_CFG2, r);
 }
 
-/* lane masks have lane 0 at lsb. mask_p for positive lines, n for negative */
-static void dsi_cio_enable_lane_override(struct dsi_data *dsi,
-					 unsigned int mask_p,
-					 unsigned int mask_n)
-{
-	int i;
-	u32 l;
-	u8 lptxscp_start = dsi->num_lanes_supported == 3 ? 22 : 26;
-
-	l = 0;
-
-	for (i = 0; i < dsi->num_lanes_supported; ++i) {
-		unsigned int p = dsi->lanes[i].polarity;
-
-		if (mask_p & (1 << i))
-			l |= 1 << (i * 2 + (p ? 0 : 1));
-
-		if (mask_n & (1 << i))
-			l |= 1 << (i * 2 + (p ? 1 : 0));
-	}
-
-	/*
-	 * Bits in REGLPTXSCPDAT4TO0DXDY:
-	 * 17: DY0 18: DX0
-	 * 19: DY1 20: DX1
-	 * 21: DY2 22: DX2
-	 * 23: DY3 24: DX3
-	 * 25: DY4 26: DX4
-	 */
-
-	/* Set the lane override configuration */
-
-	/* REGLPTXSCPDAT4TO0DXDY */
-	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, l, lptxscp_start, 17);
-
-	/* Enable lane override */
-
-	/* ENLPTXSCPDAT */
-	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 1, 27, 27);
-}
-
-static void dsi_cio_disable_lane_override(struct dsi_data *dsi)
-{
-	/* Disable lane override */
-	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */
-	/* Reset the lane override configuration */
-	/* REGLPTXSCPDAT4TO0DXDY */
-	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 22, 17);
-}
-
 static int dsi_cio_wait_tx_clk_esc_reset(struct dsi_data *dsi)
 {
 	int t, i;
@@ -1674,32 +1584,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
 	l = FLD_MOD(l, 0x1fff, 12, 0);	/* STOP_STATE_COUNTER_IO */
 	dsi_write_reg(dsi, DSI_TIMING1, l);
 
-	if (dsi->ulps_enabled) {
-		unsigned int mask_p;
-		int i;
-
-		DSSDBG("manual ulps exit\n");
-
-		/* ULPS is exited by Mark-1 state for 1ms, followed by
-		 * stop state. DSS HW cannot do this via the normal
-		 * ULPS exit sequence, as after reset the DSS HW thinks
-		 * that we are not in ULPS mode, and refuses to send the
-		 * sequence. So we need to send the ULPS exit sequence
-		 * manually by setting positive lines high and negative lines
-		 * low for 1ms.
-		 */
-
-		mask_p = 0;
-
-		for (i = 0; i < dsi->num_lanes_supported; ++i) {
-			if (dsi->lanes[i].function == DSI_LANE_UNUSED)
-				continue;
-			mask_p |= 1 << i;
-		}
-
-		dsi_cio_enable_lane_override(dsi, mask_p, 0);
-	}
-
 	r = dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ON);
 	if (r)
 		goto err_cio_pwr;
@@ -1718,17 +1602,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
 	if (r)
 		goto err_tx_clk_esc_rst;
 
-	if (dsi->ulps_enabled) {
-		/* Keep Mark-1 state for 1ms (as per DSI spec) */
-		ktime_t wait = ns_to_ktime(1000 * 1000);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_hrtimeout(&wait, HRTIMER_MODE_REL);
-
-		/* Disable the override. The lanes should be set to Mark-11
-		 * state by the HW */
-		dsi_cio_disable_lane_override(dsi);
-	}
-
 	/* FORCE_TX_STOP_MODE_IO */
 	REG_FLD_MOD(dsi, DSI_TIMING1, 0, 15, 15);
 
@@ -1739,8 +1612,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
 		    !(dsi->dsidev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS),
 		    13, 13);
 
-	dsi->ulps_enabled = false;
-
 	DSSDBG("CIO init done\n");
 
 	return 0;
@@ -1750,8 +1621,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
 err_cio_pwr_dom:
 	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_OFF);
 err_cio_pwr:
-	if (dsi->ulps_enabled)
-		dsi_cio_disable_lane_override(dsi);
 err_scp_clk_dom:
 	dsi_disable_scp_clk(dsi);
 	dsi_disable_pads(dsi);
@@ -2522,99 +2391,6 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int vc,
 	return r;
 }
 
-static int dsi_enter_ulps(struct dsi_data *dsi)
-{
-	DECLARE_COMPLETION_ONSTACK(completion);
-	int r, i;
-	unsigned int mask;
-
-	DSSDBG("Entering ULPS");
-
-	WARN_ON(!dsi_bus_is_locked(dsi));
-
-	WARN_ON(dsi->ulps_enabled);
-
-	if (dsi->ulps_enabled)
-		return 0;
-
-	/* DDR_CLK_ALWAYS_ON */
-	if (REG_GET(dsi, DSI_CLK_CTRL, 13, 13)) {
-		dsi_if_enable(dsi, 0);
-		REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 13, 13);
-		dsi_if_enable(dsi, 1);
-	}
-
-	dsi_sync_vc(dsi, 0);
-	dsi_sync_vc(dsi, 1);
-	dsi_sync_vc(dsi, 2);
-	dsi_sync_vc(dsi, 3);
-
-	dsi_force_tx_stop_mode_io(dsi);
-
-	dsi_vc_enable(dsi, 0, false);
-	dsi_vc_enable(dsi, 1, false);
-	dsi_vc_enable(dsi, 2, false);
-	dsi_vc_enable(dsi, 3, false);
-
-	if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 16, 16)) {	/* HS_BUSY */
-		DSSERR("HS busy when enabling ULPS\n");
-		return -EIO;
-	}
-
-	if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 17, 17)) {	/* LP_BUSY */
-		DSSERR("LP busy when enabling ULPS\n");
-		return -EIO;
-	}
-
-	r = dsi_register_isr_cio(dsi, dsi_completion_handler, &completion,
-			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
-	if (r)
-		return r;
-
-	mask = 0;
-
-	for (i = 0; i < dsi->num_lanes_supported; ++i) {
-		if (dsi->lanes[i].function == DSI_LANE_UNUSED)
-			continue;
-		mask |= 1 << i;
-	}
-	/* Assert TxRequestEsc for data lanes and TxUlpsClk for clk lane */
-	/* LANEx_ULPS_SIG2 */
-	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, mask, 9, 5);
-
-	/* flush posted write and wait for SCP interface to finish the write */
-	dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2);
-
-	if (wait_for_completion_timeout(&completion,
-				msecs_to_jiffies(1000)) == 0) {
-		DSSERR("ULPS enable timeout\n");
-		r = -EIO;
-		goto err;
-	}
-
-	dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion,
-			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
-
-	/* Reset LANEx_ULPS_SIG2 */
-	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, 0, 9, 5);
-
-	/* flush posted write and wait for SCP interface to finish the write */
-	dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2);
-
-	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ULPS);
-
-	dsi_if_enable(dsi, false);
-
-	dsi->ulps_enabled = true;
-
-	return 0;
-
-err:
-	dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion,
-			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
-	return r;
-}
-
 static void dsi_set_lp_rx_timeout(struct dsi_data *dsi, unsigned int ticks,
 				  bool x4, bool x16)
 {
@@ -3397,7 +3173,6 @@ static void dsi_handle_framedone(struct dsi_data *dsi, int error)
 		REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
 	}
 
-	dsi_set_ulps_auto(dsi, true);
 	dsi_bus_unlock(dsi);
 
 	if (!error)
@@ -3488,8 +3263,6 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
 
 	DSSDBG("dsi_update_channel: %d", vc);
 
-	dsi_set_ulps_auto(dsi, false);
-
 	r = _dsi_send_nop(dsi, VC_CMD, dsi->dsidev->channel);
 	if (r < 0) {
 		DSSWARN("failed to send nop between frames: %d\n", r);
@@ -3509,7 +3282,6 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
 	return 0;
 
 err:
-	dsi_set_ulps_auto(dsi, true);
 	dsi_bus_unlock(dsi);
 	return r;
 }
@@ -3702,12 +3474,8 @@ static int dsi_init_dsi(struct dsi_data *dsi)
 	return r;
 }
 
-static void dsi_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
-				   bool enter_ulps)
+static void dsi_uninit_dsi(struct dsi_data *dsi)
 {
-	if (enter_ulps && !dsi->ulps_enabled)
-		dsi_enter_ulps(dsi);
-
 	/* disable interface */
 	dsi_if_enable(dsi, 0);
 	dsi_vc_enable(dsi, 0, 0);
@@ -3719,10 +3487,8 @@ static void dsi_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
 	dsi_cio_uninit(dsi);
 	dss_pll_disable(&dsi->pll);
 
-	if (disconnect_lanes) {
-		regulator_disable(dsi->vdds_dsi_reg);
-		dsi->vdds_dsi_enabled = false;
-	}
+	regulator_disable(dsi->vdds_dsi_reg);
+	dsi->vdds_dsi_enabled = false;
 }
 
 static void dsi_enable(struct dsi_data *dsi)
@@ -3754,8 +3520,7 @@ static void dsi_enable(struct dsi_data *dsi)
 	DSSDBG("dsi_enable FAILED\n");
 }
 
-static void dsi_disable(struct dsi_data *dsi,
-		bool disconnect_lanes, bool enter_ulps)
+static void dsi_disable(struct dsi_data *dsi)
 {
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
@@ -3766,7 +3531,7 @@ static void dsi_disable(struct dsi_data *dsi,
 	dsi_sync_vc(dsi, 2);
 	dsi_sync_vc(dsi, 3);
 
-	dsi_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
+	dsi_uninit_dsi(dsi);
 
 	dsi_runtime_put(dsi);
 
@@ -3787,42 +3552,6 @@ static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 	return 0;
 }
 
-static void omap_dsi_ulps_work_callback(struct work_struct *work)
-{
-	struct dsi_data *dsi = container_of(work, struct dsi_data,
-					    ulps_work.work);
-
-	dsi_bus_lock(dsi);
-
-	dsi_enable_te(dsi, false);
-
-	dsi_disable(dsi, false, true);
-
-	dsi_bus_unlock(dsi);
-}
-
-static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable)
-{
-	WARN_ON(!dsi_bus_is_locked(dsi));
-
-	if (!dsi->ulps_auto_idle)
-		return;
-
-	if (enable) {
-		schedule_delayed_work(&dsi->ulps_work, msecs_to_jiffies(250));
-	} else {
-		cancel_delayed_work_sync(&dsi->ulps_work);
-
-		if (!dsi->ulps_enabled)
-			return;
-
-		dsi_bus_lock(dsi);
-		dsi_enable(dsi);
-		dsi_enable_te(dsi, true);
-		dsi_bus_unlock(dsi);
-	}
-}
-
 #ifdef PRINT_VERBOSE_VM_TIMINGS
 static void print_dsi_vm(const char *str,
 		const struct omap_dss_dsi_videomode_timings *t)
@@ -4494,13 +4223,10 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 
 	dsi_bus_lock(dsi);
 
-	if (dsi->video_enabled) {
-		dsi_set_ulps_auto(dsi, false);
+	if (dsi->video_enabled)
 		r = _omap_dsi_host_transfer(dsi, vc, msg);
-		dsi_set_ulps_auto(dsi, true);
-	} else {
+	else
 		r = -EIO;
-	}
 
 	dsi_bus_unlock(dsi);
 
@@ -4642,9 +4368,6 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	dsi->dsidev = client;
 	dsi->pix_fmt = client->format;
 
-	INIT_DEFERRABLE_WORK(&dsi->ulps_work,
-			     omap_dsi_ulps_work_callback);
-
 	dsi->config.hs_clk_min = 150000000; // TODO: get from client?
 	dsi->config.hs_clk_max = client->hs_rate;
 	dsi->config.lp_clk_min = 7000000; // TODO: get from client?
@@ -4657,8 +4380,6 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	else
 		dsi->config.trans_mode = OMAP_DSS_DSI_EVENT_MODE;
 
-	dsi->ulps_auto_idle = false;
-
 	return 0;
 }
 
@@ -4913,8 +4634,6 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
 
 	dsi->video_enabled = true;
 
-	dsi_set_ulps_auto(dsi, true);
-
 	dsi_bus_unlock(dsi);
 }
 
@@ -4929,7 +4648,7 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
 
 	dsi_disable_video_output(dssdev, VC_VIDEO);
 
-	dsi_disable(dsi, true, false);
+	dsi_disable(dsi);
 
 	dsi_bus_unlock(dsi);
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h b/drivers/gpu/drm/omapdrm/dss/dsi.h
index 3543828e30eb..452cee3279db 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.h
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
@@ -391,12 +391,8 @@ struct dsi_data {
 	atomic_t do_ext_te_update;
 
 	bool te_enabled;
-	bool ulps_enabled;
-	bool ulps_auto_idle;
 	bool video_enabled;
 
-	struct delayed_work ulps_work;
-
 	struct delayed_work framedone_timeout_work;
 
 #ifdef DSI_CATCH_MISSING_TE
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* [PATCH v4 80/80] drm/omap: dsi: fix DCS_CMD_ENABLE
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (78 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 79/80] drm/omap: dsi: remove ulps support Tomi Valkeinen
@ 2020-11-24 12:45 ` Tomi Valkeinen
  2020-12-01  0:40   ` Laurent Pinchart
  2020-11-30  9:39 ` [PATCH v4 81/80] drm/omap: dsi: allow DSI commands to be sent early Tomi Valkeinen
  80 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

We only need to set VC_CTRL:DCS_CMD_ENABLE for command mode panels when
the HW has DSI_QUIRK_DCS_CMD_CONFIG_VC quirk. The old code did this
right by accident, but now we set DCS_CMD_ENABLE for video mode panels
too.

Fix this by skipping the set for video mode.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index ffecacd7350a..d52bef0c7aa2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3401,7 +3401,8 @@ static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
 	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 1, 1); /* SOURCE_VP */
 	dsi->vc[VC_VIDEO].source = DSI_VC_SOURCE_VP;
 
-	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC)
+	if ((dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) &&
+	    !(dsi->dsidev->mode_flags & MIPI_DSI_MODE_VIDEO))
 		REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 30, 30); /* DCS_CMD_ENABLE */
 
 	dsi_vc_enable(dsi, VC_CMD, 1);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  2020-11-24 12:45 ` [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI Tomi Valkeinen
@ 2020-11-24 16:18   ` Sam Ravnborg
  2020-11-24 16:26     ` Tomi Valkeinen
  2020-11-30  9:50   ` Laurent Pinchart
  2020-12-14 12:54   ` Sebastian Reichel
  2 siblings, 1 reply; 152+ messages in thread
From: Sam Ravnborg @ 2020-11-24 16:18 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

Hi Tomi,

On Tue, Nov 24, 2020 at 02:45:13PM +0200, Tomi Valkeinen wrote:
> Use the common MIPI_DCS_GET_ERROR_COUNT_ON_DSI define instead of
> driver's own.
> 
They are both 5 - OK

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

IMO you should get all the patches at least up including this patch applied.
They are all reviewed/acked. And then you have a much smaller stack of
patches to spam us with.

	Sam

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  2020-11-24 16:18   ` Sam Ravnborg
@ 2020-11-24 16:26     ` Tomi Valkeinen
  2020-11-24 16:38       ` Sam Ravnborg
  0 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 16:26 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

Hi Sam,

On 24/11/2020 18:18, Sam Ravnborg wrote:
> Hi Tomi,
> 
> On Tue, Nov 24, 2020 at 02:45:13PM +0200, Tomi Valkeinen wrote:
>> Use the common MIPI_DCS_GET_ERROR_COUNT_ON_DSI define instead of
>> driver's own.
>>
> They are both 5 - OK
> 
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> 
> IMO you should get all the patches at least up including this patch applied.
> They are all reviewed/acked. And then you have a much smaller stack of
> patches to spam us with.

Yes, I think that makes sense. I did not want to merge them earlier, as with the v3, I could not get
videomode panels work at all (while cmd mode panels did work). So I was not sure if something is
totally silly and broken in the series.

Now that I can get video mode panels work with some hacks on top, I'm fine with merging these.

But it's too late for 5.11, as we need testing and work on the video mode panels. So targeting 5.12.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  2020-11-24 16:26     ` Tomi Valkeinen
@ 2020-11-24 16:38       ` Sam Ravnborg
  2020-11-25  8:52         ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Sam Ravnborg @ 2020-11-24 16:38 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

Hi Tomi

On Tue, Nov 24, 2020 at 06:26:47PM +0200, Tomi Valkeinen wrote:
> Hi Sam,
> 
> On 24/11/2020 18:18, Sam Ravnborg wrote:
> > Hi Tomi,
> > 
> > On Tue, Nov 24, 2020 at 02:45:13PM +0200, Tomi Valkeinen wrote:
> >> Use the common MIPI_DCS_GET_ERROR_COUNT_ON_DSI define instead of
> >> driver's own.
> >>
> > They are both 5 - OK
> > 
> >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> > Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> > 
> > IMO you should get all the patches at least up including this patch applied.
> > They are all reviewed/acked. And then you have a much smaller stack of
> > patches to spam us with.
> 
> Yes, I think that makes sense. I did not want to merge them earlier, as with the v3, I could not get
> videomode panels work at all (while cmd mode panels did work). So I was not sure if something is
> totally silly and broken in the series.
> 
> Now that I can get video mode panels work with some hacks on top, I'm fine with merging these.
> 
> But it's too late for 5.11, as we need testing and work on the video mode panels. So targeting 5.12.
Obviously your call, but I see no reason to wait for working videomode
panles if what you have now do not introduce any (known) regressions.

ofc I assume videomode panels is something new and not something that worked
before.

	Sam

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable
  2020-11-24 12:45 ` [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
@ 2020-11-24 17:25   ` Sam Ravnborg
  2020-11-30  9:51   ` Laurent Pinchart
  2020-12-14 12:54   ` Sebastian Reichel
  2 siblings, 0 replies; 152+ messages in thread
From: Sam Ravnborg @ 2020-11-24 17:25 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

On Tue, Nov 24, 2020 at 02:45:14PM +0200, Tomi Valkeinen wrote:
> Simplify the code by moving code from _dsicm_enable_te() into
> dsicm_power_on().
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup
  2020-11-24 12:45 ` [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
@ 2020-11-24 17:30   ` Sam Ravnborg
  2020-11-24 18:19     ` Tomi Valkeinen
  2020-11-30  9:56   ` Laurent Pinchart
  2020-12-14 12:59   ` Sebastian Reichel
  2 siblings, 1 reply; 152+ messages in thread
From: Sam Ravnborg @ 2020-11-24 17:30 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

On Tue, Nov 24, 2020 at 02:45:18PM +0200, Tomi Valkeinen wrote:
> Set the column & page address once during setup, instead of relying the
> DSI host driver to set those.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

But one comment below.

> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index 59e8e6b18e97..1e7f73340736 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -171,6 +171,26 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3)
>  	return 0;
>  }
>  
> +static int dsicm_set_update_window(struct panel_drv_data *ddata)
> +{
> +	struct mipi_dsi_device *dsi = ddata->dsi;
> +	int r;
> +	u16 x1 = 0;
> +	u16 x2 = ddata->mode.hdisplay - 1;
> +	u16 y1 = 0;
> +	u16 y2 = ddata->mode.vdisplay - 1;

It does not help the readability with the variables.

Using

	r = mipi_dsi_dcs_set_column_address(dsi, 0, ddata->mode.hdisplay - 1);

would IMO be easier to parse.

Then the pointless assignment of x1 and y1 are dropped too.

But nitpicking, ignore if think the current code is better.

	Sam


> +
> +	r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
> +	if (r < 0)
> +		return r;
> +
> +	r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
> +	if (r < 0)
> +		return r;
> +
> +	return 0;
> +}
> +
>  static int dsicm_bl_update_status(struct backlight_device *dev)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
> @@ -308,6 +328,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
>  	if (r)
>  		goto err;
>  
> +	r = dsicm_set_update_window(ddata);
> +	if (r)
> +		goto err;
> +
>  	r = mipi_dsi_dcs_set_display_on(ddata->dsi);
>  	if (r)
>  		goto err;
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if'
  2020-11-24 12:45 ` [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
@ 2020-11-24 17:34   ` Sam Ravnborg
  2020-12-01  0:22   ` Laurent Pinchart
  2020-12-02 20:08   ` kernel test robot
  2 siblings, 0 replies; 152+ messages in thread
From: Sam Ravnborg @ 2020-11-24 17:34 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

Hi Tomi,

On Tue, Nov 24, 2020 at 02:45:26PM +0200, Tomi Valkeinen wrote:
> We have a useless 'if' in the dsicm_bl_update_status(), a left over from
> the conversion to DRM model. Drop the if.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

But with a few comments.

> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index 1e7f73340736..c17ed728c695 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -194,7 +194,7 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata)
>  static int dsicm_bl_update_status(struct backlight_device *dev)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
> -	int r = 0;
> +	int r;
>  	int level;
>  
>  	if (dev->props.fb_blank == FB_BLANK_UNBLANK &&

Unrelated to this patch - but here it would be better to use
level = backlight_get_brightness(dev);

level is 0 is backlight is off.

	Sam


> @@ -207,11 +207,9 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
>  
>  	mutex_lock(&ddata->lock);
>  
> -	if (ddata->enabled) {
> -		if (!r)
> -			r = dsicm_dcs_write_1(
> -				ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
> -	}
> +	if (ddata->enabled)
> +		r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
> +				      level);
>  
>  	mutex_unlock(&ddata->lock);
>  
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver
  2020-11-24 12:45 ` [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver Tomi Valkeinen
@ 2020-11-24 17:35   ` Sam Ravnborg
  2020-12-01  0:23   ` Laurent Pinchart
  1 sibling, 0 replies; 152+ messages in thread
From: Sam Ravnborg @ 2020-11-24 17:35 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

On Tue, Nov 24, 2020 at 02:45:27PM +0200, Tomi Valkeinen wrote:
> Add a panel database to the driver instead of reading propertes from DT
> data. This is similar to panel-simple, and I believe it's more future
> safe way to handle the panels.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Looks good, and you remembered to drop the unsed includes - nice.

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>


> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 107 +++++++++++++++++----------
>  1 file changed, 69 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index c17ed728c695..ec87b785871f 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -22,10 +22,7 @@
>  #include <drm/drm_modes.h>
>  #include <drm/drm_panel.h>
>  
> -#include <video/display_timing.h>
>  #include <video/mipi_display.h>
> -#include <video/of_display_timing.h>
> -#include <video/videomode.h>
>  
>  #define DCS_GET_ID1		0xda
>  #define DCS_GET_ID2		0xdb
> @@ -33,6 +30,18 @@
>  
>  #define DCS_REGULATOR_SUPPLY_NUM 2
>  
> +static const struct of_device_id dsicm_of_match[];
> +
> +struct dsic_panel_data {
> +	u32 xres;
> +	u32 yres;
> +	u32 refresh;
> +	u32 width_mm;
> +	u32 height_mm;
> +	u32 max_hs_rate;
> +	u32 max_lp_rate;
> +};
> +
>  struct panel_drv_data {
>  	struct mipi_dsi_device *dsi;
>  	struct drm_panel panel;
> @@ -48,16 +57,14 @@ struct panel_drv_data {
>  					 */
>  	unsigned long	hw_guard_wait;	/* max guard time in jiffies */
>  
> -	/* panel HW configuration from DT or platform data */
> +	const struct dsic_panel_data *panel_data;
> +
>  	struct gpio_desc *reset_gpio;
>  
>  	struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
>  
>  	bool use_dsi_backlight;
>  
> -	int width_mm;
> -	int height_mm;
> -
>  	/* runtime variables */
>  	bool enabled;
>  
> @@ -455,11 +462,8 @@ static int dsicm_get_modes(struct drm_panel *panel,
>  		return -ENOMEM;
>  	}
>  
> -	drm_mode_set_name(mode);
> -	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> -
> -	connector->display_info.width_mm = ddata->width_mm;
> -	connector->display_info.height_mm = ddata->height_mm;
> +	connector->display_info.width_mm = ddata->panel_data->width_mm;
> +	connector->display_info.height_mm = ddata->panel_data->height_mm;
>  
>  	drm_mode_probed_add(connector, mode);
>  
> @@ -476,15 +480,10 @@ static const struct drm_panel_funcs dsicm_panel_funcs = {
>  
>  static int dsicm_probe_of(struct mipi_dsi_device *dsi)
>  {
> -	struct device_node *node = dsi->dev.of_node;
>  	struct backlight_device *backlight;
>  	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
> -	struct display_timing timing;
> -	struct videomode vm = {
> -		.hactive = 864,
> -		.vactive = 480,
> -	};
>  	int err;
> +	struct drm_display_mode *mode = &ddata->mode;
>  
>  	ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
>  	if (IS_ERR(ddata->reset_gpio)) {
> @@ -493,23 +492,16 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
>  		return err;
>  	}
>  
> -	err = of_get_display_timing(node, "panel-timing", &timing);
> -	if (!err) {
> -		videomode_from_timing(&timing, &vm);
> -	} else {
> -		dev_warn(&dsi->dev,
> -			 "failed to get video timing, using defaults\n");
> -	}
> -
> -	if (!vm.pixelclock)
> -		vm.pixelclock = vm.hactive * vm.vactive * 60;
> -	drm_display_mode_from_videomode(&vm, &ddata->mode);
> -
> -	ddata->width_mm = 0;
> -	of_property_read_u32(node, "width-mm", &ddata->width_mm);
> -
> -	ddata->height_mm = 0;
> -	of_property_read_u32(node, "height-mm", &ddata->height_mm);
> +	mode->hdisplay = mode->hsync_start = mode->hsync_end = mode->htotal =
> +		ddata->panel_data->xres;
> +	mode->vdisplay = mode->vsync_start = mode->vsync_end = mode->vtotal =
> +		ddata->panel_data->yres;
> +	mode->clock = ddata->panel_data->xres * ddata->panel_data->yres *
> +		ddata->panel_data->refresh / 1000;
> +	mode->width_mm = ddata->panel_data->width_mm;
> +	mode->height_mm = ddata->panel_data->height_mm;
> +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> +	drm_mode_set_name(mode);
>  
>  	ddata->supplies[0].supply = "vpnl";
>  	ddata->supplies[1].supply = "vddi";
> @@ -536,6 +528,7 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	struct panel_drv_data *ddata;
>  	struct backlight_device *bldev = NULL;
>  	struct device *dev = &dsi->dev;
> +	const struct of_device_id *id;
>  	int r;
>  
>  	dev_dbg(dev, "probe\n");
> @@ -547,6 +540,12 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	mipi_dsi_set_drvdata(dsi, ddata);
>  	ddata->dsi = dsi;
>  
> +	id = of_match_node(dsicm_of_match, dev->of_node);
> +	if (!id)
> +		return -ENODEV;
> +
> +	ddata->panel_data = id->data;
> +
>  	r = dsicm_probe_of(dsi);
>  	if (r)
>  		return r;
> @@ -583,8 +582,8 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	dsi->format = MIPI_DSI_FMT_RGB888;
>  	dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |
>  			  MIPI_DSI_MODE_EOT_PACKET;
> -	dsi->hs_rate = 300000000;
> -	dsi->lp_rate = 10000000;
> +	dsi->hs_rate = ddata->panel_data->max_hs_rate;
> +	dsi->lp_rate = ddata->panel_data->max_lp_rate;
>  
>  	drm_panel_add(&ddata->panel);
>  
> @@ -622,8 +621,40 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
>  	return 0;
>  }
>  
> +static const struct dsic_panel_data taal_data = {
> +	.xres = 864,
> +	.yres = 480,
> +	.refresh = 60,
> +	.width_mm = 0,
> +	.height_mm = 0,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
> +static const struct dsic_panel_data himalaya_data = {
> +	.xres = 480,
> +	.yres = 864,
> +	.refresh = 60,
> +	.width_mm = 49,
> +	.height_mm = 88,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
> +static const struct dsic_panel_data droid4_data = {
> +	.xres = 540,
> +	.yres = 960,
> +	.refresh = 60,
> +	.width_mm = 50,
> +	.height_mm = 89,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
>  static const struct of_device_id dsicm_of_match[] = {
> -	{ .compatible = "panel-dsi-cm", },
> +	{ .compatible = "tpo,taal", .data = &taal_data },
> +	{ .compatible = "nokia,himalaya", &himalaya_data },
> +	{ .compatible = "motorola,droid4-panel", &droid4_data },
>  	{},
>  };
>  
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes
  2020-11-24 12:45 ` [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes Tomi Valkeinen
@ 2020-11-24 17:36   ` Sam Ravnborg
  2020-12-01  0:27   ` Laurent Pinchart
  1 sibling, 0 replies; 152+ messages in thread
From: Sam Ravnborg @ 2020-11-24 17:36 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

On Tue, Nov 24, 2020 at 02:45:28PM +0200, Tomi Valkeinen wrote:
> Drop unneeded includes.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
I trust the compiler here.
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index ec87b785871f..91ed8237a1c2 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -9,12 +9,7 @@
>  #include <linux/backlight.h>
>  #include <linux/delay.h>
>  #include <linux/gpio/consumer.h>
> -#include <linux/interrupt.h>
>  #include <linux/jiffies.h>
> -#include <linux/module.h>
> -#include <linux/sched/signal.h>
> -#include <linux/slab.h>
> -#include <linux/of_device.h>
>  #include <linux/regulator/consumer.h>
>  
>  #include <drm/drm_connector.h>
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup
  2020-11-24 17:30   ` Sam Ravnborg
@ 2020-11-24 18:19     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-24 18:19 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

On 24/11/2020 19:30, Sam Ravnborg wrote:
> On Tue, Nov 24, 2020 at 02:45:18PM +0200, Tomi Valkeinen wrote:
>> Set the column & page address once during setup, instead of relying the
>> DSI host driver to set those.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> 
> But one comment below.
> 
>> ---
>>  drivers/gpu/drm/panel/panel-dsi-cm.c | 24 ++++++++++++++++++++++++
>>  1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
>> index 59e8e6b18e97..1e7f73340736 100644
>> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
>> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
>> @@ -171,6 +171,26 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3)
>>  	return 0;
>>  }
>>  
>> +static int dsicm_set_update_window(struct panel_drv_data *ddata)
>> +{
>> +	struct mipi_dsi_device *dsi = ddata->dsi;
>> +	int r;
>> +	u16 x1 = 0;
>> +	u16 x2 = ddata->mode.hdisplay - 1;
>> +	u16 y1 = 0;
>> +	u16 y2 = ddata->mode.vdisplay - 1;
> 
> It does not help the readability with the variables.
> 
> Using
> 
> 	r = mipi_dsi_dcs_set_column_address(dsi, 0, ddata->mode.hdisplay - 1);
> 
> would IMO be easier to parse.
> 
> Then the pointless assignment of x1 and y1 are dropped too.

I think I agree with you here, although the variables do make it clearer to the reader that the
parameters are x1 and x2, not x and w.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  2020-11-24 16:38       ` Sam Ravnborg
@ 2020-11-25  8:52         ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-25  8:52 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori

On 24/11/2020 18:38, Sam Ravnborg wrote:

>>> IMO you should get all the patches at least up including this patch applied.
>>> They are all reviewed/acked. And then you have a much smaller stack of
>>> patches to spam us with.
>>
>> Yes, I think that makes sense. I did not want to merge them earlier, as with the v3, I could not get
>> videomode panels work at all (while cmd mode panels did work). So I was not sure if something is
>> totally silly and broken in the series.
>>
>> Now that I can get video mode panels work with some hacks on top, I'm fine with merging these.
>>
>> But it's too late for 5.11, as we need testing and work on the video mode panels. So targeting 5.12.
> Obviously your call, but I see no reason to wait for working videomode
> panles if what you have now do not introduce any (known) regressions.
> 
> ofc I assume videomode panels is something new and not something that worked
> before.
It gets a bit muddy here. The omap dsi host driver has had videomode support for a long time, but
there has been no upstream videomode panel drivers (omapdrm specific drivers, as omapdrm had its own
panel framework) and no board dts files using it.

I have a board with a custom made DSI videomode panel setup, but it's broken (cable, I think) and
works only randomly. I have an old 4.14 based branch with a hacky panel driver and dts file which
get the panel working. I don't know if videomode works on current upstream, or has it been broken
between 4.14 and current upstream, as the 4.14 panel driver doesn't work without modifications on
current upstream.

In this series we convert the omap dsi host driver to be a proper DRM citizen, removing support for
omapdrm specific panels, so new DRM panel drivers are needed to replace the omapdrm specific ones.

With this series applied, and adding a new panel driver and dts changes, videomode works (Nikolaus
confirmed that his panel works. Mine doesn't, as afaics it needs more finetuned initialization which
may not be possible with the current DRM bridge/panel callbacks. But mine works with some hacks).
But I'm sure in the middle of this series videomode won't work.

So, I think one can argue that this causes regressions in the middle of the series to non-upstream
panel drivers, but at the end of the series, they probably work, presuming you have a new DRM panel
driver for it.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* [PATCH v4 81/80] drm/omap: dsi: allow DSI commands to be sent early
  2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (79 preceding siblings ...)
  2020-11-24 12:45 ` [PATCH v4 80/80] drm/omap: dsi: fix DCS_CMD_ENABLE Tomi Valkeinen
@ 2020-11-30  9:39 ` Tomi Valkeinen
  80 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-11-30  9:39 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel
  Cc: Sekhar Nori, Tony Lindgren, hns, Tomi Valkeinen

Panel drivers can send DSI commands in panel's prepare(), which happens
before the bridge's enable() is called. The OMAP DSI driver currently
only sets up the DSI interface at bridge's enable(), so prepare() cannot
be used to send DSI commands.

This patch fixes the issue by making it possible to enable the DSI
interface any time a command is about to be sent. Disabling the
interface is be done via delayed work.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---

One more patch. With this video mode panels seem to work cleanly (tested
by me on omap5 uevm + custom panel and Nikolaus on pyra).

 drivers/gpu/drm/omapdrm/dss/dsi.c | 49 +++++++++++++++++++++++++++----
 drivers/gpu/drm/omapdrm/dss/dsi.h |  3 ++
 2 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index d52bef0c7aa2..ae504ab122b4 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3498,6 +3498,9 @@ static void dsi_enable(struct dsi_data *dsi)
 
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
+	if (WARN_ON(dsi->iface_enabled))
+		return;
+
 	mutex_lock(&dsi->lock);
 
 	r = dsi_runtime_get(dsi);
@@ -3510,6 +3513,8 @@ static void dsi_enable(struct dsi_data *dsi)
 	if (r)
 		goto err_init_dsi;
 
+	dsi->iface_enabled = true;
+
 	mutex_unlock(&dsi->lock);
 
 	return;
@@ -3525,6 +3530,9 @@ static void dsi_disable(struct dsi_data *dsi)
 {
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
+	if (WARN_ON(!dsi->iface_enabled))
+		return;
+
 	mutex_lock(&dsi->lock);
 
 	dsi_sync_vc(dsi, 0);
@@ -3536,6 +3544,8 @@ static void dsi_disable(struct dsi_data *dsi)
 
 	dsi_runtime_put(dsi);
 
+	dsi->iface_enabled = false;
+
 	mutex_unlock(&dsi->lock);
 }
 
@@ -4224,10 +4234,12 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
 
 	dsi_bus_lock(dsi);
 
-	if (dsi->video_enabled)
-		r = _omap_dsi_host_transfer(dsi, vc, msg);
-	else
-		r = -EIO;
+	if (!dsi->iface_enabled) {
+		dsi_enable(dsi);
+		schedule_delayed_work(&dsi->dsi_disable_work, msecs_to_jiffies(2000));
+	}
+
+	r = _omap_dsi_host_transfer(dsi, vc, msg);
 
 	dsi_bus_unlock(dsi);
 
@@ -4392,6 +4404,14 @@ static int omap_dsi_host_detach(struct mipi_dsi_host *host,
 	if (WARN_ON(dsi->dsidev != client))
 		return -EINVAL;
 
+	cancel_delayed_work_sync(&dsi->dsi_disable_work);
+
+	if (dsi->iface_enabled) {
+		dsi_bus_lock(dsi);
+		dsi_disable(dsi);
+		dsi_bus_unlock(dsi);
+	}
+
 	omap_dsi_unregister_te_irq(dsi);
 	dsi->dsidev = NULL;
 	return 0;
@@ -4627,9 +4647,12 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
 	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
 	struct omap_dss_device *dssdev = &dsi->output;
 
+	cancel_delayed_work_sync(&dsi->dsi_disable_work);
+
 	dsi_bus_lock(dsi);
 
-	dsi_enable(dsi);
+	if (!dsi->iface_enabled)
+		dsi_enable(dsi);
 
 	dsi_enable_video_output(dssdev, VC_VIDEO);
 
@@ -4643,6 +4666,8 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
 	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
 	struct omap_dss_device *dssdev = &dsi->output;
 
+	cancel_delayed_work_sync(&dsi->dsi_disable_work);
+
 	dsi_bus_lock(dsi);
 
 	dsi->video_enabled = false;
@@ -4835,6 +4860,18 @@ static const struct soc_device_attribute dsi_soc_devices[] = {
 	{ /* sentinel */ }
 };
 
+static void omap_dsi_disable_work_callback(struct work_struct *work)
+{
+	struct dsi_data *dsi = container_of(work, struct dsi_data, dsi_disable_work.work);
+
+	dsi_bus_lock(dsi);
+
+	if (dsi->iface_enabled && !dsi->video_enabled)
+		dsi_disable(dsi);
+
+	dsi_bus_unlock(dsi);
+}
+
 static int dsi_probe(struct platform_device *pdev)
 {
 	const struct soc_device_attribute *soc;
@@ -4868,6 +4905,8 @@ static int dsi_probe(struct platform_device *pdev)
 	INIT_DEFERRABLE_WORK(&dsi->framedone_timeout_work,
 			     dsi_framedone_timeout_work_callback);
 
+	INIT_DEFERRABLE_WORK(&dsi->dsi_disable_work, omap_dsi_disable_work_callback);
+
 #ifdef DSI_CATCH_MISSING_TE
 	timer_setup(&dsi->te_timer, dsi_te_timeout, 0);
 #endif
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h b/drivers/gpu/drm/omapdrm/dss/dsi.h
index 452cee3279db..805f9073d9a5 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.h
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
@@ -391,6 +391,7 @@ struct dsi_data {
 	atomic_t do_ext_te_update;
 
 	bool te_enabled;
+	bool iface_enabled;
 	bool video_enabled;
 
 	struct delayed_work framedone_timeout_work;
@@ -440,6 +441,8 @@ struct dsi_data {
 
 	struct omap_dss_device output;
 	struct drm_bridge bridge;
+
+	struct delayed_work dsi_disable_work;
 };
 
 struct dsi_packet_sent_handler_data {
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  2020-11-24 12:45 ` [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI Tomi Valkeinen
  2020-11-24 16:18   ` Sam Ravnborg
@ 2020-11-30  9:50   ` Laurent Pinchart
  2020-12-14 12:54   ` Sebastian Reichel
  2 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-11-30  9:50 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:13PM +0200, Tomi Valkeinen wrote:
> Use the common MIPI_DCS_GET_ERROR_COUNT_ON_DSI define instead of
> driver's own.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index 35a0c7da1974..cb0d27a38555 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -27,7 +27,6 @@
>  #include <video/of_display_timing.h>
>  #include <video/videomode.h>
>  
> -#define DCS_READ_NUM_ERRORS	0x05
>  #define DCS_GET_ID1		0xda
>  #define DCS_GET_ID2		0xdb
>  #define DCS_GET_ID3		0xdc
> @@ -225,7 +224,7 @@ static ssize_t num_dsi_errors_show(struct device *dev,
>  	mutex_lock(&ddata->lock);
>  
>  	if (ddata->enabled)
> -		r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, &errors);
> +		r = dsicm_dcs_read_1(ddata, MIPI_DCS_GET_ERROR_COUNT_ON_DSI, &errors);
>  
>  	mutex_unlock(&ddata->lock);
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable
  2020-11-24 12:45 ` [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
  2020-11-24 17:25   ` Sam Ravnborg
@ 2020-11-30  9:51   ` Laurent Pinchart
  2020-12-14 12:54   ` Sebastian Reichel
  2 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-11-30  9:51 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:14PM +0200, Tomi Valkeinen wrote:
> Simplify the code by moving code from _dsicm_enable_te() into
> dsicm_power_on().
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 23 ++++-------------------
>  1 file changed, 4 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index cb0d27a38555..59e8e6b18e97 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -69,8 +69,6 @@ static inline struct panel_drv_data *panel_to_ddata(struct drm_panel *panel)
>  	return container_of(panel, struct panel_drv_data, panel);
>  }
>  
> -static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
> -
>  static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable)
>  {
>  	struct backlight_device *backlight;
> @@ -314,10 +312,13 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
>  	if (r)
>  		goto err;
>  
> -	r = _dsicm_enable_te(ddata, true);
> +	r = mipi_dsi_dcs_set_tear_on(ddata->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
>  	if (r)
>  		goto err;
>  
> +	/* possible panel bug */
> +	msleep(100);
> +
>  	ddata->enabled = true;
>  
>  	if (!ddata->intro_printed) {
> @@ -418,22 +419,6 @@ static int dsicm_disable(struct drm_panel *panel)
>  	return r;
>  }
>  
> -static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
> -{
> -	struct mipi_dsi_device *dsi = ddata->dsi;
> -	int r;
> -
> -	if (enable)
> -		r = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
> -	else
> -		r = mipi_dsi_dcs_set_tear_off(dsi);
> -
> -	/* possible panel bug */
> -	msleep(100);
> -
> -	return r;
> -}
> -
>  static int dsicm_get_modes(struct drm_panel *panel,
>  			   struct drm_connector *connector)
>  {

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi
  2020-11-24 12:45 ` [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi Tomi Valkeinen
@ 2020-11-30  9:53   ` Laurent Pinchart
  2020-12-01 10:39     ` Tomi Valkeinen
  2020-12-14 12:55   ` Sebastian Reichel
  1 sibling, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-11-30  9:53 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:15PM +0200, Tomi Valkeinen wrote:
> Add address-cells & size-cells to DSI nodes so that board files do not
> need to define them.

How about adding ports too, while at it ?

It would also be nice to convert the DT bindings to YAML :-)

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> ---
>  arch/arm/boot/dts/omap5.dtsi | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
> index 2bf2e5839a7f..e6f6947965ef 100644
> --- a/arch/arm/boot/dts/omap5.dtsi
> +++ b/arch/arm/boot/dts/omap5.dtsi
> @@ -517,6 +517,9 @@ dsi1: encoder@0 {
>  						clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>,
>  							 <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>;
>  						clock-names = "fck", "sys_clk";
> +
> +						#address-cells = <1>;
> +						#size-cells = <0>;
>  					};
>  				};
>  
> @@ -549,6 +552,9 @@ dsi2: encoder@0 {
>  						clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>,
>  							 <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>;
>  						clock-names = "fck", "sys_clk";
> +
> +						#address-cells = <1>;
> +						#size-cells = <0>;
>  					};
>  				};
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 58/80] drm/omap: pll: fix iteration loop check
  2020-11-24 12:45 ` [PATCH v4 58/80] drm/omap: pll: fix iteration loop check Tomi Valkeinen
@ 2020-11-30  9:54   ` Laurent Pinchart
  2020-12-14 12:55   ` Sebastian Reichel
  1 sibling, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-11-30  9:54 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:16PM +0200, Tomi Valkeinen wrote:
> If the PLL calc function is given bad parameters, n_start/m_start may be
> higher than n_stop/m_stop, which leads to the loops iterating through
> the whole u32 number space.
> 
> Fix this by failing early on such cases.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/pll.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c
> index 1212f3cc52d1..12926218c436 100644
> --- a/drivers/gpu/drm/omapdrm/dss/pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/pll.c
> @@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
>  	n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max);
>  	n_inc = 1;
>  
> +	if (n_start > n_stop)
> +		return false;
> +
>  	if (hw->errata_i886) {
>  		swap(n_start, n_stop);
>  		n_inc = -1;
> @@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
>  				hw->m_max);
>  		m_inc = 1;
>  
> +		if (m_start > m_stop)
> +			continue;
> +
>  		if (hw->errata_i886) {
>  			swap(m_start, m_stop);
>  			m_inc = -1;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 59/80] drm/omap: dsi: set trans_mode according to client mode_flags
  2020-11-24 12:45 ` [PATCH v4 59/80] drm/omap: dsi: set trans_mode according to client mode_flags Tomi Valkeinen
@ 2020-11-30  9:55   ` Laurent Pinchart
  2020-12-14 12:56   ` Sebastian Reichel
  1 sibling, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-11-30  9:55 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:17PM +0200, Tomi Valkeinen wrote:
> The DSI host driver currently ignores the video mode flags in
> client->mode_flags. Add the code to take the transfer mode from client's
> mode_flags.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index c3592c6db977..7fee9cf8782d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5140,6 +5140,13 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
>  	dsi->config.lp_clk_min = 7000000; // TODO: get from client?
>  	dsi->config.lp_clk_max = client->lp_rate;
>  
> +	if (client->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
> +		dsi->config.trans_mode = OMAP_DSS_DSI_BURST_MODE;
> +	else if (client->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)
> +		dsi->config.trans_mode = OMAP_DSS_DSI_PULSE_MODE;
> +	else
> +		dsi->config.trans_mode = OMAP_DSS_DSI_EVENT_MODE;
> +
>  	dsi->ulps_auto_idle = false;
>  
>  	return 0;
> 

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup
  2020-11-24 12:45 ` [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
  2020-11-24 17:30   ` Sam Ravnborg
@ 2020-11-30  9:56   ` Laurent Pinchart
  2020-12-14 12:59   ` Sebastian Reichel
  2 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-11-30  9:56 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:18PM +0200, Tomi Valkeinen wrote:
> Set the column & page address once during setup, instead of relying the
> DSI host driver to set those.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

With Sam's comments addressed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index 59e8e6b18e97..1e7f73340736 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -171,6 +171,26 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3)
>  	return 0;
>  }
>  
> +static int dsicm_set_update_window(struct panel_drv_data *ddata)
> +{
> +	struct mipi_dsi_device *dsi = ddata->dsi;
> +	int r;
> +	u16 x1 = 0;
> +	u16 x2 = ddata->mode.hdisplay - 1;
> +	u16 y1 = 0;
> +	u16 y2 = ddata->mode.vdisplay - 1;
> +
> +	r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
> +	if (r < 0)
> +		return r;
> +
> +	r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
> +	if (r < 0)
> +		return r;
> +
> +	return 0;
> +}
> +
>  static int dsicm_bl_update_status(struct backlight_device *dev)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
> @@ -308,6 +328,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
>  	if (r)
>  		goto err;
>  
> +	r = dsicm_set_update_window(ddata);
> +	if (r)
> +		goto err;
> +
>  	r = mipi_dsi_dcs_set_display_on(ddata->dsi);
>  	if (r)
>  		goto err;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 61/80] drm/omap: dsi: send nop instead of page & column
  2020-11-24 12:45 ` [PATCH v4 61/80] drm/omap: dsi: send nop instead of page & column Tomi Valkeinen
@ 2020-11-30  9:58   ` Laurent Pinchart
  2020-12-01 10:59     ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-11-30  9:58 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:19PM +0200, Tomi Valkeinen wrote:
> The OMAP DSI command mode panel driver used to send page & column
> address before each frame update, and this code was moved into the DSI
> host driver when converting it to the DRM bridge model.
> 
> However, it's not really required to send the page & column address
> before each frame. It's also something that doesn't really belong to the
> DSI host driver, so we should drop the code.
> 
> That said, frame updates break if we don't send _something_ between the
> frames. A NOP command does the trick.
> 
> It is not clear if this behavior is as expected from a DSI command mode
> frame transfer, or is it a feature/issue with OMAP DSI driver, or a
> feature/issue in the command mode panel used. So this probably needs to
> be revisited later.

This is important information, could you capture it in a comment in the
code ?

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 41 +++++++++----------------------
>  1 file changed, 12 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 7fee9cf8782d..746c2149fbbd 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3884,35 +3884,19 @@ static int _dsi_update(struct dsi_data *dsi)
>  	return 0;
>  }
>  
> -static int _dsi_update_window(struct dsi_data *dsi, int channel,
> -			      int x, int y, int w, int h)
> -{
> -	int x1 = x, x2 = (x + w - 1);
> -	int y1 = y, y2 = (y + h - 1);
> -	u8 payloadX[5] = { MIPI_DCS_SET_COLUMN_ADDRESS,
> -			   x1 >> 8, x1 & 0xff, x2 >> 8, x2 & 0xff };
> -	u8 payloadY[5] = { MIPI_DCS_SET_PAGE_ADDRESS,
> -			   y1 >> 8, y1 & 0xff, y2 >> 8, y2 & 0xff };
> -	struct mipi_dsi_msg msgX = { 0 }, msgY = { 0 };
> -	int ret;
> +static int _dsi_send_nop(struct dsi_data *dsi, int channel)
> +{
> +	const u8 payload[] = { MIPI_DCS_NOP };
> +	const struct mipi_dsi_msg msg = {
> +		.channel = channel,
> +		.type = MIPI_DSI_DCS_SHORT_WRITE,
> +		.tx_len = 1,
> +		.tx_buf = payload,
> +	};
>  
>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
> -	msgX.type = MIPI_DSI_DCS_LONG_WRITE;
> -	msgX.channel = channel;
> -	msgX.tx_buf = payloadX;
> -	msgX.tx_len = sizeof(payloadX);
> -
> -	msgY.type = MIPI_DSI_DCS_LONG_WRITE;
> -	msgY.channel = channel;
> -	msgY.tx_buf = payloadY;
> -	msgY.tx_len = sizeof(payloadY);
> -
> -	ret = _omap_dsi_host_transfer(dsi, &msgX);
> -	if (ret != 0)
> -		return ret;
> -
> -	return _omap_dsi_host_transfer(dsi, &msgY);
> +	return _omap_dsi_host_transfer(dsi, &msg);
>  }
>  
>  static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
> @@ -3944,10 +3928,9 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
>  
>  	dsi_set_ulps_auto(dsi, false);
>  
> -	r = _dsi_update_window(dsi, channel, 0, 0, dsi->vm.hactive,
> -			       dsi->vm.vactive);
> +	r = _dsi_send_nop(dsi, channel);
>  	if (r < 0) {
> -		DSSWARN("window update error: %d\n", r);
> +		DSSWARN("failed to send nop between frames: %d\n", r);
>  		goto err;
>  	}
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 62/80] drm/omap: dsi: simplify VC handling
  2020-11-24 12:45 ` [PATCH v4 62/80] drm/omap: dsi: simplify VC handling Tomi Valkeinen
@ 2020-11-30 10:00   ` Laurent Pinchart
  2020-12-01 11:11     ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-11-30 10:00 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:20PM +0200, Tomi Valkeinen wrote:
> The VC handling has gotten quite tangled up. As the first step to clean
> it up, lets define that we only support a single DSI peripheral (which
> was really already the case), and we always use VC0 (define VC_DEFAULT
> 0) register block to send data to the peripheral.
> 
> We can thus have a single mipi_dsi_device pointer and remove the for

s/the for/the need for/ ?

> loops which made passes over all the four VCs (just the first one was
> ever used).
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 49 ++++++++-----------------------
>  1 file changed, 13 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 746c2149fbbd..63338324c564 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -360,9 +360,10 @@ struct dsi_data {
>  	bool vdds_dsi_enabled;
>  	struct regulator *vdds_dsi_reg;
>  
> +	struct mipi_dsi_device *dsidev;
> +
>  	struct {
>  		enum dsi_vc_source source;
> -		struct mipi_dsi_device *dest;
>  		enum fifo_size tx_fifo_size;
>  		enum fifo_size rx_fifo_size;
>  	} vc[4];
> @@ -452,6 +453,8 @@ static bool dsi_perf;
>  module_param(dsi_perf, bool, 0644);
>  #endif
>  
> +#define VC_DEFAULT 0
> +
>  #define drm_bridge_to_dsi(bridge) \
>  	container_of(bridge, struct dsi_data, bridge)
>  
> @@ -3716,16 +3719,11 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
>  static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
> -	unsigned int i;
>  
>  	dsi_bus_lock(dsi);
>  	dsi->video_enabled = false;
>  
> -	for (i = 0; i < 4; i++) {
> -		if (!dsi->vc[i].dest)
> -			continue;
> -		dsi_disable_video_output(dssdev, i);
> -	}
> +	dsi_disable_video_output(dssdev, VC_DEFAULT);
>  
>  	dsi_display_disable(dssdev);
>  
> @@ -3914,11 +3912,6 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
>  		goto err;
>  	}
>  
> -	if (!dsi->vc[channel].dest) {
> -		r = -ENODEV;
> -		goto err;
> -	}
> -
>  	if (dsi->vm.hactive == 0 || dsi->vm.vactive == 0) {
>  		r = -EINVAL;
>  		goto err;
> @@ -3954,16 +3947,7 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
>  
>  static int dsi_update_all(struct omap_dss_device *dssdev)
>  {
> -	unsigned int i;
> -	int r;
> -
> -	for (i = 0; i < 4; i++) {
> -		r = dsi_update_channel(dssdev, i);
> -		if (r && r != -ENODEV)
> -			return r;
> -	}
> -
> -	return r;
> +	return dsi_update_channel(dssdev, VC_DEFAULT);
>  }
>  
>  /* Display funcs */
> @@ -4191,17 +4175,12 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
>  static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
> -	unsigned int i;
>  
>  	dsi_bus_lock(dsi);
>  
>  	dsi_display_enable(dssdev);
>  
> -	for (i = 0; i < 4; i++) {
> -		if (!dsi->vc[i].dest)
> -			continue;
> -		dsi_enable_video_output(dssdev, i);
> -	}
> +	dsi_enable_video_output(dssdev, VC_DEFAULT);
>  
>  	dsi->video_enabled = true;
>  
> @@ -5090,8 +5069,8 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
>  	if (channel > 3)
>  		return -EINVAL;
>  
> -	if (dsi->vc[channel].dest) {
> -		DSSERR("cannot get VC for display %s", dev_name(&client->dev));
> +	if (dsi->dsidev) {
> +		DSSERR("dsi client already attached\n");
>  		return -EBUSY;
>  	}
>  
> @@ -5112,7 +5091,7 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
>  		dsi->mode = OMAP_DSS_DSI_CMD_MODE;
>  	}
>  
> -	dsi->vc[channel].dest = client;
> +	dsi->dsidev = client;
>  	dsi->pix_fmt = client->format;
>  
>  	INIT_DEFERRABLE_WORK(&dsi->ulps_work,
> @@ -5144,11 +5123,11 @@ static int omap_dsi_host_detach(struct mipi_dsi_host *host,
>  	if (channel > 3)
>  		return -EINVAL;
>  
> -	if (dsi->vc[channel].dest != client)
> +	if (WARN_ON(dsi->dsidev != client))
>  		return -EINVAL;
>  
>  	omap_dsi_unregister_te_irq(dsi);
> -	dsi->vc[channel].dest = NULL;
> +	dsi->dsidev = NULL;
>  	return 0;
>  }
>  
> @@ -5680,10 +5659,8 @@ static int dsi_probe(struct platform_device *pdev)
>  	}
>  
>  	/* DSI VCs initialization */
> -	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) {
> +	for (i = 0; i < ARRAY_SIZE(dsi->vc); i++)
>  		dsi->vc[i].source = DSI_VC_SOURCE_L4;
> -		dsi->vc[i].dest = NULL;
> -	}
>  
>  	r = dsi_get_clocks(dsi);
>  	if (r)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 63/80] drm/omap: dsi: drop useless channel checks
  2020-11-24 12:45 ` [PATCH v4 63/80] drm/omap: dsi: drop useless channel checks Tomi Valkeinen
@ 2020-12-01  0:14   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:14 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:21PM +0200, Tomi Valkeinen wrote:
> A DSI peripheral can have virtual channel ID of 0-3. This should be
> always the case, and there's no need in the driver to validate the
> channel.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 11 -----------
>  1 file changed, 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 63338324c564..fbf05097612f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3902,9 +3902,6 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r;
>  
> -	if (channel > 3)
> -		return -EINVAL;
> -
>  	dsi_bus_lock(dsi);
>  
>  	if (!dsi->video_enabled) {
> @@ -5063,12 +5060,8 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
>  				struct mipi_dsi_device *client)
>  {
>  	struct dsi_data *dsi = host_to_omap(host);
> -	unsigned int channel = client->channel;
>  	int r;
>  
> -	if (channel > 3)
> -		return -EINVAL;
> -
>  	if (dsi->dsidev) {
>  		DSSERR("dsi client already attached\n");
>  		return -EBUSY;
> @@ -5118,10 +5111,6 @@ static int omap_dsi_host_detach(struct mipi_dsi_host *host,
>  				struct mipi_dsi_device *client)
>  {
>  	struct dsi_data *dsi = host_to_omap(host);
> -	unsigned int channel = client->channel;
> -
> -	if (channel > 3)
> -		return -EINVAL;
>  
>  	if (WARN_ON(dsi->dsidev != client))
>  		return -EINVAL;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 64/80] drm/omap: dsi: cleanup channel usages
  2020-11-24 12:45 ` [PATCH v4 64/80] drm/omap: dsi: cleanup channel usages Tomi Valkeinen
@ 2020-12-01  0:17   ` Laurent Pinchart
  2020-12-01 11:23     ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:17 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:22PM +0200, Tomi Valkeinen wrote:
> The "channel" usage in omap dsi driver is super confusing. We have three
> different "channels":
> 
> 1) DSI virtual channel ID. This is a number from 0 to 3, included in the
> packet payload.
> 
> 2) VC. This is a register block in the DSI IP. There are four of those
> blocks. A VC is a DSI "pipeline", with defined fifo settings, data
> source (cpu or dispc), and some other settings. It has no relation to
> the 1).

Lovely that it's called VC :-)

> 3) dispc channel. It's the "pipeline" number dispc uses to send pixel
> data.
> 
> To clean this up use the following names for each of the above: 1)
> "channel" 2) "vc" 3) "dispc_channel"

1) and 2) will still be prone to confusion :-S Would it help to name 2)
hw_vc or something similar ?

> This patch is mostly about renaming things, but as in some places 1) and
> 2) have gotten mixed up, additional changes were needed to untangle
> them. This is mostly just adding a new parameter to some functions so
> that we pass both the vc and the channel.

It would ease review if this could be split in two patches.

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 315 +++++++++++++++---------------
>  1 file changed, 158 insertions(+), 157 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index fbf05097612f..4ac82166edc3 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -214,9 +214,9 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
>  static int dsi_display_init_dispc(struct dsi_data *dsi);
>  static void dsi_display_uninit_dispc(struct dsi_data *dsi);
>  
> -static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
> +static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel);
>  
> -static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
> +static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
>  				       const struct mipi_dsi_msg *msg);
>  
>  static void dsi_display_disable(struct omap_dss_device *dssdev);
> @@ -376,7 +376,7 @@ struct dsi_data {
>  	/* space for a copy used by the interrupt handler */
>  	struct dsi_isr_tables isr_tables_copy;
>  
> -	int update_channel;
> +	int update_vc;
>  #ifdef DSI_PERF_MEASURE
>  	unsigned int update_bytes;
>  #endif
> @@ -639,7 +639,7 @@ static void print_irq_status(u32 status)
>  #undef PIS
>  }
>  
> -static void print_irq_status_vc(int channel, u32 status)
> +static void print_irq_status_vc(int vc, u32 status)
>  {
>  	if (status == 0)
>  		return;
> @@ -650,7 +650,7 @@ static void print_irq_status_vc(int channel, u32 status)
>  #define PIS(x) (status & DSI_VC_IRQ_##x) ? (#x " ") : ""
>  
>  	pr_debug("DSI VC(%d) IRQ 0x%x: %s%s%s%s%s%s%s%s%s\n",
> -		channel,
> +		vc,
>  		status,
>  		PIS(CS),
>  		PIS(ECC_CORR),
> @@ -1031,7 +1031,7 @@ static int dsi_unregister_isr(struct dsi_data *dsi, omap_dsi_isr_t isr,
>  	return r;
>  }
>  
> -static int dsi_register_isr_vc(struct dsi_data *dsi, int channel,
> +static int dsi_register_isr_vc(struct dsi_data *dsi, int vc,
>  			       omap_dsi_isr_t isr, void *arg, u32 mask)
>  {
>  	unsigned long flags;
> @@ -1040,18 +1040,18 @@ static int dsi_register_isr_vc(struct dsi_data *dsi, int channel,
>  	spin_lock_irqsave(&dsi->irq_lock, flags);
>  
>  	r = _dsi_register_isr(isr, arg, mask,
> -			dsi->isr_tables.isr_table_vc[channel],
> -			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
> +			dsi->isr_tables.isr_table_vc[vc],
> +			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]));
>  
>  	if (r == 0)
> -		_omap_dsi_set_irqs_vc(dsi, channel);
> +		_omap_dsi_set_irqs_vc(dsi, vc);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  
>  	return r;
>  }
>  
> -static int dsi_unregister_isr_vc(struct dsi_data *dsi, int channel,
> +static int dsi_unregister_isr_vc(struct dsi_data *dsi, int vc,
>  				 omap_dsi_isr_t isr, void *arg, u32 mask)
>  {
>  	unsigned long flags;
> @@ -1060,11 +1060,11 @@ static int dsi_unregister_isr_vc(struct dsi_data *dsi, int channel,
>  	spin_lock_irqsave(&dsi->irq_lock, flags);
>  
>  	r = _dsi_unregister_isr(isr, arg, mask,
> -			dsi->isr_tables.isr_table_vc[channel],
> -			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel]));
> +			dsi->isr_tables.isr_table_vc[vc],
> +			ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]));
>  
>  	if (r == 0)
> -		_omap_dsi_set_irqs_vc(dsi, channel);
> +		_omap_dsi_set_irqs_vc(dsi, vc);
>  
>  	spin_unlock_irqrestore(&dsi->irq_lock, flags);
>  
> @@ -2232,9 +2232,9 @@ static int dsi_force_tx_stop_mode_io(struct dsi_data *dsi)
>  	return 0;
>  }
>  
> -static bool dsi_vc_is_enabled(struct dsi_data *dsi, int channel)
> +static bool dsi_vc_is_enabled(struct dsi_data *dsi, int vc)
>  {
> -	return REG_GET(dsi, DSI_VC_CTRL(channel), 0, 0);
> +	return REG_GET(dsi, DSI_VC_CTRL(vc), 0, 0);
>  }
>  
>  static void dsi_packet_sent_handler_vp(void *data, u32 mask)
> @@ -2242,14 +2242,14 @@ static void dsi_packet_sent_handler_vp(void *data, u32 mask)
>  	struct dsi_packet_sent_handler_data *vp_data =
>  		(struct dsi_packet_sent_handler_data *) data;
>  	struct dsi_data *dsi = vp_data->dsi;
> -	const int channel = dsi->update_channel;
> +	const int vc = dsi->update_vc;
>  	u8 bit = dsi->te_enabled ? 30 : 31;
>  
> -	if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit) == 0)
> +	if (REG_GET(dsi, DSI_VC_TE(vc), bit, bit) == 0)
>  		complete(vp_data->completion);
>  }
>  
> -static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel)
> +static int dsi_sync_vc_vp(struct dsi_data *dsi, int vc)
>  {
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	struct dsi_packet_sent_handler_data vp_data = {
> @@ -2261,13 +2261,13 @@ static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel)
>  
>  	bit = dsi->te_enabled ? 30 : 31;
>  
> -	r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
> +	r = dsi_register_isr_vc(dsi, vc, dsi_packet_sent_handler_vp,
>  		&vp_data, DSI_VC_IRQ_PACKET_SENT);
>  	if (r)
>  		goto err0;
>  
>  	/* Wait for completion only if TE_EN/TE_START is still set */
> -	if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit)) {
> +	if (REG_GET(dsi, DSI_VC_TE(vc), bit, bit)) {
>  		if (wait_for_completion_timeout(&completion,
>  				msecs_to_jiffies(10)) == 0) {
>  			DSSERR("Failed to complete previous frame transfer\n");
> @@ -2276,12 +2276,12 @@ static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel)
>  		}
>  	}
>  
> -	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
> +	dsi_unregister_isr_vc(dsi, vc, dsi_packet_sent_handler_vp,
>  		&vp_data, DSI_VC_IRQ_PACKET_SENT);
>  
>  	return 0;
>  err1:
> -	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp,
> +	dsi_unregister_isr_vc(dsi, vc, dsi_packet_sent_handler_vp,
>  		&vp_data, DSI_VC_IRQ_PACKET_SENT);
>  err0:
>  	return r;
> @@ -2292,13 +2292,13 @@ static void dsi_packet_sent_handler_l4(void *data, u32 mask)
>  	struct dsi_packet_sent_handler_data *l4_data =
>  		(struct dsi_packet_sent_handler_data *) data;
>  	struct dsi_data *dsi = l4_data->dsi;
> -	const int channel = dsi->update_channel;
> +	const int vc = dsi->update_vc;
>  
> -	if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5) == 0)
> +	if (REG_GET(dsi, DSI_VC_CTRL(vc), 5, 5) == 0)
>  		complete(l4_data->completion);
>  }
>  
> -static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel)
> +static int dsi_sync_vc_l4(struct dsi_data *dsi, int vc)
>  {
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	struct dsi_packet_sent_handler_data l4_data = {
> @@ -2307,13 +2307,13 @@ static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel)
>  	};
>  	int r = 0;
>  
> -	r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
> +	r = dsi_register_isr_vc(dsi, vc, dsi_packet_sent_handler_l4,
>  		&l4_data, DSI_VC_IRQ_PACKET_SENT);
>  	if (r)
>  		goto err0;
>  
>  	/* Wait for completion only if TX_FIFO_NOT_EMPTY is still set */
> -	if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5)) {
> +	if (REG_GET(dsi, DSI_VC_CTRL(vc), 5, 5)) {
>  		if (wait_for_completion_timeout(&completion,
>  				msecs_to_jiffies(10)) == 0) {
>  			DSSERR("Failed to complete previous l4 transfer\n");
> @@ -2322,47 +2322,47 @@ static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel)
>  		}
>  	}
>  
> -	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
> +	dsi_unregister_isr_vc(dsi, vc, dsi_packet_sent_handler_l4,
>  		&l4_data, DSI_VC_IRQ_PACKET_SENT);
>  
>  	return 0;
>  err1:
> -	dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4,
> +	dsi_unregister_isr_vc(dsi, vc, dsi_packet_sent_handler_l4,
>  		&l4_data, DSI_VC_IRQ_PACKET_SENT);
>  err0:
>  	return r;
>  }
>  
> -static int dsi_sync_vc(struct dsi_data *dsi, int channel)
> +static int dsi_sync_vc(struct dsi_data *dsi, int vc)
>  {
>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	WARN_ON(in_interrupt());
>  
> -	if (!dsi_vc_is_enabled(dsi, channel))
> +	if (!dsi_vc_is_enabled(dsi, vc))
>  		return 0;
>  
> -	switch (dsi->vc[channel].source) {
> +	switch (dsi->vc[vc].source) {
>  	case DSI_VC_SOURCE_VP:
> -		return dsi_sync_vc_vp(dsi, channel);
> +		return dsi_sync_vc_vp(dsi, vc);
>  	case DSI_VC_SOURCE_L4:
> -		return dsi_sync_vc_l4(dsi, channel);
> +		return dsi_sync_vc_l4(dsi, vc);
>  	default:
>  		BUG();
>  		return -EINVAL;
>  	}
>  }
>  
> -static int dsi_vc_enable(struct dsi_data *dsi, int channel, bool enable)
> +static int dsi_vc_enable(struct dsi_data *dsi, int vc, bool enable)
>  {
> -	DSSDBG("dsi_vc_enable channel %d, enable %d\n",
> -			channel, enable);
> +	DSSDBG("dsi_vc_enable vc %d, enable %d\n",
> +			vc, enable);
>  
>  	enable = enable ? 1 : 0;
>  
> -	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 0, 0);
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 0, 0);
>  
> -	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 0, enable)) {
> +	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(vc), 0, enable)) {
>  		DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
>  		return -EIO;
>  	}
> @@ -2370,17 +2370,17 @@ static int dsi_vc_enable(struct dsi_data *dsi, int channel, bool enable)
>  	return 0;
>  }
>  
> -static void dsi_vc_initial_config(struct dsi_data *dsi, int channel)
> +static void dsi_vc_initial_config(struct dsi_data *dsi, int vc)
>  {
>  	u32 r;
>  
> -	DSSDBG("Initial config of virtual channel %d", channel);
> +	DSSDBG("Initial config of VC %d", vc);
>  
> -	r = dsi_read_reg(dsi, DSI_VC_CTRL(channel));
> +	r = dsi_read_reg(dsi, DSI_VC_CTRL(vc));
>  
>  	if (FLD_GET(r, 15, 15)) /* VC_BUSY */
>  		DSSERR("VC(%d) busy when trying to configure it!\n",
> -				channel);
> +				vc);
>  
>  	r = FLD_MOD(r, 0, 1, 1); /* SOURCE, 0 = L4 */
>  	r = FLD_MOD(r, 0, 2, 2); /* BTA_SHORT_EN  */
> @@ -2395,76 +2395,76 @@ static void dsi_vc_initial_config(struct dsi_data *dsi, int channel)
>  	r = FLD_MOD(r, 4, 29, 27); /* DMA_RX_REQ_NB = no dma */
>  	r = FLD_MOD(r, 4, 23, 21); /* DMA_TX_REQ_NB = no dma */
>  
> -	dsi_write_reg(dsi, DSI_VC_CTRL(channel), r);
> +	dsi_write_reg(dsi, DSI_VC_CTRL(vc), r);
>  
> -	dsi->vc[channel].source = DSI_VC_SOURCE_L4;
> +	dsi->vc[vc].source = DSI_VC_SOURCE_L4;
>  }
>  
> -static int dsi_vc_config_source(struct dsi_data *dsi, int channel,
> +static int dsi_vc_config_source(struct dsi_data *dsi, int vc,
>  				enum dsi_vc_source source)
>  {
> -	if (dsi->vc[channel].source == source)
> +	if (dsi->vc[vc].source == source)
>  		return 0;
>  
> -	DSSDBG("Source config of virtual channel %d", channel);
> +	DSSDBG("Source config of VC %d", vc);
>  
> -	dsi_sync_vc(dsi, channel);
> +	dsi_sync_vc(dsi, vc);
>  
> -	dsi_vc_enable(dsi, channel, 0);
> +	dsi_vc_enable(dsi, vc, 0);
>  
>  	/* VC_BUSY */
> -	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 15, 0)) {
> -		DSSERR("vc(%d) busy when trying to config for VP\n", channel);
> +	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(vc), 15, 0)) {
> +		DSSERR("vc(%d) busy when trying to config for VP\n", vc);
>  		return -EIO;
>  	}
>  
>  	/* SOURCE, 0 = L4, 1 = video port */
> -	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), source, 1, 1);
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), source, 1, 1);
>  
>  	/* DCS_CMD_ENABLE */
>  	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) {
>  		bool enable = source == DSI_VC_SOURCE_VP;
> -		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 30, 30);
> +		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 30, 30);
>  	}
>  
> -	dsi_vc_enable(dsi, channel, 1);
> +	dsi_vc_enable(dsi, vc, 1);
>  
> -	dsi->vc[channel].source = source;
> +	dsi->vc[vc].source = source;
>  
>  	return 0;
>  }
>  
> -static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
> +static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
>  		bool enable)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
> -	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable);
> +	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", vc, enable);
>  
>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
> -	dsi_vc_enable(dsi, channel, 0);
> +	dsi_vc_enable(dsi, vc, 0);
>  	dsi_if_enable(dsi, 0);
>  
> -	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 9, 9);
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 9, 9);
>  
> -	dsi_vc_enable(dsi, channel, 1);
> +	dsi_vc_enable(dsi, vc, 1);
>  	dsi_if_enable(dsi, 1);
>  
>  	dsi_force_tx_stop_mode_io(dsi);
>  
>  	/* start the DDR clock by sending a NULL packet */
>  	if (dsi->vm_timings.ddr_clk_always_on && enable)
> -		dsi_vc_send_null(dsi, channel);
> +		dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
>  
>  	dsi->in_lp_mode = !enable;
>  }
>  
> -static void dsi_vc_flush_long_data(struct dsi_data *dsi, int channel)
> +static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
>  {
> -	while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
> +	while (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
>  		u32 val;
> -		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
> +		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc));
>  		DSSDBG("\t\tb1 %#02x b2 %#02x b3 %#02x b4 %#02x\n",
>  				(val >> 0) & 0xff,
>  				(val >> 8) & 0xff,
> @@ -2510,13 +2510,13 @@ static void dsi_show_rx_ack_with_err(u16 err)
>  		DSSERR("\t\tDSI Protocol Violation\n");
>  }
>  
> -static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel)
> +static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int vc)
>  {
>  	/* RX_FIFO_NOT_EMPTY */
> -	while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
> +	while (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
>  		u32 val;
>  		u8 dt;
> -		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
> +		val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc));
>  		DSSERR("\trawval %#08x\n", val);
>  		dt = FLD_GET(val, 5, 0);
>  		if (dt == MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT) {
> @@ -2531,7 +2531,7 @@ static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel)
>  		} else if (dt == MIPI_DSI_RX_DCS_LONG_READ_RESPONSE) {
>  			DSSERR("\tDCS long response, len %d\n",
>  					FLD_GET(val, 23, 8));
> -			dsi_vc_flush_long_data(dsi, channel);
> +			dsi_vc_flush_long_data(dsi, vc);
>  		} else {
>  			DSSERR("\tunknown datatype 0x%02x\n", dt);
>  		}
> @@ -2539,35 +2539,35 @@ static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel)
>  	return 0;
>  }
>  
> -static int dsi_vc_send_bta(struct dsi_data *dsi, int channel)
> +static int dsi_vc_send_bta(struct dsi_data *dsi, int vc)
>  {
>  	if (dsi->debug_write || dsi->debug_read)
> -		DSSDBG("dsi_vc_send_bta %d\n", channel);
> +		DSSDBG("dsi_vc_send_bta %d\n", vc);
>  
>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	/* RX_FIFO_NOT_EMPTY */
> -	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) {
> +	if (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
>  		DSSERR("rx fifo not empty when sending BTA, dumping data:\n");
> -		dsi_vc_flush_receive_data(dsi, channel);
> +		dsi_vc_flush_receive_data(dsi, vc);
>  	}
>  
> -	REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 6, 6); /* BTA_EN */
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 6, 6); /* BTA_EN */
>  
>  	/* flush posted write */
> -	dsi_read_reg(dsi, DSI_VC_CTRL(channel));
> +	dsi_read_reg(dsi, DSI_VC_CTRL(vc));
>  
>  	return 0;
>  }
>  
> -static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
> +static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int vc)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	DECLARE_COMPLETION_ONSTACK(completion);
>  	int r = 0;
>  	u32 err;
>  
> -	r = dsi_register_isr_vc(dsi, channel, dsi_completion_handler,
> +	r = dsi_register_isr_vc(dsi, vc, dsi_completion_handler,
>  			&completion, DSI_VC_IRQ_BTA);
>  	if (r)
>  		goto err0;
> @@ -2577,7 +2577,7 @@ static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
>  	if (r)
>  		goto err1;
>  
> -	r = dsi_vc_send_bta(dsi, channel);
> +	r = dsi_vc_send_bta(dsi, vc);
>  	if (r)
>  		goto err2;
>  
> @@ -2598,14 +2598,15 @@ static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
>  	dsi_unregister_isr(dsi, dsi_completion_handler, &completion,
>  			DSI_IRQ_ERROR_MASK);
>  err1:
> -	dsi_unregister_isr_vc(dsi, channel, dsi_completion_handler,
> +	dsi_unregister_isr_vc(dsi, vc, dsi_completion_handler,
>  			&completion, DSI_VC_IRQ_BTA);
>  err0:
>  	return r;
>  }
>  
> -static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel,
> -					    u8 data_type, u16 len, u8 ecc)
> +static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int vc,
> +					    int channel, u8 data_type, u16 len,
> +					    u8 ecc)
>  {
>  	u32 val;
>  	u8 data_id;
> @@ -2615,12 +2616,12 @@ static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel,
>  	data_id = data_type | channel << 6;
>  
>  	val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) |
> -		FLD_VAL(ecc, 31, 24);
> +	      FLD_VAL(ecc, 31, 24);
>  
> -	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_HEADER(channel), val);
> +	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_HEADER(vc), val);
>  }
>  
> -static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel,
> +static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int vc,
>  					     u8 b1, u8 b2, u8 b3, u8 b4)
>  {
>  	u32 val;
> @@ -2630,10 +2631,10 @@ static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel,
>  /*	DSSDBG("\twriting %02x, %02x, %02x, %02x (%#010x)\n",
>  			b1, b2, b3, b4, val); */
>  
> -	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(channel), val);
> +	dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(vc), val);
>  }
>  
> -static int dsi_vc_send_long(struct dsi_data *dsi,
> +static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
>  			    const struct mipi_dsi_msg *msg)
>  {
>  	/*u32 val; */
> @@ -2646,14 +2647,14 @@ static int dsi_vc_send_long(struct dsi_data *dsi,
>  		DSSDBG("dsi_vc_send_long, %d bytes\n", msg->tx_len);
>  
>  	/* len + header */
> -	if (dsi->vc[msg->channel].tx_fifo_size * 32 * 4 < msg->tx_len + 4) {
> +	if (dsi->vc[vc].tx_fifo_size * 32 * 4 < msg->tx_len + 4) {
>  		DSSERR("unable to send long packet: packet too long.\n");
>  		return -EINVAL;
>  	}
>  
> -	dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
> +	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
>  
> -	dsi_vc_write_long_header(dsi, msg->channel, msg->type, msg->tx_len, 0);
> +	dsi_vc_write_long_header(dsi, vc, msg->channel, msg->type, msg->tx_len, 0);
>  
>  	p = msg->tx_buf;
>  	for (i = 0; i < msg->tx_len >> 2; i++) {
> @@ -2665,7 +2666,7 @@ static int dsi_vc_send_long(struct dsi_data *dsi,
>  		b3 = *p++;
>  		b4 = *p++;
>  
> -		dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, b4);
> +		dsi_vc_write_long_payload(dsi, vc, b1, b2, b3, b4);
>  	}
>  
>  	i = msg->tx_len % 4;
> @@ -2690,13 +2691,13 @@ static int dsi_vc_send_long(struct dsi_data *dsi,
>  			break;
>  		}
>  
> -		dsi_vc_write_long_payload(dsi, msg->channel, b1, b2, b3, 0);
> +		dsi_vc_write_long_payload(dsi, vc, b1, b2, b3, 0);
>  	}
>  
>  	return r;
>  }
>  
> -static int dsi_vc_send_short(struct dsi_data *dsi,
> +static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
>  			     const struct mipi_dsi_msg *msg)
>  {
>  	struct mipi_dsi_packet pkt;
> @@ -2710,11 +2711,11 @@ static int dsi_vc_send_short(struct dsi_data *dsi,
>  
>  	if (dsi->debug_write)
>  		DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
> -		       msg->channel, msg->type, pkt.header[1], pkt.header[2]);
> +		       vc, msg->type, pkt.header[1], pkt.header[2]);
>  
> -	dsi_vc_config_source(dsi, msg->channel, DSI_VC_SOURCE_L4);
> +	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
>  
> -	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(msg->channel)), 16, 16)) {
> +	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(vc)), 16, 16)) {
>  		DSSERR("ERROR FIFO FULL, aborting transfer\n");
>  		return -EINVAL;
>  	}
> @@ -2722,31 +2723,31 @@ static int dsi_vc_send_short(struct dsi_data *dsi,
>  	r = pkt.header[3] << 24 | pkt.header[2] << 16 | pkt.header[1] << 8 |
>  	    pkt.header[0];
>  
> -	dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(msg->channel), r);
> +	dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc), r);
>  
>  	return 0;
>  }
>  
> -static int dsi_vc_send_null(struct dsi_data *dsi, int channel)
> +static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel)
>  {
>  	const struct mipi_dsi_msg msg = {
>  		.channel = channel,
>  		.type = MIPI_DSI_NULL_PACKET,
>  	};
>  
> -	return dsi_vc_send_long(dsi, &msg);
> +	return dsi_vc_send_long(dsi, vc, &msg);
>  }
>  
> -static int dsi_vc_write_common(struct omap_dss_device *dssdev,
> +static int dsi_vc_write_common(struct omap_dss_device *dssdev, int vc,
>  			       const struct mipi_dsi_msg *msg)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r;
>  
>  	if (mipi_dsi_packet_format_is_short(msg->type))
> -		r = dsi_vc_send_short(dsi, msg);
> +		r = dsi_vc_send_short(dsi, vc, msg);
>  	else
> -		r = dsi_vc_send_long(dsi, msg);
> +		r = dsi_vc_send_long(dsi, vc, msg);
>  
>  	if (r < 0)
>  		return r;
> @@ -2758,23 +2759,23 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev,
>  	 * In that case we can return early.
>  	 */
>  
> -	r = dsi_vc_send_bta_sync(dssdev, msg->channel);
> +	r = dsi_vc_send_bta_sync(dssdev, vc);
>  	if (r) {
>  		DSSERR("bta sync failed\n");
>  		return r;
>  	}
>  
>  	/* RX_FIFO_NOT_EMPTY */
> -	if (REG_GET(dsi, DSI_VC_CTRL(msg->channel), 20, 20)) {
> +	if (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20)) {
>  		DSSERR("rx fifo not empty after write, dumping data:\n");
> -		dsi_vc_flush_receive_data(dsi, msg->channel);
> +		dsi_vc_flush_receive_data(dsi, vc);
>  		return -EIO;
>  	}
>  
>  	return 0;
>  }
>  
> -static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
> +static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int vc, u8 *buf,
>  			       int buflen, enum dss_dsi_content_type type)
>  {
>  	u32 val;
> @@ -2782,13 +2783,13 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
>  	int r;
>  
>  	/* RX_FIFO_NOT_EMPTY */
> -	if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20) == 0) {
> +	if (REG_GET(dsi, DSI_VC_CTRL(vc), 20, 20) == 0) {
>  		DSSERR("RX fifo empty when trying to read.\n");
>  		r = -EIO;
>  		goto err;
>  	}
>  
> -	val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel));
> +	val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(vc));
>  	if (dsi->debug_read)
>  		DSSDBG("\theader: %08x\n", val);
>  	dt = FLD_GET(val, 5, 0);
> @@ -2852,7 +2853,7 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
>  		for (w = 0; w < len + 2;) {
>  			int b;
>  			val = dsi_read_reg(dsi,
> -				DSI_VC_SHORT_PACKET_HEADER(channel));
> +				DSI_VC_SHORT_PACKET_HEADER(vc));
>  			if (dsi->debug_read)
>  				DSSDBG("\t\t%02x %02x %02x %02x\n",
>  						(val >> 0) & 0xff,
> @@ -2876,32 +2877,31 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf,
>  	}
>  
>  err:
> -	DSSERR("dsi_vc_read_rx_fifo(ch %d type %s) failed\n", channel,
> +	DSSERR("dsi_vc_read_rx_fifo(vc %d type %s) failed\n", vc,
>  		type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" : "DCS");
>  
>  	return r;
>  }
>  
> -static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
> +static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int vc,
>  			   const struct mipi_dsi_msg *msg)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	u8 cmd = ((u8 *)msg->tx_buf)[0];
> -	u8 channel = msg->channel;
>  	int r;
>  
>  	if (dsi->debug_read)
> -		DSSDBG("%s(ch %d, cmd %x)\n", __func__, channel, cmd);
> +		DSSDBG("%s(ch %d, cmd %x)\n", __func__, vc, cmd);
>  
> -	r = dsi_vc_send_short(dsi, msg);
> +	r = dsi_vc_send_short(dsi, vc, msg);
>  	if (r)
>  		goto err;
>  
> -	r = dsi_vc_send_bta_sync(dssdev, channel);
> +	r = dsi_vc_send_bta_sync(dssdev, vc);
>  	if (r)
>  		goto err;
>  
> -	r = dsi_vc_read_rx_fifo(dsi, channel, msg->rx_buf, msg->rx_len,
> +	r = dsi_vc_read_rx_fifo(dsi, vc, msg->rx_buf, msg->rx_len,
>  		DSS_DSI_CONTENT_DCS);
>  	if (r < 0)
>  		goto err;
> @@ -2913,25 +2913,25 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
>  
>  	return 0;
>  err:
> -	DSSERR("%s(ch %d, cmd 0x%02x) failed\n", __func__,  msg->channel, cmd);
> +	DSSERR("%s(ch %d, cmd 0x%02x) failed\n", __func__,  vc, cmd);
>  	return r;
>  }
>  
> -static int dsi_vc_generic_read(struct omap_dss_device *dssdev,
> +static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int vc,
>  			       const struct mipi_dsi_msg *msg)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r;
>  
> -	r = dsi_vc_send_short(dsi, msg);
> +	r = dsi_vc_send_short(dsi, vc, msg);
>  	if (r)
>  		goto err;
>  
> -	r = dsi_vc_send_bta_sync(dssdev, msg->channel);
> +	r = dsi_vc_send_bta_sync(dssdev, vc);
>  	if (r)
>  		goto err;
>  
> -	r = dsi_vc_read_rx_fifo(dsi, msg->channel, msg->rx_buf, msg->rx_len,
> +	r = dsi_vc_read_rx_fifo(dsi, vc, msg->rx_buf, msg->rx_len,
>  		DSS_DSI_CONTENT_GENERIC);
>  	if (r < 0)
>  		goto err;
> @@ -2943,7 +2943,7 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev,
>  
>  	return 0;
>  err:
> -	DSSERR("%s(ch %d, reqlen %d) failed\n", __func__,  msg->channel, msg->tx_len);
> +	DSSERR("%s(ch %d, reqlen %d) failed\n", __func__,  vc, msg->tx_len);
>  	return r;
>  }
>  
> @@ -3631,7 +3631,7 @@ static int dsi_configure_pins(struct dsi_data *dsi,
>  	return 0;
>  }
>  
> -static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
> +static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
> @@ -3665,17 +3665,17 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  		}
>  
>  		dsi_if_enable(dsi, false);
> -		dsi_vc_enable(dsi, channel, false);
> +		dsi_vc_enable(dsi, vc, false);
>  
>  		/* MODE, 1 = video mode */
> -		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 4, 4);
> +		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 4, 4);
>  
>  		word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
>  
> -		dsi_vc_write_long_header(dsi, channel, data_type,
> +		dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, data_type,
>  				word_count, 0);
>  
> -		dsi_vc_enable(dsi, channel, true);
> +		dsi_vc_enable(dsi, vc, true);
>  		dsi_if_enable(dsi, true);
>  	}
>  
> @@ -3688,7 +3688,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  err_mgr_enable:
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
>  		dsi_if_enable(dsi, false);
> -		dsi_vc_enable(dsi, channel, false);
> +		dsi_vc_enable(dsi, vc, false);
>  	}
>  err_pix_fmt:
>  	dsi_display_uninit_dispc(dsi);
> @@ -3696,18 +3696,18 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
>  	return;
>  }
>  
> -static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel)
> +static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
>  		dsi_if_enable(dsi, false);
> -		dsi_vc_enable(dsi, channel, false);
> +		dsi_vc_enable(dsi, vc, false);
>  
>  		/* MODE, 0 = command mode */
> -		REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 0, 4, 4);
> +		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);
>  
> -		dsi_vc_enable(dsi, channel, true);
> +		dsi_vc_enable(dsi, vc, true);
>  		dsi_if_enable(dsi, true);
>  	}
>  
> @@ -3740,14 +3740,14 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  	unsigned int packet_len;
>  	u32 l;
>  	int r;
> -	const unsigned channel = dsi->update_channel;
> +	const unsigned vc = dsi->update_vc;
>  	const unsigned int line_buf_size = dsi->line_buffer_size;
>  	u16 w = dsi->vm.hactive;
>  	u16 h = dsi->vm.vactive;
>  
>  	DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h);
>  
> -	dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_VP);
> +	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_VP);
>  
>  	bytespp	= mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) / 8;
>  	bytespl = w * bytespp;
> @@ -3768,16 +3768,16 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  		total_len += (bytespf % packet_payload) + 1;
>  
>  	l = FLD_VAL(total_len, 23, 0); /* TE_SIZE */
> -	dsi_write_reg(dsi, DSI_VC_TE(channel), l);
> +	dsi_write_reg(dsi, DSI_VC_TE(vc), l);
>  
> -	dsi_vc_write_long_header(dsi, channel, MIPI_DSI_DCS_LONG_WRITE,
> +	dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, MIPI_DSI_DCS_LONG_WRITE,
>  		packet_len, 0);
>  
>  	if (dsi->te_enabled)
>  		l = FLD_MOD(l, 1, 30, 30); /* TE_EN */
>  	else
>  		l = FLD_MOD(l, 1, 31, 31); /* TE_START */
> -	dsi_write_reg(dsi, DSI_VC_TE(channel), l);
> +	dsi_write_reg(dsi, DSI_VC_TE(vc), l);
>  
>  	/* We put SIDLEMODE to no-idle for the duration of the transfer,
>  	 * because DSS interrupts are not capable of waking up the CPU and the
> @@ -3800,7 +3800,7 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  		 * for TE is longer than the timer allows */
>  		REG_FLD_MOD(dsi, DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */
>  
> -		dsi_vc_send_bta(dsi, channel);
> +		dsi_vc_send_bta(dsi, vc);
>  
>  #ifdef DSI_CATCH_MISSING_TE
>  		mod_timer(&dsi->te_timer, jiffies + msecs_to_jiffies(250));
> @@ -3882,7 +3882,7 @@ static int _dsi_update(struct dsi_data *dsi)
>  	return 0;
>  }
>  
> -static int _dsi_send_nop(struct dsi_data *dsi, int channel)
> +static int _dsi_send_nop(struct dsi_data *dsi, int vc, int channel)
>  {
>  	const u8 payload[] = { MIPI_DCS_NOP };
>  	const struct mipi_dsi_msg msg = {
> @@ -3894,10 +3894,10 @@ static int _dsi_send_nop(struct dsi_data *dsi, int channel)
>  
>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
> -	return _omap_dsi_host_transfer(dsi, &msg);
> +	return _omap_dsi_host_transfer(dsi, vc, &msg);
>  }
>  
> -static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
> +static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r;
> @@ -3914,17 +3914,17 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int channel)
>  		goto err;
>  	}
>  
> -	DSSDBG("dsi_update_channel: %d", channel);
> +	DSSDBG("dsi_update_channel: %d", vc);
>  
>  	dsi_set_ulps_auto(dsi, false);
>  
> -	r = _dsi_send_nop(dsi, channel);
> +	r = _dsi_send_nop(dsi, vc, dsi->dsidev->channel);
>  	if (r < 0) {
>  		DSSWARN("failed to send nop between frames: %d\n", r);
>  		goto err;
>  	}
>  
> -	dsi->update_channel = channel;
> +	dsi->update_vc = vc;
>  
>  	if (dsi->te_enabled && dsi->te_gpio) {
>  		schedule_delayed_work(&dsi->te_timeout_work,
> @@ -3973,10 +3973,10 @@ static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
>  
>  static int dsi_display_init_dispc(struct dsi_data *dsi)
>  {
> -	enum omap_channel channel = dsi->output.dispc_channel;
> +	enum omap_channel dispc_channel = dsi->output.dispc_channel;
>  	int r;
>  
> -	dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
> +	dss_select_lcd_clk_source(dsi->dss, dispc_channel, dsi->module_id == 0 ?
>  			DSS_CLK_SRC_PLL1_1 :
>  			DSS_CLK_SRC_PLL2_1);
>  
> @@ -4012,19 +4012,19 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
>  		dss_mgr_unregister_framedone_handler(&dsi->output,
>  				dsi_framedone_irq_callback, dsi);
>  err:
> -	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
> +	dss_select_lcd_clk_source(dsi->dss, dispc_channel, DSS_CLK_SRC_FCK);
>  	return r;
>  }
>  
>  static void dsi_display_uninit_dispc(struct dsi_data *dsi)
>  {
> -	enum omap_channel channel = dsi->output.dispc_channel;
> +	enum omap_channel dispc_channel = dsi->output.dispc_channel;
>  
>  	if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
>  		dss_mgr_unregister_framedone_handler(&dsi->output,
>  				dsi_framedone_irq_callback, dsi);
>  
> -	dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
> +	dss_select_lcd_clk_source(dsi->dss, dispc_channel, DSS_CLK_SRC_FCK);
>  }
>  
>  static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
> @@ -4841,12 +4841,12 @@ static int dsi_set_config(struct omap_dss_device *dssdev,
>  }
>  
>  /*
> - * Return a hardcoded channel for the DSI output. This should work for
> + * Return a hardcoded dispc channel for the DSI output. This should work for
>   * current use cases, but this can be later expanded to either resolve
>   * the channel in some more dynamic manner, or get the channel as a user
>   * parameter.
>   */
> -static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
> +static enum omap_channel dsi_get_dispc_channel(struct dsi_data *dsi)
>  {
>  	switch (dsi->data->model) {
>  	case DSI_MODEL_OMAP3:
> @@ -4880,14 +4880,14 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi)
>  	}
>  }
>  
> -static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
> +static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
>  				       const struct mipi_dsi_msg *msg)
>  {
>  	struct omap_dss_device *dssdev = &dsi->output;
>  	int r;
>  
>  	if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode)
> -		dsi_vc_enable_hs(dssdev, msg->channel,
> +		dsi_vc_enable_hs(dssdev, vc,
>  				 !(msg->flags & MIPI_DSI_MSG_USE_LPM));
>  
>  	switch (msg->type) {
> @@ -4900,15 +4900,15 @@ static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi,
>  	case MIPI_DSI_DCS_LONG_WRITE:
>  	case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
>  	case MIPI_DSI_NULL_PACKET:
> -		r = dsi_vc_write_common(dssdev, msg);
> +		r = dsi_vc_write_common(dssdev, vc, msg);
>  		break;
>  	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
>  	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
>  	case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
> -		r = dsi_vc_generic_read(dssdev, msg);
> +		r = dsi_vc_generic_read(dssdev, vc, msg);
>  		break;
>  	case MIPI_DSI_DCS_READ:
> -		r = dsi_vc_dcs_read(dssdev, msg);
> +		r = dsi_vc_dcs_read(dssdev, vc, msg);
>  		break;
>  	default:
>  		r = -EINVAL;
> @@ -4936,12 +4936,13 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
>  {
>  	struct dsi_data *dsi = host_to_omap(host);
>  	int r;
> +	int vc = VC_DEFAULT;
>  
>  	dsi_bus_lock(dsi);
>  
>  	if (dsi->video_enabled) {
>  		dsi_set_ulps_auto(dsi, false);
> -		r = _omap_dsi_host_transfer(dsi, msg);
> +		r = _omap_dsi_host_transfer(dsi, vc, msg);
>  		dsi_set_ulps_auto(dsi, true);
>  	} else {
>  		r = -EIO;
> @@ -5398,7 +5399,7 @@ static int dsi_init_output(struct dsi_data *dsi)
>  
>  	out->type = OMAP_DISPLAY_TYPE_DSI;
>  	out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
> -	out->dispc_channel = dsi_get_channel(dsi);
> +	out->dispc_channel = dsi_get_dispc_channel(dsi);
>  	out->dsi_ops = &dsi_ops;
>  	out->of_port = 0;
>  	out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 65/80] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode
  2020-11-24 12:45 ` [PATCH v4 65/80] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode Tomi Valkeinen
@ 2020-12-01  0:18   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:18 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:23PM +0200, Tomi Valkeinen wrote:
> Simplify and optimize dsi_vc_enable_hs() so that it can be called
> without checking the current HS/LP mode. Make dsi_vc_enable_hs() return
> if the VC is already in the correct mode.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 4ac82166edc3..c3f13226ac26 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -341,7 +341,6 @@ struct dsi_data {
>  	int irq;
>  
>  	bool is_enabled;
> -	bool in_lp_mode;
>  
>  	struct clk *dss_clk;
>  	struct regmap *syscon;
> @@ -2441,6 +2440,9 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
>  
>  	DSSDBG("dsi_vc_enable_hs(%d, %d)\n", vc, enable);
>  
> +	if (REG_GET(dsi, DSI_VC_CTRL(vc), 9, 9) == enable)
> +		return;
> +

I tend to prefer cached state instead of reading it back from the
hardware, as it's (marginally) more efficient. In either case,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
>  	dsi_vc_enable(dsi, vc, 0);
> @@ -2456,8 +2458,6 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
>  	/* start the DDR clock by sending a NULL packet */
>  	if (dsi->vm_timings.ddr_clk_always_on && enable)
>  		dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
> -
> -	dsi->in_lp_mode = !enable;
>  }
>  
>  static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
> @@ -4886,9 +4886,7 @@ static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
>  	struct omap_dss_device *dssdev = &dsi->output;
>  	int r;
>  
> -	if (!!(msg->flags & MIPI_DSI_MSG_USE_LPM) != dsi->in_lp_mode)
> -		dsi_vc_enable_hs(dssdev, vc,
> -				 !(msg->flags & MIPI_DSI_MSG_USE_LPM));
> +	dsi_vc_enable_hs(dssdev, vc, !(msg->flags & MIPI_DSI_MSG_USE_LPM));
>  
>  	switch (msg->type) {
>  	case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 66/80] drm/omap: dsi: set LP/HS before update
  2020-11-24 12:45 ` [PATCH v4 66/80] drm/omap: dsi: set LP/HS before update Tomi Valkeinen
@ 2020-12-01  0:20   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:20 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:24PM +0200, Tomi Valkeinen wrote:
> We currently use a single VC for sending commands and pixel data. The
> LP/HS mode for pixel data is correct by accident, as we have set the VC
> to HS already earlier.
> 
> However, if we use a different VC for video data, the VC is in LP mode.
> Fix this by always setting the LP/HS mode before starting a frame
> update.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index c3f13226ac26..41d6231d6e31 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3918,6 +3918,8 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
>  
>  	dsi_set_ulps_auto(dsi, false);
>  
> +	dsi_vc_enable_hs(dssdev, vc, !(dsi->dsidev->mode_flags & MIPI_DSI_MODE_LPM));
> +
>  	r = _dsi_send_nop(dsi, vc, dsi->dsidev->channel);
>  	if (r < 0) {
>  		DSSWARN("failed to send nop between frames: %d\n", r);

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 67/80] drm/omap: dsi: use separate VCs for cmd and video
  2020-11-24 12:45 ` [PATCH v4 67/80] drm/omap: dsi: use separate VCs for cmd and video Tomi Valkeinen
@ 2020-12-01  0:21   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:21 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:25PM +0200, Tomi Valkeinen wrote:
> For command mode panels we can use a single VC for sending command and
> video data, even if we have to change the data source for that VC when
> going from command to video or vice versa.
> 
> However, with video mode panels we want to keep the pixel data VC
> enabled, and use another VC for command data, and the commands will get
> interleaved into the pixel data.
> 
> This patch makes the driver use VC0 for commands and VC1 for video.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 41d6231d6e31..019814a0a264 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -452,7 +452,9 @@ static bool dsi_perf;
>  module_param(dsi_perf, bool, 0644);
>  #endif
>  
> -#define VC_DEFAULT 0
> +/* Note: for some reason video mode seems to work only if VC_VIDEO is 0 */
> +#define VC_VIDEO	0
> +#define VC_CMD		1
>  
>  #define drm_bridge_to_dsi(bridge) \
>  	container_of(bridge, struct dsi_data, bridge)
> @@ -3723,7 +3725,7 @@ static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
>  	dsi_bus_lock(dsi);
>  	dsi->video_enabled = false;
>  
> -	dsi_disable_video_output(dssdev, VC_DEFAULT);
> +	dsi_disable_video_output(dssdev, VC_VIDEO);
>  
>  	dsi_display_disable(dssdev);
>  
> @@ -3946,7 +3948,7 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
>  
>  static int dsi_update_all(struct omap_dss_device *dssdev)
>  {
> -	return dsi_update_channel(dssdev, VC_DEFAULT);
> +	return dsi_update_channel(dssdev, VC_VIDEO);
>  }
>  
>  /* Display funcs */
> @@ -4179,7 +4181,7 @@ static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
>  
>  	dsi_display_enable(dssdev);
>  
> -	dsi_enable_video_output(dssdev, VC_DEFAULT);
> +	dsi_enable_video_output(dssdev, VC_VIDEO);
>  
>  	dsi->video_enabled = true;
>  
> @@ -4936,7 +4938,7 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
>  {
>  	struct dsi_data *dsi = host_to_omap(host);
>  	int r;
> -	int vc = VC_DEFAULT;
> +	int vc = VC_CMD;
>  
>  	dsi_bus_lock(dsi);
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if'
  2020-11-24 12:45 ` [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
  2020-11-24 17:34   ` Sam Ravnborg
@ 2020-12-01  0:22   ` Laurent Pinchart
  2020-12-01 11:26     ` Tomi Valkeinen
  2020-12-02 20:08   ` kernel test robot
  2 siblings, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:22 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:26PM +0200, Tomi Valkeinen wrote:
> We have a useless 'if' in the dsicm_bl_update_status(), a left over from
> the conversion to DRM model. Drop the if.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index 1e7f73340736..c17ed728c695 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -194,7 +194,7 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata)
>  static int dsicm_bl_update_status(struct backlight_device *dev)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
> -	int r = 0;
> +	int r;
>  	int level;
>  
>  	if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
> @@ -207,11 +207,9 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
>  
>  	mutex_lock(&ddata->lock);
>  
> -	if (ddata->enabled) {
> -		if (!r)
> -			r = dsicm_dcs_write_1(
> -				ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
> -	}
> +	if (ddata->enabled)
> +		r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
> +				      level);

If !ddata->enabled, won't r be uninitialized ?

>  
>  	mutex_unlock(&ddata->lock);
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver
  2020-11-24 12:45 ` [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver Tomi Valkeinen
  2020-11-24 17:35   ` Sam Ravnborg
@ 2020-12-01  0:23   ` Laurent Pinchart
  2020-12-01 11:29     ` Tomi Valkeinen
  1 sibling, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:23 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:27PM +0200, Tomi Valkeinen wrote:
> Add a panel database to the driver instead of reading propertes from DT
> data. This is similar to panel-simple, and I believe it's more future
> safe way to handle the panels.

No need to care about backward compatibility ?

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 107 +++++++++++++++++----------
>  1 file changed, 69 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index c17ed728c695..ec87b785871f 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -22,10 +22,7 @@
>  #include <drm/drm_modes.h>
>  #include <drm/drm_panel.h>
>  
> -#include <video/display_timing.h>
>  #include <video/mipi_display.h>
> -#include <video/of_display_timing.h>
> -#include <video/videomode.h>
>  
>  #define DCS_GET_ID1		0xda
>  #define DCS_GET_ID2		0xdb
> @@ -33,6 +30,18 @@
>  
>  #define DCS_REGULATOR_SUPPLY_NUM 2
>  
> +static const struct of_device_id dsicm_of_match[];
> +
> +struct dsic_panel_data {
> +	u32 xres;
> +	u32 yres;
> +	u32 refresh;
> +	u32 width_mm;
> +	u32 height_mm;
> +	u32 max_hs_rate;
> +	u32 max_lp_rate;
> +};
> +
>  struct panel_drv_data {
>  	struct mipi_dsi_device *dsi;
>  	struct drm_panel panel;
> @@ -48,16 +57,14 @@ struct panel_drv_data {
>  					 */
>  	unsigned long	hw_guard_wait;	/* max guard time in jiffies */
>  
> -	/* panel HW configuration from DT or platform data */
> +	const struct dsic_panel_data *panel_data;
> +
>  	struct gpio_desc *reset_gpio;
>  
>  	struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
>  
>  	bool use_dsi_backlight;
>  
> -	int width_mm;
> -	int height_mm;
> -
>  	/* runtime variables */
>  	bool enabled;
>  
> @@ -455,11 +462,8 @@ static int dsicm_get_modes(struct drm_panel *panel,
>  		return -ENOMEM;
>  	}
>  
> -	drm_mode_set_name(mode);
> -	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> -
> -	connector->display_info.width_mm = ddata->width_mm;
> -	connector->display_info.height_mm = ddata->height_mm;
> +	connector->display_info.width_mm = ddata->panel_data->width_mm;
> +	connector->display_info.height_mm = ddata->panel_data->height_mm;
>  
>  	drm_mode_probed_add(connector, mode);
>  
> @@ -476,15 +480,10 @@ static const struct drm_panel_funcs dsicm_panel_funcs = {
>  
>  static int dsicm_probe_of(struct mipi_dsi_device *dsi)
>  {
> -	struct device_node *node = dsi->dev.of_node;
>  	struct backlight_device *backlight;
>  	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
> -	struct display_timing timing;
> -	struct videomode vm = {
> -		.hactive = 864,
> -		.vactive = 480,
> -	};
>  	int err;
> +	struct drm_display_mode *mode = &ddata->mode;
>  
>  	ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
>  	if (IS_ERR(ddata->reset_gpio)) {
> @@ -493,23 +492,16 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
>  		return err;
>  	}
>  
> -	err = of_get_display_timing(node, "panel-timing", &timing);
> -	if (!err) {
> -		videomode_from_timing(&timing, &vm);
> -	} else {
> -		dev_warn(&dsi->dev,
> -			 "failed to get video timing, using defaults\n");
> -	}
> -
> -	if (!vm.pixelclock)
> -		vm.pixelclock = vm.hactive * vm.vactive * 60;
> -	drm_display_mode_from_videomode(&vm, &ddata->mode);
> -
> -	ddata->width_mm = 0;
> -	of_property_read_u32(node, "width-mm", &ddata->width_mm);
> -
> -	ddata->height_mm = 0;
> -	of_property_read_u32(node, "height-mm", &ddata->height_mm);
> +	mode->hdisplay = mode->hsync_start = mode->hsync_end = mode->htotal =
> +		ddata->panel_data->xres;
> +	mode->vdisplay = mode->vsync_start = mode->vsync_end = mode->vtotal =
> +		ddata->panel_data->yres;
> +	mode->clock = ddata->panel_data->xres * ddata->panel_data->yres *
> +		ddata->panel_data->refresh / 1000;
> +	mode->width_mm = ddata->panel_data->width_mm;
> +	mode->height_mm = ddata->panel_data->height_mm;
> +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> +	drm_mode_set_name(mode);
>  
>  	ddata->supplies[0].supply = "vpnl";
>  	ddata->supplies[1].supply = "vddi";
> @@ -536,6 +528,7 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	struct panel_drv_data *ddata;
>  	struct backlight_device *bldev = NULL;
>  	struct device *dev = &dsi->dev;
> +	const struct of_device_id *id;
>  	int r;
>  
>  	dev_dbg(dev, "probe\n");
> @@ -547,6 +540,12 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	mipi_dsi_set_drvdata(dsi, ddata);
>  	ddata->dsi = dsi;
>  
> +	id = of_match_node(dsicm_of_match, dev->of_node);
> +	if (!id)
> +		return -ENODEV;
> +
> +	ddata->panel_data = id->data;
> +
>  	r = dsicm_probe_of(dsi);
>  	if (r)
>  		return r;
> @@ -583,8 +582,8 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	dsi->format = MIPI_DSI_FMT_RGB888;
>  	dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |
>  			  MIPI_DSI_MODE_EOT_PACKET;
> -	dsi->hs_rate = 300000000;
> -	dsi->lp_rate = 10000000;
> +	dsi->hs_rate = ddata->panel_data->max_hs_rate;
> +	dsi->lp_rate = ddata->panel_data->max_lp_rate;
>  
>  	drm_panel_add(&ddata->panel);
>  
> @@ -622,8 +621,40 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
>  	return 0;
>  }
>  
> +static const struct dsic_panel_data taal_data = {
> +	.xres = 864,
> +	.yres = 480,
> +	.refresh = 60,
> +	.width_mm = 0,
> +	.height_mm = 0,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
> +static const struct dsic_panel_data himalaya_data = {
> +	.xres = 480,
> +	.yres = 864,
> +	.refresh = 60,
> +	.width_mm = 49,
> +	.height_mm = 88,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
> +static const struct dsic_panel_data droid4_data = {
> +	.xres = 540,
> +	.yres = 960,
> +	.refresh = 60,
> +	.width_mm = 50,
> +	.height_mm = 89,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
>  static const struct of_device_id dsicm_of_match[] = {
> -	{ .compatible = "panel-dsi-cm", },
> +	{ .compatible = "tpo,taal", .data = &taal_data },
> +	{ .compatible = "nokia,himalaya", &himalaya_data },
> +	{ .compatible = "motorola,droid4-panel", &droid4_data },
>  	{},
>  };
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes
  2020-11-24 12:45 ` [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes Tomi Valkeinen
  2020-11-24 17:36   ` Sam Ravnborg
@ 2020-12-01  0:27   ` Laurent Pinchart
  2020-12-01 11:33     ` Tomi Valkeinen
  1 sibling, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:27 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:28PM +0200, Tomi Valkeinen wrote:
> Drop unneeded includes.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index ec87b785871f..91ed8237a1c2 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -9,12 +9,7 @@
>  #include <linux/backlight.h>
>  #include <linux/delay.h>
>  #include <linux/gpio/consumer.h>
> -#include <linux/interrupt.h>

This could go to the patch that moves TE handling to the code.

>  #include <linux/jiffies.h>
> -#include <linux/module.h>

I'd keep module.h as you use macros it defines, and we shouldn't depend
in indirect includes.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> -#include <linux/sched/signal.h>
> -#include <linux/slab.h>
> -#include <linux/of_device.h>
>  #include <linux/regulator/consumer.h>
>  
>  #include <drm/drm_connector.h>

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 71/80] drm/omap: dsi: move structs & defines to dsi.h
  2020-11-24 12:45 ` [PATCH v4 71/80] drm/omap: dsi: move structs & defines to dsi.h Tomi Valkeinen
@ 2020-12-01  0:31   ` Laurent Pinchart
  2020-12-01 11:37     ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:31 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:29PM +0200, Tomi Valkeinen wrote:
> Move structs and defines to a private dsi.h header file to make dsi.c a
> bit easier to navigate. Also move the (now) private structs and defines
> from omapdss.h to dsi.h.

I usually tend to keep structures used by a single .c file in that file,
but it's a matter of personal preference I suppose.

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c     | 384 +---------------------
>  drivers/gpu/drm/omapdrm/dss/dsi.h     | 456 ++++++++++++++++++++++++++
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |  64 ----
>  3 files changed, 457 insertions(+), 447 deletions(-)
>  create mode 100644 drivers/gpu/drm/omapdrm/dss/dsi.h
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 019814a0a264..a01e09c9b477 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -45,73 +45,7 @@
>  
>  #define DSI_CATCH_MISSING_TE
>  
> -struct dsi_reg { u16 module; u16 idx; };
> -
> -#define DSI_REG(mod, idx)		((const struct dsi_reg) { mod, idx })
> -
> -/* DSI Protocol Engine */
> -
> -#define DSI_PROTO			0
> -#define DSI_PROTO_SZ			0x200
> -
> -#define DSI_REVISION			DSI_REG(DSI_PROTO, 0x0000)
> -#define DSI_SYSCONFIG			DSI_REG(DSI_PROTO, 0x0010)
> -#define DSI_SYSSTATUS			DSI_REG(DSI_PROTO, 0x0014)
> -#define DSI_IRQSTATUS			DSI_REG(DSI_PROTO, 0x0018)
> -#define DSI_IRQENABLE			DSI_REG(DSI_PROTO, 0x001C)
> -#define DSI_CTRL			DSI_REG(DSI_PROTO, 0x0040)
> -#define DSI_GNQ				DSI_REG(DSI_PROTO, 0x0044)
> -#define DSI_COMPLEXIO_CFG1		DSI_REG(DSI_PROTO, 0x0048)
> -#define DSI_COMPLEXIO_IRQ_STATUS	DSI_REG(DSI_PROTO, 0x004C)
> -#define DSI_COMPLEXIO_IRQ_ENABLE	DSI_REG(DSI_PROTO, 0x0050)
> -#define DSI_CLK_CTRL			DSI_REG(DSI_PROTO, 0x0054)
> -#define DSI_TIMING1			DSI_REG(DSI_PROTO, 0x0058)
> -#define DSI_TIMING2			DSI_REG(DSI_PROTO, 0x005C)
> -#define DSI_VM_TIMING1			DSI_REG(DSI_PROTO, 0x0060)
> -#define DSI_VM_TIMING2			DSI_REG(DSI_PROTO, 0x0064)
> -#define DSI_VM_TIMING3			DSI_REG(DSI_PROTO, 0x0068)
> -#define DSI_CLK_TIMING			DSI_REG(DSI_PROTO, 0x006C)
> -#define DSI_TX_FIFO_VC_SIZE		DSI_REG(DSI_PROTO, 0x0070)
> -#define DSI_RX_FIFO_VC_SIZE		DSI_REG(DSI_PROTO, 0x0074)
> -#define DSI_COMPLEXIO_CFG2		DSI_REG(DSI_PROTO, 0x0078)
> -#define DSI_RX_FIFO_VC_FULLNESS		DSI_REG(DSI_PROTO, 0x007C)
> -#define DSI_VM_TIMING4			DSI_REG(DSI_PROTO, 0x0080)
> -#define DSI_TX_FIFO_VC_EMPTINESS	DSI_REG(DSI_PROTO, 0x0084)
> -#define DSI_VM_TIMING5			DSI_REG(DSI_PROTO, 0x0088)
> -#define DSI_VM_TIMING6			DSI_REG(DSI_PROTO, 0x008C)
> -#define DSI_VM_TIMING7			DSI_REG(DSI_PROTO, 0x0090)
> -#define DSI_STOPCLK_TIMING		DSI_REG(DSI_PROTO, 0x0094)
> -#define DSI_VC_CTRL(n)			DSI_REG(DSI_PROTO, 0x0100 + (n * 0x20))
> -#define DSI_VC_TE(n)			DSI_REG(DSI_PROTO, 0x0104 + (n * 0x20))
> -#define DSI_VC_LONG_PACKET_HEADER(n)	DSI_REG(DSI_PROTO, 0x0108 + (n * 0x20))
> -#define DSI_VC_LONG_PACKET_PAYLOAD(n)	DSI_REG(DSI_PROTO, 0x010C + (n * 0x20))
> -#define DSI_VC_SHORT_PACKET_HEADER(n)	DSI_REG(DSI_PROTO, 0x0110 + (n * 0x20))
> -#define DSI_VC_IRQSTATUS(n)		DSI_REG(DSI_PROTO, 0x0118 + (n * 0x20))
> -#define DSI_VC_IRQENABLE(n)		DSI_REG(DSI_PROTO, 0x011C + (n * 0x20))
> -
> -/* DSIPHY_SCP */
> -
> -#define DSI_PHY				1
> -#define DSI_PHY_OFFSET			0x200
> -#define DSI_PHY_SZ			0x40
> -
> -#define DSI_DSIPHY_CFG0			DSI_REG(DSI_PHY, 0x0000)
> -#define DSI_DSIPHY_CFG1			DSI_REG(DSI_PHY, 0x0004)
> -#define DSI_DSIPHY_CFG2			DSI_REG(DSI_PHY, 0x0008)
> -#define DSI_DSIPHY_CFG5			DSI_REG(DSI_PHY, 0x0014)
> -#define DSI_DSIPHY_CFG10		DSI_REG(DSI_PHY, 0x0028)
> -
> -/* DSI_PLL_CTRL_SCP */
> -
> -#define DSI_PLL				2
> -#define DSI_PLL_OFFSET			0x300
> -#define DSI_PLL_SZ			0x20
> -
> -#define DSI_PLL_CONTROL			DSI_REG(DSI_PLL, 0x0000)
> -#define DSI_PLL_STATUS			DSI_REG(DSI_PLL, 0x0004)
> -#define DSI_PLL_GO			DSI_REG(DSI_PLL, 0x0008)
> -#define DSI_PLL_CONFIGURATION1		DSI_REG(DSI_PLL, 0x000C)
> -#define DSI_PLL_CONFIGURATION2		DSI_REG(DSI_PLL, 0x0010)
> +#include "dsi.h"
>  
>  #define REG_GET(dsi, idx, start, end) \
>  	FLD_GET(dsi_read_reg(dsi, idx), start, end)
> @@ -119,96 +53,6 @@ struct dsi_reg { u16 module; u16 idx; };
>  #define REG_FLD_MOD(dsi, idx, val, start, end) \
>  	dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, end))
>  
> -/* Global interrupts */
> -#define DSI_IRQ_VC0		(1 << 0)
> -#define DSI_IRQ_VC1		(1 << 1)
> -#define DSI_IRQ_VC2		(1 << 2)
> -#define DSI_IRQ_VC3		(1 << 3)
> -#define DSI_IRQ_WAKEUP		(1 << 4)
> -#define DSI_IRQ_RESYNC		(1 << 5)
> -#define DSI_IRQ_PLL_LOCK	(1 << 7)
> -#define DSI_IRQ_PLL_UNLOCK	(1 << 8)
> -#define DSI_IRQ_PLL_RECALL	(1 << 9)
> -#define DSI_IRQ_COMPLEXIO_ERR	(1 << 10)
> -#define DSI_IRQ_HS_TX_TIMEOUT	(1 << 14)
> -#define DSI_IRQ_LP_RX_TIMEOUT	(1 << 15)
> -#define DSI_IRQ_TE_TRIGGER	(1 << 16)
> -#define DSI_IRQ_ACK_TRIGGER	(1 << 17)
> -#define DSI_IRQ_SYNC_LOST	(1 << 18)
> -#define DSI_IRQ_LDO_POWER_GOOD	(1 << 19)
> -#define DSI_IRQ_TA_TIMEOUT	(1 << 20)
> -#define DSI_IRQ_ERROR_MASK \
> -	(DSI_IRQ_HS_TX_TIMEOUT | DSI_IRQ_LP_RX_TIMEOUT | DSI_IRQ_SYNC_LOST | \
> -	DSI_IRQ_TA_TIMEOUT)
> -#define DSI_IRQ_CHANNEL_MASK	0xf
> -
> -/* Virtual channel interrupts */
> -#define DSI_VC_IRQ_CS		(1 << 0)
> -#define DSI_VC_IRQ_ECC_CORR	(1 << 1)
> -#define DSI_VC_IRQ_PACKET_SENT	(1 << 2)
> -#define DSI_VC_IRQ_FIFO_TX_OVF	(1 << 3)
> -#define DSI_VC_IRQ_FIFO_RX_OVF	(1 << 4)
> -#define DSI_VC_IRQ_BTA		(1 << 5)
> -#define DSI_VC_IRQ_ECC_NO_CORR	(1 << 6)
> -#define DSI_VC_IRQ_FIFO_TX_UDF	(1 << 7)
> -#define DSI_VC_IRQ_PP_BUSY_CHANGE (1 << 8)
> -#define DSI_VC_IRQ_ERROR_MASK \
> -	(DSI_VC_IRQ_CS | DSI_VC_IRQ_ECC_CORR | DSI_VC_IRQ_FIFO_TX_OVF | \
> -	DSI_VC_IRQ_FIFO_RX_OVF | DSI_VC_IRQ_ECC_NO_CORR | \
> -	DSI_VC_IRQ_FIFO_TX_UDF)
> -
> -/* ComplexIO interrupts */
> -#define DSI_CIO_IRQ_ERRSYNCESC1		(1 << 0)
> -#define DSI_CIO_IRQ_ERRSYNCESC2		(1 << 1)
> -#define DSI_CIO_IRQ_ERRSYNCESC3		(1 << 2)
> -#define DSI_CIO_IRQ_ERRSYNCESC4		(1 << 3)
> -#define DSI_CIO_IRQ_ERRSYNCESC5		(1 << 4)
> -#define DSI_CIO_IRQ_ERRESC1		(1 << 5)
> -#define DSI_CIO_IRQ_ERRESC2		(1 << 6)
> -#define DSI_CIO_IRQ_ERRESC3		(1 << 7)
> -#define DSI_CIO_IRQ_ERRESC4		(1 << 8)
> -#define DSI_CIO_IRQ_ERRESC5		(1 << 9)
> -#define DSI_CIO_IRQ_ERRCONTROL1		(1 << 10)
> -#define DSI_CIO_IRQ_ERRCONTROL2		(1 << 11)
> -#define DSI_CIO_IRQ_ERRCONTROL3		(1 << 12)
> -#define DSI_CIO_IRQ_ERRCONTROL4		(1 << 13)
> -#define DSI_CIO_IRQ_ERRCONTROL5		(1 << 14)
> -#define DSI_CIO_IRQ_STATEULPS1		(1 << 15)
> -#define DSI_CIO_IRQ_STATEULPS2		(1 << 16)
> -#define DSI_CIO_IRQ_STATEULPS3		(1 << 17)
> -#define DSI_CIO_IRQ_STATEULPS4		(1 << 18)
> -#define DSI_CIO_IRQ_STATEULPS5		(1 << 19)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP0_1	(1 << 20)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP1_1	(1 << 21)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP0_2	(1 << 22)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP1_2	(1 << 23)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP0_3	(1 << 24)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP1_3	(1 << 25)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP0_4	(1 << 26)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP1_4	(1 << 27)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP0_5	(1 << 28)
> -#define DSI_CIO_IRQ_ERRCONTENTIONLP1_5	(1 << 29)
> -#define DSI_CIO_IRQ_ULPSACTIVENOT_ALL0	(1 << 30)
> -#define DSI_CIO_IRQ_ULPSACTIVENOT_ALL1	(1 << 31)
> -#define DSI_CIO_IRQ_ERROR_MASK \
> -	(DSI_CIO_IRQ_ERRSYNCESC1 | DSI_CIO_IRQ_ERRSYNCESC2 | \
> -	 DSI_CIO_IRQ_ERRSYNCESC3 | DSI_CIO_IRQ_ERRSYNCESC4 | \
> -	 DSI_CIO_IRQ_ERRSYNCESC5 | \
> -	 DSI_CIO_IRQ_ERRESC1 | DSI_CIO_IRQ_ERRESC2 | \
> -	 DSI_CIO_IRQ_ERRESC3 | DSI_CIO_IRQ_ERRESC4 | \
> -	 DSI_CIO_IRQ_ERRESC5 | \
> -	 DSI_CIO_IRQ_ERRCONTROL1 | DSI_CIO_IRQ_ERRCONTROL2 | \
> -	 DSI_CIO_IRQ_ERRCONTROL3 | DSI_CIO_IRQ_ERRCONTROL4 | \
> -	 DSI_CIO_IRQ_ERRCONTROL5 | \
> -	 DSI_CIO_IRQ_ERRCONTENTIONLP0_1 | DSI_CIO_IRQ_ERRCONTENTIONLP1_1 | \
> -	 DSI_CIO_IRQ_ERRCONTENTIONLP0_2 | DSI_CIO_IRQ_ERRCONTENTIONLP1_2 | \
> -	 DSI_CIO_IRQ_ERRCONTENTIONLP0_3 | DSI_CIO_IRQ_ERRCONTENTIONLP1_3 | \
> -	 DSI_CIO_IRQ_ERRCONTENTIONLP0_4 | DSI_CIO_IRQ_ERRCONTENTIONLP1_4 | \
> -	 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
> -
> -typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
> -struct dsi_data;
> -
>  static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
>  
>  static int dsi_display_init_dispc(struct dsi_data *dsi);
> @@ -221,232 +65,6 @@ static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
>  
>  static void dsi_display_disable(struct omap_dss_device *dssdev);
>  
> -/* DSI PLL HSDIV indices */
> -#define HSDIV_DISPC	0
> -#define HSDIV_DSI	1
> -
> -#define DSI_MAX_NR_ISRS                2
> -#define DSI_MAX_NR_LANES	5
> -
> -enum dsi_model {
> -	DSI_MODEL_OMAP3,
> -	DSI_MODEL_OMAP4,
> -	DSI_MODEL_OMAP5,
> -};
> -
> -enum dsi_lane_function {
> -	DSI_LANE_UNUSED	= 0,
> -	DSI_LANE_CLK,
> -	DSI_LANE_DATA1,
> -	DSI_LANE_DATA2,
> -	DSI_LANE_DATA3,
> -	DSI_LANE_DATA4,
> -};
> -
> -struct dsi_lane_config {
> -	enum dsi_lane_function function;
> -	u8 polarity;
> -};
> -
> -struct dsi_isr_data {
> -	omap_dsi_isr_t	isr;
> -	void		*arg;
> -	u32		mask;
> -};
> -
> -enum fifo_size {
> -	DSI_FIFO_SIZE_0		= 0,
> -	DSI_FIFO_SIZE_32	= 1,
> -	DSI_FIFO_SIZE_64	= 2,
> -	DSI_FIFO_SIZE_96	= 3,
> -	DSI_FIFO_SIZE_128	= 4,
> -};
> -
> -enum dsi_vc_source {
> -	DSI_VC_SOURCE_L4 = 0,
> -	DSI_VC_SOURCE_VP,
> -};
> -
> -struct dsi_irq_stats {
> -	unsigned long last_reset;
> -	unsigned int irq_count;
> -	unsigned int dsi_irqs[32];
> -	unsigned int vc_irqs[4][32];
> -	unsigned int cio_irqs[32];
> -};
> -
> -struct dsi_isr_tables {
> -	struct dsi_isr_data isr_table[DSI_MAX_NR_ISRS];
> -	struct dsi_isr_data isr_table_vc[4][DSI_MAX_NR_ISRS];
> -	struct dsi_isr_data isr_table_cio[DSI_MAX_NR_ISRS];
> -};
> -
> -struct dsi_lp_clock_info {
> -	unsigned long lp_clk;
> -	u16 lp_clk_div;
> -};
> -
> -struct dsi_clk_calc_ctx {
> -	struct dsi_data *dsi;
> -	struct dss_pll *pll;
> -
> -	/* inputs */
> -
> -	const struct omap_dss_dsi_config *config;
> -
> -	unsigned long req_pck_min, req_pck_nom, req_pck_max;
> -
> -	/* outputs */
> -
> -	struct dss_pll_clock_info dsi_cinfo;
> -	struct dispc_clock_info dispc_cinfo;
> -	struct dsi_lp_clock_info lp_cinfo;
> -
> -	struct videomode vm;
> -	struct omap_dss_dsi_videomode_timings dsi_vm;
> -};
> -
> -struct dsi_module_id_data {
> -	u32 address;
> -	int id;
> -};
> -
> -enum dsi_quirks {
> -	DSI_QUIRK_PLL_PWR_BUG = (1 << 0),	/* DSI-PLL power command 0x3 is not working */
> -	DSI_QUIRK_DCS_CMD_CONFIG_VC = (1 << 1),
> -	DSI_QUIRK_VC_OCP_WIDTH = (1 << 2),
> -	DSI_QUIRK_REVERSE_TXCLKESC = (1 << 3),
> -	DSI_QUIRK_GNQ = (1 << 4),
> -	DSI_QUIRK_PHY_DCC = (1 << 5),
> -};
> -
> -struct dsi_of_data {
> -	enum dsi_model model;
> -	const struct dss_pll_hw *pll_hw;
> -	const struct dsi_module_id_data *modules;
> -	unsigned int max_fck_freq;
> -	unsigned int max_pll_lpdiv;
> -	enum dsi_quirks quirks;
> -};
> -
> -struct dsi_data {
> -	struct device *dev;
> -	void __iomem *proto_base;
> -	void __iomem *phy_base;
> -	void __iomem *pll_base;
> -
> -	const struct dsi_of_data *data;
> -	int module_id;
> -
> -	int irq;
> -
> -	bool is_enabled;
> -
> -	struct clk *dss_clk;
> -	struct regmap *syscon;
> -	struct dss_device *dss;
> -
> -	struct mipi_dsi_host host;
> -
> -	struct dispc_clock_info user_dispc_cinfo;
> -	struct dss_pll_clock_info user_dsi_cinfo;
> -
> -	struct dsi_lp_clock_info user_lp_cinfo;
> -	struct dsi_lp_clock_info current_lp_cinfo;
> -
> -	struct dss_pll pll;
> -
> -	bool vdds_dsi_enabled;
> -	struct regulator *vdds_dsi_reg;
> -
> -	struct mipi_dsi_device *dsidev;
> -
> -	struct {
> -		enum dsi_vc_source source;
> -		enum fifo_size tx_fifo_size;
> -		enum fifo_size rx_fifo_size;
> -	} vc[4];
> -
> -	struct mutex lock;
> -	struct semaphore bus_lock;
> -
> -	spinlock_t irq_lock;
> -	struct dsi_isr_tables isr_tables;
> -	/* space for a copy used by the interrupt handler */
> -	struct dsi_isr_tables isr_tables_copy;
> -
> -	int update_vc;
> -#ifdef DSI_PERF_MEASURE
> -	unsigned int update_bytes;
> -#endif
> -
> -	/* external TE GPIO */
> -	struct gpio_desc *te_gpio;
> -	int te_irq;
> -	struct delayed_work te_timeout_work;
> -	atomic_t do_ext_te_update;
> -
> -	bool te_enabled;
> -	bool ulps_enabled;
> -	bool ulps_auto_idle;
> -	bool video_enabled;
> -
> -	struct delayed_work ulps_work;
> -
> -	struct delayed_work framedone_timeout_work;
> -
> -#ifdef DSI_CATCH_MISSING_TE
> -	struct timer_list te_timer;
> -#endif
> -
> -	unsigned long cache_req_pck;
> -	unsigned long cache_clk_freq;
> -	struct dss_pll_clock_info cache_cinfo;
> -
> -	u32		errors;
> -	spinlock_t	errors_lock;
> -#ifdef DSI_PERF_MEASURE
> -	ktime_t perf_setup_time;
> -	ktime_t perf_start_time;
> -#endif
> -	int debug_read;
> -	int debug_write;
> -	struct {
> -		struct dss_debugfs_entry *irqs;
> -		struct dss_debugfs_entry *regs;
> -		struct dss_debugfs_entry *clks;
> -	} debugfs;
> -
> -#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
> -	spinlock_t irq_stats_lock;
> -	struct dsi_irq_stats irq_stats;
> -#endif
> -
> -	unsigned int num_lanes_supported;
> -	unsigned int line_buffer_size;
> -
> -	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
> -	unsigned int num_lanes_used;
> -
> -	unsigned int scp_clk_refcount;
> -
> -	struct omap_dss_dsi_config config;
> -
> -	struct dss_lcd_mgr_config mgr_config;
> -	struct videomode vm;
> -	enum mipi_dsi_pixel_format pix_fmt;
> -	enum omap_dss_dsi_mode mode;
> -	struct omap_dss_dsi_videomode_timings vm_timings;
> -
> -	struct omap_dss_device output;
> -	struct drm_bridge bridge;
> -};
> -
> -struct dsi_packet_sent_handler_data {
> -	struct dsi_data *dsi;
> -	struct completion *completion;
> -};
> -
>  #ifdef DSI_PERF_MEASURE
>  static bool dsi_perf;
>  module_param(dsi_perf, bool, 0644);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h b/drivers/gpu/drm/omapdrm/dss/dsi.h
> new file mode 100644
> index 000000000000..7cc2cc748ed9
> --- /dev/null
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
> @@ -0,0 +1,456 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
> + * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
> + */
> +
> +#ifndef __OMAP_DRM_DSS_DSI_H
> +#define __OMAP_DRM_DSS_DSI_H
> +
> +#include <drm/drm_mipi_dsi.h>
> +
> +struct dsi_reg { u16 module; u16 idx; };

How about using the common kernel coding style ?

struct dsi_reg {
	u16 module;
	u16 idx;
};

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +
> +#define DSI_REG(mod, idx)		((const struct dsi_reg) { mod, idx })
> +
> +/* DSI Protocol Engine */
> +
> +#define DSI_PROTO			0
> +#define DSI_PROTO_SZ			0x200
> +
> +#define DSI_REVISION			DSI_REG(DSI_PROTO, 0x0000)
> +#define DSI_SYSCONFIG			DSI_REG(DSI_PROTO, 0x0010)
> +#define DSI_SYSSTATUS			DSI_REG(DSI_PROTO, 0x0014)
> +#define DSI_IRQSTATUS			DSI_REG(DSI_PROTO, 0x0018)
> +#define DSI_IRQENABLE			DSI_REG(DSI_PROTO, 0x001C)
> +#define DSI_CTRL			DSI_REG(DSI_PROTO, 0x0040)
> +#define DSI_GNQ				DSI_REG(DSI_PROTO, 0x0044)
> +#define DSI_COMPLEXIO_CFG1		DSI_REG(DSI_PROTO, 0x0048)
> +#define DSI_COMPLEXIO_IRQ_STATUS	DSI_REG(DSI_PROTO, 0x004C)
> +#define DSI_COMPLEXIO_IRQ_ENABLE	DSI_REG(DSI_PROTO, 0x0050)
> +#define DSI_CLK_CTRL			DSI_REG(DSI_PROTO, 0x0054)
> +#define DSI_TIMING1			DSI_REG(DSI_PROTO, 0x0058)
> +#define DSI_TIMING2			DSI_REG(DSI_PROTO, 0x005C)
> +#define DSI_VM_TIMING1			DSI_REG(DSI_PROTO, 0x0060)
> +#define DSI_VM_TIMING2			DSI_REG(DSI_PROTO, 0x0064)
> +#define DSI_VM_TIMING3			DSI_REG(DSI_PROTO, 0x0068)
> +#define DSI_CLK_TIMING			DSI_REG(DSI_PROTO, 0x006C)
> +#define DSI_TX_FIFO_VC_SIZE		DSI_REG(DSI_PROTO, 0x0070)
> +#define DSI_RX_FIFO_VC_SIZE		DSI_REG(DSI_PROTO, 0x0074)
> +#define DSI_COMPLEXIO_CFG2		DSI_REG(DSI_PROTO, 0x0078)
> +#define DSI_RX_FIFO_VC_FULLNESS		DSI_REG(DSI_PROTO, 0x007C)
> +#define DSI_VM_TIMING4			DSI_REG(DSI_PROTO, 0x0080)
> +#define DSI_TX_FIFO_VC_EMPTINESS	DSI_REG(DSI_PROTO, 0x0084)
> +#define DSI_VM_TIMING5			DSI_REG(DSI_PROTO, 0x0088)
> +#define DSI_VM_TIMING6			DSI_REG(DSI_PROTO, 0x008C)
> +#define DSI_VM_TIMING7			DSI_REG(DSI_PROTO, 0x0090)
> +#define DSI_STOPCLK_TIMING		DSI_REG(DSI_PROTO, 0x0094)
> +#define DSI_VC_CTRL(n)			DSI_REG(DSI_PROTO, 0x0100 + (n * 0x20))
> +#define DSI_VC_TE(n)			DSI_REG(DSI_PROTO, 0x0104 + (n * 0x20))
> +#define DSI_VC_LONG_PACKET_HEADER(n)	DSI_REG(DSI_PROTO, 0x0108 + (n * 0x20))
> +#define DSI_VC_LONG_PACKET_PAYLOAD(n)	DSI_REG(DSI_PROTO, 0x010C + (n * 0x20))
> +#define DSI_VC_SHORT_PACKET_HEADER(n)	DSI_REG(DSI_PROTO, 0x0110 + (n * 0x20))
> +#define DSI_VC_IRQSTATUS(n)		DSI_REG(DSI_PROTO, 0x0118 + (n * 0x20))
> +#define DSI_VC_IRQENABLE(n)		DSI_REG(DSI_PROTO, 0x011C + (n * 0x20))
> +
> +/* DSIPHY_SCP */
> +
> +#define DSI_PHY				1
> +#define DSI_PHY_OFFSET			0x200
> +#define DSI_PHY_SZ			0x40
> +
> +#define DSI_DSIPHY_CFG0			DSI_REG(DSI_PHY, 0x0000)
> +#define DSI_DSIPHY_CFG1			DSI_REG(DSI_PHY, 0x0004)
> +#define DSI_DSIPHY_CFG2			DSI_REG(DSI_PHY, 0x0008)
> +#define DSI_DSIPHY_CFG5			DSI_REG(DSI_PHY, 0x0014)
> +#define DSI_DSIPHY_CFG10		DSI_REG(DSI_PHY, 0x0028)
> +
> +/* DSI_PLL_CTRL_SCP */
> +
> +#define DSI_PLL				2
> +#define DSI_PLL_OFFSET			0x300
> +#define DSI_PLL_SZ			0x20
> +
> +#define DSI_PLL_CONTROL			DSI_REG(DSI_PLL, 0x0000)
> +#define DSI_PLL_STATUS			DSI_REG(DSI_PLL, 0x0004)
> +#define DSI_PLL_GO			DSI_REG(DSI_PLL, 0x0008)
> +#define DSI_PLL_CONFIGURATION1		DSI_REG(DSI_PLL, 0x000C)
> +#define DSI_PLL_CONFIGURATION2		DSI_REG(DSI_PLL, 0x0010)
> +
> +/* Global interrupts */
> +#define DSI_IRQ_VC0		(1 << 0)
> +#define DSI_IRQ_VC1		(1 << 1)
> +#define DSI_IRQ_VC2		(1 << 2)
> +#define DSI_IRQ_VC3		(1 << 3)
> +#define DSI_IRQ_WAKEUP		(1 << 4)
> +#define DSI_IRQ_RESYNC		(1 << 5)
> +#define DSI_IRQ_PLL_LOCK	(1 << 7)
> +#define DSI_IRQ_PLL_UNLOCK	(1 << 8)
> +#define DSI_IRQ_PLL_RECALL	(1 << 9)
> +#define DSI_IRQ_COMPLEXIO_ERR	(1 << 10)
> +#define DSI_IRQ_HS_TX_TIMEOUT	(1 << 14)
> +#define DSI_IRQ_LP_RX_TIMEOUT	(1 << 15)
> +#define DSI_IRQ_TE_TRIGGER	(1 << 16)
> +#define DSI_IRQ_ACK_TRIGGER	(1 << 17)
> +#define DSI_IRQ_SYNC_LOST	(1 << 18)
> +#define DSI_IRQ_LDO_POWER_GOOD	(1 << 19)
> +#define DSI_IRQ_TA_TIMEOUT	(1 << 20)
> +#define DSI_IRQ_ERROR_MASK \
> +	(DSI_IRQ_HS_TX_TIMEOUT | DSI_IRQ_LP_RX_TIMEOUT | DSI_IRQ_SYNC_LOST | \
> +	DSI_IRQ_TA_TIMEOUT)
> +#define DSI_IRQ_CHANNEL_MASK	0xf
> +
> +/* Virtual channel interrupts */
> +#define DSI_VC_IRQ_CS		(1 << 0)
> +#define DSI_VC_IRQ_ECC_CORR	(1 << 1)
> +#define DSI_VC_IRQ_PACKET_SENT	(1 << 2)
> +#define DSI_VC_IRQ_FIFO_TX_OVF	(1 << 3)
> +#define DSI_VC_IRQ_FIFO_RX_OVF	(1 << 4)
> +#define DSI_VC_IRQ_BTA		(1 << 5)
> +#define DSI_VC_IRQ_ECC_NO_CORR	(1 << 6)
> +#define DSI_VC_IRQ_FIFO_TX_UDF	(1 << 7)
> +#define DSI_VC_IRQ_PP_BUSY_CHANGE (1 << 8)
> +#define DSI_VC_IRQ_ERROR_MASK \
> +	(DSI_VC_IRQ_CS | DSI_VC_IRQ_ECC_CORR | DSI_VC_IRQ_FIFO_TX_OVF | \
> +	DSI_VC_IRQ_FIFO_RX_OVF | DSI_VC_IRQ_ECC_NO_CORR | \
> +	DSI_VC_IRQ_FIFO_TX_UDF)
> +
> +/* ComplexIO interrupts */
> +#define DSI_CIO_IRQ_ERRSYNCESC1		(1 << 0)
> +#define DSI_CIO_IRQ_ERRSYNCESC2		(1 << 1)
> +#define DSI_CIO_IRQ_ERRSYNCESC3		(1 << 2)
> +#define DSI_CIO_IRQ_ERRSYNCESC4		(1 << 3)
> +#define DSI_CIO_IRQ_ERRSYNCESC5		(1 << 4)
> +#define DSI_CIO_IRQ_ERRESC1		(1 << 5)
> +#define DSI_CIO_IRQ_ERRESC2		(1 << 6)
> +#define DSI_CIO_IRQ_ERRESC3		(1 << 7)
> +#define DSI_CIO_IRQ_ERRESC4		(1 << 8)
> +#define DSI_CIO_IRQ_ERRESC5		(1 << 9)
> +#define DSI_CIO_IRQ_ERRCONTROL1		(1 << 10)
> +#define DSI_CIO_IRQ_ERRCONTROL2		(1 << 11)
> +#define DSI_CIO_IRQ_ERRCONTROL3		(1 << 12)
> +#define DSI_CIO_IRQ_ERRCONTROL4		(1 << 13)
> +#define DSI_CIO_IRQ_ERRCONTROL5		(1 << 14)
> +#define DSI_CIO_IRQ_STATEULPS1		(1 << 15)
> +#define DSI_CIO_IRQ_STATEULPS2		(1 << 16)
> +#define DSI_CIO_IRQ_STATEULPS3		(1 << 17)
> +#define DSI_CIO_IRQ_STATEULPS4		(1 << 18)
> +#define DSI_CIO_IRQ_STATEULPS5		(1 << 19)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP0_1	(1 << 20)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP1_1	(1 << 21)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP0_2	(1 << 22)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP1_2	(1 << 23)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP0_3	(1 << 24)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP1_3	(1 << 25)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP0_4	(1 << 26)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP1_4	(1 << 27)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP0_5	(1 << 28)
> +#define DSI_CIO_IRQ_ERRCONTENTIONLP1_5	(1 << 29)
> +#define DSI_CIO_IRQ_ULPSACTIVENOT_ALL0	(1 << 30)
> +#define DSI_CIO_IRQ_ULPSACTIVENOT_ALL1	(1 << 31)
> +#define DSI_CIO_IRQ_ERROR_MASK \
> +	(DSI_CIO_IRQ_ERRSYNCESC1 | DSI_CIO_IRQ_ERRSYNCESC2 | \
> +	 DSI_CIO_IRQ_ERRSYNCESC3 | DSI_CIO_IRQ_ERRSYNCESC4 | \
> +	 DSI_CIO_IRQ_ERRSYNCESC5 | \
> +	 DSI_CIO_IRQ_ERRESC1 | DSI_CIO_IRQ_ERRESC2 | \
> +	 DSI_CIO_IRQ_ERRESC3 | DSI_CIO_IRQ_ERRESC4 | \
> +	 DSI_CIO_IRQ_ERRESC5 | \
> +	 DSI_CIO_IRQ_ERRCONTROL1 | DSI_CIO_IRQ_ERRCONTROL2 | \
> +	 DSI_CIO_IRQ_ERRCONTROL3 | DSI_CIO_IRQ_ERRCONTROL4 | \
> +	 DSI_CIO_IRQ_ERRCONTROL5 | \
> +	 DSI_CIO_IRQ_ERRCONTENTIONLP0_1 | DSI_CIO_IRQ_ERRCONTENTIONLP1_1 | \
> +	 DSI_CIO_IRQ_ERRCONTENTIONLP0_2 | DSI_CIO_IRQ_ERRCONTENTIONLP1_2 | \
> +	 DSI_CIO_IRQ_ERRCONTENTIONLP0_3 | DSI_CIO_IRQ_ERRCONTENTIONLP1_3 | \
> +	 DSI_CIO_IRQ_ERRCONTENTIONLP0_4 | DSI_CIO_IRQ_ERRCONTENTIONLP1_4 | \
> +	 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
> +
> +enum omap_dss_dsi_mode {
> +	OMAP_DSS_DSI_CMD_MODE = 0,
> +	OMAP_DSS_DSI_VIDEO_MODE,
> +};
> +
> +enum omap_dss_dsi_trans_mode {
> +	/* Sync Pulses: both sync start and end packets sent */
> +	OMAP_DSS_DSI_PULSE_MODE,
> +	/* Sync Events: only sync start packets sent */
> +	OMAP_DSS_DSI_EVENT_MODE,
> +	/* Burst: only sync start packets sent, pixels are time compressed */
> +	OMAP_DSS_DSI_BURST_MODE,
> +};
> +
> +struct omap_dss_dsi_videomode_timings {
> +	unsigned long hsclk;
> +
> +	unsigned int ndl;
> +	unsigned int bitspp;
> +
> +	/* pixels */
> +	u16 hact;
> +	/* lines */
> +	u16 vact;
> +
> +	/* DSI video mode blanking data */
> +	/* Unit: byte clock cycles */
> +	u16 hss;
> +	u16 hsa;
> +	u16 hse;
> +	u16 hfp;
> +	u16 hbp;
> +	/* Unit: line clocks */
> +	u16 vsa;
> +	u16 vfp;
> +	u16 vbp;
> +
> +	/* DSI blanking modes */
> +	int blanking_mode;
> +	int hsa_blanking_mode;
> +	int hbp_blanking_mode;
> +	int hfp_blanking_mode;
> +
> +	enum omap_dss_dsi_trans_mode trans_mode;
> +
> +	bool ddr_clk_always_on;
> +	int window_sync;
> +};
> +
> +struct omap_dss_dsi_config {
> +	enum omap_dss_dsi_mode mode;
> +	enum mipi_dsi_pixel_format pixel_format;
> +	const struct videomode *vm;
> +
> +	unsigned long hs_clk_min, hs_clk_max;
> +	unsigned long lp_clk_min, lp_clk_max;
> +
> +	bool ddr_clk_always_on;
> +	enum omap_dss_dsi_trans_mode trans_mode;
> +};
> +
> +/* DSI PLL HSDIV indices */
> +#define HSDIV_DISPC	0
> +#define HSDIV_DSI	1
> +
> +#define DSI_MAX_NR_ISRS                2
> +#define DSI_MAX_NR_LANES	5
> +
> +enum dsi_model {
> +	DSI_MODEL_OMAP3,
> +	DSI_MODEL_OMAP4,
> +	DSI_MODEL_OMAP5,
> +};
> +
> +enum dsi_lane_function {
> +	DSI_LANE_UNUSED	= 0,
> +	DSI_LANE_CLK,
> +	DSI_LANE_DATA1,
> +	DSI_LANE_DATA2,
> +	DSI_LANE_DATA3,
> +	DSI_LANE_DATA4,
> +};
> +
> +struct dsi_lane_config {
> +	enum dsi_lane_function function;
> +	u8 polarity;
> +};
> +
> +typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
> +
> +struct dsi_isr_data {
> +	omap_dsi_isr_t	isr;
> +	void		*arg;
> +	u32		mask;
> +};
> +
> +enum fifo_size {
> +	DSI_FIFO_SIZE_0		= 0,
> +	DSI_FIFO_SIZE_32	= 1,
> +	DSI_FIFO_SIZE_64	= 2,
> +	DSI_FIFO_SIZE_96	= 3,
> +	DSI_FIFO_SIZE_128	= 4,
> +};
> +
> +enum dsi_vc_source {
> +	DSI_VC_SOURCE_L4 = 0,
> +	DSI_VC_SOURCE_VP,
> +};
> +
> +struct dsi_irq_stats {
> +	unsigned long last_reset;
> +	unsigned int irq_count;
> +	unsigned int dsi_irqs[32];
> +	unsigned int vc_irqs[4][32];
> +	unsigned int cio_irqs[32];
> +};
> +
> +struct dsi_isr_tables {
> +	struct dsi_isr_data isr_table[DSI_MAX_NR_ISRS];
> +	struct dsi_isr_data isr_table_vc[4][DSI_MAX_NR_ISRS];
> +	struct dsi_isr_data isr_table_cio[DSI_MAX_NR_ISRS];
> +};
> +
> +struct dsi_lp_clock_info {
> +	unsigned long lp_clk;
> +	u16 lp_clk_div;
> +};
> +
> +struct dsi_clk_calc_ctx {
> +	struct dsi_data *dsi;
> +	struct dss_pll *pll;
> +
> +	/* inputs */
> +
> +	const struct omap_dss_dsi_config *config;
> +
> +	unsigned long req_pck_min, req_pck_nom, req_pck_max;
> +
> +	/* outputs */
> +
> +	struct dss_pll_clock_info dsi_cinfo;
> +	struct dispc_clock_info dispc_cinfo;
> +	struct dsi_lp_clock_info lp_cinfo;
> +
> +	struct videomode vm;
> +	struct omap_dss_dsi_videomode_timings dsi_vm;
> +};
> +
> +struct dsi_module_id_data {
> +	u32 address;
> +	int id;
> +};
> +
> +enum dsi_quirks {
> +	DSI_QUIRK_PLL_PWR_BUG = (1 << 0),	/* DSI-PLL power command 0x3 is not working */
> +	DSI_QUIRK_DCS_CMD_CONFIG_VC = (1 << 1),
> +	DSI_QUIRK_VC_OCP_WIDTH = (1 << 2),
> +	DSI_QUIRK_REVERSE_TXCLKESC = (1 << 3),
> +	DSI_QUIRK_GNQ = (1 << 4),
> +	DSI_QUIRK_PHY_DCC = (1 << 5),
> +};
> +
> +struct dsi_of_data {
> +	enum dsi_model model;
> +	const struct dss_pll_hw *pll_hw;
> +	const struct dsi_module_id_data *modules;
> +	unsigned int max_fck_freq;
> +	unsigned int max_pll_lpdiv;
> +	enum dsi_quirks quirks;
> +};
> +
> +struct dsi_data {
> +	struct device *dev;
> +	void __iomem *proto_base;
> +	void __iomem *phy_base;
> +	void __iomem *pll_base;
> +
> +	const struct dsi_of_data *data;
> +	int module_id;
> +
> +	int irq;
> +
> +	bool is_enabled;
> +
> +	struct clk *dss_clk;
> +	struct regmap *syscon;
> +	struct dss_device *dss;
> +
> +	struct mipi_dsi_host host;
> +
> +	struct dispc_clock_info user_dispc_cinfo;
> +	struct dss_pll_clock_info user_dsi_cinfo;
> +
> +	struct dsi_lp_clock_info user_lp_cinfo;
> +	struct dsi_lp_clock_info current_lp_cinfo;
> +
> +	struct dss_pll pll;
> +
> +	bool vdds_dsi_enabled;
> +	struct regulator *vdds_dsi_reg;
> +
> +	struct mipi_dsi_device *dsidev;
> +
> +	struct {
> +		enum dsi_vc_source source;
> +		enum fifo_size tx_fifo_size;
> +		enum fifo_size rx_fifo_size;
> +	} vc[4];
> +
> +	struct mutex lock;
> +	struct semaphore bus_lock;
> +
> +	spinlock_t irq_lock;
> +	struct dsi_isr_tables isr_tables;
> +	/* space for a copy used by the interrupt handler */
> +	struct dsi_isr_tables isr_tables_copy;
> +
> +	int update_vc;
> +#ifdef DSI_PERF_MEASURE
> +	unsigned int update_bytes;
> +#endif
> +
> +	/* external TE GPIO */
> +	struct gpio_desc *te_gpio;
> +	int te_irq;
> +	struct delayed_work te_timeout_work;
> +	atomic_t do_ext_te_update;
> +
> +	bool te_enabled;
> +	bool ulps_enabled;
> +	bool ulps_auto_idle;
> +	bool video_enabled;
> +
> +	struct delayed_work ulps_work;
> +
> +	struct delayed_work framedone_timeout_work;
> +
> +#ifdef DSI_CATCH_MISSING_TE
> +	struct timer_list te_timer;
> +#endif
> +
> +	unsigned long cache_req_pck;
> +	unsigned long cache_clk_freq;
> +	struct dss_pll_clock_info cache_cinfo;
> +
> +	u32		errors;
> +	spinlock_t	errors_lock;
> +#ifdef DSI_PERF_MEASURE
> +	ktime_t perf_setup_time;
> +	ktime_t perf_start_time;
> +#endif
> +	int debug_read;
> +	int debug_write;
> +	struct {
> +		struct dss_debugfs_entry *irqs;
> +		struct dss_debugfs_entry *regs;
> +		struct dss_debugfs_entry *clks;
> +	} debugfs;
> +
> +#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
> +	spinlock_t irq_stats_lock;
> +	struct dsi_irq_stats irq_stats;
> +#endif
> +
> +	unsigned int num_lanes_supported;
> +	unsigned int line_buffer_size;
> +
> +	struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
> +	unsigned int num_lanes_used;
> +
> +	unsigned int scp_clk_refcount;
> +
> +	struct omap_dss_dsi_config config;
> +
> +	struct dss_lcd_mgr_config mgr_config;
> +	struct videomode vm;
> +	enum mipi_dsi_pixel_format pix_fmt;
> +	enum omap_dss_dsi_mode mode;
> +	struct omap_dss_dsi_videomode_timings vm_timings;
> +
> +	struct omap_dss_device output;
> +	struct drm_bridge bridge;
> +};
> +
> +struct dsi_packet_sent_handler_data {
> +	struct dsi_data *dsi;
> +	struct completion *completion;
> +};
> +
> +#endif /* __OMAP_DRM_DSS_DSI_H */
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 9df322ca467d..6ecaa060ff4b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -14,7 +14,6 @@
>  #include <linux/platform_data/omapdss.h>
>  
>  #include <drm/drm_crtc.h>
> -#include <drm/drm_mipi_dsi.h>
>  #include <drm/drm_mode.h>
>  
>  #define DISPC_IRQ_FRAMEDONE		(1 << 0)
> @@ -118,11 +117,6 @@ enum omap_dss_venc_type {
>  	OMAP_DSS_VENC_TYPE_SVIDEO,
>  };
>  
> -enum omap_dss_dsi_mode {
> -	OMAP_DSS_DSI_CMD_MODE = 0,
> -	OMAP_DSS_DSI_VIDEO_MODE,
> -};
> -
>  enum omap_dss_rotation_type {
>  	OMAP_DSS_ROT_NONE	= 0,
>  	OMAP_DSS_ROT_TILER	= 1 << 0,
> @@ -147,64 +141,6 @@ enum omap_dss_output_id {
>  	OMAP_DSS_OUTPUT_HDMI	= 1 << 6,
>  };
>  
> -/* DSI */
> -
> -enum omap_dss_dsi_trans_mode {
> -	/* Sync Pulses: both sync start and end packets sent */
> -	OMAP_DSS_DSI_PULSE_MODE,
> -	/* Sync Events: only sync start packets sent */
> -	OMAP_DSS_DSI_EVENT_MODE,
> -	/* Burst: only sync start packets sent, pixels are time compressed */
> -	OMAP_DSS_DSI_BURST_MODE,
> -};
> -
> -struct omap_dss_dsi_videomode_timings {
> -	unsigned long hsclk;
> -
> -	unsigned int ndl;
> -	unsigned int bitspp;
> -
> -	/* pixels */
> -	u16 hact;
> -	/* lines */
> -	u16 vact;
> -
> -	/* DSI video mode blanking data */
> -	/* Unit: byte clock cycles */
> -	u16 hss;
> -	u16 hsa;
> -	u16 hse;
> -	u16 hfp;
> -	u16 hbp;
> -	/* Unit: line clocks */
> -	u16 vsa;
> -	u16 vfp;
> -	u16 vbp;
> -
> -	/* DSI blanking modes */
> -	int blanking_mode;
> -	int hsa_blanking_mode;
> -	int hbp_blanking_mode;
> -	int hfp_blanking_mode;
> -
> -	enum omap_dss_dsi_trans_mode trans_mode;
> -
> -	bool ddr_clk_always_on;
> -	int window_sync;
> -};
> -
> -struct omap_dss_dsi_config {
> -	enum omap_dss_dsi_mode mode;
> -	enum mipi_dsi_pixel_format pixel_format;
> -	const struct videomode *vm;
> -
> -	unsigned long hs_clk_min, hs_clk_max;
> -	unsigned long lp_clk_min, lp_clk_max;
> -
> -	bool ddr_clk_always_on;
> -	enum omap_dss_dsi_trans_mode trans_mode;
> -};
> -
>  struct omap_dss_cpr_coefs {
>  	s16 rr, rg, rb;
>  	s16 gr, gg, gb;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 72/80] drm/omap: dsi: move enable/disable to bridge enable/disable
  2020-11-24 12:45 ` [PATCH v4 72/80] drm/omap: dsi: move enable/disable to bridge enable/disable Tomi Valkeinen
@ 2020-12-01  0:32   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:32 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:30PM +0200, Tomi Valkeinen wrote:
> Clean up the code by inlining dsi_enable_video_outputs and
> dsi_disable_video_outputs functions.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 55 +++++++++++++------------------
>  1 file changed, 22 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index a01e09c9b477..4f79d6c664ff 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3336,20 +3336,6 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
>  	dsi_display_uninit_dispc(dsi);
>  }
>  
> -static void dsi_disable_video_outputs(struct omap_dss_device *dssdev)
> -{
> -	struct dsi_data *dsi = to_dsi_data(dssdev);
> -
> -	dsi_bus_lock(dsi);
> -	dsi->video_enabled = false;
> -
> -	dsi_disable_video_output(dssdev, VC_VIDEO);
> -
> -	dsi_display_disable(dssdev);
> -
> -	dsi_bus_unlock(dsi);
> -}
> -
>  static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  {
>  	unsigned int bytespp;
> @@ -3791,23 +3777,6 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
>  	_dsi_display_enable(dsi);
>  }
>  
> -static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
> -{
> -	struct dsi_data *dsi = to_dsi_data(dssdev);
> -
> -	dsi_bus_lock(dsi);
> -
> -	dsi_display_enable(dssdev);
> -
> -	dsi_enable_video_output(dssdev, VC_VIDEO);
> -
> -	dsi->video_enabled = true;
> -
> -	dsi_set_ulps_auto(dsi, true);
> -
> -	dsi_bus_unlock(dsi);
> -}
> -
>  static void _dsi_display_disable(struct dsi_data *dsi,
>  		bool disconnect_lanes, bool enter_ulps)
>  {
> @@ -4969,15 +4938,35 @@ static void dsi_bridge_mode_set(struct drm_bridge *bridge,
>  static void dsi_bridge_enable(struct drm_bridge *bridge)
>  {
>  	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
> +	struct omap_dss_device *dssdev = &dsi->output;
>  
> -	dsi_enable_video_outputs(&dsi->output);
> +	dsi_bus_lock(dsi);
> +
> +	dsi_display_enable(dssdev);
> +
> +	dsi_enable_video_output(dssdev, VC_VIDEO);
> +
> +	dsi->video_enabled = true;
> +
> +	dsi_set_ulps_auto(dsi, true);
> +
> +	dsi_bus_unlock(dsi);
>  }
>  
>  static void dsi_bridge_disable(struct drm_bridge *bridge)
>  {
>  	struct dsi_data *dsi = drm_bridge_to_dsi(bridge);
> +	struct omap_dss_device *dssdev = &dsi->output;
> +
> +	dsi_bus_lock(dsi);
> +
> +	dsi->video_enabled = false;
> +
> +	dsi_disable_video_output(dssdev, VC_VIDEO);
>  
> -	dsi_disable_video_outputs(&dsi->output);
> +	dsi_display_disable(dssdev);
> +
> +	dsi_bus_unlock(dsi);
>  }
>  
>  static const struct drm_bridge_funcs dsi_bridge_funcs = {

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 73/80] drm/omap: dsi: display_enable cleanup
  2020-11-24 12:45 ` [PATCH v4 73/80] drm/omap: dsi: display_enable cleanup Tomi Valkeinen
@ 2020-12-01  0:32   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:32 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:31PM +0200, Tomi Valkeinen wrote:
> We can drop dsi_display_enable(), which just calls
> _dsi_display_enable(), and rename _dsi_display_enable() to
> dsi_display_enable().

How about adding a comment here to explain why the WARN_ON() is needed
anymore ?

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 16 +++-------------
>  1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 4f79d6c664ff..e50418db71ef 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3738,7 +3738,7 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
>  	}
>  }
>  
> -static void _dsi_display_enable(struct dsi_data *dsi)
> +static void dsi_display_enable(struct dsi_data *dsi)
>  {
>  	int r;
>  
> @@ -3767,16 +3767,6 @@ static void _dsi_display_enable(struct dsi_data *dsi)
>  	DSSDBG("dsi_display_ulps_enable FAILED\n");
>  }
>  
> -static void dsi_display_enable(struct omap_dss_device *dssdev)
> -{
> -	struct dsi_data *dsi = to_dsi_data(dssdev);
> -	DSSDBG("dsi_display_enable\n");
> -
> -	WARN_ON(!dsi_bus_is_locked(dsi));
> -
> -	_dsi_display_enable(dsi);
> -}
> -
>  static void _dsi_display_disable(struct dsi_data *dsi,
>  		bool disconnect_lanes, bool enter_ulps)
>  {
> @@ -3851,7 +3841,7 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable)
>  			return;
>  
>  		dsi_bus_lock(dsi);
> -		_dsi_display_enable(dsi);
> +		dsi_display_enable(dsi);
>  		dsi_enable_te(dsi, true);
>  		dsi_bus_unlock(dsi);
>  	}
> @@ -4942,7 +4932,7 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
>  
>  	dsi_bus_lock(dsi);
>  
> -	dsi_display_enable(dssdev);
> +	dsi_display_enable(dsi);
>  
>  	dsi_enable_video_output(dssdev, VC_VIDEO);
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 74/80] drm/omap: dsi: display_disable cleanup
  2020-11-24 12:45 ` [PATCH v4 74/80] drm/omap: dsi: display_disable cleanup Tomi Valkeinen
@ 2020-12-01  0:33   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:33 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:32PM +0200, Tomi Valkeinen wrote:
> We can drop dsi_display_disable() which just calls
> _dsi_display_disable(), and rename _dsi_display_disable() to
> dsi_display_disable().

Same comment as for the previous patch. I'd actually squash the two.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 19 +++----------------
>  1 file changed, 3 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index e50418db71ef..d23fc43f1d1e 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -63,8 +63,6 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel);
>  static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, int vc,
>  				       const struct mipi_dsi_msg *msg);
>  
> -static void dsi_display_disable(struct omap_dss_device *dssdev);
> -
>  #ifdef DSI_PERF_MEASURE
>  static bool dsi_perf;
>  module_param(dsi_perf, bool, 0644);
> @@ -3767,7 +3765,7 @@ static void dsi_display_enable(struct dsi_data *dsi)
>  	DSSDBG("dsi_display_ulps_enable FAILED\n");
>  }
>  
> -static void _dsi_display_disable(struct dsi_data *dsi,
> +static void dsi_display_disable(struct dsi_data *dsi,
>  		bool disconnect_lanes, bool enter_ulps)
>  {
>  	WARN_ON(!dsi_bus_is_locked(dsi));
> @@ -3786,17 +3784,6 @@ static void _dsi_display_disable(struct dsi_data *dsi,
>  	mutex_unlock(&dsi->lock);
>  }
>  
> -static void dsi_display_disable(struct omap_dss_device *dssdev)
> -{
> -	struct dsi_data *dsi = to_dsi_data(dssdev);
> -
> -	WARN_ON(!dsi_bus_is_locked(dsi));
> -
> -	DSSDBG("dsi_display_disable\n");
> -
> -	_dsi_display_disable(dsi, true, false);
> -}
> -
>  static int dsi_enable_te(struct dsi_data *dsi, bool enable)
>  {
>  	dsi->te_enabled = enable;
> @@ -3820,7 +3807,7 @@ static void omap_dsi_ulps_work_callback(struct work_struct *work)
>  
>  	dsi_enable_te(dsi, false);
>  
> -	_dsi_display_disable(dsi, false, true);
> +	dsi_display_disable(dsi, false, true);
>  
>  	dsi_bus_unlock(dsi);
>  }
> @@ -4954,7 +4941,7 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
>  
>  	dsi_disable_video_output(dssdev, VC_VIDEO);
>  
> -	dsi_display_disable(dssdev);
> +	dsi_display_disable(dsi, true, false);
>  
>  	dsi_bus_unlock(dsi);
>  }

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 75/80] drm/omap: dsi: rename dsi_display_* functions
  2020-11-24 12:45 ` [PATCH v4 75/80] drm/omap: dsi: rename dsi_display_* functions Tomi Valkeinen
@ 2020-12-01  0:34   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:34 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:33PM +0200, Tomi Valkeinen wrote:
> The function names have evolved to be very confusing, and bunch of them
> have "display" in them even if the function doesn't deal with display as
> such (e.g. dsi_display_enable which just enables the DSI interface).
> Rename them by dropping the "display".
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 36 +++++++++++++++----------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index d23fc43f1d1e..ff8ace957291 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -55,8 +55,8 @@
>  
>  static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
>  
> -static int dsi_display_init_dispc(struct dsi_data *dsi);
> -static void dsi_display_uninit_dispc(struct dsi_data *dsi);
> +static int dsi_init_dispc(struct dsi_data *dsi);
> +static void dsi_uninit_dispc(struct dsi_data *dsi);
>  
>  static int dsi_vc_send_null(struct dsi_data *dsi, int vc, int channel);
>  
> @@ -3257,7 +3257,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
>  	u16 word_count;
>  	int r;
>  
> -	r = dsi_display_init_dispc(dsi);
> +	r = dsi_init_dispc(dsi);
>  	if (r) {
>  		dev_err(dsi->dev, "failed to init dispc!\n");
>  		return;
> @@ -3309,7 +3309,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
>  		dsi_vc_enable(dsi, vc, false);
>  	}
>  err_pix_fmt:
> -	dsi_display_uninit_dispc(dsi);
> +	dsi_uninit_dispc(dsi);
>  	dev_err(dsi->dev, "failed to enable DSI encoder!\n");
>  	return;
>  }
> @@ -3331,7 +3331,7 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
>  
>  	dss_mgr_disable(&dsi->output);
>  
> -	dsi_display_uninit_dispc(dsi);
> +	dsi_uninit_dispc(dsi);
>  }
>  
>  static void dsi_update_screen_dispc(struct dsi_data *dsi)
> @@ -3577,7 +3577,7 @@ static int dsi_configure_dispc_clocks(struct dsi_data *dsi)
>  	return 0;
>  }
>  
> -static int dsi_display_init_dispc(struct dsi_data *dsi)
> +static int dsi_init_dispc(struct dsi_data *dsi)
>  {
>  	enum omap_channel dispc_channel = dsi->output.dispc_channel;
>  	int r;
> @@ -3622,7 +3622,7 @@ static int dsi_display_init_dispc(struct dsi_data *dsi)
>  	return r;
>  }
>  
> -static void dsi_display_uninit_dispc(struct dsi_data *dsi)
> +static void dsi_uninit_dispc(struct dsi_data *dsi)
>  {
>  	enum omap_channel dispc_channel = dsi->output.dispc_channel;
>  
> @@ -3649,7 +3649,7 @@ static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
>  	return 0;
>  }
>  
> -static int dsi_display_init_dsi(struct dsi_data *dsi)
> +static int dsi_init_dsi(struct dsi_data *dsi)
>  {
>  	int r;
>  
> @@ -3713,7 +3713,7 @@ static int dsi_display_init_dsi(struct dsi_data *dsi)
>  	return r;
>  }
>  
> -static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
> +static void dsi_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
>  				   bool enter_ulps)
>  {
>  	if (enter_ulps && !dsi->ulps_enabled)
> @@ -3736,7 +3736,7 @@ static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
>  	}
>  }
>  
> -static void dsi_display_enable(struct dsi_data *dsi)
> +static void dsi_enable(struct dsi_data *dsi)
>  {
>  	int r;
>  
> @@ -3750,7 +3750,7 @@ static void dsi_display_enable(struct dsi_data *dsi)
>  
>  	_dsi_initialize_irq(dsi);
>  
> -	r = dsi_display_init_dsi(dsi);
> +	r = dsi_init_dsi(dsi);
>  	if (r)
>  		goto err_init_dsi;
>  
> @@ -3762,10 +3762,10 @@ static void dsi_display_enable(struct dsi_data *dsi)
>  	dsi_runtime_put(dsi);
>  err_get_dsi:
>  	mutex_unlock(&dsi->lock);
> -	DSSDBG("dsi_display_ulps_enable FAILED\n");
> +	DSSDBG("dsi_enable FAILED\n");
>  }
>  
> -static void dsi_display_disable(struct dsi_data *dsi,
> +static void dsi_disable(struct dsi_data *dsi,
>  		bool disconnect_lanes, bool enter_ulps)
>  {
>  	WARN_ON(!dsi_bus_is_locked(dsi));
> @@ -3777,7 +3777,7 @@ static void dsi_display_disable(struct dsi_data *dsi,
>  	dsi_sync_vc(dsi, 2);
>  	dsi_sync_vc(dsi, 3);
>  
> -	dsi_display_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
> +	dsi_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
>  
>  	dsi_runtime_put(dsi);
>  
> @@ -3807,7 +3807,7 @@ static void omap_dsi_ulps_work_callback(struct work_struct *work)
>  
>  	dsi_enable_te(dsi, false);
>  
> -	dsi_display_disable(dsi, false, true);
> +	dsi_disable(dsi, false, true);
>  
>  	dsi_bus_unlock(dsi);
>  }
> @@ -3828,7 +3828,7 @@ static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable)
>  			return;
>  
>  		dsi_bus_lock(dsi);
> -		dsi_display_enable(dsi);
> +		dsi_enable(dsi);
>  		dsi_enable_te(dsi, true);
>  		dsi_bus_unlock(dsi);
>  	}
> @@ -4919,7 +4919,7 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
>  
>  	dsi_bus_lock(dsi);
>  
> -	dsi_display_enable(dsi);
> +	dsi_enable(dsi);
>  
>  	dsi_enable_video_output(dssdev, VC_VIDEO);
>  
> @@ -4941,7 +4941,7 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
>  
>  	dsi_disable_video_output(dssdev, VC_VIDEO);
>  
> -	dsi_display_disable(dsi, true, false);
> +	dsi_disable(dsi, true, false);
>  
>  	dsi_bus_unlock(dsi);
>  }

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 76/80] drm/omap: dsi: cleanup initial vc setup
  2020-11-24 12:45 ` [PATCH v4 76/80] drm/omap: dsi: cleanup initial vc setup Tomi Valkeinen
@ 2020-12-01  0:36   ` Laurent Pinchart
  2020-12-01 11:51     ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:36 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:34PM +0200, Tomi Valkeinen wrote:
> As we now have a fixed setup for VCs (VC0 for video stream, VC1 for
> commands), we can simplify the VC setup.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 85 +++++++++++--------------------
>  1 file changed, 31 insertions(+), 54 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index ff8ace957291..27d0d119668b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -2017,40 +2017,6 @@ static void dsi_vc_initial_config(struct dsi_data *dsi, int vc)
>  	dsi->vc[vc].source = DSI_VC_SOURCE_L4;
>  }
>  
> -static int dsi_vc_config_source(struct dsi_data *dsi, int vc,
> -				enum dsi_vc_source source)
> -{
> -	if (dsi->vc[vc].source == source)
> -		return 0;
> -
> -	DSSDBG("Source config of VC %d", vc);
> -
> -	dsi_sync_vc(dsi, vc);
> -
> -	dsi_vc_enable(dsi, vc, 0);
> -
> -	/* VC_BUSY */
> -	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(vc), 15, 0)) {
> -		DSSERR("vc(%d) busy when trying to config for VP\n", vc);
> -		return -EIO;
> -	}
> -
> -	/* SOURCE, 0 = L4, 1 = video port */
> -	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), source, 1, 1);
> -
> -	/* DCS_CMD_ENABLE */
> -	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) {
> -		bool enable = source == DSI_VC_SOURCE_VP;
> -		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 30, 30);
> -	}
> -
> -	dsi_vc_enable(dsi, vc, 1);
> -
> -	dsi->vc[vc].source = source;
> -
> -	return 0;
> -}
> -
>  static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
>  		bool enable)
>  {
> @@ -2072,10 +2038,6 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
>  	dsi_if_enable(dsi, 1);
>  
>  	dsi_force_tx_stop_mode_io(dsi);
> -
> -	/* start the DDR clock by sending a NULL packet */
> -	if (dsi->vm_timings.ddr_clk_always_on && enable)
> -		dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
>  }
>  
>  static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
> @@ -2270,8 +2232,6 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
>  		return -EINVAL;
>  	}
>  
> -	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
> -
>  	dsi_vc_write_long_header(dsi, vc, msg->channel, msg->type, msg->tx_len, 0);
>  
>  	p = msg->tx_buf;
> @@ -2331,8 +2291,6 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
>  		DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
>  		       vc, msg->type, pkt.header[1], pkt.header[2]);
>  
> -	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
> -
>  	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(vc)), 16, 16)) {
>  		DSSERR("ERROR FIFO FULL, aborting transfer\n");
>  		return -EINVAL;
> @@ -3351,8 +3309,6 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
>  
>  	DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h);
>  
> -	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_VP);
> -
>  	bytespp	= mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) / 8;
>  	bytespl = w * bytespp;
>  	bytespf = bytespl * h;
> @@ -3522,9 +3478,7 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
>  
>  	dsi_set_ulps_auto(dsi, false);
>  
> -	dsi_vc_enable_hs(dssdev, vc, !(dsi->dsidev->mode_flags & MIPI_DSI_MODE_LPM));

Why is this not needed anymore ?

> -
> -	r = _dsi_send_nop(dsi, vc, dsi->dsidev->channel);
> +	r = _dsi_send_nop(dsi, VC_CMD, dsi->dsidev->channel);
>  	if (r < 0) {
>  		DSSWARN("failed to send nop between frames: %d\n", r);
>  		goto err;
> @@ -3649,6 +3603,35 @@ static int dsi_configure_dsi_clocks(struct dsi_data *dsi)
>  	return 0;
>  }
>  
> +static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
> +{
> +	/* Setup VC_CMD for LP and cpu transfers */
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_CMD), 0, 9, 9); /* LP */
> +
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_CMD), 0, 1, 1); /* SOURCE_L4 */
> +	dsi->vc[VC_CMD].source = DSI_VC_SOURCE_L4;
> +
> +	/* Setup VC_VIDEO for HS and dispc transfers */
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 9, 9); /* HS */
> +
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 1, 1); /* SOURCE_VP */
> +	dsi->vc[VC_VIDEO].source = DSI_VC_SOURCE_VP;
> +
> +	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC)
> +		REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 30, 30); /* DCS_CMD_ENABLE */
> +
> +	dsi_vc_enable(dsi, VC_CMD, 1);
> +	dsi_vc_enable(dsi, VC_VIDEO, 1);
> +
> +	dsi_if_enable(dsi, 1);
> +
> +	dsi_force_tx_stop_mode_io(dsi);
> +
> +	/* start the DDR clock by sending a NULL packet */
> +	if (dsi->vm_timings.ddr_clk_always_on)
> +		dsi_vc_send_null(dsi, VC_CMD, dsi->dsidev->channel);
> +}
> +
>  static int dsi_init_dsi(struct dsi_data *dsi)
>  {
>  	int r;
> @@ -3691,13 +3674,7 @@ static int dsi_init_dsi(struct dsi_data *dsi)
>  	if (r)
>  		goto err3;
>  
> -	/* enable interface */
> -	dsi_vc_enable(dsi, 0, 1);
> -	dsi_vc_enable(dsi, 1, 1);
> -	dsi_vc_enable(dsi, 2, 1);
> -	dsi_vc_enable(dsi, 3, 1);
> -	dsi_if_enable(dsi, 1);
> -	dsi_force_tx_stop_mode_io(dsi);
> +	dsi_setup_dsi_vcs(dsi);
>  
>  	return 0;
>  err3:

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 77/80] drm/omap: dsi: split video mode enable/disable into separate func
  2020-11-24 12:45 ` [PATCH v4 77/80] drm/omap: dsi: split video mode enable/disable into separate func Tomi Valkeinen
@ 2020-12-01  0:37   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:37 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:35PM +0200, Tomi Valkeinen wrote:
> Clean up the code by separating video-mode enable/disable code into
> functions of their own.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 101 +++++++++++++++++-------------
>  1 file changed, 57 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 27d0d119668b..6d20245495ac 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3207,12 +3207,61 @@ static int dsi_configure_pins(struct dsi_data *dsi,
>  	return 0;
>  }
>  
> -static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
> +static int dsi_enable_video_mode(struct dsi_data *dsi, int vc)
>  {
> -	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int bpp = mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt);
>  	u8 data_type;
>  	u16 word_count;
> +
> +	switch (dsi->pix_fmt) {
> +	case MIPI_DSI_FMT_RGB888:
> +		data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
> +		break;
> +	case MIPI_DSI_FMT_RGB666:
> +		data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
> +		break;
> +	case MIPI_DSI_FMT_RGB666_PACKED:
> +		data_type = MIPI_DSI_PACKED_PIXEL_STREAM_18;
> +		break;
> +	case MIPI_DSI_FMT_RGB565:
> +		data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	dsi_if_enable(dsi, false);
> +	dsi_vc_enable(dsi, vc, false);
> +
> +	/* MODE, 1 = video mode */
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 4, 4);
> +
> +	word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
> +
> +	dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, data_type,
> +			word_count, 0);
> +
> +	dsi_vc_enable(dsi, vc, true);
> +	dsi_if_enable(dsi, true);
> +
> +	return 0;
> +}
> +
> +static void dsi_disable_video_mode(struct dsi_data *dsi, int vc)
> +{
> +	dsi_if_enable(dsi, false);
> +	dsi_vc_enable(dsi, vc, false);
> +
> +	/* MODE, 0 = command mode */
> +	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);
> +
> +	dsi_vc_enable(dsi, vc, true);
> +	dsi_if_enable(dsi, true);
> +}
> +
> +static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
> +{
> +	struct dsi_data *dsi = to_dsi_data(dssdev);
>  	int r;
>  
>  	r = dsi_init_dispc(dsi);
> @@ -3222,37 +3271,9 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
>  	}
>  
>  	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
> -		switch (dsi->pix_fmt) {
> -		case MIPI_DSI_FMT_RGB888:
> -			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24;
> -			break;
> -		case MIPI_DSI_FMT_RGB666:
> -			data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
> -			break;
> -		case MIPI_DSI_FMT_RGB666_PACKED:
> -			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_18;
> -			break;
> -		case MIPI_DSI_FMT_RGB565:
> -			data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16;
> -			break;
> -		default:
> -			r = -EINVAL;
> -			goto err_pix_fmt;
> -		}
> -
> -		dsi_if_enable(dsi, false);
> -		dsi_vc_enable(dsi, vc, false);
> -
> -		/* MODE, 1 = video mode */
> -		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 1, 4, 4);
> -
> -		word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8);
> -
> -		dsi_vc_write_long_header(dsi, vc, dsi->dsidev->channel, data_type,
> -				word_count, 0);
> -
> -		dsi_vc_enable(dsi, vc, true);
> -		dsi_if_enable(dsi, true);
> +		r = dsi_enable_video_mode(dsi, vc);
> +		if (r)
> +			goto err_video_mode;
>  	}
>  
>  	r = dss_mgr_enable(&dsi->output);
> @@ -3266,7 +3287,7 @@ static void dsi_enable_video_output(struct omap_dss_device *dssdev, int vc)
>  		dsi_if_enable(dsi, false);
>  		dsi_vc_enable(dsi, vc, false);
>  	}
> -err_pix_fmt:
> +err_video_mode:
>  	dsi_uninit_dispc(dsi);
>  	dev_err(dsi->dev, "failed to enable DSI encoder!\n");
>  	return;
> @@ -3276,16 +3297,8 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int vc)
>  {
>  	struct dsi_data *dsi = to_dsi_data(dssdev);
>  
> -	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
> -		dsi_if_enable(dsi, false);
> -		dsi_vc_enable(dsi, vc, false);
> -
> -		/* MODE, 0 = command mode */
> -		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), 0, 4, 4);
> -
> -		dsi_vc_enable(dsi, vc, true);
> -		dsi_if_enable(dsi, true);
> -	}
> +	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE)
> +		dsi_disable_video_mode(dsi, vc);
>  
>  	dss_mgr_disable(&dsi->output);
>  

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 78/80] drm/omap: dsi: fix and cleanup ddr_clk_always_on
  2020-11-24 12:45 ` [PATCH v4 78/80] drm/omap: dsi: fix and cleanup ddr_clk_always_on Tomi Valkeinen
@ 2020-12-01  0:38   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:38 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:36PM +0200, Tomi Valkeinen wrote:
> The driver ignores MIPI_DSI_CLOCK_NON_CONTINUOUS, and always uses
> non-continuous clock.
> 
> Fix this by using MIPI_DSI_CLOCK_NON_CONTINUOUS and at the same time,
> drop ddr_clk_always_on field which seems pretty useless.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 12 +++++-------
>  drivers/gpu/drm/omapdrm/dss/dsi.h |  2 --
>  2 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 6d20245495ac..6e9c99402540 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -1734,11 +1734,10 @@ static int dsi_cio_init(struct dsi_data *dsi)
>  
>  	dsi_cio_timings(dsi);
>  
> -	if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
> -		/* DDR_CLK_ALWAYS_ON */
> -		REG_FLD_MOD(dsi, DSI_CLK_CTRL,
> -			dsi->vm_timings.ddr_clk_always_on, 13, 13);
> -	}
> +	/* DDR_CLK_ALWAYS_ON */
> +	REG_FLD_MOD(dsi, DSI_CLK_CTRL,
> +		    !(dsi->dsidev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS),
> +		    13, 13);
>  
>  	dsi->ulps_enabled = false;
>  
> @@ -3641,7 +3640,7 @@ static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
>  	dsi_force_tx_stop_mode_io(dsi);
>  
>  	/* start the DDR clock by sending a NULL packet */
> -	if (dsi->vm_timings.ddr_clk_always_on)
> +	if (!(dsi->dsidev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS))
>  		dsi_vc_send_null(dsi, VC_CMD, dsi->dsidev->channel);
>  }
>  
> @@ -4150,7 +4149,6 @@ static bool dsi_vm_calc_blanking(struct dsi_clk_calc_ctx *ctx)
>  	dsi_vm->hfp_blanking_mode = 1;
>  	dsi_vm->hbp_blanking_mode = 1;
>  
> -	dsi_vm->ddr_clk_always_on = cfg->ddr_clk_always_on;
>  	dsi_vm->window_sync = 4;
>  
>  	/* setup DISPC videomode */
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h b/drivers/gpu/drm/omapdrm/dss/dsi.h
> index 7cc2cc748ed9..3543828e30eb 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
> @@ -209,7 +209,6 @@ struct omap_dss_dsi_videomode_timings {
>  
>  	enum omap_dss_dsi_trans_mode trans_mode;
>  
> -	bool ddr_clk_always_on;
>  	int window_sync;
>  };
>  
> @@ -221,7 +220,6 @@ struct omap_dss_dsi_config {
>  	unsigned long hs_clk_min, hs_clk_max;
>  	unsigned long lp_clk_min, lp_clk_max;
>  
> -	bool ddr_clk_always_on;
>  	enum omap_dss_dsi_trans_mode trans_mode;
>  };
> 

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 79/80] drm/omap: dsi: remove ulps support
  2020-11-24 12:45 ` [PATCH v4 79/80] drm/omap: dsi: remove ulps support Tomi Valkeinen
@ 2020-12-01  0:39   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:39 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:37PM +0200, Tomi Valkeinen wrote:
> ULPS doesn't work, and I have been unable to get it to work. As ULPS is
> a minor power-saving feature which requires substantial amount of
> non-trivial code, and we have trouble just getting and
> keeping DSI working at all, remove ULPS support.
> 
> When the DSI driver works reliably for command and video mode displays,
> someone interested can add it back.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 297 +-----------------------------
>  drivers/gpu/drm/omapdrm/dss/dsi.h |   4 -
>  2 files changed, 8 insertions(+), 293 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 6e9c99402540..ffecacd7350a 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -53,8 +53,6 @@
>  #define REG_FLD_MOD(dsi, idx, val, start, end) \
>  	dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, end))
>  
> -static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable);
> -
>  static int dsi_init_dispc(struct dsi_data *dsi);
>  static void dsi_uninit_dispc(struct dsi_data *dsi);
>  
> @@ -688,44 +686,6 @@ static int dsi_unregister_isr_vc(struct dsi_data *dsi, int vc,
>  	return r;
>  }
>  
> -static int dsi_register_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
> -				void *arg, u32 mask)
> -{
> -	unsigned long flags;
> -	int r;
> -
> -	spin_lock_irqsave(&dsi->irq_lock, flags);
> -
> -	r = _dsi_register_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio,
> -			ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
> -
> -	if (r == 0)
> -		_omap_dsi_set_irqs_cio(dsi);
> -
> -	spin_unlock_irqrestore(&dsi->irq_lock, flags);
> -
> -	return r;
> -}
> -
> -static int dsi_unregister_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr,
> -				  void *arg, u32 mask)
> -{
> -	unsigned long flags;
> -	int r;
> -
> -	spin_lock_irqsave(&dsi->irq_lock, flags);
> -
> -	r = _dsi_unregister_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio,
> -			ARRAY_SIZE(dsi->isr_tables.isr_table_cio));
> -
> -	if (r == 0)
> -		_omap_dsi_set_irqs_cio(dsi);
> -
> -	spin_unlock_irqrestore(&dsi->irq_lock, flags);
> -
> -	return r;
> -}
> -
>  static u32 dsi_get_errors(struct dsi_data *dsi)
>  {
>  	unsigned long flags;
> @@ -1450,56 +1410,6 @@ static void dsi_cio_timings(struct dsi_data *dsi)
>  	dsi_write_reg(dsi, DSI_DSIPHY_CFG2, r);
>  }
>  
> -/* lane masks have lane 0 at lsb. mask_p for positive lines, n for negative */
> -static void dsi_cio_enable_lane_override(struct dsi_data *dsi,
> -					 unsigned int mask_p,
> -					 unsigned int mask_n)
> -{
> -	int i;
> -	u32 l;
> -	u8 lptxscp_start = dsi->num_lanes_supported == 3 ? 22 : 26;
> -
> -	l = 0;
> -
> -	for (i = 0; i < dsi->num_lanes_supported; ++i) {
> -		unsigned int p = dsi->lanes[i].polarity;
> -
> -		if (mask_p & (1 << i))
> -			l |= 1 << (i * 2 + (p ? 0 : 1));
> -
> -		if (mask_n & (1 << i))
> -			l |= 1 << (i * 2 + (p ? 1 : 0));
> -	}
> -
> -	/*
> -	 * Bits in REGLPTXSCPDAT4TO0DXDY:
> -	 * 17: DY0 18: DX0
> -	 * 19: DY1 20: DX1
> -	 * 21: DY2 22: DX2
> -	 * 23: DY3 24: DX3
> -	 * 25: DY4 26: DX4
> -	 */
> -
> -	/* Set the lane override configuration */
> -
> -	/* REGLPTXSCPDAT4TO0DXDY */
> -	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, l, lptxscp_start, 17);
> -
> -	/* Enable lane override */
> -
> -	/* ENLPTXSCPDAT */
> -	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 1, 27, 27);
> -}
> -
> -static void dsi_cio_disable_lane_override(struct dsi_data *dsi)
> -{
> -	/* Disable lane override */
> -	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */
> -	/* Reset the lane override configuration */
> -	/* REGLPTXSCPDAT4TO0DXDY */
> -	REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 22, 17);
> -}
> -
>  static int dsi_cio_wait_tx_clk_esc_reset(struct dsi_data *dsi)
>  {
>  	int t, i;
> @@ -1674,32 +1584,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
>  	l = FLD_MOD(l, 0x1fff, 12, 0);	/* STOP_STATE_COUNTER_IO */
>  	dsi_write_reg(dsi, DSI_TIMING1, l);
>  
> -	if (dsi->ulps_enabled) {
> -		unsigned int mask_p;
> -		int i;
> -
> -		DSSDBG("manual ulps exit\n");
> -
> -		/* ULPS is exited by Mark-1 state for 1ms, followed by
> -		 * stop state. DSS HW cannot do this via the normal
> -		 * ULPS exit sequence, as after reset the DSS HW thinks
> -		 * that we are not in ULPS mode, and refuses to send the
> -		 * sequence. So we need to send the ULPS exit sequence
> -		 * manually by setting positive lines high and negative lines
> -		 * low for 1ms.
> -		 */
> -
> -		mask_p = 0;
> -
> -		for (i = 0; i < dsi->num_lanes_supported; ++i) {
> -			if (dsi->lanes[i].function == DSI_LANE_UNUSED)
> -				continue;
> -			mask_p |= 1 << i;
> -		}
> -
> -		dsi_cio_enable_lane_override(dsi, mask_p, 0);
> -	}
> -
>  	r = dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ON);
>  	if (r)
>  		goto err_cio_pwr;
> @@ -1718,17 +1602,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
>  	if (r)
>  		goto err_tx_clk_esc_rst;
>  
> -	if (dsi->ulps_enabled) {
> -		/* Keep Mark-1 state for 1ms (as per DSI spec) */
> -		ktime_t wait = ns_to_ktime(1000 * 1000);
> -		set_current_state(TASK_UNINTERRUPTIBLE);
> -		schedule_hrtimeout(&wait, HRTIMER_MODE_REL);
> -
> -		/* Disable the override. The lanes should be set to Mark-11
> -		 * state by the HW */
> -		dsi_cio_disable_lane_override(dsi);
> -	}
> -
>  	/* FORCE_TX_STOP_MODE_IO */
>  	REG_FLD_MOD(dsi, DSI_TIMING1, 0, 15, 15);
>  
> @@ -1739,8 +1612,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
>  		    !(dsi->dsidev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS),
>  		    13, 13);
>  
> -	dsi->ulps_enabled = false;
> -
>  	DSSDBG("CIO init done\n");
>  
>  	return 0;
> @@ -1750,8 +1621,6 @@ static int dsi_cio_init(struct dsi_data *dsi)
>  err_cio_pwr_dom:
>  	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_OFF);
>  err_cio_pwr:
> -	if (dsi->ulps_enabled)
> -		dsi_cio_disable_lane_override(dsi);
>  err_scp_clk_dom:
>  	dsi_disable_scp_clk(dsi);
>  	dsi_disable_pads(dsi);
> @@ -2522,99 +2391,6 @@ static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int vc,
>  	return r;
>  }
>  
> -static int dsi_enter_ulps(struct dsi_data *dsi)
> -{
> -	DECLARE_COMPLETION_ONSTACK(completion);
> -	int r, i;
> -	unsigned int mask;
> -
> -	DSSDBG("Entering ULPS");
> -
> -	WARN_ON(!dsi_bus_is_locked(dsi));
> -
> -	WARN_ON(dsi->ulps_enabled);
> -
> -	if (dsi->ulps_enabled)
> -		return 0;
> -
> -	/* DDR_CLK_ALWAYS_ON */
> -	if (REG_GET(dsi, DSI_CLK_CTRL, 13, 13)) {
> -		dsi_if_enable(dsi, 0);
> -		REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 13, 13);
> -		dsi_if_enable(dsi, 1);
> -	}
> -
> -	dsi_sync_vc(dsi, 0);
> -	dsi_sync_vc(dsi, 1);
> -	dsi_sync_vc(dsi, 2);
> -	dsi_sync_vc(dsi, 3);
> -
> -	dsi_force_tx_stop_mode_io(dsi);
> -
> -	dsi_vc_enable(dsi, 0, false);
> -	dsi_vc_enable(dsi, 1, false);
> -	dsi_vc_enable(dsi, 2, false);
> -	dsi_vc_enable(dsi, 3, false);
> -
> -	if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 16, 16)) {	/* HS_BUSY */
> -		DSSERR("HS busy when enabling ULPS\n");
> -		return -EIO;
> -	}
> -
> -	if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 17, 17)) {	/* LP_BUSY */
> -		DSSERR("LP busy when enabling ULPS\n");
> -		return -EIO;
> -	}
> -
> -	r = dsi_register_isr_cio(dsi, dsi_completion_handler, &completion,
> -			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
> -	if (r)
> -		return r;
> -
> -	mask = 0;
> -
> -	for (i = 0; i < dsi->num_lanes_supported; ++i) {
> -		if (dsi->lanes[i].function == DSI_LANE_UNUSED)
> -			continue;
> -		mask |= 1 << i;
> -	}
> -	/* Assert TxRequestEsc for data lanes and TxUlpsClk for clk lane */
> -	/* LANEx_ULPS_SIG2 */
> -	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, mask, 9, 5);
> -
> -	/* flush posted write and wait for SCP interface to finish the write */
> -	dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2);
> -
> -	if (wait_for_completion_timeout(&completion,
> -				msecs_to_jiffies(1000)) == 0) {
> -		DSSERR("ULPS enable timeout\n");
> -		r = -EIO;
> -		goto err;
> -	}
> -
> -	dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion,
> -			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
> -
> -	/* Reset LANEx_ULPS_SIG2 */
> -	REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, 0, 9, 5);
> -
> -	/* flush posted write and wait for SCP interface to finish the write */
> -	dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2);
> -
> -	dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ULPS);
> -
> -	dsi_if_enable(dsi, false);
> -
> -	dsi->ulps_enabled = true;
> -
> -	return 0;
> -
> -err:
> -	dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion,
> -			DSI_CIO_IRQ_ULPSACTIVENOT_ALL0);
> -	return r;
> -}
> -
>  static void dsi_set_lp_rx_timeout(struct dsi_data *dsi, unsigned int ticks,
>  				  bool x4, bool x16)
>  {
> @@ -3397,7 +3173,6 @@ static void dsi_handle_framedone(struct dsi_data *dsi, int error)
>  		REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */
>  	}
>  
> -	dsi_set_ulps_auto(dsi, true);
>  	dsi_bus_unlock(dsi);
>  
>  	if (!error)
> @@ -3488,8 +3263,6 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
>  
>  	DSSDBG("dsi_update_channel: %d", vc);
>  
> -	dsi_set_ulps_auto(dsi, false);
> -
>  	r = _dsi_send_nop(dsi, VC_CMD, dsi->dsidev->channel);
>  	if (r < 0) {
>  		DSSWARN("failed to send nop between frames: %d\n", r);
> @@ -3509,7 +3282,6 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
>  	return 0;
>  
>  err:
> -	dsi_set_ulps_auto(dsi, true);
>  	dsi_bus_unlock(dsi);
>  	return r;
>  }
> @@ -3702,12 +3474,8 @@ static int dsi_init_dsi(struct dsi_data *dsi)
>  	return r;
>  }
>  
> -static void dsi_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
> -				   bool enter_ulps)
> +static void dsi_uninit_dsi(struct dsi_data *dsi)
>  {
> -	if (enter_ulps && !dsi->ulps_enabled)
> -		dsi_enter_ulps(dsi);
> -
>  	/* disable interface */
>  	dsi_if_enable(dsi, 0);
>  	dsi_vc_enable(dsi, 0, 0);
> @@ -3719,10 +3487,8 @@ static void dsi_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes,
>  	dsi_cio_uninit(dsi);
>  	dss_pll_disable(&dsi->pll);
>  
> -	if (disconnect_lanes) {
> -		regulator_disable(dsi->vdds_dsi_reg);
> -		dsi->vdds_dsi_enabled = false;
> -	}
> +	regulator_disable(dsi->vdds_dsi_reg);
> +	dsi->vdds_dsi_enabled = false;
>  }
>  
>  static void dsi_enable(struct dsi_data *dsi)
> @@ -3754,8 +3520,7 @@ static void dsi_enable(struct dsi_data *dsi)
>  	DSSDBG("dsi_enable FAILED\n");
>  }
>  
> -static void dsi_disable(struct dsi_data *dsi,
> -		bool disconnect_lanes, bool enter_ulps)
> +static void dsi_disable(struct dsi_data *dsi)
>  {
>  	WARN_ON(!dsi_bus_is_locked(dsi));
>  
> @@ -3766,7 +3531,7 @@ static void dsi_disable(struct dsi_data *dsi,
>  	dsi_sync_vc(dsi, 2);
>  	dsi_sync_vc(dsi, 3);
>  
> -	dsi_uninit_dsi(dsi, disconnect_lanes, enter_ulps);
> +	dsi_uninit_dsi(dsi);
>  
>  	dsi_runtime_put(dsi);
>  
> @@ -3787,42 +3552,6 @@ static int dsi_enable_te(struct dsi_data *dsi, bool enable)
>  	return 0;
>  }
>  
> -static void omap_dsi_ulps_work_callback(struct work_struct *work)
> -{
> -	struct dsi_data *dsi = container_of(work, struct dsi_data,
> -					    ulps_work.work);
> -
> -	dsi_bus_lock(dsi);
> -
> -	dsi_enable_te(dsi, false);
> -
> -	dsi_disable(dsi, false, true);
> -
> -	dsi_bus_unlock(dsi);
> -}
> -
> -static void dsi_set_ulps_auto(struct dsi_data *dsi, bool enable)
> -{
> -	WARN_ON(!dsi_bus_is_locked(dsi));
> -
> -	if (!dsi->ulps_auto_idle)
> -		return;
> -
> -	if (enable) {
> -		schedule_delayed_work(&dsi->ulps_work, msecs_to_jiffies(250));
> -	} else {
> -		cancel_delayed_work_sync(&dsi->ulps_work);
> -
> -		if (!dsi->ulps_enabled)
> -			return;
> -
> -		dsi_bus_lock(dsi);
> -		dsi_enable(dsi);
> -		dsi_enable_te(dsi, true);
> -		dsi_bus_unlock(dsi);
> -	}
> -}
> -
>  #ifdef PRINT_VERBOSE_VM_TIMINGS
>  static void print_dsi_vm(const char *str,
>  		const struct omap_dss_dsi_videomode_timings *t)
> @@ -4494,13 +4223,10 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host,
>  
>  	dsi_bus_lock(dsi);
>  
> -	if (dsi->video_enabled) {
> -		dsi_set_ulps_auto(dsi, false);
> +	if (dsi->video_enabled)
>  		r = _omap_dsi_host_transfer(dsi, vc, msg);
> -		dsi_set_ulps_auto(dsi, true);
> -	} else {
> +	else
>  		r = -EIO;
> -	}
>  
>  	dsi_bus_unlock(dsi);
>  
> @@ -4642,9 +4368,6 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
>  	dsi->dsidev = client;
>  	dsi->pix_fmt = client->format;
>  
> -	INIT_DEFERRABLE_WORK(&dsi->ulps_work,
> -			     omap_dsi_ulps_work_callback);
> -
>  	dsi->config.hs_clk_min = 150000000; // TODO: get from client?
>  	dsi->config.hs_clk_max = client->hs_rate;
>  	dsi->config.lp_clk_min = 7000000; // TODO: get from client?
> @@ -4657,8 +4380,6 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
>  	else
>  		dsi->config.trans_mode = OMAP_DSS_DSI_EVENT_MODE;
>  
> -	dsi->ulps_auto_idle = false;
> -
>  	return 0;
>  }
>  
> @@ -4913,8 +4634,6 @@ static void dsi_bridge_enable(struct drm_bridge *bridge)
>  
>  	dsi->video_enabled = true;
>  
> -	dsi_set_ulps_auto(dsi, true);
> -
>  	dsi_bus_unlock(dsi);
>  }
>  
> @@ -4929,7 +4648,7 @@ static void dsi_bridge_disable(struct drm_bridge *bridge)
>  
>  	dsi_disable_video_output(dssdev, VC_VIDEO);
>  
> -	dsi_disable(dsi, true, false);
> +	dsi_disable(dsi);
>  
>  	dsi_bus_unlock(dsi);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.h b/drivers/gpu/drm/omapdrm/dss/dsi.h
> index 3543828e30eb..452cee3279db 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.h
> @@ -391,12 +391,8 @@ struct dsi_data {
>  	atomic_t do_ext_te_update;
>  
>  	bool te_enabled;
> -	bool ulps_enabled;
> -	bool ulps_auto_idle;
>  	bool video_enabled;
>  
> -	struct delayed_work ulps_work;
> -
>  	struct delayed_work framedone_timeout_work;
>  
>  #ifdef DSI_CATCH_MISSING_TE

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 80/80] drm/omap: dsi: fix DCS_CMD_ENABLE
  2020-11-24 12:45 ` [PATCH v4 80/80] drm/omap: dsi: fix DCS_CMD_ENABLE Tomi Valkeinen
@ 2020-12-01  0:40   ` Laurent Pinchart
  0 siblings, 0 replies; 152+ messages in thread
From: Laurent Pinchart @ 2020-12-01  0:40 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

Hi Tomi,

Thank you for the patch.

On Tue, Nov 24, 2020 at 02:45:38PM +0200, Tomi Valkeinen wrote:
> We only need to set VC_CTRL:DCS_CMD_ENABLE for command mode panels when
> the HW has DSI_QUIRK_DCS_CMD_CONFIG_VC quirk. The old code did this
> right by accident, but now we set DCS_CMD_ENABLE for video mode panels
> too.
> 
> Fix this by skipping the set for video mode.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index ffecacd7350a..d52bef0c7aa2 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3401,7 +3401,8 @@ static void dsi_setup_dsi_vcs(struct dsi_data *dsi)
>  	REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 1, 1); /* SOURCE_VP */
>  	dsi->vc[VC_VIDEO].source = DSI_VC_SOURCE_VP;
>  
> -	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC)
> +	if ((dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) &&
> +	    !(dsi->dsidev->mode_flags & MIPI_DSI_MODE_VIDEO))
>  		REG_FLD_MOD(dsi, DSI_VC_CTRL(VC_VIDEO), 1, 30, 30); /* DCS_CMD_ENABLE */
>  
>  	dsi_vc_enable(dsi, VC_CMD, 1);

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 49/80] ARM: omap2plus_defconfig: Update for moved DSI command mode panel
  2020-11-24 12:45 ` [PATCH v4 49/80] ARM: omap2plus_defconfig: Update for moved DSI command mode panel Tomi Valkeinen
@ 2020-12-01  8:46   ` Tony Lindgren
  0 siblings, 0 replies; 152+ messages in thread
From: Tony Lindgren @ 2020-12-01  8:46 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

* Tomi Valkeinen <tomi.valkeinen@ti.com> [201124 12:48]:
> From: Sebastian Reichel <sebastian.reichel@collabora.com>
> 
> The DSI command mode panel is no longer specific
> to OMAP and thus the config option has been renamed
> slightly.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Best to merge this along with the dss patches:

Acked-by: Tony Lindgren <tony@atomide.com>

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi
  2020-11-30  9:53   ` Laurent Pinchart
@ 2020-12-01 10:39     ` Tomi Valkeinen
  2020-12-01 10:47       ` Tony Lindgren
  0 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 10:39 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 30/11/2020 11:53, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:15PM +0200, Tomi Valkeinen wrote:
>> Add address-cells & size-cells to DSI nodes so that board files do not
>> need to define them.
> 
> How about adding ports too, while at it ?

We don't have ports for other encoders either. I'm not sure if adding ports helps or not, but I
think it makes sense to add them consistently to all encoders on all boards if we want to go that way.

> It would also be nice to convert the DT bindings to YAML :-)

I agree, but not as part of this already 81 patch series. =)

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi
  2020-12-01 10:39     ` Tomi Valkeinen
@ 2020-12-01 10:47       ` Tony Lindgren
  0 siblings, 0 replies; 152+ messages in thread
From: Tony Lindgren @ 2020-12-01 10:47 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Sebastian Reichel, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns

* Tomi Valkeinen <tomi.valkeinen@ti.com> [201201 10:39]:
> On 30/11/2020 11:53, Laurent Pinchart wrote:
> > Hi Tomi,
> > 
> > Thank you for the patch.
> > 
> > On Tue, Nov 24, 2020 at 02:45:15PM +0200, Tomi Valkeinen wrote:
> >> Add address-cells & size-cells to DSI nodes so that board files do not
> >> need to define them.
> > 
> > How about adding ports too, while at it ?
> 
> We don't have ports for other encoders either. I'm not sure if adding ports helps or not, but I
> think it makes sense to add them consistently to all encoders on all boards if we want to go that way.
> 
> > It would also be nice to convert the DT bindings to YAML :-)
> 
> I agree, but not as part of this already 81 patch series. =)

Please feel free to merge this via the dss tree:

Acked-by: Tony Lindgren <tony@atomide.com>

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 61/80] drm/omap: dsi: send nop instead of page & column
  2020-11-30  9:58   ` Laurent Pinchart
@ 2020-12-01 10:59     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 10:59 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 30/11/2020 11:58, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:19PM +0200, Tomi Valkeinen wrote:
>> The OMAP DSI command mode panel driver used to send page & column
>> address before each frame update, and this code was moved into the DSI
>> host driver when converting it to the DRM bridge model.
>>
>> However, it's not really required to send the page & column address
>> before each frame. It's also something that doesn't really belong to the
>> DSI host driver, so we should drop the code.
>>
>> That said, frame updates break if we don't send _something_ between the
>> frames. A NOP command does the trick.
>>
>> It is not clear if this behavior is as expected from a DSI command mode
>> frame transfer, or is it a feature/issue with OMAP DSI driver, or a
>> feature/issue in the command mode panel used. So this probably needs to
>> be revisited later.
> 
> This is important information, could you capture it in a comment in the
> code ?

I think this is related to the following (from DSI spec):

"To enable PHY synchronization the host processor should  periodically end HS transmission and drive
the Data Lanes to the LP state. This transition should take place at least once per frame"

And in OMAP TRM:

"Special care must be taken in the case of the last line of the frame. The LPS transition is
required when the link is in HS mode for the whole frame."

I'm not 100% sure about that, but I'll change the commit description and add a comment to reflect
the above text.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 62/80] drm/omap: dsi: simplify VC handling
  2020-11-30 10:00   ` Laurent Pinchart
@ 2020-12-01 11:11     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 11:11 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 30/11/2020 12:00, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:20PM +0200, Tomi Valkeinen wrote:
>> The VC handling has gotten quite tangled up. As the first step to clean
>> it up, lets define that we only support a single DSI peripheral (which
>> was really already the case), and we always use VC0 (define VC_DEFAULT
>> 0) register block to send data to the peripheral.
>>
>> We can thus have a single mipi_dsi_device pointer and remove the for
> 
> s/the for/the need for/ ?

Hmm, no, that's not what I was trying to say. Maybe it's clearer with a dash: "remove the for-loops
which..."

> 
>> loops which made passes over all the four VCs (just the first one was
>> ever used).
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 64/80] drm/omap: dsi: cleanup channel usages
  2020-12-01  0:17   ` Laurent Pinchart
@ 2020-12-01 11:23     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 11:23 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 01/12/2020 02:17, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:22PM +0200, Tomi Valkeinen wrote:
>> The "channel" usage in omap dsi driver is super confusing. We have three
>> different "channels":
>>
>> 1) DSI virtual channel ID. This is a number from 0 to 3, included in the
>> packet payload.
>>
>> 2) VC. This is a register block in the DSI IP. There are four of those
>> blocks. A VC is a DSI "pipeline", with defined fifo settings, data
>> source (cpu or dispc), and some other settings. It has no relation to
>> the 1).
> 
> Lovely that it's called VC :-)

Yes. There are 4 VC blocks. My guess is that initially the HW designers meant that one HW VC block
is used for one DSI channel (DSI supports 4 channels). But at least I cannot see how the HW could be
used that way.

>> 3) dispc channel. It's the "pipeline" number dispc uses to send pixel
>> data.
>>
>> To clean this up use the following names for each of the above: 1)
>> "channel" 2) "vc" 3) "dispc_channel"
> 
> 1) and 2) will still be prone to confusion :-S Would it help to name 2)
> hw_vc or something similar ?

The omap dsi driver uses "vc" and "channel" consistently after this patch, and afaics in the DRM
framework it's always "channel". So I kind of agree with you but I hope this is enough. Otherwise
I'll spend lots of hours solving the conflicts after rename... Well, a new rename patch could be
done later on top if needed.

>> This patch is mostly about renaming things, but as in some places 1) and
>> 2) have gotten mixed up, additional changes were needed to untangle
>> them. This is mostly just adding a new parameter to some functions so
>> that we pass both the vc and the channel.
> 
> It would ease review if this could be split in two patches.

Ok. I'll see if I can split this up without a huge amount of work. They are a bit tangled up... But
I agree, this is a bit too big patch.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if'
  2020-12-01  0:22   ` Laurent Pinchart
@ 2020-12-01 11:26     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 11:26 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 01/12/2020 02:22, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:26PM +0200, Tomi Valkeinen wrote:
>> We have a useless 'if' in the dsicm_bl_update_status(), a left over from
>> the conversion to DRM model. Drop the if.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> ---
>>  drivers/gpu/drm/panel/panel-dsi-cm.c | 10 ++++------
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
>> index 1e7f73340736..c17ed728c695 100644
>> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
>> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
>> @@ -194,7 +194,7 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata)
>>  static int dsicm_bl_update_status(struct backlight_device *dev)
>>  {
>>  	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
>> -	int r = 0;
>> +	int r;
>>  	int level;
>>  
>>  	if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
>> @@ -207,11 +207,9 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
>>  
>>  	mutex_lock(&ddata->lock);
>>  
>> -	if (ddata->enabled) {
>> -		if (!r)
>> -			r = dsicm_dcs_write_1(
>> -				ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
>> -	}
>> +	if (ddata->enabled)
>> +		r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
>> +				      level);
> 
> If !ddata->enabled, won't r be uninitialized ?

Yes. I wonder how I missed that... I'll keep the "r = 0" initialization.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver
  2020-12-01  0:23   ` Laurent Pinchart
@ 2020-12-01 11:29     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 11:29 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 01/12/2020 02:23, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:27PM +0200, Tomi Valkeinen wrote:
>> Add a panel database to the driver instead of reading propertes from DT
>> data. This is similar to panel-simple, and I believe it's more future
>> safe way to handle the panels.
> 
> No need to care about backward compatibility ?

I don't think this breaks backward compatibility. The data from the board files is now in the panel
driver. The old dts files should continue working fine.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes
  2020-12-01  0:27   ` Laurent Pinchart
@ 2020-12-01 11:33     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 11:33 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 01/12/2020 02:27, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:28PM +0200, Tomi Valkeinen wrote:
>> Drop unneeded includes.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> ---
>>  drivers/gpu/drm/panel/panel-dsi-cm.c | 5 -----
>>  1 file changed, 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
>> index ec87b785871f..91ed8237a1c2 100644
>> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
>> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
>> @@ -9,12 +9,7 @@
>>  #include <linux/backlight.h>
>>  #include <linux/delay.h>
>>  #include <linux/gpio/consumer.h>
>> -#include <linux/interrupt.h>
> 
> This could go to the patch that moves TE handling to the code.

True.

>>  #include <linux/jiffies.h>
>> -#include <linux/module.h>
> 
> I'd keep module.h as you use macros it defines, and we shouldn't depend
> in indirect includes.

Ok.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 71/80] drm/omap: dsi: move structs & defines to dsi.h
  2020-12-01  0:31   ` Laurent Pinchart
@ 2020-12-01 11:37     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 11:37 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 01/12/2020 02:31, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:29PM +0200, Tomi Valkeinen wrote:
>> Move structs and defines to a private dsi.h header file to make dsi.c a
>> bit easier to navigate. Also move the (now) private structs and defines
>> from omapdss.h to dsi.h.
> 
> I usually tend to keep structures used by a single .c file in that file,
> but it's a matter of personal preference I suppose.

We already had dsi.h. After all the recent changes, it was now only used by dsi.c. So I could have
moved everything from there to dsi.c. But dsi.c was pretty crowded already, and I had trouble
navigating it, so I thought it's better to move structs and macros from dsi.c to dsi.h.

>> +struct dsi_reg { u16 module; u16 idx; };
> 
> How about using the common kernel coding style ?
> 
> struct dsi_reg {
> 	u16 module;
> 	u16 idx;
> };

Ok.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 76/80] drm/omap: dsi: cleanup initial vc setup
  2020-12-01  0:36   ` Laurent Pinchart
@ 2020-12-01 11:51     ` Tomi Valkeinen
  0 siblings, 0 replies; 152+ messages in thread
From: Tomi Valkeinen @ 2020-12-01 11:51 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

On 01/12/2020 02:36, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Tue, Nov 24, 2020 at 02:45:34PM +0200, Tomi Valkeinen wrote:
>> As we now have a fixed setup for VCs (VC0 for video stream, VC1 for
>> commands), we can simplify the VC setup.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> ---
>>  drivers/gpu/drm/omapdrm/dss/dsi.c | 85 +++++++++++--------------------
>>  1 file changed, 31 insertions(+), 54 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
>> index ff8ace957291..27d0d119668b 100644
>> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
>> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
>> @@ -2017,40 +2017,6 @@ static void dsi_vc_initial_config(struct dsi_data *dsi, int vc)
>>  	dsi->vc[vc].source = DSI_VC_SOURCE_L4;
>>  }
>>  
>> -static int dsi_vc_config_source(struct dsi_data *dsi, int vc,
>> -				enum dsi_vc_source source)
>> -{
>> -	if (dsi->vc[vc].source == source)
>> -		return 0;
>> -
>> -	DSSDBG("Source config of VC %d", vc);
>> -
>> -	dsi_sync_vc(dsi, vc);
>> -
>> -	dsi_vc_enable(dsi, vc, 0);
>> -
>> -	/* VC_BUSY */
>> -	if (!wait_for_bit_change(dsi, DSI_VC_CTRL(vc), 15, 0)) {
>> -		DSSERR("vc(%d) busy when trying to config for VP\n", vc);
>> -		return -EIO;
>> -	}
>> -
>> -	/* SOURCE, 0 = L4, 1 = video port */
>> -	REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), source, 1, 1);
>> -
>> -	/* DCS_CMD_ENABLE */
>> -	if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) {
>> -		bool enable = source == DSI_VC_SOURCE_VP;
>> -		REG_FLD_MOD(dsi, DSI_VC_CTRL(vc), enable, 30, 30);
>> -	}
>> -
>> -	dsi_vc_enable(dsi, vc, 1);
>> -
>> -	dsi->vc[vc].source = source;
>> -
>> -	return 0;
>> -}
>> -
>>  static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
>>  		bool enable)
>>  {
>> @@ -2072,10 +2038,6 @@ static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int vc,
>>  	dsi_if_enable(dsi, 1);
>>  
>>  	dsi_force_tx_stop_mode_io(dsi);
>> -
>> -	/* start the DDR clock by sending a NULL packet */
>> -	if (dsi->vm_timings.ddr_clk_always_on && enable)
>> -		dsi_vc_send_null(dsi, vc, dsi->dsidev->channel);
>>  }
>>  
>>  static void dsi_vc_flush_long_data(struct dsi_data *dsi, int vc)
>> @@ -2270,8 +2232,6 @@ static int dsi_vc_send_long(struct dsi_data *dsi, int vc,
>>  		return -EINVAL;
>>  	}
>>  
>> -	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
>> -
>>  	dsi_vc_write_long_header(dsi, vc, msg->channel, msg->type, msg->tx_len, 0);
>>  
>>  	p = msg->tx_buf;
>> @@ -2331,8 +2291,6 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int vc,
>>  		DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
>>  		       vc, msg->type, pkt.header[1], pkt.header[2]);
>>  
>> -	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_L4);
>> -
>>  	if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(vc)), 16, 16)) {
>>  		DSSERR("ERROR FIFO FULL, aborting transfer\n");
>>  		return -EINVAL;
>> @@ -3351,8 +3309,6 @@ static void dsi_update_screen_dispc(struct dsi_data *dsi)
>>  
>>  	DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h);
>>  
>> -	dsi_vc_config_source(dsi, vc, DSI_VC_SOURCE_VP);
>> -
>>  	bytespp	= mipi_dsi_pixel_format_to_bpp(dsi->pix_fmt) / 8;
>>  	bytespl = w * bytespp;
>>  	bytespf = bytespl * h;
>> @@ -3522,9 +3478,7 @@ static int dsi_update_channel(struct omap_dss_device *dssdev, int vc)
>>  
>>  	dsi_set_ulps_auto(dsi, false);
>>  
>> -	dsi_vc_enable_hs(dssdev, vc, !(dsi->dsidev->mode_flags & MIPI_DSI_MODE_LPM));
> 
> Why is this not needed anymore ?

This is in dsi_update_channel(), so about sending the frame. We always want to send the frame in HS,
and we set the VC to HS in the dsi_setup_dsi_vcs() in this patch. So there's no longer need to
configure the speed for each dsi_update_channel invocation.

So there's a slight change in behavior, as before this patch you could send frames in LP, but can't
after this. But who would want to do that...

I think I can clean this up by changing "drm/omap: dsi: set LP/HS before update" to "always enable
HS before update". And then dropping the line here.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if'
  2020-11-24 12:45 ` [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
  2020-11-24 17:34   ` Sam Ravnborg
  2020-12-01  0:22   ` Laurent Pinchart
@ 2020-12-02 20:08   ` kernel test robot
  2 siblings, 0 replies; 152+ messages in thread
From: kernel test robot @ 2020-12-02 20:08 UTC (permalink / raw)
  To: Tomi Valkeinen, Sebastian Reichel, Laurent Pinchart,
	Nikhil Devshatwar, linux-omap, dri-devel
  Cc: kbuild-all, clang-built-linux, Tony Lindgren, hns,
	Tomi Valkeinen, Sekhar Nori

[-- Attachment #1: Type: text/plain, Size: 3281 bytes --]

Hi Tomi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on omap/for-next]
[also build test WARNING on robh/for-next balbi-usb/testing/next linus/master v5.10-rc6]
[cannot apply to next-20201201]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tomi-Valkeinen/Convert-DSI-code-to-use-drm_mipi_dsi-and-drm_panel/20201124-205129
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git for-next
config: riscv-randconfig-r016-20201202 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 2671fccf0381769276ca8246ec0499adcb9b0355)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/09d304dc23e60a46580ec8a3d7db7210138fc9db
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tomi-Valkeinen/Convert-DSI-code-to-use-drm_mipi_dsi-and-drm_panel/20201124-205129
        git checkout 09d304dc23e60a46580ec8a3d7db7210138fc9db
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/panel/panel-dsi-cm.c:210:6: warning: variable 'r' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (ddata->enabled)
               ^~~~~~~~~~~~~~
   drivers/gpu/drm/panel/panel-dsi-cm.c:216:9: note: uninitialized use occurs here
           return r;
                  ^
   drivers/gpu/drm/panel/panel-dsi-cm.c:210:2: note: remove the 'if' if its condition is always true
           if (ddata->enabled)
           ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/panel/panel-dsi-cm.c:197:7: note: initialize the variable 'r' to silence this warning
           int r;
                ^
                 = 0
   1 warning generated.

vim +210 drivers/gpu/drm/panel/panel-dsi-cm.c

   193	
   194	static int dsicm_bl_update_status(struct backlight_device *dev)
   195	{
   196		struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
   197		int r;
   198		int level;
   199	
   200		if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
   201				dev->props.power == FB_BLANK_UNBLANK)
   202			level = dev->props.brightness;
   203		else
   204			level = 0;
   205	
   206		dev_dbg(&ddata->dsi->dev, "update brightness to %d\n", level);
   207	
   208		mutex_lock(&ddata->lock);
   209	
 > 210		if (ddata->enabled)
   211			r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
   212					      level);
   213	
   214		mutex_unlock(&ddata->lock);
   215	
   216		return r;
   217	}
   218	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28684 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 50/80] drm/omap: squash omapdrm sub-modules into one
  2020-11-24 12:45 ` [PATCH v4 50/80] drm/omap: squash omapdrm sub-modules into one Tomi Valkeinen
@ 2020-12-14 12:53   ` Sebastian Reichel
  0 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:53 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 22246 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:08PM +0200, Tomi Valkeinen wrote:
> At the moment we have three different modules: omapdss-base, omapdss,
> omapdrm. This setup is finally obsolete, as the last omapdrm specific
> panel has been converted to DRM panel.
> 
> We can thus remove omapdss-base and omapdss, and just compile everything
> into omapdrm.ko.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/omapdrm/Kconfig       | 119 ++++++++++++++++++++++-
>  drivers/gpu/drm/omapdrm/Makefile      |  17 +++-
>  drivers/gpu/drm/omapdrm/dss/Kconfig   | 132 --------------------------
>  drivers/gpu/drm/omapdrm/dss/Makefile  |  18 ----
>  drivers/gpu/drm/omapdrm/dss/base.c    |  24 +----
>  drivers/gpu/drm/omapdrm/dss/display.c |   2 -
>  drivers/gpu/drm/omapdrm/dss/dss.c     |  11 +--
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |   3 +
>  drivers/gpu/drm/omapdrm/dss/output.c  |  11 ---
>  drivers/gpu/drm/omapdrm/omap_drv.c    |  20 +++-
>  10 files changed, 155 insertions(+), 202 deletions(-)
>  delete mode 100644 drivers/gpu/drm/omapdrm/dss/Kconfig
>  delete mode 100644 drivers/gpu/drm/omapdrm/dss/Makefile
> 
> diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
> index cea3f44ea6d4..e7281da5bc6a 100644
> --- a/drivers/gpu/drm/omapdrm/Kconfig
> +++ b/drivers/gpu/drm/omapdrm/Kconfig
> @@ -5,12 +5,129 @@ config DRM_OMAP
>  	depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
>  	select OMAP2_DSS
>  	select DRM_KMS_HELPER
> +	select VIDEOMODE_HELPERS
> +	select HDMI
>  	default n
>  	help
>  	  DRM display driver for OMAP2/3/4 based boards.
>  
>  if DRM_OMAP
>  
> -source "drivers/gpu/drm/omapdrm/dss/Kconfig"
> +config OMAP2_DSS_DEBUG
> +	bool "Debug support"
> +	default n
> +	help
> +	  This enables printing of debug messages. Alternatively, debug messages
> +	  can also be enabled by setting CONFIG_DYNAMIC_DEBUG and then setting
> +	  appropriate flags in <debugfs>/dynamic_debug/control.
> +
> +config OMAP2_DSS_DEBUGFS
> +	bool "Debugfs filesystem support"
> +	depends on DEBUG_FS
> +	default n
> +	help
> +	  This enables debugfs for OMAPDSS at <debugfs>/omapdss. This enables
> +	  querying about clock configuration and register configuration of dss,
> +	  dispc, dsi, hdmi and rfbi.
> +
> +config OMAP2_DSS_COLLECT_IRQ_STATS
> +	bool "Collect DSS IRQ statistics"
> +	depends on OMAP2_DSS_DEBUGFS
> +	default n
> +	help
> +	  Collect DSS IRQ statistics, printable via debugfs.
> +
> +	  The statistics can be found from
> +	  <debugfs>/omapdss/dispc_irq for DISPC interrupts, and
> +	  <debugfs>/omapdss/dsi_irq for DSI interrupts.
> +
> +config OMAP2_DSS_DPI
> +	bool "DPI support"
> +	default y
> +	help
> +	  DPI Interface. This is the Parallel Display Interface.
> +
> +config OMAP2_DSS_VENC
> +	bool "VENC support"
> +	default y
> +	help
> +	  OMAP Video Encoder support for S-Video and composite TV-out.
> +
> +config OMAP2_DSS_HDMI_COMMON
> +	bool
> +
> +config OMAP4_DSS_HDMI
> +	bool "HDMI support for OMAP4"
> +	default y
> +	select OMAP2_DSS_HDMI_COMMON
> +	help
> +	  HDMI support for OMAP4 based SoCs.
> +
> +config OMAP4_DSS_HDMI_CEC
> +	bool "Enable HDMI CEC support for OMAP4"
> +	depends on OMAP4_DSS_HDMI
> +	select CEC_CORE
> +	default y
> +	help
> +	  When selected the HDMI transmitter will support the CEC feature.
> +
> +config OMAP5_DSS_HDMI
> +	bool "HDMI support for OMAP5"
> +	default n
> +	select OMAP2_DSS_HDMI_COMMON
> +	help
> +	  HDMI Interface for OMAP5 and similar cores. This adds the High
> +	  Definition Multimedia Interface. See http://www.hdmi.org/ for HDMI
> +	  specification.
> +
> +config OMAP2_DSS_SDI
> +	bool "SDI support"
> +	default n
> +	help
> +	  SDI (Serial Display Interface) support.
> +
> +	  SDI is a high speed one-way display serial bus between the host
> +	  processor and a display.
> +
> +config OMAP2_DSS_DSI
> +	bool "DSI support"
> +	default n
> +	select DRM_MIPI_DSI
> +	help
> +	  MIPI DSI (Display Serial Interface) support.
> +
> +	  DSI is a high speed half-duplex serial interface between the host
> +	  processor and a peripheral, such as a display or a framebuffer chip.
> +
> +	  See http://www.mipi.org/ for DSI specifications.
> +
> +config OMAP2_DSS_MIN_FCK_PER_PCK
> +	int "Minimum FCK/PCK ratio (for scaling)"
> +	range 0 32
> +	default 0
> +	help
> +	  This can be used to adjust the minimum FCK/PCK ratio.
> +
> +	  With this you can make sure that DISPC FCK is at least
> +	  n x PCK. Video plane scaling requires higher FCK than
> +	  normally.
> +
> +	  If this is set to 0, there's no extra constraint on the
> +	  DISPC FCK. However, the FCK will at minimum be
> +	  2xPCK (if active matrix) or 3xPCK (if passive matrix).
> +
> +	  Max FCK is 173MHz, so this doesn't work if your PCK
> +	  is very high.
> +
> +config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
> +	bool "Sleep 20ms after VENC reset"
> +	default y
> +	help
> +	  There is a 20ms sleep after VENC reset which seemed to fix the
> +	  reset. The reason for the bug is unclear, and it's also unclear
> +	  on what platforms this happens.
> +
> +	  This option enables the sleep, and is enabled by default. You can
> +	  disable the sleep if it doesn't cause problems on your platform.
>  
>  endif
> diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
> index 2a404e045b78..33fe7e937680 100644
> --- a/drivers/gpu/drm/omapdrm/Makefile
> +++ b/drivers/gpu/drm/omapdrm/Makefile
> @@ -4,8 +4,6 @@
>  # Direct Rendering Infrastructure (DRI)
>  #
>  
> -obj-y += dss/
> -
>  omapdrm-y := omap_drv.o \
>  	omap_irq.o \
>  	omap_debugfs.o \
> @@ -20,4 +18,17 @@ omapdrm-y := omap_drv.o \
>  
>  omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
>  
> -obj-$(CONFIG_DRM_OMAP)	+= omapdrm.o
> +omapdrm-y += dss/base.o dss/display.o dss/output.o dss/dss.o dss/dispc.o \
> +		dss/dispc_coefs.o dss/pll.o dss/video-pll.o
> +omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
> +omapdrm-$(CONFIG_OMAP2_DSS_SDI) += dss/sdi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_DSI) += dss/dsi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += dss/hdmi_common.o dss/hdmi_wp.o \
> +		dss/hdmi_pll.o dss/hdmi_phy.o
> +omapdrm-$(CONFIG_OMAP4_DSS_HDMI) += dss/hdmi4.o dss/hdmi4_core.o
> +omapdrm-$(CONFIG_OMAP4_DSS_HDMI_CEC) += dss/hdmi4_cec.o
> +omapdrm-$(CONFIG_OMAP5_DSS_HDMI) += dss/hdmi5.o dss/hdmi5_core.o
> +ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
> +
> +obj-$(CONFIG_DRM_OMAP) += omapdrm.o
> diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
> deleted file mode 100644
> index 6ec80771af3d..000000000000
> --- a/drivers/gpu/drm/omapdrm/dss/Kconfig
> +++ /dev/null
> @@ -1,132 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0-only
> -config OMAP_DSS_BASE
> -	tristate
> -
> -menuconfig OMAP2_DSS
> -	tristate "OMAP2+ Display Subsystem support"
> -	select OMAP_DSS_BASE
> -	select VIDEOMODE_HELPERS
> -	select HDMI
> -	help
> -	  OMAP2+ Display Subsystem support.
> -
> -if OMAP2_DSS
> -
> -config OMAP2_DSS_DEBUG
> -	bool "Debug support"
> -	default n
> -	help
> -	  This enables printing of debug messages. Alternatively, debug messages
> -	  can also be enabled by setting CONFIG_DYNAMIC_DEBUG and then setting
> -	  appropriate flags in <debugfs>/dynamic_debug/control.
> -
> -config OMAP2_DSS_DEBUGFS
> -	bool "Debugfs filesystem support"
> -	depends on DEBUG_FS
> -	default n
> -	help
> -	  This enables debugfs for OMAPDSS at <debugfs>/omapdss. This enables
> -	  querying about clock configuration and register configuration of dss,
> -	  dispc, dsi, hdmi and rfbi.
> -
> -config OMAP2_DSS_COLLECT_IRQ_STATS
> -	bool "Collect DSS IRQ statistics"
> -	depends on OMAP2_DSS_DEBUGFS
> -	default n
> -	help
> -	  Collect DSS IRQ statistics, printable via debugfs.
> -
> -	  The statistics can be found from
> -	  <debugfs>/omapdss/dispc_irq for DISPC interrupts, and
> -	  <debugfs>/omapdss/dsi_irq for DSI interrupts.
> -
> -config OMAP2_DSS_DPI
> -	bool "DPI support"
> -	default y
> -	help
> -	  DPI Interface. This is the Parallel Display Interface.
> -
> -config OMAP2_DSS_VENC
> -	bool "VENC support"
> -	default y
> -	help
> -	  OMAP Video Encoder support for S-Video and composite TV-out.
> -
> -config OMAP2_DSS_HDMI_COMMON
> -	bool
> -
> -config OMAP4_DSS_HDMI
> -	bool "HDMI support for OMAP4"
> -	default y
> -	select OMAP2_DSS_HDMI_COMMON
> -	help
> -	  HDMI support for OMAP4 based SoCs.
> -
> -config OMAP4_DSS_HDMI_CEC
> -	bool "Enable HDMI CEC support for OMAP4"
> -	depends on OMAP4_DSS_HDMI
> -	select CEC_CORE
> -	default y
> -	help
> -	  When selected the HDMI transmitter will support the CEC feature.
> -
> -config OMAP5_DSS_HDMI
> -	bool "HDMI support for OMAP5"
> -	default n
> -	select OMAP2_DSS_HDMI_COMMON
> -	help
> -	  HDMI Interface for OMAP5 and similar cores. This adds the High
> -	  Definition Multimedia Interface. See http://www.hdmi.org/ for HDMI
> -	  specification.
> -
> -config OMAP2_DSS_SDI
> -	bool "SDI support"
> -	default n
> -	help
> -	  SDI (Serial Display Interface) support.
> -
> -	  SDI is a high speed one-way display serial bus between the host
> -	  processor and a display.
> -
> -config OMAP2_DSS_DSI
> -	bool "DSI support"
> -	default n
> -	select DRM_MIPI_DSI
> -	help
> -	  MIPI DSI (Display Serial Interface) support.
> -
> -	  DSI is a high speed half-duplex serial interface between the host
> -	  processor and a peripheral, such as a display or a framebuffer chip.
> -
> -	  See http://www.mipi.org/ for DSI specifications.
> -
> -config OMAP2_DSS_MIN_FCK_PER_PCK
> -	int "Minimum FCK/PCK ratio (for scaling)"
> -	range 0 32
> -	default 0
> -	help
> -	  This can be used to adjust the minimum FCK/PCK ratio.
> -
> -	  With this you can make sure that DISPC FCK is at least
> -	  n x PCK. Video plane scaling requires higher FCK than
> -	  normally.
> -
> -	  If this is set to 0, there's no extra constraint on the
> -	  DISPC FCK. However, the FCK will at minimum be
> -	  2xPCK (if active matrix) or 3xPCK (if passive matrix).
> -
> -	  Max FCK is 173MHz, so this doesn't work if your PCK
> -	  is very high.
> -
> -config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
> -	bool "Sleep 20ms after VENC reset"
> -	default y
> -	help
> -	  There is a 20ms sleep after VENC reset which seemed to fix the
> -	  reset. The reason for the bug is unclear, and it's also unclear
> -	  on what platforms this happens.
> -
> -	  This option enables the sleep, and is enabled by default. You can
> -	  disable the sleep if it doesn't cause problems on your platform.
> -
> -endif
> diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile
> deleted file mode 100644
> index 811966cd7468..000000000000
> --- a/drivers/gpu/drm/omapdrm/dss/Makefile
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -# SPDX-License-Identifier: GPL-2.0
> -obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o
> -omapdss-base-y := base.o display.o output.o
> -
> -obj-$(CONFIG_OMAP2_DSS) += omapdss.o
> -# Core DSS files
> -omapdss-y := dss.o dispc.o dispc_coefs.o \
> -	pll.o video-pll.o
> -omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
> -omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
> -omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
> -omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o
> -omapdss-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += hdmi_common.o hdmi_wp.o hdmi_pll.o \
> -	hdmi_phy.o
> -omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi4_core.o
> -omapdss-$(CONFIG_OMAP4_DSS_HDMI_CEC) += hdmi4_cec.o
> -omapdss-$(CONFIG_OMAP5_DSS_HDMI) += hdmi5.o hdmi5_core.o
> -ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
> diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
> index d0d5d9c8ca76..6c57d9292415 100644
> --- a/drivers/gpu/drm/omapdrm/dss/base.c
> +++ b/drivers/gpu/drm/omapdrm/dss/base.c
> @@ -20,14 +20,11 @@ struct dispc_device *dispc_get_dispc(struct dss_device *dss)
>  {
>  	return dss->dispc;
>  }
> -EXPORT_SYMBOL(dispc_get_dispc);
>  
>  const struct dispc_ops *dispc_get_ops(struct dss_device *dss)
>  {
>  	return dss->dispc_ops;
>  }
> -EXPORT_SYMBOL(dispc_get_ops);
> -
>  
>  /* -----------------------------------------------------------------------------
>   * OMAP DSS Devices Handling
> @@ -42,7 +39,6 @@ void omapdss_device_register(struct omap_dss_device *dssdev)
>  	list_add_tail(&dssdev->list, &omapdss_devices_list);
>  	mutex_unlock(&omapdss_devices_lock);
>  }
> -EXPORT_SYMBOL_GPL(omapdss_device_register);
>  
>  void omapdss_device_unregister(struct omap_dss_device *dssdev)
>  {
> @@ -50,7 +46,6 @@ void omapdss_device_unregister(struct omap_dss_device *dssdev)
>  	list_del(&dssdev->list);
>  	mutex_unlock(&omapdss_devices_lock);
>  }
> -EXPORT_SYMBOL_GPL(omapdss_device_unregister);
>  
>  static bool omapdss_device_is_registered(struct device_node *node)
>  {
> @@ -72,24 +67,16 @@ static bool omapdss_device_is_registered(struct device_node *node)
>  
>  struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev)
>  {
> -	if (!try_module_get(dssdev->owner))
> +	if (get_device(dssdev->dev) == NULL)
>  		return NULL;
>  
> -	if (get_device(dssdev->dev) == NULL) {
> -		module_put(dssdev->owner);
> -		return NULL;
> -	}
> -
>  	return dssdev;
>  }
> -EXPORT_SYMBOL(omapdss_device_get);
>  
>  void omapdss_device_put(struct omap_dss_device *dssdev)
>  {
>  	put_device(dssdev->dev);
> -	module_put(dssdev->owner);
>  }
> -EXPORT_SYMBOL(omapdss_device_put);
>  
>  struct omap_dss_device *omapdss_find_device_by_node(struct device_node *node)
>  {
> @@ -150,7 +137,6 @@ struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from)
>  	mutex_unlock(&omapdss_devices_lock);
>  	return dssdev;
>  }
> -EXPORT_SYMBOL(omapdss_device_next_output);
>  
>  static bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
>  {
> @@ -181,7 +167,6 @@ int omapdss_device_connect(struct dss_device *dss,
>  
>  	return 0;
>  }
> -EXPORT_SYMBOL_GPL(omapdss_device_connect);
>  
>  void omapdss_device_disconnect(struct omap_dss_device *src,
>  			       struct omap_dss_device *dst)
> @@ -204,7 +189,6 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
>  
>  	dst->dss = NULL;
>  }
> -EXPORT_SYMBOL_GPL(omapdss_device_disconnect);
>  
>  /* -----------------------------------------------------------------------------
>   * Components Handling
> @@ -290,7 +274,6 @@ void omapdss_gather_components(struct device *dev)
>  	for_each_available_child_of_node(dev->of_node, child)
>  		omapdss_walk_device(dev, child, true);
>  }
> -EXPORT_SYMBOL(omapdss_gather_components);
>  
>  static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
>  {
> @@ -315,8 +298,3 @@ bool omapdss_stack_is_ready(void)
>  
>  	return true;
>  }
> -EXPORT_SYMBOL(omapdss_stack_is_ready);
> -
> -MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
> -MODULE_DESCRIPTION("OMAP Display Subsystem Base");
> -MODULE_LICENSE("GPL v2");
> diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
> index 3b82158b1bfd..7b7ee2019eae 100644
> --- a/drivers/gpu/drm/omapdrm/dss/display.c
> +++ b/drivers/gpu/drm/omapdrm/dss/display.c
> @@ -38,7 +38,6 @@ void omapdss_display_init(struct omap_dss_device *dssdev)
>  		dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
>  					      "display%u", id);
>  }
> -EXPORT_SYMBOL_GPL(omapdss_display_init);
>  
>  int omapdss_display_get_modes(struct drm_connector *connector,
>  			      const struct videomode *vm)
> @@ -57,4 +56,3 @@ int omapdss_display_get_modes(struct drm_connector *connector,
>  
>  	return 1;
>  }
> -EXPORT_SYMBOL_GPL(omapdss_display_get_modes);
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 6a160138bf88..2d566ff81c55 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -1638,21 +1638,14 @@ static struct platform_driver * const omap_dss_drivers[] = {
>  #endif
>  };
>  
> -static int __init omap_dss_init(void)
> +int __init omap_dss_init(void)
>  {
>  	return platform_register_drivers(omap_dss_drivers,
>  					 ARRAY_SIZE(omap_dss_drivers));
>  }
>  
> -static void __exit omap_dss_exit(void)
> +void omap_dss_exit(void)
>  {
>  	platform_unregister_drivers(omap_dss_drivers,
>  				    ARRAY_SIZE(omap_dss_drivers));
>  }
> -
> -module_init(omap_dss_init);
> -module_exit(omap_dss_exit);
> -
> -MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
> -MODULE_DESCRIPTION("OMAP2/3/4/5 Display Subsystem");
> -MODULE_LICENSE("GPL v2");
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 4a0826c8fed5..4e7ae164de4f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -458,4 +458,7 @@ const struct dispc_ops *dispc_get_ops(struct dss_device *dss);
>  bool omapdss_stack_is_ready(void);
>  void omapdss_gather_components(struct device *dev);
>  
> +int omap_dss_init(void);
> +void omap_dss_exit(void);
> +
>  #endif /* __OMAP_DRM_DSS_H */
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index 40cb353572f6..7a14d2b5b2f7 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -73,7 +73,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
>  	omapdss_device_cleanup_output(out);
>  	return ret;
>  }
> -EXPORT_SYMBOL(omapdss_device_init_output);
>  
>  void omapdss_device_cleanup_output(struct omap_dss_device *out)
>  {
> @@ -81,7 +80,6 @@ void omapdss_device_cleanup_output(struct omap_dss_device *out)
>  		drm_panel_bridge_remove(out->next_bridge ?
>  					out->next_bridge : out->bridge);
>  }
> -EXPORT_SYMBOL(omapdss_device_cleanup_output);
>  
>  int dss_install_mgr_ops(struct dss_device *dss,
>  			const struct dss_mgr_ops *mgr_ops,
> @@ -95,14 +93,12 @@ int dss_install_mgr_ops(struct dss_device *dss,
>  
>  	return 0;
>  }
> -EXPORT_SYMBOL(dss_install_mgr_ops);
>  
>  void dss_uninstall_mgr_ops(struct dss_device *dss)
>  {
>  	dss->mgr_ops = NULL;
>  	dss->mgr_ops_priv = NULL;
>  }
> -EXPORT_SYMBOL(dss_uninstall_mgr_ops);
>  
>  void dss_mgr_set_timings(struct omap_dss_device *dssdev,
>  			 const struct videomode *vm)
> @@ -110,7 +106,6 @@ void dss_mgr_set_timings(struct omap_dss_device *dssdev,
>  	dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv,
>  					  dssdev->dispc_channel, vm);
>  }
> -EXPORT_SYMBOL(dss_mgr_set_timings);
>  
>  void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
>  		const struct dss_lcd_mgr_config *config)
> @@ -118,28 +113,24 @@ void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
>  	dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv,
>  					     dssdev->dispc_channel, config);
>  }
> -EXPORT_SYMBOL(dss_mgr_set_lcd_config);
>  
>  int dss_mgr_enable(struct omap_dss_device *dssdev)
>  {
>  	return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv,
>  					    dssdev->dispc_channel);
>  }
> -EXPORT_SYMBOL(dss_mgr_enable);
>  
>  void dss_mgr_disable(struct omap_dss_device *dssdev)
>  {
>  	dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv,
>  				      dssdev->dispc_channel);
>  }
> -EXPORT_SYMBOL(dss_mgr_disable);
>  
>  void dss_mgr_start_update(struct omap_dss_device *dssdev)
>  {
>  	dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv,
>  					   dssdev->dispc_channel);
>  }
> -EXPORT_SYMBOL(dss_mgr_start_update);
>  
>  int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data)
> @@ -150,7 +141,6 @@ int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
>  							dssdev->dispc_channel,
>  							handler, data);
>  }
> -EXPORT_SYMBOL(dss_mgr_register_framedone_handler);
>  
>  void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data)
> @@ -161,4 +151,3 @@ void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
>  						   dssdev->dispc_channel,
>  						   handler, data);
>  }
> -EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler);
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index dbb8e95234b3..b6ba4a43f217 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -741,9 +741,21 @@ static struct platform_driver * const drivers[] = {
>  
>  static int __init omap_drm_init(void)
>  {
> +	int r;
> +
>  	DBG("init");
>  
> -	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
> +	r = omap_dss_init();
> +	if (r)
> +		return r;
> +
> +	r = platform_register_drivers(drivers, ARRAY_SIZE(drivers));
> +	if (r) {
> +		omap_dss_exit();
> +		return r;
> +	}
> +
> +	return 0;
>  }
>  
>  static void __exit omap_drm_fini(void)
> @@ -751,13 +763,15 @@ static void __exit omap_drm_fini(void)
>  	DBG("fini");
>  
>  	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
> +
> +	omap_dss_exit();
>  }
>  
> -/* need late_initcall() so we load after dss_driver's are loaded */
> -late_initcall(omap_drm_init);
> +module_init(omap_drm_init);
>  module_exit(omap_drm_fini);
>  
>  MODULE_AUTHOR("Rob Clark <rob@ti.com>");
> +MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
>  MODULE_DESCRIPTION("OMAP DRM Display Driver");
>  MODULE_ALIAS("platform:" DRIVER_NAME);
>  MODULE_LICENSE("GPL v2");
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 51/80] drm/omap: remove unused display.c
  2020-11-24 12:45 ` [PATCH v4 51/80] drm/omap: remove unused display.c Tomi Valkeinen
@ 2020-12-14 12:53   ` Sebastian Reichel
  0 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:53 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 3896 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:09PM +0200, Tomi Valkeinen wrote:
> The functions in display.c are not used, so drop the file.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/omapdrm/Makefile      |  2 +-
>  drivers/gpu/drm/omapdrm/dss/display.c | 58 ---------------------------
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |  4 --
>  3 files changed, 1 insertion(+), 63 deletions(-)
>  delete mode 100644 drivers/gpu/drm/omapdrm/dss/display.c
> 
> diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
> index 33fe7e937680..21e8277ff88f 100644
> --- a/drivers/gpu/drm/omapdrm/Makefile
> +++ b/drivers/gpu/drm/omapdrm/Makefile
> @@ -18,7 +18,7 @@ omapdrm-y := omap_drv.o \
>  
>  omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
>  
> -omapdrm-y += dss/base.o dss/display.o dss/output.o dss/dss.o dss/dispc.o \
> +omapdrm-y += dss/base.o dss/output.o dss/dss.o dss/dispc.o \
>  		dss/dispc_coefs.o dss/pll.o dss/video-pll.o
>  omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
>  omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
> diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c
> deleted file mode 100644
> index 7b7ee2019eae..000000000000
> --- a/drivers/gpu/drm/omapdrm/dss/display.c
> +++ /dev/null
> @@ -1,58 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * Copyright (C) 2009 Nokia Corporation
> - * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
> - *
> - * Some code and ideas taken from drivers/video/omap/ driver
> - * by Imre Deak.
> - */
> -
> -#define DSS_SUBSYS_NAME "DISPLAY"
> -
> -#include <linux/kernel.h>
> -#include <linux/of.h>
> -
> -#include <drm/drm_connector.h>
> -#include <drm/drm_modes.h>
> -
> -#include "omapdss.h"
> -
> -static int disp_num_counter;
> -
> -void omapdss_display_init(struct omap_dss_device *dssdev)
> -{
> -	int id;
> -
> -	/*
> -	 * Note: this presumes that all displays either have an DT alias, or
> -	 * none has.
> -	 */
> -	id = of_alias_get_id(dssdev->dev->of_node, "display");
> -	if (id < 0)
> -		id = disp_num_counter++;
> -
> -	/* Use 'label' property for name, if it exists */
> -	of_property_read_string(dssdev->dev->of_node, "label", &dssdev->name);
> -
> -	if (dssdev->name == NULL)
> -		dssdev->name = devm_kasprintf(dssdev->dev, GFP_KERNEL,
> -					      "display%u", id);
> -}
> -
> -int omapdss_display_get_modes(struct drm_connector *connector,
> -			      const struct videomode *vm)
> -{
> -	struct drm_display_mode *mode;
> -
> -	mode = drm_mode_create(connector->dev);
> -	if (!mode)
> -		return 0;
> -
> -	drm_display_mode_from_videomode(vm, mode);
> -
> -	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> -	drm_mode_set_name(mode);
> -	drm_mode_probed_add(connector, mode);
> -
> -	return 1;
> -}
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 4e7ae164de4f..90e41c635e45 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -300,10 +300,6 @@ struct dss_pdata {
>  	struct dss_device *dss;
>  };
>  
> -void omapdss_display_init(struct omap_dss_device *dssdev);
> -int omapdss_display_get_modes(struct drm_connector *connector,
> -			      const struct videomode *vm);
> -
>  void omapdss_device_register(struct omap_dss_device *dssdev);
>  void omapdss_device_unregister(struct omap_dss_device *dssdev);
>  struct omap_dss_device *omapdss_device_get(struct omap_dss_device *dssdev);
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 52/80] drm/omap: drop unused owner field
  2020-11-24 12:45 ` [PATCH v4 52/80] drm/omap: drop unused owner field Tomi Valkeinen
@ 2020-12-14 12:53   ` Sebastian Reichel
  0 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:53 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 4639 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:10PM +0200, Tomi Valkeinen wrote:
> dssdev->owner is set, but never used. We can drop the field.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dpi.c     | 1 -
>  drivers/gpu/drm/omapdrm/dss/dsi.c     | 1 -
>  drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 1 -
>  drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 1 -
>  drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 --
>  drivers/gpu/drm/omapdrm/dss/sdi.c     | 1 -
>  drivers/gpu/drm/omapdrm/dss/venc.c    | 1 -
>  7 files changed, 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
> index 1d2992daef40..030f997eccd0 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dpi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
> @@ -641,7 +641,6 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
>  	out->type = OMAP_DISPLAY_TYPE_DPI;
>  	out->dispc_channel = dpi_get_channel(dpi);
>  	out->of_port = port_num;
> -	out->owner = THIS_MODULE;
>  
>  	r = omapdss_device_init_output(out, &dpi->bridge);
>  	if (r < 0) {
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 1ea490e4fc9d..c3592c6db977 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5442,7 +5442,6 @@ static int dsi_init_output(struct dsi_data *dsi)
>  	out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
>  	out->dispc_channel = dsi_get_channel(dsi);
>  	out->dsi_ops = &dsi_ops;
> -	out->owner = THIS_MODULE;
>  	out->of_port = 0;
>  	out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE
>  		       | DRM_BUS_FLAG_DE_HIGH
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> index a14fbf06cb30..13701571d59b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
> @@ -707,7 +707,6 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
>  	out->type = OMAP_DISPLAY_TYPE_HDMI;
>  	out->name = "hdmi.0";
>  	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
> -	out->owner = THIS_MODULE;
>  	out->of_port = 0;
>  
>  	r = omapdss_device_init_output(out, &hdmi->bridge);
> diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> index b738d9750686..5d627caf90f2 100644
> --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
> @@ -681,7 +681,6 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
>  	out->type = OMAP_DISPLAY_TYPE_HDMI;
>  	out->name = "hdmi.0";
>  	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
> -	out->owner = THIS_MODULE;
>  	out->of_port = 0;
>  
>  	r = omapdss_device_init_output(out, &hdmi->bridge);
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 90e41c635e45..4442e49ffc5c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -263,8 +263,6 @@ struct omapdss_dsi_ops {
>  struct omap_dss_device {
>  	struct device *dev;
>  
> -	struct module *owner;
> -
>  	struct dss_device *dss;
>  	struct drm_bridge *bridge;
>  	struct drm_bridge *next_bridge;
> diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
> index 033fd30074b0..35827b4487bd 100644
> --- a/drivers/gpu/drm/omapdrm/dss/sdi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
> @@ -314,7 +314,6 @@ static int sdi_init_output(struct sdi_device *sdi)
>  	out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
>  	/* We have SDI only on OMAP3, where it's on port 1 */
>  	out->of_port = 1;
> -	out->owner = THIS_MODULE;
>  	out->bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE	/* 15.5.9.1.2 */
>  		       | DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE;
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
> index 6e418a0f7572..8ecffe5bbd29 100644
> --- a/drivers/gpu/drm/omapdrm/dss/venc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/venc.c
> @@ -730,7 +730,6 @@ static int venc_init_output(struct venc_device *venc)
>  	out->type = OMAP_DISPLAY_TYPE_VENC;
>  	out->name = "venc.0";
>  	out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
> -	out->owner = THIS_MODULE;
>  	out->of_port = 0;
>  
>  	r = omapdss_device_init_output(out, &venc->bridge);
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 53/80] drm/omap: remove dispc_ops
  2020-11-24 12:45 ` [PATCH v4 53/80] drm/omap: remove dispc_ops Tomi Valkeinen
@ 2020-12-14 12:54   ` Sebastian Reichel
  0 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:54 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 36561 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:11PM +0200, Tomi Valkeinen wrote:
> dispc_ops was created to help with the multi-module architecture and
> giving us the possibility of multiple dispc implementations. Neither of
> these is valid anymore, and we can remove dispc_ops and use direct
> calls to dispc.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/base.c    |   5 --
>  drivers/gpu/drm/omapdrm/dss/dispc.c   | 101 +++++++-------------------
>  drivers/gpu/drm/omapdrm/dss/dss.h     |  71 +++++++++++++++++-
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |  71 ------------------
>  drivers/gpu/drm/omapdrm/omap_crtc.c   |  30 ++++----
>  drivers/gpu/drm/omapdrm/omap_drv.c    |  15 ++--
>  drivers/gpu/drm/omapdrm/omap_drv.h    |   2 +-
>  drivers/gpu/drm/omapdrm/omap_irq.c    |  34 ++++-----
>  drivers/gpu/drm/omapdrm/omap_plane.c  |  12 +--
>  9 files changed, 143 insertions(+), 198 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
> index 6c57d9292415..ee71b05ef567 100644
> --- a/drivers/gpu/drm/omapdrm/dss/base.c
> +++ b/drivers/gpu/drm/omapdrm/dss/base.c
> @@ -21,11 +21,6 @@ struct dispc_device *dispc_get_dispc(struct dss_device *dss)
>  	return dss->dispc;
>  }
>  
> -const struct dispc_ops *dispc_get_ops(struct dss_device *dss)
> -{
> -	return dss->dispc_ops;
> -}
> -
>  /* -----------------------------------------------------------------------------
>   * OMAP DSS Devices Handling
>   */
> diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
> index 48593932bddf..509bac99cb57 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dispc.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
> @@ -351,8 +351,6 @@ static unsigned long dispc_plane_pclk_rate(struct dispc_device *dispc,
>  static unsigned long dispc_plane_lclk_rate(struct dispc_device *dispc,
>  					   enum omap_plane_id plane);
>  
> -static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
> -
>  static inline void dispc_write_reg(struct dispc_device *dispc, u16 idx, u32 val)
>  {
>  	__raw_writel(val, dispc->base + idx);
> @@ -379,12 +377,12 @@ static void mgr_fld_write(struct dispc_device *dispc, enum omap_channel channel,
>  	REG_FLD_MOD(dispc, rfld->reg, val, rfld->high, rfld->low);
>  }
>  
> -static int dispc_get_num_ovls(struct dispc_device *dispc)
> +int dispc_get_num_ovls(struct dispc_device *dispc)
>  {
>  	return dispc->feat->num_ovls;
>  }
>  
> -static int dispc_get_num_mgrs(struct dispc_device *dispc)
> +int dispc_get_num_mgrs(struct dispc_device *dispc)
>  {
>  	return dispc->feat->num_mgrs;
>  }
> @@ -667,13 +665,13 @@ void dispc_runtime_put(struct dispc_device *dispc)
>  	WARN_ON(r < 0 && r != -ENOSYS);
>  }
>  
> -static u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
> +u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
>  				   enum omap_channel channel)
>  {
>  	return mgr_desc[channel].vsync_irq;
>  }
>  
> -static u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
> +u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
>  				       enum omap_channel channel)
>  {
>  	if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc->feat->no_framedone_tv)
> @@ -682,18 +680,18 @@ static u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
>  	return mgr_desc[channel].framedone_irq;
>  }
>  
> -static u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
> +u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
>  				       enum omap_channel channel)
>  {
>  	return mgr_desc[channel].sync_lost_irq;
>  }
>  
> -static u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
> +u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
>  {
>  	return DISPC_IRQ_FRAMEDONEWB;
>  }
>  
> -static void dispc_mgr_enable(struct dispc_device *dispc,
> +void dispc_mgr_enable(struct dispc_device *dispc,
>  			     enum omap_channel channel, bool enable)
>  {
>  	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_ENABLE, enable);
> @@ -707,13 +705,13 @@ static bool dispc_mgr_is_enabled(struct dispc_device *dispc,
>  	return !!mgr_fld_read(dispc, channel, DISPC_MGR_FLD_ENABLE);
>  }
>  
> -static bool dispc_mgr_go_busy(struct dispc_device *dispc,
> +bool dispc_mgr_go_busy(struct dispc_device *dispc,
>  			      enum omap_channel channel)
>  {
>  	return mgr_fld_read(dispc, channel, DISPC_MGR_FLD_GO) == 1;
>  }
>  
> -static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
> +void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
>  {
>  	WARN_ON(!dispc_mgr_is_enabled(dispc, channel));
>  	WARN_ON(dispc_mgr_go_busy(dispc, channel));
> @@ -723,12 +721,12 @@ static void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel)
>  	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_GO, 1);
>  }
>  
> -static bool dispc_wb_go_busy(struct dispc_device *dispc)
> +bool dispc_wb_go_busy(struct dispc_device *dispc)
>  {
>  	return REG_GET(dispc, DISPC_CONTROL2, 6, 6) == 1;
>  }
>  
> -static void dispc_wb_go(struct dispc_device *dispc)
> +void dispc_wb_go(struct dispc_device *dispc)
>  {
>  	enum omap_plane_id plane = OMAP_DSS_WB;
>  	bool enable, go;
> @@ -1282,7 +1280,7 @@ static bool dispc_ovl_color_mode_supported(struct dispc_device *dispc,
>  	return false;
>  }
>  
> -static const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
> +const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
>  					    enum omap_plane_id plane)
>  {
>  	return dispc->feat->supported_color_modes[plane];
> @@ -2761,7 +2759,7 @@ static int dispc_ovl_setup_common(struct dispc_device *dispc,
>  	return 0;
>  }
>  
> -static int dispc_ovl_setup(struct dispc_device *dispc,
> +int dispc_ovl_setup(struct dispc_device *dispc,
>  			   enum omap_plane_id plane,
>  			   const struct omap_overlay_info *oi,
>  			   const struct videomode *vm, bool mem_to_mem,
> @@ -2788,7 +2786,7 @@ static int dispc_ovl_setup(struct dispc_device *dispc,
>  	return r;
>  }
>  
> -static int dispc_wb_setup(struct dispc_device *dispc,
> +int dispc_wb_setup(struct dispc_device *dispc,
>  		   const struct omap_dss_writeback_info *wi,
>  		   bool mem_to_mem, const struct videomode *vm,
>  		   enum dss_writeback_channel channel_in)
> @@ -2871,12 +2869,12 @@ static int dispc_wb_setup(struct dispc_device *dispc,
>  	return 0;
>  }
>  
> -static bool dispc_has_writeback(struct dispc_device *dispc)
> +bool dispc_has_writeback(struct dispc_device *dispc)
>  {
>  	return dispc->feat->has_writeback;
>  }
>  
> -static int dispc_ovl_enable(struct dispc_device *dispc,
> +int dispc_ovl_enable(struct dispc_device *dispc,
>  			    enum omap_plane_id plane, bool enable)
>  {
>  	DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
> @@ -2967,7 +2965,7 @@ static void dispc_mgr_enable_alpha_fixed_zorder(struct dispc_device *dispc,
>  		REG_FLD_MOD(dispc, DISPC_CONFIG, enable, 19, 19);
>  }
>  
> -static void dispc_mgr_setup(struct dispc_device *dispc,
> +void dispc_mgr_setup(struct dispc_device *dispc,
>  			    enum omap_channel channel,
>  			    const struct omap_overlay_manager_info *info)
>  {
> @@ -3046,7 +3044,7 @@ static void dispc_mgr_enable_stallmode(struct dispc_device *dispc,
>  	mgr_fld_write(dispc, channel, DISPC_MGR_FLD_STALLMODE, enable);
>  }
>  
> -static void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
> +void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
>  				     enum omap_channel channel,
>  				     const struct dss_lcd_mgr_config *config)
>  {
> @@ -3095,7 +3093,7 @@ static bool _dispc_mgr_pclk_ok(struct dispc_device *dispc,
>  		return pclk <= dispc->feat->max_tv_pclk;
>  }
>  
> -static int dispc_mgr_check_timings(struct dispc_device *dispc,
> +int dispc_mgr_check_timings(struct dispc_device *dispc,
>  				   enum omap_channel channel,
>  				   const struct videomode *vm)
>  {
> @@ -3188,7 +3186,7 @@ static int vm_flag_to_int(enum display_flags flags, enum display_flags high,
>  }
>  
>  /* change name to mode? */
> -static void dispc_mgr_set_timings(struct dispc_device *dispc,
> +void dispc_mgr_set_timings(struct dispc_device *dispc,
>  				  enum omap_channel channel,
>  				  const struct videomode *vm)
>  {
> @@ -3732,17 +3730,17 @@ int dispc_mgr_get_clock_div(struct dispc_device *dispc,
>  	return 0;
>  }
>  
> -static u32 dispc_read_irqstatus(struct dispc_device *dispc)
> +u32 dispc_read_irqstatus(struct dispc_device *dispc)
>  {
>  	return dispc_read_reg(dispc, DISPC_IRQSTATUS);
>  }
>  
> -static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
> +void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask)
>  {
>  	dispc_write_reg(dispc, DISPC_IRQSTATUS, mask);
>  }
>  
> -static void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
> +void dispc_write_irqenable(struct dispc_device *dispc, u32 mask)
>  {
>  	u32 old_mask = dispc_read_reg(dispc, DISPC_IRQENABLE);
>  
> @@ -3766,7 +3764,7 @@ void dispc_disable_sidle(struct dispc_device *dispc)
>  	REG_FLD_MOD(dispc, DISPC_SYSCONFIG, 1, 4, 3);	/* SIDLEMODE: no idle */
>  }
>  
> -static u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
> +u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
>  				enum omap_channel channel)
>  {
>  	const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
> @@ -3821,7 +3819,7 @@ static const struct drm_color_lut dispc_mgr_gamma_default_lut[] = {
>  	{ .red = U16_MAX, .green = U16_MAX, .blue = U16_MAX, },
>  };
>  
> -static void dispc_mgr_set_gamma(struct dispc_device *dispc,
> +void dispc_mgr_set_gamma(struct dispc_device *dispc,
>  				enum omap_channel channel,
>  				const struct drm_color_lut *lut,
>  				unsigned int length)
> @@ -4479,7 +4477,7 @@ static irqreturn_t dispc_irq_handler(int irq, void *arg)
>  	return dispc->user_handler(irq, dispc->user_data);
>  }
>  
> -static int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
> +int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
>  			     void *dev_id)
>  {
>  	int r;
> @@ -4503,7 +4501,7 @@ static int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
>  	return r;
>  }
>  
> -static void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
> +void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
>  {
>  	devm_free_irq(&dispc->pdev->dev, dispc->irq, dispc);
>  
> @@ -4511,7 +4509,7 @@ static void dispc_free_irq(struct dispc_device *dispc, void *dev_id)
>  	dispc->user_data = NULL;
>  }
>  
> -static u32 dispc_get_memory_bandwidth_limit(struct dispc_device *dispc)
> +u32 dispc_get_memory_bandwidth_limit(struct dispc_device *dispc)
>  {
>  	u32 limit = 0;
>  
> @@ -4681,47 +4679,6 @@ static void dispc_errata_i734_wa(struct dispc_device *dispc)
>  	REG_FLD_MOD(dispc, DISPC_CONFIG, gatestate, 8, 4);
>  }
>  
> -static const struct dispc_ops dispc_ops = {
> -	.read_irqstatus = dispc_read_irqstatus,
> -	.clear_irqstatus = dispc_clear_irqstatus,
> -	.write_irqenable = dispc_write_irqenable,
> -
> -	.request_irq = dispc_request_irq,
> -	.free_irq = dispc_free_irq,
> -
> -	.runtime_get = dispc_runtime_get,
> -	.runtime_put = dispc_runtime_put,
> -
> -	.get_num_ovls = dispc_get_num_ovls,
> -	.get_num_mgrs = dispc_get_num_mgrs,
> -
> -	.get_memory_bandwidth_limit = dispc_get_memory_bandwidth_limit,
> -
> -	.mgr_enable = dispc_mgr_enable,
> -	.mgr_is_enabled = dispc_mgr_is_enabled,
> -	.mgr_get_vsync_irq = dispc_mgr_get_vsync_irq,
> -	.mgr_get_framedone_irq = dispc_mgr_get_framedone_irq,
> -	.mgr_get_sync_lost_irq = dispc_mgr_get_sync_lost_irq,
> -	.mgr_go_busy = dispc_mgr_go_busy,
> -	.mgr_go = dispc_mgr_go,
> -	.mgr_set_lcd_config = dispc_mgr_set_lcd_config,
> -	.mgr_check_timings = dispc_mgr_check_timings,
> -	.mgr_set_timings = dispc_mgr_set_timings,
> -	.mgr_setup = dispc_mgr_setup,
> -	.mgr_gamma_size = dispc_mgr_gamma_size,
> -	.mgr_set_gamma = dispc_mgr_set_gamma,
> -
> -	.ovl_enable = dispc_ovl_enable,
> -	.ovl_setup = dispc_ovl_setup,
> -	.ovl_get_color_modes = dispc_ovl_get_color_modes,
> -
> -	.wb_get_framedone_irq = dispc_wb_get_framedone_irq,
> -	.wb_setup = dispc_wb_setup,
> -	.has_writeback = dispc_has_writeback,
> -	.wb_go_busy = dispc_wb_go_busy,
> -	.wb_go = dispc_wb_go,
> -};
> -
>  /* DISPC HW IP initialisation */
>  static const struct of_device_id dispc_of_match[] = {
>  	{ .compatible = "ti,omap2-dispc", .data = &omap24xx_dispc_feats },
> @@ -4823,7 +4780,6 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
>  	dispc_runtime_put(dispc);
>  
>  	dss->dispc = dispc;
> -	dss->dispc_ops = &dispc_ops;
>  
>  	dispc->debugfs = dss_debugfs_create_file(dss, "dispc", dispc_dump_regs,
>  						 dispc);
> @@ -4845,7 +4801,6 @@ static void dispc_unbind(struct device *dev, struct device *master, void *data)
>  	dss_debugfs_remove_file(dispc->debugfs);
>  
>  	dss->dispc = NULL;
> -	dss->dispc_ops = NULL;
>  
>  	pm_runtime_disable(dev);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 2b404bcb41dd..96f702314c8c 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -257,7 +257,6 @@ struct dss_device {
>  	struct dss_pll	*video2_pll;
>  
>  	struct dispc_device *dispc;
> -	const struct dispc_ops *dispc_ops;
>  	const struct dss_mgr_ops *mgr_ops;
>  	struct omap_drm_private *mgr_ops_priv;
>  };
> @@ -393,6 +392,76 @@ void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s);
>  int dispc_runtime_get(struct dispc_device *dispc);
>  void dispc_runtime_put(struct dispc_device *dispc);
>  
> +int dispc_get_num_ovls(struct dispc_device *dispc);
> +int dispc_get_num_mgrs(struct dispc_device *dispc);
> +
> +const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
> +					    enum omap_plane_id plane);
> +
> +u32 dispc_read_irqstatus(struct dispc_device *dispc);
> +void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
> +void dispc_write_irqenable(struct dispc_device *dispc, u32 mask);
> +
> +int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
> +			     void *dev_id);
> +void dispc_free_irq(struct dispc_device *dispc, void *dev_id);
> +
> +u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
> +				   enum omap_channel channel);
> +u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
> +				       enum omap_channel channel);
> +u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
> +				       enum omap_channel channel);
> +u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc);
> +
> +u32 dispc_get_memory_bandwidth_limit(struct dispc_device *dispc);
> +
> +void dispc_mgr_enable(struct dispc_device *dispc,
> +			     enum omap_channel channel, bool enable);
> +
> +bool dispc_mgr_go_busy(struct dispc_device *dispc,
> +			      enum omap_channel channel);
> +
> +void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel);
> +
> +void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
> +				     enum omap_channel channel,
> +				     const struct dss_lcd_mgr_config *config);
> +void dispc_mgr_set_timings(struct dispc_device *dispc,
> +				  enum omap_channel channel,
> +				  const struct videomode *vm);
> +void dispc_mgr_setup(struct dispc_device *dispc,
> +			    enum omap_channel channel,
> +			    const struct omap_overlay_manager_info *info);
> +
> +int dispc_mgr_check_timings(struct dispc_device *dispc,
> +				   enum omap_channel channel,
> +				   const struct videomode *vm);
> +
> +u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
> +				enum omap_channel channel);
> +void dispc_mgr_set_gamma(struct dispc_device *dispc,
> +				enum omap_channel channel,
> +				const struct drm_color_lut *lut,
> +				unsigned int length);
> +
> +int dispc_ovl_setup(struct dispc_device *dispc,
> +			   enum omap_plane_id plane,
> +			   const struct omap_overlay_info *oi,
> +			   const struct videomode *vm, bool mem_to_mem,
> +			   enum omap_channel channel);
> +
> +int dispc_ovl_enable(struct dispc_device *dispc,
> +			    enum omap_plane_id plane, bool enable);
> +
> +bool dispc_has_writeback(struct dispc_device *dispc);
> +int dispc_wb_setup(struct dispc_device *dispc,
> +		   const struct omap_dss_writeback_info *wi,
> +		   bool mem_to_mem, const struct videomode *vm,
> +		   enum dss_writeback_channel channel_in);
> +bool dispc_wb_go_busy(struct dispc_device *dispc);
> +void dispc_wb_go(struct dispc_device *dispc);
> +
>  void dispc_enable_sidle(struct dispc_device *dispc);
>  void dispc_disable_sidle(struct dispc_device *dispc);
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 4442e49ffc5c..fba5f05e5e48 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -376,78 +376,7 @@ int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
>  void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
>  		void (*handler)(void *), void *data);
>  
> -/* dispc ops */
> -
> -struct dispc_ops {
> -	u32 (*read_irqstatus)(struct dispc_device *dispc);
> -	void (*clear_irqstatus)(struct dispc_device *dispc, u32 mask);
> -	void (*write_irqenable)(struct dispc_device *dispc, u32 mask);
> -
> -	int (*request_irq)(struct dispc_device *dispc, irq_handler_t handler,
> -			   void *dev_id);
> -	void (*free_irq)(struct dispc_device *dispc, void *dev_id);
> -
> -	int (*runtime_get)(struct dispc_device *dispc);
> -	void (*runtime_put)(struct dispc_device *dispc);
> -
> -	int (*get_num_ovls)(struct dispc_device *dispc);
> -	int (*get_num_mgrs)(struct dispc_device *dispc);
> -
> -	u32 (*get_memory_bandwidth_limit)(struct dispc_device *dispc);
> -
> -	void (*mgr_enable)(struct dispc_device *dispc,
> -			   enum omap_channel channel, bool enable);
> -	bool (*mgr_is_enabled)(struct dispc_device *dispc,
> -			       enum omap_channel channel);
> -	u32 (*mgr_get_vsync_irq)(struct dispc_device *dispc,
> -				 enum omap_channel channel);
> -	u32 (*mgr_get_framedone_irq)(struct dispc_device *dispc,
> -				     enum omap_channel channel);
> -	u32 (*mgr_get_sync_lost_irq)(struct dispc_device *dispc,
> -				     enum omap_channel channel);
> -	bool (*mgr_go_busy)(struct dispc_device *dispc,
> -			    enum omap_channel channel);
> -	void (*mgr_go)(struct dispc_device *dispc, enum omap_channel channel);
> -	void (*mgr_set_lcd_config)(struct dispc_device *dispc,
> -				   enum omap_channel channel,
> -				   const struct dss_lcd_mgr_config *config);
> -	int (*mgr_check_timings)(struct dispc_device *dispc,
> -				 enum omap_channel channel,
> -				 const struct videomode *vm);
> -	void (*mgr_set_timings)(struct dispc_device *dispc,
> -				enum omap_channel channel,
> -				const struct videomode *vm);
> -	void (*mgr_setup)(struct dispc_device *dispc, enum omap_channel channel,
> -			  const struct omap_overlay_manager_info *info);
> -	u32 (*mgr_gamma_size)(struct dispc_device *dispc,
> -			      enum omap_channel channel);
> -	void (*mgr_set_gamma)(struct dispc_device *dispc,
> -			      enum omap_channel channel,
> -			      const struct drm_color_lut *lut,
> -			      unsigned int length);
> -
> -	int (*ovl_enable)(struct dispc_device *dispc, enum omap_plane_id plane,
> -			  bool enable);
> -	int (*ovl_setup)(struct dispc_device *dispc, enum omap_plane_id plane,
> -			 const struct omap_overlay_info *oi,
> -			 const struct videomode *vm, bool mem_to_mem,
> -			 enum omap_channel channel);
> -
> -	const u32 *(*ovl_get_color_modes)(struct dispc_device *dispc,
> -					  enum omap_plane_id plane);
> -
> -	u32 (*wb_get_framedone_irq)(struct dispc_device *dispc);
> -	int (*wb_setup)(struct dispc_device *dispc,
> -		const struct omap_dss_writeback_info *wi,
> -		bool mem_to_mem, const struct videomode *vm,
> -		enum dss_writeback_channel channel_in);
> -	bool (*has_writeback)(struct dispc_device *dispc);
> -	bool (*wb_go_busy)(struct dispc_device *dispc);
> -	void (*wb_go)(struct dispc_device *dispc);
> -};
> -
>  struct dispc_device *dispc_get_dispc(struct dss_device *dss);
> -const struct dispc_ops *dispc_get_ops(struct dss_device *dss);
>  
>  bool omapdss_stack_is_ready(void);
>  void omapdss_gather_components(struct device *dev);
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
> index 5ab557c477ef..0bf5cef579b5 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -103,7 +103,7 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
>  static void omap_crtc_dss_start_update(struct omap_drm_private *priv,
>  				       enum omap_channel channel)
>  {
> -	priv->dispc_ops->mgr_enable(priv->dispc, channel, true);
> +	dispc_mgr_enable(priv->dispc, channel, true);
>  }
>  
>  /* Called only from the encoder enable/disable and suspend/resume handlers. */
> @@ -128,7 +128,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  	}
>  
>  	if (omap_crtc->pipe->output->type == OMAP_DISPLAY_TYPE_HDMI) {
> -		priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
> +		dispc_mgr_enable(priv->dispc, channel, enable);
>  		omap_crtc->enabled = enable;
>  		return;
>  	}
> @@ -141,9 +141,9 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  		omap_crtc->ignore_digit_sync_lost = true;
>  	}
>  
> -	framedone_irq = priv->dispc_ops->mgr_get_framedone_irq(priv->dispc,
> +	framedone_irq = dispc_mgr_get_framedone_irq(priv->dispc,
>  							       channel);
> -	vsync_irq = priv->dispc_ops->mgr_get_vsync_irq(priv->dispc, channel);
> +	vsync_irq = dispc_mgr_get_vsync_irq(priv->dispc, channel);
>  
>  	if (enable) {
>  		wait = omap_irq_wait_init(dev, vsync_irq, 1);
> @@ -163,7 +163,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  			wait = omap_irq_wait_init(dev, vsync_irq, 2);
>  	}
>  
> -	priv->dispc_ops->mgr_enable(priv->dispc, channel, enable);
> +	dispc_mgr_enable(priv->dispc, channel, enable);
>  	omap_crtc->enabled = enable;
>  
>  	ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100));
> @@ -186,7 +186,7 @@ static int omap_crtc_dss_enable(struct omap_drm_private *priv,
>  	struct drm_crtc *crtc = priv->channels[channel]->crtc;
>  	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
>  
> -	priv->dispc_ops->mgr_set_timings(priv->dispc, omap_crtc->channel,
> +	dispc_mgr_set_timings(priv->dispc, omap_crtc->channel,
>  					 &omap_crtc->vm);
>  	omap_crtc_set_enabled(&omap_crtc->base, true);
>  
> @@ -221,7 +221,7 @@ static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
>  	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
>  
>  	DBG("%s", omap_crtc->name);
> -	priv->dispc_ops->mgr_set_lcd_config(priv->dispc, omap_crtc->channel,
> +	dispc_mgr_set_lcd_config(priv->dispc, omap_crtc->channel,
>  					    config);
>  }
>  
> @@ -300,7 +300,7 @@ void omap_crtc_vblank_irq(struct drm_crtc *crtc)
>  	 * If the dispc is busy we're racing the flush operation. Try again on
>  	 * the next vblank interrupt.
>  	 */
> -	if (priv->dispc_ops->mgr_go_busy(priv->dispc, omap_crtc->channel)) {
> +	if (dispc_mgr_go_busy(priv->dispc, omap_crtc->channel)) {
>  		spin_unlock(&crtc->dev->event_lock);
>  		return;
>  	}
> @@ -391,7 +391,7 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc)
>  	info.partial_alpha_enabled = false;
>  	info.cpr_enable = false;
>  
> -	priv->dispc_ops->mgr_setup(priv->dispc, omap_crtc->channel, &info);
> +	dispc_mgr_setup(priv->dispc, omap_crtc->channel, &info);
>  }
>  
>  /* -----------------------------------------------------------------------------
> @@ -432,7 +432,7 @@ static void omap_crtc_atomic_enable(struct drm_crtc *crtc,
>  
>  	DBG("%s", omap_crtc->name);
>  
> -	priv->dispc_ops->runtime_get(priv->dispc);
> +	dispc_runtime_get(priv->dispc);
>  
>  	/* manual updated display will not trigger vsync irq */
>  	if (omap_state->manually_updated)
> @@ -471,7 +471,7 @@ static void omap_crtc_atomic_disable(struct drm_crtc *crtc,
>  
>  	drm_crtc_vblank_off(crtc);
>  
> -	priv->dispc_ops->runtime_put(priv->dispc);
> +	dispc_runtime_put(priv->dispc);
>  }
>  
>  static enum drm_mode_status omap_crtc_mode_valid(struct drm_crtc *crtc,
> @@ -490,7 +490,7 @@ static enum drm_mode_status omap_crtc_mode_valid(struct drm_crtc *crtc,
>  	 * proper DISPC mode later.
>  	 */
>  	if (omap_crtc->pipe->output->type != OMAP_DISPLAY_TYPE_DSI) {
> -		r = priv->dispc_ops->mgr_check_timings(priv->dispc,
> +		r = dispc_mgr_check_timings(priv->dispc,
>  						       omap_crtc->channel,
>  						       &vm);
>  		if (r)
> @@ -605,7 +605,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
>  			length = crtc->state->gamma_lut->length /
>  				sizeof(*lut);
>  		}
> -		priv->dispc_ops->mgr_set_gamma(priv->dispc, omap_crtc->channel,
> +		dispc_mgr_set_gamma(priv->dispc, omap_crtc->channel,
>  					       lut, length);
>  	}
>  
> @@ -630,7 +630,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
>  	WARN_ON(ret != 0);
>  
>  	spin_lock_irq(&crtc->dev->event_lock);
> -	priv->dispc_ops->mgr_go(priv->dispc, omap_crtc->channel);
> +	dispc_mgr_go(priv->dispc, omap_crtc->channel);
>  	omap_crtc_arm_event(crtc);
>  	spin_unlock_irq(&crtc->dev->event_lock);
>  }
> @@ -821,7 +821,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
>  	 * extracted with dispc_mgr_gamma_size(). If it returns 0
>  	 * gamma table is not supported.
>  	 */
> -	if (priv->dispc_ops->mgr_gamma_size(priv->dispc, channel)) {
> +	if (dispc_mgr_gamma_size(priv->dispc, channel)) {
>  		unsigned int gamma_lut_size = 256;
>  
>  		drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index b6ba4a43f217..46cb088c2977 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -69,7 +69,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
>  	struct drm_device *dev = old_state->dev;
>  	struct omap_drm_private *priv = dev->dev_private;
>  
> -	priv->dispc_ops->runtime_get(priv->dispc);
> +	dispc_runtime_get(priv->dispc);
>  
>  	/* Apply the atomic update. */
>  	drm_atomic_helper_commit_modeset_disables(dev, old_state);
> @@ -113,7 +113,7 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
>  
>  	drm_atomic_helper_cleanup_planes(dev, old_state);
>  
> -	priv->dispc_ops->runtime_put(priv->dispc);
> +	dispc_runtime_put(priv->dispc);
>  }
>  
>  static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs = {
> @@ -192,7 +192,7 @@ static int omap_compare_pipelines(const void *a, const void *b)
>  static int omap_modeset_init_properties(struct drm_device *dev)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
> +	unsigned int num_planes = dispc_get_num_ovls(priv->dispc);
>  
>  	priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0,
>  						      num_planes - 1);
> @@ -221,8 +221,8 @@ static int omap_display_id(struct omap_dss_device *output)
>  static int omap_modeset_init(struct drm_device *dev)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
> -	int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
> +	int num_ovls = dispc_get_num_ovls(priv->dispc);
> +	int num_mgrs = dispc_get_num_mgrs(priv->dispc);
>  	unsigned int i;
>  	int ret;
>  	u32 plane_crtc_mask;
> @@ -580,7 +580,6 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  	priv->dev = dev;
>  	priv->dss = pdata->dss;
>  	priv->dispc = dispc_get_dispc(priv->dss);
> -	priv->dispc_ops = dispc_get_ops(priv->dss);
>  
>  	omap_crtc_pre_init(priv);
>  
> @@ -592,9 +591,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  	INIT_LIST_HEAD(&priv->obj_list);
>  
>  	/* Get memory bandwidth limits */
> -	if (priv->dispc_ops->get_memory_bandwidth_limit)
> -		priv->max_bandwidth =
> -			priv->dispc_ops->get_memory_bandwidth_limit(priv->dispc);
> +	priv->max_bandwidth = dispc_get_memory_bandwidth_limit(priv->dispc);
>  
>  	omap_gem_init(ddev);
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index 93d171ffd26d..6e69358f624c 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -12,6 +12,7 @@
>  #include <linux/workqueue.h>
>  
>  #include "dss/omapdss.h"
> +#include "dss/dss.h"
>  
>  #include <drm/drm_gem.h>
>  #include <drm/omap_drm.h>
> @@ -46,7 +47,6 @@ struct omap_drm_private {
>  
>  	struct dss_device *dss;
>  	struct dispc_device *dispc;
> -	const struct dispc_ops *dispc_ops;
>  
>  	unsigned int num_pipes;
>  	struct omap_drm_pipeline pipes[8];
> diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
> index 382bcdc72ac0..981387220765 100644
> --- a/drivers/gpu/drm/omapdrm/omap_irq.c
> +++ b/drivers/gpu/drm/omapdrm/omap_irq.c
> @@ -29,7 +29,7 @@ static void omap_irq_update(struct drm_device *dev)
>  
>  	DBG("irqmask=%08x", irqmask);
>  
> -	priv->dispc_ops->write_irqenable(priv->dispc, irqmask);
> +	dispc_write_irqenable(priv->dispc, irqmask);
>  }
>  
>  static void omap_irq_wait_handler(struct omap_irq_wait *wait)
> @@ -83,7 +83,7 @@ int omap_irq_enable_framedone(struct drm_crtc *crtc, bool enable)
>  	unsigned long flags;
>  	enum omap_channel channel = omap_crtc_channel(crtc);
>  	int framedone_irq =
> -		priv->dispc_ops->mgr_get_framedone_irq(priv->dispc, channel);
> +		dispc_mgr_get_framedone_irq(priv->dispc, channel);
>  
>  	DBG("dev=%p, crtc=%u, enable=%d", dev, channel, enable);
>  
> @@ -121,7 +121,7 @@ int omap_irq_enable_vblank(struct drm_crtc *crtc)
>  	DBG("dev=%p, crtc=%u", dev, channel);
>  
>  	spin_lock_irqsave(&priv->wait_lock, flags);
> -	priv->irq_mask |= priv->dispc_ops->mgr_get_vsync_irq(priv->dispc,
> +	priv->irq_mask |= dispc_mgr_get_vsync_irq(priv->dispc,
>  							     channel);
>  	omap_irq_update(dev);
>  	spin_unlock_irqrestore(&priv->wait_lock, flags);
> @@ -148,7 +148,7 @@ void omap_irq_disable_vblank(struct drm_crtc *crtc)
>  	DBG("dev=%p, crtc=%u", dev, channel);
>  
>  	spin_lock_irqsave(&priv->wait_lock, flags);
> -	priv->irq_mask &= ~priv->dispc_ops->mgr_get_vsync_irq(priv->dispc,
> +	priv->irq_mask &= ~dispc_mgr_get_vsync_irq(priv->dispc,
>  							      channel);
>  	omap_irq_update(dev);
>  	spin_unlock_irqrestore(&priv->wait_lock, flags);
> @@ -213,9 +213,9 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
>  	unsigned int id;
>  	u32 irqstatus;
>  
> -	irqstatus = priv->dispc_ops->read_irqstatus(priv->dispc);
> -	priv->dispc_ops->clear_irqstatus(priv->dispc, irqstatus);
> -	priv->dispc_ops->read_irqstatus(priv->dispc);	/* flush posted write */
> +	irqstatus = dispc_read_irqstatus(priv->dispc);
> +	dispc_clear_irqstatus(priv->dispc, irqstatus);
> +	dispc_read_irqstatus(priv->dispc);	/* flush posted write */
>  
>  	VERB("irqs: %08x", irqstatus);
>  
> @@ -223,15 +223,15 @@ static irqreturn_t omap_irq_handler(int irq, void *arg)
>  		struct drm_crtc *crtc = priv->pipes[id].crtc;
>  		enum omap_channel channel = omap_crtc_channel(crtc);
>  
> -		if (irqstatus & priv->dispc_ops->mgr_get_vsync_irq(priv->dispc, channel)) {
> +		if (irqstatus & dispc_mgr_get_vsync_irq(priv->dispc, channel)) {
>  			drm_handle_vblank(dev, id);
>  			omap_crtc_vblank_irq(crtc);
>  		}
>  
> -		if (irqstatus & priv->dispc_ops->mgr_get_sync_lost_irq(priv->dispc, channel))
> +		if (irqstatus & dispc_mgr_get_sync_lost_irq(priv->dispc, channel))
>  			omap_crtc_error_irq(crtc, irqstatus);
>  
> -		if (irqstatus & priv->dispc_ops->mgr_get_framedone_irq(priv->dispc, channel))
> +		if (irqstatus & dispc_mgr_get_framedone_irq(priv->dispc, channel))
>  			omap_crtc_framedone_irq(crtc, irqstatus);
>  	}
>  
> @@ -265,7 +265,7 @@ static const u32 omap_underflow_irqs[] = {
>  int omap_drm_irq_install(struct drm_device *dev)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	unsigned int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
> +	unsigned int num_mgrs = dispc_get_num_mgrs(priv->dispc);
>  	unsigned int max_planes;
>  	unsigned int i;
>  	int ret;
> @@ -283,13 +283,13 @@ int omap_drm_irq_install(struct drm_device *dev)
>  	}
>  
>  	for (i = 0; i < num_mgrs; ++i)
> -		priv->irq_mask |= priv->dispc_ops->mgr_get_sync_lost_irq(priv->dispc, i);
> +		priv->irq_mask |= dispc_mgr_get_sync_lost_irq(priv->dispc, i);
>  
> -	priv->dispc_ops->runtime_get(priv->dispc);
> -	priv->dispc_ops->clear_irqstatus(priv->dispc, 0xffffffff);
> -	priv->dispc_ops->runtime_put(priv->dispc);
> +	dispc_runtime_get(priv->dispc);
> +	dispc_clear_irqstatus(priv->dispc, 0xffffffff);
> +	dispc_runtime_put(priv->dispc);
>  
> -	ret = priv->dispc_ops->request_irq(priv->dispc, omap_irq_handler, dev);
> +	ret = dispc_request_irq(priv->dispc, omap_irq_handler, dev);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -307,5 +307,5 @@ void omap_drm_irq_uninstall(struct drm_device *dev)
>  
>  	dev->irq_enabled = false;
>  
> -	priv->dispc_ops->free_irq(priv->dispc, dev);
> +	dispc_free_irq(priv->dispc, dev);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
> index 73ec99819a3d..88d2a986d880 100644
> --- a/drivers/gpu/drm/omapdrm/omap_plane.c
> +++ b/drivers/gpu/drm/omapdrm/omap_plane.c
> @@ -70,17 +70,17 @@ static void omap_plane_atomic_update(struct drm_plane *plane,
>  			&info.paddr, &info.p_uv_addr);
>  
>  	/* and finally, update omapdss: */
> -	ret = priv->dispc_ops->ovl_setup(priv->dispc, omap_plane->id, &info,
> +	ret = dispc_ovl_setup(priv->dispc, omap_plane->id, &info,
>  			      omap_crtc_timings(state->crtc), false,
>  			      omap_crtc_channel(state->crtc));
>  	if (ret) {
>  		dev_err(plane->dev->dev, "Failed to setup plane %s\n",
>  			omap_plane->name);
> -		priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, false);
> +		dispc_ovl_enable(priv->dispc, omap_plane->id, false);
>  		return;
>  	}
>  
> -	priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, true);
> +	dispc_ovl_enable(priv->dispc, omap_plane->id, true);
>  }
>  
>  static void omap_plane_atomic_disable(struct drm_plane *plane,
> @@ -93,7 +93,7 @@ static void omap_plane_atomic_disable(struct drm_plane *plane,
>  	plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY
>  			   ? 0 : omap_plane->id;
>  
> -	priv->dispc_ops->ovl_enable(priv->dispc, omap_plane->id, false);
> +	dispc_ovl_enable(priv->dispc, omap_plane->id, false);
>  }
>  
>  static int omap_plane_atomic_check(struct drm_plane *plane,
> @@ -252,7 +252,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
>  		u32 possible_crtcs)
>  {
>  	struct omap_drm_private *priv = dev->dev_private;
> -	unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
> +	unsigned int num_planes = dispc_get_num_ovls(priv->dispc);
>  	struct drm_plane *plane;
>  	struct omap_plane *omap_plane;
>  	enum omap_plane_id id;
> @@ -271,7 +271,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
>  	if (!omap_plane)
>  		return ERR_PTR(-ENOMEM);
>  
> -	formats = priv->dispc_ops->ovl_get_color_modes(priv->dispc, id);
> +	formats = dispc_ovl_get_color_modes(priv->dispc, id);
>  	for (nformats = 0; formats[nformats]; ++nformats)
>  		;
>  	omap_plane->id = id;
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 54/80] drm/omap: remove dss_mgr_ops
  2020-11-24 12:45 ` [PATCH v4 54/80] drm/omap: remove dss_mgr_ops Tomi Valkeinen
@ 2020-12-14 12:54   ` Sebastian Reichel
  0 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:54 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 12700 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:12PM +0200, Tomi Valkeinen wrote:
> dss_mgr_ops was needed with the multi-module architecture, but is no
> longer needed. We can thus remove it and use direct calls.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dss.h     |  1 -
>  drivers/gpu/drm/omapdrm/dss/omapdss.h | 42 +++++++++++----------------
>  drivers/gpu/drm/omapdrm/dss/output.c  | 33 +++++----------------
>  drivers/gpu/drm/omapdrm/omap_crtc.c   | 38 +++++-------------------
>  drivers/gpu/drm/omapdrm/omap_crtc.h   |  2 --
>  drivers/gpu/drm/omapdrm/omap_drv.c    |  4 +--
>  6 files changed, 33 insertions(+), 87 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h
> index 96f702314c8c..a547527bb2f3 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
> @@ -257,7 +257,6 @@ struct dss_device {
>  	struct dss_pll	*video2_pll;
>  
>  	struct dispc_device *dispc;
> -	const struct dss_mgr_ops *mgr_ops;
>  	struct omap_drm_private *mgr_ops_priv;
>  };
>  
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index fba5f05e5e48..9df322ca467d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -338,31 +338,23 @@ enum dss_writeback_channel {
>  	DSS_WB_LCD3_MGR =	7,
>  };
>  
> -struct dss_mgr_ops {
> -	void (*start_update)(struct omap_drm_private *priv,
> -			     enum omap_channel channel);
> -	int (*enable)(struct omap_drm_private *priv,
> -		      enum omap_channel channel);
> -	void (*disable)(struct omap_drm_private *priv,
> -			enum omap_channel channel);
> -	void (*set_timings)(struct omap_drm_private *priv,
> -			    enum omap_channel channel,
> -			    const struct videomode *vm);
> -	void (*set_lcd_config)(struct omap_drm_private *priv,
> -			       enum omap_channel channel,
> -			       const struct dss_lcd_mgr_config *config);
> -	int (*register_framedone_handler)(struct omap_drm_private *priv,
> -			enum omap_channel channel,
> -			void (*handler)(void *), void *data);
> -	void (*unregister_framedone_handler)(struct omap_drm_private *priv,
> -			enum omap_channel channel,
> -			void (*handler)(void *), void *data);
> -};
> -
> -int dss_install_mgr_ops(struct dss_device *dss,
> -			const struct dss_mgr_ops *mgr_ops,
> -			struct omap_drm_private *priv);
> -void dss_uninstall_mgr_ops(struct dss_device *dss);
> +void omap_crtc_dss_start_update(struct omap_drm_private *priv,
> +				       enum omap_channel channel);
> +void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable);
> +int omap_crtc_dss_enable(struct omap_drm_private *priv, enum omap_channel channel);
> +void omap_crtc_dss_disable(struct omap_drm_private *priv, enum omap_channel channel);
> +void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
> +		enum omap_channel channel,
> +		const struct videomode *vm);
> +void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
> +		enum omap_channel channel,
> +		const struct dss_lcd_mgr_config *config);
> +int omap_crtc_dss_register_framedone(
> +		struct omap_drm_private *priv, enum omap_channel channel,
> +		void (*handler)(void *), void *data);
> +void omap_crtc_dss_unregister_framedone(
> +		struct omap_drm_private *priv, enum omap_channel channel,
> +		void (*handler)(void *), void *data);
>  
>  void dss_mgr_set_timings(struct omap_dss_device *dssdev,
>  		const struct videomode *vm);
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index 7a14d2b5b2f7..2121c947947b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -81,54 +81,35 @@ void omapdss_device_cleanup_output(struct omap_dss_device *out)
>  					out->next_bridge : out->bridge);
>  }
>  
> -int dss_install_mgr_ops(struct dss_device *dss,
> -			const struct dss_mgr_ops *mgr_ops,
> -			struct omap_drm_private *priv)
> -{
> -	if (dss->mgr_ops)
> -		return -EBUSY;
> -
> -	dss->mgr_ops = mgr_ops;
> -	dss->mgr_ops_priv = priv;
> -
> -	return 0;
> -}
> -
> -void dss_uninstall_mgr_ops(struct dss_device *dss)
> -{
> -	dss->mgr_ops = NULL;
> -	dss->mgr_ops_priv = NULL;
> -}
> -
>  void dss_mgr_set_timings(struct omap_dss_device *dssdev,
>  			 const struct videomode *vm)
>  {
> -	dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv,
> +	omap_crtc_dss_set_timings(dssdev->dss->mgr_ops_priv,
>  					  dssdev->dispc_channel, vm);
>  }
>  
>  void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
>  		const struct dss_lcd_mgr_config *config)
>  {
> -	dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv,
> +	omap_crtc_dss_set_lcd_config(dssdev->dss->mgr_ops_priv,
>  					     dssdev->dispc_channel, config);
>  }
>  
>  int dss_mgr_enable(struct omap_dss_device *dssdev)
>  {
> -	return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv,
> +	return omap_crtc_dss_enable(dssdev->dss->mgr_ops_priv,
>  					    dssdev->dispc_channel);
>  }
>  
>  void dss_mgr_disable(struct omap_dss_device *dssdev)
>  {
> -	dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv,
> +	omap_crtc_dss_disable(dssdev->dss->mgr_ops_priv,
>  				      dssdev->dispc_channel);
>  }
>  
>  void dss_mgr_start_update(struct omap_dss_device *dssdev)
>  {
> -	dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv,
> +	omap_crtc_dss_start_update(dssdev->dss->mgr_ops_priv,
>  					   dssdev->dispc_channel);
>  }
>  
> @@ -137,7 +118,7 @@ int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
>  {
>  	struct dss_device *dss = dssdev->dss;
>  
> -	return dss->mgr_ops->register_framedone_handler(dss->mgr_ops_priv,
> +	return omap_crtc_dss_register_framedone(dss->mgr_ops_priv,
>  							dssdev->dispc_channel,
>  							handler, data);
>  }
> @@ -147,7 +128,7 @@ void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
>  {
>  	struct dss_device *dss = dssdev->dss;
>  
> -	dss->mgr_ops->unregister_framedone_handler(dss->mgr_ops_priv,
> +	omap_crtc_dss_unregister_framedone(dss->mgr_ops_priv,
>  						   dssdev->dispc_channel,
>  						   handler, data);
>  }
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
> index 0bf5cef579b5..e3259338afb9 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.c
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
> @@ -100,14 +100,14 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
>   * the upstream part of the video pipe.
>   */
>  
> -static void omap_crtc_dss_start_update(struct omap_drm_private *priv,
> +void omap_crtc_dss_start_update(struct omap_drm_private *priv,
>  				       enum omap_channel channel)
>  {
>  	dispc_mgr_enable(priv->dispc, channel, true);
>  }
>  
>  /* Called only from the encoder enable/disable and suspend/resume handlers. */
> -static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
> +void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  {
>  	struct omap_crtc_state *omap_state = to_omap_crtc_state(crtc->state);
>  	struct drm_device *dev = crtc->dev;
> @@ -180,8 +180,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
>  }
>  
>  
> -static int omap_crtc_dss_enable(struct omap_drm_private *priv,
> -				enum omap_channel channel)
> +int omap_crtc_dss_enable(struct omap_drm_private *priv, enum omap_channel channel)
>  {
>  	struct drm_crtc *crtc = priv->channels[channel]->crtc;
>  	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
> @@ -193,8 +192,7 @@ static int omap_crtc_dss_enable(struct omap_drm_private *priv,
>  	return 0;
>  }
>  
> -static void omap_crtc_dss_disable(struct omap_drm_private *priv,
> -				  enum omap_channel channel)
> +void omap_crtc_dss_disable(struct omap_drm_private *priv, enum omap_channel channel)
>  {
>  	struct drm_crtc *crtc = priv->channels[channel]->crtc;
>  	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
> @@ -202,7 +200,7 @@ static void omap_crtc_dss_disable(struct omap_drm_private *priv,
>  	omap_crtc_set_enabled(&omap_crtc->base, false);
>  }
>  
> -static void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
> +void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
>  		enum omap_channel channel,
>  		const struct videomode *vm)
>  {
> @@ -213,7 +211,7 @@ static void omap_crtc_dss_set_timings(struct omap_drm_private *priv,
>  	omap_crtc->vm = *vm;
>  }
>  
> -static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
> +void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
>  		enum omap_channel channel,
>  		const struct dss_lcd_mgr_config *config)
>  {
> @@ -225,7 +223,7 @@ static void omap_crtc_dss_set_lcd_config(struct omap_drm_private *priv,
>  					    config);
>  }
>  
> -static int omap_crtc_dss_register_framedone(
> +int omap_crtc_dss_register_framedone(
>  		struct omap_drm_private *priv, enum omap_channel channel,
>  		void (*handler)(void *), void *data)
>  {
> @@ -244,7 +242,7 @@ static int omap_crtc_dss_register_framedone(
>  	return 0;
>  }
>  
> -static void omap_crtc_dss_unregister_framedone(
> +void omap_crtc_dss_unregister_framedone(
>  		struct omap_drm_private *priv, enum omap_channel channel,
>  		void (*handler)(void *), void *data)
>  {
> @@ -261,16 +259,6 @@ static void omap_crtc_dss_unregister_framedone(
>  	omap_crtc->framedone_handler_data = NULL;
>  }
>  
> -static const struct dss_mgr_ops mgr_ops = {
> -	.start_update = omap_crtc_dss_start_update,
> -	.enable = omap_crtc_dss_enable,
> -	.disable = omap_crtc_dss_disable,
> -	.set_timings = omap_crtc_dss_set_timings,
> -	.set_lcd_config = omap_crtc_dss_set_lcd_config,
> -	.register_framedone_handler = omap_crtc_dss_register_framedone,
> -	.unregister_framedone_handler = omap_crtc_dss_unregister_framedone,
> -};
> -
>  /* -----------------------------------------------------------------------------
>   * Setup, Flush and Page Flip
>   */
> @@ -753,16 +741,6 @@ static const char *channel_names[] = {
>  	[OMAP_DSS_CHANNEL_LCD3] = "lcd3",
>  };
>  
> -void omap_crtc_pre_init(struct omap_drm_private *priv)
> -{
> -	dss_install_mgr_ops(priv->dss, &mgr_ops, priv);
> -}
> -
> -void omap_crtc_pre_uninit(struct omap_drm_private *priv)
> -{
> -	dss_uninstall_mgr_ops(priv->dss);
> -}
> -
>  /* initialize crtc */
>  struct drm_crtc *omap_crtc_init(struct drm_device *dev,
>  				struct omap_drm_pipeline *pipe,
> diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h b/drivers/gpu/drm/omapdrm/omap_crtc.h
> index 2fd57751ae2b..a8b9cbee86e0 100644
> --- a/drivers/gpu/drm/omapdrm/omap_crtc.h
> +++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
> @@ -22,8 +22,6 @@ struct videomode;
>  
>  struct videomode *omap_crtc_timings(struct drm_crtc *crtc);
>  enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
> -void omap_crtc_pre_init(struct omap_drm_private *priv);
> -void omap_crtc_pre_uninit(struct omap_drm_private *priv);
>  struct drm_crtc *omap_crtc_init(struct drm_device *dev,
>  				struct omap_drm_pipeline *pipe,
>  				struct drm_plane *plane);
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index 46cb088c2977..da7183e98e3f 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -581,7 +581,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  	priv->dss = pdata->dss;
>  	priv->dispc = dispc_get_dispc(priv->dss);
>  
> -	omap_crtc_pre_init(priv);
> +	priv->dss->mgr_ops_priv = priv;
>  
>  	soc = soc_device_match(omapdrm_soc_devices);
>  	priv->omaprev = soc ? (unsigned int)soc->data : 0;
> @@ -634,7 +634,6 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  	omap_gem_deinit(ddev);
>  	destroy_workqueue(priv->wq);
>  	omap_disconnect_pipelines(ddev);
> -	omap_crtc_pre_uninit(priv);
>  	drm_dev_put(ddev);
>  	return ret;
>  }
> @@ -660,7 +659,6 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
>  	destroy_workqueue(priv->wq);
>  
>  	omap_disconnect_pipelines(ddev);
> -	omap_crtc_pre_uninit(priv);
>  
>  	drm_dev_put(ddev);
>  }
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI
  2020-11-24 12:45 ` [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI Tomi Valkeinen
  2020-11-24 16:18   ` Sam Ravnborg
  2020-11-30  9:50   ` Laurent Pinchart
@ 2020-12-14 12:54   ` Sebastian Reichel
  2 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:54 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 1337 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:13PM +0200, Tomi Valkeinen wrote:
> Use the common MIPI_DCS_GET_ERROR_COUNT_ON_DSI define instead of
> driver's own.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/panel/panel-dsi-cm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index 35a0c7da1974..cb0d27a38555 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -27,7 +27,6 @@
>  #include <video/of_display_timing.h>
>  #include <video/videomode.h>
>  
> -#define DCS_READ_NUM_ERRORS	0x05
>  #define DCS_GET_ID1		0xda
>  #define DCS_GET_ID2		0xdb
>  #define DCS_GET_ID3		0xdc
> @@ -225,7 +224,7 @@ static ssize_t num_dsi_errors_show(struct device *dev,
>  	mutex_lock(&ddata->lock);
>  
>  	if (ddata->enabled)
> -		r = dsicm_dcs_read_1(ddata, DCS_READ_NUM_ERRORS, &errors);
> +		r = dsicm_dcs_read_1(ddata, MIPI_DCS_GET_ERROR_COUNT_ON_DSI, &errors);
>  
>  	mutex_unlock(&ddata->lock);
>  
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable
  2020-11-24 12:45 ` [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
  2020-11-24 17:25   ` Sam Ravnborg
  2020-11-30  9:51   ` Laurent Pinchart
@ 2020-12-14 12:54   ` Sebastian Reichel
  2 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:54 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:14PM +0200, Tomi Valkeinen wrote:
> Simplify the code by moving code from _dsicm_enable_te() into
> dsicm_power_on().
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/panel/panel-dsi-cm.c | 23 ++++-------------------
>  1 file changed, 4 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index cb0d27a38555..59e8e6b18e97 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -69,8 +69,6 @@ static inline struct panel_drv_data *panel_to_ddata(struct drm_panel *panel)
>  	return container_of(panel, struct panel_drv_data, panel);
>  }
>  
> -static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
> -
>  static void dsicm_bl_power(struct panel_drv_data *ddata, bool enable)
>  {
>  	struct backlight_device *backlight;
> @@ -314,10 +312,13 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
>  	if (r)
>  		goto err;
>  
> -	r = _dsicm_enable_te(ddata, true);
> +	r = mipi_dsi_dcs_set_tear_on(ddata->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
>  	if (r)
>  		goto err;
>  
> +	/* possible panel bug */
> +	msleep(100);
> +
>  	ddata->enabled = true;
>  
>  	if (!ddata->intro_printed) {
> @@ -418,22 +419,6 @@ static int dsicm_disable(struct drm_panel *panel)
>  	return r;
>  }
>  
> -static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
> -{
> -	struct mipi_dsi_device *dsi = ddata->dsi;
> -	int r;
> -
> -	if (enable)
> -		r = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
> -	else
> -		r = mipi_dsi_dcs_set_tear_off(dsi);
> -
> -	/* possible panel bug */
> -	msleep(100);
> -
> -	return r;
> -}
> -
>  static int dsicm_get_modes(struct drm_panel *panel,
>  			   struct drm_connector *connector)
>  {
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi
  2020-11-24 12:45 ` [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi Tomi Valkeinen
  2020-11-30  9:53   ` Laurent Pinchart
@ 2020-12-14 12:55   ` Sebastian Reichel
  1 sibling, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:55 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 1369 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:15PM +0200, Tomi Valkeinen wrote:
> Add address-cells & size-cells to DSI nodes so that board files do not
> need to define them.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  arch/arm/boot/dts/omap5.dtsi | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
> index 2bf2e5839a7f..e6f6947965ef 100644
> --- a/arch/arm/boot/dts/omap5.dtsi
> +++ b/arch/arm/boot/dts/omap5.dtsi
> @@ -517,6 +517,9 @@ dsi1: encoder@0 {
>  						clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>,
>  							 <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>;
>  						clock-names = "fck", "sys_clk";
> +
> +						#address-cells = <1>;
> +						#size-cells = <0>;
>  					};
>  				};
>  
> @@ -549,6 +552,9 @@ dsi2: encoder@0 {
>  						clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>,
>  							 <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>;
>  						clock-names = "fck", "sys_clk";
> +
> +						#address-cells = <1>;
> +						#size-cells = <0>;
>  					};
>  				};
>  
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 58/80] drm/omap: pll: fix iteration loop check
  2020-11-24 12:45 ` [PATCH v4 58/80] drm/omap: pll: fix iteration loop check Tomi Valkeinen
  2020-11-30  9:54   ` Laurent Pinchart
@ 2020-12-14 12:55   ` Sebastian Reichel
  1 sibling, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:55 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 1465 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:16PM +0200, Tomi Valkeinen wrote:
> If the PLL calc function is given bad parameters, n_start/m_start may be
> higher than n_stop/m_stop, which leads to the loops iterating through
> the whole u32 number space.
> 
> Fix this by failing early on such cases.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/pll.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c
> index 1212f3cc52d1..12926218c436 100644
> --- a/drivers/gpu/drm/omapdrm/dss/pll.c
> +++ b/drivers/gpu/drm/omapdrm/dss/pll.c
> @@ -222,6 +222,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
>  	n_stop = min((unsigned)(clkin / fint_hw_min), hw->n_max);
>  	n_inc = 1;
>  
> +	if (n_start > n_stop)
> +		return false;
> +
>  	if (hw->errata_i886) {
>  		swap(n_start, n_stop);
>  		n_inc = -1;
> @@ -239,6 +242,9 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
>  				hw->m_max);
>  		m_inc = 1;
>  
> +		if (m_start > m_stop)
> +			continue;
> +
>  		if (hw->errata_i886) {
>  			swap(m_start, m_stop);
>  			m_inc = -1;
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 59/80] drm/omap: dsi: set trans_mode according to client mode_flags
  2020-11-24 12:45 ` [PATCH v4 59/80] drm/omap: dsi: set trans_mode according to client mode_flags Tomi Valkeinen
  2020-11-30  9:55   ` Laurent Pinchart
@ 2020-12-14 12:56   ` Sebastian Reichel
  1 sibling, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:56 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 1395 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:17PM +0200, Tomi Valkeinen wrote:
> The DSI host driver currently ignores the video mode flags in
> client->mode_flags. Add the code to take the transfer mode from client's
> mode_flags.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index c3592c6db977..7fee9cf8782d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -5140,6 +5140,13 @@ static int omap_dsi_host_attach(struct mipi_dsi_host *host,
>  	dsi->config.lp_clk_min = 7000000; // TODO: get from client?
>  	dsi->config.lp_clk_max = client->lp_rate;
>  
> +	if (client->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
> +		dsi->config.trans_mode = OMAP_DSS_DSI_BURST_MODE;
> +	else if (client->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)
> +		dsi->config.trans_mode = OMAP_DSS_DSI_PULSE_MODE;
> +	else
> +		dsi->config.trans_mode = OMAP_DSS_DSI_EVENT_MODE;
> +
>  	dsi->ulps_auto_idle = false;
>  
>  	return 0;
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup
  2020-11-24 12:45 ` [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
  2020-11-24 17:30   ` Sam Ravnborg
  2020-11-30  9:56   ` Laurent Pinchart
@ 2020-12-14 12:59   ` Sebastian Reichel
  2 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2020-12-14 12:59 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Nikhil Devshatwar, linux-omap, dri-devel,
	Sekhar Nori, Tony Lindgren, hns

[-- Attachment #1: Type: text/plain, Size: 1866 bytes --]

Hi,

On Tue, Nov 24, 2020 at 02:45:18PM +0200, Tomi Valkeinen wrote:
> Set the column & page address once during setup, instead of relying the
> DSI host driver to set those.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---

I'm fine with or without removal of the variables:

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/panel/panel-dsi-cm.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index 59e8e6b18e97..1e7f73340736 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -171,6 +171,26 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3)
>  	return 0;
>  }
>  
> +static int dsicm_set_update_window(struct panel_drv_data *ddata)
> +{
> +	struct mipi_dsi_device *dsi = ddata->dsi;
> +	int r;
> +	u16 x1 = 0;
> +	u16 x2 = ddata->mode.hdisplay - 1;
> +	u16 y1 = 0;
> +	u16 y2 = ddata->mode.vdisplay - 1;
> +
> +	r = mipi_dsi_dcs_set_column_address(dsi, x1, x2);
> +	if (r < 0)
> +		return r;
> +
> +	r = mipi_dsi_dcs_set_page_address(dsi, y1, y2);
> +	if (r < 0)
> +		return r;
> +
> +	return 0;
> +}
> +
>  static int dsicm_bl_update_status(struct backlight_device *dev)
>  {
>  	struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev);
> @@ -308,6 +328,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
>  	if (r)
>  		goto err;
>  
> +	r = dsicm_set_update_window(ddata);
> +	if (r)
> +		goto err;
> +
>  	r = mipi_dsi_dcs_set_display_on(ddata->dsi);
>  	if (r)
>  		goto err;
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 39/80] drm/panel: Move OMAP's DSI command mode panel driver
  2020-11-24 12:44 ` [PATCH v4 39/80] drm/panel: Move OMAP's DSI command mode panel driver Tomi Valkeinen
@ 2021-01-08 21:23   ` Dixit, Ashutosh
  2021-01-08 21:54     ` Sebastian Reichel
  0 siblings, 1 reply; 152+ messages in thread
From: Dixit, Ashutosh @ 2021-01-08 21:23 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Tony Lindgren, hns, Sekhar Nori,
	Sebastian Reichel, Thierry Reding, Sam Ravnborg

On Tue, 24 Nov 2020 04:44:57 -0800, Tomi Valkeinen wrote:
>
> From: Sebastian Reichel <sebastian.reichel@collabora.com>
>
> The panel driver is no longer using any OMAP specific APIs, so
> let's move it into the generic panel directory.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/Kconfig                        |  1 -
>  drivers/gpu/drm/omapdrm/Makefile                       |  1 -
>  drivers/gpu/drm/omapdrm/displays/Kconfig               | 10 ----------
>  drivers/gpu/drm/omapdrm/displays/Makefile              |  2 --
>  drivers/gpu/drm/panel/Kconfig                          |  9 +++++++++
>  drivers/gpu/drm/panel/Makefile                         |  1 +
>  .../gpu/drm/{omapdrm/displays => panel}/panel-dsi-cm.c |  0

Not sure if it's a result of this commit but on drm-tip we see:

$ make allmodconfig
$ make modules_check
  DESCEND  objtool
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
error: the following would cause module name conflict:
  drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.ko
  drivers/gpu/drm/panel/panel-dsi-cm.ko
make: *** [Makefile:1400: modules_check] Error 1

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 39/80] drm/panel: Move OMAP's DSI command mode panel driver
  2021-01-08 21:23   ` Dixit, Ashutosh
@ 2021-01-08 21:54     ` Sebastian Reichel
  0 siblings, 0 replies; 152+ messages in thread
From: Sebastian Reichel @ 2021-01-08 21:54 UTC (permalink / raw)
  To: Dixit, Ashutosh
  Cc: Tomi Valkeinen, Laurent Pinchart, Nikhil Devshatwar, linux-omap,
	dri-devel, Tony Lindgren, hns, Sekhar Nori, Thierry Reding,
	Sam Ravnborg

[-- Attachment #1: Type: text/plain, Size: 1969 bytes --]

Hi,

On Fri, Jan 08, 2021 at 01:23:54PM -0800, Dixit, Ashutosh wrote:
> On Tue, 24 Nov 2020 04:44:57 -0800, Tomi Valkeinen wrote:
> >
> > From: Sebastian Reichel <sebastian.reichel@collabora.com>
> >
> > The panel driver is no longer using any OMAP specific APIs, so
> > let's move it into the generic panel directory.
> >
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Acked-by: Sam Ravnborg <sam@ravnborg.org>
> > Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  drivers/gpu/drm/omapdrm/Kconfig                        |  1 -
> >  drivers/gpu/drm/omapdrm/Makefile                       |  1 -
> >  drivers/gpu/drm/omapdrm/displays/Kconfig               | 10 ----------
> >  drivers/gpu/drm/omapdrm/displays/Makefile              |  2 --
> >  drivers/gpu/drm/panel/Kconfig                          |  9 +++++++++
> >  drivers/gpu/drm/panel/Makefile                         |  1 +
> >  .../gpu/drm/{omapdrm/displays => panel}/panel-dsi-cm.c |  0
> 
> Not sure if it's a result of this commit but on drm-tip we see:
> 
> $ make allmodconfig
> $ make modules_check
>   DESCEND  objtool
>   CALL    scripts/atomic/check-atomics.sh
>   CALL    scripts/checksyscalls.sh
>   CHK     include/generated/compile.h
> error: the following would cause module name conflict:
>   drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.ko
>   drivers/gpu/drm/panel/panel-dsi-cm.ko
> make: *** [Makefile:1400: modules_check] Error 1

It is a result of this commit and it has already been reported by
Stephen Rothwell. The thread also contains a patch to fixup the
problem:

https://lore.kernel.org/linux-next/20210108195839.GA1429715@ravnborg.org/T/#m0eee5e806cc93cf9982620b7b8b9f77df2c37498

Sorry for the inconvenience,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2020-11-24 12:44 ` [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core Tomi Valkeinen
@ 2021-02-08 17:55   ` Tony Lindgren
  2021-02-11  7:34     ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Tony Lindgren @ 2021-02-08 17:55 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

Hi,

* Tomi Valkeinen <tomi.valkeinen@ti.com> [201124 12:47]:
> From: Sebastian Reichel <sebastian.reichel@collabora.com>
> 
> In preparation for removing custom DSS calls from the DSI
> panel driver, this moves support for external tearing event
> GPIOs into the DSI host driver. This way tearing events are
> always handled in the core resulting in simplification of
> the panel drivers.
> 
> The TE GPIO acquisition follows works in the same way as the
> exynos DSI implementation.

Looks like this patch causes the following warnings:

DSI: omapdss DSI error: Failed to receive BTA
DSI: omapdss DSI error: bta sync failed
DSI: omapdss DSI error: vc(0) busy when trying to config for VP
DSI: omapdss DSI error: Failed to receive BTA
DSI: omapdss DSI error: bta sync failed
DSI: omapdss DSI error: vc(0) busy when trying to config for VP
DSI: omapdss DSI error: Failed to receive BTA
DSI: omapdss DSI error: bta sync failed
DSI: omapdss DSI error: vc(0) busy when trying to config for VP
...

Any ideas? The display works for me despite the constant
warnings.

Regards,

Tony

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2021-02-08 17:55   ` Tony Lindgren
@ 2021-02-11  7:34     ` Tomi Valkeinen
  2021-02-11 17:35       ` Tony Lindgren
  0 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2021-02-11  7:34 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

On 08/02/2021 19:55, Tony Lindgren wrote:
> Hi,
> 
> * Tomi Valkeinen <tomi.valkeinen@ti.com> [201124 12:47]:
>> From: Sebastian Reichel <sebastian.reichel@collabora.com>
>>
>> In preparation for removing custom DSS calls from the DSI
>> panel driver, this moves support for external tearing event
>> GPIOs into the DSI host driver. This way tearing events are
>> always handled in the core resulting in simplification of
>> the panel drivers.
>>
>> The TE GPIO acquisition follows works in the same way as the
>> exynos DSI implementation.
> 
> Looks like this patch causes the following warnings:
> 
> DSI: omapdss DSI error: Failed to receive BTA
> DSI: omapdss DSI error: bta sync failed
> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> DSI: omapdss DSI error: Failed to receive BTA
> DSI: omapdss DSI error: bta sync failed
> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> DSI: omapdss DSI error: Failed to receive BTA
> DSI: omapdss DSI error: bta sync failed
> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> ...
> 
> Any ideas? The display works for me despite the constant
> warnings.

Which board is that? Do the errors start right from the boot, or only
after running something in userspace?

 Tomi


^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2021-02-11  7:34     ` Tomi Valkeinen
@ 2021-02-11 17:35       ` Tony Lindgren
  2021-02-17  7:42         ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Tony Lindgren @ 2021-02-11 17:35 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

* Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210211 07:35]:
> On 08/02/2021 19:55, Tony Lindgren wrote:
> > Hi,
> > 
> > * Tomi Valkeinen <tomi.valkeinen@ti.com> [201124 12:47]:
> >> From: Sebastian Reichel <sebastian.reichel@collabora.com>
> >>
> >> In preparation for removing custom DSS calls from the DSI
> >> panel driver, this moves support for external tearing event
> >> GPIOs into the DSI host driver. This way tearing events are
> >> always handled in the core resulting in simplification of
> >> the panel drivers.
> >>
> >> The TE GPIO acquisition follows works in the same way as the
> >> exynos DSI implementation.
> > 
> > Looks like this patch causes the following warnings:
> > 
> > DSI: omapdss DSI error: Failed to receive BTA
> > DSI: omapdss DSI error: bta sync failed
> > DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> > DSI: omapdss DSI error: Failed to receive BTA
> > DSI: omapdss DSI error: bta sync failed
> > DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> > DSI: omapdss DSI error: Failed to receive BTA
> > DSI: omapdss DSI error: bta sync failed
> > DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> > ...
> > 
> > Any ideas? The display works for me despite the constant
> > warnings.
> 
> Which board is that? Do the errors start right from the boot, or only
> after running something in userspace?

This is with droid4, that's about the only device I use with a display
on regular basis. I'm pretty sure some earlier version of Sebastian's
patches worked fine.

Regards,

Tony

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2021-02-11 17:35       ` Tony Lindgren
@ 2021-02-17  7:42         ` Tomi Valkeinen
  2021-02-18  5:57           ` Tony Lindgren
  0 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2021-02-17  7:42 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

On 11/02/2021 19:35, Tony Lindgren wrote:
> * Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210211 07:35]:
>> On 08/02/2021 19:55, Tony Lindgren wrote:
>>> Hi,
>>>
>>> * Tomi Valkeinen <tomi.valkeinen@ti.com> [201124 12:47]:
>>>> From: Sebastian Reichel <sebastian.reichel@collabora.com>
>>>>
>>>> In preparation for removing custom DSS calls from the DSI
>>>> panel driver, this moves support for external tearing event
>>>> GPIOs into the DSI host driver. This way tearing events are
>>>> always handled in the core resulting in simplification of
>>>> the panel drivers.
>>>>
>>>> The TE GPIO acquisition follows works in the same way as the
>>>> exynos DSI implementation.
>>>
>>> Looks like this patch causes the following warnings:
>>>
>>> DSI: omapdss DSI error: Failed to receive BTA
>>> DSI: omapdss DSI error: bta sync failed
>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>> DSI: omapdss DSI error: Failed to receive BTA
>>> DSI: omapdss DSI error: bta sync failed
>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>> DSI: omapdss DSI error: Failed to receive BTA
>>> DSI: omapdss DSI error: bta sync failed
>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>> ...
>>>
>>> Any ideas? The display works for me despite the constant
>>> warnings.
>>
>> Which board is that? Do the errors start right from the boot, or only
>> after running something in userspace?
> 
> This is with droid4, that's about the only device I use with a display
> on regular basis. I'm pretty sure some earlier version of Sebastian's
> patches worked fine.

OMAP4 SDP doesn't produce these errors and the HW looks rather
identical. Although I noticed something odd there, running kmstest
--flip on the first display works fine, but running on the second
display gets a bit erratic fps. Which is a bit odd as everything should
be identical.

So these errors start from the boot? Or only when running something
specific?

Is there a bootloader that initializes the display?

 Tomi

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2021-02-17  7:42         ` Tomi Valkeinen
@ 2021-02-18  5:57           ` Tony Lindgren
  2021-02-22  8:47             ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Tony Lindgren @ 2021-02-18  5:57 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

* Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210217 07:42]:
> On 11/02/2021 19:35, Tony Lindgren wrote:
> > * Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210211 07:35]:
> >> On 08/02/2021 19:55, Tony Lindgren wrote:
> >>> Hi,
> >>>
> >>> * Tomi Valkeinen <tomi.valkeinen@ti.com> [201124 12:47]:
> >>>> From: Sebastian Reichel <sebastian.reichel@collabora.com>
> >>>>
> >>>> In preparation for removing custom DSS calls from the DSI
> >>>> panel driver, this moves support for external tearing event
> >>>> GPIOs into the DSI host driver. This way tearing events are
> >>>> always handled in the core resulting in simplification of
> >>>> the panel drivers.
> >>>>
> >>>> The TE GPIO acquisition follows works in the same way as the
> >>>> exynos DSI implementation.
> >>>
> >>> Looks like this patch causes the following warnings:
> >>>
> >>> DSI: omapdss DSI error: Failed to receive BTA
> >>> DSI: omapdss DSI error: bta sync failed
> >>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> >>> DSI: omapdss DSI error: Failed to receive BTA
> >>> DSI: omapdss DSI error: bta sync failed
> >>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> >>> DSI: omapdss DSI error: Failed to receive BTA
> >>> DSI: omapdss DSI error: bta sync failed
> >>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
> >>> ...
> >>>
> >>> Any ideas? The display works for me despite the constant
> >>> warnings.
> >>
> >> Which board is that? Do the errors start right from the boot, or only
> >> after running something in userspace?
> > 
> > This is with droid4, that's about the only device I use with a display
> > on regular basis. I'm pretty sure some earlier version of Sebastian's
> > patches worked fine.
> 
> OMAP4 SDP doesn't produce these errors and the HW looks rather
> identical. Although I noticed something odd there, running kmstest
> --flip on the first display works fine, but running on the second
> display gets a bit erratic fps. Which is a bit odd as everything should
> be identical.

Oh cool that you have those running again/still :) In this case there
is no te-gpios if that might make a difference.

> So these errors start from the boot? Or only when running something
> specific?

They start from the boot when modules are loaded.

> Is there a bootloader that initializes the display?

Yes it boots with kexec.

Regards,

Tony

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2021-02-18  5:57           ` Tony Lindgren
@ 2021-02-22  8:47             ` Tomi Valkeinen
  2021-02-25 12:46               ` Tony Lindgren
  0 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2021-02-22  8:47 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

On 18/02/2021 07:57, Tony Lindgren wrote:
> * Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210217 07:42]:
>> On 11/02/2021 19:35, Tony Lindgren wrote:
>>> * Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210211 07:35]:
>>>> On 08/02/2021 19:55, Tony Lindgren wrote:
>>>>> Hi,
>>>>>
>>>>> * Tomi Valkeinen <tomi.valkeinen@ti.com> [201124 12:47]:
>>>>>> From: Sebastian Reichel <sebastian.reichel@collabora.com>
>>>>>>
>>>>>> In preparation for removing custom DSS calls from the DSI
>>>>>> panel driver, this moves support for external tearing event
>>>>>> GPIOs into the DSI host driver. This way tearing events are
>>>>>> always handled in the core resulting in simplification of
>>>>>> the panel drivers.
>>>>>>
>>>>>> The TE GPIO acquisition follows works in the same way as the
>>>>>> exynos DSI implementation.
>>>>>
>>>>> Looks like this patch causes the following warnings:
>>>>>
>>>>> DSI: omapdss DSI error: Failed to receive BTA
>>>>> DSI: omapdss DSI error: bta sync failed
>>>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>>>> DSI: omapdss DSI error: Failed to receive BTA
>>>>> DSI: omapdss DSI error: bta sync failed
>>>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>>>> DSI: omapdss DSI error: Failed to receive BTA
>>>>> DSI: omapdss DSI error: bta sync failed
>>>>> DSI: omapdss DSI error: vc(0) busy when trying to config for VP
>>>>> ...
>>>>>
>>>>> Any ideas? The display works for me despite the constant
>>>>> warnings.
>>>>
>>>> Which board is that? Do the errors start right from the boot, or only
>>>> after running something in userspace?
>>>
>>> This is with droid4, that's about the only device I use with a display
>>> on regular basis. I'm pretty sure some earlier version of Sebastian's
>>> patches worked fine.
>>
>> OMAP4 SDP doesn't produce these errors and the HW looks rather
>> identical. Although I noticed something odd there, running kmstest
>> --flip on the first display works fine, but running on the second
>> display gets a bit erratic fps. Which is a bit odd as everything should
>> be identical.
> 
> Oh cool that you have those running again/still :) In this case there
> is no te-gpios if that might make a difference.

No, GPIO TE is not used on OMAP4 SDP either.

>> So these errors start from the boot? Or only when running something
>> specific?
> 
> They start from the boot when modules are loaded.

Normally there are no updates happening unless an userspace app is
running, but I guess you have fb console enabled, with the blinking
cursor which makes the updates.

I usually don't have fbcon enabled, but OMAP4 SDP works fine for me with
fbcon too...

>> Is there a bootloader that initializes the display?
> 
> Yes it boots with kexec.

Is that open source? Can you disable the display setup from the
bootloader? Maybe the DSS or the panel is left into a state that for
whatever reason makes the kernel drivers break.

Or maybe a DSS or DSI reset via SYSCONFIG at probe would help, or panel
reset if it has such a feature.

 Tomi

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2021-02-22  8:47             ` Tomi Valkeinen
@ 2021-02-25 12:46               ` Tony Lindgren
  2021-02-26  9:04                 ` Tomi Valkeinen
  0 siblings, 1 reply; 152+ messages in thread
From: Tony Lindgren @ 2021-02-25 12:46 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

* Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210222 08:47]:
> On 18/02/2021 07:57, Tony Lindgren wrote:
> > Oh cool that you have those running again/still :) In this case there
> > is no te-gpios if that might make a difference.
> 
> No, GPIO TE is not used on OMAP4 SDP either.

OK

> >> So these errors start from the boot? Or only when running something
> >> specific?
> > 
> > They start from the boot when modules are loaded.
> 
> Normally there are no updates happening unless an userspace app is
> running, but I guess you have fb console enabled, with the blinking
> cursor which makes the updates.
> 
> I usually don't have fbcon enabled, but OMAP4 SDP works fine for me with
> fbcon too...

I'm using loadable modules with omap2plus_defconfig in case that makes
a difference. Maybe there's some state preserved somewhere if deferred
probe happens?

> >> Is there a bootloader that initializes the display?
> > 
> > Yes it boots with kexec.
> 
> Is that open source? Can you disable the display setup from the
> bootloader? Maybe the DSS or the panel is left into a state that for
> whatever reason makes the kernel drivers break.

Well that's a signed kernel booting kexec. But it has been working
just fine for years now so I'd rather not blame that.

> Or maybe a DSS or DSI reset via SYSCONFIG at probe would help, or panel
> reset if it has such a feature.

Maybe. But why would the $subject patch cause the errors?

Regards,

Tony

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2021-02-25 12:46               ` Tony Lindgren
@ 2021-02-26  9:04                 ` Tomi Valkeinen
  2021-02-27  7:18                   ` Tony Lindgren
  0 siblings, 1 reply; 152+ messages in thread
From: Tomi Valkeinen @ 2021-02-26  9:04 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

On 25/02/2021 14:46, Tony Lindgren wrote:
> * Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210222 08:47]:
>> On 18/02/2021 07:57, Tony Lindgren wrote:
>>> Oh cool that you have those running again/still :) In this case there
>>> is no te-gpios if that might make a difference.
>>
>> No, GPIO TE is not used on OMAP4 SDP either.
> 
> OK
> 
>>>> So these errors start from the boot? Or only when running something
>>>> specific?
>>>
>>> They start from the boot when modules are loaded.
>>
>> Normally there are no updates happening unless an userspace app is
>> running, but I guess you have fb console enabled, with the blinking
>> cursor which makes the updates.
>>
>> I usually don't have fbcon enabled, but OMAP4 SDP works fine for me with
>> fbcon too...
> 
> I'm using loadable modules with omap2plus_defconfig in case that makes
> a difference. Maybe there's some state preserved somewhere if deferred
> probe happens?

I don't think the drivers do much unless probe succeeds. I'm also using 
modules.

>>>> Is there a bootloader that initializes the display?
>>>
>>> Yes it boots with kexec.
>>
>> Is that open source? Can you disable the display setup from the
>> bootloader? Maybe the DSS or the panel is left into a state that for
>> whatever reason makes the kernel drivers break.
> 
> Well that's a signed kernel booting kexec. But it has been working
> just fine for years now so I'd rather not blame that.

I'm just looking for the difference with droid4 and omap4 sdp so that I 
could reproduce.

>> Or maybe a DSS or DSI reset via SYSCONFIG at probe would help, or panel
>> reset if it has such a feature.
> 
> Maybe. But why would the $subject patch cause the errors?

Hmm, if I read the code right, TE was not enabled at all before this 
patch. And this patch enables it. So maybe TE has never worked with that 
panel?

You could try changing the enable_te calls to pass false.

Or with the upstream driver, comment out

mipi_dsi_dcs_set_tear_on(ddata->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);

  Tomi

^ permalink raw reply	[flat|nested] 152+ messages in thread

* Re: [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core
  2021-02-26  9:04                 ` Tomi Valkeinen
@ 2021-02-27  7:18                   ` Tony Lindgren
  0 siblings, 0 replies; 152+ messages in thread
From: Tony Lindgren @ 2021-02-27  7:18 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Laurent Pinchart, Nikhil Devshatwar,
	linux-omap, dri-devel, Sekhar Nori, hns, Sebastian Reichel

* Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> [210226 09:04]:
> Hmm, if I read the code right, TE was not enabled at all before this patch.
> And this patch enables it. So maybe TE has never worked with that panel?
> 
> You could try changing the enable_te calls to pass false.
> 
> Or with the upstream driver, comment out
> 
> mipi_dsi_dcs_set_tear_on(ddata->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);

Yup you're right that's it.

Commenting it out in drivers/gpu/drm/panel/panel-dsi-cm.c makes the
warnings go away.

There are some BTA related comments in the old v3.0.8 based Android
kernel for droid4 panel at [0], but I don't really follow what they
mean. Maybe it's some ordering issue?

Regards,

Tony


[0] https://github.com/NotKit/android_kernel_motorola_omap4-common/blob/hybris-11.0/drivers/video/omap2/displays/panel-mapphone.c

^ permalink raw reply	[flat|nested] 152+ messages in thread

end of thread, other threads:[~2021-02-27  7:19 UTC | newest]

Thread overview: 152+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 12:44 [PATCH v4 00/80] Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 01/80] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 02/80] drm/omap: drop unused dsi.configure_pins Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 03/80] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 04/80] drm/omap: constify write buffers Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 05/80] drm/omap: dsi: add generic transfer function Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 06/80] drm/omap: panel-dsi-cm: convert to transfer API Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 07/80] drm/omap: dsi: unexport specific data transfer functions Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 08/80] drm/omap: dsi: drop virtual channel logic Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 09/80] drm/omap: dsi: simplify write function Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 10/80] drm/omap: dsi: simplify read functions Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 11/80] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 12/80] drm/omap: dsi: introduce mipi_dsi_host Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 13/80] drm/omap: panel-dsi-cm: use DSI helpers Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 14/80] drm/omap: dsi: request VC via mipi_dsi_attach Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 15/80] drm/omap: panel-dsi-cm: drop hardcoded VC Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 16/80] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 17/80] drm/omap: dsi: drop unused memory_read() Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 18/80] drm/omap: dsi: drop unused get_te() Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 19/80] drm/omap: dsi: drop unused enable_te() Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 20/80] drm/omap: dsi: drop useless sync() Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 21/80] drm/omap: dsi: use pixel-format and mode from attach Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 22/80] drm/omap: panel-dsi-cm: use bulk regulator API Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 23/80] drm/omap: dsi: lp/hs switching support for transfer() Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 24/80] drm/omap: dsi: move TE GPIO handling into core Tomi Valkeinen
2021-02-08 17:55   ` Tony Lindgren
2021-02-11  7:34     ` Tomi Valkeinen
2021-02-11 17:35       ` Tony Lindgren
2021-02-17  7:42         ` Tomi Valkeinen
2021-02-18  5:57           ` Tony Lindgren
2021-02-22  8:47             ` Tomi Valkeinen
2021-02-25 12:46               ` Tony Lindgren
2021-02-26  9:04                 ` Tomi Valkeinen
2021-02-27  7:18                   ` Tony Lindgren
2020-11-24 12:44 ` [PATCH v4 25/80] drm/omap: dsi: drop custom enable_te() API Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 26/80] drm/omap: dsi: do bus locking in host driver Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 27/80] drm/omap: dsi: untangle ulps ops from enable/disable Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 28/80] drm/omap: dsi: do ULPS in host driver Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 29/80] drm/omap: dsi: move panel refresh function to host Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 30/80] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 31/80] drm/omap: dsi: drop custom panel capability support Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 32/80] drm/omap: dsi: convert to drm_panel Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 33/80] drm/omap: drop omapdss-boot-init Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 34/80] drm/omap: dsi: implement check timings Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 35/80] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 36/80] drm/omap: panel-dsi-cm: support unbinding Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 37/80] drm/omap: panel-dsi-cm: fix remove() Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 38/80] drm/omap: remove global dss_device variable Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 39/80] drm/panel: Move OMAP's DSI command mode panel driver Tomi Valkeinen
2021-01-08 21:23   ` Dixit, Ashutosh
2021-01-08 21:54     ` Sebastian Reichel
2020-11-24 12:44 ` [PATCH v4 40/80] drm/omap: dsi: Register a drm_bridge Tomi Valkeinen
2020-11-24 12:44 ` [PATCH v4 41/80] drm/omap: remove legacy DSS device operations Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 42/80] drm/omap: remove unused omap_connector Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 43/80] drm/omap: simplify omap_display_id Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 44/80] drm/omap: drop unused DSS next pointer Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 45/80] drm/omap: drop DSS ops_flags Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 46/80] drm/omap: drop dssdev display field Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 47/80] drm/omap: simplify DSI manual update code Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 48/80] drm/omap: dsi: simplify pin config Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 49/80] ARM: omap2plus_defconfig: Update for moved DSI command mode panel Tomi Valkeinen
2020-12-01  8:46   ` Tony Lindgren
2020-11-24 12:45 ` [PATCH v4 50/80] drm/omap: squash omapdrm sub-modules into one Tomi Valkeinen
2020-12-14 12:53   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 51/80] drm/omap: remove unused display.c Tomi Valkeinen
2020-12-14 12:53   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 52/80] drm/omap: drop unused owner field Tomi Valkeinen
2020-12-14 12:53   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 53/80] drm/omap: remove dispc_ops Tomi Valkeinen
2020-12-14 12:54   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 54/80] drm/omap: remove dss_mgr_ops Tomi Valkeinen
2020-12-14 12:54   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 55/80] drm/panel: panel-dsi-cm: use MIPI_DCS_GET_ERROR_COUNT_ON_DSI Tomi Valkeinen
2020-11-24 16:18   ` Sam Ravnborg
2020-11-24 16:26     ` Tomi Valkeinen
2020-11-24 16:38       ` Sam Ravnborg
2020-11-25  8:52         ` Tomi Valkeinen
2020-11-30  9:50   ` Laurent Pinchart
2020-12-14 12:54   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 56/80] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
2020-11-24 17:25   ` Sam Ravnborg
2020-11-30  9:51   ` Laurent Pinchart
2020-12-14 12:54   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 57/80] ARM: dts: omap5: add address-cells & size-cells to dsi Tomi Valkeinen
2020-11-30  9:53   ` Laurent Pinchart
2020-12-01 10:39     ` Tomi Valkeinen
2020-12-01 10:47       ` Tony Lindgren
2020-12-14 12:55   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 58/80] drm/omap: pll: fix iteration loop check Tomi Valkeinen
2020-11-30  9:54   ` Laurent Pinchart
2020-12-14 12:55   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 59/80] drm/omap: dsi: set trans_mode according to client mode_flags Tomi Valkeinen
2020-11-30  9:55   ` Laurent Pinchart
2020-12-14 12:56   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 60/80] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
2020-11-24 17:30   ` Sam Ravnborg
2020-11-24 18:19     ` Tomi Valkeinen
2020-11-30  9:56   ` Laurent Pinchart
2020-12-14 12:59   ` Sebastian Reichel
2020-11-24 12:45 ` [PATCH v4 61/80] drm/omap: dsi: send nop instead of page & column Tomi Valkeinen
2020-11-30  9:58   ` Laurent Pinchart
2020-12-01 10:59     ` Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 62/80] drm/omap: dsi: simplify VC handling Tomi Valkeinen
2020-11-30 10:00   ` Laurent Pinchart
2020-12-01 11:11     ` Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 63/80] drm/omap: dsi: drop useless channel checks Tomi Valkeinen
2020-12-01  0:14   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 64/80] drm/omap: dsi: cleanup channel usages Tomi Valkeinen
2020-12-01  0:17   ` Laurent Pinchart
2020-12-01 11:23     ` Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 65/80] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode Tomi Valkeinen
2020-12-01  0:18   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 66/80] drm/omap: dsi: set LP/HS before update Tomi Valkeinen
2020-12-01  0:20   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 67/80] drm/omap: dsi: use separate VCs for cmd and video Tomi Valkeinen
2020-12-01  0:21   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 68/80] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
2020-11-24 17:34   ` Sam Ravnborg
2020-12-01  0:22   ` Laurent Pinchart
2020-12-01 11:26     ` Tomi Valkeinen
2020-12-02 20:08   ` kernel test robot
2020-11-24 12:45 ` [PATCH v4 69/80] drm/panel: panel-dsi-cm: add panel database to driver Tomi Valkeinen
2020-11-24 17:35   ` Sam Ravnborg
2020-12-01  0:23   ` Laurent Pinchart
2020-12-01 11:29     ` Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 70/80] drm/panel: panel-dsi-cm: drop unneeded includes Tomi Valkeinen
2020-11-24 17:36   ` Sam Ravnborg
2020-12-01  0:27   ` Laurent Pinchart
2020-12-01 11:33     ` Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 71/80] drm/omap: dsi: move structs & defines to dsi.h Tomi Valkeinen
2020-12-01  0:31   ` Laurent Pinchart
2020-12-01 11:37     ` Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 72/80] drm/omap: dsi: move enable/disable to bridge enable/disable Tomi Valkeinen
2020-12-01  0:32   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 73/80] drm/omap: dsi: display_enable cleanup Tomi Valkeinen
2020-12-01  0:32   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 74/80] drm/omap: dsi: display_disable cleanup Tomi Valkeinen
2020-12-01  0:33   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 75/80] drm/omap: dsi: rename dsi_display_* functions Tomi Valkeinen
2020-12-01  0:34   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 76/80] drm/omap: dsi: cleanup initial vc setup Tomi Valkeinen
2020-12-01  0:36   ` Laurent Pinchart
2020-12-01 11:51     ` Tomi Valkeinen
2020-11-24 12:45 ` [PATCH v4 77/80] drm/omap: dsi: split video mode enable/disable into separate func Tomi Valkeinen
2020-12-01  0:37   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 78/80] drm/omap: dsi: fix and cleanup ddr_clk_always_on Tomi Valkeinen
2020-12-01  0:38   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 79/80] drm/omap: dsi: remove ulps support Tomi Valkeinen
2020-12-01  0:39   ` Laurent Pinchart
2020-11-24 12:45 ` [PATCH v4 80/80] drm/omap: dsi: fix DCS_CMD_ENABLE Tomi Valkeinen
2020-12-01  0:40   ` Laurent Pinchart
2020-11-30  9:39 ` [PATCH v4 81/80] drm/omap: dsi: allow DSI commands to be sent early Tomi Valkeinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).