Skip to content

Commit aa52f57

Browse files
slongerbeampH5
authored andcommitted
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>
1 parent a4cd8f2 commit aa52f57

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎drivers/gpu/ipu-v3/ipu-common.c‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void ipu_idmac_put(struct ipuv3_channel *channel)
232232
}
233233
EXPORT_SYMBOL_GPL(ipu_idmac_put);
234234

235-
#define idma_mask(ch) (1 << (ch & 0x1f))
235+
#define idma_mask(ch) (1 << ((ch) & 0x1f))
236236

237237
void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
238238
bool doublebuffer)
@@ -315,6 +315,30 @@ int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel)
315315
}
316316
EXPORT_SYMBOL_GPL(ipu_idmac_get_current_buffer);
317317

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);
341+
318342
void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num)
319343
{
320344
struct ipu_soc *ipu = channel->ipu;

‎drivers/gpu/ipu-v3/ipu-prv.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct ipu_soc;
6868
#define IPU_DISP_TASK_STAT IPU_CM_REG(0x0254)
6969
#define IPU_CHA_BUF0_RDY(ch) IPU_CM_REG(0x0268 + 4 * ((ch) / 32))
7070
#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))
7172
#define IPU_ALT_CHA_BUF0_RDY(ch) IPU_CM_REG(0x0278 + 4 * ((ch) / 32))
7273
#define IPU_ALT_CHA_BUF1_RDY(ch) IPU_CM_REG(0x0280 + 4 * ((ch) / 32))
7374

‎include/video/imx-ipu-v3.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
165165
void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
166166
bool doublebuffer);
167167
int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel);
168+
bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num);
168169
void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
169170

170171
/*

0 commit comments

Comments
 (0)