Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpu: ipu-v3: Add ipu_idmac_buffer_is_ready()

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>

authored by

Steve Longerbeam and committed by
Philipp Zabel
aa52f578 a4cd8f22

+27 -1
+25 -1
drivers/gpu/ipu-v3/ipu-common.c
··· 232 232 } 233 233 EXPORT_SYMBOL_GPL(ipu_idmac_put); 234 234 235 - #define idma_mask(ch) (1 << (ch & 0x1f)) 235 + #define idma_mask(ch) (1 << ((ch) & 0x1f)) 236 236 237 237 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel, 238 238 bool doublebuffer) ··· 314 314 return (ipu_cm_read(ipu, IPU_CHA_CUR_BUF(chno)) & idma_mask(chno)) ? 1 : 0; 315 315 } 316 316 EXPORT_SYMBOL_GPL(ipu_idmac_get_current_buffer); 317 + 318 + bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num) 319 + { 320 + struct ipu_soc *ipu = channel->ipu; 321 + unsigned long flags; 322 + u32 reg = 0; 323 + 324 + spin_lock_irqsave(&ipu->lock, flags); 325 + switch (buf_num) { 326 + case 0: 327 + reg = ipu_cm_read(ipu, IPU_CHA_BUF0_RDY(channel->num)); 328 + break; 329 + case 1: 330 + reg = ipu_cm_read(ipu, IPU_CHA_BUF1_RDY(channel->num)); 331 + break; 332 + case 2: 333 + reg = ipu_cm_read(ipu, IPU_CHA_BUF2_RDY(channel->num)); 334 + break; 335 + } 336 + spin_unlock_irqrestore(&ipu->lock, flags); 337 + 338 + return ((reg & idma_mask(channel->num)) != 0); 339 + } 340 + EXPORT_SYMBOL_GPL(ipu_idmac_buffer_is_ready); 317 341 318 342 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num) 319 343 {
+1
drivers/gpu/ipu-v3/ipu-prv.h
··· 68 68 #define IPU_DISP_TASK_STAT IPU_CM_REG(0x0254) 69 69 #define IPU_CHA_BUF0_RDY(ch) IPU_CM_REG(0x0268 + 4 * ((ch) / 32)) 70 70 #define IPU_CHA_BUF1_RDY(ch) IPU_CM_REG(0x0270 + 4 * ((ch) / 32)) 71 + #define IPU_CHA_BUF2_RDY(ch) IPU_CM_REG(0x0288 + 4 * ((ch) / 32)) 71 72 #define IPU_ALT_CHA_BUF0_RDY(ch) IPU_CM_REG(0x0278 + 4 * ((ch) / 32)) 72 73 #define IPU_ALT_CHA_BUF1_RDY(ch) IPU_CM_REG(0x0280 + 4 * ((ch) / 32)) 73 74
+1
include/video/imx-ipu-v3.h
··· 165 165 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel, 166 166 bool doublebuffer); 167 167 int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel); 168 + bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num); 168 169 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num); 169 170 170 171 /*