summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2014-03-11[media] v4l2-compat-ioctl32: fix wrong VIDIOC_SUBDEV_G/S_EDID32 supportHans Verkuil
The wrong ioctl numbers were used due to a copy-and-paste error. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: stable@vger.kernel.org # for v3.7 and up Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] lm3646: add new dual LED Flash driverDaniel Jeong
This patch adds the driver for the LM3646, dual LED Flash driver. The LM3646 has two 1.5A sync. boost converter with dual white current source. It is controlled via an I2C compatible interface. Each flash brightness, torch brightness and enable/disable can be controlled. Under voltage, input voltage monitor and thermal threshhold Faults are added. Please refer the datasheet http://www.ti.com/lit/ds/snvs962/snvs962.pdf Signed-off-by: Daniel Jeong <gshark.jeong@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] v4l2-controls.h: Add addtional Flash fault bitsDaniel Jeong
Three Flash fault are added. V4L2_FLASH_FAULT_UNDER_VOLTAGE for the case low voltage below the min. limit. V4L2_FLASH_FAULT_INPUT_VOLTAGE for the case falling input voltage and chip adjust flash current not occur under voltage event. V4L2_FLASH_FAULT_LED_OVER_TEMPERATURE for the case the temperature exceed the maximun limit Signed-off-by: Daniel Jeong <gshark.jeong@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] controls.xml: Document addtional Flash fault bitsDaniel Jeong
Descriptions for flash faults V4L2_FLASH_FAULT_UNDER_VOLTAGE, V4L2_FLASH_FAULT_INPUT_VOLTAGE, and V4L2_FLASH_FAULT_LED_OVER_TEMPERATURE. Removed spaces before tabs. Signed-off-by: Daniel Jeong <gshark.jeong@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] lm3560: prevent memory leak in case of pdata absenceAndy Shevchenko
If we have no pdata defined and driver fails to register we leak memory. Converting to devm_kzalloc prevents this to happen. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] lm3560: keep style for the commentsAndy Shevchenko
Let's keep the style for all comments in the code, namely using small letters whenever it's possible. There is no functional change. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] lm3560: remove FSF address from the licenseAndy Shevchenko
There is no need to keep the FSF address inside each file. Moreover, it might change in future which will make this one obsolete. There is no functional change. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] v4l: of: Support empty port nodesLaurent Pinchart
Empty port nodes are allowed but currently unsupported as the v4l2_of_get_next_endpoint() function assumes that all port nodes have at least an endpoint. Fix this. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] MAINTAINERS: remove myself as a maintainer of VEU and VOU V4L2 driversGuennadi Liakhovetski
Since I'm currently unable to dedicate sufficient time to the maintainership of these two drivers update their status to "orphan" until new maintainers appear. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] media: soc_camera: rcar_vin: Add support for 10-bit YUV camerasPhil Edworthy
Add support for MBUS YUV10 BT656 and BT601 formats at rcar driver. Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] s2255drv: memory leak fixsensoray-dev
Fixes memory leak introduced by commit 47d8c881c304642a68d398b87d9e8846e643c81a. Signed-off-by: Dean Anderson <linux-dev@sensoray.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] tvp5150: Make debug module parameter visible in sysfsPhilipp Zabel
Set permissions on the debug module parameter to make it appear in sysfs. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] tvp5150: Fix type mismatch warning in clamp macroPhilipp Zabel
This patch fixes the following warning: drivers/media/i2c/tvp5150.c: In function '__tvp5150_try_crop': include/linux/kernel.h:762:17: warning: comparison of distinct pointer types lacks a cast [enabled by default] (void) (&__val == &__min); \ ^ drivers/media/i2c/tvp5150.c:886:16: note: in expansion of macro 'clamp' rect->width = clamp(rect->width, ^ include/linux/kernel.h:763:17: warning: comparison of distinct pointer types lacks a cast [enabled by default] (void) (&__val == &__max); \ ^ drivers/media/i2c/tvp5150.c:886:16: note: in expansion of macro 'clamp' rect->width = clamp(rect->width, ^ include/linux/kernel.h:762:17: warning: comparison of distinct pointer types lacks a cast [enabled by default] (void) (&__val == &__min); \ ^ drivers/media/i2c/tvp5150.c:904:17: note: in expansion of macro 'clamp' rect->height = clamp(rect->height, ^ include/linux/kernel.h:763:17: warning: comparison of distinct pointer types lacks a cast [enabled by default] (void) (&__val == &__max); \ ^ drivers/media/i2c/tvp5150.c:904:17: note: in expansion of macro 'clamp' rect->height = clamp(rect->height, ^ Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] em28xx-cards: remove a wrong indent levelDan Carpenter
This code is correct but the indenting is wrong and triggers a static checker warning "add curly braces?". Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] staging/dt3155v4l: use PCI_VENDOR_ID_INTELJon Mason
Use PCI_VENDOR_ID_INTEL instead of creating its own vendor ID #define. Signed-off-by: Jon Mason <jdmason@kudzu.us> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] media DocBook: fix NV16M descriptionHans Verkuil
The NV16M description contained some copy-and-paste text from NV12M, suggesting that this format is a 4:2:0 format when it really is a 4:2:2 format. Fixed the text. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] arv: fix sleep_on raceArnd Bergmann
interruptible_sleep_on is racy and going away. In the arv driver that race has probably never caused problems since it would require a whole video frame to be captured before the read function has a chance to go to sleep, but using wait_event_interruptible lets us kill off the old interface. In order to do this, we have to slightly adapt the meaning of the ar->start_capture field to distinguish between not having started a frame and having completed it. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] v4l: VIDEO_SH_VOU should depend on HAS_DMAGeert Uytterhoeven
If NO_DMA=y: warning: (VIDEO_DM6446_CCDC && VIDEO_DM355_CCDC && VIDEO_DM365_ISIF && VIDEO_OMAP2_VOUT && VIDEO_SH_VOU && VIDEO_VIU && VIDEO_TIMBERDALE && VIDEO_MX1 && VIDEO_OMAP1) selects VIDEOBUF_DMA_CONTIG which has unmet direct dependencies (MEDIA_SUPPORT && HAS_DMA) drivers/built-in.o: In function `videobuf_vm_close': videobuf-dma-contig.c:(.text+0x407aa0): undefined reference to `videobuf_queue_cancel' drivers/built-in.o: In function `__videobuf_dc_alloc': videobuf-dma-contig.c:(.text+0x407ba2): undefined reference to `dma_alloc_coherent' drivers/built-in.o: In function `__videobuf_mmap_mapper': videobuf-dma-contig.c:(.text+0x407d44): undefined reference to `dma_free_coherent' drivers/built-in.o: In function `free_buffer': sh_vou.c:(.text+0x41f73a): undefined reference to `videobuf_waiton' drivers/built-in.o: In function `sh_vou_poll': sh_vou.c:(.text+0x41f884): undefined reference to `videobuf_poll_stream' drivers/built-in.o: In function `sh_vou_buf_prepare': sh_vou.c:(.text+0x41fdf6): undefined reference to `videobuf_iolock' drivers/built-in.o: In function `sh_vou_reqbufs': sh_vou.c:(.text+0x4203b0): undefined reference to `videobuf_reqbufs' drivers/built-in.o: In function `sh_vou_querybuf': sh_vou.c:(.text+0x42040a): undefined reference to `videobuf_querybuf' drivers/built-in.o: In function `sh_vou_qbuf': sh_vou.c:(.text+0x42045e): undefined reference to `videobuf_qbuf' drivers/built-in.o: In function `sh_vou_dqbuf': sh_vou.c:(.text+0x4204c2): undefined reference to `videobuf_dqbuf' drivers/built-in.o: In function `sh_vou_streamon': sh_vou.c:(.text+0x420572): undefined reference to `videobuf_streamon' drivers/built-in.o: In function `sh_vou_streamoff': sh_vou.c:(.text+0x4205d2): undefined reference to `videobuf_streamoff' drivers/built-in.o: In function `sh_vou_mmap': sh_vou.c:(.text+0x420c46): undefined reference to `videobuf_mmap_mapper' VIDEO_SH_VOU selects VIDEOBUF_DMA_CONTIG, which bypasses its dependency on HAS_DMA. Make VIDEO_SH_VOU depend on HAS_DMA to fix this. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] v4l2-ctrls: replace BUG_ON by WARN_ONHans Verkuil
BUG_ON is unnecessarily strict. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drivers/media/usb/usbtv/usbtv-core.c:119:22: sparse: symbol ↵Fengguang Wu
'usbtv_id_table' was not declared. Should it be static? tree: git://linuxtv.org/media_tree.git master head: a3550ea665acd1922df8275379028c1634675629 commit: a3550ea665acd1922df8275379028c1634675629 [499/499] [media] usbtv: split core and video implementation reproduce: make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by >>) >> drivers/media/usb/usbtv/usbtv-core.c:119:22: sparse: symbol 'usbtv_id_table' was not declared. Should it be static? >> drivers/media/usb/usbtv/usbtv-core.c:129:19: sparse: symbol 'usbtv_usb_driver' was not declared. Should it be static? Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11drx-j: Fix post-BER calculus on QAM modulationMauro Carvalho Chehab
There are two troubles there: 1) the bit error measure were not accumulating; 2) it was missing the bit count. Fix them. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11drx-j: use ber_count varMauro Carvalho Chehab
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function 'ctrl_get_qam_sig_quality': drivers/media/dvb-frontends/drx39xyj/drxj.c:9468:6: warning: variable 'ber_cnt' set but not used [-Wunused-but-set-variable] u32 ber_cnt = 0; /* BER count */ ^ By reading the comment, it is said that BER should be calculated as: qam_pre_rs_ber = frac_times1e6( ber_cnt, rs_bit_cnt ); Also, it makes sense to take the mantissa into account, so fix the code to do what's commented. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: enable DVBv5 statsMauro Carvalho Chehab
Now that everything is set, let's enable DVBv5 stats, for applications that support it. DVBv3 apps will still work. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: Fix detection of no signalMauro Carvalho Chehab
When the signal is 7, it means that no signal was received. Value experimentally measured. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: properly handle bit counts on statsMauro Carvalho Chehab
Instead of just assuming that the min resolution is 1E-6, pass both bit error and bit counts for userspace to calculate BER. The same applies for PER, for 8VSB. It is not clear how to get the packet count for QAM. So, for now, don't expose PER for QAM. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: Prepare to use DVBv5 statsMauro Carvalho Chehab
Convert the stats internally to use DVBv5. For now, it will keep showing everything via DVBv3 API only, as the .len value were not initialized. That allows testing if the new stats code didn't break anything. A latter patch will add the final bits for the DVBv5 stats to fully work. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: re-add get_sig_strength()Mauro Carvalho Chehab
We'll need to use this function. Restore it from the git history. This function will be used on the next patch. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: Don't use "state" for DVB lock stateMauro Carvalho Chehab
State is already used on other places for the state struct. Don't use it here, to avoid troubles with latter patches. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: get rid of some unused varsMauro Carvalho Chehab
As reported when compiled with W=1: drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘ctrl_set_channel’: drivers/media/dvb-frontends/drx39xyj/drxj.c:10340:26: warning: variable ‘common_attr’ set but not used [-Wunused-but-set-variable] struct drx_common_attr *common_attr = NULL; ^ drivers/media/dvb-frontends/drx39xyj/drxj.c:10336:6: warning: variable ‘intermediate_freq’ set but not used [-Wunused-but-set-variable] s32 intermediate_freq = 0; Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: propagate returned error from request_firmware()Mauro Carvalho Chehab
Fix a smatch warning: drivers/media/dvb-frontends/drx39xyj/drxj.c:11711 drx_ctrl_u_code() info: why not propagate 'rc' from request_firmware() instead of (-2)? Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: Fix usage of drxj_close()Mauro Carvalho Chehab
This function is currently not used. However, it was meant to be called at device release. So, add it there. While here, remove the bad check, as reported by Dan, as smatch warning: drivers/media/dvb-frontends/drx39xyj/drxj.c:20041 drxj_close() warn: variable dereferenced before check 'demod' (see line 20036) Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: remove external symbolsMauro Carvalho Chehab
This driver doesn't export any external symbol, except for the attach() method. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: get rid of dead codeMauro Carvalho Chehab
There are large chunks of code at drx-j that aren't used. Most of them are due to analog TV support. Well, just enabling them won't make analog support work, as devices with DRX and analog support requires an extra chip (avf4910). We don't have drivers for it, nor the current device that uses this frontend has support for analog TV. So, let's just get rid of this code. If latter needed, this patch can easily be reverted from git history. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: don't use mc_info before checking if its not NULLMauro Carvalho Chehab
smatch warning: drivers/media/dvb-frontends/drx39xyj/drxj.c:20803 drx_ctrl_u_code() warn: variable dereferenced before check 'mc_info' (see line 20800) Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx39xxj.h: Fix undefined reference to attach functionMauro Carvalho Chehab
As reported by the kbuild test robot <fengguang.wu@intel.com>: drivers/built-in.o: In function `em28xx_dvb_init': em28xx-dvb.c:(.text+0x876f2c): undefined reference to `drx39xxj_attach' That happens when CONFIG_VIDEO_EM28XX_DVB is selected, and neither CONFIG_MEDIA_SUBDRV_AUTOSELECT or DVB_DRX39XYJ is selected. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: Fix dubious usage of "&" instead of "&&"Mauro Carvalho Chehab
Fixes the following warnings: drivers/media/dvb-frontends/drx39xyj/drxj.c:16764:68: warning: dubious: x & !y drivers/media/dvb-frontends/drx39xyj/drxj.c:16778:68: warning: dubious: x & !y drivers/media/dvb-frontends/drx39xyj/drxj.c:16797:68: warning: dubious: x & !y Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: Don't use 0 as NULLMauro Carvalho Chehab
Fixes the following warnings: drivers/media/dvb-frontends/drx39xyj/drxj.c:1679:65: warning: Using plain integer as NULL pointer drivers/media/dvb-frontends/drx39xyj/drxj.c:1679:71: warning: Using plain integer as NULL pointer drivers/media/dvb-frontends/drx39xyj/drxj.c:1681:52: warning: Using plain integer as NULL pointer drivers/media/dvb-frontends/drx39xyj/drxj.c:1681:58: warning: Using plain integer as NULL pointer Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-d: add missing braces in drxd_hard.c:DRXD_initDave Jones
No functional changes, but removes a duplicate check, if !state->type_A. Signed-off-by: Dave Jones <davej@fedoraproject.org> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] drx-j: drxj_default_aud_data_g can be staticFengguang Wu
Fix sparse warning: drivers/media/dvb-frontends/drx39xyj/drxj.c:1039:16: sparse: symbol 'drxj_default_aud_data_g' was not declared. Should it be static? Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] em28xx-dvb: remove one level of identation at fini callbackMauro Carvalho Chehab
Simplify the logic a little by removing one level of identation. Also, it only makes sense to print something if the .fini callback is actually doing something. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] em28xx: Only deallocate struct em28xx after finishing all extensionsMauro Carvalho Chehab
We can't free struct em28xx while one of the extensions is still using it. So, add a kref() to control it, freeing it only after the extensions fini calls. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] em28xx: only enable PCTV 80e led when streamingMauro Carvalho Chehab
Instead of keeping the led always on, use it to indicate when DVB is streaming. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] vivi: fix ENUM_FRAMEINTERVALS implementationHans Verkuil
This function never checked if width and height are correct. Add such a check so the v4l2-compliance tool returns OK again for vivi. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] vivi: correctly cleanup after a start_streaming failureHans Verkuil
If start_streaming fails then any queued buffers must be given back to the vb2 core. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] vb2: call buf_finish after the state checkHans Verkuil
Don't call buf_finish unless we know that the buffer is in a valid state. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] vb2: fix streamoff handling if streamon wasn't calledHans Verkuil
If you request buffers, then queue buffers and then call STREAMOFF those buffers are not returned to their dequeued state because streamoff will just return if q->streaming was 0. This means that afterwards you can never QBUF that same buffer again unless you do STREAMON, REQBUFS or close the filehandle first. It is clear that if you do STREAMOFF even if no STREAMON was called before, you still want to have all buffers returned to their proper dequeued state. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] vb2: replace BUG by WARN_ONHans Verkuil
No need to oops for this, WARN_ON is good enough. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] vb2: properly clean up PREPARED and QUEUED buffersHans Verkuil
If __reqbufs was called then existing buffers are freed. However, if that happens without ever having started STREAMON, but if buffers have been queued, then the buf_finish op is never called. Add a call to __vb2_queue_cancel in __reqbufs so that these buffers are cleaned up there as well. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11[media] vb2: only call start_streaming if sufficient buffers are queuedHans Verkuil
In commit 02f142ecd24aaf891324ffba8527284c1731b561 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[media] vb2: don't init the list if there are still buffersHans Verkuil
__vb2_queue_free() would init the queued_list at all times, even if q->num_buffers > 0. This should only happen if num_buffers == 0. This situation can happen if a CREATE_BUFFERS call couldn't allocate enough buffers and had to free those it did manage to allocate before returning an error. While we're at it: __vb2_queue_alloc() returns the number of buffers allocated, not an error code. So stick the result in allocated_buffers instead of ret as that's very confusing. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>