mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-29 17:53:59 -04:00
media: ti: j721e-csi2rx: Submit all available buffers
We already make sure to submit all available buffers to DMA in each DMA completion callback. Move that logic in a separate function, and use it during stream start as well, as most application queue all their buffers before stream on. Signed-off-by: Jai Luthra <j-luthra@ti.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Yemike Abhilash Chandra <y-abhilashchandra@ti.com> Co-developed-by: Rishikesh Donadkar <r-donadkar@ti.com> Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
This commit is contained in:
@@ -663,11 +663,32 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ti_csi2rx_dma_submit_pending(struct ti_csi2rx_ctx *ctx)
|
||||
{
|
||||
struct ti_csi2rx_dma *dma = &ctx->dma;
|
||||
struct ti_csi2rx_buffer *buf;
|
||||
int ret = 0;
|
||||
|
||||
/* If there are more buffers to process then start their transfer. */
|
||||
while (!list_empty(&dma->queue)) {
|
||||
buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list);
|
||||
ret = ti_csi2rx_start_dma(ctx, buf);
|
||||
if (ret) {
|
||||
dev_err(ctx->csi->dev,
|
||||
"Failed to queue the next buffer for DMA\n");
|
||||
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
|
||||
list_del(&buf->list);
|
||||
} else {
|
||||
list_move_tail(&buf->list, &dma->submitted);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ti_csi2rx_dma_callback(void *param)
|
||||
{
|
||||
struct ti_csi2rx_buffer *buf = param;
|
||||
struct ti_csi2rx_ctx *ctx = buf->ctx;
|
||||
struct ti_csi2rx_dev *csi = ctx->csi;
|
||||
struct ti_csi2rx_dma *dma = &ctx->dma;
|
||||
unsigned long flags;
|
||||
|
||||
@@ -684,18 +705,7 @@ static void ti_csi2rx_dma_callback(void *param)
|
||||
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
|
||||
list_del(&buf->list);
|
||||
|
||||
/* If there are more buffers to process then start their transfer. */
|
||||
while (!list_empty(&dma->queue)) {
|
||||
buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list);
|
||||
|
||||
if (ti_csi2rx_start_dma(ctx, buf)) {
|
||||
dev_err(csi->dev, "Failed to queue the next buffer for DMA\n");
|
||||
list_del(&buf->list);
|
||||
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
|
||||
} else {
|
||||
list_move_tail(&buf->list, &dma->submitted);
|
||||
}
|
||||
}
|
||||
ti_csi2rx_dma_submit_pending(ctx);
|
||||
|
||||
if (list_empty(&dma->submitted))
|
||||
dma->state = TI_CSI2RX_DMA_IDLE;
|
||||
@@ -1135,7 +1145,6 @@ static int ti_csi2rx_sd_enable_streams(struct v4l2_subdev *sd,
|
||||
struct ti_csi2rx_ctx *ctx = &csi->ctx[pad - TI_CSI2RX_PAD_FIRST_SOURCE];
|
||||
struct ti_csi2rx_dma *dma = &ctx->dma;
|
||||
struct media_pad *remote_pad;
|
||||
struct ti_csi2rx_buffer *buf;
|
||||
unsigned long flags;
|
||||
u64 sink_streams;
|
||||
int ret = 0;
|
||||
@@ -1160,16 +1169,13 @@ static int ti_csi2rx_sd_enable_streams(struct v4l2_subdev *sd,
|
||||
ctx->sequence = 0;
|
||||
|
||||
spin_lock_irqsave(&dma->lock, flags);
|
||||
buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list);
|
||||
|
||||
ret = ti_csi2rx_start_dma(ctx, buf);
|
||||
ret = ti_csi2rx_dma_submit_pending(ctx);
|
||||
if (ret) {
|
||||
dev_err(csi->dev, "Failed to start DMA: %d\n", ret);
|
||||
spin_unlock_irqrestore(&dma->lock, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
list_move_tail(&buf->list, &dma->submitted);
|
||||
dma->state = TI_CSI2RX_DMA_ACTIVE;
|
||||
spin_unlock_irqrestore(&dma->lock, flags);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user