* @mdev_lock: protects the count, notifier and csi members
* @pad: media pad for the video device entity
*
- * @hw_lock: protects the slot counter, hardware programming of
- * slot addresses and the @buf_addr[] list
+ * @hw_lock: protects the @active_slot counter, hardware programming
+ * of slot addresses and the @buf_addr[] list
* @buf_addr: Memory addresses where current video data is written
+ * @active_slot: The slot in use
*
* @lock: protects @queue
* @queue: vb2 buffers queue
spinlock_t hw_lock;
dma_addr_t buf_addr[RZG2L_CRU_HW_BUFFER_DEFAULT];
+ unsigned int active_slot;
struct mutex lock;
struct vb2_queue queue;
return IRQ_RETVAL(handled);
}
-static int rzg3e_cru_get_current_slot(struct rzg2l_cru_dev *cru)
-{
- u64 amnmadrs;
- int slot;
-
- /*
- * When AMnMADRSL is read, AMnMADRSH of the higher-order
- * address also latches the address.
- *
- * AMnMADRSH must be read after AMnMADRSL has been read.
- */
- amnmadrs = rzg2l_cru_read(cru, AMnMADRSL);
- amnmadrs |= (u64)rzg2l_cru_read(cru, AMnMADRSH) << 32;
-
- /* Ensure amnmadrs is within this buffer range */
- for (slot = 0; slot < cru->num_buf; slot++) {
- if (amnmadrs >= cru->buf_addr[slot] &&
- amnmadrs < cru->buf_addr[slot] + cru->format.sizeimage)
- return slot;
- }
-
- dev_err(cru->dev, "Invalid MB address 0x%llx (out of range)\n", amnmadrs);
- return -EINVAL;
-}
-
irqreturn_t rzg3e_cru_irq(int irq, void *data)
{
struct rzg2l_cru_dev *cru = data;
return IRQ_HANDLED;
}
- slot = rzg3e_cru_get_current_slot(cru);
- if (slot < 0)
- return IRQ_HANDLED;
+ slot = cru->active_slot;
+ cru->active_slot = (cru->active_slot + 1) % cru->num_buf;
dev_dbg(cru->dev, "Current written slot: %d\n", slot);
cru->buf_addr[slot] = 0;
goto assert_presetn;
}
+ cru->active_slot = 0;
cru->sequence = 0;
ret = rzg2l_cru_set_stream(cru, 1);