aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/atmel-isi.c
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2011-08-29 07:51:49 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-09-06 14:07:20 -0400
commitbd323e28bd82dfd4b72c50ddc4d5fc24e3678b99 (patch)
tree189921e2d10c732f8e439eb38a54f481ea4b05cf /drivers/media/video/atmel-isi.c
parent8607c42540d0aa61ab562506681d34c245b91fae (diff)
[media] media: vb2: change queue initialization order
This patch changes the order of operations during stream on call. Now the buffers are first queued to the driver and then the start_streaming method is called. This resolves the most common case when the driver needs to know buffer addresses to enable dma engine and start streaming. Additional parameter to start_streaming method have been added to simplify drivers code. The driver are now obliged to check if the number of queued buffers is high enough to enable hardware streaming. If not - it can return an error. In such case all the buffers that have been pre-queued are invalidated. This patch also updates all videobuf2 clients to work properly with the changed order of operations. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> CC: Pawel Osciak <pawel@osciak.com> CC: Guennadi Liakhovetski <g.liakhovetski@gmx.de> CC: Hans Verkuil <hverkuil@xs4all.nl> CC: Tomasz Stanislawski <t.stanislaws@samsung.com> CC: Sylwester Nawrocki <s.nawrocki@samsung.com> CC: Kamil Debski <k.debski@samsung.com> CC: Jonathan Corbet <corbet@lwn.net> CC: Josh Wu <josh.wu@atmel.com> CC: Hans de Goede <hdegoede@redhat.com> CC: Paul Mundt <lethal@linux-sh.org> Tested-by: Josh Wu <josh.wu@atmel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/atmel-isi.c')
-rw-r--r--drivers/media/video/atmel-isi.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c
index 7e1d7896fc6e..774715d2f84f 100644
--- a/drivers/media/video/atmel-isi.c
+++ b/drivers/media/video/atmel-isi.c
@@ -404,12 +404,13 @@ static void buffer_queue(struct vb2_buffer *vb)
404 404
405 if (isi->active == NULL) { 405 if (isi->active == NULL) {
406 isi->active = buf; 406 isi->active = buf;
407 start_dma(isi, buf); 407 if (vb2_is_streaming(vb->vb2_queue))
408 start_dma(isi, buf);
408 } 409 }
409 spin_unlock_irqrestore(&isi->lock, flags); 410 spin_unlock_irqrestore(&isi->lock, flags);
410} 411}
411 412
412static int start_streaming(struct vb2_queue *vq) 413static int start_streaming(struct vb2_queue *vq, unsigned int count)
413{ 414{
414 struct soc_camera_device *icd = soc_camera_from_vb2q(vq); 415 struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
415 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 416 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
@@ -431,17 +432,26 @@ static int start_streaming(struct vb2_queue *vq)
431 ret = wait_event_interruptible(isi->vsync_wq, 432 ret = wait_event_interruptible(isi->vsync_wq,
432 isi->state != ISI_STATE_IDLE); 433 isi->state != ISI_STATE_IDLE);
433 if (ret) 434 if (ret)
434 return ret; 435 goto err;
435 436
436 if (isi->state != ISI_STATE_READY) 437 if (isi->state != ISI_STATE_READY) {
437 return -EIO; 438 ret = -EIO;
439 goto err;
440 }
438 441
439 spin_lock_irq(&isi->lock); 442 spin_lock_irq(&isi->lock);
440 isi->state = ISI_STATE_WAIT_SOF; 443 isi->state = ISI_STATE_WAIT_SOF;
441 isi_writel(isi, ISI_INTDIS, ISI_SR_VSYNC); 444 isi_writel(isi, ISI_INTDIS, ISI_SR_VSYNC);
445 if (count)
446 start_dma(isi, isi->active);
442 spin_unlock_irq(&isi->lock); 447 spin_unlock_irq(&isi->lock);
443 448
444 return 0; 449 return 0;
450err:
451 isi->active = NULL;
452 isi->sequence = 0;
453 INIT_LIST_HEAD(&isi->video_buffer_list);
454 return ret;
445} 455}
446 456
447/* abort streaming and wait for last buffer */ 457/* abort streaming and wait for last buffer */