platform/kernel/linux-starfive.git
6 years agomedia: coda: allocate space for mpeg4 decoder mvcol buffer
Philipp Zabel [Thu, 7 Dec 2017 14:59:50 +0000 (09:59 -0500)]
media: coda: allocate space for mpeg4 decoder mvcol buffer

The MPEG-4 decoder mvcol buffer was registered, but its size not added
to a frame buffer allocation. This could cause the decoder to write past
the end of the allocated buffer for large frame sizes.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: coda: round up frame sizes to multiples of 16 for MPEG-4 decoder
Philipp Zabel [Thu, 7 Dec 2017 14:59:49 +0000 (09:59 -0500)]
media: coda: round up frame sizes to multiples of 16 for MPEG-4 decoder

We need internal frames to be rounded up to full macroblocks for MPEG-4
decoding as well.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: coda: fix capture TRY_FMT for YUYV with non-MB-aligned widths
Philipp Zabel [Thu, 7 Dec 2017 11:11:11 +0000 (06:11 -0500)]
media: coda: fix capture TRY_FMT for YUYV with non-MB-aligned widths

Since bytesperline always fulfills VDOA width requirements, detile the
whole buffer instead of limiting to visible width. This stops TRY_FMT
from returning -EINVAL for YUYV capture buffers that are not a multiple
of 16 wide.

An alternative would be to always round up width to stride, as we report
the valid image rectange via G_SELECTION (V4L2_SEL_TGT_COMPOSE_DEFAULT),
but that would require all applications to handle the compose default
rectangle properly.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: coda: set min_buffers_needed
Lucas Stach [Thu, 7 Dec 2017 11:09:46 +0000 (06:09 -0500)]
media: coda: set min_buffers_needed

The current driver implementation expects at least one buffer on
all queues to start streaming. Properly signal this to the vb2
core, to avoid confusion when streamon is racing with qbuf.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: pxa_camera: disable and unprepare the clock source on error
Flavio Ceolin [Wed, 6 Dec 2017 16:38:50 +0000 (11:38 -0500)]
media: pxa_camera: disable and unprepare the clock source on error

pxa_camera_probe() was not calling pxa_camera_deactivate(),
responsible to call clk_disable_unprepare(), on the failure path. This
was leading to unbalancing source clock.

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

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l: sh_mobile_ceu: Return buffers on streamoff()
Jacopo Mondi [Wed, 15 Nov 2017 17:59:12 +0000 (12:59 -0500)]
media: v4l: sh_mobile_ceu: Return buffers on streamoff()

videobuf2 core reports an error when not all buffers have been returned
to the framework:

drivers/media/v4l2-core/videobuf2-core.c:1651
WARN_ON(atomic_read(&q->owned_by_drv_count))

Fix this returning all buffers currently in capture queue.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: vb2-core: fix descriptions for VB2-only functions
Mauro Carvalho Chehab [Mon, 9 Oct 2017 09:31:49 +0000 (05:31 -0400)]
media: vb2-core: fix descriptions for VB2-only functions

When we split VB2 into an independent streaming module and
a V4L2 one, some vb2-core functions started to have a wrong
description: they're meant to be used only by the API-specific
parts of VB2, like vb2-v4l2, as the functions that V4L2 drivers
should use are all under videobuf2-v4l2.h.

Correct their descriptions.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-subdev: convert frame description to enum
Mauro Carvalho Chehab [Thu, 5 Oct 2017 20:32:30 +0000 (16:32 -0400)]
media: v4l2-subdev: convert frame description to enum

As kernel-doc doesn't support documenting #define values,
and using enum makes easier to identify where the values
are used, convert V4L2_MBUS_FRAME_DESC_FL_* to enum, and
use BIT() macro.

While here, fix the description at v4l2_mbus_frame_desc_entry,
in order to match what's described for
V4L2_MBUS_FRAME_DESC_FL_LEN_MAX.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-subdev: better document IO pin configuration flags
Mauro Carvalho Chehab [Thu, 5 Oct 2017 20:17:27 +0000 (16:17 -0400)]
media: v4l2-subdev: better document IO pin configuration flags

Convert V4L2_SUBDEV_IO_PIN_* to enums, use BIT() and document
via kernel-doc.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-subdev: fix a typo
Mauro Carvalho Chehab [Fri, 6 Oct 2017 13:54:05 +0000 (09:54 -0400)]
media: v4l2-subdev: fix a typo

ownner -> owner

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-tpg: use __u16 instead of int for struct tpg_rbg_color16
Mauro Carvalho Chehab [Mon, 9 Oct 2017 10:20:48 +0000 (06:20 -0400)]
media: v4l2-tpg: use __u16 instead of int for struct tpg_rbg_color16

Despite the struct says "color16", it was actually using 32 bits
for each color. Fix it.

Suggested-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-tpg.h: rename color structs
Mauro Carvalho Chehab [Mon, 9 Oct 2017 10:10:28 +0000 (06:10 -0400)]
media: v4l2-tpg.h: rename color structs

The color structs right now are just "color" and "color16".
That may lead into conflicts, and don't define precisely what
they meant. As those are used by two drivers (vivid and vimc),
this is even on a somewhat public header!

So rename them to:
color ->  tpg_rbg_color8
color16 ->  tpg_rbg_color16

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-tpg*.h: move headers to include/media/tpg and merge them
Mauro Carvalho Chehab [Mon, 9 Oct 2017 10:02:25 +0000 (06:02 -0400)]
media: v4l2-tpg*.h: move headers to include/media/tpg and merge them

The v4l2-tpg*.h headers are meant to be used only internally by
vivid and vimc. There's no sense keeping them together with the
V4L2 kAPI headers. Also, one header includes the other as they're
meant to be used together. So, merge them.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: vb2: add cross references at memops and v4l2 kernel-doc markups
Mauro Carvalho Chehab [Mon, 9 Oct 2017 09:36:52 +0000 (05:36 -0400)]
media: vb2: add cross references at memops and v4l2 kernel-doc markups

Add cross-references where needed and add periods at the end of
each kernel-doc paragraph, in order to make it coherent with other
VB2 descriptions.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: vb2-core: document remaining functions
Mauro Carvalho Chehab [Sat, 7 Oct 2017 09:05:03 +0000 (05:05 -0400)]
media: vb2-core: document remaining functions

There are several VB2 core functions that aren't documented.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: vb2-core: Improve kernel-doc markups
Mauro Carvalho Chehab [Fri, 6 Oct 2017 16:22:43 +0000 (12:22 -0400)]
media: vb2-core: Improve kernel-doc markups

There are several issues on the current markups:
- lack of cross-references;
- wrong cross-references;
- lack of a period of the end of several phrases;
- Some descriptions can be enhanced.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: vb2-core: use bitops for bits
Mauro Carvalho Chehab [Fri, 6 Oct 2017 16:20:52 +0000 (12:20 -0400)]
media: vb2-core: use bitops for bits

Use the existing macros to identify vb2_io_modes bits.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-subdev: fix description of tuner.s_radio ops
Mauro Carvalho Chehab [Fri, 6 Oct 2017 13:50:28 +0000 (09:50 -0400)]
media: v4l2-subdev: fix description of tuner.s_radio ops

The description there is completely broken and it mentions
an ioctl that doesn't exist.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-subdev: create cross-references for ioctls
Mauro Carvalho Chehab [Thu, 5 Oct 2017 19:14:50 +0000 (15:14 -0400)]
media: v4l2-subdev: create cross-references for ioctls

When generating Sphinx output, create cross-references for the
callbacks for each ioctl.

While here, fix a few wrong names for ioctls.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-dev: document video_device flags
Mauro Carvalho Chehab [Thu, 5 Oct 2017 18:05:25 +0000 (14:05 -0400)]
media: v4l2-dev: document video_device flags

Convert #defines to enums and add kernel-doc markups for V4L2
video_device flags.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-dev: document VFL_DIR_* direction defines
Mauro Carvalho Chehab [Thu, 5 Oct 2017 17:52:19 +0000 (13:52 -0400)]
media: v4l2-dev: document VFL_DIR_* direction defines

The V4L_DIR_* direction flags document the direction for a
V4L2 device node. Convert them to enum and document.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: get rid of i2c-addr.h
Mauro Carvalho Chehab [Thu, 5 Oct 2017 13:56:39 +0000 (09:56 -0400)]
media: get rid of i2c-addr.h

In the past, the same I2C address were used on multiple places.
After I2C rebinding changes, this is no longer needed. So, we
can just get rid of this header, placing the I2C address where
they belong, e. g. either at bttv driver or at tvtuner.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: i2c-addr.h: get rid of now unused defines
Mauro Carvalho Chehab [Thu, 5 Oct 2017 13:49:26 +0000 (09:49 -0400)]
media: i2c-addr.h: get rid of now unused defines

Some of the previously used I2C addresses there aren't used
anymore. So, get rid of them.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-dev: convert VFL_TYPE_* into an enum
Mauro Carvalho Chehab [Thu, 28 Sep 2017 22:39:32 +0000 (18:39 -0400)]
media: v4l2-dev: convert VFL_TYPE_* into an enum

Using enums makes easier to document, as it can use kernel-doc
markups. It also allows cross-referencing, with increases the
kAPI readability.

Please notice that now cx88_querycap() has to have a default for
the VFL type, as there are more types than supported by the driver.

Acked-By: Mike Isely <isely@pobox.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-mediabus: use BIT() macro for flags
Mauro Carvalho Chehab [Thu, 28 Sep 2017 13:51:42 +0000 (09:51 -0400)]
media: v4l2-mediabus: use BIT() macro for flags

Instead of using (1 << n) for bits, use the BIT() macro,
as it makes a difference from documentation point of view.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-flash-led-class.h: add kernel-doc to two helper funcs
Mauro Carvalho Chehab [Thu, 28 Sep 2017 13:41:48 +0000 (09:41 -0400)]
media: v4l2-flash-led-class.h: add kernel-doc to two helper funcs

There are two helper functions at v4l2-flash-led-class.h
that aren't documented.

Document them.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-dev.h: add kernel-doc to two macros
Mauro Carvalho Chehab [Thu, 28 Sep 2017 13:34:54 +0000 (09:34 -0400)]
media: v4l2-dev.h: add kernel-doc to two macros

There are two macros at v4l2-dev.h that aren't documented.

Document them, for completeness.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-event.rst: improve events description
Mauro Carvalho Chehab [Fri, 22 Sep 2017 17:35:45 +0000 (13:35 -0400)]
media: v4l2-event.rst: improve events description

Both v4l2-event.rst and v4l2-event.h have an overview of
events, but there are some inconsistencies there:

- at v4l2-event, the event's ring buffer is called kevent. Its
  name is, instead, v4l2_kevent;

- Some things are mentioned on both places (with different words),
  others are either on one of the files.

In order to cleanup this mess, put everything at v4l2-event.rst
and improve it to be a little more coherent and to have cross
references.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: media-entity.h: add kernel-doc markups for nested structs
Mauro Carvalho Chehab [Wed, 27 Sep 2017 19:54:43 +0000 (15:54 -0400)]
media: media-entity.h: add kernel-doc markups for nested structs

Now that nested structs are parsed by kernel-doc, add markups
to them.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: videobuf2-core: improve kernel-doc markups
Mauro Carvalho Chehab [Wed, 27 Sep 2017 19:49:45 +0000 (15:49 -0400)]
media: videobuf2-core: improve kernel-doc markups

Now that nested structs are supported, change the
documentation to use it. While here, add cross-references
where pertinent and use monotonic fonts where pertinent,
using the right markup tags.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-ctrls: document nested members of structs
Mauro Carvalho Chehab [Wed, 27 Sep 2017 16:25:21 +0000 (12:25 -0400)]
media: v4l2-ctrls: document nested members of structs

There are a few nested members at v4l2-ctrls.h. Now that
kernel-doc supports, document them.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-fwnode.h: better describe bus union at fwnode endpoint struct
Mauro Carvalho Chehab [Wed, 27 Sep 2017 13:51:06 +0000 (09:51 -0400)]
media: v4l2-fwnode.h: better describe bus union at fwnode endpoint struct

Better document the bus union at struct v4l2_fwnode_endpoint.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc-core.h: minor adjustments at rc_driver_type doc
Mauro Carvalho Chehab [Sun, 24 Sep 2017 09:24:58 +0000 (05:24 -0400)]
media: rc-core.h: minor adjustments at rc_driver_type doc

The description of this enum doesn't match what it
actually represents. Adjust it.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: rc-core.rst: add an introduction for RC core
Mauro Carvalho Chehab [Sat, 23 Sep 2017 10:49:50 +0000 (06:49 -0400)]
media: rc-core.rst: add an introduction for RC core

The RC core does several assumptions, but those aren't documented
anywhere, with could make harder for ones that want to understand
what's there.

So, add an introduction explaining the basic concepts of RC and
how they're related to the RC core implementation.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-dv-timings.h: convert comment into kernel-doc markup
Mauro Carvalho Chehab [Fri, 22 Sep 2017 16:52:43 +0000 (12:52 -0400)]
media: v4l2-dv-timings.h: convert comment into kernel-doc markup

The can_reduce_fps() is already documented, but it is not
using the kernel-doc markup. Convert it, in order to generate
documentation from it.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-common.h: document helper functions
Mauro Carvalho Chehab [Fri, 22 Sep 2017 13:03:54 +0000 (09:03 -0400)]
media: v4l2-common.h: document helper functions

There are several helper functions that aren't documented.

Document them.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-common: get rid of struct v4l2_discrete_probe
Mauro Carvalho Chehab [Fri, 22 Sep 2017 13:49:27 +0000 (09:49 -0400)]
media: v4l2-common: get rid of struct v4l2_discrete_probe

This struct is there just two store two arguments of
v4l2_find_nearest_format(). The other two arguments are passed
as parameter.

IMHO, there isn't much sense on doing that, and that will just
add one more struct to document ;)

So, let's get rid of the struct, passing the parameters directly.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: v4l2-common: get rid of v4l2_routing dead struct
Mauro Carvalho Chehab [Thu, 21 Sep 2017 14:04:30 +0000 (10:04 -0400)]
media: v4l2-common: get rid of v4l2_routing dead struct

This struct is not used anymore. Get rid of it and update
the documentation about what should still be converted.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: tuner-types: add kernel-doc markups for struct tunertype
Mauro Carvalho Chehab [Thu, 21 Sep 2017 13:36:54 +0000 (09:36 -0400)]
media: tuner-types: add kernel-doc markups for struct tunertype

This struct is lacking documentation. Add it.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: frontend: describe nested structs
Mauro Carvalho Chehab [Wed, 27 Sep 2017 13:22:01 +0000 (09:22 -0400)]
media: frontend: describe nested structs

There are some nested structs on this header, with aren't
properly document them.

This should solve some warnings after the addition of
a patche at kernel-doc adding support for nested structs/unions.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dvb_demux: describe nested structs
Mauro Carvalho Chehab [Wed, 27 Sep 2017 13:04:04 +0000 (09:04 -0400)]
media: dvb_demux: describe nested structs

There are some nested structs on this header, with aren't
properly document them.

This should solve some warnings after the addition of
a patche at kernel-doc adding support for nested structs/unions.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: dmxdev: describe nested structs
Mauro Carvalho Chehab [Tue, 26 Sep 2017 20:46:16 +0000 (16:46 -0400)]
media: dmxdev: describe nested structs

There are some nested structs on this header, with aren't
properly document them.

This should solve some warnings after the addition of
a patche at kernel-doc adding support for nested structs/unions.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
6 years agomedia: staging/imx: update TODO
Steve Longerbeam [Fri, 15 Dec 2017 01:04:47 +0000 (20:04 -0500)]
media: staging/imx: update TODO

Update TODO file:

- Remove TODO info about the OV564x driver, while this still needs
  to be done (add a OV5642 driver or merge with OV5640 driver), it
  is not relevant here.

- Update TODO about methods for retrieving CSI bus config.

- Add some TODO's about OF graph parsing restrictions.

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: reorder function prototypes
Steve Longerbeam [Fri, 15 Dec 2017 01:04:46 +0000 (20:04 -0500)]
media: staging/imx: reorder function prototypes

Re-order some of the function prototypes in imx-media.h to
group them correctly by source file. No functional changes.

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: convert static vdev lists to list_head
Steve Longerbeam [Fri, 15 Dec 2017 01:04:45 +0000 (20:04 -0500)]
media: staging/imx: convert static vdev lists to list_head

Although not technically necessary because imx-media has only a
maximum of 8 video devices, and once setup the video device lists
are static, in anticipation of moving control ineritance to
v4l2-core, make the vdev lists more generic by converting to
dynamic list_head's.

After doing that, 'struct imx_media_pad' is now just a list_head
of video devices reachable from a pad. Allocate an array of list_head's,
one list_head for each pad, and attach that array to sd->host_priv.
An entry in the pad lists is of type 'struct imx_media_pad_vdev', and
points to a video device from the master list.

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: remove static subdev arrays
Steve Longerbeam [Fri, 15 Dec 2017 01:04:44 +0000 (20:04 -0500)]
media: staging/imx: remove static subdev arrays

For more complex OF graphs, there will be more async subdevices
registered. Remove the static subdev[IMX_MEDIA_MAX_SUBDEVS] array,
so that imx-media places no limits on the number of async subdevs
that can be added and registered.

There were two uses for 'struct imx_media_subdev'. First was to act
as the async subdev list to be passed to v4l2_async_notifier_register().

Second was to aid in inheriting subdev controls to the capture devices,
and this is done by creating a list of capture devices that can be reached
from a subdev's source pad. So 'struct imx_media_subdev' also contained
a static array of 'struct imx_media_pad' for placing the capture device
lists at each pad.

'struct imx_media_subdev' has been completely removed. Instead, at async
completion, allocate an array of 'struct imx_media_pad' and attach it to
the subdev's host_priv pointer, in order to support subdev controls
inheritance.

Likewise, remove static async_ptrs[IMX_MEDIA_MAX_SUBDEVS] array.
Instead, allocate a 'struct imx_media_async_subdev' when forming
the async list, and add it to an asd_list list_head in
imx_media_add_async_subdev(). At async completion, allocate the
asd pointer list and pull the asd's off asd_list for
v4l2_async_notifier_register().

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: pass fwnode handle to find/add async subdev
Steve Longerbeam [Fri, 15 Dec 2017 01:04:43 +0000 (20:04 -0500)]
media: staging/imx: pass fwnode handle to find/add async subdev

Pass the subdev's fwnode_handle to imx_media_find_async_subdev() and
imx_media_add_async_subdev(), instead of a device_node.

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: remove devname string from imx_media_subdev
Steve Longerbeam [Fri, 15 Dec 2017 01:04:42 +0000 (20:04 -0500)]
media: staging/imx: remove devname string from imx_media_subdev

A separate string for the device name, for DEVNAME async match, was
never needed. Just assign the asd device name to the passed platform
device name pointer in imx_media_add_async_subdev().

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: of: allow for recursing downstream
Steve Longerbeam [Fri, 15 Dec 2017 01:04:41 +0000 (20:04 -0500)]
media: staging/imx: of: allow for recursing downstream

Calling of_parse_subdev() recursively to a downstream path that has
already been followed is ok, it just means that call will return
immediately since the subdevice was already added to the async list.

With that there is no need to determine whether a subdevice's port
is a sink or source, so 'num_{sink|src}_pads' is no longer used and
is removed.

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: 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>