openwrt/staging/blogic.git
7 years agomedia: dvb-usb: Add memory free on error path in dw2102_probe()
Anton Vasilyev [Thu, 10 Aug 2017 15:27:44 +0000 (11:27 -0400)]
media: dvb-usb: Add memory free on error path in dw2102_probe()

If dw2102_probe() fails on dvb_usb_device_init(), then memleak occurs.

The patch adds deallocation to the error path.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Reviewed-by: Enrico Mioso <mrkiko.rs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: dvb-frontends/stv0910: change minsymrate to 100Ksyms/s
Daniel Scheller [Wed, 23 Aug 2017 16:10:02 +0000 (12:10 -0400)]
media: dvb-frontends/stv0910: change minsymrate to 100Ksyms/s

The demodulator supports symbol rates as low as 100Ksyms/s - the demod
setup in start() already handles such low symbol rates and reviewers
of stv0910 equipped cards even found and tested transponders with
SRs in that range. So, announce this in the fe_ops.

Cc: Ralph Metzler <rjkm@metzlerbros.de>
Cc: Richard Scobie <r.scobie@clear.net.nz>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: staging/cxd2099: Add module parameter for buffer mode
Daniel Scheller [Wed, 23 Aug 2017 16:10:01 +0000 (12:10 -0400)]
media: staging/cxd2099: Add module parameter for buffer mode

The buffer mode of the cxd2099 driver requires more work regarding error
handling and thus can cause issues in some cases, so disable it by default
and make that mode of operation controllable by users via a module
parameter (ie. 'modprobe cxd2099 buffermode=1' enables current behaviour).

The upstream codebase also has the buffer mode disabled by default, so
we should match this (but users still can test things out using the
modparm).

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Jasmin Jessich <jasmin@anw.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: ddbridge: fix sparse warnings
Daniel Scheller [Wed, 23 Aug 2017 16:10:00 +0000 (12:10 -0400)]
media: ddbridge: fix sparse warnings

Fix several

  drivers/media/pci/ddbridge/ddbridge-core.c: warning: symbol ... was not declared. Should it be static?
  drivers/media/pci/ddbridge/ddbridge-core.c: warning: Using plain integer as NULL pointer
  drivers/media/pci/ddbridge/ddbridge-io.h: warning: cast removes address space of expression
  drivers/media/pci/ddbridge/ddbridge-io.h: warning: incorrect type in argument 1 (different address spaces)

at multiple places.

Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: ddbridge: fix teardown/deregistration order in ddb_input_detach()
Daniel Scheller [Wed, 23 Aug 2017 16:09:59 +0000 (12:09 -0400)]
media: ddbridge: fix teardown/deregistration order in ddb_input_detach()

Brought to attention by Matthias Schwarzott <zzam@gentoo.org> by fixing
possible use-after-free faults in some demod drivers:

In ddb_input_detach(), the i2c_client is unregistered and removed before
dvb frontends are unregistered and detached. While no use-after-free issue
was observed so far, there is another issue with this:

dvb->attached keeps track of the state of the input/output registration,
and the i2c_client unregistration takes place only if everything was
successful (dvb->attached == 0x31). If for some reason an error occurred
during the frontend setup, that value stays at 0x20. In the following
error handling and cleanup, ddb_input_detach() will skip down to that
state, leaving the i2c_client registered, causing refcount issues.

Fix this by moving the i2c_client deregistration down to case 0x20.

Cc: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: dvb-frontends/stv0910: release lock on gate_ctrl() failure
Daniel Scheller [Wed, 23 Aug 2017 16:09:58 +0000 (12:09 -0400)]
media: dvb-frontends/stv0910: release lock on gate_ctrl() failure

Whenever write_reg() fails to open/close the demod's I2C gate, release the
lock to avoid deadlocking situations. If I2c gate open failed, there's no
need to hold a lock, and if close fails, the mutex_unlock() at the end of
the function is never reached, leaving the mutex_lock in locked state,
which in turn will cause potential for deadlocks. Thus, release the lock
on failure.

While we're touching gate_ctrl(), add some explanation about the need for
locking and the shared I2C bus/gate.

Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: cx231xx: fix use-after-free when unregistering the i2c_client for the dvb...
Matthias Schwarzott [Wed, 2 Aug 2017 16:46:00 +0000 (12:46 -0400)]
media: cx231xx: fix use-after-free when unregistering the i2c_client for the dvb demod

Calling i2c_unregister_device for a demod driver destroys the frontend object.
Later it is accessed by calling dvb_unregister_frontend and
dvb_frontend_detach.

In some cases this leads to a general protection fault with this
callstack:

  dvb_unregister_frontend+0x25/0x50 [dvb_core]
  dvb_fini+0xdb/0x160 [cx231xx_dvb]
  cx231xx_unregister_extension+0x3d/0xb0 [cx231xx]
  cx231xx_dvb_unregister+0x10/0x809 [cx231xx_dvb]
  SyS_delete_module+0x18a/0x240
  ? exit_to_usermode_loop+0x7b/0x80
  entry_SYSCALL_64_fastpath+0x17/0x98

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: cx23885: Fix use-after-free when unregistering the i2c_client for the dvb...
Matthias Schwarzott [Wed, 2 Aug 2017 16:45:59 +0000 (12:45 -0400)]
media: cx23885: Fix use-after-free when unregistering the i2c_client for the dvb demod

Unregistering the i2c_client of the demod driver destroys the frontend
object.
Calling vb2_dvb_unregister_bus later accesses the frontend (and with the
refcount_t) conversion the refcount_t code complains:

kernel: ------------[ cut here ]------------
kernel: WARNING: CPU: 0 PID: 7883 at lib/refcount.c:128 refcount_sub_and_test+0x70/0x80
kernel: refcount_t: underflow; use-after-free.
kernel: Modules linked in: bluetooth si2165(O) a8293(O) tda10071(O) tea5767(O) tuner(O) cx23885(O-) tda18271(O) videobuf2_dvb(O) videobuf2_dma_sg(O) m88ds3103(O) tveeprom(O) cx2341x(O) v4l2_common(O) dvb_core(O) rc_core(O) videobuf2_memops(O) videobuf2_v4l2(O) ums_realtek videobuf2_core(O) uas videodev(O) media(O) rtl8192cu i2c_mux usb_storage rtl_usb rtl8192c_common rtlwifi snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core x86_pkg_temp_thermal kvm_intel kvm irqbypass
kernel: CPU: 0 PID: 7883 Comm: rmmod Tainted: G        W  O    4.11.3-gentoo #3
kernel: Hardware name: MEDION E2050 2391/H81H3-EM2, BIOS H81EM2W08.308 08/25/2014
kernel: Call Trace:
kernel:  dump_stack+0x4d/0x66
kernel:  __warn+0xc6/0xe0
kernel:  warn_slowpath_fmt+0x46/0x50
kernel:  ? kobject_put+0x2f/0x60
kernel:  refcount_sub_and_test+0x70/0x80
kernel:  refcount_dec_and_test+0x11/0x20
kernel:  dvb_unregister_frontend+0x42/0x60 [dvb_core]
kernel:  vb2_dvb_dealloc_frontends+0x9e/0x100 [videobuf2_dvb]
kernel:  vb2_dvb_unregister_bus+0xd/0x20 [videobuf2_dvb]
kernel:  cx23885_dvb_unregister+0xc3/0x110 [cx23885]
kernel:  cx23885_dev_unregister+0xea/0x150 [cx23885]
kernel:  cx23885_finidev+0x4f/0x70 [cx23885]
kernel:  pci_device_remove+0x34/0xb0
kernel:  device_release_driver_internal+0x150/0x200
kernel:  driver_detach+0x33/0x70
kernel:  bus_remove_driver+0x47/0xa0
kernel:  driver_unregister+0x27/0x50
kernel:  pci_unregister_driver+0x34/0x90
kernel:  cx23885_fini+0x10/0x12 [cx23885]
kernel:  SyS_delete_module+0x166/0x220
kernel:  ? exit_to_usermode_loop+0x7b/0x80
kernel:  entry_SYSCALL_64_fastpath+0x17/0x98
kernel: RIP: 0033:0x7f5901680b07
kernel: RSP: 002b:00007ffdf6cdb028 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
kernel: RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f5901680b07
kernel: RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000000001500258
kernel: RBP: 00000000015001f0 R08: 0000000000000000 R09: 1999999999999999
kernel: R10: 0000000000000884 R11: 0000000000000206 R12: 00007ffdf6cda010
kernel: R13: 0000000000000000 R14: 00000000015001f0 R15: 00000000014ff010
kernel: ---[ end trace c3a4659b89086061 ]---

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: staging: atomisp: fix bounds checking in mt9m114_s_exposure_selection()
Dan Carpenter [Thu, 10 Aug 2017 12:23:34 +0000 (08:23 -0400)]
media: staging: atomisp: fix bounds checking in mt9m114_s_exposure_selection()

These clamp_t() calls are no-ops because we don't save the results.  It
leads to an array out of bounds bug.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: staging: media: atomisp: ap1302: Remove FSF postal address
Harold Gomez [Thu, 10 Aug 2017 08:28:24 +0000 (04:28 -0400)]
media: staging: media: atomisp: ap1302: Remove FSF postal address

Do not include the paragraph about writing to the Free Software
Foundation's mailing address from the sample GPL notice. The FSF has
changed addresses in the past, and may do so again. Linux already includes
a copy of the GPL.

remove the unnecessary paragraph

Signed-off-by: Harold Gomez <haroldgmz11@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: staging: atomisp: imx: remove dead code
Arnd Bergmann [Mon, 7 Aug 2017 10:51:47 +0000 (06:51 -0400)]
media: staging: atomisp: imx: remove dead code

Making some functions 'static' has uncovered a few functions that
have no caller, through the gcc warnings:

atomisp/i2c/imx/imx.c:1111:12: error: 'imx_t_focus_vcm' defined but not used [-Werror=unused-function]
atomisp/i2c/imx/imx.c:1103:12: error: 'imx_vcm_init' defined but not used [-Werror=unused-function]
atomisp/i2c/imx/imx.c:1095:12: error: 'imx_vcm_power_down' defined but not used [-Werror=unused-function]
atomisp/i2c/imx/imx.c:1087:12: error: 'imx_vcm_power_up' defined but not used [-Werror=unused-function]

All four of these can be removed. Since they call indirect functions,
I also looked at how those are used in turn:

- The power_up/power_down callbacks are called from other functions
  and are still needed.

- The t_focus_vcm callbacks pointers are completely unused and can
  be removed in both imx and ov8858. Some of the handlers are called
  directly and can now be marked static, the others are dummy
  implemntations that we can remove.

- vcm_init is unused in imx, but dw9718_vcm_init is used in ov8858,
  but is not used in imx, so that one needs to stay around. The callback
  pointers in imx can be removed.

Fixes: 9a5a6911aa3f ("staging: imx: fix non-static declarations")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: arm: dts: omap3: N9/N950: Add AS3645A camera flash
Sakari Ailus [Sun, 3 May 2015 21:14:28 +0000 (17:14 -0400)]
media: arm: dts: omap3: N9/N950: Add AS3645A camera flash

Add the as3645a flash controller to the DT source.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: leds: as3645a: Add LED flash class driver
Sakari Ailus [Sun, 26 Apr 2015 21:56:54 +0000 (17:56 -0400)]
media: leds: as3645a: Add LED flash class driver

Add a LED flash class driver for the as3654a flash controller. A V4L2 flash
driver for it already exists (drivers/media/i2c/as3645a.c), and this driver
is based on that.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: dt: bindings: Document DT bindings for Analog devices as3645a
Sakari Ailus [Sat, 6 Jun 2015 11:10:59 +0000 (07:10 -0400)]
media: dt: bindings: Document DT bindings for Analog devices as3645a

Document DT bindings for Analog Devices as3645a flash LED controller which
also supports an indicator LED.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: v4l2-flash-led-class: Document v4l2_flash_init() references
Sakari Ailus [Wed, 19 Jul 2017 22:38:36 +0000 (18:38 -0400)]
media: v4l2-flash-led-class: Document v4l2_flash_init() references

The v4l2_flash_init() keeps a reference to the ops struct but not to the
config struct (nor anything it contains). Document this.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: v4l2-flash-led-class: Create separate sub-devices for indicators
Sakari Ailus [Tue, 18 Jul 2017 13:26:59 +0000 (09:26 -0400)]
media: v4l2-flash-led-class: Create separate sub-devices for indicators

The V4L2 flash interface allows controlling multiple LEDs through a single
sub-devices if, and only if, these LEDs are of different types. This
approach scales badly for flash controllers that drive multiple flash LEDs
or for LED specific associations. Essentially, the original assumption of a
LED driver chip that drives a single flash LED and an indicator LED is no
longer valid.

Address the matter by registering one sub-device per LED.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> (for greybus/light)
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: staging: greybus: light: fix memory leak in v4l2 register
Rui Miguel Silva [Wed, 2 Aug 2017 16:52:57 +0000 (12:52 -0400)]
media: staging: greybus: light: fix memory leak in v4l2 register

We are allocating memory for the v4l2 flash configuration structure and
leak it in the normal path. Just use the stack for this as we do not
use it outside of this function.

Also use IS_ERR() instead of IS_ERR_OR_NULL() to check return value from
v4l2_flash_init() for it never returns NULL.

Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
Reported-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: uapi book: Fix a few Sphinx warnings
Mauro Carvalho Chehab [Sun, 27 Aug 2017 00:16:51 +0000 (20:16 -0400)]
media: uapi book: Fix a few Sphinx warnings

Solve the following issues:

Documentation/media/uapi/v4l/dev-sliced-vbi.rst:208: ERROR: Content block expected for the "raw" directive; none found.
Documentation/media/uapi/v4l/dev-sliced-vbi.rst:216: ERROR: Content block expected for the "raw" directive; none found.
Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst:645: ERROR: Content block expected for the "raw" directive; none found.

Fixes: 70b074df4ed1 ("media: fix pdf build with Spinx 1.6")
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: smiapp: check memory allocation failure
Christophe JAILLET [Thu, 24 Aug 2017 05:58:39 +0000 (01:58 -0400)]
media: smiapp: check memory allocation failure

Check memory allocation failure and return -ENOMEM in such a case.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: omap3isp: fix uninitialized variable use
Arnd Bergmann [Wed, 23 Aug 2017 13:30:19 +0000 (09:30 -0400)]
media: omap3isp: fix uninitialized variable use

A debug printk statement was copied incorrectly into the new
csi1 parser code and causes a warning there:

drivers/media/platform/omap3isp/isp.c: In function 'isp_probe':
include/linux/dynamic_debug.h:134:3: error: 'i' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Since there is only one lane, the index is never set. This
changes the debug print to always print a zero instead,
keeping the original format of the message.

Fixes: 9211434bad30 ("media: omap3isp: Parse CSI1 configuration from the device tree")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: fix pdf build with Spinx 1.6
Mauro Carvalho Chehab [Sat, 26 Aug 2017 09:28:26 +0000 (05:28 -0400)]
media: fix pdf build with Spinx 1.6

Sphinx 1.6 generates some LaTeX code before each table,
starting its own environment before calling tabulary,
apparently to improve table layout.

The problem is that such environment is incompatible with
adjustbox. While, in thesis, it should be possible to override
it or to redefine tabulary, I was unable to produce such patch.

Also, that would likely break on some future Sphinx version.

So, instead, let's just change the font size on bigger tables,
in order for them to fit into the page size. That is not as
good as adjustbox, and require some manual work, but it should
be less sensitive to Sphinx changes.

While here, adjust a few other tables whose text is exceeding
the cell boundaries.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: qcom: don't go past the array
Mauro Carvalho Chehab [Sat, 26 Aug 2017 19:34:37 +0000 (15:34 -0400)]
media: qcom: don't go past the array

As reported by smatch:

drivers/media/platform/qcom/camss-8x16/camss-vfe.c:1136 vfe_release_wm() error: buffer overflow 'vfe->wm_output_map' 7 <= 7

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: qcom: mark long long consts as such
Mauro Carvalho Chehab [Sat, 26 Aug 2017 19:33:25 +0000 (15:33 -0400)]
media: qcom: mark long long consts as such

Fix those warnings when building on i386:

drivers/media/platform/qcom/camss-8x16/camss-csiphy.c:333:22: warning: constant 1000000000000 is so big it is long long
drivers/media/platform/qcom/camss-8x16/camss-csiphy.c:339:32: warning: constant 1000000000000 is so big it is long long

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: Add abbreviations explanation
Todor Tomov [Fri, 18 Aug 2017 08:16:34 +0000 (04:16 -0400)]
media: camss: Add abbreviations explanation

Add abbreviations explanation at the top header blocks in source files.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: doc: media/v4l-drivers/qcom_camss: Add abbreviations explanation
Todor Tomov [Fri, 18 Aug 2017 08:16:33 +0000 (04:16 -0400)]
media: doc: media/v4l-drivers/qcom_camss: Add abbreviations explanation

Add explanations for VFE's PIX and RDI interfaces.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: doc: media/v4l-drivers: Qualcomm Camera Subsystem - Media graph
Todor Tomov [Tue, 8 Aug 2017 13:30:18 +0000 (09:30 -0400)]
media: doc: media/v4l-drivers: Qualcomm Camera Subsystem - Media graph

Update the Qualcomm Camera Subsystem driver document with a media
controller pipeline graph diagram.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: Use optimal clock frequency rates
Todor Tomov [Tue, 8 Aug 2017 13:30:17 +0000 (09:30 -0400)]
media: camss: Use optimal clock frequency rates

Use standard V4L2 control to get pixel clock rate from a sensor
linked in the media controller pipeline. Then calculate clock
rates on CSIPHY, CSID and VFE to use the lowest possible.

If the currnet pixel clock rate of the sensor cannot be read then
use the highest possible. This case covers also the CSID test
generator usage.

If VFE is already powered on by another pipeline, check that the
current VFE clock rate is high enough for the new pipeline.
If not return busy error code as VFE clock rate cannot be changed
while VFE is running.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: doc: media/v4l-drivers: Qualcomm Camera Subsystem - Scale and crop
Todor Tomov [Tue, 8 Aug 2017 13:30:16 +0000 (09:30 -0400)]
media: doc: media/v4l-drivers: Qualcomm Camera Subsystem - Scale and crop

Update the Qualcomm Camera Subsystem driver document for VFE scale
and crop modules support.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: vfe: Configure crop module in VFE
Todor Tomov [Tue, 8 Aug 2017 13:30:15 +0000 (09:30 -0400)]
media: camss: vfe: Configure crop module in VFE

Add crop module configuration support to be able to apply cropping.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: vfe: Add interface for cropping
Todor Tomov [Tue, 8 Aug 2017 13:30:14 +0000 (09:30 -0400)]
media: camss: vfe: Add interface for cropping

Extend selection ioctls to handle cropping configuration.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: vfe: Configure scaler module in VFE
Todor Tomov [Tue, 8 Aug 2017 13:30:13 +0000 (09:30 -0400)]
media: camss: vfe: Configure scaler module in VFE

Add scaler module configuration support to be able to apply scaling.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: vfe: Add interface for scaling
Todor Tomov [Tue, 8 Aug 2017 13:30:12 +0000 (09:30 -0400)]
media: camss: vfe: Add interface for scaling

Add compose selection ioctls to handle scaling configuration.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: vfe: Support for frame padding
Todor Tomov [Tue, 8 Aug 2017 13:30:11 +0000 (09:30 -0400)]
media: camss: vfe: Support for frame padding

Add support for horizontal and vertical frame padding.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: doc: media/v4l-drivers: Qualcomm Camera Subsystem - PIX Interface
Todor Tomov [Tue, 8 Aug 2017 13:30:10 +0000 (09:30 -0400)]
media: doc: media/v4l-drivers: Qualcomm Camera Subsystem - PIX Interface

Update Qualcomm Camera Subsystem driver document for the PIX interface
and format conversion support.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: vfe: Format conversion support using PIX interface
Todor Tomov [Tue, 8 Aug 2017 13:30:09 +0000 (09:30 -0400)]
media: camss: vfe: Format conversion support using PIX interface

Use VFE PIX input interface and do format conversion in VFE.

Supported input format is UYVY (single plane YUV 4:2:2) and
its different sample order variations.

Supported output formats are:
- NV12/NV21 (two plane YUV 4:2:0)
- NV16/NV61 (two plane YUV 4:2:2)

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: Enable building
Todor Tomov [Tue, 8 Aug 2017 13:30:08 +0000 (09:30 -0400)]
media: camss: Enable building

Add Makefile and update platform/Kconfig and platform/Makefile
to enable building of the QCom CAMSS driver.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camms: Add core files
Todor Tomov [Tue, 8 Aug 2017 13:30:07 +0000 (09:30 -0400)]
media: camms: Add core files

These files implement the platform driver code.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: Add files which handle the video device nodes
Todor Tomov [Tue, 8 Aug 2017 13:30:06 +0000 (09:30 -0400)]
media: camss: Add files which handle the video device nodes

These files handle the video device nodes of the camss driver.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: Add VFE files
Todor Tomov [Tue, 8 Aug 2017 13:30:05 +0000 (09:30 -0400)]
media: camss: Add VFE files

These files control the VFE module. The VFE has different input
interfaces. The PIX input interface feeds the input data to an image
processing pipeline. Three RDI input interfaces bypass the image
processing pipeline. The VFE also contains the AXI bus interface which
writes the output data to memory.

RDI interfaces are supported in this version. PIX interface is not
supported.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: Add ISPIF files
Todor Tomov [Tue, 8 Aug 2017 13:30:04 +0000 (09:30 -0400)]
media: camss: Add ISPIF files

These files control the ISPIF module which handles the routing of the data
streams from the CSIDs to the inputs of the VFE.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: Add CSID files
Todor Tomov [Tue, 8 Aug 2017 13:30:03 +0000 (09:30 -0400)]
media: camss: Add CSID files

These files control the CSID modules which handle the protocol and
application layer of the CSI2 receivers.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: camss: Add CSIPHY files
Todor Tomov [Tue, 8 Aug 2017 13:30:02 +0000 (09:30 -0400)]
media: camss: Add CSIPHY files

These files control the CSIPHY modules which are responsible for the
physical layer of the CSI2 receivers.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: doc: media/v4l-drivers: Add Qualcomm Camera Subsystem driver document
Todor Tomov [Tue, 8 Aug 2017 13:30:01 +0000 (09:30 -0400)]
media: doc: media/v4l-drivers: Add Qualcomm Camera Subsystem driver document

Add a document to describe Qualcomm Camera Subsystem driver.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: MAINTAINERS: Add Qualcomm Camera subsystem driver
Todor Tomov [Tue, 8 Aug 2017 13:30:00 +0000 (09:30 -0400)]
media: MAINTAINERS: Add Qualcomm Camera subsystem driver

Add an entry for Qualcomm Camera subsystem driver.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: dt-bindings: media: Binding document for Qualcomm Camera subsystem driver
Todor Tomov [Tue, 8 Aug 2017 13:29:59 +0000 (09:29 -0400)]
media: dt-bindings: media: Binding document for Qualcomm Camera subsystem driver

Add DT binding document for Qualcomm Camera subsystem driver.

CC: Rob Herring <robh+dt@kernel.org>
CC: devicetree@vger.kernel.org
Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: v4l: Add packed Bayer raw12 pixel formats
Sakari Ailus [Tue, 8 Aug 2017 13:29:58 +0000 (09:29 -0400)]
media: v4l: Add packed Bayer raw12 pixel formats

These formats are compressed 12-bit raw bayer formats with four different
pixel orders. They are similar to 10-bit variants. The formats added by
this patch are

V4L2_PIX_FMT_SBGGR12P
V4L2_PIX_FMT_SGBRG12P
V4L2_PIX_FMT_SGRBG12P
V4L2_PIX_FMT_SRGGB12P

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: venus: fix copy/paste error in return_buf_error
Gustavo A. R. Silva [Fri, 18 Aug 2017 16:07:19 +0000 (12:07 -0400)]
media: venus: fix copy/paste error in return_buf_error

Call function v4l2_m2m_dst_buf_remove_by_buf() instead of
v4l2_m2m_src_buf_remove_by_buf()

Addresses-Coverity-ID: 1415317

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Cc: <stable@vger.kernel.org> # for v4.13
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: em28xx: calculate left volume level correctly
Colin Ian King [Tue, 22 Aug 2017 14:21:20 +0000 (10:21 -0400)]
media: em28xx: calculate left volume level correctly

The calculation of the left volume looks suspect, the value of
0x1f - ((val << 8) & 0x1f) is always 0x1f. The debug prior to the
assignment of value[1] prints the left volume setting using the
calculation 0x1f - (val >> 8) & 0x1f which looks correct to me.
Fix the left volume by using the correct expression as used in
the debug.

Detected by CoverityScan, CID#146140 ("Wrong operator used")

Fixes: 850d24a5a861 ("[media] em28xx-alsa: add mixer support for AC97 volume controls")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: platform: constify videobuf_queue_ops structures
Arvind Yadav [Tue, 22 Aug 2017 12:56:35 +0000 (08:56 -0400)]
media: platform: constify videobuf_queue_ops structures

videobuf_queue_ops are not supposed to change at runtime. All functions
working with videobuf_queue_ops provided by <media/videobuf-core.h> work
with const videobuf_queue_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: pci: constify videobuf_queue_ops structures
Arvind Yadav [Tue, 22 Aug 2017 12:56:34 +0000 (08:56 -0400)]
media: pci: constify videobuf_queue_ops structures

videobuf_queue_ops are not supposed to change at runtime. All functions
working with videobuf_queue_ops provided by <media/videobuf-core.h> work
with const videobuf_queue_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: saa7146: constify videobuf_queue_ops structures
Arvind Yadav [Tue, 22 Aug 2017 12:56:33 +0000 (08:56 -0400)]
media: saa7146: constify videobuf_queue_ops structures

videobuf_queue_ops are not supposed to change at runtime. All functions
working with videobuf_queue_ops provided by <media/videobuf-core.h> work
with const videobuf_queue_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: cx18: Make i2c_algo_bit_data const
Bhumika Goyal [Mon, 21 Aug 2017 13:35:50 +0000 (09:35 -0400)]
media: cx18: Make i2c_algo_bit_data const

Make this const as it is only used in a copy operation.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: bt8xx: Make i2c_algo_bit_data const
Bhumika Goyal [Mon, 21 Aug 2017 13:33:32 +0000 (09:33 -0400)]
media: bt8xx: Make i2c_algo_bit_data const

Make this const as it is only used in a copy operation.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: venus: venc: set correct resolution on compressed stream
Stanimir Varbanov [Fri, 18 Aug 2017 14:16:01 +0000 (10:16 -0400)]
media: venus: venc: set correct resolution on compressed stream

This change the alignment restriction for output type of buffers
only, also set corect input resolution and fill bidirectional
vb2 queue flag in order to map output type buffers read/write.
The last is needed by encoder firmware to add padding at the
bottom of output (input buffers).

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: vb2: add bidirectional flag in vb2_queue
Stanimir Varbanov [Mon, 21 Aug 2017 11:34:10 +0000 (07:34 -0400)]
media: vb2: add bidirectional flag in vb2_queue

This change is intended to give to the v4l2 drivers a choice to
change the default behavior of the v4l2-core DMA mapping direction
from DMA_TO/FROM_DEVICE (depending on the buffer type CAPTURE or
OUTPUT) to DMA_BIDIRECTIONAL during queue_init time.

Initially the issue with DMA mapping direction has been found in
Venus encoder driver where the hardware (firmware side) adds few
lines padding on bottom of the image buffer, and the consequence
is triggering of IOMMU protection faults.

This will help supporting venus encoder (and probably other drivers
in the future) which wants to map output type of buffers as
read/write.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: stm32-dcmi: g_/s_selection crop support
Hugues Fruchet [Tue, 22 Aug 2017 14:41:11 +0000 (10:41 -0400)]
media: stm32-dcmi: g_/s_selection crop support

Implements g_/s_selection crop support by using DCMI crop
hardware feature.
User can first get the maximum supported resolution of the sensor
by calling g_selection(V4L2_SEL_TGT_CROP_BOUNDS).
Then user call to s_selection(V4L2_SEL_TGT_CROP) will reset sensor
to its maximum resolution and crop request is saved for later usage
in s_fmt().
Next call to s_fmt() will check if sensor can do frame size request
with crop request. If sensor supports only discrete frame sizes,
the frame size which is larger than user request is selected in
order to be able to match the crop request. Then s_fmt() resolution
user request is adjusted to match crop request resolution.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: stm32-dcmi: cleanup variable/fields namings
Hugues Fruchet [Tue, 22 Aug 2017 14:41:10 +0000 (10:41 -0400)]
media: stm32-dcmi: cleanup variable/fields namings

Uniformize "pixfmt" variables to "pix".
Change "current_fmt" & "dcmi_fmt" variables to variables
with "sd_" prefix to explicitly refer to subdev format.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: stm32-dcmi: revisit control register handling
Hugues Fruchet [Tue, 22 Aug 2017 14:41:09 +0000 (10:41 -0400)]
media: stm32-dcmi: revisit control register handling

Simplify bits handling of DCMI_CR register.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: stm32-dcmi: catch dma submission error
Hugues Fruchet [Tue, 22 Aug 2017 14:41:08 +0000 (10:41 -0400)]
media: stm32-dcmi: catch dma submission error

Test cookie return by dmaengine_submit() and return error if any.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: v4l: fwnode: Use a less clash-prone name for MAX_DATA_LANES macro
Sakari Ailus [Mon, 14 Aug 2017 10:43:07 +0000 (06:43 -0400)]
media: v4l: fwnode: Use a less clash-prone name for MAX_DATA_LANES macro

Avoid using a generic name such as MAX_DATA_LANES in a header file widely
included in drivers. Instead, call it V4L2_FWNODE_CSI2_MAX_DATA_LANES.

Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing logic")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: v4l: fwnode: The clock lane is the first lane in lane_polarities
Sakari Ailus [Mon, 14 Aug 2017 10:22:14 +0000 (06:22 -0400)]
media: v4l: fwnode: The clock lane is the first lane in lane_polarities

The clock lane is the first lane in the lane_polarities array. Reflect this
consistently by putting the number of data lanes after the number of clock
lanes.

Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing logic")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: v4l: fwnode: Fix lane-polarities property parsing
Sakari Ailus [Mon, 14 Aug 2017 10:15:21 +0000 (06:15 -0400)]
media: v4l: fwnode: Fix lane-polarities property parsing

fwnode_property_read_u32_array() only returns the number of array elements
if the array argument is NULL. The assumption that it always did so lead to
lane-polarities properties never being read.

Fixes: 4ee236219f6d ("media: v4l2-fwnode: suppress a warning at OF parsing logic")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: dw9714: Remove ACPI match tables, convert to use probe_new
Sakari Ailus [Tue, 15 Aug 2017 09:08:52 +0000 (05:08 -0400)]
media: dw9714: Remove ACPI match tables, convert to use probe_new

The ACPI match table is empty. Remove it.

Also convert the drive to use probe_new callback in struct i2c_driver.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: dw9714: Add Devicetree support
Sakari Ailus [Tue, 15 Aug 2017 09:06:59 +0000 (05:06 -0400)]
media: dw9714: Add Devicetree support

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: dt-bindings: Add bindings for Dongwoon DW9714 voice coil
Sakari Ailus [Tue, 15 Aug 2017 09:03:39 +0000 (05:03 -0400)]
media: dt-bindings: Add bindings for Dongwoon DW9714 voice coil

Dongwoon DW9714 is a voice coil lens driver.

Also add a vendor prefix for Dongwoon for one did not exist previously.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: venus: venc: drop VP9 codec support
Stanimir Varbanov [Fri, 18 Aug 2017 14:16:06 +0000 (10:16 -0400)]
media: venus: venc: drop VP9 codec support

No one of the supported Venus version has implemented VP9 codec
for enconding, so drop it from the list of codecs.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: venus: use helper function to check supported codecs
Stanimir Varbanov [Fri, 18 Aug 2017 14:16:05 +0000 (10:16 -0400)]
media: venus: use helper function to check supported codecs

Use the helper function in decoder and encoder find_format
to runtime check supported codecs.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: venus: add helper to check supported codecs
Stanimir Varbanov [Fri, 18 Aug 2017 14:16:04 +0000 (10:16 -0400)]
media: venus: add helper to check supported codecs

Adds a helper function to runtime check supported encoder and
decoder codecs depending on venus version and platform.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: venus: fill missing video_device name
Stanimir Varbanov [Fri, 18 Aug 2017 14:16:03 +0000 (10:16 -0400)]
media: venus: fill missing video_device name

This fills missing (forgotten) video device name with
appropriate string so that udev can distinguishes between
decoder and encoder devices.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: venus: mark venc and vdec PM functions as __maybe_unused
Stanimir Varbanov [Fri, 18 Aug 2017 14:16:02 +0000 (10:16 -0400)]
media: venus: mark venc and vdec PM functions as __maybe_unused

Without PM support gcc could warns about unused functions, thus
mark runtime_suspend/resume as __maybe_unused.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: ths8200: constify i2c_device_id
Arvind Yadav [Sat, 19 Aug 2017 19:20:47 +0000 (15:20 -0400)]
media: ths8200: constify i2c_device_id

i2c_device_id are not supposed to change at runtime. All functions
working with i2c_device_id provided by <linux/i2c.h> work with
const i2c_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: tc358743: constify i2c_device_id
Arvind Yadav [Sat, 19 Aug 2017 19:20:46 +0000 (15:20 -0400)]
media: tc358743: constify i2c_device_id

i2c_device_id are not supposed to change at runtime. All functions
working with i2c_device_id provided by <linux/i2c.h> work with
const i2c_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: saa7127: constify i2c_device_id
Arvind Yadav [Sat, 19 Aug 2017 19:20:45 +0000 (15:20 -0400)]
media: saa7127: constify i2c_device_id

i2c_device_id are not supposed to change at runtime. All functions
working with i2c_device_id provided by <linux/i2c.h> work with
const i2c_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: adv7842: constify i2c_device_id
Arvind Yadav [Sat, 19 Aug 2017 19:20:44 +0000 (15:20 -0400)]
media: adv7842: constify i2c_device_id

i2c_device_id are not supposed to change at runtime. All functions
working with i2c_device_id provided by <linux/i2c.h> work with
const i2c_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: adv7511: constify i2c_device_id
Arvind Yadav [Sat, 19 Aug 2017 19:20:43 +0000 (15:20 -0400)]
media: adv7511: constify i2c_device_id

i2c_device_id are not supposed to change at runtime. All functions
working with i2c_device_id provided by <linux/i2c.h> work with
const i2c_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: ad9389b: constify i2c_device_id
Arvind Yadav [Sat, 19 Aug 2017 19:20:42 +0000 (15:20 -0400)]
media: ad9389b: constify i2c_device_id

i2c_device_id are not supposed to change at runtime. All functions
working with i2c_device_id provided by <linux/i2c.h> work with
const i2c_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: usb: make i2c_adapter const
Bhumika Goyal [Sat, 19 Aug 2017 10:34:15 +0000 (06:34 -0400)]
media: usb: make i2c_adapter const

Make these const as they are only used in a copy operation.
Done using Coccinelle

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Mike Isely <isely@pobox.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: radio-usb-si4713: make i2c_adapter const
Bhumika Goyal [Sat, 19 Aug 2017 10:34:14 +0000 (06:34 -0400)]
media: radio-usb-si4713: make i2c_adapter const

Make this const as it is only used in a copy operation.
Done using Coccinelle

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: pci: make i2c_adapter const
Bhumika Goyal [Sat, 19 Aug 2017 10:34:13 +0000 (06:34 -0400)]
media: pci: make i2c_adapter const

Make these const as they are only used in a copy operation.
Done using Coccinelle

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: i2c: make device_type const
Bhumika Goyal [Sat, 19 Aug 2017 08:22:14 +0000 (04:22 -0400)]
media: i2c: make device_type const

Make this const as it is only stored in the type field of a device
structure, which is const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: usb: make i2c_algorithm const
Bhumika Goyal [Fri, 18 Aug 2017 16:06:58 +0000 (12:06 -0400)]
media: usb: make i2c_algorithm const

Make these const as they are only used in a copy operation or
are stored in the algo field of i2c_adapter structure, which is const.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Mike Isely <isely@pobox.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: stm32-cec: use CEC_CAP_DEFAULTS
Hans Verkuil [Fri, 4 Aug 2017 10:41:55 +0000 (06:41 -0400)]
media: stm32-cec: use CEC_CAP_DEFAULTS

Use the new CEC_CAP_DEFAULTS define in this driver.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: stih-cec: use CEC_CAP_DEFAULTS
Hans Verkuil [Fri, 4 Aug 2017 10:41:54 +0000 (06:41 -0400)]
media: stih-cec: use CEC_CAP_DEFAULTS

Use the new CEC_CAP_DEFAULTS define in this driver.
This also adds the CEC_CAP_RC capability which was missing here
(and this is also the reason for this new define, to avoid missing
such capabilities).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: vivid: fix incorrect HDMI input/output CEC logging
Hans Verkuil [Sun, 20 Aug 2017 11:39:42 +0000 (07:39 -0400)]
media: vivid: fix incorrect HDMI input/output CEC logging

Only the first HDMI input has a CEC adapter, so just report 'HDMI 0' as
the HDMI input name.

For the HDMI outputs use bus_cnt instead of i as the output number.
The HDMI name now corresponds to what 'v4l2-ctl --list-outputs' reports.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: vivid: add CEC pin monitoring emulation
Hans Verkuil [Sun, 20 Aug 2017 11:15:25 +0000 (07:15 -0400)]
media: vivid: add CEC pin monitoring emulation

Add support to emulate CEC pin monitoring. There are few hardware devices
that support this, so being able to emulate it here helps developing
software for this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: cec: replace pin->cur_value by adap->cec_pin_is_high
Hans Verkuil [Sun, 20 Aug 2017 10:53:10 +0000 (06:53 -0400)]
media: cec: replace pin->cur_value by adap->cec_pin_is_high

The current CEC pin value (0 or 1) was part of the cec_pin struct,
but that assumes that CEC pin monitoring can only be used with
a driver that uses the low-level CEC pin framework.

But hardware that has both a high-level API and can monitor the
CEC pin at low-level at the same time does not need to depend on
the cec pin framework.

To support such devices remove the cur_value field from struct cec_pin
and add a cec_pin_is_high field to cec_adapter. This also makes it
possible to drop the '#ifdef CONFIG_CEC_PIN' in cec-api.c.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: cec: ensure that adap_enable(false) is called from cec_delete_adapter()
Hans Verkuil [Sun, 20 Aug 2017 11:41:41 +0000 (07:41 -0400)]
media: cec: ensure that adap_enable(false) is called from cec_delete_adapter()

When the adapter is removed the cec_delete_adapter() call attempts
to set the physical address to INVALID by calling __cec_s_phys_addr()
and so disabling the adapter.

However, __cec_s_phys_addr checks if the device node was unregistered
and just returns in that case.

This means that the adap_enable callback is never called with 'false'
to disable the CEC adapter. Most drivers don't care, but some need
to do cleanup here.

Change the test so the adapter is correctly disabled, even when the
device node is unregistered.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: ddbridge: fix semicolon.cocci warnings
Fengguang Wu [Sun, 20 Aug 2017 14:17:15 +0000 (10:17 -0400)]
media: ddbridge: fix semicolon.cocci warnings

drivers/media/pci/ddbridge/ddbridge-maxs8.c:145:2-3: Unneeded semicolon
drivers/media/pci/ddbridge/ddbridge-maxs8.c:173:2-3: Unneeded semicolon

 Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

Fixes: a43dbe430fb4 ("media: ddbridge: support MaxLinear MXL5xx based cards (MaxS4/8)")
CC: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: isl6421: add checks for current overflow
Jemma Denson [Sat, 19 Aug 2017 11:38:26 +0000 (07:38 -0400)]
media: isl6421: add checks for current overflow

This Kaffeine's BZ:
https://bugs.kde.org/show_bug.cgi?id=374693

affects SkyStar S2 PCI DVB-S/S2 rev 3.3 device. It could be due to
a Kernel bug.

While checking the Isil 6421, comparing with its manual, available at:

http://www.intersil.com/content/dam/Intersil/documents/isl6/isl6421a.pdf

It was noticed that, if the output load is highly capacitive, a different approach
is recomended when energizing the LNBf.

Also, it is possible to detect if a current overload is happening, by checking an
special flag.

Add support for it.

Tested on Skystar S2. Changes respect override_or option so should still work fine
on cx88 based cards which disable dynamic current limit.

Changes since v1:
v2 - fixed incorrect checking of i2c return values
v3 - fix if logic to check if dcl needs re-enabling
   - respect override_or values which aim to disable dcl
   - only do long sleep on overload if dcl enabled
   - add short sleep before re-enabling dcl
   - only check overload and potentially return EINVAL if device is on
v4 - revert v3 sleep logic changes to remove tuning delays

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jemma Denson <jdenson@gmail.com>
7 years agomedia: stv6111: return NULL instead of plain integer
Daniel Scheller [Sun, 20 Aug 2017 12:59:12 +0000 (08:59 -0400)]
media: stv6111: return NULL instead of plain integer

Fixes:
  stv6111.c:665:24: warning: Using plain integer as NULL pointer

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: stv0910: declare global list_head stvlist static
Daniel Scheller [Sun, 20 Aug 2017 12:59:11 +0000 (08:59 -0400)]
media: stv0910: declare global list_head stvlist static

Cleans up smatch warning:
symbol 'stvlist' was not declared. Should it be static?

Patch originally submitted by Colin Ian King <colin.king@canonical.com>,
remainder after the merge of all other stv0910 fixes.

Cc: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_*
Sean Young [Mon, 7 Aug 2017 20:20:58 +0000 (16:20 -0400)]
media: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_*

RC_TYPE is confusing and it's just the protocol. So rename it.

Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sean Young <sean@mess.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: cec: fix remote control passthrough
Hans Verkuil [Mon, 7 Aug 2017 13:31:24 +0000 (09:31 -0400)]
media: cec: fix remote control passthrough

The 'Press and Hold' operation was not correctly implemented, in
particular the requirement that the repeat doesn't start until
the second identical keypress arrives. The REP_DELAY value also
had to be adjusted (see the comment in the code) to achieve the
desired behavior.

The 'enabled_protocols' field was also never set, fix that too. Since
CEC is a fixed protocol the driver has to set this field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: rc: per-protocol repeat period
Sean Young [Wed, 9 Aug 2017 17:19:16 +0000 (13:19 -0400)]
media: rc: per-protocol repeat period

CEC needs a keypress timeout of 550ms, which is too high for the IR
protocols. Also fill in known repeat times, with 50ms error margin.

Also, combine all protocol data into one structure.

Signed-off-by: Sean Young <sean@mess.org>
Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: rc: saa7134: raw decoder can support any protocol
Sean Young [Mon, 7 Aug 2017 19:54:51 +0000 (15:54 -0400)]
media: rc: saa7134: raw decoder can support any protocol

Any protocol for which we have a software decoder, can be enabled. Without
this only the loaded protocol decoders can be selected.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: rc: ensure we do not read out of bounds
Sean Young [Mon, 7 Aug 2017 13:21:29 +0000 (09:21 -0400)]
media: rc: ensure we do not read out of bounds

If rc_validate_filter() is called for CEC or XMP, then we would read
beyond the end of the array.

Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: rc: simplify ir_raw_event_store_edge()
Sean Young [Mon, 7 Aug 2017 12:38:10 +0000 (08:38 -0400)]
media: rc: simplify ir_raw_event_store_edge()

Since commit 12749b198fa4 ("[media] rc: saa7134: add trailing space for
timely decoding"), the workaround of inserting reset events is no
longer needed.

Note that the initial reset is not needed either; other rc-core drivers
that don't use ir_raw_event_store_edge() never call this at all.

Verified on a HVR-1150 and Raspberry Pi.

Fixes: 3f5c4c73322e ("[media] rc: fix ghost keypresses with certain hw")
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: rc: saa7134: add trailing space for timely decoding
Sean Young [Mon, 7 Aug 2017 12:30:18 +0000 (08:30 -0400)]
media: rc: saa7134: add trailing space for timely decoding

The gpio-ir-recv driver adds timeouts which the saa7134 lacks; this
causes keypress not to arrive, and to only arrive once more IR is
received. This is what the commit below calls "ghost keypresses",
and that commit does not solve the issue completely.

This makes the IR on the HVR-1150 much more reliable and responsive.

Fixes: 3f5c4c73322e ("[media] rc: fix ghost keypresses with certain hw")
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: rc-core: improve ir_raw_store_edge() handling
Sean Young [Sun, 6 Aug 2017 19:25:52 +0000 (15:25 -0400)]
media: rc-core: improve ir_raw_store_edge() handling

The gpio-ir-recv driver does many wakeups (once per edge); the saa7134
driver has special handling to only wakeup 15ms after the first edge.
Make this part of rc-core so gpio-ir-recv also benefits from
this (so a rc-5 keypress now causes 3 wakeups rather than 24).

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
7 years agomedia: winbond-cir: buffer overrun during transmit
Sean Young [Fri, 4 Aug 2017 10:33:41 +0000 (06:33 -0400)]
media: winbond-cir: buffer overrun during transmit

We're reading beyond the buffer before checking its length.

BUG: KASAN: slab-out-of-bounds in wbcir_irq_tx

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>