Skip to content

Commit 1690d86

Browse files
Alex GershgorinMauro Carvalho Chehab
authored andcommitted
[media] media: mx3_camera: buf_init() add buffer state check
This patch checks the state of the buffer when calling .buf_init() method. This is needed for the USERPTR buffer type, because in that case .buf_init() is called every time a buffer is queued, and not only once during the preparation stage, like in the MMAP case. Without this check buffers get initialised repeatedly, which also leads to the allocation of new DMA descriptors, of which there is only a final relatively small number available. Both MMAP and USERPTR methods were successfully tested. Signed-off-by: Alex Gershgorin <[email protected]> [[email protected]: remove mx3_camera_buffer::state completely] Signed-off-by: Guennadi Liakhovetski <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent be0c44f commit 1690d86

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

drivers/media/video/mx3_camera.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,9 @@
6161

6262
#define MAX_VIDEO_MEM 16
6363

64-
enum csi_buffer_state {
65-
CSI_BUF_NEEDS_INIT,
66-
CSI_BUF_PREPARED,
67-
};
68-
6964
struct mx3_camera_buffer {
7065
/* common v4l buffer stuff -- must be first */
7166
struct vb2_buffer vb;
72-
enum csi_buffer_state state;
7367
struct list_head queue;
7468

7569
/* One descriptot per scatterlist (per frame) */
@@ -285,7 +279,7 @@ static void mx3_videobuf_queue(struct vb2_buffer *vb)
285279
goto error;
286280
}
287281

288-
if (buf->state == CSI_BUF_NEEDS_INIT) {
282+
if (!buf->txd) {
289283
sg_dma_address(sg) = vb2_dma_contig_plane_dma_addr(vb, 0);
290284
sg_dma_len(sg) = new_size;
291285

@@ -298,7 +292,6 @@ static void mx3_videobuf_queue(struct vb2_buffer *vb)
298292
txd->callback_param = txd;
299293
txd->callback = mx3_cam_dma_done;
300294

301-
buf->state = CSI_BUF_PREPARED;
302295
buf->txd = txd;
303296
} else {
304297
txd = buf->txd;
@@ -385,7 +378,6 @@ static void mx3_videobuf_release(struct vb2_buffer *vb)
385378

386379
/* Doesn't hurt also if the list is empty */
387380
list_del_init(&buf->queue);
388-
buf->state = CSI_BUF_NEEDS_INIT;
389381

390382
if (txd) {
391383
buf->txd = NULL;
@@ -405,13 +397,13 @@ static int mx3_videobuf_init(struct vb2_buffer *vb)
405397
struct mx3_camera_dev *mx3_cam = ici->priv;
406398
struct mx3_camera_buffer *buf = to_mx3_vb(vb);
407399

408-
/* This is for locking debugging only */
409-
INIT_LIST_HEAD(&buf->queue);
410-
sg_init_table(&buf->sg, 1);
400+
if (!buf->txd) {
401+
/* This is for locking debugging only */
402+
INIT_LIST_HEAD(&buf->queue);
403+
sg_init_table(&buf->sg, 1);
411404

412-
buf->state = CSI_BUF_NEEDS_INIT;
413-
414-
mx3_cam->buf_total += vb2_plane_size(vb, 0);
405+
mx3_cam->buf_total += vb2_plane_size(vb, 0);
406+
}
415407

416408
return 0;
417409
}

0 commit comments

Comments
 (0)