platform/kernel/linux-rpi.git
6 years agomedia: staging/imx: remove static media link arrays
Steve Longerbeam [Fri, 15 Dec 2017 01:04:40 +0000 (20:04 -0500)]
media: staging/imx: remove static media link arrays

Remove the static list of media links that were formed at probe time.
These links can instead be created after all registered async subdevices
have been bound in imx_media_probe_complete().

The media links between subdevices that exist in the device tree, can
be created post-async completion by using v4l2_fwnode_parse_link() for
each endpoint node of that subdevice. Note this approach assumes
device-tree ports are equivalent to media pads (pad index equals
port id), and that device-tree endpoints are equivalent to media
links between pads.

Because links are no longer parsed by imx_media_of_parse(), its sole
function is now only to add subdevices that it encounters by walking
the OF graph to the async list, so the function has been renamed
imx_media_add_of_subdevs().

Similarly, the media links between the IPU-internal subdevice pads (the
CSI source pads, and all pads between the vdic, ic-prp, ic-prpenc, and
ic-prpvf subdevices), can be created post-async completion by looping
through the subdevice's media pads and using the const internal_subdev
table.

Because links are no longer parsed by imx_media_add_internal_subdevs(),
this function no longer needs an array of CSI subdevs to form links
from.

In summary, the following functions, which were used to form a list
of media links at probe time, are removed:

imx_media_add_pad_link()
add_internal_links()
of_add_pad_link()

replaced by these functions, called at probe time, which only populate
the async subdev list:

imx_media_add_of_subdevs()
imx_media_add_internal_subdevs()

and these functions, called at async completion, which create the
media links:

imx_media_create_of_links()
imx_media_create_csi_of_links()
imx_media_create_internal_links()

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: staging/imx: get CSI bus type from nearest upstream entity
Steve Longerbeam [Fri, 15 Dec 2017 01:04:39 +0000 (20:04 -0500)]
media: staging/imx: get CSI bus type from nearest upstream entity

The imx-media driver currently supports a device tree graph of
limited complexity. This patch is a first step in allowing imx-media
to work with more general OF graphs.

The CSI subdevice assumes the originating upstream subdevice (the
"sensor") is connected directly to either the CSI mux or the MIPI
CSI-2 receiver. But for more complex graphs, the sensor can be distant,
with possible bridge entities in between. Thus the sensor's bus type
could be quite different from what is entering the CSI. For example
a distant sensor could have a parallel interface, but the stream
entering the i.MX is MIPI CSI-2.

To remove this assumption, get the entering bus config from the entity
that is directly upstream from either the CSI mux, or the CSI-2 receiver.
If the CSI-2 receiver is not in the enabled pipeline, the bus type to the
CSI is parallel, otherwise the CSI is receiving MIPI CSI-2.

Note that we can't use the direct upstream source connected to CSI
(which is either the CSI mux or the CSI-2 receiver) to determine
bus type. The bus entering the CSI from the CSI-2 receiver is a 32-bit
parallel bus containing the demultiplexed MIPI CSI-2 virtual channels.
But the CSI and its IDMAC channels must be configured based on whether
it is receiving data from the CSI-2 receiver or from the CSI mux's
parallel interface pins.

The function csi_get_upstream_endpoint() is used to find this
endpoint. It makes use of a new utility function
imx_media_find_upstream_pad(), that if given a grp_id of 0, will
return the closest upstream pad from start_entity.

With these changes, imx_media_find_sensor() is no longer used and
is removed. As a result there is also no longer a need to identify
any sensor or set the sensor subdev's group id as a method to search
for it. So IMX_MEDIA_GRP_ID_SENSOR is removed. Also the video-mux group
id IMX_MEDIA_GRP_ID_VIDMUX was never used so that is removed as well.
The remaining IMX_MEDIA_GRP_ID_* definitions are entities internal
to the i.MX.

Another use of imx_media_find_sensor() in the CSI was to call the
sensor's g_skip_frames op to determine if a delay was needed before
enabling the CSI at stream on. If necessary this will have to be
re-addressed at a later time.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb-frontends: fix i2c access helpers for KASAN
Arnd Bergmann [Thu, 30 Nov 2017 16:55:46 +0000 (11:55 -0500)]
media: dvb-frontends: fix i2c access helpers for KASAN

A typical code fragment was copied across many dvb-frontend drivers and
causes large stack frames when built with with CONFIG_KASAN on gcc-5/6/7:

drivers/media/dvb-frontends/cxd2841er.c:3225:1: error: the frame size of 3992 bytes is larger than 3072 bytes [-Werror=frame-larger-than=]
drivers/media/dvb-frontends/cxd2841er.c:3404:1: error: the frame size of 3136 bytes is larger than 3072 bytes [-Werror=frame-larger-than=]
drivers/media/dvb-frontends/stv0367.c:3143:1: error: the frame size of 4016 bytes is larger than 3072 bytes [-Werror=frame-larger-than=]
drivers/media/dvb-frontends/stv090x.c:3430:1: error: the frame size of 5312 bytes is larger than 3072 bytes [-Werror=frame-larger-than=]
drivers/media/dvb-frontends/stv090x.c:4248:1: error: the frame size of 4872 bytes is larger than 3072 bytes [-Werror=frame-larger-than=]

gcc-8 now solves this by consolidating the stack slots for the argument
variables, but on older compilers we can get the same behavior by taking
the pointer of a local variable rather than the inline function argument.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715
Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: r820t: fix r820t_write_reg for KASAN
Arnd Bergmann [Thu, 30 Nov 2017 11:08:05 +0000 (06:08 -0500)]
media: r820t: fix r820t_write_reg for KASAN

With CONFIG_KASAN, we get an overly long stack frame due to inlining
the register access functions:

drivers/media/tuners/r820t.c: In function 'generic_set_freq.isra.7':
drivers/media/tuners/r820t.c:1334:1: error: the frame size of 2880 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]

This is caused by a gcc bug that has now been fixed in gcc-8.
To work around the problem, we can pass the register data
through a local variable that older gcc versions can optimize
out as well.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: pxa_camera: rename the soc_camera_ prefix to pxa_camera_
Hans Verkuil [Wed, 13 Dec 2017 10:19:03 +0000 (05:19 -0500)]
media: pxa_camera: rename the soc_camera_ prefix to pxa_camera_

Rename soc_camera to pxa_camera as this has no longer anything to do with the old
soc_camera driver/framework. It's confusing when grepping on soc_camera.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: vidioc-g-dv-timings.rst: fix typo (frontporch -> backporch)
Hans Verkuil [Wed, 13 Dec 2017 09:54:04 +0000 (04:54 -0500)]
media: vidioc-g-dv-timings.rst: fix typo (frontporch -> backporch)

The description of V4L2_DV_FL_HALF_LINE mixed up frontporch with backporch.

It's the backporch that has different sizes for interlaced formats, the frontporch
remains constant.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: staging/cxd2099: cosmetics: improve strings
Daniel Scheller [Tue, 12 Dec 2017 18:46:57 +0000 (13:46 -0500)]
media: staging/cxd2099: cosmetics: improve strings

Prefix dev_*() I2C address prints with 0x, change CXD2099 to CXD2099AR,
change the MODULE_DESCRIPTION to a proper one and have a better (and
shorter) description for the buffermode modparam.

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>
6 years agomedia: staging/cxd2099: fix debug message severity
Daniel Scheller [Tue, 12 Dec 2017 18:46:56 +0000 (13:46 -0500)]
media: staging/cxd2099: fix debug message severity

Debug messages should go to KERN_DEBUG, thus change the slot_shutdown()
notice from dev_info() to dev_dbg().

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>
6 years agomedia: staging/cxd2099: fix remaining checkpatch-strict issues
Daniel Scheller [Tue, 12 Dec 2017 18:46:55 +0000 (13:46 -0500)]
media: staging/cxd2099: fix remaining checkpatch-strict issues

Fix up all remaining cosmetic issues as reported by checkpatch.pl.

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>
6 years agomedia: [RESEND] media: dvb-frontends: Add delay to Si2168 restart
Ron Economos [Tue, 12 Dec 2017 00:51:53 +0000 (19:51 -0500)]
media: [RESEND] media: dvb-frontends: Add delay to Si2168 restart

On faster CPUs a delay is required after the resume command and the restart command. Without the delay, the restart command often returns -EREMOTEIO and the Si2168 does not restart.

Note that this patch fixes the same issue as https://patchwork.linuxtv.org/patch/44304/, but I believe my udelay() fix addresses the actual problem.

Signed-off-by: Ron Economos <w6rz@comcast.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: ddbridge: stv09xx: detach frontends on lnb failure
Daniel Scheller [Mon, 11 Dec 2017 20:12:49 +0000 (15:12 -0500)]
media: ddbridge: stv09xx: detach frontends on lnb failure

While the failure handling in dvb_input_attach() has been improved lately
so any tuner failure won't result in demod driver modules with a
usecount > 0 anymore (thus requiring rmmod -f), there's still an issue
with stv090x and stv0910 based tuner modules, in that LNB driver attach
failures leave an attached demod frontend driver behind which have a
usecount of > 0 in this failure case, due to them not being detached/
released. Fix this by detaching the demod frontends if the LNB driver
fails.

Richard tested and verified the changes with STV0910 hardware, thus adding
his Tested-by.

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: tuners: tda8290: reduce stack usage with kasan
Arnd Bergmann [Mon, 11 Dec 2017 12:06:04 +0000 (07:06 -0500)]
media: tuners: tda8290: reduce stack usage with kasan

With CONFIG_KASAN enabled, we get a relatively large stack frame in one function

drivers/media/tuners/tda8290.c: In function 'tda8290_set_params':
drivers/media/tuners/tda8290.c:310:1: warning: the frame size of 1520 bytes is larger than 1024 bytes [-Wframe-larger-than=]

With CONFIG_KASAN_EXTRA this goes up to

drivers/media/tuners/tda8290.c: In function 'tda8290_set_params':
drivers/media/tuners/tda8290.c:310:1: error: the frame size of 3200 bytes is larger than 3072 bytes [-Werror=frame-larger-than=]

We can significantly reduce this by marking local arrays as 'static const', and
this should result in better compiled code for everyone.

[mchehab@s-opensource.com: fix a trivial merge conflict]
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: RC docs: add enum rc_proto description at the docs
Mauro Carvalho Chehab [Thu, 30 Nov 2017 13:00:45 +0000 (08:00 -0500)]
media: RC docs: add enum rc_proto description at the docs

This is part of the uAPI. Add it to the documentation again,
and fix cross-references.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Acked-by: Sean Young <sean@mess.org>
6 years agomedia: cec: move cec autorepeat handling to rc-core
Sean Young [Thu, 23 Nov 2017 22:37:10 +0000 (17:37 -0500)]
media: cec: move cec autorepeat handling to rc-core

CEC autorepeat is different than other protocols. Autorepeat is triggered
by the first repeated user control pressed CEC message, rather than a
fixed REP_DELAY.

This change also does away with the KEY_UP event directly after the first
KEY_DOWN event, which was used to stop autorepeat from starting.

See commit a9a249a2c997 ("media: cec: fix remote control passthrough")
for the original change.

Acked-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>
6 years agomedia: imon: auto-config ffdc 30 device
Sean Young [Tue, 21 Nov 2017 20:51:39 +0000 (15:51 -0500)]
media: imon: auto-config ffdc 30 device

Another device with the 0xffdc device id, this one with 0x30 in the
config byte. Its an iMON VFD + iMON IR (it does not understand rc6).

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: winbond-cir: Fix pnp_irq's error checking for wbcir_probe
Arvind Yadav [Thu, 16 Nov 2017 04:37:51 +0000 (23:37 -0500)]
media: winbond-cir: Fix pnp_irq's error checking for wbcir_probe

The pnp_irq() function returns -1 if an error occurs.
pnp_irq() error checking for zero is not correct.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: Replace timeval with ktime_t in imon.c
Chunyan Zhang [Mon, 6 Nov 2017 14:06:10 +0000 (09:06 -0500)]
media: rc: Replace timeval with ktime_t in imon.c

This patch changes the 32-bit time type (timeval) to the 64-bit one
(ktime_t), since 32-bit time types will break in the year 2038.

I use ktime_t instead of all uses of timeval in imon.c

This patch also changes do_gettimeofday() to ktime_get() accordingly,
since ktime_get returns a ktime_t, but do_gettimeofday returns a
struct timeval, and the other reason is that ktime_get() uses
the monotonic clock.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: improve locking
Sean Young [Sat, 4 Nov 2017 12:30:45 +0000 (08:30 -0400)]
media: lirc: improve locking

Once rc_unregister_device() has been called, no driver function
should be called.

This prevents some nasty race conditions with an ioctl calls
driver functions when the driver specific data has been freed.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: allow lirc device to be opened more than once
Sean Young [Thu, 2 Nov 2017 21:21:13 +0000 (17:21 -0400)]
media: lirc: allow lirc device to be opened more than once

This makes it possible for lircd to read from a lirc chardev, and not
keep it busy.

Note that this changes the default for timeout reports to on. lircd
already enables timeout reports when it opens a lirc device, leaving
them on until the next reboot.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: include <uapi/linux/lirc.h> rather than <media/lirc.h>
Sean Young [Thu, 2 Nov 2017 20:44:21 +0000 (16:44 -0400)]
media: rc: include <uapi/linux/lirc.h> rather than <media/lirc.h>

This removes the need for include/media/lirc.h, which just includes
the uapi file.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: move ir-lirc-codec.c contents into lirc_dev.c
Sean Young [Thu, 2 Nov 2017 20:39:16 +0000 (16:39 -0400)]
media: rc: move ir-lirc-codec.c contents into lirc_dev.c

Since removing the lirc kapi, ir-lirc-codec.c only contains lirc fops
so the file name is no longer correct. By moving its content into
lirc_dev.c the ugly extern struct lirc_fops is not longer needed,
and everything lirc related is in one file.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agokfifo: DECLARE_KIFO_PTR(fifo, u64) does not work on arm 32 bit
Sean Young [Sun, 8 Oct 2017 16:12:16 +0000 (12:12 -0400)]
kfifo: DECLARE_KIFO_PTR(fifo, u64) does not work on arm 32 bit

If you try to store u64 in a kfifo (or a struct with u64 members),
then the buf member of __STRUCT_KFIFO_PTR will cause 4 bytes
padding due to alignment (note that struct __kfifo is 20 bytes
on 32 bit).

That in turn causes the __is_kfifo_ptr() to fail, which is caught
by kfifo_alloc(), which now returns EINVAL.

So, ensure that __is_kfifo_ptr() compares to the right structure.

Signed-off-by: Sean Young <sean@mess.org>
Acked-by: Stefani Seibold <stefani@seibold.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: scancode rc devices should have a lirc device too
Sean Young [Sun, 24 Sep 2017 16:43:24 +0000 (12:43 -0400)]
media: lirc: scancode rc devices should have a lirc device too

Now that the lirc interface supports scancodes, RC scancode devices
can also have a lirc device. The only receiving feature they will have
enabled is LIRC_CAN_REC_SCANCODE.

Note that CEC devices have no lirc device, since they can be controlled
from their /dev/cecN chardev.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: document LIRC_MODE_SCANCODE
Sean Young [Sat, 25 Feb 2017 11:51:34 +0000 (06:51 -0500)]
media: lirc: document LIRC_MODE_SCANCODE

Lirc supports a new mode which requires documentation.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: ensure lirc device receives nec repeats
Sean Young [Sat, 30 Sep 2017 11:13:37 +0000 (07:13 -0400)]
media: lirc: ensure lirc device receives nec repeats

The lirc device should get lirc repeats whether there is a keymap
match or not.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: implement reading scancode
Sean Young [Sat, 25 Feb 2017 11:51:32 +0000 (06:51 -0500)]
media: lirc: implement reading scancode

This implements LIRC_MODE_SCANCODE reading from the lirc device. The
scancode can be read from the input device too, but with this interface
you get the rc protocol, keycode, toggle and repeat status in addition
to just the scancode.

int main()
{
int fd, mode, rc;
fd = open("/dev/lirc0", O_RDWR);

mode = LIRC_MODE_SCANCODE;
if (ioctl(fd, LIRC_SET_REC_MODE, &mode)) {
// kernel too old or lirc does not support transmit
}
struct lirc_scancode scancode;
while (read(fd, &scancode, sizeof(scancode)) == sizeof(scancode)) {
printf("protocol:%d scancode:0x%x toggle:%d repeat:%d\n",
scancode.rc_proto, scancode.scancode,
!!(scancode.flags & LIRC_SCANCODE_FLAG_TOGGLE),
!!(scancode.flags & LIRC_SCANCODE_FLAG_REPEAT));
}
close(fd);
}

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: remove last remnants of lirc kapi
Sean Young [Tue, 26 Sep 2017 13:34:47 +0000 (09:34 -0400)]
media: lirc: remove last remnants of lirc kapi

rc-core has replaced the lirc kapi many years ago, and now with the last
driver ported to rc-core, we can finally remove it.

Note this has no effect on userspace.

All future IR drivers should use the rc-core api.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: remove name from lirc_dev
Sean Young [Tue, 26 Sep 2017 11:56:39 +0000 (07:56 -0400)]
media: lirc: remove name from lirc_dev

This is a duplicate of rcdev->driver_name.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: create rc-core open and close lirc functions
Sean Young [Tue, 26 Sep 2017 11:44:20 +0000 (07:44 -0400)]
media: lirc: create rc-core open and close lirc functions

Replace the generic kernel lirc api with ones which use rc-core, further
reducing the lirc_dev members.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: do not call close() or open() on unregistered devices
Sean Young [Sat, 23 Sep 2017 21:44:03 +0000 (17:44 -0400)]
media: lirc: do not call close() or open() on unregistered devices

If a lirc chardev is held open after a device is unplugged, rc_close()
will be called after rc_unregister_device(). The driver is not expecting
any calls at this point, and the iguanair driver causes an oops in
this scenario.

rc_open() can be called when the device is removed too, by calling open
on the chardev whilst the device is being removed.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: move lirc_dev->attached to rc_dev->registered
Sean Young [Tue, 26 Sep 2017 11:31:29 +0000 (07:31 -0400)]
media: lirc: move lirc_dev->attached to rc_dev->registered

This is done to further remove the lirc kernel api. Ensure that every
fops checks for this.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: use kfifo rather than lirc_buffer for raw IR
Sean Young [Sat, 23 Sep 2017 18:44:18 +0000 (14:44 -0400)]
media: lirc: use kfifo rather than lirc_buffer for raw IR

Since the only mode lirc devices can handle is raw IR, handle this
in a plain kfifo.

Remove lirc_buffer since this is no longer needed.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: merge lirc_dev_fop_ioctl and ir_lirc_ioctl
Sean Young [Sat, 23 Sep 2017 16:05:59 +0000 (12:05 -0400)]
media: lirc: merge lirc_dev_fop_ioctl and ir_lirc_ioctl

Calculate lirc features when necessary, and add LIRC_{S,G}ET_REC_MODE
cases to ir_lirc_ioctl.

This makes lirc_dev_fop_ioctl() unnecessary since all cases are
already handled by ir_lirc_ioctl().

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: document and fix rc_validate_scancode()
Sean Young [Mon, 9 Oct 2017 20:32:41 +0000 (16:32 -0400)]
media: rc: document and fix rc_validate_scancode()

For some IR protocols, some scancode values not valid, i.e. they're part
of a different protocol variant.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: validate scancode for transmit
Sean Young [Wed, 27 Sep 2017 20:00:49 +0000 (16:00 -0400)]
media: lirc: validate scancode for transmit

Ensure we reject an attempt to transmit invalid scancodes.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: lirc interface should not be a raw decoder
Sean Young [Sat, 23 Sep 2017 14:41:13 +0000 (10:41 -0400)]
media: lirc: lirc interface should not be a raw decoder

The lirc user interface exists as a raw decoder, which does not make
much sense for transmit-only devices.

In addition, we want to have lirc char devices for devices which do not
use raw IR, i.e. scancode only devices.

Note that rc-code, lirc_dev, ir-lirc-codec are now calling functions of
each other, so they've been merged into one module rc-core to avoid
circular dependencies.

Since ir-lirc-codec no longer exists as separate codec module, there is no
need for RC_DRIVER_IR_RAW_TX type drivers to call ir_raw_event_register().

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: auto load encoder if necessary
Sean Young [Sat, 25 Feb 2017 11:51:31 +0000 (06:51 -0500)]
media: rc: auto load encoder if necessary

When sending scancodes, load the encoder if we need it.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: use the correct carrier for scancode transmit
Sean Young [Sat, 25 Feb 2017 11:51:30 +0000 (06:51 -0500)]
media: lirc: use the correct carrier for scancode transmit

If the lirc device supports it, set the carrier for the protocol.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: implement scancode sending
Sean Young [Sat, 25 Feb 2017 11:51:29 +0000 (06:51 -0500)]
media: lirc: implement scancode sending

This introduces a new lirc mode: scancode. Any device which can send raw IR
can now also send scancodes.

int main()
{
int mode, fd = open("/dev/lirc0", O_RDWR);

        mode = LIRC_MODE_SCANCODE;
if (ioctl(fd, LIRC_SET_SEND_MODE, &mode)) {
// kernel too old or lirc does not support transmit
}
struct lirc_scancode scancode = {
.scancode = 0x1e3d,
.rc_proto = RC_PROTO_RC5,
};
write(fd, &scancode, sizeof(scancode));
close(fd);
}

The other fields of lirc_scancode must be set to 0.

Note that toggle (rc5, rc6) and repeats (nec) are not implemented. Nor is
there a method for holding down a key for a period.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: lirc: remove LIRCCODE and LIRC_GET_LENGTH
Sean Young [Thu, 8 Jun 2017 09:10:41 +0000 (05:10 -0400)]
media: lirc: remove LIRCCODE and LIRC_GET_LENGTH

LIRCCODE is a lirc mode where a driver produces driver-dependent
codes for receive and transmit. No driver uses this any more. The
LIRC_GET_LENGTH ioctl was used for this mode only.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: MAINTAINERS: remove lirc staging area
Sean Young [Thu, 28 Sep 2017 14:40:45 +0000 (10:40 -0400)]
media: MAINTAINERS: remove lirc staging area

Now that lirc is no longer in the staging area, remove the entry.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: staging: remove lirc_zilog driver
Sean Young [Tue, 24 Oct 2017 18:59:31 +0000 (14:59 -0400)]
media: staging: remove lirc_zilog driver

The ir-kbd-i2c driver behaves like the lirc_zilog driver, except it can
send raw IR and receives scancodes rather than lirccodes.

The lirc_zilog driver only polls if the lirc chardev is opened;
similarly the ir-kbd-i2c driver only polls if the corresponding input
device is opened, or the lirc device.

Polling is disabled during IR transmission through the mutex.

The polling period is 402ms in the ir-kdb-i2c driver, and 260ms in the
lirc_zilog driver.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: i2c: enable i2c IR for hardware which isn't HD-PVR
Sean Young [Tue, 24 Oct 2017 21:04:16 +0000 (17:04 -0400)]
media: i2c: enable i2c IR for hardware which isn't HD-PVR

This is a fix for commit 329d88da4df9 ("[media] media: i2c: Don't export
ir-kbd-i2c module alias") that stopped the module from being loaded
automagically.

The problems described only affect the HD-PVR, so it should not affect
other hardware; also if the module happens to be loaded, the i2c IR
part of the HD-PVR will be enabled anyway.

Fixes: 329d88da4df9 ("[media] media: i2c: Don't export ir-kbd-i2c module alias")

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc: implement zilog transmitter
Sean Young [Sat, 21 Oct 2017 12:16:47 +0000 (08:16 -0400)]
media: rc: implement zilog transmitter

This code implements the transmitter which is currently implemented
in the staging lirc_zilog driver.

The new code does not need a signal database, iow. the
haup-ir-blaster.bin firmware file is no longer needed, and the driver
does not know anything about the keycodes in that file.

Instead, the new driver can send raw IR, but the hardware is limited
to few different lengths of pulse and spaces, so it is best to use
generated IR rather than recorded IR.

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