gpu: ipu-v3: Add ipu_idmac_buffer_is_ready()
authorSteve Longerbeam <slongerbeam@gmail.com>
Thu, 26 Jun 2014 01:05:40 +0000 (18:05 -0700)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Tue, 2 Sep 2014 12:55:48 +0000 (14:55 +0200)
Add ipu_idmac_buffer_is_ready(), returns true if the given buffer in
the given channel is set ready (owned by IPU), or false if not ready
(owned by CPU core).

Support has been added for third buffer, there is no support yet for
triple-buffering in idmac channels, but this function checks
buffer-ready for third buffer in case this support is added later.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
drivers/gpu/ipu-v3/ipu-common.c
drivers/gpu/ipu-v3/ipu-prv.h
include/video/imx-ipu-v3.h

index 18563c240f1080f61d56585ffd6cbf2323abf36e..fec72c0d18ba6006c4ca8977c3a1e9996a8c34d8 100644 (file)
@@ -232,7 +232,7 @@ void ipu_idmac_put(struct ipuv3_channel *channel)
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_put);
 
-#define idma_mask(ch)                  (1 << (ch & 0x1f))
+#define idma_mask(ch)                  (1 << ((ch) & 0x1f))
 
 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
                bool doublebuffer)
@@ -315,6 +315,30 @@ int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel)
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_get_current_buffer);
 
+bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num)
+{
+       struct ipu_soc *ipu = channel->ipu;
+       unsigned long flags;
+       u32 reg = 0;
+
+       spin_lock_irqsave(&ipu->lock, flags);
+       switch (buf_num) {
+       case 0:
+               reg = ipu_cm_read(ipu, IPU_CHA_BUF0_RDY(channel->num));
+               break;
+       case 1:
+               reg = ipu_cm_read(ipu, IPU_CHA_BUF1_RDY(channel->num));
+               break;
+       case 2:
+               reg = ipu_cm_read(ipu, IPU_CHA_BUF2_RDY(channel->num));
+               break;
+       }
+       spin_unlock_irqrestore(&ipu->lock, flags);
+
+       return ((reg & idma_mask(channel->num)) != 0);
+}
+EXPORT_SYMBOL_GPL(ipu_idmac_buffer_is_ready);
+
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num)
 {
        struct ipu_soc *ipu = channel->ipu;
index 7f08a461c92997b9c26bcbe648826edc151e18f4..bfb1e8a4483fdbf7afbcc15311b90e3be986ffb1 100644 (file)
@@ -68,6 +68,7 @@ struct ipu_soc;
 #define IPU_DISP_TASK_STAT             IPU_CM_REG(0x0254)
 #define IPU_CHA_BUF0_RDY(ch)           IPU_CM_REG(0x0268 + 4 * ((ch) / 32))
 #define IPU_CHA_BUF1_RDY(ch)           IPU_CM_REG(0x0270 + 4 * ((ch) / 32))
+#define IPU_CHA_BUF2_RDY(ch)           IPU_CM_REG(0x0288 + 4 * ((ch) / 32))
 #define IPU_ALT_CHA_BUF0_RDY(ch)       IPU_CM_REG(0x0278 + 4 * ((ch) / 32))
 #define IPU_ALT_CHA_BUF1_RDY(ch)       IPU_CM_REG(0x0280 + 4 * ((ch) / 32))
 
index 2e9bfe24fb679107a821d3d94b18c51a12b6c348..10013378394e83800b045525738378c928edb484 100644 (file)
@@ -165,6 +165,7 @@ int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
                bool doublebuffer);
 int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel);
+bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num);
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
 
 /*