]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/log
mirror_ubuntu-disco-kernel.git
6 years agomedia: merge ir_tx_z8f0811_haup and ir_rx_z8f0811_haup i2c devices
Sean Young [Thu, 12 Oct 2017 22:02:57 +0000 (18:02 -0400)]
media: merge ir_tx_z8f0811_haup and ir_rx_z8f0811_haup i2c devices

These two devices ids are really just one device with multiple
addresses. Probing becomes much simpler if we simply fold this into
one i2c device with two address.

Note that this breaks the lirc_zilog driver, however we will teach
ir-kbd-i2c to do what lirc_zilog does in a later commit.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: i2c: only poll if the rc device is opened
Sean Young [Tue, 17 Oct 2017 20:31:20 +0000 (16:31 -0400)]
media: rc: i2c: only poll if the rc device is opened

The lirc_zilog driver only polls the device if the lirc chardev
is opened; do the same with the rc-core driver.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: i2c: use dev_dbg rather hand-rolled debug
Sean Young [Wed, 18 Oct 2017 14:00:50 +0000 (10:00 -0400)]
media: rc: i2c: use dev_dbg rather hand-rolled debug

Use the dev_dbg dynamic infrastructure instead of rolling our own custom
debug logic.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: i2c: set parent of rc device and improve name
Sean Young [Wed, 18 Oct 2017 13:39:12 +0000 (09:39 -0400)]
media: rc: i2c: set parent of rc device and improve name

With the parent set for the rc device, the messages clearly state
that it is attached via i2c. The additional printk is unnecessary.

These are the old messages:

rc rc1: i2c IR (Hauppauge WinTV PVR-150 as /devices/virtual/rc/rc1
ir-kbd-i2c: i2c IR (Hauppauge WinTV PVR-150 detected at i2c-10/10-0071/ir0 [ivtv i2c driver #0]

Now we simply get:

rc rc1: Hauppauge WinTV PVR-150 as /devices/pci0000:00/0000:00:1e.0/0000:02:00.0/i2c-10/10-0071/rc/rc1

Note that we no longer copy the name. I've checked all call sites
to verfiy this is not a problem.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: xilinx-video: fix bad of_node_put() on endpoint error
Akinobu Mita [Thu, 12 Oct 2017 16:04:44 +0000 (12:04 -0400)]
media: xilinx-video: fix bad of_node_put() on endpoint error

When iterating through all endpoints using of_graph_get_next_endpoint(),
the refcount of the returned endpoint node is incremented and the refcount
of the node which is passed as previous endpoint is decremented.

So the caller doesn't need to call of_node_put() for each iterated node
except for error exit paths.  Otherwise we get "OF: ERROR: Bad
of_node_put() on ..." messages.

Cc: Hyun Kwon <hyun.kwon@xilinx.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: bt8xx: Fix err 'bt878_probe()'
Christophe JAILLET [Thu, 21 Sep 2017 23:23:56 +0000 (19:23 -0400)]
media: bt8xx: Fix err 'bt878_probe()'

This is odd to call 'pci_disable_device()' in an error path before a
coresponding successful 'pci_enable_device()'.

Return directly instead.

Fixes: 77e0be12100a ("V4L/DVB (4176): Bug-fix: Fix memory overflow")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_ca_en50221: sanity check slot number from userspace
Colin Ian King [Wed, 20 Sep 2017 22:19:59 +0000 (18:19 -0400)]
media: dvb_ca_en50221: sanity check slot number from userspace

Currently a user can pass in an unsanitized slot number which
will lead to and out of range index into ca->slot_info. Fix this
by checking that the slot number is no more than the allowed
maximum number of slots. Seems that this bug has been in the driver
forever.

Detected by CoverityScan, CID#139381 ("Untrusted pointer read")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jasmin Jessich <jasmin@anw.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: siano: fix a potential integer overflow
Gustavo A. R. Silva [Wed, 20 Sep 2017 01:09:18 +0000 (21:09 -0400)]
media: siano: fix a potential integer overflow

Add suffix ULL to constant 65535 in order to avoid a potential
integer overflow. This constant is used in a context that
expects an expression of type u64.

Addresses-Coverity-ID: 1056806

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvbsky: MyGica T230C support
Stefan Brüns [Fri, 17 Feb 2017 00:55:33 +0000 (19:55 -0500)]
media: dvbsky: MyGica T230C support

Mygica T230 DVB-T/T2/C USB stick support. It uses the same FX2/Si2168
bridge/demodulator combo as the other devices supported by the driver,
but uses the Si2141 tuner.
Several DVB-T (MPEG2) and DVB-T2 (H.265) channels were tested, as well as
the included remote control.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: staging: media: Introduce NVIDIA Tegra video decoder driver
Dmitry Osipenko [Tue, 12 Dec 2017 00:26:08 +0000 (19:26 -0500)]
media: staging: media: Introduce NVIDIA Tegra video decoder driver

NVIDIA Tegra20/30/114/124/132 SoC's have video decoder engine that
supports standard set of video formats like H.264 / MPEG-4 / WMV / VC1.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dt: bindings: Add binding for NVIDIA Tegra Video Decoder Engine
Dmitry Osipenko [Tue, 12 Dec 2017 00:26:07 +0000 (19:26 -0500)]
media: dt: bindings: Add binding for NVIDIA Tegra Video Decoder Engine

Add binding documentation for the Video Decoder Engine which is found
on NVIDIA Tegra20/30/114/124/132 SoC's.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
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>
6 years agomedia: ddbridge: improve error handling logic on fe attach failures
Daniel Scheller [Wed, 6 Dec 2017 17:59:14 +0000 (12:59 -0500)]
media: ddbridge: improve error handling logic on fe attach failures

This change makes sure that demod frontends are always detached whenever
a tuner frontend attach failed. Achieve this by moving the detach-on-
failure logic at the end of dvb_input_attach(), and adding a goto to this
block on every tuner attach failure case, so if an error occurs, there are
no stray attached frontends left. As a side effect, this removes some
duplicated code.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: drivers: media: remove duplicate includes
Pravin Shedge [Wed, 6 Dec 2017 16:52:02 +0000 (11:52 -0500)]
media: drivers: media: remove duplicate includes

These duplicate includes have been found with scripts/checkincludes.pl but
they have been removed manually to avoid removing false positives.

Signed-off-by: Pravin Shedge <pravin.shedge4linux@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: platform: sti: Adopt SPDX identifier
Benjamin Gaignard [Tue, 5 Dec 2017 14:52:39 +0000 (09:52 -0500)]
media: platform: sti: Adopt SPDX identifier

Add SPDX identifiers to files under sti directory

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com>
Acked-by: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_frontend: Add commands implementation for compat ioct
Jaedon Shin [Fri, 1 Dec 2017 12:31:30 +0000 (07:31 -0500)]
media: dvb_frontend: Add commands implementation for compat ioct

The dtv_properties structure and the dtv_property structure are
different sizes in 32-bit and 64-bit system. This patch provides
FE_SET_PROPERTY and FE_GET_PROPERTY ioctl commands implementation for
32-bit user space applications.

Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_frontend: Add compat_ioctl callback
Jaedon Shin [Fri, 1 Dec 2017 12:31:29 +0000 (07:31 -0500)]
media: dvb_frontend: Add compat_ioctl callback

Adds compat_ioctl for 32-bit user space applications on a 64-bit system.

[m.chehab@osg.samsung.com: add missing include compat.h]
Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_frontend: Add unlocked_ioctl in dvb_frontend.c
Jaedon Shin [Fri, 1 Dec 2017 12:31:28 +0000 (07:31 -0500)]
media: dvb_frontend: Add unlocked_ioctl in dvb_frontend.c

Adds unlocked ioctl function directly in dvb_frontend.c instead of using
dvb_generic_ioctl().

Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_usb_pctv452e: module refcount changes were unbalanced
Wolfgang Rohdewald [Tue, 28 Nov 2017 11:33:52 +0000 (06:33 -0500)]
media: dvb_usb_pctv452e: module refcount changes were unbalanced

dvb_frontend will call dvb_detach for:
- stb0899_detach in dvb_frontend_release and
- stb0899_release in __dvb_frontend_free

But we only do dvb_attach(stb0899_attach).
Increment the module refcount instead.

Signed-off-by: Wolfgang Rohdewald <wolfgang@rohdewald.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_frontend: fix ifnullfree.cocci warnings
Fengguang Wu [Mon, 27 Nov 2017 09:25:29 +0000 (04:25 -0500)]
media: dvb_frontend: fix ifnullfree.cocci warnings

drivers/media/dvb-core/dvb_frontend.c:154:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

 NULL check before some freeing functions is not needed.

 Based on checkpatch warning
 "kfree(NULL) is safe this check is probably not required"
 and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

Fixes: b1cb7372fa82 ("dvb_frontend: don't use-after-free the frontend struct")
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends/stv0910: remove unneeded dvb_math.h include
Daniel Scheller [Sun, 26 Nov 2017 13:00:09 +0000 (08:00 -0500)]
media: dvb-frontends/stv0910: remove unneeded dvb_math.h include

Since nothing from dvb_math.h is used, remove the unneeded include.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends/stv0910: remove unneeded symbol rate inquiry
Daniel Scheller [Sun, 26 Nov 2017 13:00:08 +0000 (08:00 -0500)]
media: dvb-frontends/stv0910: remove unneeded symbol rate inquiry

tracking_optimization() doesn't make use of the symbol rate reported by
the demodulator, so remove the unneeded inquiry and the now unneeded
variable.

Reported-by: Richard Scobie <rascobie@slingshot.co.nz>
Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <rascobie@slingshot.co.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends/stv0910: read symbolrate in get_frontend()
Daniel Scheller [Sun, 26 Nov 2017 13:00:07 +0000 (08:00 -0500)]
media: dvb-frontends/stv0910: read symbolrate in get_frontend()

Utilise get_cur_symbol_rate() in get_frontend() to update the
dtv_frontend_properties with the current symbol rate as reported by the
demodulator.

Reported-by: Richard Scobie <rascobie@slingshot.co.nz>
Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <rascobie@slingshot.co.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends/stv0910: remove unneeded check/call to get_if_freq
Daniel Scheller [Sun, 26 Nov 2017 13:00:06 +0000 (08:00 -0500)]
media: dvb-frontends/stv0910: remove unneeded check/call to get_if_freq

The result (if any) isn't used anywhere besides being assigned to a local
variable (and the only current companion stv6111 doesn't even implement
get_if_frequency()), thus remove the ptr check and the call, and also
remove the now unused iffreq variable.

Reported-by: Richard Scobie <rascobie@slingshot.co.nz>
Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <rascobie@slingshot.co.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends/stv6111: handle gate_ctrl errors
Daniel Scheller [Sun, 26 Nov 2017 13:00:05 +0000 (08:00 -0500)]
media: dvb-frontends/stv6111: handle gate_ctrl errors

When a parent (demod) driver encounters and signals a problem with
gate_ctrl(), don't blindly continue poking the I2C bus.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <rascobie@slingshot.co.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends/stv0910: WARN_ON() on consecutive mutex_unlock()
Daniel Scheller [Sun, 26 Nov 2017 13:00:04 +0000 (08:00 -0500)]
media: dvb-frontends/stv0910: WARN_ON() on consecutive mutex_unlock()

Stack dump when gate_ctrl() is called in a way that consecutive unlocks
happen. This is a clear indication that other drivers interfacing with
the stv0910 driver don't do things properly or don't check for failures,
so dump stack so that those drivers can be identified and fixed.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <rascobie@slingshot.co.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: frontends/stv0910: add field offsets to field defines
Daniel Scheller [Sun, 26 Nov 2017 13:00:03 +0000 (08:00 -0500)]
media: frontends/stv0910: add field offsets to field defines

Each field (FSTV0910_XX) is declared as reg/off/unused/sign/mask. Add
the missing offset value to the defines.

Picked up from dddvb master, commit 8a1f27c3d22c ("add field offset to
field defines") by Ralph Metzler <rjkm@metzlerbros.de>, adapted to
match the comment style in the mainline driver.

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>
6 years agomedia: dvb_frontend: remove redundant status self assignment
Colin Ian King [Thu, 23 Nov 2017 10:19:19 +0000 (05:19 -0500)]
media: dvb_frontend: remove redundant status self assignment

The assignment status to itself is redundant and can be removed.
Detected with Coccinelle.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dib0700: add support for Xbox One Digital TV Tuner
Olli Salonen [Thu, 23 Nov 2017 08:24:46 +0000 (03:24 -0500)]
media: dib0700: add support for Xbox One Digital TV Tuner

Xbox One Digital TV Tuner is a low-cost USB 2.0 multistandard TV tuner. It supports DVB-T, DVB-T2 and DVB-C broadcast standards.

USB bridge: DibCom 0700C
Demodulator: Panasonic MN88472
Tuner: TDA18250BHN

The demodulator requires firmware. Download one from here:
http://palosaari.fi/linux/v4l-dvb/firmware/MN88472/02/latest/

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tda18250: support for new silicon tuner
Olli Salonen [Thu, 23 Nov 2017 08:24:45 +0000 (03:24 -0500)]
media: tda18250: support for new silicon tuner

NXP TDA18250 silicon tuner driver.

Version 4 includes some checkpatch fixes.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends/stv0367: remove redundant self assignment of temporary
Colin Ian King [Tue, 21 Nov 2017 15:07:45 +0000 (10:07 -0500)]
media: dvb-frontends/stv0367: remove redundant self assignment of temporary

The self assignment of temporary is redundant and can be removed.
Detected using coccinelle.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: stb0899: remove redundant self assignment of k_indirect
Colin Ian King [Tue, 21 Nov 2017 13:51:10 +0000 (08:51 -0500)]
media: stb0899: remove redundant self assignment of k_indirect

The self assignment of k_indirect is redundant and can be removed.
Detected using coccinelle.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: c8sectpfe: Use resource_size function on memory resource
Vasyl Gomonovych [Mon, 20 Nov 2017 22:46:47 +0000 (17:46 -0500)]
media: c8sectpfe: Use resource_size function on memory resource

To adapt fei->sram_size calculation via resource_size for memory size
calculation before, in fei->sram = devm_ioremap_resource(dev, res).
And make memory initialization range in
memset_io for fei->sram appropriate

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Acked-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: c8sectpfe: fix potential NULL pointer dereference in c8sectpfe_timer_interrupt
Gustavo A. R. Silva [Mon, 20 Nov 2017 14:00:55 +0000 (09:00 -0500)]
media: c8sectpfe: fix potential NULL pointer dereference in c8sectpfe_timer_interrupt

_channel_ is being dereferenced before it is null checked, hence there is a
potential null pointer dereference. Fix this by moving the pointer dereference
after _channel_ has been null checked.

This issue was detected with the help of Coccinelle.

Fixes: c5f5d0f99794 ("[media] c8sectpfe: STiH407/10 Linux DVB demux support")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: c8sectpfe: DVB_C8SECTPFE should depend on HAS_DMA
Geert Uytterhoeven [Sun, 19 Nov 2017 18:57:17 +0000 (13:57 -0500)]
media: c8sectpfe: DVB_C8SECTPFE should depend on HAS_DMA

If NO_DMA=y:

    ERROR: "bad_dma_ops" [drivers/media/platform/sti/c8sectpfe/c8sectpfe.ko] undefined!

Add a dependency on HAS_DMA to fix this.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dibx000_common: Fix line continuation format
Joe Perches [Thu, 16 Nov 2017 15:27:28 +0000 (10:27 -0500)]
media: dibx000_common: Fix line continuation format

Line continuations with excess spacing causes unexpected output.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_frontend: fix return error code
Mauro Carvalho Chehab [Tue, 12 Dec 2017 12:48:12 +0000 (07:48 -0500)]
media: dvb_frontend: fix return error code

The correct error code when a function is not defined is
-ENOTSUPP. It was typoed wrong as -EOPNOTSUPP, with,
unfortunately, exists, but it is not used by the DVB core.

Thanks-to: Geert Uytterhoeven <geert@linux-m68k.org>
Thanks-to: Arnd Bergmann <arnd@arndb.de>
To make me revisit this code.

Fixes: a9cb97c3e628 ("media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code")
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: MAINTAINERS: add si2165 driver
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:11 +0000 (09:25 -0500)]
media: MAINTAINERS: add si2165 driver

Silicon Labs Si2165 DVB-C/T demod driver

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx23885: Use semicolon after assignment instead of comma
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:06 +0000 (09:25 -0500)]
media: cx23885: Use semicolon after assignment instead of comma

End assignments by semicolon instead of comma.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx231xx: Use semicolon after assignment instead of comma
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:05 +0000 (09:25 -0500)]
media: cx231xx: Use semicolon after assignment instead of comma

End assignments by semicolon instead of comma.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: Add DVBv3 wrapper for ber statistics
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:10 +0000 (09:25 -0500)]
media: si2165: Add DVBv3 wrapper for ber statistics

Add read_ber function that reads from property cache to support DVBv3.
The implementation is inspired by the cx24120 driver.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: add DVBv3 wrapper for C/N statistics
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:09 +0000 (09:25 -0500)]
media: si2165: add DVBv3 wrapper for C/N statistics

Add read_snr function that reads from property cache to support DVBv3.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: add DVBv5 BER statistics
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:08 +0000 (09:25 -0500)]
media: si2165: add DVBv5 BER statistics

Add support for BER statistics.
Configure a measurement period of 30000 packets.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: add DVBv5 C/N statistics for DVB-C
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:07 +0000 (09:25 -0500)]
media: si2165: add DVBv5 C/N statistics for DVB-C

Add C/N statistics in dB to read_status (DVBv5).

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: improve read_status
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:02 +0000 (09:25 -0500)]
media: si2165: improve read_status

Use check_signal register for DVB-T additionally.
For DVB-C use ps_lock additionally.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: Use constellation from property cache instead of hardcoded QAM256
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:04 +0000 (09:25 -0500)]
media: si2165: Use constellation from property cache instead of hardcoded QAM256

Use constellation from property cache instead of always setting it to
QAM256.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: Write const value for lock timeout
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:03 +0000 (09:25 -0500)]
media: si2165: Write const value for lock timeout

The lock timeout should not depend on the bandwidth.
It should be either constant or depend on xtal frequency.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: move ts parallel mode setting to the ts init code
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:01 +0000 (09:25 -0500)]
media: si2165: move ts parallel mode setting to the ts init code

The TS parallel mode setting should be where all other TS settings are written.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: define register macros
Matthias Schwarzott [Sun, 5 Nov 2017 14:25:00 +0000 (09:25 -0500)]
media: si2165: define register macros

Convert register numbers to macros.

Correctness verified by comparing the disassembly before and after.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: Make checkpatch happy
Matthias Schwarzott [Sun, 5 Nov 2017 14:24:59 +0000 (09:24 -0500)]
media: si2165: Make checkpatch happy

Fix almost all of checkpatch --strict warnings.

The remaining warnings are about:
* macro REG16 (should be enclosed in parentheses)
* macro REG16 (Macro argument reuse)

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: Convert debug printk to dev_dbg
Matthias Schwarzott [Sun, 5 Nov 2017 14:24:58 +0000 (09:24 -0500)]
media: si2165: Convert debug printk to dev_dbg

Removed module parameter debug and the conditions based on it.
Now it can be configured via dynamic debug.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: si2165: Remove redundant KBUILD_MODNAME from dev_* logging
Matthias Schwarzott [Sun, 5 Nov 2017 14:24:57 +0000 (09:24 -0500)]
media: si2165: Remove redundant KBUILD_MODNAME from dev_* logging

Remove redundant repeated module name from messages.

Before:
  si2165 8-0064: si2165: fw load finished

After:
  si2165 8-0064: fw load finished

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: pvrusb2: properly check endpoint types
Andrey Konovalov [Thu, 2 Nov 2017 13:52:27 +0000 (09:52 -0400)]
media: pvrusb2: properly check endpoint types

As syzkaller detected, pvrusb2 driver submits bulk urb withount checking
the the endpoint type is actually blunk. Add a check.

usb 1-1: BOGUS urb xfer, pipe 3 != type 1
------------[ cut here ]------------
WARNING: CPU: 1 PID: 2713 at drivers/usb/core/urb.c:449 usb_submit_urb+0xf8a/0x11d0
Modules linked in:
CPU: 1 PID: 2713 Comm: pvrusb2-context Not tainted
4.14.0-rc1-42251-gebb2c2437d80 #210
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: ffff88006b7a18c0 task.stack: ffff880069978000
RIP: 0010:usb_submit_urb+0xf8a/0x11d0 drivers/usb/core/urb.c:448
RSP: 0018:ffff88006997f990 EFLAGS: 00010286
RAX: 0000000000000029 RBX: ffff880063661900 RCX: 0000000000000000
RDX: 0000000000000029 RSI: ffffffff86876d60 RDI: ffffed000d32ff24
RBP: ffff88006997fa90 R08: 1ffff1000d32fdca R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff1000d32ff39
R13: 0000000000000001 R14: 0000000000000003 R15: ffff880068bbed68
FS:  0000000000000000(0000) GS:ffff88006c600000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000001032000 CR3: 000000006a0ff000 CR4: 00000000000006f0
Call Trace:
 pvr2_send_request_ex+0xa57/0x1d80 drivers/media/usb/pvrusb2/pvrusb2-hdw.c:3645
 pvr2_hdw_check_firmware drivers/media/usb/pvrusb2/pvrusb2-hdw.c:1812
 pvr2_hdw_setup_low drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2107
 pvr2_hdw_setup drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2250
 pvr2_hdw_initialize+0x548/0x3c10 drivers/media/usb/pvrusb2/pvrusb2-hdw.c:2327
 pvr2_context_check drivers/media/usb/pvrusb2/pvrusb2-context.c:118
 pvr2_context_thread_func+0x361/0x8c0 drivers/media/usb/pvrusb2/pvrusb2-context.c:167
 kthread+0x3a1/0x470 kernel/kthread.c:231
 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
Code: 48 8b 85 30 ff ff ff 48 8d b8 98 00 00 00 e8 ee 82 89 fe 45 89
e8 44 89 f1 4c 89 fa 48 89 c6 48 c7 c7 40 c0 ea 86 e8 30 1b dc fc <0f>
ff e9 9b f7 ff ff e8 aa 95 25 fd e9 80 f7 ff ff e8 50 74 f3
---[ end trace 6919030503719da6 ]---

Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: led-class-flash: better handle NULL flash struct
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:40 +0000 (17:05 -0400)]
media: led-class-flash: better handle NULL flash struct

The logic at V4L2 led core assumes that the flash struct
can be null. However, it doesn't check for null while
trying to set, causing some smatch  to warn:

drivers/media/v4l2-core/v4l2-flash-led-class.c:210 v4l2_flash_s_ctrl() error: we previously assumed 'fled_cdev' could be null (see line 200)

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:39 +0000 (17:05 -0400)]
media: dvb_frontend: be sure to init dvb_frontend_handle_ioctl() return code

As smatch warned:
drivers/media/dvb-core/dvb_frontend.c:2468 dvb_frontend_handle_ioctl() error: uninitialized symbol 'err'.

The ioctl handler actually got a regression here: before changeset
d73dcf0cdb95 ("media: dvb_frontend: cleanup ioctl handling logic"),
the code used to return -EOPNOTSUPP if an ioctl handler was not
implemented on a driver. After the change, it may return a random
value.

Fixes: d73dcf0cdb95 ("media: dvb_frontend: cleanup ioctl handling logic")
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Tested-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: xc5000: better handle I2C error messages
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:43 +0000 (17:05 -0400)]
media: xc5000: better handle I2C error messages

As warned by smatch, there are several places where the I2C
transfer may fail, leading into inconsistent behavior:

drivers/media/tuners/xc5000.c:689 xc_debug_dump() error: uninitialized symbol 'regval'.
drivers/media/tuners/xc5000.c:841 xc5000_is_firmware_loaded() error: uninitialized symbol 'id'.
drivers/media/tuners/xc5000.c:939 xc5000_set_tv_freq() error: uninitialized symbol 'pll_lock_status'.
drivers/media/tuners/xc5000.c:1195 xc_load_fw_and_init_tuner() error: uninitialized symbol 'pll_lock_status'.

Handle the return codes from the I2C transfer, in order to
address those issues.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: mxl111sf: improve error handling logic
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:54 +0000 (17:05 -0400)]
media: mxl111sf: improve error handling logic

As reported by smatch:
drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c:485 mxl111sf_demod_read_signal_strength() error: uninitialized symbol 'modulation'.

The mxl111sf_demod_read_signal_strength() just ignores if something
gets wrong while reading snr or modulation.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: drxd_hard: better handle I2C errors
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:53 +0000 (17:05 -0400)]
media: drxd_hard: better handle I2C errors

As warned by smatch:
drivers/media/dvb-frontends/drxd_hard.c:989 HI_Command() error: uninitialized symbol 'waitCmd'.
drivers/media/dvb-frontends/drxd_hard.c:1306 SC_WaitForReady() error: uninitialized symbol 'curCmd'.
drivers/media/dvb-frontends/drxd_hard.c:1322 SC_SendCommand() error: uninitialized symbol 'errCode'.
drivers/media/dvb-frontends/drxd_hard.c:1339 SC_ProcStartCommand() error: uninitialized symbol 'scExec'.

The error handling on several places are somewhat flawed, as
they don't check if Read16() returns an error.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cxd2841er: ensure that status will always be available
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:59 +0000 (17:05 -0400)]
media: cxd2841er: ensure that status will always be available

The loop with read status use a dynamic timeout value, calculated
from symbol rate. It should run the loop at least one time for
the status to be handled after the loop.

While this should, in practice, happen every time, it doesn't
hurt to change the logic to make it explicit.

This solves a smatch warning:
drivers/media/dvb-frontends/cxd2841er.c:3350 cxd2841er_set_frontend_s() error: uninitialized symbol 'status'.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx25821-alsa: fix usage of a pointer printk
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:46 +0000 (17:05 -0400)]
media: cx25821-alsa: fix usage of a pointer printk

As warned by smatch:
drivers/media/pci/cx25821/cx25821-alsa.c:155 cx25821_alsa_dma_init() warn: argument 3 to %08lx specifier is cast from pointer

Use the standard %p to print a pointer.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvbsky: shut up a bogus warning
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:55 +0000 (17:05 -0400)]
media: dvbsky: shut up a bogus warning

Smatch gives two bogus warnings on this driver:
drivers/media/usb/dvb-usb-v2/dvbsky.c:336 dvbsky_s960_attach() error: uninitialized symbol 'i2c_adapter'.
drivers/media/usb/dvb-usb-v2/dvbsky.c:459 dvbsky_s960c_attach() error: uninitialized symbol 'i2c_adapter'.

Shut them up.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: m88rs2000: handle the case where tuner doesn't have get_frequency
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:58 +0000 (17:05 -0400)]
media: m88rs2000: handle the case where tuner doesn't have get_frequency

If the tuner doesn't have get_frequency() callback, the current
code will place a random value as the frequency offset. That
doesn't seem right! The better is to just assume that, on such
case, the tuner was able to set the exact frequency that was
requested.

Fixes a smatch warning:
drivers/media/dvb-frontends/m88rs2000.c:639 m88rs2000_set_frontend() error: uninitialized symbol 'tuner_freq'.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: pt1: fix logic when pt1_nr_tables is zero or negative
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:52 +0000 (17:05 -0400)]
media: pt1: fix logic when pt1_nr_tables is zero or negative

pt1_nr_tables is a modprobe parameter. The way the logic
handles it, it can't be negative. However, user can
set it to zero.

If set to zero, however, it will cause troubles at
pt1_init_tables(), as reported by smatch:
drivers/media/pci/pt1/pt1.c:468 pt1_init_tables() error: uninitialized symbol 'first_pfn'.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ov9650: fix bogus warnings
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:56 +0000 (17:05 -0400)]
media: ov9650: fix bogus warnings

The smatch logic gets confused with the syntax used to check if the
ov9650x_read() reads succedded:
drivers/media/i2c/ov9650.c:895 __g_volatile_ctrl() error: uninitialized symbol 'reg2'.
drivers/media/i2c/ov9650.c:895 __g_volatile_ctrl() error: uninitialized symbol 'reg1'.

There's nothing wrong with the original logic, except that
it is a little more harder to review.

So, let's stick with the syntax that won't cause read
issues.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Reviewed-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: mb86a16: avoid division by zero
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:06:03 +0000 (17:06 -0400)]
media: mb86a16: avoid division by zero

As warned by smatch:
drivers/media/dvb-frontends/mb86a16.c:1690 mb86a16_read_ber() error: uninitialized symbol 'timer'.
drivers/media/dvb-frontends/mb86a16.c:1706 mb86a16_read_ber() error: uninitialized symbol 'timer'.

There is a potential risk of doing a division by zero if
timer is not handled well. Enforce it by setting a bit mask
for the values used to select the timer.

It should be noticed that I don't have mb86a16 datasheet. So,
the bitmask was guessed based on the existing checks for
the field. At worse case scenario, it will just show a
badly calculated bit error rate, but it won't crash.

While here, optimize the logic to prevent uneeded tests.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: mb86a16: be more resilient if I2C fails on sync
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:06:02 +0000 (17:06 -0400)]
media: mb86a16: be more resilient if I2C fails on sync

If the I2C read fails while check for sync, there's no point
on doing adjusting the tuner due to a random value that might
be at VIRM var. So, set VIRM to zero, as that makes the caller
for check_sync() to return an error.

Fix those smatch warnings:
drivers/media/dvb-frontends/mb86a16.c:1460 mb86a16_set_fe() error: uninitialized symbol 'VIRM'.
drivers/media/dvb-frontends/mb86a16.c:1461 mb86a16_set_fe() error: uninitialized symbol 'VIRM'.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: drxj: better handle errors
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:06:00 +0000 (17:06 -0400)]
media: drxj: better handle errors

as reported by smatch:
drivers/media/dvb-frontends/drx39xyj/drxj.c:2157 drxj_dap_atomic_read_write_block() error: uninitialized symbol 'word'.

The driver doesn't check if a read error occurred. Add such
check.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: imx274: don't randomly return if range_count is zero
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:57 +0000 (17:05 -0400)]
media: imx274: don't randomly return if range_count is zero

As smatch reported:
drivers/media/i2c/imx274.c:659 imx274_regmap_util_write_table_8() error: uninitialized symbol 'err'.

There is a bug at imx274_regmap_util_write_table_8() with causes
it to randomly return a random error if range_count is zero.

Worse than that, the logic there starts with range_count
equal to zero, and periodically resets it to zero again.

As it is a way more likely that err assumes a non-zero value,
I suspect that the chance of this code to run is very small,
so, it would be worth to review the entire function.

Anyway, clearly it shouldn't be returning error if range_count
is zero. So, let's fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: stv090x: Only print tuner lock if get_status is available
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:06:01 +0000 (17:06 -0400)]
media: stv090x: Only print tuner lock if get_status is available

The current code doesn't report tuner lock properly if the
tuner get_status callback is not available, as reported by
smatch:
drivers/media/dvb-frontends/stv090x.c:2220 stv090x_get_coldlock() error: uninitialized symbol 'reg'.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: xc4000: don't ignore error if hwmodel fails
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:47 +0000 (17:05 -0400)]
media: xc4000: don't ignore error if hwmodel fails

If, for some reason, reading the hwmodel register on
xc4000 fails, it will cause the following logig to
use a random value, as reported by smatch:

drivers/media/tuners/xc4000.c:1047 check_firmware() error: uninitialized symbol 'hwmodel'.
drivers/media/tuners/xc4000.c:1060 check_firmware() error: uninitialized symbol 'hwmodel'.
drivers/media/tuners/xc4000.c:1064 check_firmware() error: uninitialized symbol 'hwmodel'.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: radio-si476x: fix behavior when seek->range* are defined
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:44 +0000 (17:05 -0400)]
media: radio-si476x: fix behavior when seek->range* are defined

The logic at si476x_radio_s_hw_freq_seek() checks if the
frequency range that will be used to handle hardware seek
has the minimal frequency under rangelow. That works fine
if userspace zeros both fields. However, if userspace
fills either seek->rangelow or seek-rangehigh, it won't
read the corresponding range from the device, causing the
values to be unitialized, as warned by smatch:

drivers/media/radio/radio-si476x.c:789 si476x_radio_s_hw_freq_seek() error: uninitialized symbol 'rangelow'.
drivers/media/radio/radio-si476x.c:789 si476x_radio_s_hw_freq_seek() error: uninitialized symbol 'rangehigh'.

Fix it by initializing those vars from the values present at
the struct v4l2_hw_freq_seek.

While here, simplify the logic which reads such values from
the hardware limits.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: qt1010: fix bogus warnings
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:48 +0000 (17:05 -0400)]
media: qt1010: fix bogus warnings

The logic at qt1010_init_meas1() and qt1010_init_meas2()
are too complex for static analizers to identify that
some vars are always be initialized.

That causes smatch to produce the following warnings:
drivers/media/tuners/qt1010.c:248 qt1010_init_meas1() error: uninitialized symbol 'val2'.
drivers/media/tuners/qt1010.c:282 qt1010_init_meas2() error: uninitialized symbol 'val'.

So, add annotations to prevent those bogus warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tda8290: initialize agc gain
Mauro Carvalho Chehab [Wed, 1 Nov 2017 21:05:41 +0000 (17:05 -0400)]
media: tda8290: initialize agc gain

The tuning logic at tda8290 relies on agc_stat and
adc_sat to be initialized. However, as warned by smatch:

drivers/media/tuners/tda8290.c:261 tda8290_set_params() error: uninitialized symbol 'agc_stat'.
drivers/media/tuners/tda8290.c:261 tda8290_set_params() error: uninitialized symbol 'adc_sat'.
drivers/media/tuners/tda8290.c:262 tda8290_set_params() error: uninitialized symbol 'adc_sat'.

That could cause an erratic behavior if PLL is not locked,
as the code will only work if
!(pll_stat & 0x80) && (adc_sat < 20)

So, initialize it to zero, in order to let the code below
to be called, with should give more chances to adjust the
tuner gain, in order to get a PLL lock.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: atmel-isc: avoid returning a random value at isc_parse_dt()
Mauro Carvalho Chehab [Wed, 1 Nov 2017 12:54:58 +0000 (08:54 -0400)]
media: atmel-isc: avoid returning a random value at isc_parse_dt()

As warned by smatch:
drivers/media/platform/atmel/atmel-isc.c:2097 isc_parse_dt() error: uninitialized symbol 'ret'.

The problem here is that of_graph_get_next_endpoint() can
potentially return NULL on its first pass, with would make
it return a random value, as ret is not initialized.

While here, use while(1) instead of for(; ;), as while is
the preferred syntax for such kind of loops.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: em28xx: Fix use-after-free when disconnecting
Matthias Schwarzott [Mon, 30 Oct 2017 10:07:29 +0000 (06:07 -0400)]
media: em28xx: Fix use-after-free when disconnecting

Fix bug by moving the i2c_unregister_device calls after deregistration
of dvb frontend.

The new style i2c drivers already destroys the frontend object at
i2c_unregister_device time.
When the dvb frontend is unregistered afterwards it leads to this oops:

  [ 6058.866459] BUG: unable to handle kernel NULL pointer dereference at 00000000000001f8
  [ 6058.866578] IP: dvb_frontend_stop+0x30/0xd0 [dvb_core]
  [ 6058.866644] PGD 0
  [ 6058.866646] P4D 0

  [ 6058.866726] Oops: 0000 [#1] SMP
  [ 6058.866768] Modules linked in: rc_pinnacle_pctv_hd(O) em28xx_rc(O) si2157(O) si2168(O) em28xx_dvb(O) em28xx(O) 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) videobuf2_core(O) videodev(O) media(O) bluetooth ecdh_generic ums_realtek uas rtl8192cu rtl_usb rtl8192c_common rtlwifi usb_storage snd_hda_codec_realtek snd_hda_codec_hdmi snd_hda_codec_generic i2c_mux snd_hda_intel snd_hda_codec snd_hwdep x86_pkg_temp_thermal snd_hda_core kvm_intel kvm irqbypass [last unloaded: videobuf2_memops]
  [ 6058.867497] CPU: 2 PID: 7349 Comm: kworker/2:0 Tainted: G        W  O    4.13.9-gentoo #1
  [ 6058.867595] Hardware name: MEDION E2050 2391/H81H3-EM2, BIOS H81EM2W08.308 08/25/2014
  [ 6058.867692] Workqueue: usb_hub_wq hub_event
  [ 6058.867746] task: ffff88011a15e040 task.stack: ffffc90003074000
  [ 6058.867825] RIP: 0010:dvb_frontend_stop+0x30/0xd0 [dvb_core]
  [ 6058.867896] RSP: 0018:ffffc90003077b58 EFLAGS: 00010293
  [ 6058.867964] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000010040001f
  [ 6058.868056] RDX: ffff88011a15e040 RSI: ffffea000464e400 RDI: ffff88001cbe3028
  [ 6058.868150] RBP: ffffc90003077b68 R08: ffff880119390380 R09: 000000010040001f
  [ 6058.868241] R10: ffffc90003077b18 R11: 000000000001e200 R12: ffff88001cbe3028
  [ 6058.868330] R13: ffff88001cbe68d0 R14: ffff8800cf734000 R15: ffff8800cf734098
  [ 6058.868419] FS:  0000000000000000(0000) GS:ffff88011fb00000(0000) knlGS:0000000000000000
  [ 6058.868511] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  [ 6058.868578] CR2: 00000000000001f8 CR3: 00000001113c5000 CR4: 00000000001406e0
  [ 6058.868662] Call Trace:
  [ 6058.868705]  dvb_unregister_frontend+0x2a/0x80 [dvb_core]
  [ 6058.868774]  em28xx_dvb_fini+0x132/0x220 [em28xx_dvb]
  [ 6058.868840]  em28xx_close_extension+0x34/0x90 [em28xx]
  [ 6058.868902]  em28xx_usb_disconnect+0x4e/0x70 [em28xx]
  [ 6058.868968]  usb_unbind_interface+0x6d/0x260
  [ 6058.869025]  device_release_driver_internal+0x150/0x210
  [ 6058.869094]  device_release_driver+0xd/0x10
  [ 6058.869150]  bus_remove_device+0xe4/0x160
  [ 6058.869204]  device_del+0x1ce/0x2f0
  [ 6058.869253]  usb_disable_device+0x99/0x270
  [ 6058.869306]  usb_disconnect+0x8d/0x260
  [ 6058.869359]  hub_event+0x93d/0x1520
  [ 6058.869408]  ? dequeue_task_fair+0xae5/0xd20
  [ 6058.869467]  process_one_work+0x1d9/0x3e0
  [ 6058.869522]  worker_thread+0x43/0x3e0
  [ 6058.869576]  kthread+0x104/0x140
  [ 6058.869602]  ? trace_event_raw_event_workqueue_work+0x80/0x80
  [ 6058.869640]  ? kthread_create_on_node+0x40/0x40
  [ 6058.869673]  ret_from_fork+0x22/0x30
  [ 6058.869698] Code: 54 49 89 fc 53 48 8b 9f 18 03 00 00 0f 1f 44 00 00 41 83 bc 24 04 05 00 00 02 74 0c 41 c7 84 24 04 05 00 00 01 00 00 00 0f ae f0 <48> 8b bb f8 01 00 00 48 85 ff 74 5c e8 df 40 f0 e0 48 8b 93 f8
  [ 6058.869850] RIP: dvb_frontend_stop+0x30/0xd0 [dvb_core] RSP: ffffc90003077b58
  [ 6058.869894] CR2: 00000000000001f8
  [ 6058.875880] ---[ end trace 717eecf7193b3fc6 ]---

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: i.MX6: Fix MIPI CSI-2 LP-11 check
Krzysztof Hałasa [Tue, 17 Oct 2017 06:12:25 +0000 (02:12 -0400)]
media: i.MX6: Fix MIPI CSI-2 LP-11 check

Bitmask for the MIPI CSI-2 data PHY status doesn't seem to be correct.
Fix it.

Signed-off-by: Krzysztof Ha?asa <khalasa@piap.pl>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge: shut up a new warning
Mauro Carvalho Chehab [Mon, 11 Dec 2017 17:18:46 +0000 (12:18 -0500)]
media: ddbridge: shut up a new warning

drivers/media/pci/ddbridge/ddbridge-ci.c:321:5: warning: no previous prototype for 'ddb_ci_attach' [-Wmissing-prototypes]
 int ddb_ci_attach(struct ddb_port *port, u32 bitrate)
     ^~~~~~~~~~~~~

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge: update driver version number
Daniel Scheller [Sun, 15 Oct 2017 20:51:57 +0000 (16:51 -0400)]
media: ddbridge: update driver version number

Update the driver version number/string to 0.9.32-integrated.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: stv0910: read and update mod_cod in read_status()
Daniel Scheller [Sun, 15 Oct 2017 20:51:56 +0000 (16:51 -0400)]
media: stv0910: read and update mod_cod in read_status()

Add missing state->modcod update from upstream driver which needs to be
done when manage_matype_info() sets is_vcm on certain S2 transponders.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge/max: prefix lnb_init_fmode() and fe_attach_mxl5xx()
Daniel Scheller [Sun, 15 Oct 2017 20:51:55 +0000 (16:51 -0400)]
media: ddbridge/max: prefix lnb_init_fmode() and fe_attach_mxl5xx()

Add a ddb_ prefix to the two functions to better avoid conflicts in the
global namespace, ie. when building everything into the kernel image.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge/max: rename ddbridge-maxs8.[c|h] to ddbridge-max.[c|h]
Daniel Scheller [Sun, 15 Oct 2017 20:51:54 +0000 (16:51 -0400)]
media: ddbridge/max: rename ddbridge-maxs8.[c|h] to ddbridge-max.[c|h]

Rename the MaxS4/8 support files following upstream. References to these
files and descriptions have been updated aswell.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge/ci: change debug printing to debug severity
Daniel Scheller [Sun, 15 Oct 2017 20:51:53 +0000 (16:51 -0400)]
media: ddbridge/ci: change debug printing to debug severity

slot_ts_enable_xo2() logged debug output to info instead of debug, so
fix this up.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge: split off CI (common interface) from ddbridge-core
Daniel Scheller [Sun, 15 Oct 2017 20:51:52 +0000 (16:51 -0400)]
media: ddbridge: split off CI (common interface) from ddbridge-core

Move all CI device support related code from ddbridge-core to ddbridge-ci,
following the previously split off MaxS4/8 support.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge: fixup checkpatch-strict issues
Daniel Scheller [Sun, 15 Oct 2017 20:51:51 +0000 (16:51 -0400)]
media: ddbridge: fixup checkpatch-strict issues

Fixes several alignment, braces, space-before-cast, camelcase et al issues
reported by checkpatch --strict, plus a few more checkpatch didn't report.

Three checks are left after this though:
- one CamelCase in ddbridge-core, related to defines/vars/enums referenced
  from the stv090x demod driver
- one macro argument reuse in ddbridge-core aswell
- one unbalanced braces around else in ddbridge-main, which is due to
  #ifdefs related to CONFIG_PCI_MSI, which preferrably should be kept
  as-is for readability.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge: remove unneeded *fe vars from attach functions
Daniel Scheller [Sun, 15 Oct 2017 20:51:50 +0000 (16:51 -0400)]
media: ddbridge: remove unneeded *fe vars from attach functions

These are only used in C/T demod attach functions, don't add any real
benefit (ie. line length savings) and in case of cxd28xx_attach aren't
even used consequently. Remove them.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: mxl5xx: fix tuning logic
Mauro Carvalho Chehab [Sun, 15 Oct 2017 18:54:52 +0000 (14:54 -0400)]
media:  mxl5xx: fix tuning logic

The tuning logic is broken with regards to status report:
it relies on a previously-cached value that may not be valid
if re-tuned.

Change the logic to always read the status.

Acked-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dt-bindings: media: xilinx: fix typo in example
Akinobu Mita [Thu, 12 Oct 2017 16:03:34 +0000 (12:03 -0400)]
media: dt-bindings: media: xilinx: fix typo in example

Fix typo s/:/;/

Cc: Rob Herring <robh+dt@kernel.org>
Cc: Hyun Kwon <hyun.kwon@xilinx.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx25840: fix a possible divide by zero in set_fmt callback
Maciej S. Szmigiero [Tue, 10 Oct 2017 21:35:37 +0000 (17:35 -0400)]
media: cx25840: fix a possible divide by zero in set_fmt callback

If set_fmt callback is called with format->width or format->height set to
zero and HACTIVE_CNT or VACTIVE_CNT bits (respectively) in chip are zero
we will divide by zero later in this callback when we try to calculate
HSC or VSC values.

Fix this by explicitly rejecting these values.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: cx25840: describe standard for 0b1100 value in AFD_FMT_STAT bits
Maciej S. Szmigiero [Tue, 10 Oct 2017 21:34:58 +0000 (17:34 -0400)]
media: cx25840: describe standard for 0b1100 value in AFD_FMT_STAT bits

A 0b1100 value in 4 LSBs of "General Status 1" register (AFD_FMT_STAT) has
known meaning for CX2584x-series chips - it means that a SECAM signal is
currently detected by the chip.

Use this opportunity to also fix wrong binary values that were present
as comments attached to some entries in an array where
chip register -> V4L2 standard mappings are stored.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: imx-csi: fix burst size
Russell King [Fri, 29 Sep 2017 21:41:59 +0000 (17:41 -0400)]
media: imx-csi: fix burst size

Setting a burst size of "8" doesn't work for IMX219 with 8-bit bayer,
but a burst size of "16" does.  Fix this.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: staging/imx: fix complete handler
Russell King [Fri, 29 Sep 2017 21:38:39 +0000 (17:38 -0400)]
media: staging/imx: fix complete handler

The complete handler walks all entities, expecting to find an imx
subdevice for each and every entity.

However, camera drivers such as smiapp can themselves contain multiple
entities, for which there will not be an imx subdevice.  This causes
imx_media_find_subdev_by_sd() to fail, making the imx capture system
unusable with such cameras.

Work around this by killing the error entirely, thereby allowing
the imx capture to be used with such cameras.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-usb-v2: lmedm04: move ts2020 attach to dm04_lme2510_tuner
Malcolm Priestley [Tue, 26 Sep 2017 21:10:21 +0000 (17:10 -0400)]
media: dvb-usb-v2: lmedm04: move ts2020 attach to dm04_lme2510_tuner

When the tuner was split from m88rs2000 the attach function is in wrong
place.

Move to dm04_lme2510_tuner to trap errors on failure and removing
a call to lme_coldreset.

Prevents driver starting up without any tuner connected.

Fixes to trap for ts2020 fail.
LME2510(C): FE Found M88RS2000
ts2020: probe of 0-0060 failed with error -11
...
LME2510(C): TUN Found RS2000 tuner
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] PREEMPT SMP KASAN

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-usb-v2: lmedm04: Improve logic checking of warm start
Malcolm Priestley [Tue, 26 Sep 2017 21:10:20 +0000 (17:10 -0400)]
media: dvb-usb-v2: lmedm04: Improve logic checking of warm start

Warm start has no check as whether a genuine device has
connected and proceeds to next execution path.

Check device should read 0x47 at offset of 2 on USB descriptor read
and it is the amount requested of 6 bytes.

Fix for
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access as

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: siano: add SPDX markups
Mauro Carvalho Chehab [Fri, 1 Dec 2017 13:47:13 +0000 (08:47 -0500)]
media: siano: add SPDX markups

As we're now using SPDX identifiers, add the proper SPDX,
better identifying the licenses whith apply to the source code.

As we're now using the short license, it doesn't make sense to
keep the original license text.

Also, fix MODULE_LICENSE to properly identify GPL v2
at the Siano's common driver. Some codes there are licensed
on GPL v2 or latter, while others are GPL v2 only. So,
in order to reflect the common license that applies to
everything, the module itself should be GPLv2 only.

While here, use the Kernel's coding style for the comments
with copyright info.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: i2c: add SPDX identifiers to the code I wrote
Mauro Carvalho Chehab [Fri, 1 Dec 2017 13:47:12 +0000 (08:47 -0500)]
media: i2c: add SPDX identifiers to the code I wrote

As we're now using SPDX identifiers, on the several
media drivers I wrote, add the proper SPDX, identifying
the license I meant.

As we're now using the short license, it doesn't make sense to
keep the original license text.

Also, fix MODULE_LICENSE to properly identify GPL v2.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc keymaps: add SPDX identifiers to the code I wrote
Mauro Carvalho Chehab [Fri, 1 Dec 2017 13:47:11 +0000 (08:47 -0500)]
media: rc keymaps: add SPDX identifiers to the code I wrote

As we're now using SPDX identifiers, on the several
RC keymap files I wrote, add the proper SPDX, identifying
the license I meant.

As we're now using the short license, it doesn't make sense to
keep the original license text.

Also, fix MODULE_LICENSE to identify GPL v2, as this is the
minimal license requirement for those modles.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: usb: add SPDX identifiers to some code I wrote
Mauro Carvalho Chehab [Fri, 1 Dec 2017 13:47:10 +0000 (08:47 -0500)]
media: usb: add SPDX identifiers to some code I wrote

As we're now using SPDX identifiers, on several
media drivers I wrote, add the proper SPDX, identifying
the license I meant.

As we're now using the short license, it doesn't make sense to
keep the original license text.

Also, fix MODULE_LICENSE to properly identify GPL v2.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tuners: add SPDX identifiers to the code I wrote
Mauro Carvalho Chehab [Fri, 1 Dec 2017 13:47:09 +0000 (08:47 -0500)]
media: tuners: add SPDX identifiers to the code I wrote

As we're now using SPDX identifiers, on the several
media drivers I wrote, add the proper SPDX, identifying
the license I meant.

As we're now using the short license, it doesn't make sense to
keep the original license text.

Also, fix MODULE_LICENSE to properly identify GPL v2.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: add SPDX identifiers to the code I wrote
Mauro Carvalho Chehab [Fri, 1 Dec 2017 13:47:08 +0000 (08:47 -0500)]
media: rc: add SPDX identifiers to the code I wrote

As we're now using SPDX identifiers, on the several
media drivers I wrote, add the proper SPDX, identifying
the license I meant.

As we're now using the short license, it doesn't make sense to
keep the original license text.

Also, fix MODULE_LICENSE to properly identify GPL v2.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: uvcvideo: Stream error events carry no data
Laurent Pinchart [Tue, 17 Oct 2017 17:15:54 +0000 (13:15 -0400)]
media: uvcvideo: Stream error events carry no data

According to the UVC specification, stream error events carry no data.
Fix a buffer overflow (that should be harmless given data alignment)
when reporting the stream error event by removing the data byte from the
message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: uvcvideo: Mark buffer error where overflow
Baoyou Xie [Thu, 7 Sep 2017 02:59:48 +0000 (22:59 -0400)]
media: uvcvideo: Mark buffer error where overflow

Some cameras post inaccurate frame where next frame data overlap
it. this results in screen flicker, and it need to be prevented.

So this patch marks the buffer error to discard the frame where
buffer overflow.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>