linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
@ 2020-02-24 23:20 Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels Sebastian Reichel
                   ` (60 more replies)
  0 siblings, 61 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

This updates the existing omapdrm DSI code, so that it uses
common drm_mipi_dsi API and drm_panel.

The patchset has been tested with Droid 4 using Linux console, X.org and
Weston. The patchset is based on Laurent Pinchartl's patch series [0]
and removes the last custom panel driver, so quite a few cleanups on the
omapdrm codebase were possible.

[0] [PATCH v7 00/54] drm/omap: Replace custom display drivers with drm_bridge and drm_panel
    https://lore.kernel.org/dri-devel/20200222150106.22919-1-laurent.pinchart@ideasonboard.com/
    git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel

I pushed this patchset into the following branch:

git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-n900.git omapdrm/bridge/devel-with-dsi

The previous version of this patchset has been sent quite some time ago.
This version has been rebased and required cleaning up most of the
hacks. I do not have a detailed changelog, but quite a few things
changed. I decided against doing anything special for the DT change
(adding DSI channel number), since only 3 devices are affected. It is
quite likely, that all developers of those devices update DT together
with kernel for those devices. My suggestion is to merge the first two
patches ASAP and backport to stable, since it does not affect old
kernels and the change is rather small.

RFCv1: https://lore.kernel.org/dri-devel/20191117023946.VjCC3yE08DMx7JIKxNagPoT5et7WTnKGVV6MtOtB9Ro@z/

-- Sebastian

Sebastian Reichel (56):
  ARM: dts: omap: add channel to DSI panels
  ARM: dts: omap4-droid4: add panel compatible
  Revert "drm/omap: dss: Remove unused omap_dss_device operations"
  omap/drm: 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/dsi: add MIPI_DSI_MODE_ULPS_IDLE
  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: dsi: return proper error code from dsi_update_all()
  drm/omap: remove global dss_device variable
  drm/omap: bind components with drm_device argument
  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 empty omap_encoder helper functions
  drm/omap: drop DSS ops_flags
  drm/omap: drop dssdev display field
  drm/omap: simplify DSI manual update code
  ARM: omap2plus_defconfig: Update for moved DSI command mode panel
  drm/panel/panel-dsi-cm: support rotation property
  ARM: dts: omap4-droid4: add panel orientation

 .../bindings/display/panel/panel-dsi-cm.txt   |    4 +-
 .../boot/dts/motorola-mapphone-common.dtsi    |    6 +-
 arch/arm/boot/dts/omap3-n950.dts              |    3 +-
 arch/arm/boot/dts/omap3.dtsi                  |    3 +
 arch/arm/boot/dts/omap4-sdp.dts               |    6 +-
 arch/arm/boot/dts/omap4.dtsi                  |    6 +
 arch/arm/boot/dts/omap5.dtsi                  |    6 +
 arch/arm/configs/omap2plus_defconfig          |    2 +-
 drivers/gpu/drm/omapdrm/Kconfig               |    1 -
 drivers/gpu/drm/omapdrm/Makefile              |    2 -
 drivers/gpu/drm/omapdrm/displays/Kconfig      |   10 -
 drivers/gpu/drm/omapdrm/displays/Makefile     |    2 -
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 1387 -----------------
 drivers/gpu/drm/omapdrm/dss/Kconfig           |    4 +-
 drivers/gpu/drm/omapdrm/dss/Makefile          |    2 -
 drivers/gpu/drm/omapdrm/dss/base.c            |   58 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 1034 +++++++-----
 drivers/gpu/drm/omapdrm/dss/dss.c             |   44 +-
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |  220 ---
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  141 +-
 drivers/gpu/drm/omapdrm/dss/output.c          |   13 +-
 drivers/gpu/drm/omapdrm/dss/venc.c            |    1 -
 drivers/gpu/drm/omapdrm/omap_connector.c      |  157 --
 drivers/gpu/drm/omapdrm/omap_connector.h      |   28 -
 drivers/gpu/drm/omapdrm/omap_crtc.c           |   35 +-
 drivers/gpu/drm/omapdrm/omap_drv.c            |   49 +-
 drivers/gpu/drm/omapdrm/omap_drv.h            |    1 -
 drivers/gpu/drm/omapdrm/omap_encoder.c        |   59 +-
 drivers/gpu/drm/panel/Kconfig                 |    9 +
 drivers/gpu/drm/panel/Makefile                |    1 +
 drivers/gpu/drm/panel/panel-dsi-cm.c          |  674 ++++++++
 include/drm/drm_mipi_dsi.h                    |    2 +
 32 files changed, 1465 insertions(+), 2505 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/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


base-commit: 54ba965bb3873eca6098ddf04e3a8d7bba1b5557
-- 
2.25.0


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

* [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:38   ` Laurent Pinchart
  2020-02-27 20:09   ` Sam Ravnborg
  2020-02-24 23:20 ` [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible Sebastian Reichel
                   ` (59 subsequent siblings)
  60 siblings, 2 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

The standard binding for DSI requires, that the channel number
of the panel is encoded in DT. This adds the channel number in
all OMAP3-5 boards, in preparation for using common infrastructure.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../devicetree/bindings/display/panel/panel-dsi-cm.txt      | 4 +++-
 arch/arm/boot/dts/motorola-mapphone-common.dtsi             | 3 ++-
 arch/arm/boot/dts/omap3-n950.dts                            | 3 ++-
 arch/arm/boot/dts/omap3.dtsi                                | 3 +++
 arch/arm/boot/dts/omap4-sdp.dts                             | 6 ++++--
 arch/arm/boot/dts/omap4.dtsi                                | 6 ++++++
 arch/arm/boot/dts/omap5.dtsi                                | 6 ++++++
 7 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
index dce48eb9db57..f92d5c9adfc5 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
+++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
@@ -3,6 +3,7 @@ Generic MIPI DSI Command Mode Panel
 
 Required properties:
 - compatible: "panel-dsi-cm"
+- reg: DSI channel number
 
 Optional properties:
 - label: a symbolic name for the panel
@@ -15,9 +16,10 @@ Required nodes:
 Example
 -------
 
-lcd0: display {
+lcd0: panel@0 {
 	compatible = "tpo,taal", "panel-dsi-cm";
 	label = "lcd0";
+	reg = <0>;
 
 	reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
 
diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
index 85665506f4f8..a5e4ba7c8dab 100644
--- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
+++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
@@ -199,8 +199,9 @@ dsi1_out_ep: endpoint {
 		};
 	};
 
-	lcd0: display {
+	lcd0: panel@0 {
 		compatible = "panel-dsi-cm";
+		reg = <0>;
 		label = "lcd0";
 		vddi-supply = <&lcd_regulator>;
 		reset-gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>;	/* gpio101 */
diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
index 31d47a1fad84..80cf4e1177da 100644
--- a/arch/arm/boot/dts/omap3-n950.dts
+++ b/arch/arm/boot/dts/omap3-n950.dts
@@ -225,8 +225,9 @@ dsi_out_ep: endpoint {
 		};
 	};
 
-	lcd0: display {
+	lcd0: panel@0 {
 		compatible = "nokia,himalaya", "panel-dsi-cm";
+		reg = <0>;
 		label = "lcd0";
 
 		pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 634ea16a711e..409d434a9b18 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -820,6 +820,9 @@ dsi: encoder@4804fc00 {
 				ti,hwmods = "dss_dsi1";
 				clocks = <&dss1_alwon_fck>, <&dss2_alwon_fck>;
 				clock-names = "fck", "sys_clk";
+
+				#address-cells = <1>;
+				#size-cells = <0>;
 			};
 
 			rfbi: encoder@48050800 {
diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
index 91480ac1f328..8a8307517dab 100644
--- a/arch/arm/boot/dts/omap4-sdp.dts
+++ b/arch/arm/boot/dts/omap4-sdp.dts
@@ -662,8 +662,9 @@ dsi1_out_ep: endpoint {
 		};
 	};
 
-	lcd0: display {
+	lcd0: panel@0 {
 		compatible = "tpo,taal", "panel-dsi-cm";
+		reg = <0>;
 		label = "lcd0";
 
 		reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;	/* 102 */
@@ -687,8 +688,9 @@ dsi2_out_ep: endpoint {
 		};
 	};
 
-	lcd1: display {
+	lcd1: panel@0 {
 		compatible = "tpo,taal", "panel-dsi-cm";
+		reg = <0>;
 		label = "lcd1";
 
 		reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>;	/* 104 */
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 9a87440d0b9d..a75734065cac 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -465,6 +465,9 @@ dsi1: encoder@58004000 {
 				clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>,
 					 <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>;
 				clock-names = "fck", "sys_clk";
+
+				#address-cells = <1>;
+				#size-cells = <0>;
 			};
 
 			dsi2: encoder@58005000 {
@@ -479,6 +482,9 @@ dsi2: encoder@58005000 {
 				clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>,
 					 <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>;
 				clock-names = "fck", "sys_clk";
+
+				#address-cells = <1>;
+				#size-cells = <0>;
 			};
 
 			hdmi: encoder@58006000 {
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index d0ecf54d5a23..5c7462e04716 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -333,6 +333,9 @@ dsi1: encoder@58004000 {
 				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>;
 			};
 
 			dsi2: encoder@58005000 {
@@ -347,6 +350,9 @@ dsi2: encoder@58005000 {
 				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>;
 			};
 
 			hdmi: encoder@58060000 {
-- 
2.25.0


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

* [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:37   ` Laurent Pinchart
  2020-02-27 20:10   ` Sam Ravnborg
  2020-02-24 23:20 ` [PATCHv2 03/56] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Sebastian Reichel
                   ` (58 subsequent siblings)
  60 siblings, 2 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Add Droid 4 specific compatible value in addition to the
generic one, so that we have the ability to add panel
specific quirks in the future.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 arch/arm/boot/dts/motorola-mapphone-common.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
index a5e4ba7c8dab..622383ec6a75 100644
--- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
+++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
@@ -200,7 +200,7 @@ dsi1_out_ep: endpoint {
 	};
 
 	lcd0: panel@0 {
-		compatible = "panel-dsi-cm";
+		compatible = "motorola,droid4-panel", "panel-dsi-cm";
 		reg = <0>;
 		label = "lcd0";
 		vddi-supply = <&lcd_regulator>;
-- 
2.25.0


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

* [PATCHv2 03/56] Revert "drm/omap: dss: Remove unused omap_dss_device operations"
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-03-25 12:42   ` Tomi Valkeinen
  2020-02-24 23:20 ` [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins Sebastian Reichel
                   ` (57 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

From: Sebastian Reichel <sre@kernel.org>

This reverts commit 4ff8e98879e6eeae9d125dfcf3b642075d00089d.
---
 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);
 }
-- 
2.25.0


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

* [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (2 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 03/56] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:42   ` Laurent Pinchart
  2020-03-25 12:45   ` Tomi Valkeinen
  2020-02-24 23:20 ` [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Sebastian Reichel
                   ` (56 subsequent siblings)
  60 siblings, 2 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 3484b5d4a91c..e7fe5d702337 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 79ddfbfd1b58..8c39823a8295 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);
-- 
2.25.0


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

* [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (3 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 13:58   ` Laurent Pinchart
  2020-03-25 12:52   ` Tomi Valkeinen
  2020-02-24 23:20 ` [PATCHv2 06/56] drm/omap: constify write buffers Sebastian Reichel
                   ` (55 subsequent siblings)
  60 siblings, 2 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 49 +++++++------------
 drivers/gpu/drm/omapdrm/dss/omapdss.h         | 10 +---
 3 files changed, 20 insertions(+), 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 e7fe5d702337..e6ebfc35243e 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 8c39823a8295..bb2548d091ef 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -34,6 +34,7 @@
 #include <linux/sys_soc.h>
 
 #include <video/mipi_display.h>
+#include <drm/drm_mipi_dsi.h>
 
 #include "omapdss.h"
 #include "dss.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);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index b0424daaceed..53fea1cbbc2d 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -14,6 +14,7 @@
 #include <linux/platform_data/omapdss.h>
 #include <uapi/drm/drm_mode.h>
 #include <drm/drm_crtc.h>
+#include <drm/drm_mipi_dsi.h>
 
 #define DISPC_IRQ_FRAMEDONE		(1 << 0)
 #define DISPC_IRQ_VSYNC			(1 << 1)
@@ -116,13 +117,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 +204,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;
-- 
2.25.0


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

* [PATCHv2 06/56] drm/omap: constify write buffers
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (4 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 14:13   ` Laurent Pinchart
  2020-03-25 12:53   ` Tomi Valkeinen
  2020-02-24 23:20 ` [PATCHv2 07/56] drm/omap: dsi: add generic transfer function Sebastian Reichel
                   ` (54 subsequent siblings)
  60 siblings, 2 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 bb2548d091ef..f01e0476296d 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 53fea1cbbc2d..b909b3a8c835 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -308,18 +308,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);
-- 
2.25.0


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

* [PATCHv2 07/56] drm/omap: dsi: add generic transfer function
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (5 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 06/56] drm/omap: constify write buffers Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 14:16   ` Laurent Pinchart
  2020-03-25 13:05   ` Tomi Valkeinen
  2020-02-24 23:20 ` [PATCHv2 08/56] drm/omap: panel-dsi-cm: convert to transfer API Sebastian Reichel
                   ` (53 subsequent siblings)
  60 siblings, 2 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c     | 52 +++++++++++++++++++++++++++
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ++
 2 files changed, 55 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index f01e0476296d..84e2eb0b51d7 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4836,6 +4836,56 @@ 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)
+{
+	/*
+	 * no_sync can be used to optimize performance by sending
+	 * e.g. column and page information without syncing in
+	 * between. It's not absolutley 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)
 {
@@ -4890,6 +4940,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 b909b3a8c835..ea7bf0970677 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -307,6 +307,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,
-- 
2.25.0


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

* [PATCHv2 08/56] drm/omap: panel-dsi-cm: convert to transfer API
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (6 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 07/56] drm/omap: dsi: add generic transfer function Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 14:52   ` Laurent Pinchart
  2020-02-24 23:20 ` [PATCHv2 09/56] drm/omap: dsi: unexport specific data transfer functions Sebastian Reichel
                   ` (52 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 133 +++++++++++++-----
 1 file changed, 96 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 e6ebfc35243e..92f510a771fe 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,44 @@ 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,
+	};
 
-	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 u8 paramY[] = {
+		MIPI_DCS_SET_PAGE_ADDRESS,
+		(y1 >> 8) & 0xff,
+		(y1 >> 0) & 0xff,
+		(y2 >> 8) & 0xff,
+		(y2 >> 0) & 0xff,
+	};
 
-	r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf));
+	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.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 +1023,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 +1084,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 +1124,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:
-- 
2.25.0


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

* [PATCHv2 09/56] drm/omap: dsi: unexport specific data transfer functions
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (7 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 08/56] drm/omap: panel-dsi-cm: convert to transfer API Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 14:53   ` Laurent Pinchart
  2020-02-24 23:20 ` [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic Sebastian Reichel
                   ` (51 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 84e2eb0b51d7..0990777a42f7 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4941,18 +4941,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 ea7bf0970677..787e102eb068 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -309,26 +309,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 {
-- 
2.25.0


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

* [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (8 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 09/56] drm/omap: dsi: unexport specific data transfer functions Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 15:01   ` Laurent Pinchart
  2020-02-24 23:20 ` [PATCHv2 11/56] drm/omap: dsi: simplify write function Sebastian Reichel
                   ` (50 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 92f510a771fe..ba046a596044 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -769,19 +769,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;
 }
@@ -1216,6 +1209,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 0990777a42f7..8c223b808740 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);
 
@@ -4783,45 +4782,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;
 }
 
@@ -4832,7 +4805,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;
 	}
 }
 
@@ -4937,7 +4909,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,
@@ -5393,7 +5364,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 787e102eb068..587206c984a9 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -301,9 +301,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 */
-- 
2.25.0


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

* [PATCHv2 11/56] drm/omap: dsi: simplify write function
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (9 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 15:31   ` Laurent Pinchart
  2020-02-24 23:20 ` [PATCHv2 12/56] drm/omap: dsi: simplify read functions Sebastian Reichel
                   ` (49 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 drivers/gpu/drm/omapdrm/dss/Kconfig |   1 +
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 144 +++++++---------------------
 2 files changed, 33 insertions(+), 112 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
index 72ae79c0c9b4..90e2dd522896 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 8c223b808740..e5589e615808 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2696,97 +2696,49 @@ 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)
+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;
 
-	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);
+	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, channel,
-				type == DSS_DSI_CONTENT_GENERIC ?
-				MIPI_DSI_GENERIC_LONG_WRITE :
-				MIPI_DSI_DCS_LONG_WRITE, data, len, 0);
+		r = dsi_vc_send_long(dsi, msg->channel, msg->type,
+						   msg->tx_buf, msg->tx_len, 0);
 	}
 
-	return r;
-}
-
-static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
-		const u8 *data, int len)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-
-	return dsi_vc_write_nosync_common(dsi, channel, data, len,
-			DSS_DSI_CONTENT_DCS);
-}
-
-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);
-
-	return dsi_vc_write_nosync_common(dsi, channel, data, len,
-			DSS_DSI_CONTENT_GENERIC);
-}
-
-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;
+	/*
+	 * 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 earily.
+	 */
 
-	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 +2960,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);
@@ -4811,35 +4754,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)
 {
-	/*
-	 * no_sync can be used to optimize performance by sending
-	 * e.g. column and page information without syncing in
-	 * between. It's not absolutley 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:
@@ -4849,11 +4774,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;
-- 
2.25.0


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

* [PATCHv2 12/56] drm/omap: dsi: simplify read functions
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (10 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 11/56] drm/omap: dsi: simplify write function Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 16:20   ` Laurent Pinchart
  2020-02-24 23:20 ` [PATCHv2 13/56] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg Sebastian Reichel
                   ` (48 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 109 +++++++++---------------------
 1 file changed, 33 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index e5589e615808..9b5b078beb6d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2741,60 +2741,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)
 {
@@ -2903,61 +2849,75 @@ 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);
 	int r;
+	u8 dcs_cmd = ((u8*) msg->tx_buf)[0];
 
-	r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
+	r = dsi_vc_send_short(dsi, msg->channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
 	if (r)
 		goto err;
 
-	r = dsi_vc_send_bta_sync(dssdev, channel);
+	r = dsi_vc_send_bta_sync(dssdev, msg->channel);
 	if (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_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("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
+		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("dsi_vc_generic_read(ch %d, reqlen %d) failed\n",
+		msg->channel, msg->tx_len);
+	return r;
 }
 
 static int dsi_enter_ulps(struct dsi_data *dsi)
@@ -4768,12 +4728,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;
-- 
2.25.0


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

* [PATCHv2 13/56] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (11 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 12/56] drm/omap: dsi: simplify read functions Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-25 16:30   ` Laurent Pinchart
  2020-02-24 23:20 ` [PATCHv2 14/56] drm/omap: dsi: introduce mipi_dsi_host Sebastian Reichel
                   ` (47 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 92 +++++++++++++++----------------
 1 file changed, 45 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 9b5b078beb6d..4899bfa2d76f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -2599,30 +2599,36 @@ 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)
 {
+	struct mipi_dsi_packet pkg;
 	/*u32 val; */
 	int i;
 	const u8 *p;
 	int r = 0;
 	u8 b1, b2, b3, b4;
 
+	r = mipi_dsi_create_packet(&pkg, msg);
+	if (r < 0)
+		return r;
+
 	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,
+				 pkg.header[3]);
 
-	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 +2637,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,64 +2662,64 @@ 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 pkg;
 	u32 r;
-	u8 data_id;
+
+	r = mipi_dsi_create_packet(&pkg, 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, pkg.header[1], pkg.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 = pkg.header[3] << 24 | pkg.header[2] << 16 | pkg.header[1] << 8 |
+	    pkg.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;
@@ -2853,10 +2859,10 @@ 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 cmd = ((u8*) msg->tx_buf)[0];
 	int r;
-	u8 dcs_cmd = ((u8*) msg->tx_buf)[0];
 
-	r = dsi_vc_send_short(dsi, msg->channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
+	r = dsi_vc_send_short(dsi, msg);
 	if (r)
 		goto err;
 
@@ -2877,7 +2883,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
 	return 0;
 err:
 	DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
-		msg->channel, dcs_cmd);
+		msg->channel, cmd);
 	return r;
 }
 
@@ -2885,17 +2891,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;
 
-- 
2.25.0


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

* [PATCHv2 14/56] drm/omap: dsi: introduce mipi_dsi_host
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (12 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 13/56] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 15/56] drm/omap: panel-dsi-cm: use DSI helpers Sebastian Reichel
                   ` (46 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 119 +++++++++---------
 drivers/gpu/drm/omapdrm/dss/dsi.c             |  54 ++++++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |   4 -
 3 files changed, 102 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index ba046a596044..c34daecb1de5 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;
@@ -280,11 +279,11 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata,
 	};
 
 
-	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;
 
@@ -327,7 +326,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;
@@ -350,7 +349,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;
 	}
 
@@ -364,7 +363,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) {
@@ -401,7 +400,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);
 
@@ -638,7 +637,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;
 		}
@@ -647,7 +646,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;
 		}
@@ -655,7 +654,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;
 	}
 
@@ -702,7 +701,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;
 	}
@@ -711,7 +710,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);
 
@@ -738,7 +737,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);
 	}
@@ -755,7 +754,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);
@@ -766,7 +765,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);
@@ -811,7 +810,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);
 }
 
@@ -843,7 +842,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);
 }
 
@@ -867,7 +866,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;
 }
@@ -878,7 +877,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);
@@ -891,7 +890,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);
@@ -936,14 +935,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;
 }
@@ -1020,7 +1019,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,
@@ -1034,7 +1033,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,
@@ -1042,6 +1041,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;
@@ -1093,7 +1093,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;
@@ -1102,12 +1102,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;
@@ -1201,28 +1201,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 device_node *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;
 	}
 
@@ -1233,7 +1233,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");
 	}
 
@@ -1243,7 +1243,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)
@@ -1251,7 +1251,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)
@@ -1276,11 +1276,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;
 
@@ -1290,14 +1290,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;
 
@@ -1379,12 +1379,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);
 
@@ -1392,7 +1392,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);
@@ -1413,7 +1413,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 = {
@@ -1422,8 +1422,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 4899bfa2d76f..3e6a57e00456 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)
 {
@@ -4709,9 +4716,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:
@@ -4785,11 +4795,30 @@ static const struct omap_dss_device_ops dsi_ops = {
 
 		.request_vc = dsi_request_vc,
 		.release_vc = dsi_release_vc,
-
-		.transfer = omap_dsi_transfer,
 	},
 };
 
+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;
+}
+
+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
  */
@@ -5258,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) {
@@ -5282,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;
@@ -5297,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 587206c984a9..da395a5e7257 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -303,10 +303,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 {
-- 
2.25.0


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

* [PATCHv2 15/56] drm/omap: panel-dsi-cm: use DSI helpers
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (13 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 14/56] drm/omap: dsi: introduce mipi_dsi_host Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 16/56] drm/omap: dsi: request VC via mipi_dsi_attach Sebastian Reichel
                   ` (45 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 126 +++---------------
 1 file changed, 18 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 c34daecb1de5..4a4a55135494 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,46 +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)
@@ -681,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;
 
@@ -732,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);
 
@@ -950,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);
@@ -1021,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,
@@ -1083,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;
-- 
2.25.0


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

* [PATCHv2 16/56] drm/omap: dsi: request VC via mipi_dsi_attach
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (14 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 15/56] drm/omap: panel-dsi-cm: use DSI helpers Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 17/56] drm/omap: panel-dsi-cm: drop hardcoded VC Sebastian Reichel
                   ` (44 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 4a4a55135494..b3688a8ca3cf 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;
 }
 
@@ -1278,8 +1269,21 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 		goto err_bl;
 	}
 
+	dsi->lanes = 3;
+	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:
@@ -1296,6 +1300,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 3e6a57e00456..64407f4651af 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];
@@ -4690,32 +4690,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)
 {
@@ -4792,23 +4766,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,
 	},
 };
 
 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;
 }
 
 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 da395a5e7257..b946b90ce01b 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -300,9 +300,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 {
-- 
2.25.0


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

* [PATCHv2 17/56] drm/omap: panel-dsi-cm: drop hardcoded VC
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (15 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 16/56] drm/omap: dsi: request VC via mipi_dsi_attach Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 18/56] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Sebastian Reichel
                   ` (43 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 .../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 b3688a8ca3cf..9a2ccec27f7e 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);
-- 
2.25.0


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

* [PATCHv2 18/56] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (16 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 17/56] drm/omap: panel-dsi-cm: drop hardcoded VC Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-04-01 12:09   ` Tomi Valkeinen
  2020-02-24 23:20 ` [PATCHv2 19/56] drm/omap: dsi: drop unused memory_read() Sebastian Reichel
                   ` (42 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Drop local definition of common MIPI DCS 1.3 defines.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 9a2ccec27f7e..92c9dc211aeb 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
@@ -333,8 +331,10 @@ static int dsicm_bl_update_status(struct backlight_device *dev)
 		src->ops->dsi.bus_lock(src);
 
 		r = dsicm_wake_up(ddata);
-		if (!r)
-			r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, level);
+		if (!r) {
+			r = dsicm_dcs_write_1(ddata,
+				MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level);
+		}
 
 		src->ops->dsi.bus_unlock(src);
 	}
@@ -597,11 +597,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;
-- 
2.25.0


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

* [PATCHv2 19/56] drm/omap: dsi: drop unused memory_read()
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (17 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 18/56] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 20/56] drm/omap: dsi: drop unused get_te() Sebastian Reichel
                   ` (41 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 92c9dc211aeb..59b8fc71c974 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -931,97 +931,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,
@@ -1094,8 +1003,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 b946b90ce01b..54f362cc5223 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -388,10 +388,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);
-- 
2.25.0


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

* [PATCHv2 20/56] drm/omap: dsi: drop unused get_te()
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (18 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 19/56] drm/omap: dsi: drop unused memory_read() Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 21/56] drm/omap: dsi: drop unused enable_te() Sebastian Reichel
                   ` (40 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 59b8fc71c974..e4b24c67c45d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -919,18 +919,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,
@@ -1002,7 +990,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 54f362cc5223..a1e78ba665d8 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -387,7 +387,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);
-- 
2.25.0


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

* [PATCHv2 21/56] drm/omap: dsi: drop unused enable_te()
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (19 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 20/56] drm/omap: dsi: drop unused get_te() Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 22/56] drm/omap: dsi: drop useless sync() Sebastian Reichel
                   ` (39 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 e4b24c67c45d..64f493c722c0 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -882,43 +882,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,
@@ -988,8 +951,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 a1e78ba665d8..e6832bf22ed0 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -385,8 +385,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);
-- 
2.25.0


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

* [PATCHv2 22/56] drm/omap: dsi: drop useless sync()
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (20 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 21/56] drm/omap: dsi: drop unused enable_te() Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 23/56] drm/omap: dsi: use pixel-format and mode from attach Sebastian Reichel
                   ` (38 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../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 64f493c722c0..a45df247aad1 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -845,23 +845,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;
@@ -950,7 +933,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 e6832bf22ed0..2c6c32240e20 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -384,7 +384,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 fce7e944a280..3f78ce2f85a1 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);
-- 
2.25.0


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

* [PATCHv2 23/56] drm/omap: dsi: use pixel-format and mode from attach
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (21 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 22/56] drm/omap: dsi: drop useless sync() Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 24/56] drm/omap: panel-dsi-cm: use bulk regulator API Sebastian Reichel
                   ` (37 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 --
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 20 +++++++++++++------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index a45df247aad1..199eac88a777 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -550,8 +550,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 64407f4651af..6c625b6d6d6b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4583,18 +4583,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 (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");
@@ -4605,7 +4606,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,6 +4785,13 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	}
 
 	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;
 }
 
-- 
2.25.0


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

* [PATCHv2 24/56] drm/omap: panel-dsi-cm: use bulk regulator API
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (22 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 23/56] drm/omap: dsi: use pixel-format and mode from attach Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 25/56] drm/omap: dsi: lp/hs switching support for transfer() Sebastian Reichel
                   ` (36 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../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 199eac88a777..8ad407a4072e 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;
 
@@ -557,28 +558,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(DCS_REGULATOR_SUPPLY_NUM, 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);
@@ -637,12 +626,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(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+	if (r)
+		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
 
 	return r;
 }
@@ -666,10 +653,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(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
+	if (r)
+		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
 
 	ddata->enabled = false;
 }
@@ -973,21 +959,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, DCS_REGULATOR_SUPPLY_NUM,
+				      ddata->supplies);
+	if (err)
+		return err;
 
 	backlight = of_parse_phandle(node, "backlight", 0);
 	if (backlight) {
-- 
2.25.0


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

* [PATCHv2 25/56] drm/omap: dsi: lp/hs switching support for transfer()
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (23 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 24/56] drm/omap: panel-dsi-cm: use bulk regulator API Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 26/56] drm/omap: dsi: move TE GPIO handling into core Sebastian Reichel
                   ` (35 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c |  6 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c               | 13 +++++++++++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h           |  2 --
 3 files changed, 14 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 8ad407a4072e..79ac1f6b375a 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) {
@@ -574,7 +574,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)
@@ -617,7 +617,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 6c625b6d6d6b..15298ebb9d69 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -45,6 +45,9 @@ struct dsi_reg { u16 module; u16 idx; };
 
 #define DSI_REG(mod, idx)		((const struct dsi_reg) { mod, idx })
 
+/* returns true iff both arguments logically differs */
+#define NEQV(a, b) (!(a) ^ !(b))
+
 /* DSI Protocol Engine */
 
 #define DSI_PROTO			0
@@ -329,6 +332,7 @@ struct dsi_data {
 	int irq;
 
 	bool is_enabled;
+	bool in_lp_mode;
 
 	struct clk *dss_clk;
 	struct regmap *syscon;
@@ -2431,6 +2435,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)
@@ -4697,6 +4703,11 @@ 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 (NEQV(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:
@@ -4757,8 +4768,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 2c6c32240e20..355aa235c23c 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -287,8 +287,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,
-- 
2.25.0


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

* [PATCHv2 26/56] drm/omap: dsi: move TE GPIO handling into core
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (24 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 25/56] drm/omap: dsi: lp/hs switching support for transfer() Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 27/56] drm/omap: dsi: drop custom enable_te() API Sebastian Reichel
                   ` (34 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 101 +------------
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 140 ++++++++++++++++--
 2 files changed, 135 insertions(+), 106 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 79ac1f6b375a..30e48d0de961 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];
 
@@ -68,10 +67,6 @@ struct panel_drv_data {
 
 	bool te_enabled;
 
-	atomic_t do_update;
-
-	struct delayed_work te_timeout_work;
-
 	bool intro_printed;
 
 	struct workqueue_struct *workqueue;
@@ -83,8 +78,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 +233,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;
@@ -271,15 +261,12 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
 	src->ops->enable(src);
 	ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
-	r = _dsicm_enable_te(ddata, true);
+	r = _dsicm_enable_te(ddata, ddata->te_enabled);
 	if (r) {
 		dev_err(&ddata->dsi->dev, "failed to re-enable TE");
 		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 +277,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);
 
@@ -745,43 +729,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)
 {
@@ -809,16 +756,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);
@@ -840,8 +781,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);
@@ -934,14 +874,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);
@@ -1026,25 +958,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 15298ebb9d69..7c160512c886 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>
@@ -371,6 +373,11 @@ struct dsi_data {
 	unsigned int update_bytes;
 #endif
 
+	/* external TE GPIO */
+	struct gpio_desc *te_gpio;
+	struct delayed_work te_timeout_work;
+	atomic_t do_ext_te_update;
+
 	bool te_enabled;
 	bool ulps_enabled;
 
@@ -3834,19 +3841,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;
 
@@ -3859,6 +3859,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)
@@ -4102,6 +4122,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(gpiod_to_irq(dsi->te_gpio));
+		else
+			disable_irq(gpiod_to_irq(dsi->te_gpio));
+	}
+
 	return 0;
 }
 
@@ -4779,11 +4807,91 @@ 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);
+	}
+
+	return;
+}
+
+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_from_of_node(client->dev.of_node,
+					      "te-gpios", 0, GPIOD_IN,
+					      "dsi-tearing-effect");
+	if (IS_ERR(dsi->te_gpio)) {
+		err = PTR_ERR(dsi->te_gpio);
+
+		if (err == -ENOENT) {
+			dsi->te_gpio = NULL;
+			return 0;
+		} else {
+			dev_err(dsi->dev, "Could not get TE gpio: %d\n", err);
+			return err;
+		}
+	}
+
+	te_irq = gpiod_to_irq(dsi->te_gpio);
+	irq_set_status_flags(te_irq, IRQ_NOAUTOEN);
+
+	err = request_threaded_irq(te_irq, omap_dsi_te_irq_handler, NULL,
+				   IRQF_TRIGGER_RISING, "TE", dsi);
+	if (err) {
+		dev_err(dsi->dev, "request irq failed with %d\n", err);
+		gpiod_put(dsi->te_gpio);
+		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(gpiod_to_irq(dsi->te_gpio), dsi);
+		cancel_delayed_work(&dsi->te_timeout_work);
+		gpiod_put(dsi->te_gpio);
+		dsi->te_gpio = NULL;
+	}
+}
+
 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;
@@ -4793,13 +4901,20 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 		return -EBUSY;
 	}
 
-	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;
 }
@@ -4816,6 +4931,7 @@ 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;
 }
-- 
2.25.0


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

* [PATCHv2 27/56] drm/omap: dsi: drop custom enable_te() API
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (25 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 26/56] drm/omap: dsi: move TE GPIO handling into core Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 28/56] drm/omap: dsi: do bus locking in host driver Sebastian Reichel
                   ` (33 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  3 --
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 33 ++++++++++++++-----
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  2 --
 3 files changed, 24 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 30e48d0de961..e4ffe34324f8 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -772,7 +772,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;
 
@@ -781,8 +780,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 7c160512c886..50a567ebfb86 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4117,10 +4117,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) {
@@ -4730,6 +4728,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 (NEQV(msg->flags & MIPI_DSI_MSG_USE_LPM, dsi->in_lp_mode)) {
 		dsi_vc_enable_hs(dssdev, msg->channel,
@@ -4746,16 +4745,34 @@ 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)
@@ -4802,8 +4819,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 355aa235c23c..dc41f982a082 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -287,8 +287,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);
 
-- 
2.25.0


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

* [PATCHv2 28/56] drm/omap: dsi: do bus locking in host driver
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (26 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 27/56] drm/omap: dsi: drop custom enable_te() API Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:20 ` [PATCHv2 29/56] drm/omap: dsi: untangle ulps ops from enable/disable Sebastian Reichel
                   ` (32 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 46 +------------------
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 33 ++++++++-----
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  3 --
 3 files changed, 23 insertions(+), 59 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index e4ffe34324f8..42a4a69b03fd 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -298,7 +298,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;
 
@@ -313,15 +312,11 @@ 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);
@@ -347,21 +342,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;
 	}
@@ -378,20 +368,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;
 	}
@@ -409,7 +394,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;
 
@@ -420,14 +404,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);
@@ -457,7 +437,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;
 
@@ -470,9 +449,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);
@@ -673,17 +650,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;
 
@@ -700,7 +671,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);
@@ -709,24 +679,19 @@ 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);
+	mutex_unlock(&ddata->lock);
 }
 
 static int dsicm_update(struct omap_dss_device *dssdev,
@@ -739,7 +704,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)
@@ -761,11 +725,9 @@ 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);
+	/* note: no unlock here. unlock is src framedone_cb */
 	return 0;
 err:
-	src->ops->dsi.bus_unlock(src);
 	mutex_unlock(&ddata->lock);
 	return r;
 }
@@ -791,7 +753,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);
 
@@ -800,11 +761,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 50a567ebfb86..ce45021c99ce 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -479,17 +479,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);
 }
 
@@ -3805,6 +3801,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)
@@ -3864,6 +3862,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;
@@ -4723,10 +4723,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;
 
@@ -4775,6 +4774,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;
@@ -4808,9 +4820,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 dc41f982a082..8ff99c00c708 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -290,9 +290,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);
-- 
2.25.0


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

* [PATCHv2 29/56] drm/omap: dsi: untangle ulps ops from enable/disable
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (27 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 28/56] drm/omap: dsi: do bus locking in host driver Sebastian Reichel
@ 2020-02-24 23:20 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 30/56] drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE Sebastian Reichel
                   ` (31 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:20 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  8 ++--
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 38 ++++++++++++++-----
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  5 +--
 3 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 42a4a69b03fd..239a48910db7 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -233,7 +233,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;
 
@@ -258,7 +258,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, ddata->te_enabled);
@@ -586,7 +586,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(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
 	if (r)
@@ -612,7 +612,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(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
 	if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index ce45021c99ce..684d52079e89 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4062,13 +4062,10 @@ 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_ulps_enable(struct dsi_data *dsi)
 {
-	struct dsi_data *dsi = to_dsi_data(dssdev);
 	int r;
 
-	DSSDBG("dsi_display_enable\n");
-
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	mutex_lock(&dsi->lock);
@@ -4091,16 +4088,19 @@ static void dsi_display_enable(struct omap_dss_device *dssdev)
 	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_enable\n");
+	dsi_display_ulps_enable(dsi);
+}
 
-	DSSDBG("dsi_display_disable\n");
-
+static void dsi_display_ulps_disable(struct dsi_data *dsi,
+		bool disconnect_lanes, bool enter_ulps)
+{
 	WARN_ON(!dsi_bus_is_locked(dsi));
 
 	mutex_lock(&dsi->lock);
@@ -4117,6 +4117,23 @@ static void dsi_display_disable(struct omap_dss_device *dssdev,
 	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_display_ulps_disable(dsi, true, false);
+}
+
+static void dsi_ulps(struct omap_dss_device *dssdev, bool enable)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+	DSSDBG("dsi_ulps\n");
+	if (enable)
+		dsi_display_ulps_disable(dsi, false, true);
+	else
+		dsi_display_ulps_enable(dsi);
+}
+
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
 	dsi->te_enabled = enable;
@@ -4818,9 +4835,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 8ff99c00c708..484bdb01871f 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -280,10 +280,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);
 
-- 
2.25.0


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

* [PATCHv2 30/56] drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (28 preceding siblings ...)
  2020-02-24 23:20 ` [PATCHv2 29/56] drm/omap: dsi: untangle ulps ops from enable/disable Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 31/56] drm/omap: dsi: do ULPS in host driver Sebastian Reichel
                   ` (30 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

DSI command mode panels are self-refreshing displays, that
can be updated very rarely for static images. For this kind
of scenario some panels support, that the DSI bus switches
into ULPS mode until the panel needs to be refreshed.

This is problematic on some panels, so introduce a flag to
signal the DSI host implementation that the panel allows
going into ULPS mode.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 include/drm/drm_mipi_dsi.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 360e6377e84b..f36f89c14b4a 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -132,6 +132,8 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);
 #define MIPI_DSI_CLOCK_NON_CONTINUOUS	BIT(10)
 /* transmit data in low power */
 #define MIPI_DSI_MODE_LPM		BIT(11)
+/* allow going into ULPS mode while command mode panel is not updated */
+#define MIPI_DSI_MODE_ULPS_IDLE		BIT(12)
 
 enum mipi_dsi_pixel_format {
 	MIPI_DSI_FMT_RGB888,
-- 
2.25.0


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

* [PATCHv2 31/56] drm/omap: dsi: do ULPS in host driver
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (29 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 30/56] drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 32/56] drm/omap: dsi: move panel refresh function to host Sebastian Reichel
                   ` (29 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 273 +-----------------
 drivers/gpu/drm/omapdrm/dss/dsi.c             |  61 +++-
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |   2 -
 3 files changed, 62 insertions(+), 274 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 239a48910db7..1e33cf7c1448 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>
 
@@ -69,21 +68,13 @@ struct panel_drv_data {
 
 	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;
@@ -207,94 +198,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, ddata->te_enabled);
-	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);
@@ -312,11 +215,8 @@ 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);
-		}
+		r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
+				      level);
 	}
 
 	mutex_unlock(&ddata->lock);
@@ -343,18 +243,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);
 
@@ -369,17 +263,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);
 
@@ -389,103 +278,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,
 };
 
@@ -621,15 +419,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)
 {
@@ -671,17 +460,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);
 }
@@ -705,10 +489,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;
@@ -748,24 +528,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)
 {
@@ -865,7 +627,7 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 		ddata->use_dsi_backlight = true;
 	}
 
-	/* TODO: ulps */
+	/* TODO: ulps_enabled */
 
 	return 0;
 }
@@ -913,13 +675,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) {
@@ -950,6 +705,9 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	dsi->hs_rate = 300000000;
 	dsi->lp_rate = 10000000;
 
+	if (ddata->ulps_enabled)
+		dsi->mode_flags |= MIPI_DSI_MODE_ULPS_IDLE;
+
 	r = mipi_dsi_attach(dsi);
 	if (r < 0)
 		goto err_dsi_attach;
@@ -959,8 +717,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);
 
@@ -987,9 +743,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 684d52079e89..12d661ad37ad 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -210,6 +210,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);
 
@@ -380,6 +382,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;
@@ -3801,6 +3806,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);
@@ -3863,6 +3869,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,16 +4131,6 @@ static void dsi_display_disable(struct omap_dss_device *dssdev)
 	dsi_display_ulps_disable(dsi, true, false);
 }
 
-static void dsi_ulps(struct omap_dss_device *dssdev, bool enable)
-{
-	struct dsi_data *dsi = to_dsi_data(dssdev);
-	DSSDBG("dsi_ulps\n");
-	if (enable)
-		dsi_display_ulps_disable(dsi, false, true);
-	else
-		dsi_display_ulps_enable(dsi);
-}
-
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
 {
 	dsi->te_enabled = enable;
@@ -4148,6 +4145,40 @@ 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_ulps_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_display_ulps_enable(dsi);
+		dsi_enable_te(dsi, true);
+	}
+}
+
 #ifdef PRINT_VERBOSE_VM_TIMINGS
 static void print_dsi_vm(const char *str,
 		const struct omap_dss_dsi_videomode_timings *t)
@@ -4798,7 +4829,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;
@@ -4838,8 +4871,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,
@@ -4958,6 +4989,12 @@ 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->ulps_auto_idle = !!(client->mode_flags & MIPI_DSI_MODE_ULPS_IDLE);
+	dsi_set_ulps_auto(dsi, true);
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 484bdb01871f..e2643623b5f2 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -281,8 +281,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);
 
-- 
2.25.0


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

* [PATCHv2 32/56] drm/omap: dsi: move panel refresh function to host
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (30 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 31/56] drm/omap: dsi: do ULPS in host driver Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 33/56] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations Sebastian Reichel
                   ` (28 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  68 ------------
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 101 ++++++++++++++++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |  13 +--
 drivers/gpu/drm/omapdrm/omap_crtc.c           |  11 +-
 4 files changed, 97 insertions(+), 96 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 1e33cf7c1448..5a2a8cee9186 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -177,27 +177,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);
@@ -470,48 +449,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);
-	mutex_unlock(&ddata->lock);
-}
-
-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;
-
-	/* note: no unlock here. unlock is src framedone_cb */
-	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;
@@ -572,10 +509,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;
@@ -660,7 +593,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 12d661ad37ad..b0e796f90fca 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -217,6 +217,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
@@ -386,9 +389,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
@@ -3809,8 +3809,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");
 }
@@ -3842,6 +3840,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);
 }
 
@@ -3863,17 +3863,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,
@@ -3883,6 +3935,24 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel,
 		_dsi_update(dsi);
 	}
 
+	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)
+{
+	int i, r;
+
+	for (i = 0; i < 4; i++) {
+		r = dsi_update_channel(dssdev, i);
+		if (r != -ENODEV)
+			return r;
+	}
+
 	return 0;
 }
 
@@ -4102,7 +4172,9 @@ 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);
 	dsi_display_ulps_enable(dsi);
+	dsi_bus_unlock(dsi);
 }
 
 static void dsi_display_ulps_disable(struct dsi_data *dsi,
@@ -4128,7 +4200,9 @@ 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_ulps_disable(dsi, true, false);
+	dsi_bus_unlock(dsi);
 }
 
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
@@ -4876,7 +4950,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,
 	},
 };
 
@@ -4974,14 +5048,18 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 		return -EBUSY;
 	}
 
+	dsi_bus_lock(dsi);
+
 	atomic_set(&dsi->do_ext_te_update, 0);
 
 	if (client->mode_flags & MIPI_DSI_MODE_VIDEO) {
 		dsi->mode = OMAP_DSS_DSI_VIDEO_MODE;
 	} else {
 		r = omap_dsi_register_te_irq(dsi, client);
-		if (r)
+		if (r) {
+			dsi_bus_unlock(dsi);
 			return r;
+		}
 
 		dsi->mode = OMAP_DSS_DSI_CMD_MODE;
 	}
@@ -4995,6 +5073,7 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	dsi->ulps_auto_idle = !!(client->mode_flags & MIPI_DSI_MODE_ULPS_IDLE);
 	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 e2643623b5f2..d7081086c2b1 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -280,13 +280,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);
@@ -350,7 +349,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;
@@ -371,11 +369,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 3f78ce2f85a1..c924d77207fb 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;
-- 
2.25.0


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

* [PATCHv2 33/56] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (31 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 32/56] drm/omap: dsi: move panel refresh function to host Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 34/56] drm/omap: dsi: drop custom panel capability support Sebastian Reichel
                   ` (27 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 75 ++++++++++---------
 drivers/gpu/drm/omapdrm/omap_encoder.c        | 24 ++----
 2 files changed, 46 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 5a2a8cee9186..6f559c1b0bf6 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -288,27 +288,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(DCS_REGULATOR_SUPPLY_NUM, 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);
 
@@ -363,12 +342,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(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-	if (r)
-		dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
-
 	return r;
 }
 
@@ -377,6 +350,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);
@@ -388,14 +363,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(DCS_REGULATOR_SUPPLY_NUM, 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,
@@ -415,6 +382,30 @@ 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(DCS_REGULATOR_SUPPLY_NUM, 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);
@@ -449,6 +440,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(DCS_REGULATOR_SUPPLY_NUM, 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;
@@ -502,8 +503,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,
@@ -666,8 +669,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..10abe4d01b0b 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -137,15 +137,11 @@ 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.
+	 * Disable the internal encoder. This will disable the DSS output.
 	 */
-	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI) {
-		if (dssdev->ops && dssdev->ops->disable)
-			dssdev->ops->disable(dssdev);
-		dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
-	}
+	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
@@ -166,15 +162,11 @@ static void omap_encoder_enable(struct drm_encoder *encoder)
 	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.
+	 * Enable the internal encoder. This will enable the DSS output.
 	 */
-	if (dssdev->type != OMAP_DISPLAY_TYPE_DSI) {
-		if (dssdev->ops && dssdev->ops->enable)
-			dssdev->ops->enable(dssdev);
-		dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
-	}
+	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
-- 
2.25.0


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

* [PATCHv2 34/56] drm/omap: dsi: drop custom panel capability support
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (32 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 33/56] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 35/56] drm/omap: dsi: convert to drm_panel Sebastian Reichel
                   ` (26 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 6f559c1b0bf6..30be9e4ab908 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -602,9 +602,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 b0e796f90fca..42f995da21a5 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -4732,6 +4732,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)
 {
@@ -4951,6 +4958,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 d7081086c2b1..430e915d2759 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -122,11 +122,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,
@@ -281,6 +276,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,
@@ -353,8 +349,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 c924d77207fb..af62f6075602 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -495,8 +495,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);
@@ -548,17 +547,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,
-- 
2.25.0


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

* [PATCHv2 35/56] drm/omap: dsi: convert to drm_panel
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (33 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 34/56] drm/omap: dsi: drop custom panel capability support Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 36/56] drm/omap: drop omapdss-boot-init Sebastian Reichel
                   ` (25 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 210 +++++++-----------
 drivers/gpu/drm/omapdrm/dss/dsi.c             | 133 +++++++++--
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |   1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h         |   8 -
 4 files changed, 193 insertions(+), 159 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 30be9e4ab908..803b7dada343 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_panel.h>
+#include <drm/drm_modes.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;
 
@@ -71,7 +69,11 @@ struct panel_drv_data {
 	bool ulps_enabled;
 };
 
-#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);
 
@@ -285,7 +287,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;
 
@@ -322,10 +323,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) {
@@ -345,15 +342,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);
@@ -363,52 +357,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(DCS_REGULATOR_SUPPLY_NUM, ddata->supplies);
-	if (r) {
+	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);
@@ -421,33 +388,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(DCS_REGULATOR_SUPPLY_NUM, 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(DCS_REGULATOR_SUPPLY_NUM, 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)
@@ -466,50 +439,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\n",
+			ddata->mode.hdisplay, ddata->mode.vdisplay,
+			ddata->mode.vrefresh);
+		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);
-}
+	drm_mode_probed_add(connector, mode);
 
-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;
-
-	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)
@@ -518,8 +478,12 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 	struct device_node *backlight;
 	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
 	struct display_timing timing;
+	struct videomode vm;
 	int err;
 
+	vm.hactive = 864;
+	vm.vactive = 480;
+
 	ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(ddata->reset_gpio)) {
 		err = PTR_ERR(ddata->reset_gpio);
@@ -529,15 +493,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);
 
@@ -573,7 +538,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");
@@ -585,30 +549,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;
@@ -640,6 +591,10 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	if (ddata->ulps_enabled)
 		dsi->mode_flags |= MIPI_DSI_MODE_ULPS_IDLE;
 
+	r = drm_panel_add(&ddata->panel);
+	if (r < 0)
+		goto err_panel_add;
+
 	r = mipi_dsi_attach(dsi);
 	if (r < 0)
 		goto err_dsi_attach;
@@ -647,6 +602,8 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
 	return 0;
 
 err_dsi_attach:
+	drm_panel_remove(&ddata->panel);
+err_panel_add:
 	sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
 err_bl:
 	if (ddata->extbldev)
@@ -658,15 +615,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);
 
@@ -680,7 +634,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 42f995da21a5..a399d6857c0d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -37,6 +37,7 @@
 
 #include <video/mipi_display.h>
 #include <drm/drm_mipi_dsi.h>
+#include <drm/drm_panel.h>
 
 #include "omapdss.h"
 #include "dss.h"
@@ -220,6 +221,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
@@ -386,6 +389,7 @@ struct dsi_data {
 	bool te_enabled;
 	bool ulps_enabled;
 	bool ulps_auto_idle;
+	bool video_enabled;
 
 	struct delayed_work ulps_work;
 
@@ -426,6 +430,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;
@@ -3629,7 +3635,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);
@@ -3638,8 +3644,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) {
@@ -3679,7 +3687,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) {
@@ -3688,7 +3696,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)
@@ -3711,6 +3720,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);
+	int i;
+
+	dsi_bus_lock(dsi);
+	dsi->video_enabled = false;
+
+	for (i = 0; i < 3; 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;
@@ -3904,6 +3932,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;
@@ -3949,7 +3982,7 @@ static int dsi_update_all(struct omap_dss_device *dssdev)
 
 	for (i = 0; i < 4; i++) {
 		r = dsi_update_channel(dssdev, i);
-		if (r != -ENODEV)
+		if (r && r != -ENODEV)
 			return r;
 	}
 
@@ -4172,8 +4205,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_ulps_enable(dsi);
+}
+
+static void dsi_enable_video_outputs(struct omap_dss_device *dssdev)
+{
+	struct dsi_data *dsi = to_dsi_data(dssdev);
+	int i;
+
+	dsi_bus_lock(dsi);
+
+	dsi_display_enable(dssdev);
+
+	for (i = 0; i < 3; 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);
 }
 
@@ -4199,10 +4254,10 @@ static void dsi_display_ulps_disable(struct dsi_data *dsi,
 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_ulps_disable(dsi, true, false);
-	dsi_bus_unlock(dsi);
 }
 
 static int dsi_enable_te(struct dsi_data *dsi, bool enable)
@@ -4740,14 +4795,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;
@@ -4910,9 +4969,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;
@@ -4933,6 +4998,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)
 {
@@ -4948,15 +5030,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,
-
-	.dsi = {
-		.set_config = dsi_set_config,
+	.enable = dsi_enable_video_outputs,
+	.disable = dsi_disable_video_outputs,
 
-		.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,
 	},
@@ -5046,6 +5126,7 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 {
 	struct dsi_data *dsi = host_to_omap(host);
 	unsigned int channel = client->channel;
+	struct drm_panel *panel;
 	int r;
 
 	if (channel > 3)
@@ -5058,6 +5139,10 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 
 	dsi_bus_lock(dsi);
 
+	panel = of_drm_find_panel(client->dev.of_node);
+	if (IS_ERR(panel))
+		return PTR_ERR(panel);
+
 	atomic_set(&dsi->do_ext_te_update, 0);
 
 	if (client->mode_flags & MIPI_DSI_MODE_VIDEO) {
@@ -5078,8 +5163,12 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host,
 	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?
+	dsi->config.lp_clk_max = client->lp_rate;
+
 	dsi->ulps_auto_idle = !!(client->mode_flags & MIPI_DSI_MODE_ULPS_IDLE);
-	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 00372f4ce711..c849927ff185 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 430e915d2759..10e6ae666dfa 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -277,14 +277,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 {
-- 
2.25.0


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

* [PATCHv2 36/56] drm/omap: drop omapdss-boot-init
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (34 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 35/56] drm/omap: dsi: convert to drm_panel Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 37/56] drm/omap: dsi: implement check timings Sebastian Reichel
                   ` (24 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 drivers/gpu/drm/omapdrm/dss/Kconfig           |   3 -
 drivers/gpu/drm/omapdrm/dss/Makefile          |   2 -
 .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   | 219 ------------------
 3 files changed, 224 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 90e2dd522896..9ac60c24787b 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
 
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 c849927ff185..000000000000
--- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c
+++ /dev/null
@@ -1,219 +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 int __init omapdss_boot_init(void)
-{
-	struct device_node *dss, *child;
-
-	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);
-
-	for_each_available_child_of_node(dss, child) {
-		if (!of_find_property(child, "compatible", NULL))
-			continue;
-
-		omapdss_walk_device(child, true);
-	}
-
-	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);
-- 
2.25.0


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

* [PATCHv2 37/56] drm/omap: dsi: implement check timings
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (35 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 36/56] drm/omap: drop omapdss-boot-init Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 38/56] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO Sebastian Reichel
                   ` (23 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Implement check timings, which will check if its 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>
---
 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 a399d6857c0d..acbfffe83b3e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -283,6 +283,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;
@@ -297,16 +302,12 @@ struct dsi_clk_calc_ctx {
 
 	struct dss_pll_clock_info dsi_cinfo;
 	struct dispc_clock_info dispc_cinfo;
+	struct dsi_lp_clock_info user_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;
@@ -4794,44 +4795,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->user_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.user_lp_cinfo;
 	dsi->user_dsi_cinfo = ctx.dsi_cinfo;
 	dsi->user_dispc_cinfo = ctx.dispc_cinfo;
 
@@ -5008,11 +5020,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,
-- 
2.25.0


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

* [PATCHv2 38/56] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (36 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 37/56] drm/omap: dsi: implement check timings Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 39/56] drm/omap: panel-dsi-cm: support unbinding Sebastian Reichel
                   ` (22 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 803b7dada343..00dc7b0a349b 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -219,7 +219,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);
@@ -239,7 +239,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);
@@ -259,8 +259,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,
-- 
2.25.0


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

* [PATCHv2 39/56] drm/omap: panel-dsi-cm: support unbinding
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (37 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 38/56] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 40/56] drm/omap: panel-dsi-cm: fix remove() Sebastian Reichel
                   ` (21 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 00dc7b0a349b..8562f056585d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -612,7 +612,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);
 
@@ -642,11 +642,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);
-- 
2.25.0


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

* [PATCHv2 40/56] drm/omap: panel-dsi-cm: fix remove()
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (38 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 39/56] drm/omap: panel-dsi-cm: support unbinding Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 41/56] drm/omap: dsi: return proper error code from dsi_update_all() Sebastian Reichel
                   ` (20 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 8562f056585d..fef9ba5319c2 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -627,9 +627,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;
 }
 
-- 
2.25.0


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

* [PATCHv2 41/56] drm/omap: dsi: return proper error code from dsi_update_all()
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (39 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 40/56] drm/omap: panel-dsi-cm: fix remove() Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-04-01 12:23   ` Tomi Valkeinen
  2020-02-24 23:21 ` [PATCHv2 42/56] drm/omap: remove global dss_device variable Sebastian Reichel
                   ` (19 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index acbfffe83b3e..f629e6b1025b 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -3987,7 +3987,7 @@ static int dsi_update_all(struct omap_dss_device *dssdev)
 			return r;
 	}
 
-	return 0;
+	return r;
 }
 
 /* Display funcs */
-- 
2.25.0


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

* [PATCHv2 42/56] drm/omap: remove global dss_device variable
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (40 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 41/56] drm/omap: dsi: return proper error code from dsi_update_all() Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 43/56] drm/omap: bind components with drm_device argument Sebastian Reichel
                   ` (18 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 b76fc2b56227..4438947326ea 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 10e6ae666dfa..9f8aefaadefe 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -355,12 +355,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 cdafd7ef1c32..579f9d80fec9 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -594,6 +594,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;
 	unsigned int i;
 	int ret;
@@ -609,7 +610,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);
 
@@ -707,9 +708,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");
-- 
2.25.0


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

* [PATCHv2 43/56] drm/omap: bind components with drm_device argument
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (41 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 42/56] drm/omap: remove global dss_device variable Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-27  0:32   ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 44/56] drm/panel: Move OMAP's DSI command mode panel driver Sebastian Reichel
                   ` (17 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

This fixes the omapdrm driver to call component_bind_all()
with drm_device as data argument as recommended in the
DRM component helper usage text.

After this patch DRM functionality can be implemented directly
in the components resulting in a simpler driver stack by removing
one layer of abstraction.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/gpu/drm/omapdrm/dss/dss.c     | 27 +++++++++++++++++----------
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 +++
 drivers/gpu/drm/omapdrm/omap_drv.c    | 15 +++++++++++----
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 4438947326ea..a0b37d9b62ea 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1301,26 +1301,35 @@ static const struct soc_device_attribute dss_soc_devices[] = {
 	{ /* sentinel */ }
 };
 
+int dss_bind_components(struct dss_device *dss, struct drm_device *drm_dev)
+{
+	struct platform_device *pdev = dss->pdev;
+
+	return component_bind_all(&pdev->dev, drm_dev);
+}
+EXPORT_SYMBOL(dss_bind_components);
+
+void dss_unbind_components(struct dss_device *dss, struct drm_device *drm_dev)
+{
+	struct platform_device *pdev = dss->pdev;
+
+	component_unbind_all(&pdev->dev, drm_dev);
+}
+EXPORT_SYMBOL(dss_unbind_components);
+
 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);
-	if (r)
-		return r;
 
 	pm_set_vt_switch(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);
+	if (IS_ERR(drm_pdev))
 		return PTR_ERR(drm_pdev);
-	}
 
 	dss->drm_pdev = drm_pdev;
 
@@ -1332,8 +1341,6 @@ static void dss_unbind(struct device *dev)
 	struct dss_device *dss = dev_get_drvdata(dev);
 
 	platform_device_unregister(dss->drm_pdev);
-
-	component_unbind_all(dev, NULL);
 }
 
 static const struct component_master_ops dss_component_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 9f8aefaadefe..45f5c46712eb 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -526,4 +526,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 dss_bind_components(struct dss_device *dss, struct drm_device *drm_dev);
+void dss_unbind_components(struct dss_device *dss, struct drm_device *drm_dev);
+
 #endif /* __OMAP_DRM_DSS_H */
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 579f9d80fec9..c47e63e94a2e 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -237,8 +237,6 @@ static int omap_modeset_init(struct drm_device *dev)
 	if (!omapdss_stack_is_ready())
 		return -EPROBE_DEFER;
 
-	drm_mode_config_init(dev);
-
 	ret = omap_modeset_init_properties(dev);
 	if (ret < 0)
 		return ret;
@@ -605,10 +603,15 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 	ddev = drm_dev_alloc(&omap_drm_driver, dev);
 	if (IS_ERR(ddev))
 		return PTR_ERR(ddev);
-
-	priv->ddev = ddev;
 	ddev->dev_private = priv;
 
+	drm_mode_config_init(ddev);
+
+	ret = dss_bind_components(pdata->dss, ddev);
+	if (ret)
+		goto err_ddev_deinit;
+
+	priv->ddev = ddev;
 	priv->dev = dev;
 	priv->dss = pdata->dss;
 	priv->dispc = dispc_get_dispc(priv->dss);
@@ -673,6 +676,8 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 	destroy_workqueue(priv->wq);
 	omap_disconnect_pipelines(ddev);
 	omap_crtc_pre_uninit(priv);
+	dss_unbind_components(priv->dss, ddev);
+err_ddev_deinit:
 	drm_dev_put(ddev);
 	return ret;
 }
@@ -700,6 +705,8 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
 	omap_disconnect_pipelines(ddev);
 	omap_crtc_pre_uninit(priv);
 
+	dss_unbind_components(priv->dss, ddev);
+
 	drm_dev_put(ddev);
 }
 
-- 
2.25.0


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

* [PATCHv2 44/56] drm/panel: Move OMAP's DSI command mode panel driver
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (42 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 43/56] drm/omap: bind components with drm_device argument Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 45/56] drm/omap: dsi: Register a drm_bridge Sebastian Reichel
                   ` (16 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 da3b84602cdd..07ab75a66607 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -38,6 +38,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 af1e2a3cc5fc..bb19cda8a619 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.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_FEIXIN_K101_IM2BA02) += panel-feixin-k101-im2ba02.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
-- 
2.25.0


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

* [PATCHv2 45/56] drm/omap: dsi: Register a drm_bridge
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (43 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 44/56] drm/panel: Move OMAP's DSI command mode panel driver Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-25 11:50   ` [PATCHv2.1 " Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 46/56] drm/omap: remove legacy DSS device operations Sebastian Reichel
                   ` (15 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 128 +++++++++++++++++++-----------
 1 file changed, 83 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index f629e6b1025b..0d6162875b30 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 <video/mipi_display.h>
+#include <drm/drm_bridge.h>
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_panel.h>
 
@@ -440,6 +441,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 {
@@ -452,6 +454,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);
@@ -5010,50 +5015,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,
@@ -5394,6 +5356,77 @@ 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_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;
+}
+
+static void dsi_bridge_cleanup(struct dsi_data *dsi)
+{
+       drm_bridge_remove(&dsi->bridge);
+}
+
 /* -----------------------------------------------------------------------------
  * Probe & Remove, Suspend & Resume
  */
@@ -5403,6 +5436,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;
@@ -5417,9 +5452,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);
 
@@ -5432,6 +5469,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)
-- 
2.25.0


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

* [PATCHv2 46/56] drm/omap: remove legacy DSS device operations
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (44 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 45/56] drm/omap: dsi: Register a drm_bridge Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 47/56] drm/omap: remove unused omap_connector Sebastian Reichel
                   ` (14 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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   | 40 --------------
 5 files changed, 177 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 a0b37d9b62ea..bf627a50e72f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1553,15 +1553,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 45f5c46712eb..325a89d802e2 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -122,11 +122,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,
@@ -280,24 +275,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;
 };
 
@@ -341,8 +318,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 */
@@ -373,10 +348,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);
 
@@ -396,11 +367,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 528764566b17..db6becd345a0 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 10abe4d01b0b..abb3821de8b8 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -115,11 +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)
@@ -129,25 +124,6 @@ static void omap_encoder_disable(struct drm_encoder *encoder)
 	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)
@@ -157,22 +133,6 @@ static void omap_encoder_enable(struct drm_encoder *encoder)
 	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,
-- 
2.25.0


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

* [PATCHv2 47/56] drm/omap: remove unused omap_connector
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (45 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 46/56] drm/omap: remove legacy DSS device operations Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 48/56] drm/omap: simplify omap_display_id Sebastian Reichel
                   ` (13 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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   |  11 --
 6 files changed, 6 insertions(+), 182 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 db6becd345a0..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 = { { 0 } };
-	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 c47e63e94a2e..4c2095067544 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -330,19 +330,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 7c4b66efcaa7..80acd872ac38 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 abb3821de8b8..610c5a2f2771 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -139,17 +139,6 @@ 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;
 }
 
-- 
2.25.0


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

* [PATCHv2 48/56] drm/omap: simplify omap_display_id
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (46 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 47/56] drm/omap: remove unused omap_connector Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 49/56] drm/omap: drop unused DSS next pointer Sebastian Reichel
                   ` (12 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 4c2095067544..3a1982e7aa98 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))
-- 
2.25.0


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

* [PATCHv2 49/56] drm/omap: drop unused DSS next pointer
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (47 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 48/56] drm/omap: simplify omap_display_id Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 50/56] drm/omap: drop empty omap_encoder helper functions Sebastian Reichel
                   ` (11 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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..d62713b241d2 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 325a89d802e2..03498f0ed6c2 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -292,7 +292,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 610c5a2f2771..5f5fa01240a7 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)
-- 
2.25.0


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

* [PATCHv2 50/56] drm/omap: drop empty omap_encoder helper functions
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (48 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 49/56] drm/omap: drop unused DSS next pointer Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 51/56] drm/omap: drop DSS ops_flags Sebastian Reichel
                   ` (10 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Cleanup empty functions for encoder enable, disable and atomic check.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/gpu/drm/omapdrm/omap_encoder.c | 28 --------------------------
 1 file changed, 28 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
index 5f5fa01240a7..e24411fb9dac 100644
--- a/drivers/gpu/drm/omapdrm/omap_encoder.c
+++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
@@ -113,36 +113,8 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
 	dss_mgr_set_timings(output, &vm);
 }
 
-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);
-}
-
-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);
-}
-
-static int omap_encoder_atomic_check(struct drm_encoder *encoder,
-				     struct drm_crtc_state *crtc_state,
-				     struct drm_connector_state *conn_state)
-{
-	return 0;
-}
-
 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,
 };
 
 /* initialize encoder */
-- 
2.25.0


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

* [PATCHv2 51/56] drm/omap: drop DSS ops_flags
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (49 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 50/56] drm/omap: drop empty omap_encoder helper functions Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 52/56] drm/omap: drop dssdev display field Sebastian Reichel
                   ` (9 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 03498f0ed6c2..0ee042228c96 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -278,14 +278,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;
 
@@ -314,7 +306,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 766553bb2f87..96e5d2944452 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -774,7 +774,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) {
-- 
2.25.0


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

* [PATCHv2 52/56] drm/omap: drop dssdev display field
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (50 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 51/56] drm/omap: drop DSS ops_flags Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 53/56] drm/omap: simplify DSI manual update code Sebastian Reichel
                   ` (8 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

All displays are using drm_panel instead off dssdev
now, so this field is always 0 and can be dropped.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 d62713b241d2..d9a5e7b9d401 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 0ee042228c96..4ad1b63c1b07 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -297,12 +297,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;
-- 
2.25.0


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

* [PATCHv2 53/56] drm/omap: simplify DSI manual update code
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (51 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 52/56] drm/omap: drop dssdev display field Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 54/56] ARM: omap2plus_defconfig: Update for moved DSI command mode panel Sebastian Reichel
                   ` (7 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 0d6162875b30..e8924af4c30f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5015,11 +5015,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)
@@ -5445,7 +5443,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 4ad1b63c1b07..fb045eca03a6 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -274,10 +274,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;
 
@@ -299,7 +295,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 af62f6075602..e94b69871a32 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;
@@ -549,11 +542,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!");
-- 
2.25.0


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

* [PATCHv2 54/56] ARM: omap2plus_defconfig: Update for moved DSI command mode panel
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (52 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 53/56] drm/omap: simplify DSI manual update code Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 55/56] drm/panel/panel-dsi-cm: support rotation property Sebastian Reichel
                   ` (6 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
 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 b9698e217aa7..31ac2315f47c 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -350,7 +350,7 @@ 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_PANEL_DSI_CM=m
 CONFIG_DRM_TILCDC=m
 CONFIG_DRM_PANEL_SIMPLE=m
 CONFIG_DRM_DISPLAY_CONNECTOR=m
-- 
2.25.0


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

* [PATCHv2 55/56] drm/panel/panel-dsi-cm: support rotation property
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (53 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 54/56] ARM: omap2plus_defconfig: Update for moved DSI command mode panel Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-24 23:21 ` [PATCHv2 56/56] ARM: dts: omap4-droid4: add panel orientation Sebastian Reichel
                   ` (5 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Add support for the rotation property described by the
common panel bindings. The information is forwarded to
userspace using the orientation property.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/gpu/drm/panel/panel-dsi-cm.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
index fef9ba5319c2..b043ebb9c247 100644
--- a/drivers/gpu/drm/panel/panel-dsi-cm.c
+++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
@@ -58,6 +58,7 @@ struct panel_drv_data {
 
 	int width_mm;
 	int height_mm;
+	enum drm_panel_orientation panel_orientation;
 
 	/* runtime variables */
 	bool enabled;
@@ -458,6 +459,7 @@ static int dsicm_get_modes(struct drm_panel *panel,
 
 	connector->display_info.width_mm = ddata->width_mm;
 	connector->display_info.height_mm = ddata->height_mm;
+	connector->display_info.panel_orientation = ddata->panel_orientation;
 
 	drm_mode_probed_add(connector, mode);
 
@@ -479,7 +481,7 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
 	struct display_timing timing;
 	struct videomode vm;
-	int err;
+	int err, rotation;
 
 	vm.hactive = 864;
 	vm.vactive = 480;
@@ -509,6 +511,26 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
 	ddata->height_mm = 0;
 	of_property_read_u32(node, "height-mm", &ddata->height_mm);
 
+	rotation = -1;
+	of_property_read_u32(node, "rotation", &rotation);
+	switch (rotation) {
+		case 0:
+			ddata->panel_orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
+			break;
+		case 90:
+			ddata->panel_orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP;
+			break;
+		case 180:
+			ddata->panel_orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP;
+			break;
+		case 270:
+			ddata->panel_orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP;
+			break;
+		default:
+			ddata->panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
+			break;
+	}
+
 	ddata->supplies[0].supply = "vpnl";
 	ddata->supplies[1].supply = "vddi";
 	err = devm_regulator_bulk_get(&dsi->dev, DCS_REGULATOR_SUPPLY_NUM,
-- 
2.25.0


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

* [PATCHv2 56/56] ARM: dts: omap4-droid4: add panel orientation
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (54 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 55/56] drm/panel/panel-dsi-cm: support rotation property Sebastian Reichel
@ 2020-02-24 23:21 ` Sebastian Reichel
  2020-02-25  0:10 ` [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Tony Lindgren
                   ` (4 subsequent siblings)
  60 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:21 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Add information about panel orientation, so that the
system boots into a properly rotated shell.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 arch/arm/boot/dts/motorola-mapphone-common.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
index 622383ec6a75..ec77b20470d2 100644
--- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
+++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
@@ -208,6 +208,7 @@ lcd0: panel@0 {
 
 		width-mm = <50>;
 		height-mm = <89>;
+		rotation = <90>;
 
 		panel-timing {
 			clock-frequency = <0>;		/* Calculated by dsi */
-- 
2.25.0


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

* Re: [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible
  2020-02-24 23:20 ` [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible Sebastian Reichel
@ 2020-02-24 23:37   ` Laurent Pinchart
  2020-02-24 23:47     ` Tony Lindgren
  2020-02-24 23:57     ` Sebastian Reichel
  2020-02-27 20:10   ` Sam Ravnborg
  1 sibling, 2 replies; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-24 23:37 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:32AM +0100, Sebastian Reichel wrote:
> Add Droid 4 specific compatible value in addition to the
> generic one, so that we have the ability to add panel
> specific quirks in the future.

We need to document this compatible string in DT bindings, I don't think
this is included in this series. Furthermore, could we use a compatible
string that actually matches the panel vendor and model, instead of the
device name ?

> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  arch/arm/boot/dts/motorola-mapphone-common.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> index a5e4ba7c8dab..622383ec6a75 100644
> --- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> +++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> @@ -200,7 +200,7 @@ dsi1_out_ep: endpoint {
>  	};
>  
>  	lcd0: panel@0 {
> -		compatible = "panel-dsi-cm";
> +		compatible = "motorola,droid4-panel", "panel-dsi-cm";
>  		reg = <0>;
>  		label = "lcd0";
>  		vddi-supply = <&lcd_regulator>;

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels
  2020-02-24 23:20 ` [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels Sebastian Reichel
@ 2020-02-24 23:38   ` Laurent Pinchart
  2020-02-25  0:01     ` Sebastian Reichel
  2020-02-27 20:09   ` Sam Ravnborg
  1 sibling, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-24 23:38 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:31AM +0100, Sebastian Reichel wrote:
> The standard binding for DSI requires, that the channel number
> of the panel is encoded in DT. This adds the channel number in
> all OMAP3-5 boards, in preparation for using common infrastructure.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  .../devicetree/bindings/display/panel/panel-dsi-cm.txt      | 4 +++-
>  arch/arm/boot/dts/motorola-mapphone-common.dtsi             | 3 ++-
>  arch/arm/boot/dts/omap3-n950.dts                            | 3 ++-
>  arch/arm/boot/dts/omap3.dtsi                                | 3 +++
>  arch/arm/boot/dts/omap4-sdp.dts                             | 6 ++++--
>  arch/arm/boot/dts/omap4.dtsi                                | 6 ++++++
>  arch/arm/boot/dts/omap5.dtsi                                | 6 ++++++
>  7 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> index dce48eb9db57..f92d5c9adfc5 100644
> --- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> +++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> @@ -3,6 +3,7 @@ Generic MIPI DSI Command Mode Panel
>  
>  Required properties:
>  - compatible: "panel-dsi-cm"
> +- reg: DSI channel number
>  
>  Optional properties:
>  - label: a symbolic name for the panel
> @@ -15,9 +16,10 @@ Required nodes:
>  Example
>  -------
>  
> -lcd0: display {
> +lcd0: panel@0 {
>  	compatible = "tpo,taal", "panel-dsi-cm";
>  	label = "lcd0";
> +	reg = <0>;
>  
>  	reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
>  

While at it, how about converting this to yaml ?

> diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> index 85665506f4f8..a5e4ba7c8dab 100644
> --- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> +++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> @@ -199,8 +199,9 @@ dsi1_out_ep: endpoint {
>  		};
>  	};
>  
> -	lcd0: display {
> +	lcd0: panel@0 {
>  		compatible = "panel-dsi-cm";
> +		reg = <0>;
>  		label = "lcd0";
>  		vddi-supply = <&lcd_regulator>;
>  		reset-gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>;	/* gpio101 */
> diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
> index 31d47a1fad84..80cf4e1177da 100644
> --- a/arch/arm/boot/dts/omap3-n950.dts
> +++ b/arch/arm/boot/dts/omap3-n950.dts
> @@ -225,8 +225,9 @@ dsi_out_ep: endpoint {
>  		};
>  	};
>  
> -	lcd0: display {
> +	lcd0: panel@0 {
>  		compatible = "nokia,himalaya", "panel-dsi-cm";
> +		reg = <0>;
>  		label = "lcd0";
>  
>  		pinctrl-names = "default";
> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> index 634ea16a711e..409d434a9b18 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -820,6 +820,9 @@ dsi: encoder@4804fc00 {
>  				ti,hwmods = "dss_dsi1";
>  				clocks = <&dss1_alwon_fck>, <&dss2_alwon_fck>;
>  				clock-names = "fck", "sys_clk";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
>  			};
>  
>  			rfbi: encoder@48050800 {
> diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
> index 91480ac1f328..8a8307517dab 100644
> --- a/arch/arm/boot/dts/omap4-sdp.dts
> +++ b/arch/arm/boot/dts/omap4-sdp.dts
> @@ -662,8 +662,9 @@ dsi1_out_ep: endpoint {
>  		};
>  	};
>  
> -	lcd0: display {
> +	lcd0: panel@0 {
>  		compatible = "tpo,taal", "panel-dsi-cm";
> +		reg = <0>;
>  		label = "lcd0";
>  
>  		reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;	/* 102 */
> @@ -687,8 +688,9 @@ dsi2_out_ep: endpoint {
>  		};
>  	};
>  
> -	lcd1: display {
> +	lcd1: panel@0 {
>  		compatible = "tpo,taal", "panel-dsi-cm";
> +		reg = <0>;
>  		label = "lcd1";
>  
>  		reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>;	/* 104 */
> diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
> index 9a87440d0b9d..a75734065cac 100644
> --- a/arch/arm/boot/dts/omap4.dtsi
> +++ b/arch/arm/boot/dts/omap4.dtsi
> @@ -465,6 +465,9 @@ dsi1: encoder@58004000 {
>  				clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>,
>  					 <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>;
>  				clock-names = "fck", "sys_clk";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
>  			};
>  
>  			dsi2: encoder@58005000 {
> @@ -479,6 +482,9 @@ dsi2: encoder@58005000 {
>  				clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>,
>  					 <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>;
>  				clock-names = "fck", "sys_clk";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
>  			};
>  
>  			hdmi: encoder@58006000 {
> diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
> index d0ecf54d5a23..5c7462e04716 100644
> --- a/arch/arm/boot/dts/omap5.dtsi
> +++ b/arch/arm/boot/dts/omap5.dtsi
> @@ -333,6 +333,9 @@ dsi1: encoder@58004000 {
>  				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>;
>  			};
>  
>  			dsi2: encoder@58005000 {
> @@ -347,6 +350,9 @@ dsi2: encoder@58005000 {
>  				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>;
>  			};
>  
>  			hdmi: encoder@58060000 {

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins
  2020-02-24 23:20 ` [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins Sebastian Reichel
@ 2020-02-24 23:42   ` Laurent Pinchart
  2020-02-26 21:28     ` Sebastian Reichel
  2020-03-25 12:45   ` Tomi Valkeinen
  1 sibling, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-24 23:42 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:34AM +0100, Sebastian Reichel wrote:
> 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>
> ---
>  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 3484b5d4a91c..e7fe5d702337 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 79ddfbfd1b58..8c39823a8295 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 {

I think you can drop the definition of the omap_dsi_pin_config structure
earlier in this file too, as well as the OMAP_DSS_MAX_DSI_PINS macro.
With this fixed,

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

>  	/* 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);

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible
  2020-02-24 23:37   ` Laurent Pinchart
@ 2020-02-24 23:47     ` Tony Lindgren
  2020-02-27 22:10       ` Laurent Pinchart
  2020-02-24 23:57     ` Sebastian Reichel
  1 sibling, 1 reply; 113+ messages in thread
From: Tony Lindgren @ 2020-02-24 23:47 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Sebastian Reichel, Tomi Valkeinen,
	Merlijn Wajer, H. Nikolaus Schaller, Rob Herring, linux-omap,
	dri-devel, kernel

* Laurent Pinchart <laurent.pinchart@ideasonboard.com> [200224 23:38]:
> Hi Sebastian,
> 
> Thank you for the patch.
> 
> On Tue, Feb 25, 2020 at 12:20:32AM +0100, Sebastian Reichel wrote:
> > Add Droid 4 specific compatible value in addition to the
> > generic one, so that we have the ability to add panel
> > specific quirks in the future.
> 
> We need to document this compatible string in DT bindings, I don't think
> this is included in this series. Furthermore, could we use a compatible
> string that actually matches the panel vendor and model, instead of the
> device name ?

To me it seems there are multiple similar panels from various
vendors in use for xt875/xt894/xt910/xt912 phones, I'm not sure
if anybody has this list?

Regards,

Tony

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

* Re: [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible
  2020-02-24 23:37   ` Laurent Pinchart
  2020-02-24 23:47     ` Tony Lindgren
@ 2020-02-24 23:57     ` Sebastian Reichel
  1 sibling, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-24 23:57 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi Laurent,

On Tue, Feb 25, 2020 at 01:37:08AM +0200, Laurent Pinchart wrote:
> Hi Sebastian,
> 
> Thank you for the patch.

Thanks for the review.

> On Tue, Feb 25, 2020 at 12:20:32AM +0100, Sebastian Reichel wrote:
> > Add Droid 4 specific compatible value in addition to the
> > generic one, so that we have the ability to add panel
> > specific quirks in the future.
> 
> We need to document this compatible string in DT bindings, I don't think
> this is included in this series.

Correct, right now none of the extra compatible strings are
documented in the binding file. E.g. "tpo,taal" is used by
omap4-sdp and in the example section of the DT bindings.

> Furthermore, could we use a compatible string that actually
> matches the panel vendor and model, instead of the device name ?

We don't know the Droid 4 panel vendor and/or model. For
N950 "nokia,himalaya" is used, which is obviously also
not the real vendor. But for N950 there is a good reason
to use a N950 specific compatible anyways, since some
pixels are covered by plastic.

Maybe this can just be handled when the bindings file is
converted to YAML?

-- Sebastian

> 
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > ---
> >  arch/arm/boot/dts/motorola-mapphone-common.dtsi | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> > index a5e4ba7c8dab..622383ec6a75 100644
> > --- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> > +++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> > @@ -200,7 +200,7 @@ dsi1_out_ep: endpoint {
> >  	};
> >  
> >  	lcd0: panel@0 {
> > -		compatible = "panel-dsi-cm";
> > +		compatible = "motorola,droid4-panel", "panel-dsi-cm";
> >  		reg = <0>;
> >  		label = "lcd0";
> >  		vddi-supply = <&lcd_regulator>;
> 
> -- 
> Regards,
> 
> Laurent Pinchart

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

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

* Re: [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels
  2020-02-24 23:38   ` Laurent Pinchart
@ 2020-02-25  0:01     ` Sebastian Reichel
  0 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-25  0:01 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi Laurent,

On Tue, Feb 25, 2020 at 01:38:21AM +0200, Laurent Pinchart wrote:
> Hi Sebastian,
> 
> Thank you for the patch.
> 
> On Tue, Feb 25, 2020 at 12:20:31AM +0100, Sebastian Reichel wrote:
> > The standard binding for DSI requires, that the channel number
> > of the panel is encoded in DT. This adds the channel number in
> > all OMAP3-5 boards, in preparation for using common infrastructure.
> > 
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > ---
> >  .../devicetree/bindings/display/panel/panel-dsi-cm.txt      | 4 +++-
> >  arch/arm/boot/dts/motorola-mapphone-common.dtsi             | 3 ++-
> >  arch/arm/boot/dts/omap3-n950.dts                            | 3 ++-
> >  arch/arm/boot/dts/omap3.dtsi                                | 3 +++
> >  arch/arm/boot/dts/omap4-sdp.dts                             | 6 ++++--
> >  arch/arm/boot/dts/omap4.dtsi                                | 6 ++++++
> >  arch/arm/boot/dts/omap5.dtsi                                | 6 ++++++
> >  7 files changed, 26 insertions(+), 5 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> > index dce48eb9db57..f92d5c9adfc5 100644
> > --- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> > +++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> > @@ -3,6 +3,7 @@ Generic MIPI DSI Command Mode Panel
> >  
> >  Required properties:
> >  - compatible: "panel-dsi-cm"
> > +- reg: DSI channel number
> >  
> >  Optional properties:
> >  - label: a symbolic name for the panel
> > @@ -15,9 +16,10 @@ Required nodes:
> >  Example
> >  -------
> >  
> > -lcd0: display {
> > +lcd0: panel@0 {
> >  	compatible = "tpo,taal", "panel-dsi-cm";
> >  	label = "lcd0";
> > +	reg = <0>;
> >  
> >  	reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
> >  
> 
> While at it, how about converting this to yaml ?

Ack. I was waiting for the dsi-controller YAML bindings to land,
which has happened in the meantime. I think it's better to do
this in a separate patch though, so that this one can easily be
backported.

-- Sebastian

> > diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> > index 85665506f4f8..a5e4ba7c8dab 100644
> > --- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> > +++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> > @@ -199,8 +199,9 @@ dsi1_out_ep: endpoint {
> >  		};
> >  	};
> >  
> > -	lcd0: display {
> > +	lcd0: panel@0 {
> >  		compatible = "panel-dsi-cm";
> > +		reg = <0>;
> >  		label = "lcd0";
> >  		vddi-supply = <&lcd_regulator>;
> >  		reset-gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>;	/* gpio101 */
> > diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
> > index 31d47a1fad84..80cf4e1177da 100644
> > --- a/arch/arm/boot/dts/omap3-n950.dts
> > +++ b/arch/arm/boot/dts/omap3-n950.dts
> > @@ -225,8 +225,9 @@ dsi_out_ep: endpoint {
> >  		};
> >  	};
> >  
> > -	lcd0: display {
> > +	lcd0: panel@0 {
> >  		compatible = "nokia,himalaya", "panel-dsi-cm";
> > +		reg = <0>;
> >  		label = "lcd0";
> >  
> >  		pinctrl-names = "default";
> > diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> > index 634ea16a711e..409d434a9b18 100644
> > --- a/arch/arm/boot/dts/omap3.dtsi
> > +++ b/arch/arm/boot/dts/omap3.dtsi
> > @@ -820,6 +820,9 @@ dsi: encoder@4804fc00 {
> >  				ti,hwmods = "dss_dsi1";
> >  				clocks = <&dss1_alwon_fck>, <&dss2_alwon_fck>;
> >  				clock-names = "fck", "sys_clk";
> > +
> > +				#address-cells = <1>;
> > +				#size-cells = <0>;
> >  			};
> >  
> >  			rfbi: encoder@48050800 {
> > diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
> > index 91480ac1f328..8a8307517dab 100644
> > --- a/arch/arm/boot/dts/omap4-sdp.dts
> > +++ b/arch/arm/boot/dts/omap4-sdp.dts
> > @@ -662,8 +662,9 @@ dsi1_out_ep: endpoint {
> >  		};
> >  	};
> >  
> > -	lcd0: display {
> > +	lcd0: panel@0 {
> >  		compatible = "tpo,taal", "panel-dsi-cm";
> > +		reg = <0>;
> >  		label = "lcd0";
> >  
> >  		reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;	/* 102 */
> > @@ -687,8 +688,9 @@ dsi2_out_ep: endpoint {
> >  		};
> >  	};
> >  
> > -	lcd1: display {
> > +	lcd1: panel@0 {
> >  		compatible = "tpo,taal", "panel-dsi-cm";
> > +		reg = <0>;
> >  		label = "lcd1";
> >  
> >  		reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>;	/* 104 */
> > diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
> > index 9a87440d0b9d..a75734065cac 100644
> > --- a/arch/arm/boot/dts/omap4.dtsi
> > +++ b/arch/arm/boot/dts/omap4.dtsi
> > @@ -465,6 +465,9 @@ dsi1: encoder@58004000 {
> >  				clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>,
> >  					 <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>;
> >  				clock-names = "fck", "sys_clk";
> > +
> > +				#address-cells = <1>;
> > +				#size-cells = <0>;
> >  			};
> >  
> >  			dsi2: encoder@58005000 {
> > @@ -479,6 +482,9 @@ dsi2: encoder@58005000 {
> >  				clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>,
> >  					 <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>;
> >  				clock-names = "fck", "sys_clk";
> > +
> > +				#address-cells = <1>;
> > +				#size-cells = <0>;
> >  			};
> >  
> >  			hdmi: encoder@58006000 {
> > diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
> > index d0ecf54d5a23..5c7462e04716 100644
> > --- a/arch/arm/boot/dts/omap5.dtsi
> > +++ b/arch/arm/boot/dts/omap5.dtsi
> > @@ -333,6 +333,9 @@ dsi1: encoder@58004000 {
> >  				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>;
> >  			};
> >  
> >  			dsi2: encoder@58005000 {
> > @@ -347,6 +350,9 @@ dsi2: encoder@58005000 {
> >  				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>;
> >  			};
> >  
> >  			hdmi: encoder@58060000 {
> 
> -- 
> Regards,
> 
> Laurent Pinchart

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (55 preceding siblings ...)
  2020-02-24 23:21 ` [PATCHv2 56/56] ARM: dts: omap4-droid4: add panel orientation Sebastian Reichel
@ 2020-02-25  0:10 ` Tony Lindgren
  2020-02-25  2:28   ` Sebastian Reichel
  2020-02-25 11:53 ` [PATCHv2 57/56] dt-bindings: display: panel-dsi-cm: convert to YAML Sebastian Reichel
                   ` (3 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Tony Lindgren @ 2020-02-25  0:10 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen,
	Merlijn Wajer, H. Nikolaus Schaller, Rob Herring, linux-omap,
	dri-devel, kernel

* Sebastian Reichel <sebastian.reichel@collabora.com> [200224 23:22]:
> This updates the existing omapdrm DSI code, so that it uses
> common drm_mipi_dsi API and drm_panel.
> 
> The patchset has been tested with Droid 4 using Linux console, X.org and
> Weston. The patchset is based on Laurent Pinchartl's patch series [0]
> and removes the last custom panel driver, so quite a few cleanups on the
> omapdrm codebase were possible.
> 
> [0] [PATCH v7 00/54] drm/omap: Replace custom display drivers with drm_bridge and drm_panel
>     https://lore.kernel.org/dri-devel/20200222150106.22919-1-laurent.pinchart@ideasonboard.com/
>     git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel
> 
> I pushed this patchset into the following branch:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-n900.git omapdrm/bridge/devel-with-dsi

I gave your omapdrm/bridge/devel-with-dsi branch a quirk test
on droid4, but get the following oops with mostly modular
omap2_defconfig.

BTW, I think there's also some refcount issue in general where
the omapdrm related modules cannot be unloaded any longer?

Regards,

Tony

8< -------------------------
Internal error: Oops: 805 [#1] PREEMPT SMP ARM
Modules linked in: omapdss(+) omapdss_base drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm drm_panel_ors
CPU: 0 PID: 811 Comm: modprobe Not tainted 5.6.0-rc2-00376-g163017c12d62a #1926
Hardware name: Generic OMAP4 (Flattened Device Tree)
PC is at drm_bridge_remove+0x24/0x40 [drm]
LR is at drm_bridge_remove+0x14/0x40 [drm]
pc : [<bf2a0cb4>]    lr : [<bf2a0ca4>]    psr: 60000013
sp : edc6fc88  ip : eda3a100  fp : bf38a5b4
r10: bf38c7d0  r9 : edc164b8  r8 : edc1606c
r7 : edc1647c  r6 : edc93010  r5 : bf2dc428  r4 : edc164b8
r3 : edc164fc  r2 : 00000000  r1 : 00000000  r0 : bf2dc428
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c5387d  Table: adc7404a  DAC: 00000051
Process modprobe (pid: 811, stack limit = 0x(ptrval))
Stack: (0xedc6fc88 to 0xedc70000)
fc80:                   edc16040 fffffdfb edc93010 bf37dfd0 00000080 edc2eb00
fca0: edc16040 edc93010 edc93010 00000000 bf392178 00000000 00000000 bf392178
fcc0: 0000001e c0624424 edc93010 c0efafa0 c0efafa4 00000000 00000000 c06222e4
fce0: edc93010 bf392178 bf392178 c0622880 c06243a0 c06243dc c0e93210 c06225cc
fd00: bf38c450 a0000013 bf38a5b4 edc93010 00000000 bf392178 c0622880 c06243a0
fd20: c06243dc c0622878 00000000 bf392178 edc93010 c06228d8 edc94fb4 edc6e000
fd40: bf392178 c062069c edc50eb8 ee8dae58 edc94fb4 d759a07d ee8dae6c bf392178
fd60: edc50e80 c0e93210 00000000 c0621618 bf38f0c0 bf3922c0 00000006 bf392178
fd80: bf3922c0 00000006 c0623db0 c062344c 00000002 bf3922c0 00000006 c06244fc
fda0: bf38a5b0 bf38a5a8 000be666 c0ec0540 bf39a000 00000000 bf392308 00000002
fdc0: edc2c300 c01dc694 edc6ff30 c0102fec c0ebbcf4 00000000 00000cc0 c0d75a70
fde0: edc2c2c0 c02b4538 c0d75a70 a0000013 a0000013 00000008 c01de5bc 00000002
fe00: 00000001 c01dc694 edc6ff30 d759a07d edbe7400 bf3922c0 00000002 d759a07d
fe20: bf392308 bf3922c0 edbe7400 edc2c2c0 bf392308 c01de5f8 00000002 edc2c2c0
fe40: bf3922c0 00000002 edc2c2c0 c01e0b1c bf3922cc 00007fff bf3922c0 c01dd34c
fe60: bf3a44ee 004c1a8f bf3922c0 bf3923d4 bf3924b8 c0a05fa8 00000000 bf38d075
fe80: 00000001 00000000 c0bddd78 c0bc76d8 bf38a03c 00000002 00000000 00000000
fea0: 00000000 00000000 6e72656b 00006c65 00000000 00000000 00000000 00000000
fec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
fee0: 00000000 d759a07d 7fffffff edc6e000 00000000 00000003 004c1a8f 7fffffff
ff00: 00000000 0000017b 004d56a0 c01e1050 7fffffff 00000000 00000003 c093c724
ff20: 00000002 f1370000 000e3464 00000000 f138b0c6 f138f3c0 f1370000 000e3464
ff40: f1452a3c f14527a4 f1425e58 00022000 00025680 0000a084 00027a0b 00000000
ff60: 00000000 00000000 0000a074 0000003e 0000003f 00000021 00000025 00000018
ff80: 00000000 d759a07d 004dcb80 64a54c46 b6f6a510 0000017b 0000017b c0101204
ffa0: edc6e000 c0101000 64a54c46 b6f6a510 00000003 004c1a8f 00000000 004dcb80
ffc0: 64a54c46 b6f6a510 0000017b 0000017b 004dcb80 00000001 00000000 004d56a0
ffe0: 004dcb80 bea7ba90 0043d1a9 b6f1d0b8 60000030 00000003 00000000 00000000
[<bf2a0cb4>] (drm_bridge_remove [drm]) from [<bf37dfd0>] (dsi_probe+0x3ac/0x55c [omapdss])
[<bf37dfd0>] (dsi_probe [omapdss]) from [<c0624424>] (platform_drv_probe+0x48/0x98)
[<c0624424>] (platform_drv_probe) from [<c06222e4>] (really_probe+0x1dc/0x340)
[<c06222e4>] (really_probe) from [<c06225cc>] (driver_probe_device+0x5c/0x160)
[<c06225cc>] (driver_probe_device) from [<c0622878>] (device_driver_attach+0x58/0x60)
[<c0622878>] (device_driver_attach) from [<c06228d8>] (__driver_attach+0x58/0xcc)
[<c06228d8>] (__driver_attach) from [<c062069c>] (bus_for_each_dev+0x78/0xb8)
[<c062069c>] (bus_for_each_dev) from [<c0621618>] (bus_add_driver+0xf0/0x1d4)
[<c0621618>] (bus_add_driver) from [<c062344c>] (driver_register+0x74/0x108)
[<c062344c>] (driver_register) from [<c06244fc>] (__platform_register_drivers+0x54/0xd0)
[<c06244fc>] (__platform_register_drivers) from [<c0102fec>] (do_one_initcall+0x44/0x2a8)
[<c0102fec>] (do_one_initcall) from [<c01de5f8>] (do_init_module+0x5c/0x234)
[<c01de5f8>] (do_init_module) from [<c01e0b1c>] (load_module+0x22c4/0x2580)
[<c01e0b1c>] (load_module) from [<c01e1050>] (sys_finit_module+0xc4/0xe0)
[<c01e1050>] (sys_finit_module) from [<c0101000>] (ret_fast_syscall+0x0/0x54)
Exception stack(0xedc6ffa8 to 0xedc6fff0)
ffa0:                   64a54c46 b6f6a510 00000003 004c1a8f 00000000 004dcb80
ffc0: 64a54c46 b6f6a510 0000017b 0000017b 004dcb80 00000001 00000000 004d56a0
ffe0: 004dcb80 bea7ba90 0043d1a9 b6f1d0b8
Code: e5942048 e5941044 e2843044 e1a00005 (e5812004)
---[ end trace 6213ab3cbabf9f59 ]---

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-25  0:10 ` [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Tony Lindgren
@ 2020-02-25  2:28   ` Sebastian Reichel
  2020-02-25 15:42     ` Tony Lindgren
  0 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-25  2:28 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Laurent Pinchart, Tomi Valkeinen, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi,

On Mon, Feb 24, 2020 at 04:10:11PM -0800, Tony Lindgren wrote:
> * Sebastian Reichel <sebastian.reichel@collabora.com> [200224 23:22]:
> > This updates the existing omapdrm DSI code, so that it uses
> > common drm_mipi_dsi API and drm_panel.
> > 
> > The patchset has been tested with Droid 4 using Linux console, X.org and
> > Weston. The patchset is based on Laurent Pinchartl's patch series [0]
> > and removes the last custom panel driver, so quite a few cleanups on the
> > omapdrm codebase were possible.
> > 
> > [0] [PATCH v7 00/54] drm/omap: Replace custom display drivers with drm_bridge and drm_panel
> >     https://lore.kernel.org/dri-devel/20200222150106.22919-1-laurent.pinchart@ideasonboard.com/
> >     git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel
> > 
> > I pushed this patchset into the following branch:
> > 
> > git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-n900.git omapdrm/bridge/devel-with-dsi
> 
> I gave your omapdrm/bridge/devel-with-dsi branch a quirk test
> on droid4, but get the following oops with mostly modular
> omap2_defconfig.

:( I was testing with a non-modular kernel, since that gives me a
much easier testing workflow. Guess I need to spend some time to get
a good setup for testing modular kernel with Droid4.

> BTW, I think there's also some refcount issue in general where
> the omapdrm related modules cannot be unloaded any longer?

I wouldn't be too surprised. The dependencies are quite interesting
at the moment with omapdss registering omapdrm and then omapdrm
registers the drm_device, which references the encoders from
omapdss. I think this is something to look at once Laurent's and
my branch have been merged to avoid increasing the complexity.
Technically it should be possible to link everything into one
module.

> 8< -------------------------
> Internal error: Oops: 805 [#1] PREEMPT SMP ARM
> Modules linked in: omapdss(+) omapdss_base drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm drm_panel_ors
> CPU: 0 PID: 811 Comm: modprobe Not tainted 5.6.0-rc2-00376-g163017c12d62a #1926
> Hardware name: Generic OMAP4 (Flattened Device Tree)
> PC is at drm_bridge_remove+0x24/0x40 [drm]
> LR is at drm_bridge_remove+0x14/0x40 [drm]
> pc : [<bf2a0cb4>]    lr : [<bf2a0ca4>]    psr: 60000013
> sp : edc6fc88  ip : eda3a100  fp : bf38a5b4
> r10: bf38c7d0  r9 : edc164b8  r8 : edc1606c
> r7 : edc1647c  r6 : edc93010  r5 : bf2dc428  r4 : edc164b8
> r3 : edc164fc  r2 : 00000000  r1 : 00000000  r0 : bf2dc428
> Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> Control: 10c5387d  Table: adc7404a  DAC: 00000051
> Process modprobe (pid: 811, stack limit = 0x(ptrval))
> Stack: (0xedc6fc88 to 0xedc70000)
> fc80:                   edc16040 fffffdfb edc93010 bf37dfd0 00000080 edc2eb00
> fca0: edc16040 edc93010 edc93010 00000000 bf392178 00000000 00000000 bf392178
> fcc0: 0000001e c0624424 edc93010 c0efafa0 c0efafa4 00000000 00000000 c06222e4
> fce0: edc93010 bf392178 bf392178 c0622880 c06243a0 c06243dc c0e93210 c06225cc
> fd00: bf38c450 a0000013 bf38a5b4 edc93010 00000000 bf392178 c0622880 c06243a0
> fd20: c06243dc c0622878 00000000 bf392178 edc93010 c06228d8 edc94fb4 edc6e000
> fd40: bf392178 c062069c edc50eb8 ee8dae58 edc94fb4 d759a07d ee8dae6c bf392178
> fd60: edc50e80 c0e93210 00000000 c0621618 bf38f0c0 bf3922c0 00000006 bf392178
> fd80: bf3922c0 00000006 c0623db0 c062344c 00000002 bf3922c0 00000006 c06244fc
> fda0: bf38a5b0 bf38a5a8 000be666 c0ec0540 bf39a000 00000000 bf392308 00000002
> fdc0: edc2c300 c01dc694 edc6ff30 c0102fec c0ebbcf4 00000000 00000cc0 c0d75a70
> fde0: edc2c2c0 c02b4538 c0d75a70 a0000013 a0000013 00000008 c01de5bc 00000002
> fe00: 00000001 c01dc694 edc6ff30 d759a07d edbe7400 bf3922c0 00000002 d759a07d
> fe20: bf392308 bf3922c0 edbe7400 edc2c2c0 bf392308 c01de5f8 00000002 edc2c2c0
> fe40: bf3922c0 00000002 edc2c2c0 c01e0b1c bf3922cc 00007fff bf3922c0 c01dd34c
> fe60: bf3a44ee 004c1a8f bf3922c0 bf3923d4 bf3924b8 c0a05fa8 00000000 bf38d075
> fe80: 00000001 00000000 c0bddd78 c0bc76d8 bf38a03c 00000002 00000000 00000000
> fea0: 00000000 00000000 6e72656b 00006c65 00000000 00000000 00000000 00000000
> fec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> fee0: 00000000 d759a07d 7fffffff edc6e000 00000000 00000003 004c1a8f 7fffffff
> ff00: 00000000 0000017b 004d56a0 c01e1050 7fffffff 00000000 00000003 c093c724
> ff20: 00000002 f1370000 000e3464 00000000 f138b0c6 f138f3c0 f1370000 000e3464
> ff40: f1452a3c f14527a4 f1425e58 00022000 00025680 0000a084 00027a0b 00000000
> ff60: 00000000 00000000 0000a074 0000003e 0000003f 00000021 00000025 00000018
> ff80: 00000000 d759a07d 004dcb80 64a54c46 b6f6a510 0000017b 0000017b c0101204
> ffa0: edc6e000 c0101000 64a54c46 b6f6a510 00000003 004c1a8f 00000000 004dcb80
> ffc0: 64a54c46 b6f6a510 0000017b 0000017b 004dcb80 00000001 00000000 004d56a0
> ffe0: 004dcb80 bea7ba90 0043d1a9 b6f1d0b8 60000030 00000003 00000000 00000000
> [<bf2a0cb4>] (drm_bridge_remove [drm]) from [<bf37dfd0>] (dsi_probe+0x3ac/0x55c [omapdss])
> [<bf37dfd0>] (dsi_probe [omapdss]) from [<c0624424>] (platform_drv_probe+0x48/0x98)
> [<c0624424>] (platform_drv_probe) from [<c06222e4>] (really_probe+0x1dc/0x340)
> [<c06222e4>] (really_probe) from [<c06225cc>] (driver_probe_device+0x5c/0x160)
> [<c06225cc>] (driver_probe_device) from [<c0622878>] (device_driver_attach+0x58/0x60)
> [<c0622878>] (device_driver_attach) from [<c06228d8>] (__driver_attach+0x58/0xcc)
> [<c06228d8>] (__driver_attach) from [<c062069c>] (bus_for_each_dev+0x78/0xb8)
> [<c062069c>] (bus_for_each_dev) from [<c0621618>] (bus_add_driver+0xf0/0x1d4)
> [<c0621618>] (bus_add_driver) from [<c062344c>] (driver_register+0x74/0x108)
> [<c062344c>] (driver_register) from [<c06244fc>] (__platform_register_drivers+0x54/0xd0)
> [<c06244fc>] (__platform_register_drivers) from [<c0102fec>] (do_one_initcall+0x44/0x2a8)
> [<c0102fec>] (do_one_initcall) from [<c01de5f8>] (do_init_module+0x5c/0x234)
> [<c01de5f8>] (do_init_module) from [<c01e0b1c>] (load_module+0x22c4/0x2580)
> [<c01e0b1c>] (load_module) from [<c01e1050>] (sys_finit_module+0xc4/0xe0)
> [<c01e1050>] (sys_finit_module) from [<c0101000>] (ret_fast_syscall+0x0/0x54)
> Exception stack(0xedc6ffa8 to 0xedc6fff0)
> ffa0:                   64a54c46 b6f6a510 00000003 004c1a8f 00000000 004dcb80
> ffc0: 64a54c46 b6f6a510 0000017b 0000017b 004dcb80 00000001 00000000 004d56a0
> ffe0: 004dcb80 bea7ba90 0043d1a9 b6f1d0b8
> Code: e5942048 e5941044 e2843044 e1a00005 (e5812004)
> ---[ end trace 6213ab3cbabf9f59 ]---

oops, looks like dsi_bridge_init() is missing "drm_bridge_add(&dsi->bridge);"
before returning. Now I wonder why it is working for me without the
bridge being added :) I will send out an updated patch for this tomorrow.

-- Sebastian

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

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

* [PATCHv2.1 45/56] drm/omap: dsi: Register a drm_bridge
  2020-02-24 23:21 ` [PATCHv2 45/56] drm/omap: dsi: Register a drm_bridge Sebastian Reichel
@ 2020-02-25 11:50   ` Sebastian Reichel
  0 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-25 11:50 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

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>
---
PATCHv2 -> PATCHv2.1: Add missing drm_bridge_add() call
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 130 +++++++++++++++++++-----------
 1 file changed, 85 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index f629e6b1025b..cde10c774b8b 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 <video/mipi_display.h>
+#include <drm/drm_bridge.h>
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_panel.h>
 
@@ -440,6 +441,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 {
@@ -452,6 +454,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);
@@ -5010,50 +5015,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,
@@ -5394,6 +5356,79 @@ 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_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
  */
@@ -5403,6 +5438,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;
@@ -5417,9 +5454,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);
 
@@ -5432,6 +5471,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)
-- 
2.25.0


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

* [PATCHv2 57/56] dt-bindings: display: panel-dsi-cm: convert to YAML
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (56 preceding siblings ...)
  2020-02-25  0:10 ` [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Tony Lindgren
@ 2020-02-25 11:53 ` Sebastian Reichel
  2020-02-27 20:35   ` Sam Ravnborg
  2020-02-26 12:28 ` [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
                   ` (2 subsequent siblings)
  60 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-25 11:53 UTC (permalink / raw)
  To: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel, Sebastian Reichel

Convert panel-dsi-cm bindings to YAML and add
missing properties while at it.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../bindings/display/panel/panel-dsi-cm.txt   | 31 ------
 .../bindings/display/panel/panel-dsi-cm.yaml  | 97 +++++++++++++++++++
 2 files changed, 97 insertions(+), 31 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
 create mode 100644 Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml

diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
deleted file mode 100644
index f92d5c9adfc5..000000000000
--- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-Generic MIPI DSI Command Mode Panel
-===================================
-
-Required properties:
-- compatible: "panel-dsi-cm"
-- reg: DSI channel number
-
-Optional properties:
-- label: a symbolic name for the panel
-- reset-gpios: panel reset gpio
-- te-gpios: panel TE gpio
-
-Required nodes:
-- Video port for DSI input
-
-Example
--------
-
-lcd0: panel@0 {
-	compatible = "tpo,taal", "panel-dsi-cm";
-	label = "lcd0";
-	reg = <0>;
-
-	reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
-
-	port {
-		lcd0_in: endpoint {
-			remote-endpoint = <&dsi1_out_ep>;
-		};
-	};
-};
diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml
new file mode 100644
index 000000000000..ca61171ae145
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/panel-dsi-cm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DSI command mode panels
+
+maintainers:
+  - Tomi Valkeinen <tomi.valkeinen@ti.com>
+  - Sebastian Reichel <sre@kernel.org>
+
+description: |
+  This binding file is a collection of the DSI panels that
+  are usually driven in command mode. If no backlight is
+  referenced via the optional backlight property, the DSI
+  panel is assumed to have native backlight support.
+  The panel may use an OF graph binding for the association
+  to the display, or it may be a direct child node of the
+  display.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+
+  compatible:
+    enum:
+      # compatible must be listed in alphabetical order, ordered by compatible.
+      # The description in the comment is mandatory for each compatible.
+      - motorola,droid4-panel, panel-dsi-cm
+      - nokia,himalaya, panel-dsi-cm
+      - tpo,taal, panel-dsi-cm
+
+  reg:
+    maxItems: 1
+    description: DSI virtual channel
+
+  te-gpios:
+    maxItems: 1
+    description:
+      Specifier for a GPIO connected to the panel TE (tearing event) signal.
+      The GPIO informs the system, that data should be sent to the display
+      on rising edges of the GPIO to avoid (or reduce) tearing effects.
+      Falling edge can be supported by inverting the GPIO specifier polarity
+      flag.
+
+  vddi-supply:
+    description:
+      Display panels require power to be supplied. While several panels need
+      more than one power supply with panel-specific constraints governing the
+      order and timings of the power supplies, in many cases a single power
+      supply is sufficient, either because the panel has a single power rail, or
+      because all its power rails can be driven by the same supply. In that case
+      the vddi-supply property specifies the supply powering the panel as a
+      phandle to a regulator.
+
+  vpnl-supply:
+    description:
+      When the display panel needs a second power supply, this property can be
+      used in addition to vddi-supply. Both supplies will be enabled at the
+      same time before the panel is being accessed.
+
+  width-mm: true
+  height-mm: true
+  label: true
+  rotation: true
+  panel-timing: true
+  port: true
+  reset-gpios: true
+  backlight: true
+
+additionalProperties: false
+
+required:
+  - compatible
+  - port
+  - reg
+
+examples:
+  - |
+    dsi1@12345678 {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      panel@0 {
+        compatible = "tpo,taal", "panel-dsi-cm";
+        label = "lcd0";
+        reg = <0>;
+        reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
+
+        port {
+          panel: endpoint {
+            remote-endpoint = <&dsi1_out_ep>;
+          };
+        };
+      };
+    };
-- 
2.25.0


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

* Re: [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*
  2020-02-24 23:20 ` [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Sebastian Reichel
@ 2020-02-25 13:58   ` Laurent Pinchart
  2020-02-26 21:25     ` Sebastian Reichel
  2020-03-25 12:52   ` Tomi Valkeinen
  1 sibling, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 13:58 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:35AM +0100, Sebastian Reichel wrote:
> This replaces OMAP specific enum for pixel format with
> common implementation.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 +-
>  drivers/gpu/drm/omapdrm/dss/dsi.c             | 49 +++++++------------
>  drivers/gpu/drm/omapdrm/dss/omapdss.h         | 10 +---
>  3 files changed, 20 insertions(+), 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 e7fe5d702337..e6ebfc35243e 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 8c39823a8295..bb2548d091ef 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -34,6 +34,7 @@
>  #include <linux/sys_soc.h>
>  
>  #include <video/mipi_display.h>
> +#include <drm/drm_mipi_dsi.h>

Maybe sort those two headers alphabetically ?

>  
>  #include "omapdss.h"
>  #include "dss.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();

Removing a BUG() is really nice :-) I suppose this never happened, or we
would have heard of it. Still, is there a top-level location where we
could validate the format (assuming it is still used at the end of this
series) ? mipi_dsi_pixel_format_to_bpp() returns -EINVAL if the format
is invalid, and we don't check for that through the code . It doesn't
have to be handled in this patch, it can be done later in the series as
you keep reworking the code.

> -		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);
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index b0424daaceed..53fea1cbbc2d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -14,6 +14,7 @@
>  #include <linux/platform_data/omapdss.h>
>  #include <uapi/drm/drm_mode.h>

While at it, I would replace this with

#include <drm/drm_mode.h>

, add a blank line here, and keep the drm headers sorted alphabetically.

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

>  #include <drm/drm_crtc.h>
> +#include <drm/drm_mipi_dsi.h>
>  
>  #define DISPC_IRQ_FRAMEDONE		(1 << 0)
>  #define DISPC_IRQ_VSYNC			(1 << 1)
> @@ -116,13 +117,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 +204,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;

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 06/56] drm/omap: constify write buffers
  2020-02-24 23:20 ` [PATCHv2 06/56] drm/omap: constify write buffers Sebastian Reichel
@ 2020-02-25 14:13   ` Laurent Pinchart
  2020-03-25 12:53   ` Tomi Valkeinen
  1 sibling, 0 replies; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 14:13 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:36AM +0100, Sebastian Reichel wrote:
> The write buffers are not modified, so they can be constant.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Assuming this compiles :-),

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 bb2548d091ef..f01e0476296d 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 53fea1cbbc2d..b909b3a8c835 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -308,18 +308,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);

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 07/56] drm/omap: dsi: add generic transfer function
  2020-02-24 23:20 ` [PATCHv2 07/56] drm/omap: dsi: add generic transfer function Sebastian Reichel
@ 2020-02-25 14:16   ` Laurent Pinchart
  2020-03-25 13:05   ` Tomi Valkeinen
  1 sibling, 0 replies; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 14:16 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:37AM +0100, Sebastian Reichel wrote:
> 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>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c     | 52 +++++++++++++++++++++++++++
>  drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ++
>  2 files changed, 55 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index f01e0476296d..84e2eb0b51d7 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -4836,6 +4836,56 @@ 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)
> +{
> +	/*
> +	 * no_sync can be used to optimize performance by sending
> +	 * e.g. column and page information without syncing in
> +	 * between. It's not absolutley required, so postpone this
> +	 * feature for now.

The 80 columns limit is quite small as it is, no need to make it even
tighter :-)

> +	 */
> +	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);

This uses spaces for indentation (and the result isn't aligned to ().

> +		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);

Misaligned indentation here too.

> +		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);

And here.

> +	case MIPI_DSI_DCS_READ:
> +		return dsi_vc_dcs_read(dssdev, msg->channel,
> +				((u8*) msg->tx_buf)[0],
> +				msg->rx_buf, msg->rx_len);

And I think you get the message :-)

> +	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)
>  {
> @@ -4890,6 +4940,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 b909b3a8c835..ea7bf0970677 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -307,6 +307,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);

Ditto. With those small issues fixed,

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

> +
>  	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,

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 08/56] drm/omap: panel-dsi-cm: convert to transfer API
  2020-02-24 23:20 ` [PATCHv2 08/56] drm/omap: panel-dsi-cm: convert to transfer API Sebastian Reichel
@ 2020-02-25 14:52   ` Laurent Pinchart
  2020-02-26 22:12     ` Sebastian Reichel
  0 siblings, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 14:52 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:38AM +0100, Sebastian Reichel wrote:
> 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>
> ---
>  .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 133 +++++++++++++-----
>  1 file changed, 96 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 e6ebfc35243e..92f510a771fe 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);

Should you call dsicm_dcs_write_0(ddata, MIPI_DCS_ENTER_SLEEP_MODE)
instead ? This uses the _nosync variant though, is it an issue ?

>  	if (r)
>  		return r;
>  
> @@ -233,28 +249,44 @@ 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,
> +	};
>  
> -	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 u8 paramY[] = {
> +		MIPI_DCS_SET_PAGE_ADDRESS,
> +		(y1 >> 8) & 0xff,
> +		(y1 >> 0) & 0xff,
> +		(y2 >> 8) & 0xff,
> +		(y2 >> 0) & 0xff,
> +	};
>  
> -	r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf));

Also replacing a _nosync variant here.

> +	const struct mipi_dsi_msg msgY = {
> +		.channel = ddata->channel,
> +		.type = MIPI_DSI_GENERIC_LONG_WRITE,
> +		.tx_buf = paramY,
> +		.tx_len = 5,
> +	};
> +
> +

A single blank line is enough.

> +	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);

And here, you're replacing bta_sync. If I understand the code correctly,
you're essentially removing an optimization, as each write will sync,
right ? I'm fine with this change if we add the functionality back later
in this series.

> +	if (r)
> +		return r;
>  
>  	return r;
>  }
> @@ -991,6 +1023,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)

Please use tabs instead of spaces for indentation.

> +{
> +	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 +1084,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 +1124,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:

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 09/56] drm/omap: dsi: unexport specific data transfer functions
  2020-02-24 23:20 ` [PATCHv2 09/56] drm/omap: dsi: unexport specific data transfer functions Sebastian Reichel
@ 2020-02-25 14:53   ` Laurent Pinchart
  0 siblings, 0 replies; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 14:53 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:39AM +0100, Sebastian Reichel wrote:
> After converting all DSI drivers, unexport the specific transfer
> functions.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 84e2eb0b51d7..0990777a42f7 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -4941,18 +4941,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 ea7bf0970677..787e102eb068 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -309,26 +309,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 {

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic
  2020-02-24 23:20 ` [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic Sebastian Reichel
@ 2020-02-25 15:01   ` Laurent Pinchart
  2020-04-01 11:30     ` Tomi Valkeinen
  0 siblings, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 15:01 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:40AM +0100, Sebastian Reichel wrote:
> 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.

I wonder why this level of indirection was used, allocating "virtual
VCs". A single virtual indirection should be enough :-) I may be missing
some context though, I'll defer that to Tomi, but for me,

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

> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.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 92f510a771fe..ba046a596044 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
> @@ -769,19 +769,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;
>  }
> @@ -1216,6 +1209,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 0990777a42f7..8c223b808740 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);
>  
> @@ -4783,45 +4782,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;
>  }
>  
> @@ -4832,7 +4805,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;
>  	}
>  }
>  
> @@ -4937,7 +4909,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,
> @@ -5393,7 +5364,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 787e102eb068..587206c984a9 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -301,9 +301,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 */

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 11/56] drm/omap: dsi: simplify write function
  2020-02-24 23:20 ` [PATCHv2 11/56] drm/omap: dsi: simplify write function Sebastian Reichel
@ 2020-02-25 15:31   ` Laurent Pinchart
  2020-02-26 22:46     ` Sebastian Reichel
  0 siblings, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 15:31 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:41AM +0100, Sebastian Reichel wrote:
> 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>
> ---
>  drivers/gpu/drm/omapdrm/dss/Kconfig |   1 +
>  drivers/gpu/drm/omapdrm/dss/dsi.c   | 144 +++++++---------------------
>  2 files changed, 33 insertions(+), 112 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
> index 72ae79c0c9b4..90e2dd522896 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 8c223b808740..e5589e615808 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -2696,97 +2696,49 @@ 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)
> +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;
>  
> -	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);
> +	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);

You use the packet for this case only, I think you could simply write

		u16 data = ((msg->tx_len > 0) ? tx[0] : 0)
			 | (((msg->tx_len > 1) ? tx[1] : 0) << 8);
		r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 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);
> +		r = dsi_vc_send_long(dsi, msg->channel, msg->type,
> +						   msg->tx_buf, msg->tx_len, 0);

Indentation.

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

>  	}
>  
> -	return r;
> -}
> -
> -static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
> -		const u8 *data, int len)
> -{
> -	struct dsi_data *dsi = to_dsi_data(dssdev);
> -
> -	return dsi_vc_write_nosync_common(dsi, channel, data, len,
> -			DSS_DSI_CONTENT_DCS);
> -}
> -
> -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);
> -
> -	return dsi_vc_write_nosync_common(dsi, channel, data, len,
> -			DSS_DSI_CONTENT_GENERIC);
> -}
> -
> -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;
> +	/*
> +	 * 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 earily.

s/earily/early/

Do I understand correctly that this isn't implemented yet ? You should
make it clear in the comment that it's a candidate for a future
optimization.

> +	 */
>  
> -	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 +2960,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);
> @@ -4811,35 +4754,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)
>  {
> -	/*
> -	 * no_sync can be used to optimize performance by sending
> -	 * e.g. column and page information without syncing in
> -	 * between. It's not absolutley 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:
> @@ -4849,11 +4774,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;

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-25  2:28   ` Sebastian Reichel
@ 2020-02-25 15:42     ` Tony Lindgren
  2020-02-25 23:01       ` Sebastian Reichel
  0 siblings, 1 reply; 113+ messages in thread
From: Tony Lindgren @ 2020-02-25 15:42 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Laurent Pinchart, Tomi Valkeinen, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

* Sebastian Reichel <sre@kernel.org> [200225 02:29]:
> On Mon, Feb 24, 2020 at 04:10:11PM -0800, Tony Lindgren wrote:
> > BTW, I think there's also some refcount issue in general where
> > the omapdrm related modules cannot be unloaded any longer?
> 
> I wouldn't be too surprised. The dependencies are quite interesting
> at the moment with omapdss registering omapdrm and then omapdrm
> registers the drm_device, which references the encoders from
> omapdss. I think this is something to look at once Laurent's and
> my branch have been merged to avoid increasing the complexity.
> Technically it should be possible to link everything into one
> module.

Well the DSS is really DOSSI for Display Output SubSystem
Interconnect :) The devices on the interconnect are mostly
independent and ideally the toplevel dss driver would just
provide Linux generic resources to dispc and various output
drivers. So probably not a good idea to try to build it all
into a single module.

Regards,

Tony

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

* Re: [PATCHv2 12/56] drm/omap: dsi: simplify read functions
  2020-02-24 23:20 ` [PATCHv2 12/56] drm/omap: dsi: simplify read functions Sebastian Reichel
@ 2020-02-25 16:20   ` Laurent Pinchart
  0 siblings, 0 replies; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 16:20 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:42AM +0100, Sebastian Reichel wrote:
> 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>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 109 +++++++++---------------------
>  1 file changed, 33 insertions(+), 76 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index e5589e615808..9b5b078beb6d 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -2741,60 +2741,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);
> -

Do you plan to drop debug_read ? I don't really mind, but it can have
its uses. If this wasn't done on purpose, you may want to move those
messages to dsi_vc_dcs_read() and dsi_vc_generic_read().

> -	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)
>  {
> @@ -2903,61 +2849,75 @@ 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);
>  	int r;
> +	u8 dcs_cmd = ((u8*) msg->tx_buf)[0];

Nitpicking, dcs_cmd before r ?

>  
> -	r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd);
> +	r = dsi_vc_send_short(dsi, msg->channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
>  	if (r)
>  		goto err;
>  
> -	r = dsi_vc_send_bta_sync(dssdev, channel);
> +	r = dsi_vc_send_bta_sync(dssdev, msg->channel);
>  	if (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_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("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
> +		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);

As with the previous patch, I think you can compute data manually if the
only use of the packet structure is to get this information.

> +
> +	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("dsi_vc_generic_read(ch %d, reqlen %d) failed\n",
> +		msg->channel, msg->tx_len);
> +	return r;
>  }
>  
>  static int dsi_enter_ulps(struct dsi_data *dsi)
> @@ -4768,12 +4728,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;

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 13/56] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg
  2020-02-24 23:20 ` [PATCHv2 13/56] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg Sebastian Reichel
@ 2020-02-25 16:30   ` Laurent Pinchart
  2020-02-26 23:34     ` Sebastian Reichel
  0 siblings, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 16:30 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

Thank you for the patch.

On Tue, Feb 25, 2020 at 12:20:43AM +0100, Sebastian Reichel wrote:
> 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>
> ---
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 92 +++++++++++++++----------------
>  1 file changed, 45 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index 9b5b078beb6d..4899bfa2d76f 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -2599,30 +2599,36 @@ 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)
>  {
> +	struct mipi_dsi_packet pkg;
>  	/*u32 val; */
>  	int i;
>  	const u8 *p;
>  	int r = 0;
>  	u8 b1, b2, b3, b4;
>  
> +	r = mipi_dsi_create_packet(&pkg, msg);
> +	if (r < 0)
> +		return r;
> +
>  	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,
> +				 pkg.header[3]);

mipi_dsi_create_packet() never sets header[3]. I suppose that's not an
issue as we were always passing ecc as 0 to this function, but you may
want to drop mipi_dsi_create_packet() above and just hardcode 0 here.

>  
> -	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 +2637,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,64 +2662,64 @@ 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 pkg;

s/pkg/pkt/ (or packet)

>  	u32 r;
> -	u8 data_id;
> +
> +	r = mipi_dsi_create_packet(&pkg, 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, pkg.header[1], pkg.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 = pkg.header[3] << 24 | pkg.header[2] << 16 | pkg.header[1] << 8 |
> +	    pkg.header[0];

OK, this justifies using mipi_dsi_create_packet(), so you can skip the
related comments in earlier patches.

> -	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;
> @@ -2853,10 +2859,10 @@ 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 cmd = ((u8*) msg->tx_buf)[0];
>  	int r;
> -	u8 dcs_cmd = ((u8*) msg->tx_buf)[0];
>  
> -	r = dsi_vc_send_short(dsi, msg->channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
> +	r = dsi_vc_send_short(dsi, msg);
>  	if (r)
>  		goto err;
>  
> @@ -2877,7 +2883,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
>  	return 0;
>  err:
>  	DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
> -		msg->channel, dcs_cmd);
> +		msg->channel, cmd);
>  	return r;
>  }
>  
> @@ -2885,17 +2891,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;
>  

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-25 15:42     ` Tony Lindgren
@ 2020-02-25 23:01       ` Sebastian Reichel
  2020-02-25 23:06         ` Laurent Pinchart
  2020-02-25 23:09         ` Tony Lindgren
  0 siblings, 2 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-25 23:01 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Laurent Pinchart, Tomi Valkeinen, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi,

On Tue, Feb 25, 2020 at 07:42:37AM -0800, Tony Lindgren wrote:
> * Sebastian Reichel <sre@kernel.org> [200225 02:29]:
> > On Mon, Feb 24, 2020 at 04:10:11PM -0800, Tony Lindgren wrote:
> > > BTW, I think there's also some refcount issue in general where
> > > the omapdrm related modules cannot be unloaded any longer?
> > 
> > I wouldn't be too surprised. The dependencies are quite interesting
> > at the moment with omapdss registering omapdrm and then omapdrm
> > registers the drm_device, which references the encoders from
> > omapdss. I think this is something to look at once Laurent's and
> > my branch have been merged to avoid increasing the complexity.
> > Technically it should be possible to link everything into one
> > module.
> 
> Well the DSS is really DOSSI for Display Output SubSystem
> Interconnect :) The devices on the interconnect are mostly
> independent and ideally the toplevel dss driver would just
> provide Linux generic resources to dispc and various output
> drivers. So probably not a good idea to try to build it all
> into a single module.

All the output drivers and dispc are already in a single module:
omapdss.ko. There is omapdss-base.ko, omapdss.ko and omapdrm.ko
module. omapdss-base.ko contains a few helpers, omapdss.ko contains
dispc and all output encoders, omapdrm has the tiler code and
wraps some of the custom DSS APIs to DRM APIs. I think the best
way forward is to eliminate the custom API and use common DRM
APIs directly. Then merge all 3 modules into one module.

In theory one could add modules for each encoder, but practically
this only increases complexity. DRM cannnot hotplug encoders, so
removing any module results in complete loss of DRM. Also during
probe we need to load all modules, since something might be
connected. So having extra modules is not really useful?

-- Sebastian

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-25 23:01       ` Sebastian Reichel
@ 2020-02-25 23:06         ` Laurent Pinchart
  2020-02-25 23:09         ` Tony Lindgren
  1 sibling, 0 replies; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-25 23:06 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Tony Lindgren, Tomi Valkeinen, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

On Wed, Feb 26, 2020 at 12:01:24AM +0100, Sebastian Reichel wrote:
> On Tue, Feb 25, 2020 at 07:42:37AM -0800, Tony Lindgren wrote:
> > * Sebastian Reichel <sre@kernel.org> [200225 02:29]:
> > > On Mon, Feb 24, 2020 at 04:10:11PM -0800, Tony Lindgren wrote:
> > > > BTW, I think there's also some refcount issue in general where
> > > > the omapdrm related modules cannot be unloaded any longer?
> > > 
> > > I wouldn't be too surprised. The dependencies are quite interesting
> > > at the moment with omapdss registering omapdrm and then omapdrm
> > > registers the drm_device, which references the encoders from
> > > omapdss. I think this is something to look at once Laurent's and
> > > my branch have been merged to avoid increasing the complexity.
> > > Technically it should be possible to link everything into one
> > > module.
> > 
> > Well the DSS is really DOSSI for Display Output SubSystem
> > Interconnect :) The devices on the interconnect are mostly
> > independent and ideally the toplevel dss driver would just
> > provide Linux generic resources to dispc and various output
> > drivers. So probably not a good idea to try to build it all
> > into a single module.
> 
> All the output drivers and dispc are already in a single module:
> omapdss.ko. There is omapdss-base.ko, omapdss.ko and omapdrm.ko
> module. omapdss-base.ko contains a few helpers, omapdss.ko contains
> dispc and all output encoders, omapdrm has the tiler code and
> wraps some of the custom DSS APIs to DRM APIs. I think the best
> way forward is to eliminate the custom API and use common DRM
> APIs directly. Then merge all 3 modules into one module.
> 
> In theory one could add modules for each encoder, but practically
> this only increases complexity. DRM cannnot hotplug encoders, so
> removing any module results in complete loss of DRM. Also during
> probe we need to load all modules, since something might be
> connected. So having extra modules is not really useful?

This was considered previously, but blocked (IIRC) because it introduced
circular dependencies with the omapdrm-specific display drivers in
drivers/gpu/drm/omapdrm/displays/. Once panel-dsi-cm goes away, I think
we can give it another try.

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-25 23:01       ` Sebastian Reichel
  2020-02-25 23:06         ` Laurent Pinchart
@ 2020-02-25 23:09         ` Tony Lindgren
  2020-02-25 23:52           ` Sebastian Reichel
  1 sibling, 1 reply; 113+ messages in thread
From: Tony Lindgren @ 2020-02-25 23:09 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Laurent Pinchart, Tomi Valkeinen, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

* Sebastian Reichel <sre@kernel.org> [200225 23:03]:
> Hi,
> 
> On Tue, Feb 25, 2020 at 07:42:37AM -0800, Tony Lindgren wrote:
> > * Sebastian Reichel <sre@kernel.org> [200225 02:29]:
> > > On Mon, Feb 24, 2020 at 04:10:11PM -0800, Tony Lindgren wrote:
> > > > BTW, I think there's also some refcount issue in general where
> > > > the omapdrm related modules cannot be unloaded any longer?
> > > 
> > > I wouldn't be too surprised. The dependencies are quite interesting
> > > at the moment with omapdss registering omapdrm and then omapdrm
> > > registers the drm_device, which references the encoders from
> > > omapdss. I think this is something to look at once Laurent's and
> > > my branch have been merged to avoid increasing the complexity.
> > > Technically it should be possible to link everything into one
> > > module.
> > 
> > Well the DSS is really DOSSI for Display Output SubSystem
> > Interconnect :) The devices on the interconnect are mostly
> > independent and ideally the toplevel dss driver would just
> > provide Linux generic resources to dispc and various output
> > drivers. So probably not a good idea to try to build it all
> > into a single module.
> 
> All the output drivers and dispc are already in a single module:
> omapdss.ko. There is omapdss-base.ko, omapdss.ko and omapdrm.ko
> module. omapdss-base.ko contains a few helpers, omapdss.ko contains
> dispc and all output encoders, omapdrm has the tiler code and
> wraps some of the custom DSS APIs to DRM APIs. I think the best
> way forward is to eliminate the custom API and use common DRM
> APIs directly. Then merge all 3 modules into one module.
> 
> In theory one could add modules for each encoder, but practically
> this only increases complexity. DRM cannnot hotplug encoders, so
> removing any module results in complete loss of DRM. Also during
> probe we need to load all modules, since something might be
> connected. So having extra modules is not really useful?

Well my main concern here is that we should use generic
Linux frameworks between the devices within DSS where possible.
I can see a single driver pile of code quickly turn into a
spaghetti of internal calls instead..

Also each devices on the DSS interconnect needs to do
pm_runtime_get for it's struct device naturally.

If you can avoid the issues above, then I have no objections
of just having one module.

Regards,

Tony

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-25 23:09         ` Tony Lindgren
@ 2020-02-25 23:52           ` Sebastian Reichel
  2020-02-26 12:20             ` Tomi Valkeinen
  0 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-25 23:52 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Laurent Pinchart, Tomi Valkeinen, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi,

On Tue, Feb 25, 2020 at 03:09:37PM -0800, Tony Lindgren wrote:
> * Sebastian Reichel <sre@kernel.org> [200225 23:03]:
> > Hi,
> > 
> > On Tue, Feb 25, 2020 at 07:42:37AM -0800, Tony Lindgren wrote:
> > > * Sebastian Reichel <sre@kernel.org> [200225 02:29]:
> > > > On Mon, Feb 24, 2020 at 04:10:11PM -0800, Tony Lindgren wrote:
> > > > > BTW, I think there's also some refcount issue in general where
> > > > > the omapdrm related modules cannot be unloaded any longer?
> > > > 
> > > > I wouldn't be too surprised. The dependencies are quite interesting
> > > > at the moment with omapdss registering omapdrm and then omapdrm
> > > > registers the drm_device, which references the encoders from
> > > > omapdss. I think this is something to look at once Laurent's and
> > > > my branch have been merged to avoid increasing the complexity.
> > > > Technically it should be possible to link everything into one
> > > > module.
> > > 
> > > Well the DSS is really DOSSI for Display Output SubSystem
> > > Interconnect :) The devices on the interconnect are mostly
> > > independent and ideally the toplevel dss driver would just
> > > provide Linux generic resources to dispc and various output
> > > drivers. So probably not a good idea to try to build it all
> > > into a single module.
> > 
> > All the output drivers and dispc are already in a single module:
> > omapdss.ko. There is omapdss-base.ko, omapdss.ko and omapdrm.ko
> > module. omapdss-base.ko contains a few helpers, omapdss.ko contains
> > dispc and all output encoders, omapdrm has the tiler code and
> > wraps some of the custom DSS APIs to DRM APIs. I think the best
> > way forward is to eliminate the custom API and use common DRM
> > APIs directly. Then merge all 3 modules into one module.
> > 
> > In theory one could add modules for each encoder, but practically
> > this only increases complexity. DRM cannnot hotplug encoders, so
> > removing any module results in complete loss of DRM. Also during
> > probe we need to load all modules, since something might be
> > connected. So having extra modules is not really useful?
> 
> Well my main concern here is that we should use generic
> Linux frameworks between the devices within DSS where possible.

Ack.

> I can see a single driver pile of code quickly turn into a
> spaghetti of internal calls instead.

I was only talking about generating a single module, it contains
multiple drivers. And we already have the spaghetti of internal
calls between omapdrm and omapdss. With the modules it only means,
that functions are either exported or accessed via callbacks.

> Also each devices on the DSS interconnect needs to do
> pm_runtime_get for it's struct device naturally.

Sure, but you are talking about things that are already part of a
single module (omapdss.ko). omapdss-base.ko and omapdrm.ko do not
directly access hardware.

> If you can avoid the issues above, then I have no objections
> of just having one module.

Well for now let's get Laurent's and my series forward. I think
the next step would be to get rid of omap_encoder by moving the
encoder init into the DSS output code. Technically we are already
merging omapdrm and omapdss, e.g. omap_connector is gone from
omapdrm after the series.

-- Sebastian

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-25 23:52           ` Sebastian Reichel
@ 2020-02-26 12:20             ` Tomi Valkeinen
  0 siblings, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-02-26 12:20 UTC (permalink / raw)
  To: Sebastian Reichel, Tony Lindgren
  Cc: Laurent Pinchart, Merlijn Wajer, H. Nikolaus Schaller,
	Rob Herring, linux-omap, dri-devel, kernel

On 26/02/2020 01:52, Sebastian Reichel wrote:

> Well for now let's get Laurent's and my series forward. I think
> the next step would be to get rid of omap_encoder by moving the
> encoder init into the DSS output code. Technically we are already
> merging omapdrm and omapdss, e.g. omap_connector is gone from
> omapdrm after the series.

After Laurent's series (now pushed) and this one, we can turn omapdrm into a single module, as it's 
supposed to be.

I don't see a point in trying to change DSS internal encoders into separate modules, as they're all 
under DSS, and at times connected in ways which are not easily represented with generic APIs. In 
theory it should be possible, but I don't see any real benefit in such work.

  Tomi

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (57 preceding siblings ...)
  2020-02-25 11:53 ` [PATCHv2 57/56] dt-bindings: display: panel-dsi-cm: convert to YAML Sebastian Reichel
@ 2020-02-26 12:28 ` Tomi Valkeinen
  2020-02-27  0:28   ` Sebastian Reichel
  2020-03-25 12:47 ` Tomi Valkeinen
  2020-06-25 13:07 ` H. Nikolaus Schaller
  60 siblings, 1 reply; 113+ messages in thread
From: Tomi Valkeinen @ 2020-02-26 12:28 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

On 25/02/2020 01:20, Sebastian Reichel wrote:
> This updates the existing omapdrm DSI code, so that it uses
> common drm_mipi_dsi API and drm_panel.
> 
> The patchset has been tested with Droid 4 using Linux console, X.org and
> Weston. The patchset is based on Laurent Pinchartl's patch series [0]
> and removes the last custom panel driver, so quite a few cleanups on the
> omapdrm codebase were possible.

I haven't done any reviews yet, but applied these (and the one v2.1 patch) on top of Laurent's. I booted up AM5 EVM and loaded the modules:

[   17.261560] WARNING: CPU: 0 PID: 419 at drivers/base/component.c:636 component_bind_all+0x1f4/0x258
[   17.270811] Modules linked in: omapdrm(+) omapdss omapdss_base panel_osd_osd101t2587_53ts panel_simple simple_bridge ti_tpd12s015 display_connec
tor tc358767 tc358768 sii902x ti_tfp410 drm_kms_helper drm drm_panel_orientation_quirks cfbfillrect cfbimgblt cfbcopyarea cec
[   17.295521] CPU: 0 PID: 419 Comm: insmod Not tainted 5.6.0-rc2-00375-g66c4203ed9d4 #2
[   17.303387] Hardware name: Generic DRA74X (Flattened Device Tree)
[   17.309520] [<c011431c>] (unwind_backtrace) from [<c010dc20>] (show_stack+0x10/0x14)
[   17.317306] [<c010dc20>] (show_stack) from [<c09acca4>] (dump_stack+0xb4/0xd0)
[   17.324567] [<c09acca4>] (dump_stack) from [<c013a33c>] (__warn+0xc0/0xf8)
[   17.331477] [<c013a33c>] (__warn) from [<c013a700>] (warn_slowpath_fmt+0x58/0xb8)
[   17.338998] [<c013a700>] (warn_slowpath_fmt) from [<c0630698>] (component_bind_all+0x1f4/0x258)
[   17.347768] [<c0630698>] (component_bind_all) from [<bf11b52c>] (pdev_probe+0xe0/0x7a0 [omapdrm])
[   17.356709] [<bf11b52c>] (pdev_probe [omapdrm]) from [<c063a198>] (platform_drv_probe+0x48/0x98)
[   17.365537] [<c063a198>] (platform_drv_probe) from [<c0637c1c>] (really_probe+0x200/0x478)
[   17.373841] [<c0637c1c>] (really_probe) from [<c0638060>] (driver_probe_device+0x6c/0x1b4)
[   17.382145] [<c0638060>] (driver_probe_device) from [<c06383f0>] (device_driver_attach+0x58/0x60)
[   17.391060] [<c06383f0>] (device_driver_attach) from [<c063849c>] (__driver_attach+0xa4/0x148)
[   17.399713] [<c063849c>] (__driver_attach) from [<c0635af8>] (bus_for_each_dev+0x70/0xb4)
[   17.407930] [<c0635af8>] (bus_for_each_dev) from [<c0636d60>] (bus_add_driver+0x100/0x204)
[   17.416233] [<c0636d60>] (bus_add_driver) from [<c0639078>] (driver_register+0x74/0x108)
[   17.424361] [<c0639078>] (driver_register) from [<c063a2a8>] (__platform_register_drivers+0x58/0x150)
[   17.433628] [<c063a2a8>] (__platform_register_drivers) from [<c0102ff8>] (do_one_initcall+0x48/0x2a0)
[   17.442893] [<c0102ff8>] (do_one_initcall) from [<c01e2efc>] (do_init_module+0x5c/0x234)
[   17.451022] [<c01e2efc>] (do_init_module) from [<c01e5668>] (load_module+0x250c/0x28a4)
[   17.459064] [<c01e5668>] (load_module) from [<c01e5cb8>] (sys_finit_module+0xcc/0x110)
[   17.467020] [<c01e5cb8>] (sys_finit_module) from [<c0101000>] (ret_fast_syscall+0x0/0x54)
[   17.475233] Exception stack(0xea84bfa8 to 0xea84bff0)
[   17.480307] bfa0:                   00000002 00000000 00000003 0002a894 00000000 bebd2d74
[   17.488524] bfc0: 00000002 00000000 00028424 0000017b 0003eeb0 00000002 b6ffe000 00000000
[   17.496738] bfe0: bebd2bb8 bebd2ba8 00020d7c b6edb0b0
[   17.502365] ---[ end trace c20802296d6b2775 ]---
[   17.508567] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dsi_framedone_timeout_work_callback [omapdss])
[   17.520358] omapdss_dss 58000000.dss: bound 58040000.encoder (ops dsi_framedone_timeout_work_callback [omapdss])
[   17.559728] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[   17.574544] [drm] Enabling DMM ywrap scrolling
[   17.580606] omapdrm omapdrm.0: fb0: omapdrmdrmfb frame buffer device
[   17.625099] [drm] Initialized omapdrm 1.0.0 20110917 for omapdrm.0 on minor 0

Similar warning on module unload. The display works, though.

 Tomi

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

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

* Re: [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*
  2020-02-25 13:58   ` Laurent Pinchart
@ 2020-02-26 21:25     ` Sebastian Reichel
  0 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-26 21:25 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi,

On Tue, Feb 25, 2020 at 03:58:23PM +0200, Laurent Pinchart wrote:
> Hi Sebastian,
> 
> Thank you for the patch.
> 
> On Tue, Feb 25, 2020 at 12:20:35AM +0100, Sebastian Reichel wrote:
> > This replaces OMAP specific enum for pixel format with
> > common implementation.
> > 
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > ---
> >  .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 +-
> >  drivers/gpu/drm/omapdrm/dss/dsi.c             | 49 +++++++------------
> >  drivers/gpu/drm/omapdrm/dss/omapdss.h         | 10 +---
> >  3 files changed, 20 insertions(+), 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 e7fe5d702337..e6ebfc35243e 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 8c39823a8295..bb2548d091ef 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> > +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> > @@ -34,6 +34,7 @@
> >  #include <linux/sys_soc.h>
> >  
> >  #include <video/mipi_display.h>
> > +#include <drm/drm_mipi_dsi.h>
> 
> Maybe sort those two headers alphabetically ?

Ack.

> 
> >  
> >  #include "omapdss.h"
> >  #include "dss.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();
> 
> Removing a BUG() is really nice :-) I suppose this never happened, or we
> would have heard of it. Still, is there a top-level location where we
> could validate the format (assuming it is still used at the end of this
> series) ? mipi_dsi_pixel_format_to_bpp() returns -EINVAL if the format
> is invalid, and we don't check for that through the code . It doesn't
> have to be handled in this patch, it can be done later in the series as
> you keep reworking the code.

The pixel format is a constant from the panel driver (first change
in this patch). In the encoder stage it originates from dsi_set_config(),
later from omap_dsi_host_attach(). I will add a check there.

> > -		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);
> > diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> > index b0424daaceed..53fea1cbbc2d 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> > +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> > @@ -14,6 +14,7 @@
> >  #include <linux/platform_data/omapdss.h>
> >  #include <uapi/drm/drm_mode.h>
> 
> While at it, I would replace this with
> 
> #include <drm/drm_mode.h>
> 
> , add a blank line here, and keep the drm headers sorted alphabetically.

Ack

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

Thanks.

> >  #include <drm/drm_crtc.h>
> > +#include <drm/drm_mipi_dsi.h>
> >  
> >  #define DISPC_IRQ_FRAMEDONE		(1 << 0)
> >  #define DISPC_IRQ_VSYNC			(1 << 1)
> > @@ -116,13 +117,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 +204,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;
> 
> -- 
> Regards,
> 
> Laurent Pinchart

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

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

* Re: [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins
  2020-02-24 23:42   ` Laurent Pinchart
@ 2020-02-26 21:28     ` Sebastian Reichel
  2020-02-26 21:36       ` Laurent Pinchart
  0 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-26 21:28 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi Laurent,

On Tue, Feb 25, 2020 at 01:42:49AM +0200, Laurent Pinchart wrote:
> Hi Sebastian,
> 
> Thank you for the patch.
> 
> On Tue, Feb 25, 2020 at 12:20:34AM +0100, Sebastian Reichel wrote:
> > 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>
> > ---
> >  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 3484b5d4a91c..e7fe5d702337 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 79ddfbfd1b58..8c39823a8295 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 {
> 
> I think you can drop the definition of the omap_dsi_pin_config structure
> earlier in this file too, as well as the OMAP_DSS_MAX_DSI_PINS macro.
> With this fixed,

No, the struct is still used by the code setting up the pins from
DT.

-- Sebastian

> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> >  	/* 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);
> 
> -- 
> Regards,
> 
> Laurent Pinchart

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

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

* Re: [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins
  2020-02-26 21:28     ` Sebastian Reichel
@ 2020-02-26 21:36       ` Laurent Pinchart
  2020-02-26 22:25         ` Sebastian Reichel
  0 siblings, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-26 21:36 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

On Wed, Feb 26, 2020 at 10:28:19PM +0100, Sebastian Reichel wrote:
> On Tue, Feb 25, 2020 at 01:42:49AM +0200, Laurent Pinchart wrote:
> > On Tue, Feb 25, 2020 at 12:20:34AM +0100, Sebastian Reichel wrote:
> > > 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>
> > > ---
> > >  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 3484b5d4a91c..e7fe5d702337 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 79ddfbfd1b58..8c39823a8295 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 {
> > 
> > I think you can drop the definition of the omap_dsi_pin_config structure
> > earlier in this file too, as well as the OMAP_DSS_MAX_DSI_PINS macro.
> > With this fixed,
> 
> No, the struct is still used by the code setting up the pins from
> DT.

Indeed, my bad. I think I'd pass the unsigned int num_pins and const int
*pins to dsi_configure_pins() directly to drop the structure, but that
can be done in a subsequent patch (maybe it is already :-)).

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

This tag holds.

> > >  	/* 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);

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 08/56] drm/omap: panel-dsi-cm: convert to transfer API
  2020-02-25 14:52   ` Laurent Pinchart
@ 2020-02-26 22:12     ` Sebastian Reichel
  0 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-26 22:12 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi,

On Tue, Feb 25, 2020 at 04:52:21PM +0200, Laurent Pinchart wrote:
> Hi Sebastian,
> 
> Thank you for the patch.
> 
> On Tue, Feb 25, 2020 at 12:20:38AM +0100, Sebastian Reichel wrote:
> > 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>
> > ---
> >  .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 133 +++++++++++++-----
> >  1 file changed, 96 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 e6ebfc35243e..92f510a771fe 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);
> 
> Should you call dsicm_dcs_write_0(ddata, MIPI_DCS_ENTER_SLEEP_MODE)
> instead ? This uses the _nosync variant though, is it an issue ?

Right, this will be replaced by mipi_dsi_dcs_enter_sleep_mode() in
a future patch. I did not notice any issues with commands not being
send when panel is turned off, so it should be fine.

> >  	if (r)
> >  		return r;
> >  
> > @@ -233,28 +249,44 @@ 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,
> > +	};
> >  
> > -	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 u8 paramY[] = {
> > +		MIPI_DCS_SET_PAGE_ADDRESS,
> > +		(y1 >> 8) & 0xff,
> > +		(y1 >> 0) & 0xff,
> > +		(y2 >> 8) & 0xff,
> > +		(y2 >> 0) & 0xff,
> > +	};
> >  
> > -	r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf));
> 
> Also replacing a _nosync variant here.
>
> > +	const struct mipi_dsi_msg msgY = {
> > +		.channel = ddata->channel,
> > +		.type = MIPI_DSI_GENERIC_LONG_WRITE,
> > +		.tx_buf = paramY,
> > +		.tx_len = 5,
> > +	};
> > +
> > +
> 
> A single blank line is enough.
> 
> > +	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);
> 
> And here, you're replacing bta_sync. If I understand the code correctly,
> you're essentially removing an optimization, as each write will sync,
> right ? I'm fine with this change if we add the functionality back later
> in this series.

Yes, this is an optimization. X and Y will be sync'd together. This
is removed here, so that we can use the common helpers:
mipi_dsi_dcs_set_column_address() and mipi_dsi_dcs_set_page_address().

Actually those are also removed even further when the update
handling is moved to DSI encoder. It should be possible to
reintroduce it there without the need to expose the nosync
feature via DRM API.

> > +	if (r)
> > +		return r;
> >  
> >  	return r;
> >  }
> > @@ -991,6 +1023,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)
> 
> Please use tabs instead of spaces for indentation.

Ack.

> > +{
> > +	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 +1084,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 +1124,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:
> 
> -- 
> Regards,
> 
> Laurent Pinchart

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

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

* Re: [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins
  2020-02-26 21:36       ` Laurent Pinchart
@ 2020-02-26 22:25         ` Sebastian Reichel
  0 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-26 22:25 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi Laurent,

On Wed, Feb 26, 2020 at 11:36:30PM +0200, Laurent Pinchart wrote:
> > > I think you can drop the definition of the omap_dsi_pin_config structure
> > > earlier in this file too, as well as the OMAP_DSS_MAX_DSI_PINS macro.
> > > With this fixed,
> > 
> > No, the struct is still used by the code setting up the pins from
> > DT.
> 
> Indeed, my bad. I think I'd pass the unsigned int num_pins and const int
> *pins to dsi_configure_pins() directly to drop the structure, but that
> can be done in a subsequent patch (maybe it is already :-)).

I added quite some cleanups at the end of the series, but there is
still quite a few cleanups possible within the DSI encoder
(including this one). Cleaning up dsi.c takes some time and rebasing
this code gets annoying.

After this series the cleanups mostly are internal to dsi.c and
should reduce merge conflict probability.  Also I feel a bit
uncomfortable, since we currently have no DSI video mode user.
Nikolaus Schaller is working on adding support for such a system, so
it would be nice to get that supported first making it possible to
do easy bisecting for issues introduced by refactoring. (This is not
specifically about dsi_configure_pins of course)

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

Thanks.

-- Sebastian

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

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

* Re: [PATCHv2 11/56] drm/omap: dsi: simplify write function
  2020-02-25 15:31   ` Laurent Pinchart
@ 2020-02-26 22:46     ` Sebastian Reichel
  2020-02-26 22:48       ` Laurent Pinchart
  0 siblings, 1 reply; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-26 22:46 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi Laurent,

On Tue, Feb 25, 2020 at 05:31:05PM +0200, Laurent Pinchart wrote:
> > +	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);
> 
> You use the packet for this case only, I think you could simply write
> 
> 		u16 data = ((msg->tx_len > 0) ? tx[0] : 0)
> 			 | (((msg->tx_len > 1) ? tx[1] : 0) << 8);
> 		r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);

That probably works with 's/tx[/((u8*) msg->tx_buf)[', which looks
really ugly :) This code is further simplified by a further patch,
which forwards the complete message into dsi_vc_send_short().

> >  	} 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);
> > +		r = dsi_vc_send_long(dsi, msg->channel, msg->type,
> > +						   msg->tx_buf, msg->tx_len, 0);
> 
> Indentation.

Ok.

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

Are you fine with keeping the mipi_dsi_packet, since it will be
removed in a further patch?

> >  	}
> >  
> > -	return r;
> > -}
> > -
> > -static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
> > -		const u8 *data, int len)
> > -{
> > -	struct dsi_data *dsi = to_dsi_data(dssdev);
> > -
> > -	return dsi_vc_write_nosync_common(dsi, channel, data, len,
> > -			DSS_DSI_CONTENT_DCS);
> > -}
> > -
> > -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);
> > -
> > -	return dsi_vc_write_nosync_common(dsi, channel, data, len,
> > -			DSS_DSI_CONTENT_GENERIC);
> > -}
> > -
> > -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;
> > +	/*
> > +	 * 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 earily.
> 
> s/earily/early/
> 
> Do I understand correctly that this isn't implemented yet ? You should
> make it clear in the comment that it's a candidate for a future
> optimization.

Yes. I forgot the TODO keyword for some reason. Has been quite some
time since I wrote this patch :) I fixed the earily and prefixed the
message with TODO.

-- Sebastian

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

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

* Re: [PATCHv2 11/56] drm/omap: dsi: simplify write function
  2020-02-26 22:46     ` Sebastian Reichel
@ 2020-02-26 22:48       ` Laurent Pinchart
  0 siblings, 0 replies; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-26 22:48 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

Hi Sebastian,

On Wed, Feb 26, 2020 at 11:46:43PM +0100, Sebastian Reichel wrote:
> On Tue, Feb 25, 2020 at 05:31:05PM +0200, Laurent Pinchart wrote:
> > > +	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);
> > 
> > You use the packet for this case only, I think you could simply write
> > 
> > 		u16 data = ((msg->tx_len > 0) ? tx[0] : 0)
> > 			 | (((msg->tx_len > 1) ? tx[1] : 0) << 8);
> > 		r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0);
> 
> That probably works with 's/tx[/((u8*) msg->tx_buf)[', which looks
> really ugly :) This code is further simplified by a further patch,
> which forwards the complete message into dsi_vc_send_short().
> 
> > >  	} 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);
> > > +		r = dsi_vc_send_long(dsi, msg->channel, msg->type,
> > > +						   msg->tx_buf, msg->tx_len, 0);
> > 
> > Indentation.
> 
> Ok.
> 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Are you fine with keeping the mipi_dsi_packet, since it will be
> removed in a further patch?

Yes, please ignore the comments related to the packet structure, I've
realized when reviewing a patch further in this series that this goes
away (I've mentioned that explicitly in the review of that patch).

> > >  	}
> > >  
> > > -	return r;
> > > -}
> > > -
> > > -static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
> > > -		const u8 *data, int len)
> > > -{
> > > -	struct dsi_data *dsi = to_dsi_data(dssdev);
> > > -
> > > -	return dsi_vc_write_nosync_common(dsi, channel, data, len,
> > > -			DSS_DSI_CONTENT_DCS);
> > > -}
> > > -
> > > -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);
> > > -
> > > -	return dsi_vc_write_nosync_common(dsi, channel, data, len,
> > > -			DSS_DSI_CONTENT_GENERIC);
> > > -}
> > > -
> > > -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;
> > > +	/*
> > > +	 * 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 earily.
> > 
> > s/earily/early/
> > 
> > Do I understand correctly that this isn't implemented yet ? You should
> > make it clear in the comment that it's a candidate for a future
> > optimization.
> 
> Yes. I forgot the TODO keyword for some reason. Has been quite some
> time since I wrote this patch :) I fixed the earily and prefixed the
> message with TODO.

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 13/56] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg
  2020-02-25 16:30   ` Laurent Pinchart
@ 2020-02-26 23:34     ` Sebastian Reichel
  0 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-26 23:34 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi Laurent,

On Tue, Feb 25, 2020 at 06:30:01PM +0200, Laurent Pinchart wrote:
> On Tue, Feb 25, 2020 at 12:20:43AM +0100, Sebastian Reichel wrote:
> > 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>
> > ---
> >  drivers/gpu/drm/omapdrm/dss/dsi.c | 92 +++++++++++++++----------------
> >  1 file changed, 45 insertions(+), 47 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> > index 9b5b078beb6d..4899bfa2d76f 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> > +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> > @@ -2599,30 +2599,36 @@ 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)
> >  {
> > +	struct mipi_dsi_packet pkg;
> >  	/*u32 val; */
> >  	int i;
> >  	const u8 *p;
> >  	int r = 0;
> >  	u8 b1, b2, b3, b4;
> >  
> > +	r = mipi_dsi_create_packet(&pkg, msg);
> > +	if (r < 0)
> > +		return r;
> > +
> >  	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,
> > +				 pkg.header[3]);
> 
> mipi_dsi_create_packet() never sets header[3]. I suppose that's not an
> issue as we were always passing ecc as 0 to this function, but you may
> want to drop mipi_dsi_create_packet() above and just hardcode 0 here.

sure.

> >  
> > -	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 +2637,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,64 +2662,64 @@ 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 pkg;
> 
> s/pkg/pkt/ (or packet)

Ack.

-- Sebastian

> >  	u32 r;
> > -	u8 data_id;
> > +
> > +	r = mipi_dsi_create_packet(&pkg, 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, pkg.header[1], pkg.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 = pkg.header[3] << 24 | pkg.header[2] << 16 | pkg.header[1] << 8 |
> > +	    pkg.header[0];
> 
> OK, this justifies using mipi_dsi_create_packet(), so you can skip the
> related comments in earlier patches.
> 
> > -	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;
> > @@ -2853,10 +2859,10 @@ 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 cmd = ((u8*) msg->tx_buf)[0];
> >  	int r;
> > -	u8 dcs_cmd = ((u8*) msg->tx_buf)[0];
> >  
> > -	r = dsi_vc_send_short(dsi, msg->channel, MIPI_DSI_DCS_READ, dcs_cmd, 0);
> > +	r = dsi_vc_send_short(dsi, msg);
> >  	if (r)
> >  		goto err;
> >  
> > @@ -2877,7 +2883,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev,
> >  	return 0;
> >  err:
> >  	DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
> > -		msg->channel, dcs_cmd);
> > +		msg->channel, cmd);
> >  	return r;
> >  }
> >  
> > @@ -2885,17 +2891,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;
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-26 12:28 ` [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
@ 2020-02-27  0:28   ` Sebastian Reichel
  0 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-27  0:28 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Laurent Pinchart, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

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

Hi,

On Wed, Feb 26, 2020 at 02:28:23PM +0200, Tomi Valkeinen wrote:
> On 25/02/2020 01:20, Sebastian Reichel wrote:
> > This updates the existing omapdrm DSI code, so that it uses
> > common drm_mipi_dsi API and drm_panel.
> > 
> > The patchset has been tested with Droid 4 using Linux console, X.org and
> > Weston. The patchset is based on Laurent Pinchartl's patch series [0]
> > and removes the last custom panel driver, so quite a few cleanups on the
> > omapdrm codebase were possible.
> 
> I haven't done any reviews yet, but applied these (and the one
> v2.1 patch) on top of Laurent's. I booted up AM5 EVM and loaded
> the modules:
> 
> [   17.261560] WARNING: CPU: 0 PID: 419 at drivers/base/component.c:636 component_bind_all+0x1f4/0x258

I did not see that warning for some reason. I guess I was always
lucky, since its a race condition introduced by "drm/omap: bind
components with drm_device argument". That patch moves
component_bind_all from dss_bind() to omapdrm's probe() to get
access to drm_dev. Currently omapdrm is the only DRM driver not
supplying that as parameter and its required to move encoder init
into the DSS output drivers. I assumed that it would be ok, since
it just postpones the call a little bit. Unfortunately it also
moves it out of the lock protection from dss_bind().

The only fix, that I see is to register the drm_dev is dss_bind
and then supply it to omapdrm via pdata. But I think we could
actually get rid of the omapdrm platform device completly and
just use its parent "omapdss_dss". I suppose a follow-up patchset
could merge the code into one module and do this merge.

Probably it's the best to drop that patch for now. It's not yet
used in the patches, that I sent.

> [   17.270811] Modules linked in: omapdrm(+) omapdss omapdss_base panel_osd_osd101t2587_53ts panel_simple simple_bridge ti_tpd12s015 display_connec
> tor tc358767 tc358768 sii902x ti_tfp410 drm_kms_helper drm drm_panel_orientation_quirks cfbfillrect cfbimgblt cfbcopyarea cec
> [   17.295521] CPU: 0 PID: 419 Comm: insmod Not tainted 5.6.0-rc2-00375-g66c4203ed9d4 #2
> [   17.303387] Hardware name: Generic DRA74X (Flattened Device Tree)
> [   17.309520] [<c011431c>] (unwind_backtrace) from [<c010dc20>] (show_stack+0x10/0x14)
> [   17.317306] [<c010dc20>] (show_stack) from [<c09acca4>] (dump_stack+0xb4/0xd0)
> [   17.324567] [<c09acca4>] (dump_stack) from [<c013a33c>] (__warn+0xc0/0xf8)
> [   17.331477] [<c013a33c>] (__warn) from [<c013a700>] (warn_slowpath_fmt+0x58/0xb8)
> [   17.338998] [<c013a700>] (warn_slowpath_fmt) from [<c0630698>] (component_bind_all+0x1f4/0x258)
> [   17.347768] [<c0630698>] (component_bind_all) from [<bf11b52c>] (pdev_probe+0xe0/0x7a0 [omapdrm])
> [   17.356709] [<bf11b52c>] (pdev_probe [omapdrm]) from [<c063a198>] (platform_drv_probe+0x48/0x98)
> [   17.365537] [<c063a198>] (platform_drv_probe) from [<c0637c1c>] (really_probe+0x200/0x478)
> [   17.373841] [<c0637c1c>] (really_probe) from [<c0638060>] (driver_probe_device+0x6c/0x1b4)
> [   17.382145] [<c0638060>] (driver_probe_device) from [<c06383f0>] (device_driver_attach+0x58/0x60)
> [   17.391060] [<c06383f0>] (device_driver_attach) from [<c063849c>] (__driver_attach+0xa4/0x148)
> [   17.399713] [<c063849c>] (__driver_attach) from [<c0635af8>] (bus_for_each_dev+0x70/0xb4)
> [   17.407930] [<c0635af8>] (bus_for_each_dev) from [<c0636d60>] (bus_add_driver+0x100/0x204)
> [   17.416233] [<c0636d60>] (bus_add_driver) from [<c0639078>] (driver_register+0x74/0x108)
> [   17.424361] [<c0639078>] (driver_register) from [<c063a2a8>] (__platform_register_drivers+0x58/0x150)
> [   17.433628] [<c063a2a8>] (__platform_register_drivers) from [<c0102ff8>] (do_one_initcall+0x48/0x2a0)
> [   17.442893] [<c0102ff8>] (do_one_initcall) from [<c01e2efc>] (do_init_module+0x5c/0x234)
> [   17.451022] [<c01e2efc>] (do_init_module) from [<c01e5668>] (load_module+0x250c/0x28a4)
> [   17.459064] [<c01e5668>] (load_module) from [<c01e5cb8>] (sys_finit_module+0xcc/0x110)
> [   17.467020] [<c01e5cb8>] (sys_finit_module) from [<c0101000>] (ret_fast_syscall+0x0/0x54)
> [   17.475233] Exception stack(0xea84bfa8 to 0xea84bff0)
> [   17.480307] bfa0:                   00000002 00000000 00000003 0002a894 00000000 bebd2d74
> [   17.488524] bfc0: 00000002 00000000 00028424 0000017b 0003eeb0 00000002 b6ffe000 00000000
> [   17.496738] bfe0: bebd2bb8 bebd2ba8 00020d7c b6edb0b0
> [   17.502365] ---[ end trace c20802296d6b2775 ]---
> [   17.508567] omapdss_dss 58000000.dss: bound 58001000.dispc (ops dsi_framedone_timeout_work_callback [omapdss])
> [   17.520358] omapdss_dss 58000000.dss: bound 58040000.encoder (ops dsi_framedone_timeout_work_callback [omapdss])
> [   17.559728] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
> [   17.574544] [drm] Enabling DMM ywrap scrolling
> [   17.580606] omapdrm omapdrm.0: fb0: omapdrmdrmfb frame buffer device
> [   17.625099] [drm] Initialized omapdrm 1.0.0 20110917 for omapdrm.0 on minor 0
> 
> Similar warning on module unload. The display works, though.

same problem, with dss_unbind() and omapdrm's remove function.

-- Sebastian

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

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

* Re: [PATCHv2 43/56] drm/omap: bind components with drm_device argument
  2020-02-24 23:21 ` [PATCHv2 43/56] drm/omap: bind components with drm_device argument Sebastian Reichel
@ 2020-02-27  0:32   ` Sebastian Reichel
  0 siblings, 0 replies; 113+ messages in thread
From: Sebastian Reichel @ 2020-02-27  0:32 UTC (permalink / raw)
  To: Laurent Pinchart, Tomi Valkeinen
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

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

Hi,

On Tue, Feb 25, 2020 at 12:21:13AM +0100, Sebastian Reichel wrote:
> This fixes the omapdrm driver to call component_bind_all()
> with drm_device as data argument as recommended in the
> DRM component helper usage text.
> 
> After this patch DRM functionality can be implemented directly
> in the components resulting in a simpler driver stack by removing
> one layer of abstraction.

Please ignore this faulty patch, its fortunately not required for
the remaining series. For details see my reply to Tomi:

https://lore.kernel.org/dri-devel/20200227002843.7ea73mewcr4rmzli@earth.universe/T/#m2b76dd570804845e997da19214647634f5fc7dd0

-- Sebastian

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

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

* Re: [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels
  2020-02-24 23:20 ` [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels Sebastian Reichel
  2020-02-24 23:38   ` Laurent Pinchart
@ 2020-02-27 20:09   ` Sam Ravnborg
  1 sibling, 0 replies; 113+ messages in thread
From: Sam Ravnborg @ 2020-02-27 20:09 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen, kernel,
	Tony Lindgren, H. Nikolaus Schaller, Merlijn Wajer, dri-devel,
	linux-omap

Hi Sebastian.

On Tue, Feb 25, 2020 at 12:20:31AM +0100, Sebastian Reichel wrote:
> The standard binding for DSI requires, that the channel number
> of the panel is encoded in DT. This adds the channel number in
> all OMAP3-5 boards, in preparation for using common infrastructure.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  .../devicetree/bindings/display/panel/panel-dsi-cm.txt      | 4 +++-
>  arch/arm/boot/dts/motorola-mapphone-common.dtsi             | 3 ++-
>  arch/arm/boot/dts/omap3-n950.dts                            | 3 ++-
>  arch/arm/boot/dts/omap3.dtsi                                | 3 +++
>  arch/arm/boot/dts/omap4-sdp.dts                             | 6 ++++--
>  arch/arm/boot/dts/omap4.dtsi                                | 6 ++++++
>  arch/arm/boot/dts/omap5.dtsi                                | 6 ++++++
>  7 files changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> index dce48eb9db57..f92d5c9adfc5 100644
> --- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> +++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> @@ -3,6 +3,7 @@ Generic MIPI DSI Command Mode Panel
>  
>  Required properties:
>  - compatible: "panel-dsi-cm"
It is not direct related to this patch - but you touch the file...
This binding should require a specific + a generic binding.
So any panel that in the beginng can fallback only on the generic
handling can later fallback to some panel specific quirks.

This is easy to express in .yaml format like this:
properties:
  compatible:
    description:
      Shall contain a panel specific compatible and "panel-dps-cm"
      in that order.
    items:
      - {}
      - const: panel-dsi-cm

This will not prevent a user from using:

    compatible: "foo,bar","panel-dsi-cm"

But then there is documentation for a specific compatible.

On top of this - no changes to .txt files in panel/
You need to convert to DT Schema and then patch the binding.
(Not a global fixed rule - but something I try to enforce to get the
rest converted).

	Sam

> +- reg: DSI channel number
>  
>  Optional properties:
>  - label: a symbolic name for the panel
> @@ -15,9 +16,10 @@ Required nodes:
>  Example
>  -------
>  
> -lcd0: display {
> +lcd0: panel@0 {
>  	compatible = "tpo,taal", "panel-dsi-cm";
>  	label = "lcd0";
> +	reg = <0>;
>  
>  	reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
>  
> diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> index 85665506f4f8..a5e4ba7c8dab 100644
> --- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> +++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> @@ -199,8 +199,9 @@ dsi1_out_ep: endpoint {
>  		};
>  	};
>  
> -	lcd0: display {
> +	lcd0: panel@0 {
>  		compatible = "panel-dsi-cm";
> +		reg = <0>;
>  		label = "lcd0";
>  		vddi-supply = <&lcd_regulator>;
>  		reset-gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>;	/* gpio101 */
> diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
> index 31d47a1fad84..80cf4e1177da 100644
> --- a/arch/arm/boot/dts/omap3-n950.dts
> +++ b/arch/arm/boot/dts/omap3-n950.dts
> @@ -225,8 +225,9 @@ dsi_out_ep: endpoint {
>  		};
>  	};
>  
> -	lcd0: display {
> +	lcd0: panel@0 {
>  		compatible = "nokia,himalaya", "panel-dsi-cm";
> +		reg = <0>;
>  		label = "lcd0";
>  
>  		pinctrl-names = "default";
> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> index 634ea16a711e..409d434a9b18 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -820,6 +820,9 @@ dsi: encoder@4804fc00 {
>  				ti,hwmods = "dss_dsi1";
>  				clocks = <&dss1_alwon_fck>, <&dss2_alwon_fck>;
>  				clock-names = "fck", "sys_clk";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
>  			};
>  
>  			rfbi: encoder@48050800 {
> diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
> index 91480ac1f328..8a8307517dab 100644
> --- a/arch/arm/boot/dts/omap4-sdp.dts
> +++ b/arch/arm/boot/dts/omap4-sdp.dts
> @@ -662,8 +662,9 @@ dsi1_out_ep: endpoint {
>  		};
>  	};
>  
> -	lcd0: display {
> +	lcd0: panel@0 {
>  		compatible = "tpo,taal", "panel-dsi-cm";
> +		reg = <0>;
>  		label = "lcd0";
>  
>  		reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;	/* 102 */
> @@ -687,8 +688,9 @@ dsi2_out_ep: endpoint {
>  		};
>  	};
>  
> -	lcd1: display {
> +	lcd1: panel@0 {
>  		compatible = "tpo,taal", "panel-dsi-cm";
> +		reg = <0>;
>  		label = "lcd1";
>  
>  		reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>;	/* 104 */
> diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
> index 9a87440d0b9d..a75734065cac 100644
> --- a/arch/arm/boot/dts/omap4.dtsi
> +++ b/arch/arm/boot/dts/omap4.dtsi
> @@ -465,6 +465,9 @@ dsi1: encoder@58004000 {
>  				clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>,
>  					 <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>;
>  				clock-names = "fck", "sys_clk";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
>  			};
>  
>  			dsi2: encoder@58005000 {
> @@ -479,6 +482,9 @@ dsi2: encoder@58005000 {
>  				clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>,
>  					 <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>;
>  				clock-names = "fck", "sys_clk";
> +
> +				#address-cells = <1>;
> +				#size-cells = <0>;
>  			};
>  
>  			hdmi: encoder@58006000 {
> diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
> index d0ecf54d5a23..5c7462e04716 100644
> --- a/arch/arm/boot/dts/omap5.dtsi
> +++ b/arch/arm/boot/dts/omap5.dtsi
> @@ -333,6 +333,9 @@ dsi1: encoder@58004000 {
>  				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>;
>  			};
>  
>  			dsi2: encoder@58005000 {
> @@ -347,6 +350,9 @@ dsi2: encoder@58005000 {
>  				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>;
>  			};
>  
>  			hdmi: encoder@58060000 {
> -- 
> 2.25.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible
  2020-02-24 23:20 ` [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible Sebastian Reichel
  2020-02-24 23:37   ` Laurent Pinchart
@ 2020-02-27 20:10   ` Sam Ravnborg
  1 sibling, 0 replies; 113+ messages in thread
From: Sam Ravnborg @ 2020-02-27 20:10 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen, kernel,
	Tony Lindgren, H. Nikolaus Schaller, Merlijn Wajer, dri-devel,
	linux-omap

On Tue, Feb 25, 2020 at 12:20:32AM +0100, Sebastian Reichel wrote:
> Add Droid 4 specific compatible value in addition to the
> generic one, so that we have the ability to add panel
> specific quirks in the future.
> 

Yes, exactly as explained in previous mail. Thanks.

> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  arch/arm/boot/dts/motorola-mapphone-common.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> index a5e4ba7c8dab..622383ec6a75 100644
> --- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> +++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi
> @@ -200,7 +200,7 @@ dsi1_out_ep: endpoint {
>  	};
>  
>  	lcd0: panel@0 {
> -		compatible = "panel-dsi-cm";
> +		compatible = "motorola,droid4-panel", "panel-dsi-cm";
>  		reg = <0>;
>  		label = "lcd0";
>  		vddi-supply = <&lcd_regulator>;
> -- 
> 2.25.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCHv2 57/56] dt-bindings: display: panel-dsi-cm: convert to YAML
  2020-02-25 11:53 ` [PATCHv2 57/56] dt-bindings: display: panel-dsi-cm: convert to YAML Sebastian Reichel
@ 2020-02-27 20:35   ` Sam Ravnborg
  2020-02-27 22:08     ` Laurent Pinchart
  0 siblings, 1 reply; 113+ messages in thread
From: Sam Ravnborg @ 2020-02-27 20:35 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen, kernel,
	Tony Lindgren, H. Nikolaus Schaller, Merlijn Wajer, dri-devel,
	linux-omap

Hi Sebastian.

On Tue, Feb 25, 2020 at 12:53:41PM +0100, Sebastian Reichel wrote:
> Convert panel-dsi-cm bindings to YAML and add
> missing properties while at it.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

As saind in previous mail - I prefer to convert ann then patch.
But end result is the same so OK.

> ---
>  .../bindings/display/panel/panel-dsi-cm.txt   | 31 ------
>  .../bindings/display/panel/panel-dsi-cm.yaml  | 97 +++++++++++++++++++
>  2 files changed, 97 insertions(+), 31 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
>  create mode 100644 Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml
> 
> diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> deleted file mode 100644
> index f92d5c9adfc5..000000000000
> --- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -Generic MIPI DSI Command Mode Panel
> -===================================
> -
> -Required properties:
> -- compatible: "panel-dsi-cm"
> -- reg: DSI channel number
> -
> -Optional properties:
> -- label: a symbolic name for the panel
> -- reset-gpios: panel reset gpio
> -- te-gpios: panel TE gpio
> -
> -Required nodes:
> -- Video port for DSI input
> -
> -Example
> --------
> -
> -lcd0: panel@0 {
> -	compatible = "tpo,taal", "panel-dsi-cm";
> -	label = "lcd0";
> -	reg = <0>;
> -
> -	reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
> -
> -	port {
> -		lcd0_in: endpoint {
> -			remote-endpoint = <&dsi1_out_ep>;
> -		};
> -	};
> -};
> diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml
> new file mode 100644
> index 000000000000..ca61171ae145
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml
> @@ -0,0 +1,97 @@
> +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/display/panel/panel-dsi-cm.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: DSI command mode panels
> +
> +maintainers:
> +  - Tomi Valkeinen <tomi.valkeinen@ti.com>
> +  - Sebastian Reichel <sre@kernel.org>
> +
> +description: |
> +  This binding file is a collection of the DSI panels that
> +  are usually driven in command mode. If no backlight is
> +  referenced via the optional backlight property, the DSI
> +  panel is assumed to have native backlight support.
> +  The panel may use an OF graph binding for the association
> +  to the display, or it may be a direct child node of the
> +  display.
> +
> +allOf:
> +  - $ref: panel-common.yaml#
> +
> +properties:
> +
> +  compatible:
> +    enum:
> +      # compatible must be listed in alphabetical order, ordered by compatible.
> +      # The description in the comment is mandatory for each compatible.
> +      - motorola,droid4-panel, panel-dsi-cm
> +      - nokia,himalaya, panel-dsi-cm
> +      - tpo,taal, panel-dsi-cm
Please consider to use the following syntax (from memory - may require
an enum:):

  compatible:
    description:
      Shall contain a panel specific compatible and "panel-dsi-cm"
      in that order.
    items:
      - oneOf:
          # Maybe add a short description of this panel
        - motorola,droid4-panel
          # Maybe add a short description of this panel
	- nokia,himalaya
          # Maybe add a short description of this panel
	- tpo,taal

      - const: panel-dsi-cm

Then panel-dsi-cm is always specified as a second mandatory compatible.



> +
> +  reg:
> +    maxItems: 1
> +    description: DSI virtual channel
> +
> +  te-gpios:
> +    maxItems: 1
> +    description:
> +      Specifier for a GPIO connected to the panel TE (tearing event) signal.
> +      The GPIO informs the system, that data should be sent to the display
> +      on rising edges of the GPIO to avoid (or reduce) tearing effects.
> +      Falling edge can be supported by inverting the GPIO specifier polarity
> +      flag.
te-gpios is used by several panels.
Please add it to panel-common with your nice description.

With the above addressed:
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>


	Sam

> +
> +  vddi-supply:
> +    description:
> +      Display panels require power to be supplied. While several panels need
> +      more than one power supply with panel-specific constraints governing the
> +      order and timings of the power supplies, in many cases a single power
> +      supply is sufficient, either because the panel has a single power rail, or
> +      because all its power rails can be driven by the same supply. In that case
> +      the vddi-supply property specifies the supply powering the panel as a
> +      phandle to a regulator.
> +
> +  vpnl-supply:
> +    description:
> +      When the display panel needs a second power supply, this property can be
> +      used in addition to vddi-supply. Both supplies will be enabled at the
> +      same time before the panel is being accessed.
> +
> +  width-mm: true
> +  height-mm: true
> +  label: true
> +  rotation: true
> +  panel-timing: true
> +  port: true
> +  reset-gpios: true
> +  backlight: true
> +
> +additionalProperties: false
> +
> +required:
> +  - compatible
> +  - port
> +  - reg
> +
> +examples:
> +  - |
> +    dsi1@12345678 {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +      panel@0 {
> +        compatible = "tpo,taal", "panel-dsi-cm";
> +        label = "lcd0";
> +        reg = <0>;
> +        reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
> +
> +        port {
> +          panel: endpoint {
> +            remote-endpoint = <&dsi1_out_ep>;
> +          };
> +        };
> +      };
> +    };
> -- 
> 2.25.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCHv2 57/56] dt-bindings: display: panel-dsi-cm: convert to YAML
  2020-02-27 20:35   ` Sam Ravnborg
@ 2020-02-27 22:08     ` Laurent Pinchart
  0 siblings, 0 replies; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-27 22:08 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sam Ravnborg, Sebastian Reichel, Tomi Valkeinen, kernel,
	Tony Lindgren, H. Nikolaus Schaller, Merlijn Wajer, dri-devel,
	linux-omap

Hi Sebastian,

Thank you for the patch.

On Thu, Feb 27, 2020 at 09:35:21PM +0100, Sam Ravnborg wrote:
> On Tue, Feb 25, 2020 at 12:53:41PM +0100, Sebastian Reichel wrote:
> > Convert panel-dsi-cm bindings to YAML and add
> > missing properties while at it.
> > 
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> 
> As saind in previous mail - I prefer to convert ann then patch.
> But end result is the same so OK.

I agree, splitting the patch would be better.

> > ---
> >  .../bindings/display/panel/panel-dsi-cm.txt   | 31 ------
> >  .../bindings/display/panel/panel-dsi-cm.yaml  | 97 +++++++++++++++++++
> >  2 files changed, 97 insertions(+), 31 deletions(-)
> >  delete mode 100644 Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> >  create mode 100644 Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> > deleted file mode 100644
> > index f92d5c9adfc5..000000000000
> > --- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt
> > +++ /dev/null
> > @@ -1,31 +0,0 @@
> > -Generic MIPI DSI Command Mode Panel
> > -===================================
> > -
> > -Required properties:
> > -- compatible: "panel-dsi-cm"
> > -- reg: DSI channel number
> > -
> > -Optional properties:
> > -- label: a symbolic name for the panel
> > -- reset-gpios: panel reset gpio
> > -- te-gpios: panel TE gpio
> > -
> > -Required nodes:
> > -- Video port for DSI input
> > -
> > -Example
> > --------
> > -
> > -lcd0: panel@0 {
> > -	compatible = "tpo,taal", "panel-dsi-cm";
> > -	label = "lcd0";
> > -	reg = <0>;
> > -
> > -	reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
> > -
> > -	port {
> > -		lcd0_in: endpoint {
> > -			remote-endpoint = <&dsi1_out_ep>;
> > -		};
> > -	};
> > -};
> > diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml
> > new file mode 100644
> > index 000000000000..ca61171ae145
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.yaml
> > @@ -0,0 +1,97 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/display/panel/panel-dsi-cm.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: DSI command mode panels
> > +
> > +maintainers:
> > +  - Tomi Valkeinen <tomi.valkeinen@ti.com>
> > +  - Sebastian Reichel <sre@kernel.org>
> > +
> > +description: |
> > +  This binding file is a collection of the DSI panels that
> > +  are usually driven in command mode. If no backlight is
> > +  referenced via the optional backlight property, the DSI
> > +  panel is assumed to have native backlight support.

Maybe this sentence could be moved to the description of the backlight
property ? Or would it override the description from panel-common.yaml ?
If so, is there a way in the yaml bindings syntax to extend that
property ?

> > +  The panel may use an OF graph binding for the association
> > +  to the display, or it may be a direct child node of the
> > +  display.
> > +
> > +allOf:
> > +  - $ref: panel-common.yaml#
> > +
> > +properties:
> > +
> > +  compatible:
> > +    enum:
> > +      # compatible must be listed in alphabetical order, ordered by compatible.
> > +      # The description in the comment is mandatory for each compatible.
> > +      - motorola,droid4-panel, panel-dsi-cm
> > +      - nokia,himalaya, panel-dsi-cm
> > +      - tpo,taal, panel-dsi-cm
>
> Please consider to use the following syntax (from memory - may require
> an enum:):
> 
>   compatible:
>     description:
>       Shall contain a panel specific compatible and "panel-dsi-cm"
>       in that order.
>     items:
>       - oneOf:
>           # Maybe add a short description of this panel
>         - motorola,droid4-panel
>           # Maybe add a short description of this panel
> 	- nokia,himalaya
>           # Maybe add a short description of this panel
> 	- tpo,taal
> 
>       - const: panel-dsi-cm
> 
> Then panel-dsi-cm is always specified as a second mandatory compatible.

This is not only nicer, but it's actually correct, while the original
version isn't. The original version would require, for instance,

	compatible = "motorola,droid4-panel, panel-dsi-cm";

and not

	compatible = "motorola,droid4-panel", "panel-dsi-cm";

> > +
> > +  reg:
> > +    maxItems: 1
> > +    description: DSI virtual channel
> > +
> > +  te-gpios:
> > +    maxItems: 1
> > +    description:
> > +      Specifier for a GPIO connected to the panel TE (tearing event) signal.
> > +      The GPIO informs the system, that data should be sent to the display
> > +      on rising edges of the GPIO to avoid (or reduce) tearing effects.
> > +      Falling edge can be supported by inverting the GPIO specifier polarity
> > +      flag.
>
> te-gpios is used by several panels.
> Please add it to panel-common with your nice description.

Possible too late to change this, but shouldn't we really have used

	interrupts = <...>;
	interrupt-names = "te";

?

The TE signal may be connected to an interrupt pin that is not a GPIO.

> With the above addressed:
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> 
> > +
> > +  vddi-supply:
> > +    description:
> > +      Display panels require power to be supplied. While several panels need
> > +      more than one power supply with panel-specific constraints governing the
> > +      order and timings of the power supplies, in many cases a single power
> > +      supply is sufficient, either because the panel has a single power rail, or
> > +      because all its power rails can be driven by the same supply. In that case
> > +      the vddi-supply property specifies the supply powering the panel as a
> > +      phandle to a regulator.
> > +
> > +  vpnl-supply:
> > +    description:
> > +      When the display panel needs a second power supply, this property can be
> > +      used in addition to vddi-supply. Both supplies will be enabled at the
> > +      same time before the panel is being accessed.

Too late for this too, but I wonder if the best practice for this kind
of cases wouldn't be to specify a single supply that would be modelled
by a regulator with multiple inputs.

> > +  width-mm: true
> > +  height-mm: true
> > +  label: true
> > +  rotation: true
> > +  panel-timing: true
> > +  port: true
> > +  reset-gpios: true
> > +  backlight: true
> > +
> > +additionalProperties: false
> > +
> > +required:
> > +  - compatible
> > +  - port

You wrote in the overall description that the panel may have a port node
or may be a child of the DSI controller. Doesn't that make port optional
?

Should we require width-mm and height-mm ?

> > +  - reg
> > +
> > +examples:
> > +  - |
> > +    dsi1@12345678 {
> > +      #address-cells = <1>;
> > +      #size-cells = <0>;
> > +      panel@0 {
> > +        compatible = "tpo,taal", "panel-dsi-cm";
> > +        label = "lcd0";
> > +        reg = <0>;
> > +        reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>;
> > +
> > +        port {
> > +          panel: endpoint {
> > +            remote-endpoint = <&dsi1_out_ep>;
> > +          };
> > +        };
> > +      };
> > +    };

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible
  2020-02-24 23:47     ` Tony Lindgren
@ 2020-02-27 22:10       ` Laurent Pinchart
  2020-02-28 15:34         ` Tony Lindgren
  0 siblings, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-02-27 22:10 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Sebastian Reichel, Sebastian Reichel, Tomi Valkeinen,
	Merlijn Wajer, H. Nikolaus Schaller, Rob Herring, linux-omap,
	dri-devel, kernel

Hi Tony,

On Mon, Feb 24, 2020 at 03:47:59PM -0800, Tony Lindgren wrote:
> * Laurent Pinchart <laurent.pinchart@ideasonboard.com> [200224 23:38]:
> > On Tue, Feb 25, 2020 at 12:20:32AM +0100, Sebastian Reichel wrote:
> > > Add Droid 4 specific compatible value in addition to the
> > > generic one, so that we have the ability to add panel
> > > specific quirks in the future.
> > 
> > We need to document this compatible string in DT bindings, I don't think
> > this is included in this series. Furthermore, could we use a compatible
> > string that actually matches the panel vendor and model, instead of the
> > device name ?
> 
> To me it seems there are multiple similar panels from various
> vendors in use for xt875/xt894/xt910/xt912 phones, I'm not sure
> if anybody has this list?

Are they all truly compatible ?

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible
  2020-02-27 22:10       ` Laurent Pinchart
@ 2020-02-28 15:34         ` Tony Lindgren
  0 siblings, 0 replies; 113+ messages in thread
From: Tony Lindgren @ 2020-02-28 15:34 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Sebastian Reichel, Tomi Valkeinen,
	Merlijn Wajer, H. Nikolaus Schaller, Rob Herring, linux-omap,
	dri-devel, kernel

* Laurent Pinchart <laurent.pinchart@ideasonboard.com> [200227 22:12]:
> Hi Tony,
> 
> On Mon, Feb 24, 2020 at 03:47:59PM -0800, Tony Lindgren wrote:
> > * Laurent Pinchart <laurent.pinchart@ideasonboard.com> [200224 23:38]:
> > > On Tue, Feb 25, 2020 at 12:20:32AM +0100, Sebastian Reichel wrote:
> > > > Add Droid 4 specific compatible value in addition to the
> > > > generic one, so that we have the ability to add panel
> > > > specific quirks in the future.
> > > 
> > > We need to document this compatible string in DT bindings, I don't think
> > > this is included in this series. Furthermore, could we use a compatible
> > > string that actually matches the panel vendor and model, instead of the
> > > device name ?
> > 
> > To me it seems there are multiple similar panels from various
> > vendors in use for xt875/xt894/xt910/xt912 phones, I'm not sure
> > if anybody has this list?
> 
> Are they all truly compatible ?

Well that is still unknown. We know that x894 panel config works with
xt875 at least. The panels are different looking the original dtb files.

Best to use device specific compatibles like Sebastian is doing.
If we ever get some real manufacturer and model data, we can add
that.

Regards,

Tony

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

* Re: [PATCHv2 03/56] Revert "drm/omap: dss: Remove unused omap_dss_device operations"
  2020-02-24 23:20 ` [PATCHv2 03/56] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Sebastian Reichel
@ 2020-03-25 12:42   ` Tomi Valkeinen
  0 siblings, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-03-25 12:42 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

Hi,

On 25/02/2020 01:20, Sebastian Reichel wrote:
> From: Sebastian Reichel <sre@kernel.org>
> 
> This reverts commit 4ff8e98879e6eeae9d125dfcf3b642075d00089d.
> ---
>   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(-)

This is missing description.

  Tomi

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

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

* Re: [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins
  2020-02-24 23:20 ` [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins Sebastian Reichel
  2020-02-24 23:42   ` Laurent Pinchart
@ 2020-03-25 12:45   ` Tomi Valkeinen
  1 sibling, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-03-25 12:45 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

On 25/02/2020 01:20, Sebastian Reichel wrote:
> 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>
> ---
>   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(-)

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

  Tomi

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (58 preceding siblings ...)
  2020-02-26 12:28 ` [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
@ 2020-03-25 12:47 ` Tomi Valkeinen
  2020-03-25 13:03   ` Laurent Pinchart
  2020-06-25 13:07 ` H. Nikolaus Schaller
  60 siblings, 1 reply; 113+ messages in thread
From: Tomi Valkeinen @ 2020-03-25 12:47 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

On 25/02/2020 01:20, Sebastian Reichel wrote:
> This updates the existing omapdrm DSI code, so that it uses
> common drm_mipi_dsi API and drm_panel.
> 
> The patchset has been tested with Droid 4 using Linux console, X.org and
> Weston. The patchset is based on Laurent Pinchartl's patch series [0]
> and removes the last custom panel driver, so quite a few cleanups on the
> omapdrm codebase were possible.

This is a big series, and I suggest to keep the cleanups to minimum. Things can be cleaned up 
afterwards after the functional parts of this series have been merged.

  Tomi


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

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

* Re: [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_*
  2020-02-24 23:20 ` [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Sebastian Reichel
  2020-02-25 13:58   ` Laurent Pinchart
@ 2020-03-25 12:52   ` Tomi Valkeinen
  1 sibling, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-03-25 12:52 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

On 25/02/2020 01:20, Sebastian Reichel wrote:
> This replaces OMAP specific enum for pixel format with
> common implementation.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>   .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   |  2 +-
>   drivers/gpu/drm/omapdrm/dss/dsi.c             | 49 +++++++------------
>   drivers/gpu/drm/omapdrm/dss/omapdss.h         | 10 +---
>   3 files changed, 20 insertions(+), 41 deletions(-)

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

  Tomi

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

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

* Re: [PATCHv2 06/56] drm/omap: constify write buffers
  2020-02-24 23:20 ` [PATCHv2 06/56] drm/omap: constify write buffers Sebastian Reichel
  2020-02-25 14:13   ` Laurent Pinchart
@ 2020-03-25 12:53   ` Tomi Valkeinen
  1 sibling, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-03-25 12:53 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

On 25/02/2020 01:20, Sebastian Reichel wrote:
> The write buffers are not modified, so they can be constant.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>   drivers/gpu/drm/omapdrm/dss/dsi.c     | 24 ++++++++++++------------
>   drivers/gpu/drm/omapdrm/dss/omapdss.h | 10 +++++-----
>   2 files changed, 17 insertions(+), 17 deletions(-)

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

  Tomi

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-03-25 12:47 ` Tomi Valkeinen
@ 2020-03-25 13:03   ` Laurent Pinchart
  2020-04-01 12:43     ` Tomi Valkeinen
  0 siblings, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-03-25 13:03 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Sebastian Reichel, Tony Lindgren,
	Merlijn Wajer, H. Nikolaus Schaller, Rob Herring, linux-omap,
	dri-devel, kernel

Hi Tomi,

On Wed, Mar 25, 2020 at 02:47:48PM +0200, Tomi Valkeinen wrote:
> On 25/02/2020 01:20, Sebastian Reichel wrote:
> > This updates the existing omapdrm DSI code, so that it uses
> > common drm_mipi_dsi API and drm_panel.
> > 
> > The patchset has been tested with Droid 4 using Linux console, X.org and
> > Weston. The patchset is based on Laurent Pinchartl's patch series [0]
> > and removes the last custom panel driver, so quite a few cleanups on the
> > omapdrm codebase were possible.
> 
> This is a big series, and I suggest to keep the cleanups to minimum.
> Things can be cleaned up afterwards after the functional parts of this
> series have been merged.

There are a few cleanups at the bottom of the series that could be
merged without waiting for the rest though :-)

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 07/56] drm/omap: dsi: add generic transfer function
  2020-02-24 23:20 ` [PATCHv2 07/56] drm/omap: dsi: add generic transfer function Sebastian Reichel
  2020-02-25 14:16   ` Laurent Pinchart
@ 2020-03-25 13:05   ` Tomi Valkeinen
  1 sibling, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-03-25 13:05 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

On 25/02/2020 01:20, Sebastian Reichel wrote:
> 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>
> ---
>   drivers/gpu/drm/omapdrm/dss/dsi.c     | 52 +++++++++++++++++++++++++++
>   drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ++
>   2 files changed, 55 insertions(+)

With the white-space issues Laurent reported fixed:

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

  Tomi

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

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

* Re: [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic
  2020-02-25 15:01   ` Laurent Pinchart
@ 2020-04-01 11:30     ` Tomi Valkeinen
  2020-04-01 11:33       ` Laurent Pinchart
  0 siblings, 1 reply; 113+ messages in thread
From: Tomi Valkeinen @ 2020-04-01 11:30 UTC (permalink / raw)
  To: Laurent Pinchart, Sebastian Reichel
  Cc: Sebastian Reichel, Tony Lindgren, Merlijn Wajer,
	H. Nikolaus Schaller, Rob Herring, linux-omap, dri-devel, kernel

On 25/02/2020 17:01, Laurent Pinchart wrote:
> Hi Sebastian,
> 
> Thank you for the patch.
> 
> On Tue, Feb 25, 2020 at 12:20:40AM +0100, Sebastian Reichel wrote:
>> 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.
> 
> I wonder why this level of indirection was used, allocating "virtual
> VCs". A single virtual indirection should be enough :-) I may be missing
> some context though, I'll defer that to Tomi, but for me,

I haven't reviewed the code yet, and it's been a long time since I wrote this code. But maybe this 
explains at least some:

(I hope I remember this right)

DSI packets have virtual channel IDs (VCID). That's number 0-3 that needs to be in the packets.

DSI IP has virtual channel "blocks" (VC), with associated registers. So 4 VC register blocks. These 
are not related to DSI virtual channel IDs in any way.

To do DSI transactions, you choose a VC, and program it. A VC can send data via video pipeline, or 
transmit and receive data messages created with CPU. And in both cases, you need to include the VCID 
in the transmissions, of course.

So, I think a normal use case could be a single panel, with VCID 0. To send video data and control 
messages, you would use VC0 and VC1. VC0 would be configured for video data, and VC1 would be 
configured for control messages.

And if I recall right, currently you first request a free VC from the IP with request_vc(). Then you 
use set_vc_id(channel, id) to set the VCID, used when doing transactions with that VC.

So the virtual channel naming is pretty confusing in the DSI IP, in my opinion.

  Tomi

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

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

* Re: [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic
  2020-04-01 11:30     ` Tomi Valkeinen
@ 2020-04-01 11:33       ` Laurent Pinchart
  2020-04-01 11:43         ` Tomi Valkeinen
  0 siblings, 1 reply; 113+ messages in thread
From: Laurent Pinchart @ 2020-04-01 11:33 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Sebastian Reichel, Sebastian Reichel, Tony Lindgren,
	Merlijn Wajer, H. Nikolaus Schaller, Rob Herring, linux-omap,
	dri-devel, kernel

Hi Tomi,

On Wed, Apr 01, 2020 at 02:30:25PM +0300, Tomi Valkeinen wrote:
> On 25/02/2020 17:01, Laurent Pinchart wrote:
> > On Tue, Feb 25, 2020 at 12:20:40AM +0100, Sebastian Reichel wrote:
> >> 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.
> > 
> > I wonder why this level of indirection was used, allocating "virtual
> > VCs". A single virtual indirection should be enough :-) I may be missing
> > some context though, I'll defer that to Tomi, but for me,
> 
> I haven't reviewed the code yet, and it's been a long time since I wrote this code. But maybe this 
> explains at least some:
> 
> (I hope I remember this right)
> 
> DSI packets have virtual channel IDs (VCID). That's number 0-3 that needs to be in the packets.
> 
> DSI IP has virtual channel "blocks" (VC), with associated registers. So 4 VC register blocks. These 
> are not related to DSI virtual channel IDs in any way.
> 
> To do DSI transactions, you choose a VC, and program it. A VC can send data via video pipeline, or 
> transmit and receive data messages created with CPU. And in both cases, you need to include the VCID 
> in the transmissions, of course.
> 
> So, I think a normal use case could be a single panel, with VCID 0. To send video data and control 
> messages, you would use VC0 and VC1. VC0 would be configured for video data, and VC1 would be 
> configured for control messages.
> 
> And if I recall right, currently you first request a free VC from the IP with request_vc(). Then you 
> use set_vc_id(channel, id) to set the VCID, used when doing transactions with that VC.
> 
> So the virtual channel naming is pretty confusing in the DSI IP, in my opinion.

I wasn't aware of those details, thank you for the explanation. It's
quite confusing indeed, let's try to document the architecture in a
comment block at the beginning of the dsi.c file for later reference.

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic
  2020-04-01 11:33       ` Laurent Pinchart
@ 2020-04-01 11:43         ` Tomi Valkeinen
  0 siblings, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-04-01 11:43 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Sebastian Reichel, Tony Lindgren,
	Merlijn Wajer, H. Nikolaus Schaller, Rob Herring, linux-omap,
	dri-devel, kernel

On 01/04/2020 14:33, Laurent Pinchart wrote:
> Hi Tomi,
> 
> On Wed, Apr 01, 2020 at 02:30:25PM +0300, Tomi Valkeinen wrote:
>> On 25/02/2020 17:01, Laurent Pinchart wrote:
>>> On Tue, Feb 25, 2020 at 12:20:40AM +0100, Sebastian Reichel wrote:
>>>> 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.
>>>
>>> I wonder why this level of indirection was used, allocating "virtual
>>> VCs". A single virtual indirection should be enough :-) I may be missing
>>> some context though, I'll defer that to Tomi, but for me,
>>
>> I haven't reviewed the code yet, and it's been a long time since I wrote this code. But maybe this
>> explains at least some:
>>
>> (I hope I remember this right)
>>
>> DSI packets have virtual channel IDs (VCID). That's number 0-3 that needs to be in the packets.
>>
>> DSI IP has virtual channel "blocks" (VC), with associated registers. So 4 VC register blocks. These
>> are not related to DSI virtual channel IDs in any way.
>>
>> To do DSI transactions, you choose a VC, and program it. A VC can send data via video pipeline, or
>> transmit and receive data messages created with CPU. And in both cases, you need to include the VCID
>> in the transmissions, of course.
>>
>> So, I think a normal use case could be a single panel, with VCID 0. To send video data and control
>> messages, you would use VC0 and VC1. VC0 would be configured for video data, and VC1 would be
>> configured for control messages.
>>
>> And if I recall right, currently you first request a free VC from the IP with request_vc(). Then you
>> use set_vc_id(channel, id) to set the VCID, used when doing transactions with that VC.
>>
>> So the virtual channel naming is pretty confusing in the DSI IP, in my opinion.
> 
> I wasn't aware of those details, thank you for the explanation. It's
> quite confusing indeed, let's try to document the architecture in a
> comment block at the beginning of the dsi.c file for later reference.

But also, I think there's much room for cleanups and improvements. I don't think we have ever really 
supported multiple DSI peripherals, even in theory. So just one peripheral, with VCID always 0.

Even if we need two VCs to manage that single peripheral (I think that's often the case, we want one 
VC for video, one for control), we could fully hide that detail into the driver. This won't work 
with more than 2 DSI peripherals, but I think we can just say the driver supports a single 
peripheral, and that's it.

But with a quick browsing of this patch, I don't think it does it right, as it looks to me that the 
patch makes VCID == VC.

  Tomi

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

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

* Re: [PATCHv2 18/56] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines
  2020-02-24 23:20 ` [PATCHv2 18/56] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Sebastian Reichel
@ 2020-04-01 12:09   ` Tomi Valkeinen
  0 siblings, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-04-01 12:09 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

On 25/02/2020 01:20, Sebastian Reichel wrote:
> Drop local definition of common MIPI DCS 1.3 defines.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>   drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)

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

  Tomi

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

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

* Re: [PATCHv2 41/56] drm/omap: dsi: return proper error code from dsi_update_all()
  2020-02-24 23:21 ` [PATCHv2 41/56] drm/omap: dsi: return proper error code from dsi_update_all() Sebastian Reichel
@ 2020-04-01 12:23   ` Tomi Valkeinen
  0 siblings, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-04-01 12:23 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Laurent Pinchart
  Cc: Tony Lindgren, Merlijn Wajer, H. Nikolaus Schaller, Rob Herring,
	linux-omap, dri-devel, kernel

On 25/02/2020 01:21, Sebastian Reichel wrote:
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>   drivers/gpu/drm/omapdrm/dss/dsi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
> index acbfffe83b3e..f629e6b1025b 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dsi.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
> @@ -3987,7 +3987,7 @@ static int dsi_update_all(struct omap_dss_device *dssdev)
>   			return r;
>   	}
>   
> -	return 0;
> +	return r;
>   }
>   
>   /* Display funcs */
> 

Shouldn't this be squashed to earlier patch?

  Tomi

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-03-25 13:03   ` Laurent Pinchart
@ 2020-04-01 12:43     ` Tomi Valkeinen
  0 siblings, 0 replies; 113+ messages in thread
From: Tomi Valkeinen @ 2020-04-01 12:43 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Sebastian Reichel, Sebastian Reichel, Tony Lindgren,
	Merlijn Wajer, H. Nikolaus Schaller, Rob Herring, linux-omap,
	dri-devel, kernel

On 25/03/2020 15:03, Laurent Pinchart wrote:
> Hi Tomi,
> 
> On Wed, Mar 25, 2020 at 02:47:48PM +0200, Tomi Valkeinen wrote:
>> On 25/02/2020 01:20, Sebastian Reichel wrote:
>>> This updates the existing omapdrm DSI code, so that it uses
>>> common drm_mipi_dsi API and drm_panel.
>>>
>>> The patchset has been tested with Droid 4 using Linux console, X.org and
>>> Weston. The patchset is based on Laurent Pinchartl's patch series [0]
>>> and removes the last custom panel driver, so quite a few cleanups on the
>>> omapdrm codebase were possible.
>>
>> This is a big series, and I suggest to keep the cleanups to minimum.
>> Things can be cleaned up afterwards after the functional parts of this
>> series have been merged.
> 
> There are a few cleanups at the bottom of the series that could be
> merged without waiting for the rest though :-)

Yep. So, Sebastian, if there are patches that can be applied independently of this series, can you 
send those separately or move them to the beginning of the series.

There was also the change to include/drm/drm_mipi_dsi.h which is outside the OMAP context. Maybe 
send that separately to the relevant maintainers. Or at least cc them, as now it's kind of hidden 
between all the omap changes.

And I need to try to wake up one of my boards with a DSI video mode display for testing...

  Tomi

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

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

* Re: [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel
  2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
                   ` (59 preceding siblings ...)
  2020-03-25 12:47 ` Tomi Valkeinen
@ 2020-06-25 13:07 ` H. Nikolaus Schaller
  60 siblings, 0 replies; 113+ messages in thread
From: H. Nikolaus Schaller @ 2020-06-25 13:07 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Laurent Pinchart, Tomi Valkeinen,
	Tony Lindgren, Merlijn Wajer, Rob Herring, Linux-OMAP,
	open list:DRM PANEL DRIVERS, kernel, kernel,
	Discussions about the Letux Kernel, David Shah

Hi Sebastian,

> Am 25.02.2020 um 00:20 schrieb Sebastian Reichel <sebastian.reichel@collabora.com>:
> 
> This updates the existing omapdrm DSI code, so that it uses
> common drm_mipi_dsi API and drm_panel.
> 
> The patchset has been tested with Droid 4 using Linux console, X.org and
> Weston. The patchset is based on Laurent Pinchartl's patch series [0]
> and removes the last custom panel driver, so quite a few cleanups on the
> omapdrm codebase were possible.
> 
> [0] [PATCH v7 00/54] drm/omap: Replace custom display drivers with drm_bridge and drm_panel
>    https://lore.kernel.org/dri-devel/20200222150106.22919-1-laurent.pinchart@ideasonboard.com/
>    git://linuxtv.org/pinchartl/media.git omapdrm/bridge/devel
> 
> I pushed this patchset into the following branch:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-n900.git omapdrm/bridge/devel-with-dsi
> 
> The previous version of this patchset has been sent quite some time ago.
> This version has been rebased and required cleaning up most of the
> hacks. I do not have a detailed changelog, but quite a few things
> changed. I decided against doing anything special for the DT change
> (adding DSI channel number), since only 3 devices are affected. It is
> quite likely, that all developers of those devices update DT together
> with kernel for those devices. My suggestion is to merge the first two
> patches ASAP and backport to stable, since it does not affect old
> kernels and the change is rather small.
> 
> RFCv1: https://lore.kernel.org/dri-devel/20191117023946.VjCC3yE08DMx7JIKxNagPoT5et7WTnKGVV6MtOtB9Ro@z/

is there something new for this series? Is there a repo where it has been rebased to v5.8-rc1 (and tested)?

Our Pyra MIPI/DSI omap5 panel setup is broken by upstream changes since v5.7-rc1 and I am not sure if it is better to search in the old omapdrm code what is missing now. Or to wait for your DSI code and just update/fix our panel driver (and have a chance to get that one upstream).

BR and thanks,
Nikolaus


> 
> -- Sebastian
> 
> Sebastian Reichel (56):
>  ARM: dts: omap: add channel to DSI panels
>  ARM: dts: omap4-droid4: add panel compatible
>  Revert "drm/omap: dss: Remove unused omap_dss_device operations"
>  omap/drm: 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/dsi: add MIPI_DSI_MODE_ULPS_IDLE
>  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: dsi: return proper error code from dsi_update_all()
>  drm/omap: remove global dss_device variable
>  drm/omap: bind components with drm_device argument
>  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 empty omap_encoder helper functions
>  drm/omap: drop DSS ops_flags
>  drm/omap: drop dssdev display field
>  drm/omap: simplify DSI manual update code
>  ARM: omap2plus_defconfig: Update for moved DSI command mode panel
>  drm/panel/panel-dsi-cm: support rotation property
>  ARM: dts: omap4-droid4: add panel orientation
> 
> .../bindings/display/panel/panel-dsi-cm.txt   |    4 +-
> .../boot/dts/motorola-mapphone-common.dtsi    |    6 +-
> arch/arm/boot/dts/omap3-n950.dts              |    3 +-
> arch/arm/boot/dts/omap3.dtsi                  |    3 +
> arch/arm/boot/dts/omap4-sdp.dts               |    6 +-
> arch/arm/boot/dts/omap4.dtsi                  |    6 +
> arch/arm/boot/dts/omap5.dtsi                  |    6 +
> arch/arm/configs/omap2plus_defconfig          |    2 +-
> drivers/gpu/drm/omapdrm/Kconfig               |    1 -
> drivers/gpu/drm/omapdrm/Makefile              |    2 -
> drivers/gpu/drm/omapdrm/displays/Kconfig      |   10 -
> drivers/gpu/drm/omapdrm/displays/Makefile     |    2 -
> .../gpu/drm/omapdrm/displays/panel-dsi-cm.c   | 1387 -----------------
> drivers/gpu/drm/omapdrm/dss/Kconfig           |    4 +-
> drivers/gpu/drm/omapdrm/dss/Makefile          |    2 -
> drivers/gpu/drm/omapdrm/dss/base.c            |   58 +-
> drivers/gpu/drm/omapdrm/dss/dsi.c             | 1034 +++++++-----
> drivers/gpu/drm/omapdrm/dss/dss.c             |   44 +-
> .../gpu/drm/omapdrm/dss/omapdss-boot-init.c   |  220 ---
> drivers/gpu/drm/omapdrm/dss/omapdss.h         |  141 +-
> drivers/gpu/drm/omapdrm/dss/output.c          |   13 +-
> drivers/gpu/drm/omapdrm/dss/venc.c            |    1 -
> drivers/gpu/drm/omapdrm/omap_connector.c      |  157 --
> drivers/gpu/drm/omapdrm/omap_connector.h      |   28 -
> drivers/gpu/drm/omapdrm/omap_crtc.c           |   35 +-
> drivers/gpu/drm/omapdrm/omap_drv.c            |   49 +-
> drivers/gpu/drm/omapdrm/omap_drv.h            |    1 -
> drivers/gpu/drm/omapdrm/omap_encoder.c        |   59 +-
> drivers/gpu/drm/panel/Kconfig                 |    9 +
> drivers/gpu/drm/panel/Makefile                |    1 +
> drivers/gpu/drm/panel/panel-dsi-cm.c          |  674 ++++++++
> include/drm/drm_mipi_dsi.h                    |    2 +
> 32 files changed, 1465 insertions(+), 2505 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/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
> 
> 
> base-commit: 54ba965bb3873eca6098ddf04e3a8d7bba1b5557
> -- 
> 2.25.0
> 


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

end of thread, other threads:[~2020-06-25 13:07 UTC | newest]

Thread overview: 113+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 23:20 [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels Sebastian Reichel
2020-02-24 23:38   ` Laurent Pinchart
2020-02-25  0:01     ` Sebastian Reichel
2020-02-27 20:09   ` Sam Ravnborg
2020-02-24 23:20 ` [PATCHv2 02/56] ARM: dts: omap4-droid4: add panel compatible Sebastian Reichel
2020-02-24 23:37   ` Laurent Pinchart
2020-02-24 23:47     ` Tony Lindgren
2020-02-27 22:10       ` Laurent Pinchart
2020-02-28 15:34         ` Tony Lindgren
2020-02-24 23:57     ` Sebastian Reichel
2020-02-27 20:10   ` Sam Ravnborg
2020-02-24 23:20 ` [PATCHv2 03/56] Revert "drm/omap: dss: Remove unused omap_dss_device operations" Sebastian Reichel
2020-03-25 12:42   ` Tomi Valkeinen
2020-02-24 23:20 ` [PATCHv2 04/56] omap/drm: drop unused dsi.configure_pins Sebastian Reichel
2020-02-24 23:42   ` Laurent Pinchart
2020-02-26 21:28     ` Sebastian Reichel
2020-02-26 21:36       ` Laurent Pinchart
2020-02-26 22:25         ` Sebastian Reichel
2020-03-25 12:45   ` Tomi Valkeinen
2020-02-24 23:20 ` [PATCHv2 05/56] drm/omap: dsi: use MIPI_DSI_FMT_* instead of OMAP_DSS_DSI_FMT_* Sebastian Reichel
2020-02-25 13:58   ` Laurent Pinchart
2020-02-26 21:25     ` Sebastian Reichel
2020-03-25 12:52   ` Tomi Valkeinen
2020-02-24 23:20 ` [PATCHv2 06/56] drm/omap: constify write buffers Sebastian Reichel
2020-02-25 14:13   ` Laurent Pinchart
2020-03-25 12:53   ` Tomi Valkeinen
2020-02-24 23:20 ` [PATCHv2 07/56] drm/omap: dsi: add generic transfer function Sebastian Reichel
2020-02-25 14:16   ` Laurent Pinchart
2020-03-25 13:05   ` Tomi Valkeinen
2020-02-24 23:20 ` [PATCHv2 08/56] drm/omap: panel-dsi-cm: convert to transfer API Sebastian Reichel
2020-02-25 14:52   ` Laurent Pinchart
2020-02-26 22:12     ` Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 09/56] drm/omap: dsi: unexport specific data transfer functions Sebastian Reichel
2020-02-25 14:53   ` Laurent Pinchart
2020-02-24 23:20 ` [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic Sebastian Reichel
2020-02-25 15:01   ` Laurent Pinchart
2020-04-01 11:30     ` Tomi Valkeinen
2020-04-01 11:33       ` Laurent Pinchart
2020-04-01 11:43         ` Tomi Valkeinen
2020-02-24 23:20 ` [PATCHv2 11/56] drm/omap: dsi: simplify write function Sebastian Reichel
2020-02-25 15:31   ` Laurent Pinchart
2020-02-26 22:46     ` Sebastian Reichel
2020-02-26 22:48       ` Laurent Pinchart
2020-02-24 23:20 ` [PATCHv2 12/56] drm/omap: dsi: simplify read functions Sebastian Reichel
2020-02-25 16:20   ` Laurent Pinchart
2020-02-24 23:20 ` [PATCHv2 13/56] drm/omap: dsi: switch dsi_vc_send_long/short to mipi_dsi_msg Sebastian Reichel
2020-02-25 16:30   ` Laurent Pinchart
2020-02-26 23:34     ` Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 14/56] drm/omap: dsi: introduce mipi_dsi_host Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 15/56] drm/omap: panel-dsi-cm: use DSI helpers Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 16/56] drm/omap: dsi: request VC via mipi_dsi_attach Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 17/56] drm/omap: panel-dsi-cm: drop hardcoded VC Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 18/56] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Sebastian Reichel
2020-04-01 12:09   ` Tomi Valkeinen
2020-02-24 23:20 ` [PATCHv2 19/56] drm/omap: dsi: drop unused memory_read() Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 20/56] drm/omap: dsi: drop unused get_te() Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 21/56] drm/omap: dsi: drop unused enable_te() Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 22/56] drm/omap: dsi: drop useless sync() Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 23/56] drm/omap: dsi: use pixel-format and mode from attach Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 24/56] drm/omap: panel-dsi-cm: use bulk regulator API Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 25/56] drm/omap: dsi: lp/hs switching support for transfer() Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 26/56] drm/omap: dsi: move TE GPIO handling into core Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 27/56] drm/omap: dsi: drop custom enable_te() API Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 28/56] drm/omap: dsi: do bus locking in host driver Sebastian Reichel
2020-02-24 23:20 ` [PATCHv2 29/56] drm/omap: dsi: untangle ulps ops from enable/disable Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 30/56] drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 31/56] drm/omap: dsi: do ULPS in host driver Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 32/56] drm/omap: dsi: move panel refresh function to host Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 33/56] drm/omap: dsi: Reverse direction of the DSS device enable/disable operations Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 34/56] drm/omap: dsi: drop custom panel capability support Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 35/56] drm/omap: dsi: convert to drm_panel Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 36/56] drm/omap: drop omapdss-boot-init Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 37/56] drm/omap: dsi: implement check timings Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 38/56] drm/omap: panel-dsi-cm: use DEVICE_ATTR_RO Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 39/56] drm/omap: panel-dsi-cm: support unbinding Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 40/56] drm/omap: panel-dsi-cm: fix remove() Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 41/56] drm/omap: dsi: return proper error code from dsi_update_all() Sebastian Reichel
2020-04-01 12:23   ` Tomi Valkeinen
2020-02-24 23:21 ` [PATCHv2 42/56] drm/omap: remove global dss_device variable Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 43/56] drm/omap: bind components with drm_device argument Sebastian Reichel
2020-02-27  0:32   ` Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 44/56] drm/panel: Move OMAP's DSI command mode panel driver Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 45/56] drm/omap: dsi: Register a drm_bridge Sebastian Reichel
2020-02-25 11:50   ` [PATCHv2.1 " Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 46/56] drm/omap: remove legacy DSS device operations Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 47/56] drm/omap: remove unused omap_connector Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 48/56] drm/omap: simplify omap_display_id Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 49/56] drm/omap: drop unused DSS next pointer Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 50/56] drm/omap: drop empty omap_encoder helper functions Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 51/56] drm/omap: drop DSS ops_flags Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 52/56] drm/omap: drop dssdev display field Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 53/56] drm/omap: simplify DSI manual update code Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 54/56] ARM: omap2plus_defconfig: Update for moved DSI command mode panel Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 55/56] drm/panel/panel-dsi-cm: support rotation property Sebastian Reichel
2020-02-24 23:21 ` [PATCHv2 56/56] ARM: dts: omap4-droid4: add panel orientation Sebastian Reichel
2020-02-25  0:10 ` [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Tony Lindgren
2020-02-25  2:28   ` Sebastian Reichel
2020-02-25 15:42     ` Tony Lindgren
2020-02-25 23:01       ` Sebastian Reichel
2020-02-25 23:06         ` Laurent Pinchart
2020-02-25 23:09         ` Tony Lindgren
2020-02-25 23:52           ` Sebastian Reichel
2020-02-26 12:20             ` Tomi Valkeinen
2020-02-25 11:53 ` [PATCHv2 57/56] dt-bindings: display: panel-dsi-cm: convert to YAML Sebastian Reichel
2020-02-27 20:35   ` Sam Ravnborg
2020-02-27 22:08     ` Laurent Pinchart
2020-02-26 12:28 ` [PATCHv2 00/56] drm/omap: Convert DSI code to use drm_mipi_dsi and drm_panel Tomi Valkeinen
2020-02-27  0:28   ` Sebastian Reichel
2020-03-25 12:47 ` Tomi Valkeinen
2020-03-25 13:03   ` Laurent Pinchart
2020-04-01 12:43     ` Tomi Valkeinen
2020-06-25 13:07 ` H. Nikolaus Schaller

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).