drm/i915/dsi: call dpi_send_cmd() for each dsi port at a higher level
authorJani Nikula <jani.nikula@intel.com>
Fri, 16 Jan 2015 12:27:16 +0000 (14:27 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 27 Jan 2015 08:51:11 +0000 (09:51 +0100)
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 <gaurav.k.singh@intel.com>
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.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-By: Shobhit Kumar <shobhit.kumar@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_dsi.c
drivers/gpu/drm/i915/intel_dsi_cmd.c
drivers/gpu/drm/i915/intel_dsi_cmd.h

index 6620124eccc2bc151e6b0ed58c6de47314ed4b64..4bb9886fa2cfb44864a123ac0f222d5a188ce15b 100644 (file)
@@ -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);
        }
 }
index 562811c1a9d2ba9eca20bcdce40178eb36f4f773..5f63c807acea11e2e716ce5877c468c335f39b8b 100644 (file)
@@ -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;
 }
index 326a5ac555616af5eb79040d2a808d6f780dd0df..1d1a716e473ac013105d8b364d29e91a8059008b 100644 (file)
@@ -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 */