Skip to contentSkip to conversation

drm/i915: port dsi over to drm panel/dsi frameworks

RFC PATCH In review Jani Nikula 4 participants 45 messages Jan 16, 2015 – Jan 29, 2015

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

cover drm/i915: port dsi over to drm panel/dsi frameworks

This series ports our DSI code over to the drm_panel and mipi_dsi_host/mipi_dsi_device. There are some rough edges towards the end of the series, see commit message for patch 8 for details.

Patches 1-6 are prep work, fairly independent

Patch 7 ports the driver over to drm_panel

Patches 8-10 port the driver over to mipi_dsi_host/device

Patches 11-12 do some additional cleanup

BR,
Jani.

Jani Nikula (12):
drm/i915/dsi: call dpi_send_cmd() for each dsi port at a higher level drm/i915/dsi: set max return packet size for each dsi port drm/i915/dsi: move wait_for_dsi_fifo_empty to intel_dsi.c drm/i915/dsi: call wait_for_dsi_fifo_empty() for each dsi port drm/i915/dsi: remove unnecessary dsi device callbacks drm/i915/dsi: add some constness to vbt panel driver drm/i915/dsi: switch to drm_panel interface
drm/i915/dsi: add drm mipi dsi host support
drm/i915/dsi: make the vbt panel driver use mipi_dsi_device for
transfers
drm/i915/dsi: remove old read/write functions in favor of new stuff drm/i915/dsi: move dpi_send_cmd() to intel_dsi.c and make it static drm/i915/dsi: remove intel_dsi_cmd.c and the unused functions therein

 drivers/gpu/drm/i915/Kconfig               |   2 +
 drivers/gpu/drm/i915/Makefile              |   1 -
 drivers/gpu/drm/i915/intel_dsi.c           | 336 +++++++++++++++++-----
 drivers/gpu/drm/i915/intel_dsi.h           |  69 ++---
 drivers/gpu/drm/i915/intel_dsi_cmd.c       | 432 -----------------------------
 drivers/gpu/drm/i915/intel_dsi_cmd.h       |  78 ------
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 289 ++++++++++---------
 7 files changed, 441 insertions(+), 766 deletions(-)
 delete mode 100644 drivers/gpu/drm/i915/intel_dsi_cmd.c
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

RFC PATCH 1/12 drm/i915/dsi: call dpi_send_cmd() for each dsi port at a higher level

Instead of having the for each dsi port loop within dpi_send_cmd(), add a port parameter to the function and call it for each port instead.

This is a rewrite of

commit 4510cd779e5897eeb8691aecbd639bb62ec27d55

Author: Gaurav K Singh <[email protected]>
Date:   Thu Dec 4 10:58:51 2014 +0530

drm/i915: Dual link needs Shutdown and Turn on packet for both ports

to add more flexibility in using dpi_send_cmd() for just one port as necessary. No functional changes.

---
 drivers/gpu/drm/i915/intel_dsi.c     |  7 +++++--
 drivers/gpu/drm/i915/intel_dsi_cmd.c | 26 ++++++++++----------------
 drivers/gpu/drm/i915/intel_dsi_cmd.h |  2 +-
 3 files changed, 16 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +5 -2
index 42b6d6f5cecc..36b19c7e87b9 100644
@@ -207,7 +207,8 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 		I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
 	else {
 		msleep(20); /* XXX */
-		dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN);
+		for_each_dsi_port(port, intel_dsi->ports)
+			dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN, port);
 		msleep(100);
 
 		if (intel_dsi->dev.dev_ops->enable)
@@ -275,12 +276,14 @@ static void intel_dsi_enable_nop(struct intel_encoder *encoder)
 static void intel_dsi_pre_disable(struct intel_encoder *encoder)
 {
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	enum port port;
 
 	DRM_DEBUG_KMS("\n");
 
 	if (is_vid_mode(intel_dsi)) {
 		/* Send Shutdown command to the panel in LP mode */
-		dpi_send_cmd(intel_dsi, SHUTDOWN, DPI_LP_MODE_EN);
+		for_each_dsi_port(port, intel_dsi->ports)
+			dpi_send_cmd(intel_dsi, SHUTDOWN, DPI_LP_MODE_EN, port);
 		msleep(10);
 	}
 }
drivers/gpu/drm/i915/intel_dsi_cmd.c +10 -16
index 562811c1a9d2..5f63c807acea 100644
@@ -380,12 +380,11 @@ int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
  *
  * XXX: commands with data in MIPI_DPI_DATA?
  */
-int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs)
+int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port)
 {
 	struct drm_encoder *encoder = &intel_dsi->base.base;
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum port port;
 	u32 mask;
 
 	/* XXX: pipe, hs */
@@ -394,23 +393,18 @@ int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs)
 	else
 		cmd |= DPI_LP_MODE;
 
-	for_each_dsi_port(port, intel_dsi->ports) {
-		/* clear bit */
-		I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
+	/* clear bit */
+	I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
 
-		/* XXX: old code skips write if control unchanged */
-		if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
-			DRM_ERROR("Same special packet %02x twice in a row.\n",
-									cmd);
+	/* XXX: old code skips write if control unchanged */
+	if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
+		DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
 
-		I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
+	I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
 
-		mask = SPL_PKT_SENT_INTERRUPT;
-		if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask,
-									100))
-			DRM_ERROR("Video mode command 0x%08x send failed.\n",
-									cmd);
-	}
+	mask = SPL_PKT_SENT_INTERRUPT;
+	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 100))
+		DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
 
 	return 0;
 }
drivers/gpu/drm/i915/intel_dsi_cmd.h +1 -1
index 326a5ac55561..1d1a716e473a 100644
@@ -51,7 +51,7 @@ int dsi_vc_dcs_read(struct intel_dsi *intel_dsi, int channel, u8 dcs_cmd,
 int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
 		u8 *reqdata, int reqlen, u8 *buf, int buflen, enum port port);
 
-int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs);
+int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port);
 void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi);
 
 /* XXX: questionable write helpers */
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

RFC PATCH 2/12 drm/i915/dsi: set max return packet size for each dsi port

In reply to Jani Nikula

This seems like the right thing to do. This also gets rid of a call to intel_dsi_pipe_to_port() which we want to remove eventually.

---
 drivers/gpu/drm/i915/intel_dsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +3 -3
index 36b19c7e87b9..49e186bc080f 100644
@@ -197,14 +197,14 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 {
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
+	enum port port;
 
 	DRM_DEBUG_KMS("\n");
 
 	if (is_cmd_mode(intel_dsi))
-		I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
+		for_each_dsi_port(port, intel_dsi->ports)
+			I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
 	else {
 		msleep(20); /* XXX */
 		for_each_dsi_port(port, intel_dsi->ports)
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

RFC PATCH 3/12 drm/i915/dsi: move wait_for_dsi_fifo_empty to intel_dsi.c

In reply to Jani Nikula

wait_for_dsi_fifo_empty can be static in intel_dsi.c. No functional changes.

---
 drivers/gpu/drm/i915/intel_dsi.c     | 16 ++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi_cmd.c | 16 ----------------
 drivers/gpu/drm/i915/intel_dsi_cmd.h |  1 -
 3 files changed, 16 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +16 -0
index 49e186bc080f..e82cf5f65c9a 100644
@@ -42,6 +42,22 @@ static const struct intel_dsi_device intel_dsi_devices[] = {
 	},
 };
 
+static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi)
+{
+	struct drm_encoder *encoder = &intel_dsi->base.base;
+	struct drm_device *dev = encoder->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
+	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
+	u32 mask;
+
+	mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
+		LP_DATA_FIFO_EMPTY | HS_DATA_FIFO_EMPTY;
+
+	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 100))
+		DRM_ERROR("DPI FIFOs are not empty\n");
+}
+
 static void band_gap_reset(struct drm_i915_private *dev_priv)
 {
 	mutex_lock(&dev_priv->dpio_lock);
drivers/gpu/drm/i915/intel_dsi_cmd.c +0 -16
index 5f63c807acea..17b892a365ee 100644
@@ -408,19 +408,3 @@ int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port)
 
 	return 0;
 }
-
-void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
-	u32 mask;
-
-	mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
-		LP_DATA_FIFO_EMPTY | HS_DATA_FIFO_EMPTY;
-
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 100))
-		DRM_ERROR("DPI FIFOs are not empty\n");
-}
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -1
index 1d1a716e473a..70f24666a1f9 100644
@@ -52,7 +52,6 @@ int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
 		u8 *reqdata, int reqlen, u8 *buf, int buflen, enum port port);
 
 int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port);
-void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi);
 
 /* XXX: questionable write helpers */
 static inline int dsi_vc_dcs_write_0(struct intel_dsi *intel_dsi,
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

RFC PATCH 4/12 drm/i915/dsi: call wait_for_dsi_fifo_empty() for each dsi port

In reply to Jani Nikula

Add port parameter to wait_for_dsi_fifo_empty, and call it for each dsi port.

We can now remove the transitional intel_dsi_pipe_to_port() function.

---
 drivers/gpu/drm/i915/intel_dsi.c | 17 ++++++++++-------
 drivers/gpu/drm/i915/intel_dsi.h | 12 ------------
 2 files changed, 10 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +10 -7
index e82cf5f65c9a..9b0eaa9db845 100644
@@ -42,13 +42,11 @@ static const struct intel_dsi_device intel_dsi_devices[] = {
 	},
 };
 
-static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi)
+static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi, enum port port)
 {
 	struct drm_encoder *encoder = &intel_dsi->base.base;
 	struct drm_device *dev = encoder->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
 	u32 mask;
 
 	mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
@@ -230,7 +228,8 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 		if (intel_dsi->dev.dev_ops->enable)
 			intel_dsi->dev.dev_ops->enable(&intel_dsi->dev);
 
-		wait_for_dsi_fifo_empty(intel_dsi);
+		for_each_dsi_port(port, intel_dsi->ports)
+			wait_for_dsi_fifo_empty(intel_dsi, port);
 
 		intel_dsi_port_enable(encoder);
 	}
@@ -243,6 +242,7 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
 	enum pipe pipe = intel_crtc->pipe;
+	enum port port;
 	u32 tmp;
 
 	DRM_DEBUG_KMS("\n");
@@ -272,7 +272,8 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 	if (intel_dsi->dev.dev_ops->send_otp_cmds)
 		intel_dsi->dev.dev_ops->send_otp_cmds(&intel_dsi->dev);
 
-	wait_for_dsi_fifo_empty(intel_dsi);
+	for_each_dsi_port(port, intel_dsi->ports)
+		wait_for_dsi_fifo_empty(intel_dsi, port);
 
 	/* Enable port in pre-enable phase itself because as per hw team
 	 * recommendation, port should be enabled befor plane & pipe */
@@ -315,7 +316,8 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 	DRM_DEBUG_KMS("\n");
 
 	if (is_vid_mode(intel_dsi)) {
-		wait_for_dsi_fifo_empty(intel_dsi);
+		for_each_dsi_port(port, intel_dsi->ports)
+			wait_for_dsi_fifo_empty(intel_dsi, port);
 
 		intel_dsi_port_disable(encoder);
 		msleep(2);
@@ -344,7 +346,8 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
 	if (intel_dsi->dev.dev_ops->disable)
 		intel_dsi->dev.dev_ops->disable(&intel_dsi->dev);
 
-	wait_for_dsi_fifo_empty(intel_dsi);
+	for_each_dsi_port(port, intel_dsi->ports)
+		wait_for_dsi_fifo_empty(intel_dsi, port);
 }
 
 static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_dsi.h +0 -12
index 8fe2064dd804..2bb8c46c7889 100644
@@ -137,18 +137,6 @@ struct intel_dsi {
 	u16 panel_pwr_cycle_delay;
 };
 
-/* XXX: Transitional before dual port configuration */
-static inline enum port intel_dsi_pipe_to_port(enum pipe pipe)
-{
-	if (pipe == PIPE_A)
-		return PORT_A;
-	else if (pipe == PIPE_B)
-		return PORT_C;
-
-	WARN(1, "DSI on pipe %c, assuming port C\n", pipe_name(pipe));
-	return PORT_C;
-}
-
 #define for_each_dsi_port(__port, __ports_mask) \
 	for ((__port) = PORT_A; (__port) < I915_MAX_PORTS; (__port)++)	\
 		if ((__ports_mask) & (1 << (__port)))
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

RFC PATCH 5/12 drm/i915/dsi: remove unnecessary dsi device callbacks

In reply to Jani Nikula

Remove all the trivial and/or dummy callbacks from intel dsi device ops. Merge send_otp_cmds into panel_reset as they're called back to back.

This will be helpful for switching to use drm_panel for the callbacks. If we ever need the additional callbacks, we should add them to drm_panel funcs.

---
 drivers/gpu/drm/i915/intel_dsi.c           | 32 ++-------------------
 drivers/gpu/drm/i915/intel_dsi.h           | 20 -------------
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 45 ++----------------------------
 3 files changed, 5 insertions(+), 92 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +2 -30
index 9b0eaa9db845..fc218b7754b3 100644
@@ -70,12 +70,6 @@ static void band_gap_reset(struct drm_i915_private *dev_priv)
 	mutex_unlock(&dev_priv->dpio_lock);
 }
 
-static struct intel_dsi *intel_attached_dsi(struct drm_connector *connector)
-{
-	return container_of(intel_attached_encoder(connector),
-			    struct intel_dsi, base);
-}
-
 static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
 {
 	return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE;
@@ -99,7 +93,6 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
 	struct intel_connector *intel_connector = intel_dsi->attached_connector;
 	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
 	struct drm_display_mode *adjusted_mode = &config->adjusted_mode;
-	struct drm_display_mode *mode = &config->requested_mode;
 
 	DRM_DEBUG_KMS("\n");
 
@@ -109,10 +102,6 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
 	/* DSI uses short packets for sync events, so clear mode flags for DSI */
 	adjusted_mode->flags = 0;
 
-	if (intel_dsi->dev.dev_ops->mode_fixup)
-		return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev,
-							  mode, adjusted_mode);
-
 	return true;
 }
 
@@ -269,9 +258,6 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 	if (intel_dsi->dev.dev_ops->panel_reset)
 		intel_dsi->dev.dev_ops->panel_reset(&intel_dsi->dev);
 
-	if (intel_dsi->dev.dev_ops->send_otp_cmds)
-		intel_dsi->dev.dev_ops->send_otp_cmds(&intel_dsi->dev);
-
 	for_each_dsi_port(port, intel_dsi->ports)
 		wait_for_dsi_fifo_empty(intel_dsi, port);
 
@@ -484,7 +470,6 @@ intel_dsi_mode_valid(struct drm_connector *connector,
 {
 	struct intel_connector *intel_connector = to_intel_connector(connector);
 	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
 
 	DRM_DEBUG_KMS("\n");
 
@@ -500,7 +485,7 @@ intel_dsi_mode_valid(struct drm_connector *connector,
 			return MODE_PANEL;
 	}
 
-	return intel_dsi->dev.dev_ops->mode_valid(&intel_dsi->dev, mode);
+	return MODE_OK;
 }
 
 /* return txclkesc cycles in terms of divider and duration in us */
@@ -749,20 +734,7 @@ static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
 static enum drm_connector_status
 intel_dsi_detect(struct drm_connector *connector, bool force)
 {
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
-	struct intel_encoder *intel_encoder = &intel_dsi->base;
-	enum intel_display_power_domain power_domain;
-	enum drm_connector_status connector_status;
-	struct drm_i915_private *dev_priv = intel_encoder->base.dev->dev_private;
-
-	DRM_DEBUG_KMS("\n");
-	power_domain = intel_display_port_power_domain(intel_encoder);
-
-	intel_display_power_get(dev_priv, power_domain);
-	connector_status = intel_dsi->dev.dev_ops->detect(&intel_dsi->dev);
-	intel_display_power_put(dev_priv, power_domain);
-
-	return connector_status;
+	return connector_status_connected;
 }
 
 static int intel_dsi_get_modes(struct drm_connector *connector)
drivers/gpu/drm/i915/intel_dsi.h +0 -20
index 2bb8c46c7889..22f87036a256 100644
@@ -47,33 +47,13 @@ struct intel_dsi_dev_ops {
 
 	void (*disable_panel_power)(struct intel_dsi_device *dsi);
 
-	/* one time programmable commands if needed */
-	void (*send_otp_cmds)(struct intel_dsi_device *dsi);
-
 	/* This callback must be able to assume DSI commands can be sent */
 	void (*enable)(struct intel_dsi_device *dsi);
 
 	/* This callback must be able to assume DSI commands can be sent */
 	void (*disable)(struct intel_dsi_device *dsi);
 
-	int (*mode_valid)(struct intel_dsi_device *dsi,
-			  struct drm_display_mode *mode);
-
-	bool (*mode_fixup)(struct intel_dsi_device *dsi,
-			   const struct drm_display_mode *mode,
-			   struct drm_display_mode *adjusted_mode);
-
-	void (*mode_set)(struct intel_dsi_device *dsi,
-			 struct drm_display_mode *mode,
-			 struct drm_display_mode *adjusted_mode);
-
-	enum drm_connector_status (*detect)(struct intel_dsi_device *dsi);
-
-	bool (*get_hw_state)(struct intel_dsi_device *dev);
-
 	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-
-	void (*destroy) (struct intel_dsi_device *dsi);
 };
 
 struct intel_dsi {
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +3 -42

83 lines not on this page · raw message

Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#22 lore raw

RFC PATCH 6/12 drm/i915/dsi: add some constness to vbt panel driver

In reply to Jani Nikula

Const is good for you. No functional changes.

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +9 -8
index b0e7327a485f..561ec2981dfd 100644
@@ -99,7 +99,8 @@ static inline enum port intel_dsi_seq_port_to_port(u8 port)
 	return port ? PORT_C : PORT_A;
 }
 
-static u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi, u8 *data)
+static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
+				       const u8 *data)
 {
 	u8 type, byte, mode, vc, seq_port;
 	u16 len;
@@ -165,9 +166,9 @@ static u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi, u8 *data)
 	return data;
 }
 
-static u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, u8 *data)
+static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data)
 {
-	u32 delay = *((u32 *) data);
+	u32 delay = *((const u32 *) data);
 
 	usleep_range(delay, delay + 10);
 	data += 4;
@@ -175,7 +176,7 @@ static u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, u8 *data)
 	return data;
 }
 
-static u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, u8 *data)
+static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
 {
 	u8 gpio, action;
 	u16 function, pad;
@@ -208,7 +209,8 @@ static u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, u8 *data)
 	return data;
 }
 
-typedef u8 * (*fn_mipi_elem_exec)(struct intel_dsi *intel_dsi, u8 *data);
+typedef const u8 * (*fn_mipi_elem_exec)(struct intel_dsi *intel_dsi,
+					const u8 *data);
 static const fn_mipi_elem_exec exec_elem[] = {
 	NULL, /* reserved */
 	mipi_exec_send_packet,
@@ -232,13 +234,12 @@ static const char * const seq_name[] = {
 	"MIPI_SEQ_DEASSERT_RESET"
 };
 
-static void generic_exec_sequence(struct intel_dsi *intel_dsi, char *sequence)
+static void generic_exec_sequence(struct intel_dsi *intel_dsi, const u8 *data)
 {
-	u8 *data = sequence;
 	fn_mipi_elem_exec mipi_elem_exec;
 	int index;
 
-	if (!sequence)
+	if (!data)
 		return;
 
 	DRM_DEBUG_DRIVER("Starting MIPI sequence - %s\n", seq_name[*data]);
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#24 lore raw

RFC PATCH 7/12 drm/i915/dsi: switch to drm_panel interface

In reply to Jani Nikula

Replace intel_dsi_device and intel_dsi_dev_ops with drm_panel and drm_panel_funcs. They are adequate for what we have now, and if we end up needing more than this we should improve drm_panel. This will keep us better aligned with the drm core infrastructure.

The panel driver initialization changes a bit. It still remains hideous, but fixing that is beyond the scope here.

---
 drivers/gpu/drm/i915/Kconfig               |   1 +
 drivers/gpu/drm/i915/intel_dsi.c           |  68 +++++++----
 drivers/gpu/drm/i915/intel_dsi.h           |  27 +----
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 179 ++++++++++++++++++-----------
 4 files changed, 156 insertions(+), 119 deletions(-)
drivers/gpu/drm/i915/Kconfig +1 -0
index 4e39ab34eb1c..da196cd07263 100644
@@ -11,6 +11,7 @@ config DRM_I915
 	select SHMEM
 	select TMPFS
 	select DRM_KMS_HELPER
+	select DRM_PANEL
 	# i915 depends on ACPI_VIDEO when ACPI is enabled
 	# but for select to work, need to select ACPI_VIDEO's dependencies, ick
 	select BACKLIGHT_LCD_SUPPORT if ACPI
drivers/gpu/drm/i915/intel_dsi.c +43 -25

152 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dsi.h +2 -25
index 22f87036a256..fc0b2b8d90f1 100644
@@ -33,33 +33,10 @@
 #define DSI_DUAL_LINK_FRONT_BACK	1
 #define DSI_DUAL_LINK_PIXEL_ALT		2
 
-struct intel_dsi_device {
-	unsigned int panel_id;
-	const char *name;
-	const struct intel_dsi_dev_ops *dev_ops;
-	void *dev_priv;
-};
-
-struct intel_dsi_dev_ops {
-	bool (*init)(struct intel_dsi_device *dsi);
-
-	void (*panel_reset)(struct intel_dsi_device *dsi);
-
-	void (*disable_panel_power)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*enable)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*disable)(struct intel_dsi_device *dsi);
-
-	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-};
-
 struct intel_dsi {
 	struct intel_encoder base;
 
-	struct intel_dsi_device dev;
+	struct drm_panel *panel;
 
 	struct intel_connector *attached_connector;
 
@@ -130,6 +107,6 @@ extern void vlv_enable_dsi_pll(struct intel_encoder *encoder);
 extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 
-extern struct intel_dsi_dev_ops vbt_generic_dsi_display_ops;
+struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id);
 
 #endif /* _INTEL_DSI_H */
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +110 -69

221 lines not on this page · raw message

Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#30 lore raw

RFC PATCH 8/12 drm/i915/dsi: add drm mipi dsi host support

In reply to Jani Nikula

Add basic support for using the drm mipi dsi framework for DSI. We don't use device tree which is pretty much required by mipi_dsi_host_register and friends, and we don't have the kind of device model the functions expect either. So we cheat and use it as a library to abstract what we
need: a nice, clean interface for DSI transfers. This means we will have to be careful with what functions we call, as the driver model devices in mipi_dsi_host and mipi_dsi_device will *not* be initialized.

---
 drivers/gpu/drm/i915/Kconfig               |   1 +
 drivers/gpu/drm/i915/intel_dsi.c           | 162 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_dsi.h           |  18 ++++
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |   3 -
 4 files changed, 180 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/Kconfig +1 -0
index da196cd07263..74acca9bcd9d 100644
@@ -12,6 +12,7 @@ config DRM_I915
 	select TMPFS
 	select DRM_KMS_HELPER
 	select DRM_PANEL
+	select DRM_MIPI_DSI
 	# i915 depends on ACPI_VIDEO when ACPI is enabled
 	# but for select to work, need to select ACPI_VIDEO's dependencies, ick
 	select BACKLIGHT_LCD_SUPPORT if ACPI
drivers/gpu/drm/i915/intel_dsi.c +161 -1

192 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dsi.h +18 -0
index fc0b2b8d90f1..2784ac442368 100644
@@ -26,6 +26,7 @@
 
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
+#include <drm/drm_mipi_dsi.h>
 #include "intel_drv.h"
 
 /* Dual Link support */
@@ -33,10 +34,13 @@
 #define DSI_DUAL_LINK_FRONT_BACK	1
 #define DSI_DUAL_LINK_PIXEL_ALT		2
 
+struct intel_dsi_host;
+
 struct intel_dsi {
 	struct intel_encoder base;
 
 	struct drm_panel *panel;
+	struct intel_dsi_host *dsi_hosts[I915_MAX_PORTS];
 
 	struct intel_connector *attached_connector;
 
@@ -94,6 +98,20 @@ struct intel_dsi {
 	u16 panel_pwr_cycle_delay;
 };
 
+struct intel_dsi_host {
+	struct mipi_dsi_host base;
+	struct intel_dsi *intel_dsi;
+	enum port port;
+
+	/* our little hack */
+	struct mipi_dsi_device *device;
+};
+
+static inline struct intel_dsi_host *to_intel_dsi_host(struct mipi_dsi_host *h)
+{
+	return container_of(h, struct intel_dsi_host, base);
+}
+
 #define for_each_dsi_port(__port, __ports_mask) \
 	for ((__port) = PORT_A; (__port) < I915_MAX_PORTS; (__port)++)	\
 		if ((__ports_mask) & (1 << (__port)))
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -3
index 204f54df8fe1..e363c26a2b05 100644
@@ -399,9 +399,6 @@ struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
 	intel_dsi->dual_link = mipi_config->dual_link;
 	intel_dsi->pixel_overlap = mipi_config->pixel_overlap;
 
-	if (intel_dsi->dual_link)
-		intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
-
 	if (intel_dsi->pixel_format == VID_MODE_FORMAT_RGB666)
 		bits_per_pixel = 18;
 	else if (intel_dsi->pixel_format == VID_MODE_FORMAT_RGB565)
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#32 lore raw

RFC PATCH 9/12 drm/i915/dsi: make the vbt panel driver use mipi_dsi_device for transfers

In reply to Jani Nikula

Use the drm core interfaces in preparation of removing our homebrew.

---
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 52 +++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +34 -18
index e363c26a2b05..0b09e66f7e29 100644
@@ -113,14 +113,18 @@ static inline enum port intel_dsi_seq_port_to_port(u8 port)
 static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
 				       const u8 *data)
 {
-	u8 type, byte, mode, vc, seq_port;
+	struct mipi_dsi_device *dsi_device;
+	u8 type, flags, seq_port;
 	u16 len;
 	enum port port;
 
-	byte = *data++;
-	mode = (byte >> MIPI_TRANSFER_MODE_SHIFT) & 0x1;
-	vc = (byte >> MIPI_VIRTUAL_CHANNEL_SHIFT) & 0x3;
-	seq_port = (byte >> MIPI_PORT_SHIFT) & 0x3;
+	flags = *data++;
+	type = *data++;
+
+	len = *((u16 *) data);
+	data += 2;
+
+	seq_port = (flags >> MIPI_PORT_SHIFT) & 3;
 
 	/* For DSI single link on Port A & C, the seq_port value which is
 	 * parsed from Sequence Block#53 of VBT has been set to 0
@@ -131,24 +135,29 @@ static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
 		port = PORT_C;
 	else
 		port = intel_dsi_seq_port_to_port(seq_port);
-	/* LP or HS mode */
-	intel_dsi->hs = mode;
 
-	/* get packet type and increment the pointer */
-	type = *data++;
+	dsi_device = intel_dsi->dsi_hosts[port]->device;
+	if (!dsi_device) {
+		DRM_DEBUG_KMS("no dsi device for port %c\n", port_name(port));
+		goto out;
+	}
 
-	len = *((u16 *) data);
-	data += 2;
+	if ((flags >> MIPI_TRANSFER_MODE_SHIFT) & 1)
+		dsi_device->mode_flags &= ~MIPI_DSI_MODE_LPM;
+	else
+		dsi_device->mode_flags |= MIPI_DSI_MODE_LPM;
+
+	dsi_device->channel = (flags >> MIPI_VIRTUAL_CHANNEL_SHIFT) & 3;
 
 	switch (type) {
 	case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
-		dsi_vc_generic_write_0(intel_dsi, vc, port);
+		mipi_dsi_generic_write(dsi_device, NULL, 0);
 		break;
 	case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
-		dsi_vc_generic_write_1(intel_dsi, vc, *data, port);
+		mipi_dsi_generic_write(dsi_device, data, 1);
 		break;
 	case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
-		dsi_vc_generic_write_2(intel_dsi, vc, *data, *(data + 1), port);
+		mipi_dsi_generic_write(dsi_device, data, 2);
 		break;
 	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
 	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
@@ -156,22 +165,23 @@ static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
 		DRM_DEBUG_DRIVER("Generic Read not yet implemented or used\n");
 		break;
 	case MIPI_DSI_GENERIC_LONG_WRITE:
-		dsi_vc_generic_write(intel_dsi, vc, data, len, port);
+		mipi_dsi_generic_write(dsi_device, data, len);
 		break;
 	case MIPI_DSI_DCS_SHORT_WRITE:
-		dsi_vc_dcs_write_0(intel_dsi, vc, *data, port);
+		mipi_dsi_dcs_write_buffer(dsi_device, data, 1);
 		break;
 	case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
-		dsi_vc_dcs_write_1(intel_dsi, vc, *data, *(data + 1), port);
+		mipi_dsi_dcs_write_buffer(dsi_device, data, 2);
 		break;
 	case MIPI_DSI_DCS_READ:
 		DRM_DEBUG_DRIVER("DCS Read not yet implemented or used\n");
 		break;
 	case MIPI_DSI_DCS_LONG_WRITE:
-		dsi_vc_dcs_write(intel_dsi, vc, data, len, port);
+		mipi_dsi_dcs_write_buffer(dsi_device, data, len);
 		break;
 	}
 
+out:
 	data += len;
 
 	return data;
@@ -389,6 +399,7 @@ struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
 	u32 lp_to_hs_switch, hs_to_lp_switch;
 	u32 pclk, computed_ddr;
 	u16 burst_mode_ratio;
+	enum port port;
 
 	DRM_DEBUG_KMS("\n");
 
@@ -661,5 +672,10 @@ struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
 	vbt_panel->panel.funcs = &vbt_panel_funcs;
 	drm_panel_add(&vbt_panel->panel);
 
+	/* a regular driver would get the device in probe */
+	for_each_dsi_port(port, intel_dsi->ports) {
+		mipi_dsi_attach(intel_dsi->dsi_hosts[port]->device);
+	}
+
 	return &vbt_panel->panel;
 }
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#34 lore raw

RFC PATCH 10/12 drm/i915/dsi: remove old read/write functions in favor of new stuff

In reply to Jani Nikula

All of these are replaced by the drm core mipi dsi functions.

---
 drivers/gpu/drm/i915/intel_dsi_cmd.c | 259 -----------------------------------
 drivers/gpu/drm/i915/intel_dsi_cmd.h |  72 ----------
 2 files changed, 331 deletions(-)
drivers/gpu/drm/i915/intel_dsi_cmd.c +0 -259
index 17b892a365ee..6baaa374fc89 100644
@@ -96,11 +96,6 @@ static void print_stat(struct intel_dsi *intel_dsi, enum port port)
 #undef STAT_BIT
 }
 
-enum dsi_type {
-	DSI_DCS,
-	DSI_GENERIC,
-};
-
 /* enable or disable command mode hs transmissions */
 void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
 						enum port port)
@@ -121,260 +116,6 @@ void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
 	intel_dsi->hs = enable;
 }
 
-static int dsi_vc_send_short(struct intel_dsi *intel_dsi, int channel,
-			     u8 data_type, u16 data, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 ctrl_reg;
-	u32 ctrl;
-	u32 mask;
-
-	DRM_DEBUG_KMS("channel %d, data_type %d, data %04x\n",
-		      channel, data_type, data);
-
-	if (intel_dsi->hs) {
-		ctrl_reg = MIPI_HS_GEN_CTRL(port);
-		mask = HS_CTRL_FIFO_FULL;
-	} else {
-		ctrl_reg = MIPI_LP_GEN_CTRL(port);
-		mask = LP_CTRL_FIFO_FULL;
-	}
-
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == 0, 50)) {
-		DRM_ERROR("Timeout waiting for HS/LP CTRL FIFO !full\n");
-		print_stat(intel_dsi, port);
-	}
-
-	/*
-	 * Note: This function is also used for long packets, with length passed
-	 * as data, since SHORT_PACKET_PARAM_SHIFT ==
-	 * LONG_PACKET_WORD_COUNT_SHIFT.
-	 */
-	ctrl = data << SHORT_PACKET_PARAM_SHIFT |
-		channel << VIRTUAL_CHANNEL_SHIFT |
-		data_type << DATA_TYPE_SHIFT;
-
-	I915_WRITE(ctrl_reg, ctrl);
-
-	return 0;
-}
-
-static int dsi_vc_send_long(struct intel_dsi *intel_dsi, int channel,
-		u8 data_type, const u8 *data, int len, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 data_reg;
-	int i, j, n;
-	u32 mask;
-
-	DRM_DEBUG_KMS("channel %d, data_type %d, len %04x\n",
-		      channel, data_type, len);
-
-	if (intel_dsi->hs) {
-		data_reg = MIPI_HS_GEN_DATA(port);
-		mask = HS_DATA_FIFO_FULL;
-	} else {
-		data_reg = MIPI_LP_GEN_DATA(port);
-		mask = LP_DATA_FIFO_FULL;
-	}
-
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == 0, 50))
-		DRM_ERROR("Timeout waiting for HS/LP DATA FIFO !full\n");
-
-	for (i = 0; i < len; i += n) {
-		u32 val = 0;
-		n = min_t(int, len - i, 4);
-
-		for (j = 0; j < n; j++)
-			val |= *data++ << 8 * j;
-
-		I915_WRITE(data_reg, val);
-		/* XXX: check for data fifo full, once that is set, write 4
-		 * dwords, then wait for not set, then continue. */
-	}
-
-	return dsi_vc_send_short(intel_dsi, channel, data_type, len, port);
-}
-
-static int dsi_vc_write_common(struct intel_dsi *intel_dsi,
-			       int channel, const u8 *data, int len,
-			       enum dsi_type type, enum port port)
-{
-	int ret;
-
-	if (len == 0) {
-		BUG_ON(type == DSI_GENERIC);
-		ret = dsi_vc_send_short(intel_dsi, channel,
-					MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM,
-					0, port);
-	} else if (len == 1) {
-		ret = dsi_vc_send_short(intel_dsi, channel,
-					type == DSI_GENERIC ?
-					MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM :
-					MIPI_DSI_DCS_SHORT_WRITE, data[0],
-					port);
-	} else if (len == 2) {
-		ret = dsi_vc_send_short(intel_dsi, channel,
-					type == DSI_GENERIC ?
-					MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM :
-					MIPI_DSI_DCS_SHORT_WRITE_PARAM,
-					(data[1] << 8) | data[0], port);
-	} else {
-		ret = dsi_vc_send_long(intel_dsi, channel,
-					type == DSI_GENERIC ?
-					MIPI_DSI_GENERIC_LONG_WRITE :
-					MIPI_DSI_DCS_LONG_WRITE, data, len,
-					port);
-	}
-
-	return ret;
-}
-
-int dsi_vc_dcs_write(struct intel_dsi *intel_dsi, int channel,
-		     const u8 *data, int len, enum port port)
-{
-	return dsi_vc_write_common(intel_dsi, channel, data, len, DSI_DCS,
-									port);
-}
-
-int dsi_vc_generic_write(struct intel_dsi *intel_dsi, int channel,
-			 const u8 *data, int len, enum port port)
-{
-	return dsi_vc_write_common(intel_dsi, channel, data, len, DSI_GENERIC,
-									port);
-}
-
-static int dsi_vc_dcs_send_read_request(struct intel_dsi *intel_dsi,
-				int channel, u8 dcs_cmd, enum port port)
-{
-	return dsi_vc_send_short(intel_dsi, channel, MIPI_DSI_DCS_READ,
-				 dcs_cmd, port);
-}
-
-static int dsi_vc_generic_send_read_request(struct intel_dsi *intel_dsi,
-					    int channel, u8 *reqdata,
-					    int reqlen, enum port port)
-{
-	u16 data;
-	u8 data_type;
-
-	switch (reqlen) {
-	case 0:
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
-		data = 0;
-		break;
-	case 1:
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
-		data = reqdata[0];
-		break;
-	case 2:
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
-		data = (reqdata[1] << 8) | reqdata[0];
-		break;
-	default:
-		BUG();
-	}
-
-	return dsi_vc_send_short(intel_dsi, channel, data_type, data, port);
-}
-
-static int dsi_read_data_return(struct intel_dsi *intel_dsi,
-				u8 *buf, int buflen, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	int i, len = 0;
-	u32 data_reg, val;
-
-	if (intel_dsi->hs) {
-		data_reg = MIPI_HS_GEN_DATA(port);
-	} else {
-		data_reg = MIPI_LP_GEN_DATA(port);
-	}
-
-	while (len < buflen) {
-		val = I915_READ(data_reg);
-		for (i = 0; i < 4 && len < buflen; i++, len++)
-			buf[len] = val >> 8 * i;
-	}
-
-	return len;
-}
-
-int dsi_vc_dcs_read(struct intel_dsi *intel_dsi, int channel, u8 dcs_cmd,
-		    u8 *buf, int buflen, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 mask;
-	int ret;
-
-	/*
-	 * XXX: should issue multiple read requests and reads if request is
-	 * longer than MIPI_MAX_RETURN_PKT_SIZE
-	 */
-
-	I915_WRITE(MIPI_INTR_STAT(port), GEN_READ_DATA_AVAIL);
-
-	ret = dsi_vc_dcs_send_read_request(intel_dsi, channel, dcs_cmd, port);
-	if (ret)
-		return ret;
-
-	mask = GEN_READ_DATA_AVAIL;
-	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 50))
-		DRM_ERROR("Timeout waiting for read data.\n");
-
-	ret = dsi_read_data_return(intel_dsi, buf, buflen, port);
-	if (ret < 0)
-		return ret;
-
-	if (ret != buflen)
-		return -EIO;
-
-	return 0;
-}
-
-int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
-		u8 *reqdata, int reqlen, u8 *buf, int buflen, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 mask;
-	int ret;
-
-	/*
-	 * XXX: should issue multiple read requests and reads if request is
-	 * longer than MIPI_MAX_RETURN_PKT_SIZE
-	 */
-
-	I915_WRITE(MIPI_INTR_STAT(port), GEN_READ_DATA_AVAIL);
-
-	ret = dsi_vc_generic_send_read_request(intel_dsi, channel, reqdata,
-					       reqlen, port);
-	if (ret)
-		return ret;
-
-	mask = GEN_READ_DATA_AVAIL;
-	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 50))
-		DRM_ERROR("Timeout waiting for read data.\n");
-
-	ret = dsi_read_data_return(intel_dsi, buf, buflen, port);
-	if (ret < 0)
-		return ret;
-
-	if (ret != buflen)
-		return -EIO;
-
-	return 0;
-}
-
 /*
  * send a video mode command
  *
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -72

78 lines not on this page · raw message

Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#36 lore raw

RFC PATCH 11/12 drm/i915/dsi: move dpi_send_cmd() to intel_dsi.c and make it static

In reply to Jani Nikula

No functional changes.

---
 drivers/gpu/drm/i915/intel_dsi.c     | 39 ++++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/i915/intel_dsi_cmd.c | 34 -------------------------------
 drivers/gpu/drm/i915/intel_dsi_cmd.h |  5 -----
 3 files changed, 37 insertions(+), 41 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +37 -2
index 5cfa3431785a..791d90b4c047 100644
@@ -202,6 +202,41 @@ static struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi,
 	return host;
 }
 
+/*
+ * send a video mode command
+ *
+ * XXX: commands with data in MIPI_DPI_DATA?
+ */
+static int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs,
+			enum port port)
+{
+	struct drm_encoder *encoder = &intel_dsi->base.base;
+	struct drm_device *dev = encoder->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 mask;
+
+	/* XXX: pipe, hs */
+	if (hs)
+		cmd &= ~DPI_LP_MODE;
+	else
+		cmd |= DPI_LP_MODE;
+
+	/* clear bit */
+	I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
+
+	/* XXX: old code skips write if control unchanged */
+	if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
+		DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
+
+	I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
+
+	mask = SPL_PKT_SENT_INTERRUPT;
+	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 100))
+		DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
+
+	return 0;
+}
+
 static void band_gap_reset(struct drm_i915_private *dev_priv)
 {
 	mutex_lock(&dev_priv->dpio_lock);
@@ -357,7 +392,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 	else {
 		msleep(20); /* XXX */
 		for_each_dsi_port(port, intel_dsi->ports)
-			dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN, port);
+			dpi_send_cmd(intel_dsi, TURN_ON, false, port);
 		msleep(100);
 
 		drm_panel_enable(intel_dsi->panel);
@@ -430,7 +465,7 @@ static void intel_dsi_pre_disable(struct intel_encoder *encoder)
 	if (is_vid_mode(intel_dsi)) {
 		/* Send Shutdown command to the panel in LP mode */
 		for_each_dsi_port(port, intel_dsi->ports)
-			dpi_send_cmd(intel_dsi, SHUTDOWN, DPI_LP_MODE_EN, port);
+			dpi_send_cmd(intel_dsi, SHUTDOWN, false, port);
 		msleep(10);
 	}
 }
drivers/gpu/drm/i915/intel_dsi_cmd.c +0 -34
index 6baaa374fc89..acdc5da7b46f 100644
@@ -115,37 +115,3 @@ void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
 
 	intel_dsi->hs = enable;
 }
-
-/*
- * send a video mode command
- *
- * XXX: commands with data in MIPI_DPI_DATA?
- */
-int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 mask;
-
-	/* XXX: pipe, hs */
-	if (hs)
-		cmd &= ~DPI_LP_MODE;
-	else
-		cmd |= DPI_LP_MODE;
-
-	/* clear bit */
-	I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
-
-	/* XXX: old code skips write if control unchanged */
-	if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
-		DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
-
-	I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
-
-	mask = SPL_PKT_SENT_INTERRUPT;
-	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 100))
-		DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
-
-	return 0;
-}
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -5
index 9a28ff58a92b..886779030f1a 100644
@@ -33,12 +33,7 @@
 #include "intel_drv.h"
 #include "intel_dsi.h"
 
-#define DPI_LP_MODE_EN	false
-#define DPI_HS_MODE_EN	true
-
 void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
 						enum port port);
 
-int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port);
-
 #endif /* _INTEL_DSI_DSI_H */
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#38 lore raw

RFC PATCH 12/12 drm/i915/dsi: remove intel_dsi_cmd.c and the unused functions therein

In reply to Jani Nikula

The removed functions can be resurrected in intel_dsi.c as need arises.

---
 drivers/gpu/drm/i915/Makefile              |   1 -
 drivers/gpu/drm/i915/intel_dsi.c           |   1 -
 drivers/gpu/drm/i915/intel_dsi_cmd.c       | 117 -----------------------------
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |   1 -
 4 files changed, 120 deletions(-)
 delete mode 100644 drivers/gpu/drm/i915/intel_dsi_cmd.c
drivers/gpu/drm/i915/Makefile +0 -1
index 16e3dc350274..63afe63bf0e4 100644
@@ -71,7 +71,6 @@ i915-y += dvo_ch7017.o \
 	  intel_ddi.o \
 	  intel_dp.o \
 	  intel_dp_mst.o \
-	  intel_dsi_cmd.o \
 	  intel_dsi.o \
 	  intel_dsi_pll.o \
 	  intel_dsi_panel_vbt.o \
drivers/gpu/drm/i915/intel_dsi.c +0 -1
index 791d90b4c047..02ae5e583b27 100644
@@ -33,7 +33,6 @@
 #include "i915_drv.h"
 #include "intel_drv.h"
 #include "intel_dsi.h"
-#include "intel_dsi_cmd.h"
 
 static const struct {
 	u16 panel_id;
drivers/gpu/drm/i915/intel_dsi_cmd.c deleted +0 -117

117 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
index 0b09e66f7e29..c3eec66f5076 100644
@@ -36,7 +36,6 @@
 #include "i915_drv.h"
 #include "intel_drv.h"
 #include "intel_dsi.h"
-#include "intel_dsi_cmd.h"
 
 struct vbt_panel {
 	struct drm_panel panel;
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/12
#2 lore raw

Re: [RFC PATCH 01/12] drm/i915/dsi: call dpi_send_cmd() for each dsi port at a higher level

In reply to Jani Nikula
Quoted 9 lines · Jani Nikula

Instead of having the for each dsi port loop within dpi_send_cmd(), add a port parameter to the function and call it for each port instead.

This is a rewrite of

commit 4510cd779e5897eeb8691aecbd639bb62ec27d55

Author: Gaurav K Singh <[email protected]>
Date:   Thu Dec 4 10:58:51 2014 +0530
Quoted 6 lines

drm/i915: Dual link needs Shutdown and Turn on packet for both ports

to add more flexibility in using dpi_send_cmd() for just one port as necessary. No functional changes.

Better this way.

Quoted 93 lines
---
  drivers/gpu/drm/i915/intel_dsi.c     |  7 +++++--
  drivers/gpu/drm/i915/intel_dsi_cmd.c | 26 ++++++++++----------------
  drivers/gpu/drm/i915/intel_dsi_cmd.h |  2 +-
  3 files changed, 16 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +5 -2
index 42b6d6f5cecc..36b19c7e87b9 100644
@@ -207,7 +207,8 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
  		I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
  	else {
  		msleep(20); /* XXX */
-		dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN);
+		for_each_dsi_port(port, intel_dsi->ports)
+			dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN, port);
  		msleep(100);
 
  		if (intel_dsi->dev.dev_ops->enable)
@@ -275,12 +276,14 @@ static void intel_dsi_enable_nop(struct intel_encoder *encoder)
  static void intel_dsi_pre_disable(struct intel_encoder *encoder)
  {
  	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
+	enum port port;
 
  	DRM_DEBUG_KMS("\n");
 
  	if (is_vid_mode(intel_dsi)) {
  		/* Send Shutdown command to the panel in LP mode */
-		dpi_send_cmd(intel_dsi, SHUTDOWN, DPI_LP_MODE_EN);
+		for_each_dsi_port(port, intel_dsi->ports)
+			dpi_send_cmd(intel_dsi, SHUTDOWN, DPI_LP_MODE_EN, port);
  		msleep(10);
  	}
  }
drivers/gpu/drm/i915/intel_dsi_cmd.c +10 -16
index 562811c1a9d2..5f63c807acea 100644
@@ -380,12 +380,11 @@ int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
   *
   * XXX: commands with data in MIPI_DPI_DATA?
   */
-int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs)
+int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port)
  {
  	struct drm_encoder *encoder = &intel_dsi->base.base;
  	struct drm_device *dev = encoder->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	enum port port;
  	u32 mask;
 
  	/* XXX: pipe, hs */
@@ -394,23 +393,18 @@ int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs)
  	else
  		cmd |= DPI_LP_MODE;
 
-	for_each_dsi_port(port, intel_dsi->ports) {
-		/* clear bit */
-		I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
+	/* clear bit */
+	I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
 
-		/* XXX: old code skips write if control unchanged */
-		if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
-			DRM_ERROR("Same special packet %02x twice in a row.\n",
-									cmd);
+	/* XXX: old code skips write if control unchanged */
+	if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
+		DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
 
-		I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
+	I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
 
-		mask = SPL_PKT_SENT_INTERRUPT;
-		if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask,
-									100))
-			DRM_ERROR("Video mode command 0x%08x send failed.\n",
-									cmd);
-	}
+	mask = SPL_PKT_SENT_INTERRUPT;
+	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 100))
+		DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
 
  	return 0;
  }
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -0
index 326a5ac55561..1d1a716e473a 100644

drivers/gpu/drm/i915/intel_dsi_cmd.h int dsi_vc_dcs_read(struct intel_dsi *intel_dsi, int channel, u8 dcs_cmd, · line 57

Quoted 8 lines
drivers/gpu/drm/i915/intel_dsi_cmd.h +1 -1
@@ -51,7 +51,7 @@ int dsi_vc_dcs_read(struct intel_dsi *intel_dsi, int channel, u8 dcs_cmd,
  int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
  		u8 *reqdata, int reqlen, u8 *buf, int buflen, enum port port);
 
-int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs);
+int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port);
  void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi);
 
  /* XXX: questionable write helpers */

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 3/12
#9 lore raw

Re: [RFC PATCH 03/12] drm/i915/dsi: move wait_for_dsi_fifo_empty to intel_dsi.c

In reply to Jani Nikula
Quoted 4 lines · Jani Nikula

wait_for_dsi_fifo_empty can be static in intel_dsi.c. No functional changes.

Quoted 63 lines
---
  drivers/gpu/drm/i915/intel_dsi.c     | 16 ++++++++++++++++
  drivers/gpu/drm/i915/intel_dsi_cmd.c | 16 ----------------
  drivers/gpu/drm/i915/intel_dsi_cmd.h |  1 -
  3 files changed, 16 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +16 -0
index 49e186bc080f..e82cf5f65c9a 100644
@@ -42,6 +42,22 @@ static const struct intel_dsi_device intel_dsi_devices[] = {
  	},
  };
 
+static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi)
+{
+	struct drm_encoder *encoder = &intel_dsi->base.base;
+	struct drm_device *dev = encoder->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
+	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
+	u32 mask;
+
+	mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
+		LP_DATA_FIFO_EMPTY | HS_DATA_FIFO_EMPTY;
+
+	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 100))
+		DRM_ERROR("DPI FIFOs are not empty\n");
+}
+
  static void band_gap_reset(struct drm_i915_private *dev_priv)
  {
  	mutex_lock(&dev_priv->dpio_lock);
drivers/gpu/drm/i915/intel_dsi_cmd.c +0 -16
index 5f63c807acea..17b892a365ee 100644
@@ -408,19 +408,3 @@ int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port)
 
  	return 0;
  }
-
-void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
-	u32 mask;
-
-	mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
-		LP_DATA_FIFO_EMPTY | HS_DATA_FIFO_EMPTY;
-
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 100))
-		DRM_ERROR("DPI FIFOs are not empty\n");
-}
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -0
index 1d1a716e473a..70f24666a1f9 100644

drivers/gpu/drm/i915/intel_dsi_cmd.h int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel, · line 57

Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -1
@@ -52,7 +52,6 @@ int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
  		u8 *reqdata, int reqlen, u8 *buf, int buflen, enum port port);
 
  int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port);
-void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi);
 
  /* XXX: questionable write helpers */
  static inline int dsi_vc_dcs_write_0(struct intel_dsi *intel_dsi,

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [RFC PATCH 02/12] drm/i915/dsi: set max return packet size for each dsi port

In reply to Jani Nikula
Quoted 17 lines · Jani Nikula

This seems like the right thing to do. This also gets rid of a call to intel_dsi_pipe_to_port() which we want to remove eventually.

---
  drivers/gpu/drm/i915/intel_dsi.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +0 -1
index 36b19c7e87b9..49e186bc080f 100644
@@ -197,14 +197,14 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
  {
  	struct drm_device *dev = encoder->base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_enable(struct intel_encoder *encoder) · line 207

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi.c +3 -2
  	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
+	enum port port;
 
  	DRM_DEBUG_KMS("\n");
 
  	if (is_cmd_mode(intel_dsi))
-		I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
+		for_each_dsi_port(port, intel_dsi->ports)
+			I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);

Using for_each_dsi_port() macro in this way will make the following else below as "else" part for that "if" inside the macro, breaking the whole logic. We should enclose the true part of is_cmd_mode check in braces

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_enable(struct intel_encoder *encoder) · line 210

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi.c +0 -0
  	else {
  		msleep(20); /* XXX */
  		for_each_dsi_port(port, intel_dsi->ports)

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 4/12
#11 lore raw

Re: [RFC PATCH 04/12] drm/i915/dsi: call wait_for_dsi_fifo_empty() for each dsi port

In reply to Jani Nikula
Quoted 6 lines · Jani Nikula

Add port parameter to wait_for_dsi_fifo_empty, and call it for each dsi port.

We can now remove the transitional intel_dsi_pipe_to_port() function.

Quoted 86 lines
---
  drivers/gpu/drm/i915/intel_dsi.c | 17 ++++++++++-------
  drivers/gpu/drm/i915/intel_dsi.h | 12 ------------
  2 files changed, 10 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +10 -7
index e82cf5f65c9a..9b0eaa9db845 100644
@@ -42,13 +42,11 @@ static const struct intel_dsi_device intel_dsi_devices[] = {
  	},
  };
 
-static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi)
+static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi, enum port port)
  {
  	struct drm_encoder *encoder = &intel_dsi->base.base;
  	struct drm_device *dev = encoder->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
  	u32 mask;
 
  	mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
@@ -230,7 +228,8 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
  		if (intel_dsi->dev.dev_ops->enable)
  			intel_dsi->dev.dev_ops->enable(&intel_dsi->dev);
 
-		wait_for_dsi_fifo_empty(intel_dsi);
+		for_each_dsi_port(port, intel_dsi->ports)
+			wait_for_dsi_fifo_empty(intel_dsi, port);
 
  		intel_dsi_port_enable(encoder);
  	}
@@ -243,6 +242,7 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
  	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  	enum pipe pipe = intel_crtc->pipe;
+	enum port port;
  	u32 tmp;
 
  	DRM_DEBUG_KMS("\n");
@@ -272,7 +272,8 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
  	if (intel_dsi->dev.dev_ops->send_otp_cmds)
  		intel_dsi->dev.dev_ops->send_otp_cmds(&intel_dsi->dev);
 
-	wait_for_dsi_fifo_empty(intel_dsi);
+	for_each_dsi_port(port, intel_dsi->ports)
+		wait_for_dsi_fifo_empty(intel_dsi, port);
 
  	/* Enable port in pre-enable phase itself because as per hw team
  	 * recommendation, port should be enabled befor plane & pipe */
@@ -315,7 +316,8 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
  	DRM_DEBUG_KMS("\n");
 
  	if (is_vid_mode(intel_dsi)) {
-		wait_for_dsi_fifo_empty(intel_dsi);
+		for_each_dsi_port(port, intel_dsi->ports)
+			wait_for_dsi_fifo_empty(intel_dsi, port);
 
  		intel_dsi_port_disable(encoder);
  		msleep(2);
@@ -344,7 +346,8 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
  	if (intel_dsi->dev.dev_ops->disable)
  		intel_dsi->dev.dev_ops->disable(&intel_dsi->dev);
 
-	wait_for_dsi_fifo_empty(intel_dsi);
+	for_each_dsi_port(port, intel_dsi->ports)
+		wait_for_dsi_fifo_empty(intel_dsi, port);
  }
 
  static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
drivers/gpu/drm/i915/intel_dsi.h +0 -5
index 8fe2064dd804..2bb8c46c7889 100644
@@ -137,18 +137,6 @@ struct intel_dsi {
  	u16 panel_pwr_cycle_delay;
  };
 
-/* XXX: Transitional before dual port configuration */
-static inline enum port intel_dsi_pipe_to_port(enum pipe pipe)
-{
-	if (pipe == PIPE_A)
-		return PORT_A;

drivers/gpu/drm/i915/intel_dsi.h struct intel_dsi { · line 142

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi.h +0 -7
-	else if (pipe == PIPE_B)
-		return PORT_C;
-
-	WARN(1, "DSI on pipe %c, assuming port C\n", pipe_name(pipe));
-	return PORT_C;
-}
-
  #define for_each_dsi_port(__port, __ports_mask) \
  	for ((__port) = PORT_A; (__port) < I915_MAX_PORTS; (__port)++)	\
  		if ((__ports_mask) & (1 << (__port)))

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 5/12
#13 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

In reply to Jani Nikula
Quoted 41 lines · Jani Nikula

Remove all the trivial and/or dummy callbacks from intel dsi device ops. Merge send_otp_cmds into panel_reset as they're called back to back.

This will be helpful for switching to use drm_panel for the callbacks. If we ever need the additional callbacks, we should add them to drm_panel funcs.

---
  drivers/gpu/drm/i915/intel_dsi.c           | 32 ++-------------------
  drivers/gpu/drm/i915/intel_dsi.h           | 20 -------------
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 45 ++----------------------------
  3 files changed, 5 insertions(+), 92 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +0 -7
index 9b0eaa9db845..fc218b7754b3 100644
@@ -70,12 +70,6 @@ static void band_gap_reset(struct drm_i915_private *dev_priv)
  	mutex_unlock(&dev_priv->dpio_lock);
  }
 
-static struct intel_dsi *intel_attached_dsi(struct drm_connector *connector)
-{
-	return container_of(intel_attached_encoder(connector),
-			    struct intel_dsi, base);
-}
-
  static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
  {
  	return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE;
@@ -99,7 +93,6 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  	struct intel_connector *intel_connector = intel_dsi->attached_connector;
  	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  	struct drm_display_mode *adjusted_mode = &config->adjusted_mode;
-	struct drm_display_mode *mode = &config->requested_mode;
 
  	DRM_DEBUG_KMS("\n");
 

drivers/gpu/drm/i915/intel_dsi.c static bool intel_dsi_compute_config(struct intel_encoder *encoder, · line 115

Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi.c +0 -4
@@ -109,10 +102,6 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  	/* DSI uses short packets for sync events, so clear mode flags for DSI */
  	adjusted_mode->flags = 0;
 
-	if (intel_dsi->dev.dev_ops->mode_fixup)
-		return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev,
-							  mode, adjusted_mode);
-

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Either way

Quoted 172 lines
drivers/gpu/drm/i915/intel_dsi.c +2 -19
  	return true;
  }
 
@@ -269,9 +258,6 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
  	if (intel_dsi->dev.dev_ops->panel_reset)
  		intel_dsi->dev.dev_ops->panel_reset(&intel_dsi->dev);
 
-	if (intel_dsi->dev.dev_ops->send_otp_cmds)
-		intel_dsi->dev.dev_ops->send_otp_cmds(&intel_dsi->dev);
-
  	for_each_dsi_port(port, intel_dsi->ports)
  		wait_for_dsi_fifo_empty(intel_dsi, port);
 
@@ -484,7 +470,6 @@ intel_dsi_mode_valid(struct drm_connector *connector,
  {
  	struct intel_connector *intel_connector = to_intel_connector(connector);
  	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
 
  	DRM_DEBUG_KMS("\n");
 
@@ -500,7 +485,7 @@ intel_dsi_mode_valid(struct drm_connector *connector,
  			return MODE_PANEL;
  	}
 
-	return intel_dsi->dev.dev_ops->mode_valid(&intel_dsi->dev, mode);
+	return MODE_OK;
  }
 
  /* return txclkesc cycles in terms of divider and duration in us */
@@ -749,20 +734,7 @@ static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
  static enum drm_connector_status
  intel_dsi_detect(struct drm_connector *connector, bool force)
  {
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
-	struct intel_encoder *intel_encoder = &intel_dsi->base;
-	enum intel_display_power_domain power_domain;
-	enum drm_connector_status connector_status;
-	struct drm_i915_private *dev_priv = intel_encoder->base.dev->dev_private;
-
-	DRM_DEBUG_KMS("\n");
-	power_domain = intel_display_port_power_domain(intel_encoder);
-
-	intel_display_power_get(dev_priv, power_domain);
-	connector_status = intel_dsi->dev.dev_ops->detect(&intel_dsi->dev);
-	intel_display_power_put(dev_priv, power_domain);
-
-	return connector_status;
+	return connector_status_connected;
  }
 
  static int intel_dsi_get_modes(struct drm_connector *connector)
drivers/gpu/drm/i915/intel_dsi.h +0 -20
index 2bb8c46c7889..22f87036a256 100644
@@ -47,33 +47,13 @@ struct intel_dsi_dev_ops {
 
  	void (*disable_panel_power)(struct intel_dsi_device *dsi);
 
-	/* one time programmable commands if needed */
-	void (*send_otp_cmds)(struct intel_dsi_device *dsi);
-
  	/* This callback must be able to assume DSI commands can be sent */
  	void (*enable)(struct intel_dsi_device *dsi);
 
  	/* This callback must be able to assume DSI commands can be sent */
  	void (*disable)(struct intel_dsi_device *dsi);
 
-	int (*mode_valid)(struct intel_dsi_device *dsi,
-			  struct drm_display_mode *mode);
-
-	bool (*mode_fixup)(struct intel_dsi_device *dsi,
-			   const struct drm_display_mode *mode,
-			   struct drm_display_mode *adjusted_mode);
-
-	void (*mode_set)(struct intel_dsi_device *dsi,
-			 struct drm_display_mode *mode,
-			 struct drm_display_mode *adjusted_mode);
-
-	enum drm_connector_status (*detect)(struct intel_dsi_device *dsi);
-
-	bool (*get_hw_state)(struct intel_dsi_device *dev);
-
  	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-
-	void (*destroy) (struct intel_dsi_device *dsi);
  };
 
  struct intel_dsi {
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +3 -38
index 5493aef5a6a3..b0e7327a485f 100644
@@ -559,18 +559,6 @@ static bool generic_init(struct intel_dsi_device *dsi)
  	return true;
  }
 
-static int generic_mode_valid(struct intel_dsi_device *dsi,
-		   struct drm_display_mode *mode)
-{
-	return MODE_OK;
-}
-
-static bool generic_mode_fixup(struct intel_dsi_device *dsi,
-		    const struct drm_display_mode *mode,
-		    struct drm_display_mode *adjusted_mode) {
-	return true;
-}
-
  static void generic_panel_reset(struct intel_dsi_device *dsi)
  {
  	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
@@ -580,26 +568,18 @@ static void generic_panel_reset(struct intel_dsi_device *dsi)
  	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET];
 
  	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static void generic_disable_panel_power(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
 
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
  	generic_exec_sequence(intel_dsi, sequence);
  }
 
-static void generic_send_otp_cmds(struct intel_dsi_device *dsi)
+static void generic_disable_panel_power(struct intel_dsi_device *dsi)
  {
  	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
  	struct drm_device *dev = intel_dsi->base.base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
+	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
 
  	generic_exec_sequence(intel_dsi, sequence);
  }
@@ -626,16 +606,6 @@ static void generic_disable(struct intel_dsi_device *dsi)
  	generic_exec_sequence(intel_dsi, sequence);
  }
 
-static enum drm_connector_status generic_detect(struct intel_dsi_device *dsi)
-{
-	return connector_status_connected;
-}
-
-static bool generic_get_hw_state(struct intel_dsi_device *dev)
-{
-	return true;
-}
-
  static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi)
  {
  	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
@@ -646,20 +616,11 @@ static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi)
  	return dev_priv->vbt.lfp_lvds_vbt_mode;
  }
 
-static void generic_destroy(struct intel_dsi_device *dsi) { }
-
-/* Callbacks. We might not need them all. */
  struct intel_dsi_dev_ops vbt_generic_dsi_display_ops = {
  	.init = generic_init,
-	.mode_valid = generic_mode_valid,
-	.mode_fixup = generic_mode_fixup,

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi) · line 626

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -4
  	.panel_reset = generic_panel_reset,
  	.disable_panel_power = generic_disable_panel_power,
-	.send_otp_cmds = generic_send_otp_cmds,
  	.enable = generic_enable,
  	.disable = generic_disable,
-	.detect = generic_detect,
-	.get_hw_state = generic_get_hw_state,
  	.get_modes = generic_get_modes,
-	.destroy = generic_destroy,
  };

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 6/12
#23 lore raw

Re: [RFC PATCH 06/12] drm/i915/dsi: add some constness to vbt panel driver

In reply to Jani Nikula
Quoted 3 lines · Jani Nikula

Const is good for you. No functional changes.

Quoted 56 lines
---
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 17 +++++++++--------
  1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +8 -6
index b0e7327a485f..561ec2981dfd 100644
@@ -99,7 +99,8 @@ static inline enum port intel_dsi_seq_port_to_port(u8 port)
  	return port ? PORT_C : PORT_A;
  }
 
-static u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi, u8 *data)
+static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
+				       const u8 *data)
  {
  	u8 type, byte, mode, vc, seq_port;
  	u16 len;
@@ -165,9 +166,9 @@ static u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi, u8 *data)
  	return data;
  }
 
-static u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, u8 *data)
+static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data)
  {
-	u32 delay = *((u32 *) data);
+	u32 delay = *((const u32 *) data);
 
  	usleep_range(delay, delay + 10);
  	data += 4;
@@ -175,7 +176,7 @@ static u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, u8 *data)
  	return data;
  }
 
-static u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, u8 *data)
+static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
  {
  	u8 gpio, action;
  	u16 function, pad;
@@ -208,7 +209,8 @@ static u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, u8 *data)
  	return data;
  }
 
-typedef u8 * (*fn_mipi_elem_exec)(struct intel_dsi *intel_dsi, u8 *data);
+typedef const u8 * (*fn_mipi_elem_exec)(struct intel_dsi *intel_dsi,
+					const u8 *data);
  static const fn_mipi_elem_exec exec_elem[] = {
  	NULL, /* reserved */
  	mipi_exec_send_packet,
@@ -232,13 +234,12 @@ static const char * const seq_name[] = {
  	"MIPI_SEQ_DEASSERT_RESET"
  };
 
-static void generic_exec_sequence(struct intel_dsi *intel_dsi, char *sequence)
+static void generic_exec_sequence(struct intel_dsi *intel_dsi, const u8 *data)

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static const char * const seq_name[] = { · line 245

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -2
  {
-	u8 *data = sequence;
  	fn_mipi_elem_exec mipi_elem_exec;
  	int index;
 
-	if (!sequence)
+	if (!data)
  		return;
 
  	DRM_DEBUG_DRIVER("Starting MIPI sequence - %s\n", seq_name[*data]);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#41 lore raw
In reply to Jani Nikula
Quoted 5 lines · Jani Nikula

This series ports our DSI code over to the drm_panel and mipi_dsi_host/mipi_dsi_device. There are some rough edges towards the end of the series, see commit message for patch 8 for details.

Patches 1-6 are prep work, fairly independent

While I continue to review, quick test of patches show that till here it is fine(with minor fix for Patch 2), but from Patch 7 on wards things really don't work.

Quoted 34 lines

Patch 7 ports the driver over to drm_panel

Patches 8-10 port the driver over to mipi_dsi_host/device

Patches 11-12 do some additional cleanup

BR,
Jani.

Jani Nikula (12):
drm/i915/dsi: call dpi_send_cmd() for each dsi port at a higher level drm/i915/dsi: set max return packet size for each dsi port drm/i915/dsi: move wait_for_dsi_fifo_empty to intel_dsi.c drm/i915/dsi: call wait_for_dsi_fifo_empty() for each dsi port drm/i915/dsi: remove unnecessary dsi device callbacks drm/i915/dsi: add some constness to vbt panel driver drm/i915/dsi: switch to drm_panel interface
drm/i915/dsi: add drm mipi dsi host support
drm/i915/dsi: make the vbt panel driver use mipi_dsi_device for
transfers
drm/i915/dsi: remove old read/write functions in favor of new stuff drm/i915/dsi: move dpi_send_cmd() to intel_dsi.c and make it static drm/i915/dsi: remove intel_dsi_cmd.c and the unused functions therein

  drivers/gpu/drm/i915/Kconfig               |   2 +
  drivers/gpu/drm/i915/Makefile              |   1 -
  drivers/gpu/drm/i915/intel_dsi.c           | 336 +++++++++++++++++-----
  drivers/gpu/drm/i915/intel_dsi.h           |  69 ++---
  drivers/gpu/drm/i915/intel_dsi_cmd.c       | 432 -----------------------------
  drivers/gpu/drm/i915/intel_dsi_cmd.h       |  78 ------
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 289 ++++++++++---------
  7 files changed, 441 insertions(+), 766 deletions(-)
Quoted 2 lines

delete mode 100644 drivers/gpu/drm/i915/intel_dsi_cmd.c

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

Re: [RFC PATCH 02/12] drm/i915/dsi: set max return packet size for each dsi port

In reply to Shobhit Kumar
Quoted 24 lines · Shobhit Kumar
Quoted 23 lines · Jani Nikula

This seems like the right thing to do. This also gets rid of a call to intel_dsi_pipe_to_port() which we want to remove eventually.

---
  drivers/gpu/drm/i915/intel_dsi.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +1 -2
index 36b19c7e87b9..49e186bc080f 100644
@@ -197,14 +197,14 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
  {
  	struct drm_device *dev = encoder->base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
+	enum port port;
 
  	DRM_DEBUG_KMS("\n");
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_enable(struct intel_encoder *encoder) · line 207

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi.c +2 -1
  	if (is_cmd_mode(intel_dsi))
-		I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
+		for_each_dsi_port(port, intel_dsi->ports)
+			I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);

Using for_each_dsi_port() macro in this way will make the following else below as "else" part for that "if" inside the macro, breaking the whole logic. We should enclose the true part of is_cmd_mode check in braces

Auch, good catch. Thanks.

Jani.

Quoted 8 lines

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_enable(struct intel_encoder *encoder) · line 210

Quoted 5 lines
drivers/gpu/drm/i915/intel_dsi.c +0 -0
  	else {
  		msleep(20); /* XXX */
  		for_each_dsi_port(port, intel_dsi->ports)

Regards
Shobhit

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

PATCH v2 1/1 drm/i915/dsi: set max return packet size for each dsi port

In reply to Jani Nikula

This seems like the right thing to do. This also gets rid of a call to intel_dsi_pipe_to_port() which we want to remove eventually.

v2: add braces to fix else logic (Shobhit)

---
 drivers/gpu/drm/i915/intel_dsi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +5 -5
index 4bb9886fa2cf..dac41046a0cc 100644
@@ -197,15 +197,15 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
 {
 	struct drm_device *dev = encoder->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
+	enum port port;
 
 	DRM_DEBUG_KMS("\n");
 
-	if (is_cmd_mode(intel_dsi))
-		I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
-	else {
+	if (is_cmd_mode(intel_dsi)) {
+		for_each_dsi_port(port, intel_dsi->ports)
+			I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
+	} else {
 		msleep(20); /* XXX */
 		for_each_dsi_port(port, intel_dsi->ports)
 			dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN, port);
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

In reply to Shobhit Kumar
Quoted 45 lines · Shobhit Kumar
Quoted 44 lines · Jani Nikula

Remove all the trivial and/or dummy callbacks from intel dsi device ops. Merge send_otp_cmds into panel_reset as they're called back to back.

This will be helpful for switching to use drm_panel for the callbacks. If we ever need the additional callbacks, we should add them to drm_panel funcs.

---
  drivers/gpu/drm/i915/intel_dsi.c           | 32 ++-------------------
  drivers/gpu/drm/i915/intel_dsi.h           | 20 -------------
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 45 ++----------------------------
  3 files changed, 5 insertions(+), 92 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +0 -7
index 9b0eaa9db845..fc218b7754b3 100644
@@ -70,12 +70,6 @@ static void band_gap_reset(struct drm_i915_private *dev_priv)
  	mutex_unlock(&dev_priv->dpio_lock);
  }
 
-static struct intel_dsi *intel_attached_dsi(struct drm_connector *connector)
-{
-	return container_of(intel_attached_encoder(connector),
-			    struct intel_dsi, base);
-}
-
  static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
  {
  	return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE;
@@ -99,7 +93,6 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  	struct intel_connector *intel_connector = intel_dsi->attached_connector;
  	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  	struct drm_display_mode *adjusted_mode = &config->adjusted_mode;
-	struct drm_display_mode *mode = &config->requested_mode;
 
  	DRM_DEBUG_KMS("\n");
 
@@ -109,10 +102,6 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  	/* DSI uses short packets for sync events, so clear mode flags for DSI */
  	adjusted_mode->flags = 0;
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_dsi.c static bool intel_dsi_compute_config(struct intel_encoder *encoder, · line 115

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi.c +0 -4
-	if (intel_dsi->dev.dev_ops->mode_fixup)
-		return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev,
-							  mode, adjusted_mode);
-

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Can we just have the driver return the desired mode from .get_modes in that case?

BR,
Jani.

Quoted 194 lines

Either way

Quoted 172 lines
drivers/gpu/drm/i915/intel_dsi.c +2 -19
  	return true;
  }
 
@@ -269,9 +258,6 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
  	if (intel_dsi->dev.dev_ops->panel_reset)
  		intel_dsi->dev.dev_ops->panel_reset(&intel_dsi->dev);
 
-	if (intel_dsi->dev.dev_ops->send_otp_cmds)
-		intel_dsi->dev.dev_ops->send_otp_cmds(&intel_dsi->dev);
-
  	for_each_dsi_port(port, intel_dsi->ports)
  		wait_for_dsi_fifo_empty(intel_dsi, port);
 
@@ -484,7 +470,6 @@ intel_dsi_mode_valid(struct drm_connector *connector,
  {
  	struct intel_connector *intel_connector = to_intel_connector(connector);
  	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
 
  	DRM_DEBUG_KMS("\n");
 
@@ -500,7 +485,7 @@ intel_dsi_mode_valid(struct drm_connector *connector,
  			return MODE_PANEL;
  	}
 
-	return intel_dsi->dev.dev_ops->mode_valid(&intel_dsi->dev, mode);
+	return MODE_OK;
  }
 
  /* return txclkesc cycles in terms of divider and duration in us */
@@ -749,20 +734,7 @@ static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
  static enum drm_connector_status
  intel_dsi_detect(struct drm_connector *connector, bool force)
  {
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
-	struct intel_encoder *intel_encoder = &intel_dsi->base;
-	enum intel_display_power_domain power_domain;
-	enum drm_connector_status connector_status;
-	struct drm_i915_private *dev_priv = intel_encoder->base.dev->dev_private;
-
-	DRM_DEBUG_KMS("\n");
-	power_domain = intel_display_port_power_domain(intel_encoder);
-
-	intel_display_power_get(dev_priv, power_domain);
-	connector_status = intel_dsi->dev.dev_ops->detect(&intel_dsi->dev);
-	intel_display_power_put(dev_priv, power_domain);
-
-	return connector_status;
+	return connector_status_connected;
  }
 
  static int intel_dsi_get_modes(struct drm_connector *connector)
drivers/gpu/drm/i915/intel_dsi.h +0 -20
index 2bb8c46c7889..22f87036a256 100644
@@ -47,33 +47,13 @@ struct intel_dsi_dev_ops {
 
  	void (*disable_panel_power)(struct intel_dsi_device *dsi);
 
-	/* one time programmable commands if needed */
-	void (*send_otp_cmds)(struct intel_dsi_device *dsi);
-
  	/* This callback must be able to assume DSI commands can be sent */
  	void (*enable)(struct intel_dsi_device *dsi);
 
  	/* This callback must be able to assume DSI commands can be sent */
  	void (*disable)(struct intel_dsi_device *dsi);
 
-	int (*mode_valid)(struct intel_dsi_device *dsi,
-			  struct drm_display_mode *mode);
-
-	bool (*mode_fixup)(struct intel_dsi_device *dsi,
-			   const struct drm_display_mode *mode,
-			   struct drm_display_mode *adjusted_mode);
-
-	void (*mode_set)(struct intel_dsi_device *dsi,
-			 struct drm_display_mode *mode,
-			 struct drm_display_mode *adjusted_mode);
-
-	enum drm_connector_status (*detect)(struct intel_dsi_device *dsi);
-
-	bool (*get_hw_state)(struct intel_dsi_device *dev);
-
  	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-
-	void (*destroy) (struct intel_dsi_device *dsi);
  };
 
  struct intel_dsi {
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +3 -38
index 5493aef5a6a3..b0e7327a485f 100644
@@ -559,18 +559,6 @@ static bool generic_init(struct intel_dsi_device *dsi)
  	return true;
  }
 
-static int generic_mode_valid(struct intel_dsi_device *dsi,
-		   struct drm_display_mode *mode)
-{
-	return MODE_OK;
-}
-
-static bool generic_mode_fixup(struct intel_dsi_device *dsi,
-		    const struct drm_display_mode *mode,
-		    struct drm_display_mode *adjusted_mode) {
-	return true;
-}
-
  static void generic_panel_reset(struct intel_dsi_device *dsi)
  {
  	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
@@ -580,26 +568,18 @@ static void generic_panel_reset(struct intel_dsi_device *dsi)
  	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET];
 
  	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static void generic_disable_panel_power(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
 
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
  	generic_exec_sequence(intel_dsi, sequence);
  }
 
-static void generic_send_otp_cmds(struct intel_dsi_device *dsi)
+static void generic_disable_panel_power(struct intel_dsi_device *dsi)
  {
  	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
  	struct drm_device *dev = intel_dsi->base.base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
+	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
 
  	generic_exec_sequence(intel_dsi, sequence);
  }
@@ -626,16 +606,6 @@ static void generic_disable(struct intel_dsi_device *dsi)
  	generic_exec_sequence(intel_dsi, sequence);
  }
 
-static enum drm_connector_status generic_detect(struct intel_dsi_device *dsi)
-{
-	return connector_status_connected;
-}
-
-static bool generic_get_hw_state(struct intel_dsi_device *dev)
-{
-	return true;
-}
-
  static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi)
  {
  	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
@@ -646,20 +616,11 @@ static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi)
  	return dev_priv->vbt.lfp_lvds_vbt_mode;
  }
 
-static void generic_destroy(struct intel_dsi_device *dsi) { }
-
-/* Callbacks. We might not need them all. */
  struct intel_dsi_dev_ops vbt_generic_dsi_display_ops = {
  	.init = generic_init,
-	.mode_valid = generic_mode_valid,
-	.mode_fixup = generic_mode_fixup,

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi) · line 626

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -4
  	.panel_reset = generic_panel_reset,
  	.disable_panel_power = generic_disable_panel_power,
-	.send_otp_cmds = generic_send_otp_cmds,
  	.enable = generic_enable,
  	.disable = generic_disable,
-	.detect = generic_detect,
-	.get_hw_state = generic_get_hw_state,
  	.get_modes = generic_get_modes,
-	.destroy = generic_destroy,
  };

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#42 lore raw
In reply to Shobhit Kumar
Quoted 10 lines · Shobhit Kumar
Quoted 5 lines · Jani Nikula

This series ports our DSI code over to the drm_panel and mipi_dsi_host/mipi_dsi_device. There are some rough edges towards the end of the series, see commit message for patch 8 for details.

Patches 1-6 are prep work, fairly independent

While I continue to review, quick test of patches show that till here it is fine(with minor fix for Patch 2), but from Patch 7 on wards things really don't work.

Okay, thanks for the review so far and trying it out.

What breaks down with patch 7? Which device are you trying this on?

BR,
Jani.

Quoted 41 lines
Quoted 35 lines

Patch 7 ports the driver over to drm_panel

Patches 8-10 port the driver over to mipi_dsi_host/device

Patches 11-12 do some additional cleanup

BR,
Jani.

Jani Nikula (12):
drm/i915/dsi: call dpi_send_cmd() for each dsi port at a higher level drm/i915/dsi: set max return packet size for each dsi port drm/i915/dsi: move wait_for_dsi_fifo_empty to intel_dsi.c drm/i915/dsi: call wait_for_dsi_fifo_empty() for each dsi port drm/i915/dsi: remove unnecessary dsi device callbacks drm/i915/dsi: add some constness to vbt panel driver drm/i915/dsi: switch to drm_panel interface
drm/i915/dsi: add drm mipi dsi host support
drm/i915/dsi: make the vbt panel driver use mipi_dsi_device for
transfers
drm/i915/dsi: remove old read/write functions in favor of new stuff drm/i915/dsi: move dpi_send_cmd() to intel_dsi.c and make it static drm/i915/dsi: remove intel_dsi_cmd.c and the unused functions therein

  drivers/gpu/drm/i915/Kconfig               |   2 +
  drivers/gpu/drm/i915/Makefile              |   1 -
  drivers/gpu/drm/i915/intel_dsi.c           | 336 +++++++++++++++++-----
  drivers/gpu/drm/i915/intel_dsi.h           |  69 ++---
  drivers/gpu/drm/i915/intel_dsi_cmd.c       | 432 -----------------------------
  drivers/gpu/drm/i915/intel_dsi_cmd.h       |  78 ------
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 289 ++++++++++---------
  7 files changed, 441 insertions(+), 766 deletions(-)
Quoted 2 lines

delete mode 100644 drivers/gpu/drm/i915/intel_dsi_cmd.c

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 1/1
#7 lore raw

Re: [PATCH v2] drm/i915/dsi: set max return packet size for each dsi port

In reply to Jani Nikula
Quoted 26 lines · Jani Nikula

This seems like the right thing to do. This also gets rid of a call to intel_dsi_pipe_to_port() which we want to remove eventually.

v2: add braces to fix else logic (Shobhit)

---
  drivers/gpu/drm/i915/intel_dsi.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +1 -2
index 4bb9886fa2cf..dac41046a0cc 100644
@@ -197,15 +197,15 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
  {
  	struct drm_device *dev = encoder->base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
-	enum port port = intel_dsi_pipe_to_port(intel_crtc->pipe);
+	enum port port;
 
  	DRM_DEBUG_KMS("\n");
 

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_enable(struct intel_encoder *encoder) · line 211

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi.c +4 -3
-	if (is_cmd_mode(intel_dsi))
-		I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
-	else {
+	if (is_cmd_mode(intel_dsi)) {
+		for_each_dsi_port(port, intel_dsi->ports)
+			I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
+	} else {
  		msleep(20); /* XXX */
  		for_each_dsi_port(port, intel_dsi->ports)
  			dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN, port);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#43 lore raw
In reply to Jani Nikula
Quoted 8 lines · Jani Nikula
Quoted 7 lines · Shobhit Kumar
Quoted 5 lines · Jani Nikula

This series ports our DSI code over to the drm_panel and mipi_dsi_host/mipi_dsi_device. There are some rough edges towards the end of the series, see commit message for patch 8 for details.

Patches 1-6 are prep work, fairly independent

Quoted 7 lines
Quoted 3 lines

While I continue to review, quick test of patches show that till here it is fine(with minor fix for Patch 2), but from Patch 7 on wards things really don't work.

Okay, thanks for the review so far and trying it out.

What breaks down with patch 7? Which device are you trying this on?

It just hangs during bootup console. Guessing there is some kernel panic somewhere but the Asus T100 on which I am trying does not have serial to get logs. Will try to debug today.

Regards
Shobhit

Quoted 47 lines

BR,
Jani.

Quoted 41 lines
Quoted 35 lines

Patch 7 ports the driver over to drm_panel

Patches 8-10 port the driver over to mipi_dsi_host/device

Patches 11-12 do some additional cleanup

BR,
Jani.

Jani Nikula (12):
drm/i915/dsi: call dpi_send_cmd() for each dsi port at a higher level drm/i915/dsi: set max return packet size for each dsi port drm/i915/dsi: move wait_for_dsi_fifo_empty to intel_dsi.c drm/i915/dsi: call wait_for_dsi_fifo_empty() for each dsi port drm/i915/dsi: remove unnecessary dsi device callbacks drm/i915/dsi: add some constness to vbt panel driver drm/i915/dsi: switch to drm_panel interface
drm/i915/dsi: add drm mipi dsi host support
drm/i915/dsi: make the vbt panel driver use mipi_dsi_device for
transfers
drm/i915/dsi: remove old read/write functions in favor of new stuff drm/i915/dsi: move dpi_send_cmd() to intel_dsi.c and make it static drm/i915/dsi: remove intel_dsi_cmd.c and the unused functions therein

   drivers/gpu/drm/i915/Kconfig               |   2 +
   drivers/gpu/drm/i915/Makefile              |   1 -
   drivers/gpu/drm/i915/intel_dsi.c           | 336 +++++++++++++++++-----
   drivers/gpu/drm/i915/intel_dsi.h           |  69 ++---
   drivers/gpu/drm/i915/intel_dsi_cmd.c       | 432 -----------------------------
   drivers/gpu/drm/i915/intel_dsi_cmd.h       |  78 ------
   drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 289 ++++++++++---------
   7 files changed, 441 insertions(+), 766 deletions(-)
Quoted 2 lines

delete mode 100644 drivers/gpu/drm/i915/intel_dsi_cmd.c

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#15 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

In reply to Jani Nikula
Quoted 59 lines · Jani Nikula
Quoted 45 lines · Shobhit Kumar
Quoted 44 lines · Jani Nikula

Remove all the trivial and/or dummy callbacks from intel dsi device ops. Merge send_otp_cmds into panel_reset as they're called back to back.

This will be helpful for switching to use drm_panel for the callbacks. If we ever need the additional callbacks, we should add them to drm_panel funcs.

---
   drivers/gpu/drm/i915/intel_dsi.c           | 32 ++-------------------
   drivers/gpu/drm/i915/intel_dsi.h           | 20 -------------
   drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 45 ++----------------------------
   3 files changed, 5 insertions(+), 92 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +0 -7
index 9b0eaa9db845..fc218b7754b3 100644
@@ -70,12 +70,6 @@ static void band_gap_reset(struct drm_i915_private *dev_priv)
   	mutex_unlock(&dev_priv->dpio_lock);
   }
 
-static struct intel_dsi *intel_attached_dsi(struct drm_connector *connector)
-{
-	return container_of(intel_attached_encoder(connector),
-			    struct intel_dsi, base);
-}
-
   static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
   {
   	return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE;
@@ -99,7 +93,6 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
   	struct intel_connector *intel_connector = intel_dsi->attached_connector;
   	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
   	struct drm_display_mode *adjusted_mode = &config->adjusted_mode;
-	struct drm_display_mode *mode = &config->requested_mode;
 
   	DRM_DEBUG_KMS("\n");
 
@@ -109,10 +102,6 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
   	/* DSI uses short packets for sync events, so clear mode flags for DSI */
   	adjusted_mode->flags = 0;
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_dsi.c static bool intel_dsi_compute_config(struct intel_encoder *encoder, · line 115

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi.c +0 -4
-	if (intel_dsi->dev.dev_ops->mode_fixup)
-		return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev,
-							  mode, adjusted_mode);
-

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Quoted 2 lines

Can we just have the driver return the desired mode from .get_modes in that case?

Okay, I think I did not explain correctly. Get modes is modified to give the needed target mode only so that userspace creates buffer of the needed resolution, but in fixup which is called at modeset, we correct the adjusted_mode back to have native resolutions so that modeset is correctly done. if we do not do like this, during modeset resolutions will be wrong as per the timings.

Regards
Shobhit

Quoted 200 lines

BR,
Jani.

Quoted 194 lines

Either way

Quoted 172 lines
drivers/gpu/drm/i915/intel_dsi.c +2 -19
   	return true;
   }
 
@@ -269,9 +258,6 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
   	if (intel_dsi->dev.dev_ops->panel_reset)
   		intel_dsi->dev.dev_ops->panel_reset(&intel_dsi->dev);
 
-	if (intel_dsi->dev.dev_ops->send_otp_cmds)
-		intel_dsi->dev.dev_ops->send_otp_cmds(&intel_dsi->dev);
-
   	for_each_dsi_port(port, intel_dsi->ports)
   		wait_for_dsi_fifo_empty(intel_dsi, port);
 
@@ -484,7 +470,6 @@ intel_dsi_mode_valid(struct drm_connector *connector,
   {
   	struct intel_connector *intel_connector = to_intel_connector(connector);
   	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
 
   	DRM_DEBUG_KMS("\n");
 
@@ -500,7 +485,7 @@ intel_dsi_mode_valid(struct drm_connector *connector,
   			return MODE_PANEL;
   	}
 
-	return intel_dsi->dev.dev_ops->mode_valid(&intel_dsi->dev, mode);
+	return MODE_OK;
   }
 
   /* return txclkesc cycles in terms of divider and duration in us */
@@ -749,20 +734,7 @@ static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
   static enum drm_connector_status
   intel_dsi_detect(struct drm_connector *connector, bool force)
   {
-	struct intel_dsi *intel_dsi = intel_attached_dsi(connector);
-	struct intel_encoder *intel_encoder = &intel_dsi->base;
-	enum intel_display_power_domain power_domain;
-	enum drm_connector_status connector_status;
-	struct drm_i915_private *dev_priv = intel_encoder->base.dev->dev_private;
-
-	DRM_DEBUG_KMS("\n");
-	power_domain = intel_display_port_power_domain(intel_encoder);
-
-	intel_display_power_get(dev_priv, power_domain);
-	connector_status = intel_dsi->dev.dev_ops->detect(&intel_dsi->dev);
-	intel_display_power_put(dev_priv, power_domain);
-
-	return connector_status;
+	return connector_status_connected;
   }
 
   static int intel_dsi_get_modes(struct drm_connector *connector)
drivers/gpu/drm/i915/intel_dsi.h +0 -20
index 2bb8c46c7889..22f87036a256 100644
@@ -47,33 +47,13 @@ struct intel_dsi_dev_ops {
 
   	void (*disable_panel_power)(struct intel_dsi_device *dsi);
 
-	/* one time programmable commands if needed */
-	void (*send_otp_cmds)(struct intel_dsi_device *dsi);
-
   	/* This callback must be able to assume DSI commands can be sent */
   	void (*enable)(struct intel_dsi_device *dsi);
 
   	/* This callback must be able to assume DSI commands can be sent */
   	void (*disable)(struct intel_dsi_device *dsi);
 
-	int (*mode_valid)(struct intel_dsi_device *dsi,
-			  struct drm_display_mode *mode);
-
-	bool (*mode_fixup)(struct intel_dsi_device *dsi,
-			   const struct drm_display_mode *mode,
-			   struct drm_display_mode *adjusted_mode);
-
-	void (*mode_set)(struct intel_dsi_device *dsi,
-			 struct drm_display_mode *mode,
-			 struct drm_display_mode *adjusted_mode);
-
-	enum drm_connector_status (*detect)(struct intel_dsi_device *dsi);
-
-	bool (*get_hw_state)(struct intel_dsi_device *dev);
-
   	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-
-	void (*destroy) (struct intel_dsi_device *dsi);
   };
 
   struct intel_dsi {
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +3 -38
index 5493aef5a6a3..b0e7327a485f 100644
@@ -559,18 +559,6 @@ static bool generic_init(struct intel_dsi_device *dsi)
   	return true;
   }
 
-static int generic_mode_valid(struct intel_dsi_device *dsi,
-		   struct drm_display_mode *mode)
-{
-	return MODE_OK;
-}
-
-static bool generic_mode_fixup(struct intel_dsi_device *dsi,
-		    const struct drm_display_mode *mode,
-		    struct drm_display_mode *adjusted_mode) {
-	return true;
-}
-
   static void generic_panel_reset(struct intel_dsi_device *dsi)
   {
   	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
@@ -580,26 +568,18 @@ static void generic_panel_reset(struct intel_dsi_device *dsi)
   	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET];
 
   	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static void generic_disable_panel_power(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
 
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
   	generic_exec_sequence(intel_dsi, sequence);
   }
 
-static void generic_send_otp_cmds(struct intel_dsi_device *dsi)
+static void generic_disable_panel_power(struct intel_dsi_device *dsi)
   {
   	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
   	struct drm_device *dev = intel_dsi->base.base.dev;
   	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
+	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
 
   	generic_exec_sequence(intel_dsi, sequence);
   }
@@ -626,16 +606,6 @@ static void generic_disable(struct intel_dsi_device *dsi)
   	generic_exec_sequence(intel_dsi, sequence);
   }
 
-static enum drm_connector_status generic_detect(struct intel_dsi_device *dsi)
-{
-	return connector_status_connected;
-}
-
-static bool generic_get_hw_state(struct intel_dsi_device *dev)
-{
-	return true;
-}
-
   static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi)
   {
   	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
@@ -646,20 +616,11 @@ static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi)
   	return dev_priv->vbt.lfp_lvds_vbt_mode;
   }
 
-static void generic_destroy(struct intel_dsi_device *dsi) { }
-
-/* Callbacks. We might not need them all. */
   struct intel_dsi_dev_ops vbt_generic_dsi_display_ops = {
   	.init = generic_init,
-	.mode_valid = generic_mode_valid,
-	.mode_fixup = generic_mode_fixup,

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi) · line 626

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -4
   	.panel_reset = generic_panel_reset,
   	.disable_panel_power = generic_disable_panel_power,
-	.send_otp_cmds = generic_send_otp_cmds,
   	.enable = generic_enable,
   	.disable = generic_disable,
-	.detect = generic_detect,
-	.get_hw_state = generic_get_hw_state,
   	.get_modes = generic_get_modes,
-	.destroy = generic_destroy,
   };

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#25 lore raw

Re: [RFC PATCH 07/12] drm/i915/dsi: switch to drm_panel interface

In reply to Jani Nikula
Quoted 170 lines · Jani Nikula

Replace intel_dsi_device and intel_dsi_dev_ops with drm_panel and drm_panel_funcs. They are adequate for what we have now, and if we end up needing more than this we should improve drm_panel. This will keep us better aligned with the drm core infrastructure.

The panel driver initialization changes a bit. It still remains hideous, but fixing that is beyond the scope here.

---
  drivers/gpu/drm/i915/Kconfig               |   1 +
  drivers/gpu/drm/i915/intel_dsi.c           |  68 +++++++----
  drivers/gpu/drm/i915/intel_dsi.h           |  27 +----
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 179 ++++++++++++++++++-----------
  4 files changed, 156 insertions(+), 119 deletions(-)
drivers/gpu/drm/i915/Kconfig +1 -0
index 4e39ab34eb1c..da196cd07263 100644
@@ -11,6 +11,7 @@ config DRM_I915
  	select SHMEM
  	select TMPFS
  	select DRM_KMS_HELPER
+	select DRM_PANEL
  	# i915 depends on ACPI_VIDEO when ACPI is enabled
  	# but for select to work, need to select ACPI_VIDEO's dependencies, ick
  	select BACKLIGHT_LCD_SUPPORT if ACPI
drivers/gpu/drm/i915/intel_dsi.c +31 -23
index fc218b7754b3..19a9955eab0e 100644
@@ -27,18 +27,20 @@
  #include <drm/drm_crtc.h>
  #include <drm/drm_edid.h>
  #include <drm/i915_drm.h>
+#include <drm/drm_panel.h>
  #include <linux/slab.h>
  #include "i915_drv.h"
  #include "intel_drv.h"
  #include "intel_dsi.h"
  #include "intel_dsi_cmd.h"
 
-/* the sub-encoders aka panel drivers */
-static const struct intel_dsi_device intel_dsi_devices[] = {
+static const struct {
+	u16 panel_id;
+	struct drm_panel * (*init)(struct intel_dsi *intel_dsi, u16 panel_id);
+} intel_dsi_drivers[] = {
  	{
  		.panel_id = MIPI_DSI_GENERIC_PANEL_ID,
-		.name = "vbt-generic-dsi-vid-mode-display",
-		.dev_ops = &vbt_generic_dsi_display_ops,
+		.init = vbt_panel_init,
  	},
  };
 
@@ -214,8 +216,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
  			dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN, port);
  		msleep(100);
 
-		if (intel_dsi->dev.dev_ops->enable)
-			intel_dsi->dev.dev_ops->enable(&intel_dsi->dev);
+		drm_panel_enable(intel_dsi->panel);
 
  		for_each_dsi_port(port, intel_dsi->ports)
  			wait_for_dsi_fifo_empty(intel_dsi, port);
@@ -255,8 +256,7 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 
  	msleep(intel_dsi->panel_on_delay);
 
-	if (intel_dsi->dev.dev_ops->panel_reset)
-		intel_dsi->dev.dev_ops->panel_reset(&intel_dsi->dev);
+	drm_panel_prepare(intel_dsi->panel);
 
  	for_each_dsi_port(port, intel_dsi->ports)
  		wait_for_dsi_fifo_empty(intel_dsi, port);
@@ -329,8 +329,7 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
  	}
  	/* if disable packets are sent before sending shutdown packet then in
  	 * some next enable sequence send turn on packet error is observed */
-	if (intel_dsi->dev.dev_ops->disable)
-		intel_dsi->dev.dev_ops->disable(&intel_dsi->dev);
+	drm_panel_disable(intel_dsi->panel);
 
  	for_each_dsi_port(port, intel_dsi->ports)
  		wait_for_dsi_fifo_empty(intel_dsi, port);
@@ -395,8 +394,7 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
  	val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
  	I915_WRITE(DSPCLK_GATE_D, val);
 
-	if (intel_dsi->dev.dev_ops->disable_panel_power)
-		intel_dsi->dev.dev_ops->disable_panel_power(&intel_dsi->dev);
+	drm_panel_unprepare(intel_dsi->panel);
 
  	msleep(intel_dsi->panel_off_delay);
  	msleep(intel_dsi->panel_pwr_cycle_delay);
@@ -760,7 +758,7 @@ static int intel_dsi_get_modes(struct drm_connector *connector)
  	return 1;
  }
 
-static void intel_dsi_destroy(struct drm_connector *connector)
+static void intel_dsi_connector_destroy(struct drm_connector *connector)
  {
  	struct intel_connector *intel_connector = to_intel_connector(connector);
 
@@ -770,8 +768,20 @@ static void intel_dsi_destroy(struct drm_connector *connector)
  	kfree(connector);
  }
 
+static void intel_dsi_encoder_destroy(struct drm_encoder *encoder)
+{
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
+
+	if (intel_dsi->panel) {
+		drm_panel_detach(intel_dsi->panel);
+		/* XXX: Logically this call belongs in the panel driver. */
+		drm_panel_remove(intel_dsi->panel);
+	}
+	intel_encoder_destroy(encoder);
+}
+
  static const struct drm_encoder_funcs intel_dsi_funcs = {
-	.destroy = intel_encoder_destroy,
+	.destroy = intel_dsi_encoder_destroy,
  };
 
  static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs = {
@@ -783,7 +793,7 @@ static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs
  static const struct drm_connector_funcs intel_dsi_connector_funcs = {
  	.dpms = intel_connector_dpms,
  	.detect = intel_dsi_detect,
-	.destroy = intel_dsi_destroy,
+	.destroy = intel_dsi_connector_destroy,
  	.fill_modes = drm_helper_probe_single_connector_modes,
  };
 
@@ -794,9 +804,8 @@ void intel_dsi_init(struct drm_device *dev)
  	struct drm_encoder *encoder;
  	struct intel_connector *intel_connector;
  	struct drm_connector *connector;
-	struct drm_display_mode *fixed_mode = NULL;
+	struct drm_display_mode *scan, *fixed_mode = NULL;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	const struct intel_dsi_device *dsi;
  	unsigned int i;
 
  	DRM_DEBUG_KMS("\n");
@@ -853,15 +862,14 @@ void intel_dsi_init(struct drm_device *dev)
  		intel_dsi->ports = (1 << PORT_C);
  	}
 
-	for (i = 0; i < ARRAY_SIZE(intel_dsi_devices); i++) {
-		dsi = &intel_dsi_devices[i];
-		intel_dsi->dev = *dsi;
-
-		if (dsi->dev_ops->init(&intel_dsi->dev))
+	for (i = 0; i < ARRAY_SIZE(intel_dsi_drivers); i++) {
+		intel_dsi->panel = intel_dsi_drivers[i].init(intel_dsi,
+							     intel_dsi_drivers[i].panel_id);
+		if (intel_dsi->panel)
  			break;
  	}
 
-	if (i == ARRAY_SIZE(intel_dsi_devices)) {
+	if (!intel_dsi->panel) {
  		DRM_DEBUG_KMS("no device found\n");
  		goto err;
  	}

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 893

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi.c +2 -1
@@ -881,13 +889,23 @@ void intel_dsi_init(struct drm_device *dev)
 
  	drm_connector_register(connector);
 
-	fixed_mode = dsi->dev_ops->get_modes(&intel_dsi->dev);
+	drm_panel_attach(intel_dsi->panel, connector);
+	drm_panel_get_modes(intel_dsi->panel);

Should be inside the config mutex_lock below.

Quoted 256 lines
drivers/gpu/drm/i915/intel_dsi.c +10 -1
+
+	mutex_lock(&dev->mode_config.mutex);
+	list_for_each_entry(scan, &connector->probed_modes, head) {
+		if ((scan->type & DRM_MODE_TYPE_PREFERRED)) {
+			fixed_mode = drm_mode_duplicate(dev, scan);
+			break;
+		}
+	}
+	mutex_unlock(&dev->mode_config.mutex);
+
  	if (!fixed_mode) {
  		DRM_DEBUG_KMS("no fixed mode\n");
  		goto err;
  	}
 
-	fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
  	return;
drivers/gpu/drm/i915/intel_dsi.h +2 -25
index 22f87036a256..fc0b2b8d90f1 100644
@@ -33,33 +33,10 @@
  #define DSI_DUAL_LINK_FRONT_BACK	1
  #define DSI_DUAL_LINK_PIXEL_ALT		2
 
-struct intel_dsi_device {
-	unsigned int panel_id;
-	const char *name;
-	const struct intel_dsi_dev_ops *dev_ops;
-	void *dev_priv;
-};
-
-struct intel_dsi_dev_ops {
-	bool (*init)(struct intel_dsi_device *dsi);
-
-	void (*panel_reset)(struct intel_dsi_device *dsi);
-
-	void (*disable_panel_power)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*enable)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*disable)(struct intel_dsi_device *dsi);
-
-	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-};
-
  struct intel_dsi {
  	struct intel_encoder base;
 
-	struct intel_dsi_device dev;
+	struct drm_panel *panel;
 
  	struct intel_connector *attached_connector;
 
@@ -130,6 +107,6 @@ extern void vlv_enable_dsi_pll(struct intel_encoder *encoder);
  extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
  extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 
-extern struct intel_dsi_dev_ops vbt_generic_dsi_display_ops;
+struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id);
 
  #endif /* _INTEL_DSI_H */
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +104 -37
index 561ec2981dfd..204f54df8fe1 100644
@@ -28,6 +28,7 @@
  #include <drm/drm_crtc.h>
  #include <drm/drm_edid.h>
  #include <drm/i915_drm.h>
+#include <drm/drm_panel.h>
  #include <linux/slab.h>
  #include <video/mipi_display.h>
  #include <asm/intel-mid.h>
@@ -37,6 +38,16 @@
  #include "intel_dsi.h"
  #include "intel_dsi_cmd.h"
 
+struct vbt_panel {
+	struct drm_panel panel;
+	struct intel_dsi *intel_dsi;
+};
+
+static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel)
+{
+	return container_of(panel, struct vbt_panel, panel);
+}
+
  #define MIPI_TRANSFER_MODE_SHIFT	0
  #define MIPI_VIRTUAL_CHANNEL_SHIFT	1
  #define MIPI_PORT_SHIFT			3
@@ -272,14 +283,103 @@ static void generic_exec_sequence(struct intel_dsi *intel_dsi, const u8 *data)
  	}
  }
 
-static bool generic_init(struct intel_dsi_device *dsi)
+static int vbt_panel_prepare(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const u8 *sequence;
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	return 0;
+}
+
+static int vbt_panel_unprepare(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const u8 *sequence;
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	return 0;
+}
+
+static int vbt_panel_enable(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const u8 *sequence;
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DISPLAY_ON];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	return 0;
+}
+
+static int vbt_panel_disable(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const u8 *sequence;
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DISPLAY_OFF];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	return 0;
+}
+
+static int vbt_panel_get_modes(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_display_mode *mode;
+
+	if (!panel->connector)
+		return 0;
+
+	mode = drm_mode_duplicate(dev, dev_priv->vbt.lfp_lvds_vbt_mode);
+	if (!mode)
+		return 0;
+
+	mode->type |= DRM_MODE_TYPE_PREFERRED;
+
+	drm_mode_probed_add(panel->connector, mode);
+
+	return 1;
+}
+
+static const struct drm_panel_funcs vbt_panel_funcs = {
+	.disable = vbt_panel_disable,
+	.unprepare = vbt_panel_unprepare,
+	.prepare = vbt_panel_prepare,
+	.enable = vbt_panel_enable,
+	.get_modes = vbt_panel_get_modes,
+};
+
+struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
  {
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
  	struct drm_device *dev = intel_dsi->base.base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
  	struct mipi_pps_data *pps = dev_priv->vbt.dsi.pps;
  	struct drm_display_mode *mode = dev_priv->vbt.lfp_lvds_vbt_mode;
+	struct vbt_panel *vbt_panel;
  	u32 bits_per_pixel = 24;
  	u32 tlpx_ns, extra_byte_count, bitrate, tlpx_ui;
  	u32 ui_num, ui_den;
@@ -346,7 +446,7 @@ static bool generic_init(struct intel_dsi_device *dsi)
  			if (mipi_config->target_burst_mode_freq <
  								computed_ddr) {
  				DRM_ERROR("Burst mode freq is less than computed\n");
-				return false;
+				return NULL;
  			}
 
  			burst_mode_ratio = DIV_ROUND_UP(
@@ -356,7 +456,7 @@ static bool generic_init(struct intel_dsi_device *dsi)
  			pclk = DIV_ROUND_UP(pclk * burst_mode_ratio, 100);
  		} else {
  			DRM_ERROR("Burst mode target is not set\n");
-			return false;
+			return NULL;
  		}
  	} else
  		burst_mode_ratio = 100;
@@ -557,71 +657,12 @@ static bool generic_init(struct intel_dsi_device *dsi)
  	intel_dsi->panel_off_delay = pps->panel_off_delay / 10;
  	intel_dsi->panel_pwr_cycle_delay = pps->panel_power_cycle_delay / 10;
 
-	return true;
-}
-
-static void generic_panel_reset(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET];
-
-	generic_exec_sequence(intel_dsi, sequence);
-
-	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
-	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static void generic_disable_panel_power(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
-
-	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static void generic_enable(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static bool generic_init(struct intel_dsi_device *dsi) · line 667

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +6 -2
+	/* This is cheating a bit with the cleanup. */
+	vbt_panel = devm_kzalloc(dev->dev, sizeof(*vbt_panel), GFP_KERNEL);
 
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DISPLAY_ON];
+	drm_panel_init(&vbt_panel->panel);
+	vbt_panel->panel.funcs = &vbt_panel_funcs;
+	drm_panel_add(&vbt_panel->panel);
 
-	generic_exec_sequence(intel_dsi, sequence);
+	return &vbt_panel->panel;

You just missed vbt_panel->intel_dsi = intel_dsi; before returning

Regards
Shobhit

Quoted 22 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -20
  }
-
-static void generic_disable(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DISPLAY_OFF];
-
-	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	dev_priv->vbt.lfp_lvds_vbt_mode->type |= DRM_MODE_TYPE_PREFERRED;
-	return dev_priv->vbt.lfp_lvds_vbt_mode;

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static bool generic_init(struct intel_dsi_device *dsi) · line 627

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -10
-}
-
-struct intel_dsi_dev_ops vbt_generic_dsi_display_ops = {
-	.init = generic_init,
-	.panel_reset = generic_panel_reset,
-	.disable_panel_power = generic_disable_panel_power,
-	.enable = generic_enable,
-	.disable = generic_disable,
-	.get_modes = generic_get_modes,
-};

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 8/12
#31 lore raw

Re: [RFC PATCH 08/12] drm/i915/dsi: add drm mipi dsi host support

In reply to Jani Nikula
Quoted 9 lines · Jani Nikula

Add basic support for using the drm mipi dsi framework for DSI. We don't use device tree which is pretty much required by mipi_dsi_host_register and friends, and we don't have the kind of device model the functions expect either. So we cheat and use it as a library to abstract what we
need: a nice, clean interface for DSI transfers. This means we will have to be careful with what functions we call, as the driver model devices in mipi_dsi_host and mipi_dsi_device will *not* be initialized.

Looks good.

Quoted 273 lines
---
  drivers/gpu/drm/i915/Kconfig               |   1 +
  drivers/gpu/drm/i915/intel_dsi.c           | 162 ++++++++++++++++++++++++++++-
  drivers/gpu/drm/i915/intel_dsi.h           |  18 ++++
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |   3 -
  4 files changed, 180 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/Kconfig +1 -0
index da196cd07263..74acca9bcd9d 100644
@@ -12,6 +12,7 @@ config DRM_I915
  	select TMPFS
  	select DRM_KMS_HELPER
  	select DRM_PANEL
+	select DRM_MIPI_DSI
  	# i915 depends on ACPI_VIDEO when ACPI is enabled
  	# but for select to work, need to select ACPI_VIDEO's dependencies, ick
  	select BACKLIGHT_LCD_SUPPORT if ACPI
drivers/gpu/drm/i915/intel_dsi.c +161 -1
index 19a9955eab0e..5cfa3431785a 100644
@@ -28,6 +28,7 @@
  #include <drm/drm_edid.h>
  #include <drm/i915_drm.h>
  #include <drm/drm_panel.h>
+#include <drm/drm_mipi_dsi.h>
  #include <linux/slab.h>
  #include "i915_drv.h"
  #include "intel_drv.h"
@@ -58,6 +59,149 @@ static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi, enum port port)
  		DRM_ERROR("DPI FIFOs are not empty\n");
  }
 
+static void write_data(struct drm_i915_private *dev_priv, u32 reg,
+		       const u8 *data, u32 len)
+{
+	u32 i, j;
+
+	for (i = 0; i < len; i += 4) {
+		u32 val = 0;
+
+		for (j = 0; j < min_t(u32, len - i, 4); j++)
+			val |= *data++ << 8 * j;
+
+		I915_WRITE(reg, val);
+	}
+}
+
+static void read_data(struct drm_i915_private *dev_priv, u32 reg,
+		      u8 *data, u32 len)
+{
+	u32 i, j;
+
+	for (i = 0; i < len; i += 4) {
+		u32 val = I915_READ(reg);
+
+		for (j = 0; j < min_t(u32, len - i, 4); j++)
+			*data++ = val >> 8 * j;
+	}
+}
+
+static ssize_t intel_dsi_host_transfer(struct mipi_dsi_host *host,
+				       const struct mipi_dsi_msg *msg)
+{
+	struct intel_dsi_host *intel_dsi_host = to_intel_dsi_host(host);
+	struct drm_device *dev = intel_dsi_host->intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	enum port port = intel_dsi_host->port;
+	struct mipi_dsi_packet packet;
+	ssize_t ret;
+	const u8 *header, *data;
+	u32 data_reg, data_mask, ctrl_reg, ctrl_mask;
+
+	ret = mipi_dsi_create_packet(&packet, msg);
+	if (ret < 0)
+		return ret;
+
+	header = packet.header;
+	data = packet.payload;
+
+	if (msg->flags & MIPI_DSI_MSG_USE_LPM) {
+		data_reg = MIPI_LP_GEN_DATA(port);
+		data_mask = LP_DATA_FIFO_FULL;
+		ctrl_reg = MIPI_LP_GEN_CTRL(port);
+		ctrl_mask = LP_CTRL_FIFO_FULL;
+	} else {
+		data_reg = MIPI_HS_GEN_DATA(port);
+		data_mask = HS_DATA_FIFO_FULL;
+		ctrl_reg = MIPI_HS_GEN_CTRL(port);
+		ctrl_mask = HS_CTRL_FIFO_FULL;
+	}
+
+	/* note: this is never true for reads */
+	if (packet.payload_length) {
+
+		if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & data_mask) == 0, 50))
+			DRM_ERROR("Timeout waiting for HS/LP DATA FIFO !full\n");
+
+		write_data(dev_priv, data_reg, packet.payload,
+			   packet.payload_length);
+	}
+
+	if (msg->rx_len) {
+		I915_WRITE(MIPI_INTR_STAT(port), GEN_READ_DATA_AVAIL);
+	}
+
+	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & ctrl_mask) == 0, 50)) {
+		DRM_ERROR("Timeout waiting for HS/LP CTRL FIFO !full\n");
+	}
+
+	I915_WRITE(ctrl_reg, header[2] << 16 | header[1] << 8 | header[0]);
+
+	/* ->rx_len is set only for reads */
+	if (msg->rx_len) {
+		data_mask = GEN_READ_DATA_AVAIL;
+		if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & data_mask) == data_mask, 50))
+			DRM_ERROR("Timeout waiting for read data.\n");
+
+		read_data(dev_priv, data_reg, msg->rx_buf, msg->rx_len);
+	}
+
+	/* XXX: fix for reads and writes */
+	return 4 + packet.payload_length;
+}
+
+static int intel_dsi_host_attach(struct mipi_dsi_host *host,
+				 struct mipi_dsi_device *dsi)
+{
+	return 0;
+}
+
+static int intel_dsi_host_detach(struct mipi_dsi_host *host,
+				 struct mipi_dsi_device *dsi)
+{
+	return 0;
+}
+
+static const struct mipi_dsi_host_ops intel_dsi_host_ops = {
+	.attach = intel_dsi_host_attach,
+	.detach = intel_dsi_host_detach,
+	.transfer = intel_dsi_host_transfer,
+};
+
+static struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi,
+						  enum port port)
+{
+	struct intel_dsi_host *host;
+	struct mipi_dsi_device *device;
+
+	host = kzalloc(sizeof(*host), GFP_KERNEL);
+	if (!host)
+		return NULL;
+
+	host->base.ops = &intel_dsi_host_ops;
+	host->intel_dsi = intel_dsi;
+	host->port = port;
+
+	/*
+	 * We should call mipi_dsi_host_register(&host->base) here, but we don't
+	 * have a host->dev, and we don't have OF stuff either. So just use the
+	 * dsi framework as a library and hope for the best. Create the dsi
+	 * devices by ourselves here too. Need to be careful though, because we
+	 * don't initialize any of the driver model devices here.
+	 */
+	device = kzalloc(sizeof(*device), GFP_KERNEL);
+	if (!device) {
+		kfree(host);
+		return NULL;
+	}
+
+	device->host = &host->base;
+	host->device = device;
+
+	return host;
+}
+
  static void band_gap_reset(struct drm_i915_private *dev_priv)
  {
  	mutex_lock(&dev_priv->dpio_lock);
@@ -806,6 +950,7 @@ void intel_dsi_init(struct drm_device *dev)
  	struct drm_connector *connector;
  	struct drm_display_mode *scan, *fixed_mode = NULL;
  	struct drm_i915_private *dev_priv = dev->dev_private;
+	enum port port;
  	unsigned int i;
 
  	DRM_DEBUG_KMS("\n");
@@ -854,7 +999,11 @@ void intel_dsi_init(struct drm_device *dev)
  	intel_connector->unregister = intel_connector_unregister;
 
  	/* Pipe A maps to MIPI DSI port A, pipe B maps to MIPI DSI port C */
-	if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIA) {
+	if (dev_priv->vbt.dsi.config->dual_link) {
+		/* XXX: does dual link work on either pipe? */
+		intel_encoder->crtc_mask = (1 << PIPE_A);
+		intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
+	} else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIA) {
  		intel_encoder->crtc_mask = (1 << PIPE_A);
  		intel_dsi->ports = (1 << PORT_A);
  	} else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIC) {
@@ -862,6 +1011,17 @@ void intel_dsi_init(struct drm_device *dev)
  		intel_dsi->ports = (1 << PORT_C);
  	}
 
+	/* Create a DSI host (and a device) for each port. */
+	for_each_dsi_port(port, intel_dsi->ports) {
+		struct intel_dsi_host *host;
+
+		host = intel_dsi_host_init(intel_dsi, port);
+		if (!host)
+			goto err;
+
+		intel_dsi->dsi_hosts[port] = host;
+	}
+
  	for (i = 0; i < ARRAY_SIZE(intel_dsi_drivers); i++) {
  		intel_dsi->panel = intel_dsi_drivers[i].init(intel_dsi,
  							     intel_dsi_drivers[i].panel_id);
drivers/gpu/drm/i915/intel_dsi.h +18 -0
index fc0b2b8d90f1..2784ac442368 100644
@@ -26,6 +26,7 @@
 
  #include <drm/drmP.h>
  #include <drm/drm_crtc.h>
+#include <drm/drm_mipi_dsi.h>
  #include "intel_drv.h"
 
  /* Dual Link support */
@@ -33,10 +34,13 @@
  #define DSI_DUAL_LINK_FRONT_BACK	1
  #define DSI_DUAL_LINK_PIXEL_ALT		2
 
+struct intel_dsi_host;
+
  struct intel_dsi {
  	struct intel_encoder base;
 
  	struct drm_panel *panel;
+	struct intel_dsi_host *dsi_hosts[I915_MAX_PORTS];
 
  	struct intel_connector *attached_connector;
 
@@ -94,6 +98,20 @@ struct intel_dsi {
  	u16 panel_pwr_cycle_delay;
  };
 
+struct intel_dsi_host {
+	struct mipi_dsi_host base;
+	struct intel_dsi *intel_dsi;
+	enum port port;
+
+	/* our little hack */
+	struct mipi_dsi_device *device;
+};
+
+static inline struct intel_dsi_host *to_intel_dsi_host(struct mipi_dsi_host *h)
+{
+	return container_of(h, struct intel_dsi_host, base);
+}
+
  #define for_each_dsi_port(__port, __ports_mask) \
  	for ((__port) = PORT_A; (__port) < I915_MAX_PORTS; (__port)++)	\
  		if ((__ports_mask) & (1 << (__port)))
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
index 204f54df8fe1..e363c26a2b05 100644

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id) · line 404

Quoted 9 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -3
@@ -399,9 +399,6 @@ struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
  	intel_dsi->dual_link = mipi_config->dual_link;
  	intel_dsi->pixel_overlap = mipi_config->pixel_overlap;
 
-	if (intel_dsi->dual_link)
-		intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
-
  	if (intel_dsi->pixel_format == VID_MODE_FORMAT_RGB666)
  		bits_per_pixel = 18;
  	else if (intel_dsi->pixel_format == VID_MODE_FORMAT_RGB565)

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 9/12
#33 lore raw

Re: [RFC PATCH 09/12] drm/i915/dsi: make the vbt panel driver use mipi_dsi_device for transfers

In reply to Jani Nikula
Quoted 3 lines · Jani Nikula

Use the drm core interfaces in preparation of removing our homebrew.

All looks well on code review and tested also and everything works. I have ASUS T100 whose panel does not need actually the DCS write commands during OTP or enabling, so this patch won't get exercised. With that said-

Quoted 109 lines
---
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 52 +++++++++++++++++++-----------
  1 file changed, 34 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +29 -18
index e363c26a2b05..0b09e66f7e29 100644
@@ -113,14 +113,18 @@ static inline enum port intel_dsi_seq_port_to_port(u8 port)
  static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
  				       const u8 *data)
  {
-	u8 type, byte, mode, vc, seq_port;
+	struct mipi_dsi_device *dsi_device;
+	u8 type, flags, seq_port;
  	u16 len;
  	enum port port;
 
-	byte = *data++;
-	mode = (byte >> MIPI_TRANSFER_MODE_SHIFT) & 0x1;
-	vc = (byte >> MIPI_VIRTUAL_CHANNEL_SHIFT) & 0x3;
-	seq_port = (byte >> MIPI_PORT_SHIFT) & 0x3;
+	flags = *data++;
+	type = *data++;
+
+	len = *((u16 *) data);
+	data += 2;
+
+	seq_port = (flags >> MIPI_PORT_SHIFT) & 3;
 
  	/* For DSI single link on Port A & C, the seq_port value which is
  	 * parsed from Sequence Block#53 of VBT has been set to 0
@@ -131,24 +135,29 @@ static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
  		port = PORT_C;
  	else
  		port = intel_dsi_seq_port_to_port(seq_port);
-	/* LP or HS mode */
-	intel_dsi->hs = mode;
 
-	/* get packet type and increment the pointer */
-	type = *data++;
+	dsi_device = intel_dsi->dsi_hosts[port]->device;
+	if (!dsi_device) {
+		DRM_DEBUG_KMS("no dsi device for port %c\n", port_name(port));
+		goto out;
+	}
 
-	len = *((u16 *) data);
-	data += 2;
+	if ((flags >> MIPI_TRANSFER_MODE_SHIFT) & 1)
+		dsi_device->mode_flags &= ~MIPI_DSI_MODE_LPM;
+	else
+		dsi_device->mode_flags |= MIPI_DSI_MODE_LPM;
+
+	dsi_device->channel = (flags >> MIPI_VIRTUAL_CHANNEL_SHIFT) & 3;
 
  	switch (type) {
  	case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
-		dsi_vc_generic_write_0(intel_dsi, vc, port);
+		mipi_dsi_generic_write(dsi_device, NULL, 0);
  		break;
  	case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
-		dsi_vc_generic_write_1(intel_dsi, vc, *data, port);
+		mipi_dsi_generic_write(dsi_device, data, 1);
  		break;
  	case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
-		dsi_vc_generic_write_2(intel_dsi, vc, *data, *(data + 1), port);
+		mipi_dsi_generic_write(dsi_device, data, 2);
  		break;
  	case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
  	case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
@@ -156,22 +165,23 @@ static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi,
  		DRM_DEBUG_DRIVER("Generic Read not yet implemented or used\n");
  		break;
  	case MIPI_DSI_GENERIC_LONG_WRITE:
-		dsi_vc_generic_write(intel_dsi, vc, data, len, port);
+		mipi_dsi_generic_write(dsi_device, data, len);
  		break;
  	case MIPI_DSI_DCS_SHORT_WRITE:
-		dsi_vc_dcs_write_0(intel_dsi, vc, *data, port);
+		mipi_dsi_dcs_write_buffer(dsi_device, data, 1);
  		break;
  	case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
-		dsi_vc_dcs_write_1(intel_dsi, vc, *data, *(data + 1), port);
+		mipi_dsi_dcs_write_buffer(dsi_device, data, 2);
  		break;
  	case MIPI_DSI_DCS_READ:
  		DRM_DEBUG_DRIVER("DCS Read not yet implemented or used\n");
  		break;
  	case MIPI_DSI_DCS_LONG_WRITE:
-		dsi_vc_dcs_write(intel_dsi, vc, data, len, port);
+		mipi_dsi_dcs_write_buffer(dsi_device, data, len);
  		break;
  	}
 
+out:
  	data += len;
 
  	return data;
@@ -389,6 +399,7 @@ struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
  	u32 lp_to_hs_switch, hs_to_lp_switch;
  	u32 pclk, computed_ddr;
  	u16 burst_mode_ratio;
+	enum port port;
 
  	DRM_DEBUG_KMS("\n");
 

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id) · line 681

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +5 -0
@@ -661,5 +672,10 @@ struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
  	vbt_panel->panel.funcs = &vbt_panel_funcs;
  	drm_panel_add(&vbt_panel->panel);
 
+	/* a regular driver would get the device in probe */
+	for_each_dsi_port(port, intel_dsi->ports) {
+		mipi_dsi_attach(intel_dsi->dsi_hosts[port]->device);
+	}
+
  	return &vbt_panel->panel;
  }

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 10/12
#35 lore raw

Re: [RFC PATCH 10/12] drm/i915/dsi: remove old read/write functions in favor of new stuff

In reply to Jani Nikula
Quoted 3 lines · Jani Nikula

All of these are replaced by the drm core mipi dsi functions.

Quoted 356 lines
---
  drivers/gpu/drm/i915/intel_dsi_cmd.c | 259 -----------------------------------
  drivers/gpu/drm/i915/intel_dsi_cmd.h |  72 ----------
  2 files changed, 331 deletions(-)
drivers/gpu/drm/i915/intel_dsi_cmd.c +0 -259
index 17b892a365ee..6baaa374fc89 100644
@@ -96,11 +96,6 @@ static void print_stat(struct intel_dsi *intel_dsi, enum port port)
  #undef STAT_BIT
  }
 
-enum dsi_type {
-	DSI_DCS,
-	DSI_GENERIC,
-};
-
  /* enable or disable command mode hs transmissions */
  void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
  						enum port port)
@@ -121,260 +116,6 @@ void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
  	intel_dsi->hs = enable;
  }
 
-static int dsi_vc_send_short(struct intel_dsi *intel_dsi, int channel,
-			     u8 data_type, u16 data, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 ctrl_reg;
-	u32 ctrl;
-	u32 mask;
-
-	DRM_DEBUG_KMS("channel %d, data_type %d, data %04x\n",
-		      channel, data_type, data);
-
-	if (intel_dsi->hs) {
-		ctrl_reg = MIPI_HS_GEN_CTRL(port);
-		mask = HS_CTRL_FIFO_FULL;
-	} else {
-		ctrl_reg = MIPI_LP_GEN_CTRL(port);
-		mask = LP_CTRL_FIFO_FULL;
-	}
-
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == 0, 50)) {
-		DRM_ERROR("Timeout waiting for HS/LP CTRL FIFO !full\n");
-		print_stat(intel_dsi, port);
-	}
-
-	/*
-	 * Note: This function is also used for long packets, with length passed
-	 * as data, since SHORT_PACKET_PARAM_SHIFT ==
-	 * LONG_PACKET_WORD_COUNT_SHIFT.
-	 */
-	ctrl = data << SHORT_PACKET_PARAM_SHIFT |
-		channel << VIRTUAL_CHANNEL_SHIFT |
-		data_type << DATA_TYPE_SHIFT;
-
-	I915_WRITE(ctrl_reg, ctrl);
-
-	return 0;
-}
-
-static int dsi_vc_send_long(struct intel_dsi *intel_dsi, int channel,
-		u8 data_type, const u8 *data, int len, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 data_reg;
-	int i, j, n;
-	u32 mask;
-
-	DRM_DEBUG_KMS("channel %d, data_type %d, len %04x\n",
-		      channel, data_type, len);
-
-	if (intel_dsi->hs) {
-		data_reg = MIPI_HS_GEN_DATA(port);
-		mask = HS_DATA_FIFO_FULL;
-	} else {
-		data_reg = MIPI_LP_GEN_DATA(port);
-		mask = LP_DATA_FIFO_FULL;
-	}
-
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == 0, 50))
-		DRM_ERROR("Timeout waiting for HS/LP DATA FIFO !full\n");
-
-	for (i = 0; i < len; i += n) {
-		u32 val = 0;
-		n = min_t(int, len - i, 4);
-
-		for (j = 0; j < n; j++)
-			val |= *data++ << 8 * j;
-
-		I915_WRITE(data_reg, val);
-		/* XXX: check for data fifo full, once that is set, write 4
-		 * dwords, then wait for not set, then continue. */
-	}
-
-	return dsi_vc_send_short(intel_dsi, channel, data_type, len, port);
-}
-
-static int dsi_vc_write_common(struct intel_dsi *intel_dsi,
-			       int channel, const u8 *data, int len,
-			       enum dsi_type type, enum port port)
-{
-	int ret;
-
-	if (len == 0) {
-		BUG_ON(type == DSI_GENERIC);
-		ret = dsi_vc_send_short(intel_dsi, channel,
-					MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM,
-					0, port);
-	} else if (len == 1) {
-		ret = dsi_vc_send_short(intel_dsi, channel,
-					type == DSI_GENERIC ?
-					MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM :
-					MIPI_DSI_DCS_SHORT_WRITE, data[0],
-					port);
-	} else if (len == 2) {
-		ret = dsi_vc_send_short(intel_dsi, channel,
-					type == DSI_GENERIC ?
-					MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM :
-					MIPI_DSI_DCS_SHORT_WRITE_PARAM,
-					(data[1] << 8) | data[0], port);
-	} else {
-		ret = dsi_vc_send_long(intel_dsi, channel,
-					type == DSI_GENERIC ?
-					MIPI_DSI_GENERIC_LONG_WRITE :
-					MIPI_DSI_DCS_LONG_WRITE, data, len,
-					port);
-	}
-
-	return ret;
-}
-
-int dsi_vc_dcs_write(struct intel_dsi *intel_dsi, int channel,
-		     const u8 *data, int len, enum port port)
-{
-	return dsi_vc_write_common(intel_dsi, channel, data, len, DSI_DCS,
-									port);
-}
-
-int dsi_vc_generic_write(struct intel_dsi *intel_dsi, int channel,
-			 const u8 *data, int len, enum port port)
-{
-	return dsi_vc_write_common(intel_dsi, channel, data, len, DSI_GENERIC,
-									port);
-}
-
-static int dsi_vc_dcs_send_read_request(struct intel_dsi *intel_dsi,
-				int channel, u8 dcs_cmd, enum port port)
-{
-	return dsi_vc_send_short(intel_dsi, channel, MIPI_DSI_DCS_READ,
-				 dcs_cmd, port);
-}
-
-static int dsi_vc_generic_send_read_request(struct intel_dsi *intel_dsi,
-					    int channel, u8 *reqdata,
-					    int reqlen, enum port port)
-{
-	u16 data;
-	u8 data_type;
-
-	switch (reqlen) {
-	case 0:
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
-		data = 0;
-		break;
-	case 1:
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
-		data = reqdata[0];
-		break;
-	case 2:
-		data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
-		data = (reqdata[1] << 8) | reqdata[0];
-		break;
-	default:
-		BUG();
-	}
-
-	return dsi_vc_send_short(intel_dsi, channel, data_type, data, port);
-}
-
-static int dsi_read_data_return(struct intel_dsi *intel_dsi,
-				u8 *buf, int buflen, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	int i, len = 0;
-	u32 data_reg, val;
-
-	if (intel_dsi->hs) {
-		data_reg = MIPI_HS_GEN_DATA(port);
-	} else {
-		data_reg = MIPI_LP_GEN_DATA(port);
-	}
-
-	while (len < buflen) {
-		val = I915_READ(data_reg);
-		for (i = 0; i < 4 && len < buflen; i++, len++)
-			buf[len] = val >> 8 * i;
-	}
-
-	return len;
-}
-
-int dsi_vc_dcs_read(struct intel_dsi *intel_dsi, int channel, u8 dcs_cmd,
-		    u8 *buf, int buflen, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 mask;
-	int ret;
-
-	/*
-	 * XXX: should issue multiple read requests and reads if request is
-	 * longer than MIPI_MAX_RETURN_PKT_SIZE
-	 */
-
-	I915_WRITE(MIPI_INTR_STAT(port), GEN_READ_DATA_AVAIL);
-
-	ret = dsi_vc_dcs_send_read_request(intel_dsi, channel, dcs_cmd, port);
-	if (ret)
-		return ret;
-
-	mask = GEN_READ_DATA_AVAIL;
-	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 50))
-		DRM_ERROR("Timeout waiting for read data.\n");
-
-	ret = dsi_read_data_return(intel_dsi, buf, buflen, port);
-	if (ret < 0)
-		return ret;
-
-	if (ret != buflen)
-		return -EIO;
-
-	return 0;
-}
-
-int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
-		u8 *reqdata, int reqlen, u8 *buf, int buflen, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 mask;
-	int ret;
-
-	/*
-	 * XXX: should issue multiple read requests and reads if request is
-	 * longer than MIPI_MAX_RETURN_PKT_SIZE
-	 */
-
-	I915_WRITE(MIPI_INTR_STAT(port), GEN_READ_DATA_AVAIL);
-
-	ret = dsi_vc_generic_send_read_request(intel_dsi, channel, reqdata,
-					       reqlen, port);
-	if (ret)
-		return ret;
-
-	mask = GEN_READ_DATA_AVAIL;
-	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 50))
-		DRM_ERROR("Timeout waiting for read data.\n");
-
-	ret = dsi_read_data_return(intel_dsi, buf, buflen, port);
-	if (ret < 0)
-		return ret;
-
-	if (ret != buflen)
-		return -EIO;
-
-	return 0;
-}
-
  /*
   * send a video mode command
   *
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -63
index 70f24666a1f9..9a28ff58a92b 100644
@@ -39,78 +39,6 @@
  void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
  						enum port port);
 
-int dsi_vc_dcs_write(struct intel_dsi *intel_dsi, int channel,
-		     const u8 *data, int len, enum port port);
-
-int dsi_vc_generic_write(struct intel_dsi *intel_dsi, int channel,
-			 const u8 *data, int len, enum port port);
-
-int dsi_vc_dcs_read(struct intel_dsi *intel_dsi, int channel, u8 dcs_cmd,
-		    u8 *buf, int buflen, enum port port);
-
-int dsi_vc_generic_read(struct intel_dsi *intel_dsi, int channel,
-		u8 *reqdata, int reqlen, u8 *buf, int buflen, enum port port);
-
  int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port);
 
-/* XXX: questionable write helpers */
-static inline int dsi_vc_dcs_write_0(struct intel_dsi *intel_dsi,
-				     int channel, u8 dcs_cmd, enum port port)
-{
-	return dsi_vc_dcs_write(intel_dsi, channel, &dcs_cmd, 1, port);
-}
-
-static inline int dsi_vc_dcs_write_1(struct intel_dsi *intel_dsi,
-			int channel, u8 dcs_cmd, u8 param, enum port port)
-{
-	u8 buf[2] = { dcs_cmd, param };
-	return dsi_vc_dcs_write(intel_dsi, channel, buf, 2, port);
-}
-
-static inline int dsi_vc_generic_write_0(struct intel_dsi *intel_dsi,
-					 int channel, enum port port)
-{
-	return dsi_vc_generic_write(intel_dsi, channel, NULL, 0, port);
-}
-
-static inline int dsi_vc_generic_write_1(struct intel_dsi *intel_dsi,
-					 int channel, u8 param, enum port port)
-{
-	return dsi_vc_generic_write(intel_dsi, channel, &param, 1, port);
-}
-
-static inline int dsi_vc_generic_write_2(struct intel_dsi *intel_dsi,
-			int channel, u8 param1, u8 param2, enum port port)
-{
-	u8 buf[2] = { param1, param2 };
-	return dsi_vc_generic_write(intel_dsi, channel, buf, 2, port);
-}
-
-/* XXX: questionable read helpers */
-static inline int dsi_vc_generic_read_0(struct intel_dsi *intel_dsi,
-			int channel, u8 *buf, int buflen, enum port port)
-{
-	return dsi_vc_generic_read(intel_dsi, channel, NULL, 0, buf, buflen,
-									port);
-}
-
-static inline int dsi_vc_generic_read_1(struct intel_dsi *intel_dsi,
-					int channel, u8 param, u8 *buf,
-					int buflen, enum port port)
-{
-	return dsi_vc_generic_read(intel_dsi, channel, &param, 1, buf, buflen,
-									port);
-}
-
-static inline int dsi_vc_generic_read_2(struct intel_dsi *intel_dsi,
-					int channel, u8 param1, u8 param2,

drivers/gpu/drm/i915/intel_dsi_cmd.h line 44

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -9
-					u8 *buf, int buflen, enum port port)
-{
-	u8 req[2] = { param1, param2 };
-
-	return dsi_vc_generic_read(intel_dsi, channel, req, 2, buf, buflen,
-									port);
-}
-
-
  #endif /* _INTEL_DSI_DSI_H */

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 11/12
#37 lore raw

Re: [RFC PATCH 11/12] drm/i915/dsi: move dpi_send_cmd() to intel_dsi.c and make it static

In reply to Jani Nikula
Quoted 3 lines · Jani Nikula

No functional changes.

Quoted 120 lines
---
  drivers/gpu/drm/i915/intel_dsi.c     | 39 ++++++++++++++++++++++++++++++++++--
  drivers/gpu/drm/i915/intel_dsi_cmd.c | 34 -------------------------------
  drivers/gpu/drm/i915/intel_dsi_cmd.h |  5 -----
  3 files changed, 37 insertions(+), 41 deletions(-)
drivers/gpu/drm/i915/intel_dsi.c +37 -2
index 5cfa3431785a..791d90b4c047 100644
@@ -202,6 +202,41 @@ static struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi,
  	return host;
  }
 
+/*
+ * send a video mode command
+ *
+ * XXX: commands with data in MIPI_DPI_DATA?
+ */
+static int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs,
+			enum port port)
+{
+	struct drm_encoder *encoder = &intel_dsi->base.base;
+	struct drm_device *dev = encoder->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 mask;
+
+	/* XXX: pipe, hs */
+	if (hs)
+		cmd &= ~DPI_LP_MODE;
+	else
+		cmd |= DPI_LP_MODE;
+
+	/* clear bit */
+	I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
+
+	/* XXX: old code skips write if control unchanged */
+	if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
+		DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
+
+	I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
+
+	mask = SPL_PKT_SENT_INTERRUPT;
+	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 100))
+		DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
+
+	return 0;
+}
+
  static void band_gap_reset(struct drm_i915_private *dev_priv)
  {
  	mutex_lock(&dev_priv->dpio_lock);
@@ -357,7 +392,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
  	else {
  		msleep(20); /* XXX */
  		for_each_dsi_port(port, intel_dsi->ports)
-			dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN, port);
+			dpi_send_cmd(intel_dsi, TURN_ON, false, port);
  		msleep(100);
 
  		drm_panel_enable(intel_dsi->panel);
@@ -430,7 +465,7 @@ static void intel_dsi_pre_disable(struct intel_encoder *encoder)
  	if (is_vid_mode(intel_dsi)) {
  		/* Send Shutdown command to the panel in LP mode */
  		for_each_dsi_port(port, intel_dsi->ports)
-			dpi_send_cmd(intel_dsi, SHUTDOWN, DPI_LP_MODE_EN, port);
+			dpi_send_cmd(intel_dsi, SHUTDOWN, false, port);
  		msleep(10);
  	}
  }
drivers/gpu/drm/i915/intel_dsi_cmd.c +0 -34
index 6baaa374fc89..acdc5da7b46f 100644
@@ -115,37 +115,3 @@ void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
 
  	intel_dsi->hs = enable;
  }
-
-/*
- * send a video mode command
- *
- * XXX: commands with data in MIPI_DPI_DATA?
- */
-int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 mask;
-
-	/* XXX: pipe, hs */
-	if (hs)
-		cmd &= ~DPI_LP_MODE;
-	else
-		cmd |= DPI_LP_MODE;
-
-	/* clear bit */
-	I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
-
-	/* XXX: old code skips write if control unchanged */
-	if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
-		DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
-
-	I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
-
-	mask = SPL_PKT_SENT_INTERRUPT;
-	if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 100))
-		DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
-
-	return 0;
-}
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -0
index 9a28ff58a92b..886779030f1a 100644
@@ -33,12 +33,7 @@
  #include "intel_drv.h"
  #include "intel_dsi.h"

drivers/gpu/drm/i915/intel_dsi_cmd.h line 39

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_cmd.h +0 -5
 
-#define DPI_LP_MODE_EN	false
-#define DPI_HS_MODE_EN	true
-
  void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
  						enum port port);
 
-int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs, enum port port);
-
  #endif /* _INTEL_DSI_DSI_H */

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 12/12
#39 lore raw

Re: [RFC PATCH 12/12] drm/i915/dsi: remove intel_dsi_cmd.c and the unused functions therein

In reply to Jani Nikula
Quoted 3 lines · Jani Nikula

The removed functions can be resurrected in intel_dsi.c as need arises.

Quoted 161 lines
---
  drivers/gpu/drm/i915/Makefile              |   1 -
  drivers/gpu/drm/i915/intel_dsi.c           |   1 -
  drivers/gpu/drm/i915/intel_dsi_cmd.c       | 117 -----------------------------
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |   1 -
  4 files changed, 120 deletions(-)

delete mode 100644 drivers/gpu/drm/i915/intel_dsi_cmd.c

drivers/gpu/drm/i915/Makefile +0 -1
index 16e3dc350274..63afe63bf0e4 100644
@@ -71,7 +71,6 @@ i915-y += dvo_ch7017.o \
  	  intel_ddi.o \
  	  intel_dp.o \
  	  intel_dp_mst.o \
-	  intel_dsi_cmd.o \
  	  intel_dsi.o \
  	  intel_dsi_pll.o \
  	  intel_dsi_panel_vbt.o \
drivers/gpu/drm/i915/intel_dsi.c +0 -1
index 791d90b4c047..02ae5e583b27 100644
@@ -33,7 +33,6 @@
  #include "i915_drv.h"
  #include "intel_drv.h"
  #include "intel_dsi.h"
-#include "intel_dsi_cmd.h"
 
  static const struct {
  	u16 panel_id;
drivers/gpu/drm/i915/intel_dsi_cmd.c deleted +0 -117
deleted file mode 100644
index acdc5da7b46f..000000000000
@@ -1,117 +0,0 @@
-/*
- * Copyright © 2013 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Author: Jani Nikula <[email protected]>
- */
-
-#include <linux/export.h>
-#include <drm/drmP.h>
-#include <drm/drm_crtc.h>
-#include <video/mipi_display.h>
-#include "i915_drv.h"
-#include "intel_drv.h"
-#include "intel_dsi.h"
-#include "intel_dsi_cmd.h"
-
-/*
- * XXX: MIPI_DATA_ADDRESS, MIPI_DATA_LENGTH, MIPI_COMMAND_LENGTH, and
- * MIPI_COMMAND_ADDRESS registers.
- *
- * Apparently these registers provide a MIPI adapter level way to send (lots of)
- * commands and data to the receiver, without having to write the commands and
- * data to MIPI_{HS,LP}_GEN_{CTRL,DATA} registers word by word.
- *
- * Presumably for anything other than MIPI_DCS_WRITE_MEMORY_START and
- * MIPI_DCS_WRITE_MEMORY_CONTINUE (which are used to update the external
- * framebuffer in command mode displays) these are just an optimization that can
- * come later.
- *
- * For memory writes, these should probably be used for performance.
- */
-
-static void print_stat(struct intel_dsi *intel_dsi, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 val;
-
-	val = I915_READ(MIPI_INTR_STAT(port));
-
-#define STAT_BIT(val, bit) (val) & (bit) ? " " #bit : ""
-	DRM_DEBUG_KMS("MIPI_INTR_STAT(%c) = %08x"
-		      "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
-		      "\n", port_name(port), val,
-		      STAT_BIT(val, TEARING_EFFECT),
-		      STAT_BIT(val, SPL_PKT_SENT_INTERRUPT),
-		      STAT_BIT(val, GEN_READ_DATA_AVAIL),
-		      STAT_BIT(val, LP_GENERIC_WR_FIFO_FULL),
-		      STAT_BIT(val, HS_GENERIC_WR_FIFO_FULL),
-		      STAT_BIT(val, RX_PROT_VIOLATION),
-		      STAT_BIT(val, RX_INVALID_TX_LENGTH),
-		      STAT_BIT(val, ACK_WITH_NO_ERROR),
-		      STAT_BIT(val, TURN_AROUND_ACK_TIMEOUT),
-		      STAT_BIT(val, LP_RX_TIMEOUT),
-		      STAT_BIT(val, HS_TX_TIMEOUT),
-		      STAT_BIT(val, DPI_FIFO_UNDERRUN),
-		      STAT_BIT(val, LOW_CONTENTION),
-		      STAT_BIT(val, HIGH_CONTENTION),
-		      STAT_BIT(val, TXDSI_VC_ID_INVALID),
-		      STAT_BIT(val, TXDSI_DATA_TYPE_NOT_RECOGNISED),
-		      STAT_BIT(val, TXCHECKSUM_ERROR),
-		      STAT_BIT(val, TXECC_MULTIBIT_ERROR),
-		      STAT_BIT(val, TXECC_SINGLE_BIT_ERROR),
-		      STAT_BIT(val, TXFALSE_CONTROL_ERROR),
-		      STAT_BIT(val, RXDSI_VC_ID_INVALID),
-		      STAT_BIT(val, RXDSI_DATA_TYPE_NOT_REGOGNISED),
-		      STAT_BIT(val, RXCHECKSUM_ERROR),
-		      STAT_BIT(val, RXECC_MULTIBIT_ERROR),
-		      STAT_BIT(val, RXECC_SINGLE_BIT_ERROR),
-		      STAT_BIT(val, RXFALSE_CONTROL_ERROR),
-		      STAT_BIT(val, RXHS_RECEIVE_TIMEOUT_ERROR),
-		      STAT_BIT(val, RX_LP_TX_SYNC_ERROR),
-		      STAT_BIT(val, RXEXCAPE_MODE_ENTRY_ERROR),
-		      STAT_BIT(val, RXEOT_SYNC_ERROR),
-		      STAT_BIT(val, RXSOT_SYNC_ERROR),
-		      STAT_BIT(val, RXSOT_ERROR));
-#undef STAT_BIT
-}
-
-/* enable or disable command mode hs transmissions */
-void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
-						enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 temp;
-	u32 mask = DBI_FIFO_EMPTY;
-
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 50))
-		DRM_ERROR("Timeout waiting for DBI FIFO empty\n");
-
-	temp = I915_READ(MIPI_HS_LP_DBI_ENABLE(port));
-	temp &= DBI_HS_LP_MODE_MASK;
-	I915_WRITE(MIPI_HS_LP_DBI_ENABLE(port), enable ? DBI_HS_MODE : DBI_LP_MODE);
-
-	intel_dsi->hs = enable;
-}
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
index 0b09e66f7e29..c3eec66f5076 100644

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c line 41

Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
@@ -36,7 +36,6 @@
  #include "i915_drv.h"
  #include "intel_drv.h"
  #include "intel_dsi.h"
-#include "intel_dsi_cmd.h"
 
  struct vbt_panel {
  	struct drm_panel panel;

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#44 lore raw
In reply to Shobhit Kumar
Quoted 13 lines · Shobhit Kumar
Quoted 12 lines · Jani Nikula
Quoted 10 lines · Shobhit Kumar
Quoted 5 lines · Jani Nikula

This series ports our DSI code over to the drm_panel and mipi_dsi_host/mipi_dsi_device. There are some rough edges towards the end of the series, see commit message for patch 8 for details.

Patches 1-6 are prep work, fairly independent

While I continue to review, quick test of patches show that till here it is fine(with minor fix for Patch 2), but from Patch 7 on wards things really don't work.

Quoted 8 lines
Quoted 3 lines

Okay, thanks for the review so far and trying it out.

What breaks down with patch 7? Which device are you trying this on?

It just hangs during bootup console. Guessing there is some kernel panic somewhere but the Asus T100 on which I am trying does not have serial to get logs. Will try to debug today.

Okay with the issues fixed in patch 7, all works well so once you fix all those in your patch -

Tested-by Shobhit kumar <[email protected]>

Quoted 54 lines

Regards
Shobhit

Quoted 51 lines

BR,
Jani.

Quoted 45 lines
Quoted 39 lines

Patch 7 ports the driver over to drm_panel

Patches 8-10 port the driver over to mipi_dsi_host/device

Patches 11-12 do some additional cleanup

BR,
Jani.

Jani Nikula (12):
drm/i915/dsi: call dpi_send_cmd() for each dsi port at a higher
level
drm/i915/dsi: set max return packet size for each dsi port drm/i915/dsi: move wait_for_dsi_fifo_empty to intel_dsi.c drm/i915/dsi: call wait_for_dsi_fifo_empty() for each dsi port drm/i915/dsi: remove unnecessary dsi device callbacks drm/i915/dsi: add some constness to vbt panel driver drm/i915/dsi: switch to drm_panel interface drm/i915/dsi: add drm mipi dsi host support drm/i915/dsi: make the vbt panel driver use mipi_dsi_device for
transfers
drm/i915/dsi: remove old read/write functions in favor of new stuff drm/i915/dsi: move dpi_send_cmd() to intel_dsi.c and make it static drm/i915/dsi: remove intel_dsi_cmd.c and the unused functions
therein

   drivers/gpu/drm/i915/Kconfig               |   2 +
   drivers/gpu/drm/i915/Makefile              |   1 -
   drivers/gpu/drm/i915/intel_dsi.c           | 336
+++++++++++++++++-----
   drivers/gpu/drm/i915/intel_dsi.h           |  69 ++---
   drivers/gpu/drm/i915/intel_dsi_cmd.c       | 432
-----------------------------
   drivers/gpu/drm/i915/intel_dsi_cmd.h       |  78 ------
   drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 289 ++++++++++---------
   7 files changed, 441 insertions(+), 766 deletions(-)
Quoted 2 lines

delete mode 100644 drivers/gpu/drm/i915/intel_dsi_cmd.c

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#28 lore raw

PATCH v2 1/1 drm/i915/dsi: switch to drm_panel interface

In reply to Jani Nikula

Replace intel_dsi_device and intel_dsi_dev_ops with drm_panel and drm_panel_funcs. They are adequate for what we have now, and if we end up needing more than this we should improve drm_panel. This will keep us better aligned with the drm core infrastructure.

The panel driver initialization changes a bit. It still remains hideous, but fixing that is beyond the scope here.

v2: extend mode config mutex to cover drm_panel_get_modes (Shobhit)

    vbt_panel->intel_dsi = intel_dsi in vbt panel init (Shobhit)
---
 drivers/gpu/drm/i915/Kconfig               |   1 +
 drivers/gpu/drm/i915/intel_dsi.c           |  68 +++++++----
 drivers/gpu/drm/i915/intel_dsi.h           |  27 +----
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 180 ++++++++++++++++++-----------
 4 files changed, 157 insertions(+), 119 deletions(-)
drivers/gpu/drm/i915/Kconfig +1 -0
index 4e39ab34eb1c..da196cd07263 100644
@@ -11,6 +11,7 @@ config DRM_I915
 	select SHMEM
 	select TMPFS
 	select DRM_KMS_HELPER
+	select DRM_PANEL
 	# i915 depends on ACPI_VIDEO when ACPI is enabled
 	# but for select to work, need to select ACPI_VIDEO's dependencies, ick
 	select BACKLIGHT_LCD_SUPPORT if ACPI
drivers/gpu/drm/i915/intel_dsi.c +43 -25

152 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dsi.h +2 -25
index 22f87036a256..fc0b2b8d90f1 100644
@@ -33,33 +33,10 @@
 #define DSI_DUAL_LINK_FRONT_BACK	1
 #define DSI_DUAL_LINK_PIXEL_ALT		2
 
-struct intel_dsi_device {
-	unsigned int panel_id;
-	const char *name;
-	const struct intel_dsi_dev_ops *dev_ops;
-	void *dev_priv;
-};
-
-struct intel_dsi_dev_ops {
-	bool (*init)(struct intel_dsi_device *dsi);
-
-	void (*panel_reset)(struct intel_dsi_device *dsi);
-
-	void (*disable_panel_power)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*enable)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*disable)(struct intel_dsi_device *dsi);
-
-	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-};
-
 struct intel_dsi {
 	struct intel_encoder base;
 
-	struct intel_dsi_device dev;
+	struct drm_panel *panel;
 
 	struct intel_connector *attached_connector;
 
@@ -130,6 +107,6 @@ extern void vlv_enable_dsi_pll(struct intel_encoder *encoder);
 extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
 extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 
-extern struct intel_dsi_dev_ops vbt_generic_dsi_display_ops;
+struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id);
 
 #endif /* _INTEL_DSI_H */
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +111 -69

222 lines not on this page · raw message

Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

In reply to Shobhit Kumar
Quoted 13 lines · Shobhit Kumar
Quoted 11 lines · Jani Nikula
Quoted 7 lines · Shobhit Kumar

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Can we just have the driver return the desired mode from .get_modes in that case?

Quoted 6 lines

Okay, I think I did not explain correctly. Get modes is modified to give the needed target mode only so that userspace creates buffer of the needed resolution, but in fixup which is called at modeset, we correct the adjusted_mode back to have native resolutions so that modeset is correctly done. if we do not do like this, during modeset resolutions will be wrong as per the timings.

I'm confused. Can you please give an example in real numbers about the different resolution and how it's all fixed up in hw?

E.g. 800x600 framebuffer -> pfit -> 1024x756 panel,

get_modes gives 800x600, adjusted mode corrects to 1024x756. And please mention what vbt has to do in all this too.

I think I need an example since I can't figure out what exactly your describing ...

Thanks, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#26 lore raw

Re: [RFC PATCH 07/12] drm/i915/dsi: switch to drm_panel interface

In reply to Shobhit Kumar
Quoted 10 lines · Shobhit Kumar

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 893

Quoted 7 lines · Jani Nikula
drivers/gpu/drm/i915/intel_dsi.c +2 -1
@@ -881,13 +889,23 @@ void intel_dsi_init(struct drm_device *dev)
 
 	drm_connector_register(connector);
 
-	fixed_mode = dsi->dev_ops->get_modes(&intel_dsi->dev);
+	drm_panel_attach(intel_dsi->panel, connector);
+	drm_panel_get_modes(intel_dsi->panel);

Should be inside the config mutex_lock below.

Why?

Quoted 9 lines

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 902

Quoted 9 lines
drivers/gpu/drm/i915/intel_dsi.c +9 -0
+
+	mutex_lock(&dev->mode_config.mutex);
+	list_for_each_entry(scan, &connector->probed_modes, head) {
+		if ((scan->type & DRM_MODE_TYPE_PREFERRED)) {
+			fixed_mode = drm_mode_duplicate(dev, scan);
+			break;
+		}
+	}
+	mutex_unlock(&dev->mode_config.mutex);

Generally this is single-threaded init code, no one else can touch it. Which means you also never ever need locks. We tend to occasionally sprinkle them around to satisfy general locking checks which are correct at runtime. But at least in tricky cases that means we also stick a comment next to them (see e.g. the various places in i915_irq.c).

Merged up to the previous patch, thanks a lot.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

In reply to Daniel Vetter
Quoted 21 lines · Daniel Vetter
Quoted 13 lines · Shobhit Kumar
Quoted 11 lines · Jani Nikula
Quoted 7 lines · Shobhit Kumar

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Can we just have the driver return the desired mode from .get_modes in that case?

Quoted 6 lines

Okay, I think I did not explain correctly. Get modes is modified to give the needed target mode only so that userspace creates buffer of the needed resolution, but in fixup which is called at modeset, we correct the adjusted_mode back to have native resolutions so that modeset is correctly done. if we do not do like this, during modeset resolutions will be wrong as per the timings.

Quoted 6 lines

I'm confused. Can you please give an example in real numbers about the different resolution and how it's all fixed up in hw?

E.g. 800x600 framebuffer -> pfit -> 1024x756 panel,

get_modes gives 800x600, adjusted mode corrects to 1024x756. And please

We had a 19x12 DSI panel which we needed to drive at 12x8 due to lack of 12x8 panels for testing purposes. So get_modes returned 12x8 so that user space gave 12x8 FBs, and internally in mode_fixup we adjusted correctly for the 19x12 panel timings and enabled pfit

Quoted 1 line

mention what vbt has to do in all this too.

VBT allows to avoid panel specific and build specific hard coding in the code, which should work as is for normal 19x12 usage as well. Block #42 panel xres and yres are used to indicate this lower needed resolution when different from panel_fixed_mode.

Regards
Shobhit

Quoted 6 lines

I think I need an example since I can't figure out what exactly your describing ...

Thanks, Daniel

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#27 lore raw

Re: [RFC PATCH 07/12] drm/i915/dsi: switch to drm_panel interface

In reply to Daniel Vetter
Quoted 6 lines · Daniel Vetter
Quoted 5 lines · Shobhit Kumar
Quoted 4 lines · Jani Nikula
drivers/gpu/drm/i915/intel_dsi.c +0 -0
@@ -881,13 +889,23 @@ void intel_dsi_init(struct drm_device *dev)
 
  	drm_connector_register(connector);
 
Quoted 7 lines
Quoted 5 lines

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 893

Quoted 3 lines
drivers/gpu/drm/i915/intel_dsi.c +2 -1
-	fixed_mode = dsi->dev_ops->get_modes(&intel_dsi->dev);
+	drm_panel_attach(intel_dsi->panel, connector);
+	drm_panel_get_modes(intel_dsi->panel);

Should be inside the config mutex_lock below.

Why?

Because usually the drm_mode_probed_add gets called in the drm flow with correct locking, but in this case calling get_modes here results in drm_mode_probed_add being called which expects the lock to be taken. Else we will see a big WARN dump. I agree with your comment below but this was mainly to avoid the warning dump.

Quoted 17 lines
Quoted 10 lines

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 902

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi.c +9 -0
+
+	mutex_lock(&dev->mode_config.mutex);
+	list_for_each_entry(scan, &connector->probed_modes, head) {
+		if ((scan->type & DRM_MODE_TYPE_PREFERRED)) {
+			fixed_mode = drm_mode_duplicate(dev, scan);
+			break;
+		}
+	}
+	mutex_unlock(&dev->mode_config.mutex);

Generally this is single-threaded init code, no one else can touch it. Which means you also never ever need locks. We tend to occasionally sprinkle them around to satisfy general locking checks which are correct at runtime. But at least in tricky cases that means we also stick a comment next to them (see e.g. the various places in i915_irq.c).

Quoted 3 lines

Merged up to the previous patch, thanks a lot.
-Daniel

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

In reply to Shobhit Kumar
Quoted 25 lines · Shobhit Kumar
Quoted 24 lines · Daniel Vetter
Quoted 13 lines · Shobhit Kumar
Quoted 11 lines · Jani Nikula
Quoted 7 lines · Shobhit Kumar

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Can we just have the driver return the desired mode from .get_modes in that case?

Quoted 6 lines

Okay, I think I did not explain correctly. Get modes is modified to give the needed target mode only so that userspace creates buffer of the needed resolution, but in fixup which is called at modeset, we correct the adjusted_mode back to have native resolutions so that modeset is correctly done. if we do not do like this, during modeset resolutions will be wrong as per the timings.

I'm confused. Can you please give an example in real numbers about the different resolution and how it's all fixed up in hw?

Quoted 8 lines
Quoted 3 lines

E.g. 800x600 framebuffer -> pfit -> 1024x756 panel,

get_modes gives 800x600, adjusted mode corrects to 1024x756. And please

We had a 19x12 DSI panel which we needed to drive at 12x8 due to lack of 12x8 panels for testing purposes. So get_modes returned 12x8 so that user space gave 12x8 FBs, and internally in mode_fixup we adjusted correctly for the 19x12 panel timings and enabled pfit

Hm, is that a real use-case shipping to customers or just a hack for development? In the later case I think we can just hardcode the edid for edp ...
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

Quoted 30 lines · Daniel Vetter
Quoted 29 lines · Shobhit Kumar
Quoted 27 lines · Daniel Vetter
Quoted 13 lines · Shobhit Kumar
Quoted 11 lines · Jani Nikula
Quoted 7 lines · Shobhit Kumar

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Can we just have the driver return the desired mode from .get_modes in that case?

Quoted 6 lines

Okay, I think I did not explain correctly. Get modes is modified to give the needed target mode only so that userspace creates buffer of the needed resolution, but in fixup which is called at modeset, we correct the adjusted_mode back to have native resolutions so that modeset is correctly done. if we do not do like this, during modeset resolutions will be wrong as per the timings.

I'm confused. Can you please give an example in real numbers about the different resolution and how it's all fixed up in hw?

E.g. 800x600 framebuffer -> pfit -> 1024x756 panel,

get_modes gives 800x600, adjusted mode corrects to 1024x756. And please

Quoted 8 lines
Quoted 4 lines

We had a 19x12 DSI panel which we needed to drive at 12x8 due to lack of 12x8 panels for testing purposes. So get_modes returned 12x8 so that user space gave 12x8 FBs, and internally in mode_fixup we adjusted correctly for the 19x12 panel timings and enabled pfit

Hm, is that a real use-case shipping to customers or just a hack for development? In the later case I think we can just hardcode the edid for edp ...

Also how is this different from userspace creating a 800x600 mode and giving it to the kernel which then uses the pfitter to display it at native resolution. That is how it works today. This should also be possible with a video= parameter...
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#20 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

Quoted 36 lines · Chris Wilson
Quoted 35 lines · Daniel Vetter
Quoted 33 lines · Shobhit Kumar
Quoted 21 lines · Daniel Vetter
Quoted 13 lines · Shobhit Kumar
Quoted 11 lines · Jani Nikula
Quoted 7 lines · Shobhit Kumar

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Can we just have the driver return the desired mode from .get_modes in that case?

Quoted 6 lines

Okay, I think I did not explain correctly. Get modes is modified to give the needed target mode only so that userspace creates buffer of the needed resolution, but in fixup which is called at modeset, we correct the adjusted_mode back to have native resolutions so that modeset is correctly done. if we do not do like this, during modeset resolutions will be wrong as per the timings.

Quoted 6 lines

I'm confused. Can you please give an example in real numbers about the different resolution and how it's all fixed up in hw?

E.g. 800x600 framebuffer -> pfit -> 1024x756 panel,

get_modes gives 800x600, adjusted mode corrects to 1024x756. And please

We had a 19x12 DSI panel which we needed to drive at 12x8 due to lack of 12x8 panels for testing purposes. So get_modes returned 12x8 so that user space gave 12x8 FBs, and internally in mode_fixup we adjusted correctly for the 19x12 panel timings and enabled pfit

Quoted 8 lines
Quoted 3 lines

Hm, is that a real use-case shipping to customers or just a hack for development? In the later case I think we can just hardcode the edid for edp ...

Also how is this different from userspace creating a 800x600 mode and giving it to the kernel which then uses the pfitter to display it at native resolution. That is how it works today. This should also be possible with a video= parameter...

Its different in a way, that user space changes will need a new system build which is not allowed as per the requirements that we had and hence no hard coding in code anywhere as well.

As I said earlier also that this case might not be useful in general and I am okay to remove this callback.

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#21 lore raw

Re: [RFC PATCH 05/12] drm/i915/dsi: remove unnecessary dsi device callbacks

Quoted 46 lines · Shobhit Kumar
Quoted 36 lines · Chris Wilson
Quoted 35 lines · Daniel Vetter
Quoted 33 lines · Shobhit Kumar
Quoted 21 lines · Daniel Vetter
Quoted 13 lines · Shobhit Kumar
Quoted 11 lines · Jani Nikula
Quoted 7 lines · Shobhit Kumar

There had been a instance where we had to drive different resolution (lower) than the native one. Also in VBT there is a field to make this generic at least from driver perspective to give the needed target resolution. In case target resolution is same as native, nothing gets changed, else mode_fixup function adjusts the mode accordingly keeping timing as same and enabling scalar. Might not be useful in general, but did find a use internally.

Can we just have the driver return the desired mode from .get_modes in that case?

Quoted 6 lines

Okay, I think I did not explain correctly. Get modes is modified to give the needed target mode only so that userspace creates buffer of the needed resolution, but in fixup which is called at modeset, we correct the adjusted_mode back to have native resolutions so that modeset is correctly done. if we do not do like this, during modeset resolutions will be wrong as per the timings.

Quoted 6 lines

I'm confused. Can you please give an example in real numbers about the different resolution and how it's all fixed up in hw?

E.g. 800x600 framebuffer -> pfit -> 1024x756 panel,

get_modes gives 800x600, adjusted mode corrects to 1024x756. And please

We had a 19x12 DSI panel which we needed to drive at 12x8 due to lack of 12x8 panels for testing purposes. So get_modes returned 12x8 so that user space gave 12x8 FBs, and internally in mode_fixup we adjusted correctly for the 19x12 panel timings and enabled pfit

Quoted 8 lines
Quoted 3 lines

Hm, is that a real use-case shipping to customers or just a hack for development? In the later case I think we can just hardcode the edid for edp ...

Also how is this different from userspace creating a 800x600 mode and giving it to the kernel which then uses the pfitter to display it at native resolution. That is how it works today. This should also be possible with a video= parameter...

Quoted 6 lines

Its different in a way, that user space changes will need a new system build which is not allowed as per the requirements that we had and hence no hard coding in code anywhere as well.

As I said earlier also that this case might not be useful in general and I am okay to remove this callback.

Yeah I think if rebuilding vbt for testing is ok, but rebuilding the kernel isn't then that just smells like needless red tape. I'll reconsider as soon as we need this for shipping systems of course. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 1/1
#29 lore raw

Re: [PATCH v2] drm/i915/dsi: switch to drm_panel interface

In reply to Jani Nikula
Quoted 5 lines · Jani Nikula

Replace intel_dsi_device and intel_dsi_dev_ops with drm_panel and drm_panel_funcs. They are adequate for what we have now, and if we end up needing more than this we should improve drm_panel. This will keep us better aligned with the drm core infrastructure.

Quoted 7 lines

The panel driver initialization changes a bit. It still remains hideous, but fixing that is beyond the scope here.

v2: extend mode config mutex to cover drm_panel_get_modes (Shobhit)

     vbt_panel->intel_dsi = intel_dsi in vbt panel init (Shobhit)
Quoted 456 lines
---
  drivers/gpu/drm/i915/Kconfig               |   1 +
  drivers/gpu/drm/i915/intel_dsi.c           |  68 +++++++----
  drivers/gpu/drm/i915/intel_dsi.h           |  27 +----
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c | 180 ++++++++++++++++++-----------
  4 files changed, 157 insertions(+), 119 deletions(-)
drivers/gpu/drm/i915/Kconfig +1 -0
index 4e39ab34eb1c..da196cd07263 100644
@@ -11,6 +11,7 @@ config DRM_I915
  	select SHMEM
  	select TMPFS
  	select DRM_KMS_HELPER
+	select DRM_PANEL
  	# i915 depends on ACPI_VIDEO when ACPI is enabled
  	# but for select to work, need to select ACPI_VIDEO's dependencies, ick
  	select BACKLIGHT_LCD_SUPPORT if ACPI
drivers/gpu/drm/i915/intel_dsi.c +43 -25
index c56c4150fc13..52c5fabe284a 100644
@@ -27,18 +27,20 @@
  #include <drm/drm_crtc.h>
  #include <drm/drm_edid.h>
  #include <drm/i915_drm.h>
+#include <drm/drm_panel.h>
  #include <linux/slab.h>
  #include "i915_drv.h"
  #include "intel_drv.h"
  #include "intel_dsi.h"
  #include "intel_dsi_cmd.h"
 
-/* the sub-encoders aka panel drivers */
-static const struct intel_dsi_device intel_dsi_devices[] = {
+static const struct {
+	u16 panel_id;
+	struct drm_panel * (*init)(struct intel_dsi *intel_dsi, u16 panel_id);
+} intel_dsi_drivers[] = {
  	{
  		.panel_id = MIPI_DSI_GENERIC_PANEL_ID,
-		.name = "vbt-generic-dsi-vid-mode-display",
-		.dev_ops = &vbt_generic_dsi_display_ops,
+		.init = vbt_panel_init,
  	},
  };
 
@@ -214,8 +216,7 @@ static void intel_dsi_enable(struct intel_encoder *encoder)
  			dpi_send_cmd(intel_dsi, TURN_ON, DPI_LP_MODE_EN, port);
  		msleep(100);
 
-		if (intel_dsi->dev.dev_ops->enable)
-			intel_dsi->dev.dev_ops->enable(&intel_dsi->dev);
+		drm_panel_enable(intel_dsi->panel);
 
  		for_each_dsi_port(port, intel_dsi->ports)
  			wait_for_dsi_fifo_empty(intel_dsi, port);
@@ -255,8 +256,7 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 
  	msleep(intel_dsi->panel_on_delay);
 
-	if (intel_dsi->dev.dev_ops->panel_reset)
-		intel_dsi->dev.dev_ops->panel_reset(&intel_dsi->dev);
+	drm_panel_prepare(intel_dsi->panel);
 
  	for_each_dsi_port(port, intel_dsi->ports)
  		wait_for_dsi_fifo_empty(intel_dsi, port);
@@ -329,8 +329,7 @@ static void intel_dsi_disable(struct intel_encoder *encoder)
  	}
  	/* if disable packets are sent before sending shutdown packet then in
  	 * some next enable sequence send turn on packet error is observed */
-	if (intel_dsi->dev.dev_ops->disable)
-		intel_dsi->dev.dev_ops->disable(&intel_dsi->dev);
+	drm_panel_disable(intel_dsi->panel);
 
  	for_each_dsi_port(port, intel_dsi->ports)
  		wait_for_dsi_fifo_empty(intel_dsi, port);
@@ -395,8 +394,7 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
  	val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
  	I915_WRITE(DSPCLK_GATE_D, val);
 
-	if (intel_dsi->dev.dev_ops->disable_panel_power)
-		intel_dsi->dev.dev_ops->disable_panel_power(&intel_dsi->dev);
+	drm_panel_unprepare(intel_dsi->panel);
 
  	msleep(intel_dsi->panel_off_delay);
  	msleep(intel_dsi->panel_pwr_cycle_delay);
@@ -760,7 +758,7 @@ static int intel_dsi_get_modes(struct drm_connector *connector)
  	return 1;
  }
 
-static void intel_dsi_destroy(struct drm_connector *connector)
+static void intel_dsi_connector_destroy(struct drm_connector *connector)
  {
  	struct intel_connector *intel_connector = to_intel_connector(connector);
 
@@ -770,8 +768,20 @@ static void intel_dsi_destroy(struct drm_connector *connector)
  	kfree(connector);
  }
 
+static void intel_dsi_encoder_destroy(struct drm_encoder *encoder)
+{
+	struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
+
+	if (intel_dsi->panel) {
+		drm_panel_detach(intel_dsi->panel);
+		/* XXX: Logically this call belongs in the panel driver. */
+		drm_panel_remove(intel_dsi->panel);
+	}
+	intel_encoder_destroy(encoder);
+}
+
  static const struct drm_encoder_funcs intel_dsi_funcs = {
-	.destroy = intel_encoder_destroy,
+	.destroy = intel_dsi_encoder_destroy,
  };
 
  static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs = {
@@ -783,7 +793,7 @@ static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs
  static const struct drm_connector_funcs intel_dsi_connector_funcs = {
  	.dpms = intel_connector_dpms,
  	.detect = intel_dsi_detect,
-	.destroy = intel_dsi_destroy,
+	.destroy = intel_dsi_connector_destroy,
  	.fill_modes = drm_helper_probe_single_connector_modes,
  };
 
@@ -794,9 +804,8 @@ void intel_dsi_init(struct drm_device *dev)
  	struct drm_encoder *encoder;
  	struct intel_connector *intel_connector;
  	struct drm_connector *connector;
-	struct drm_display_mode *fixed_mode = NULL;
+	struct drm_display_mode *scan, *fixed_mode = NULL;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	const struct intel_dsi_device *dsi;
  	unsigned int i;
 
  	DRM_DEBUG_KMS("\n");
@@ -853,15 +862,14 @@ void intel_dsi_init(struct drm_device *dev)
  		intel_dsi->ports = (1 << PORT_C);
  	}
 
-	for (i = 0; i < ARRAY_SIZE(intel_dsi_devices); i++) {
-		dsi = &intel_dsi_devices[i];
-		intel_dsi->dev = *dsi;
-
-		if (dsi->dev_ops->init(&intel_dsi->dev))
+	for (i = 0; i < ARRAY_SIZE(intel_dsi_drivers); i++) {
+		intel_dsi->panel = intel_dsi_drivers[i].init(intel_dsi,
+							     intel_dsi_drivers[i].panel_id);
+		if (intel_dsi->panel)
  			break;
  	}
 
-	if (i == ARRAY_SIZE(intel_dsi_devices)) {
+	if (!intel_dsi->panel) {
  		DRM_DEBUG_KMS("no device found\n");
  		goto err;
  	}
@@ -881,13 +889,23 @@ void intel_dsi_init(struct drm_device *dev)
 
  	drm_connector_register(connector);
 
-	fixed_mode = dsi->dev_ops->get_modes(&intel_dsi->dev);
+	drm_panel_attach(intel_dsi->panel, connector);
+
+	mutex_lock(&dev->mode_config.mutex);
+	drm_panel_get_modes(intel_dsi->panel);
+	list_for_each_entry(scan, &connector->probed_modes, head) {
+		if ((scan->type & DRM_MODE_TYPE_PREFERRED)) {
+			fixed_mode = drm_mode_duplicate(dev, scan);
+			break;
+		}
+	}
+	mutex_unlock(&dev->mode_config.mutex);
+
  	if (!fixed_mode) {
  		DRM_DEBUG_KMS("no fixed mode\n");
  		goto err;
  	}
 
-	fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
  	return;
drivers/gpu/drm/i915/intel_dsi.h +2 -25
index 22f87036a256..fc0b2b8d90f1 100644
@@ -33,33 +33,10 @@
  #define DSI_DUAL_LINK_FRONT_BACK	1
  #define DSI_DUAL_LINK_PIXEL_ALT		2
 
-struct intel_dsi_device {
-	unsigned int panel_id;
-	const char *name;
-	const struct intel_dsi_dev_ops *dev_ops;
-	void *dev_priv;
-};
-
-struct intel_dsi_dev_ops {
-	bool (*init)(struct intel_dsi_device *dsi);
-
-	void (*panel_reset)(struct intel_dsi_device *dsi);
-
-	void (*disable_panel_power)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*enable)(struct intel_dsi_device *dsi);
-
-	/* This callback must be able to assume DSI commands can be sent */
-	void (*disable)(struct intel_dsi_device *dsi);
-
-	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi);
-};
-
  struct intel_dsi {
  	struct intel_encoder base;
 
-	struct intel_dsi_device dev;
+	struct drm_panel *panel;
 
  	struct intel_connector *attached_connector;
 
@@ -130,6 +107,6 @@ extern void vlv_enable_dsi_pll(struct intel_encoder *encoder);
  extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
  extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
 
-extern struct intel_dsi_dev_ops vbt_generic_dsi_display_ops;
+struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id);
 
  #endif /* _INTEL_DSI_H */
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +111 -59
index 561ec2981dfd..ac7a24dcf7f7 100644
@@ -28,6 +28,7 @@
  #include <drm/drm_crtc.h>
  #include <drm/drm_edid.h>
  #include <drm/i915_drm.h>
+#include <drm/drm_panel.h>
  #include <linux/slab.h>
  #include <video/mipi_display.h>
  #include <asm/intel-mid.h>
@@ -37,6 +38,16 @@
  #include "intel_dsi.h"
  #include "intel_dsi_cmd.h"
 
+struct vbt_panel {
+	struct drm_panel panel;
+	struct intel_dsi *intel_dsi;
+};
+
+static inline struct vbt_panel *to_vbt_panel(struct drm_panel *panel)
+{
+	return container_of(panel, struct vbt_panel, panel);
+}
+
  #define MIPI_TRANSFER_MODE_SHIFT	0
  #define MIPI_VIRTUAL_CHANNEL_SHIFT	1
  #define MIPI_PORT_SHIFT			3
@@ -272,14 +283,103 @@ static void generic_exec_sequence(struct intel_dsi *intel_dsi, const u8 *data)
  	}
  }
 
-static bool generic_init(struct intel_dsi_device *dsi)
+static int vbt_panel_prepare(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const u8 *sequence;
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	return 0;
+}
+
+static int vbt_panel_unprepare(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const u8 *sequence;
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	return 0;
+}
+
+static int vbt_panel_enable(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const u8 *sequence;
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DISPLAY_ON];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	return 0;
+}
+
+static int vbt_panel_disable(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	const u8 *sequence;
+
+	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DISPLAY_OFF];
+	generic_exec_sequence(intel_dsi, sequence);
+
+	return 0;
+}
+
+static int vbt_panel_get_modes(struct drm_panel *panel)
+{
+	struct vbt_panel *vbt_panel = to_vbt_panel(panel);
+	struct intel_dsi *intel_dsi = vbt_panel->intel_dsi;
+	struct drm_device *dev = intel_dsi->base.base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_display_mode *mode;
+
+	if (!panel->connector)
+		return 0;
+
+	mode = drm_mode_duplicate(dev, dev_priv->vbt.lfp_lvds_vbt_mode);
+	if (!mode)
+		return 0;
+
+	mode->type |= DRM_MODE_TYPE_PREFERRED;
+
+	drm_mode_probed_add(panel->connector, mode);
+
+	return 1;
+}
+
+static const struct drm_panel_funcs vbt_panel_funcs = {
+	.disable = vbt_panel_disable,
+	.unprepare = vbt_panel_unprepare,
+	.prepare = vbt_panel_prepare,
+	.enable = vbt_panel_enable,
+	.get_modes = vbt_panel_get_modes,
+};
+
+struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
  {
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
  	struct drm_device *dev = intel_dsi->base.base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct mipi_config *mipi_config = dev_priv->vbt.dsi.config;
  	struct mipi_pps_data *pps = dev_priv->vbt.dsi.pps;
  	struct drm_display_mode *mode = dev_priv->vbt.lfp_lvds_vbt_mode;
+	struct vbt_panel *vbt_panel;
  	u32 bits_per_pixel = 24;
  	u32 tlpx_ns, extra_byte_count, bitrate, tlpx_ui;
  	u32 ui_num, ui_den;
@@ -346,7 +446,7 @@ static bool generic_init(struct intel_dsi_device *dsi)
  			if (mipi_config->target_burst_mode_freq <
  								computed_ddr) {
  				DRM_ERROR("Burst mode freq is less than computed\n");
-				return false;
+				return NULL;
  			}
 
  			burst_mode_ratio = DIV_ROUND_UP(
@@ -356,7 +456,7 @@ static bool generic_init(struct intel_dsi_device *dsi)
  			pclk = DIV_ROUND_UP(pclk * burst_mode_ratio, 100);
  		} else {
  			DRM_ERROR("Burst mode target is not set\n");
-			return false;
+			return NULL;
  		}
  	} else
  		burst_mode_ratio = 100;
@@ -557,71 +657,13 @@ static bool generic_init(struct intel_dsi_device *dsi)
  	intel_dsi->panel_off_delay = pps->panel_off_delay / 10;
  	intel_dsi->panel_pwr_cycle_delay = pps->panel_power_cycle_delay / 10;
 
-	return true;
-}
-
-static void generic_panel_reset(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET];
-
-	generic_exec_sequence(intel_dsi, sequence);
-
-	sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
-	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static void generic_disable_panel_power(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
-
-	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static void generic_enable(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
+	/* This is cheating a bit with the cleanup. */
+	vbt_panel = devm_kzalloc(dev->dev, sizeof(*vbt_panel), GFP_KERNEL);
 
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DISPLAY_ON];
+	vbt_panel->intel_dsi = intel_dsi;
+	drm_panel_init(&vbt_panel->panel);
+	vbt_panel->panel.funcs = &vbt_panel_funcs;
+	drm_panel_add(&vbt_panel->panel);
 
-	generic_exec_sequence(intel_dsi, sequence);
+	return &vbt_panel->panel;
  }
-
-static void generic_disable(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	char *sequence = dev_priv->vbt.dsi.sequence[MIPI_SEQ_DISPLAY_OFF];
-
-	generic_exec_sequence(intel_dsi, sequence);
-}
-
-static struct drm_display_mode *generic_get_modes(struct intel_dsi_device *dsi)
-{
-	struct intel_dsi *intel_dsi = container_of(dsi, struct intel_dsi, dev);
-	struct drm_device *dev = intel_dsi->base.base.dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	dev_priv->vbt.lfp_lvds_vbt_mode->type |= DRM_MODE_TYPE_PREFERRED;
-	return dev_priv->vbt.lfp_lvds_vbt_mode;

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static bool generic_init(struct intel_dsi_device *dsi) · line 627

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -10
-}
-
-struct intel_dsi_dev_ops vbt_generic_dsi_display_ops = {
-	.init = generic_init,
-	.panel_reset = generic_panel_reset,
-	.disable_panel_power = generic_disable_panel_power,
-	.enable = generic_enable,
-	.disable = generic_disable,
-	.get_modes = generic_get_modes,
-};

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#40 lore raw

Re: [RFC PATCH 12/12] drm/i915/dsi: remove intel_dsi_cmd.c and the unused functions therein

In reply to Shobhit Kumar
Quoted 6 lines · Shobhit Kumar
Quoted 3 lines · Jani Nikula

The removed functions can be resurrected in intel_dsi.c as need arises.

Ok, merged all the remaining patches.

Thanks, Daniel

Quoted 173 lines
Quoted 162 lines
---
 drivers/gpu/drm/i915/Makefile              |   1 -
 drivers/gpu/drm/i915/intel_dsi.c           |   1 -
 drivers/gpu/drm/i915/intel_dsi_cmd.c       | 117 -----------------------------
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |   1 -
 4 files changed, 120 deletions(-)
 delete mode 100644 drivers/gpu/drm/i915/intel_dsi_cmd.c
drivers/gpu/drm/i915/Makefile +0 -1
index 16e3dc350274..63afe63bf0e4 100644
@@ -71,7 +71,6 @@ i915-y += dvo_ch7017.o \
 	  intel_ddi.o \
 	  intel_dp.o \
 	  intel_dp_mst.o \
-	  intel_dsi_cmd.o \
 	  intel_dsi.o \
 	  intel_dsi_pll.o \
 	  intel_dsi_panel_vbt.o \
drivers/gpu/drm/i915/intel_dsi.c +0 -1
index 791d90b4c047..02ae5e583b27 100644
@@ -33,7 +33,6 @@
 #include "i915_drv.h"
 #include "intel_drv.h"
 #include "intel_dsi.h"
-#include "intel_dsi_cmd.h"
 
 static const struct {
 	u16 panel_id;
drivers/gpu/drm/i915/intel_dsi_cmd.c deleted +0 -117
deleted file mode 100644
index acdc5da7b46f..000000000000
@@ -1,117 +0,0 @@
-/*
- * Copyright © 2013 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Author: Jani Nikula <[email protected]>
- */
-
-#include <linux/export.h>
-#include <drm/drmP.h>
-#include <drm/drm_crtc.h>
-#include <video/mipi_display.h>
-#include "i915_drv.h"
-#include "intel_drv.h"
-#include "intel_dsi.h"
-#include "intel_dsi_cmd.h"
-
-/*
- * XXX: MIPI_DATA_ADDRESS, MIPI_DATA_LENGTH, MIPI_COMMAND_LENGTH, and
- * MIPI_COMMAND_ADDRESS registers.
- *
- * Apparently these registers provide a MIPI adapter level way to send (lots of)
- * commands and data to the receiver, without having to write the commands and
- * data to MIPI_{HS,LP}_GEN_{CTRL,DATA} registers word by word.
- *
- * Presumably for anything other than MIPI_DCS_WRITE_MEMORY_START and
- * MIPI_DCS_WRITE_MEMORY_CONTINUE (which are used to update the external
- * framebuffer in command mode displays) these are just an optimization that can
- * come later.
- *
- * For memory writes, these should probably be used for performance.
- */
-
-static void print_stat(struct intel_dsi *intel_dsi, enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 val;
-
-	val = I915_READ(MIPI_INTR_STAT(port));
-
-#define STAT_BIT(val, bit) (val) & (bit) ? " " #bit : ""
-	DRM_DEBUG_KMS("MIPI_INTR_STAT(%c) = %08x"
-		      "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
-		      "\n", port_name(port), val,
-		      STAT_BIT(val, TEARING_EFFECT),
-		      STAT_BIT(val, SPL_PKT_SENT_INTERRUPT),
-		      STAT_BIT(val, GEN_READ_DATA_AVAIL),
-		      STAT_BIT(val, LP_GENERIC_WR_FIFO_FULL),
-		      STAT_BIT(val, HS_GENERIC_WR_FIFO_FULL),
-		      STAT_BIT(val, RX_PROT_VIOLATION),
-		      STAT_BIT(val, RX_INVALID_TX_LENGTH),
-		      STAT_BIT(val, ACK_WITH_NO_ERROR),
-		      STAT_BIT(val, TURN_AROUND_ACK_TIMEOUT),
-		      STAT_BIT(val, LP_RX_TIMEOUT),
-		      STAT_BIT(val, HS_TX_TIMEOUT),
-		      STAT_BIT(val, DPI_FIFO_UNDERRUN),
-		      STAT_BIT(val, LOW_CONTENTION),
-		      STAT_BIT(val, HIGH_CONTENTION),
-		      STAT_BIT(val, TXDSI_VC_ID_INVALID),
-		      STAT_BIT(val, TXDSI_DATA_TYPE_NOT_RECOGNISED),
-		      STAT_BIT(val, TXCHECKSUM_ERROR),
-		      STAT_BIT(val, TXECC_MULTIBIT_ERROR),
-		      STAT_BIT(val, TXECC_SINGLE_BIT_ERROR),
-		      STAT_BIT(val, TXFALSE_CONTROL_ERROR),
-		      STAT_BIT(val, RXDSI_VC_ID_INVALID),
-		      STAT_BIT(val, RXDSI_DATA_TYPE_NOT_REGOGNISED),
-		      STAT_BIT(val, RXCHECKSUM_ERROR),
-		      STAT_BIT(val, RXECC_MULTIBIT_ERROR),
-		      STAT_BIT(val, RXECC_SINGLE_BIT_ERROR),
-		      STAT_BIT(val, RXFALSE_CONTROL_ERROR),
-		      STAT_BIT(val, RXHS_RECEIVE_TIMEOUT_ERROR),
-		      STAT_BIT(val, RX_LP_TX_SYNC_ERROR),
-		      STAT_BIT(val, RXEXCAPE_MODE_ENTRY_ERROR),
-		      STAT_BIT(val, RXEOT_SYNC_ERROR),
-		      STAT_BIT(val, RXSOT_SYNC_ERROR),
-		      STAT_BIT(val, RXSOT_ERROR));
-#undef STAT_BIT
-}
-
-/* enable or disable command mode hs transmissions */
-void dsi_hs_mode_enable(struct intel_dsi *intel_dsi, bool enable,
-						enum port port)
-{
-	struct drm_encoder *encoder = &intel_dsi->base.base;
-	struct drm_device *dev = encoder->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	u32 temp;
-	u32 mask = DBI_FIFO_EMPTY;
-
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 50))
-		DRM_ERROR("Timeout waiting for DBI FIFO empty\n");
-
-	temp = I915_READ(MIPI_HS_LP_DBI_ENABLE(port));
-	temp &= DBI_HS_LP_MODE_MASK;
-	I915_WRITE(MIPI_HS_LP_DBI_ENABLE(port), enable ? DBI_HS_MODE : DBI_LP_MODE);
-
-	intel_dsi->hs = enable;
-}
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
index 0b09e66f7e29..c3eec66f5076 100644

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c line 41

Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -1
@@ -36,7 +36,6 @@
 #include "i915_drv.h"
 #include "intel_drv.h"
 #include "intel_dsi.h"
-#include "intel_dsi_cmd.h"
 
 struct vbt_panel {
 	struct drm_panel panel;

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx