aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mx3_camera.c
diff options
context:
space:
mode:
authorAlex Gershgorin <alexg@meprolight.com>2012-08-01 04:05:10 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-15 18:23:10 -0400
commit1690d86aa33fa14c0ae4ac97e59d806eeddccd2c (patch)
treec78814611d12950ce5acfd0be9d0f3f8932b4ead /drivers/media/video/mx3_camera.c
parentbe0c44fb480fe43fe8794ec4bff0b0e7e0b50c72 (diff)
[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 <alexg@meprolight.com> [g.liakhovetski@gmx.de: remove mx3_camera_buffer::state completely] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mx3_camera.c')
-rw-r--r--drivers/media/video/mx3_camera.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c
index f13643d3135..af2297dd49c 100644
--- a/drivers/media/video/mx3_camera.c
+++ b/drivers/media/video/mx3_camera.c
@@ -61,15 +61,9 @@
61 61
62#define MAX_VIDEO_MEM 16 62#define MAX_VIDEO_MEM 16
63 63
64enum csi_buffer_state {
65 CSI_BUF_NEEDS_INIT,
66 CSI_BUF_PREPARED,
67};
68
69struct mx3_camera_buffer { 64struct mx3_camera_buffer {
70 /* common v4l buffer stuff -- must be first */ 65 /* common v4l buffer stuff -- must be first */
71 struct vb2_buffer vb; 66 struct vb2_buffer vb;
72 enum csi_buffer_state state;
73 struct list_head queue; 67 struct list_head queue;
74 68
75 /* One descriptot per scatterlist (per frame) */ 69 /* One descriptot per scatterlist (per frame) */
@@ -285,7 +279,7 @@ static void mx3_videobuf_queue(struct vb2_buffer *vb)
285 goto error; 279 goto error;
286 } 280 }
287 281
288 if (buf->state == CSI_BUF_NEEDS_INIT) { 282 if (!buf->txd) {
289 sg_dma_address(sg) = vb2_dma_contig_plane_dma_addr(vb, 0); 283 sg_dma_address(sg) = vb2_dma_contig_plane_dma_addr(vb, 0);
290 sg_dma_len(sg) = new_size; 284 sg_dma_len(sg) = new_size;
291 285
@@ -298,7 +292,6 @@ static void mx3_videobuf_queue(struct vb2_buffer *vb)
298 txd->callback_param = txd; 292 txd->callback_param = txd;
299 txd->callback = mx3_cam_dma_done; 293 txd->callback = mx3_cam_dma_done;
300 294
301 buf->state = CSI_BUF_PREPARED;
302 buf->txd = txd; 295 buf->txd = txd;
303 } else { 296 } else {
304 txd = buf->txd; 297 txd = buf->txd;
@@ -385,7 +378,6 @@ static void mx3_videobuf_release(struct vb2_buffer *vb)
385 378
386 /* Doesn't hurt also if the list is empty */ 379 /* Doesn't hurt also if the list is empty */
387 list_del_init(&buf->queue); 380 list_del_init(&buf->queue);
388 buf->state = CSI_BUF_NEEDS_INIT;
389 381
390 if (txd) { 382 if (txd) {
391 buf->txd = NULL; 383 buf->txd = NULL;
@@ -405,13 +397,13 @@ static int mx3_videobuf_init(struct vb2_buffer *vb)
405 struct mx3_camera_dev *mx3_cam = ici->priv; 397 struct mx3_camera_dev *mx3_cam = ici->priv;
406 struct mx3_camera_buffer *buf = to_mx3_vb(vb); 398 struct mx3_camera_buffer *buf = to_mx3_vb(vb);
407 399
408 /* This is for locking debugging only */ 400 if (!buf->txd) {
409 INIT_LIST_HEAD(&buf->queue); 401 /* This is for locking debugging only */
410 sg_init_table(&buf->sg, 1); 402 INIT_LIST_HEAD(&buf->queue);
403 sg_init_table(&buf->sg, 1);
411 404
412 buf->state = CSI_BUF_NEEDS_INIT; 405 mx3_cam->buf_total += vb2_plane_size(vb, 0);
413 406 }
414 mx3_cam->buf_total += vb2_plane_size(vb, 0);
415 407
416 return 0; 408 return 0;
417} 409}