[Intel-gfx] [PATCH 01/14] drm/i915: allocate DMA region for mipi dbi cmd buffer

Gaurav K Singh gaurav.k.singh at intel.com
Tue Sep 29 14:53:58 PDT 2015


Allocate DMA region for MIPI DBI command buffer. This memory
will be used when sending command via DBI interface.

Signed-off-by: Gaurav K Singh <gaurav.k.singh at intel.com>
Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohan.marimuthu at intel.com>
---
 drivers/gpu/drm/i915/intel_dsi.c |   17 +++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi.h |    2 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index d7e2118..6483d7f 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -32,6 +32,7 @@
 #include <drm/drm_mipi_dsi.h>
 #include <linux/slab.h>
 #include <linux/gpio/consumer.h>
+#include <linux/dma-mapping.h>
 #include "i915_drv.h"
 #include "intel_drv.h"
 #include "intel_dsi.h"
@@ -468,12 +469,22 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
 	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
+	dma_addr_t dma_handle;
 	enum pipe pipe = intel_crtc->pipe;
 	enum port port;
 	u32 tmp;
 
 	DRM_DEBUG_KMS("\n");
 
+	if (IS_CHERRYVIEW(dev))
+		intel_dsi->cmd_buff_virt_addr = dma_alloc_coherent(dev, 4096,
+								&dma_handle, GFP_KERNEL);
+		if (!intel_dsi->cmd_buff_virt_addr)
+			return -ENOMEM;
+
+		intel_dsi->dma_handle = dma_handle;
+	}
+
 	/* Panel Enable over CRC PMIC */
 	if (intel_dsi->gpio_panel)
 		gpiod_set_value_cansleep(intel_dsi->gpio_panel, 1);
@@ -661,6 +672,10 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 	msleep(intel_dsi->panel_off_delay);
 	msleep(intel_dsi->panel_pwr_cycle_delay);
 
+	if (IS_CHERRYVIEW(dev_priv->dev) && intel_dsi->dma_handle)
+		dma_free_coherent(dev, 4096,
+				intel_dsi->cmd_buff_virt_addr, intel_dsi->dma_handle);
+
 	/* Panel Disable over CRC PMIC */
 	if (intel_dsi->gpio_panel)
 		gpiod_set_value_cansleep(intel_dsi->gpio_panel, 0);
@@ -1198,6 +1213,8 @@ void intel_dsi_init(struct drm_device *dev)
 		intel_encoder->crtc_mask = (1 << PIPE_B);
 		intel_dsi->ports = (1 << PORT_C);
 	}
+	intel_dsi->cmd_buff_virt_addr = NULL;
+	intel_dsi->dma_handle = 0;
 
 	/* Create a DSI host (and a device) for each port. */
 	for_each_dsi_port(port, intel_dsi->ports) {
diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
index e6cb252..81b321f 100644
--- a/drivers/gpu/drm/i915/intel_dsi.h
+++ b/drivers/gpu/drm/i915/intel_dsi.h
@@ -46,6 +46,8 @@ struct intel_dsi {
 	struct gpio_desc *gpio_panel;
 
 	struct intel_connector *attached_connector;
+	void *cmd_buff_virt_addr;
+	dma_addr_t dma_handle;
 
 	/* bit mask of ports being driven */
 	u16 ports;
-- 
1.7.9.5



More information about the Intel-gfx mailing list