linux/drivers/media/platform
Hans Verkuil b3379c6201 [media] vb2: only call start_streaming if sufficient buffers are queued
In commit 02f142ecd2 support was added to
start_streaming to return -ENOBUFS if insufficient buffers were queued
for the DMA engine to start. The vb2 core would attempt calling
start_streaming again if another buffer would be queued up.

Later analysis uncovered problems with the queue management if start_streaming
would return an error: the buffers are enqueued to the driver before the
start_streaming op is called, so after an error they are never returned to
the vb2 core. The solution for this is to let the driver return them to
the vb2 core in case of an error while starting the DMA engine. However,
in the case of -ENOBUFS that would be weird: it is not a real error, it
just says that more buffers are needed. Requiring start_streaming to give
them back only to have them requeued again the next time the application
calls QBUF is inefficient.

This patch changes this mechanism: it adds a 'min_buffers_needed' field
to vb2_queue that drivers can set with the minimum number of buffers
required to start the DMA engine. The start_streaming op is only called
if enough buffers are queued. The -ENOBUFS handling has been dropped in
favor of this new method.

Drivers are expected to return buffers back to vb2 core with state QUEUED
if start_streaming would return an error. The vb2 core checks for this
and produces a warning if that didn't happen and it will forcefully
reclaim such buffers to ensure that the internal vb2 core state remains
consistent and all buffer-related resources have been correctly freed
and all op calls have been balanced.

__reqbufs() has been updated to check that at least min_buffers_needed
buffers could be allocated. If fewer buffers were allocated then __reqbufs
will free what was allocated and return -ENOMEM. Based on a suggestion from
Pawel Osciak.

__create_bufs() doesn't do that check, since the use of __create_bufs
assumes some advance scenario where the user might want more control.
Instead streamon will check if enough buffers were allocated to prevent
streaming with fewer than the minimum required number of buffers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11 06:56:41 -03:00
..
blackfin [media] v4l: Rename vb2_queue.timestamp_type as timestamp_flags 2014-03-05 16:34:14 -03:00
davinci [media] vb2: only call start_streaming if sufficient buffers are queued 2014-03-11 06:56:41 -03:00
exynos4-is Linux 3.14-rc5 2014-03-11 06:55:49 -03:00
exynos-gsc [media] v4l: Copy timestamp source flags to destination on m2m devices 2014-03-05 16:47:15 -03:00
marvell-ccic [media] vb2: change result code of buf_finish to void 2014-03-11 06:56:38 -03:00
omap [media] omap_vout: avoid sleep_on race 2014-02-28 14:31:02 -03:00
omap3isp [media] omap3isp: Fix kerneldoc for _module_sync_is_stopping and isp_isr() 2014-03-05 17:02:07 -03:00
s3c-camif [media] v4l: Rename vb2_queue.timestamp_type as timestamp_flags 2014-03-05 16:34:14 -03:00
s5p-g2d [media] v4l: Copy timestamp source flags to destination on m2m devices 2014-03-05 16:47:15 -03:00
s5p-jpeg Linux 3.14-rc5 2014-03-11 06:55:49 -03:00
s5p-mfc [media] v4l: Copy timestamp source flags to destination on m2m devices 2014-03-05 16:47:15 -03:00
s5p-tv [media] vb2: only call start_streaming if sufficient buffers are queued 2014-03-11 06:56:41 -03:00
soc_camera [media] v4l: Rename vb2_queue.timestamp_type as timestamp_flags 2014-03-05 16:34:14 -03:00
ti-vpe [media] v4l: Copy timestamp source flags to destination on m2m devices 2014-03-05 16:47:15 -03:00
vsp1 [media] v4l: Rename vb2_queue.timestamp_type as timestamp_flags 2014-03-05 16:34:14 -03:00
arv.c
coda.c [media] v4l: Copy timestamp source flags to destination on m2m devices 2014-03-05 16:47:15 -03:00
coda.h [media] coda: add CODA7541 decoding support 2013-07-31 15:56:44 -03:00
fsl-viu.c fsl-viu: adjust for OF based clock lookup 2014-01-12 18:53:05 +01:00
indycam.c [media] indycam: remove g_chip_ident op 2013-06-17 08:49:47 -03:00
indycam.h
Kconfig [media] omap24xx/tcm825x: move to staging for future removal 2013-12-20 13:45:22 -02:00
m2m-deinterlace.c [media] v4l: Copy timestamp source flags to destination on m2m devices 2014-03-05 16:47:15 -03:00
Makefile [media] omap24xx/tcm825x: move to staging for future removal 2013-12-20 13:45:22 -02:00
mem2mem_testdev.c [media] v4l: Copy timestamp source flags to destination on m2m devices 2014-03-05 16:47:15 -03:00
mx2_emmaprp.c [media] v4l: Copy timestamp source flags to destination on m2m devices 2014-03-05 16:47:15 -03:00
sh_veu.c sh_veu: Replace PTR_RET with PTR_ERR_OR_ZERO 2013-07-16 16:06:01 +09:30
sh_vou.c [media] sh_vou: comment unused vars 2014-01-13 11:30:26 -02:00
timblogiw.c Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma 2013-11-20 13:20:24 -08:00
via-camera.c [media] via-camera: replace current_norm by g_std 2013-06-17 09:33:49 -03:00
via-camera.h
vino.c [media] v4l2: pass std by value to the write-only s_std ioctl 2013-03-24 06:47:00 -03:00
vino.h
vivi.c [media] v4l: Rename vb2_queue.timestamp_type as timestamp_flags 2014-03-05 16:34:14 -03:00