summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/rcar-vin/rcar-dma.c
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>2020-10-16 01:14:05 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-11-16 10:31:10 +0100
commitb83a18cca8924a11eb3317354de30a5a4220aec9 (patch)
tree03528a08348fc768054703a54f878c10d37081ba /drivers/media/platform/rcar-vin/rcar-dma.c
parent90ed57851eef0d60320cf2c24536de9ab3183e0f (diff)
media: rcar-vin: Remove handling of user-space buffers when stopping
When returning buffers to user-space it's no longer needed to examine the buffers given to hardware as recent changes guarantees the only buffer present in the hardware registers when the driver is not in the running state is the scratch buffer. Remove the special case and rename the function to better describe it now only deals with buffers queued to the driver but not yet recorded in the hardware registers. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/platform/rcar-vin/rcar-dma.c')
-rw-r--r--drivers/media/platform/rcar-vin/rcar-dma.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index ca90bde8d29f..680160f9f851 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -1051,27 +1051,10 @@ done:
}
/* Need to hold qlock before calling */
-static void return_all_buffers(struct rvin_dev *vin,
- enum vb2_buffer_state state)
+static void return_unused_buffers(struct rvin_dev *vin,
+ enum vb2_buffer_state state)
{
struct rvin_buffer *buf, *node;
- struct vb2_v4l2_buffer *freed[HW_BUFFER_NUM];
- unsigned int i, n;
-
- for (i = 0; i < HW_BUFFER_NUM; i++) {
- freed[i] = vin->buf_hw[i].buffer;
- vin->buf_hw[i].buffer = NULL;
-
- for (n = 0; n < i; n++) {
- if (freed[i] == freed[n]) {
- freed[i] = NULL;
- break;
- }
- }
-
- if (freed[i])
- vb2_buffer_done(&freed[i]->vb2_buf, state);
- }
list_for_each_entry_safe(buf, node, &vin->buf_list, list) {
vb2_buffer_done(&buf->vb.vb2_buf, state);
@@ -1271,7 +1254,7 @@ static int rvin_start_streaming(struct vb2_queue *vq, unsigned int count)
&vin->scratch_phys, GFP_KERNEL);
if (!vin->scratch) {
spin_lock_irqsave(&vin->qlock, flags);
- return_all_buffers(vin, VB2_BUF_STATE_QUEUED);
+ return_unused_buffers(vin, VB2_BUF_STATE_QUEUED);
spin_unlock_irqrestore(&vin->qlock, flags);
vin_err(vin, "Failed to allocate scratch buffer\n");
return -ENOMEM;
@@ -1280,7 +1263,7 @@ static int rvin_start_streaming(struct vb2_queue *vq, unsigned int count)
ret = rvin_set_stream(vin, 1);
if (ret) {
spin_lock_irqsave(&vin->qlock, flags);
- return_all_buffers(vin, VB2_BUF_STATE_QUEUED);
+ return_unused_buffers(vin, VB2_BUF_STATE_QUEUED);
spin_unlock_irqrestore(&vin->qlock, flags);
goto out;
}
@@ -1291,7 +1274,7 @@ static int rvin_start_streaming(struct vb2_queue *vq, unsigned int count)
ret = rvin_capture_start(vin);
if (ret) {
- return_all_buffers(vin, VB2_BUF_STATE_QUEUED);
+ return_unused_buffers(vin, VB2_BUF_STATE_QUEUED);
rvin_set_stream(vin, 0);
}
@@ -1358,8 +1341,8 @@ static void rvin_stop_streaming(struct vb2_queue *vq)
vin->state = STOPPED;
}
- /* Release all active buffers */
- return_all_buffers(vin, VB2_BUF_STATE_ERROR);
+ /* Return all unused buffers. */
+ return_unused_buffers(vin, VB2_BUF_STATE_ERROR);
spin_unlock_irqrestore(&vin->qlock, flags);