platform/kernel/linux-rpi.git
4 years agomedia: atomisp: remove ISP version macros from sh_css_legacy.h
Mauro Carvalho Chehab [Thu, 23 Apr 2020 07:29:45 +0000 (09:29 +0200)]
media: atomisp: remove ISP version macros from sh_css_legacy.h

This header is really version-independent. So, just get rid
of the macros from it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: make sh_css_sp_init_pipeline() ISP version independent
Mauro Carvalho Chehab [Thu, 23 Apr 2020 07:11:01 +0000 (09:11 +0200)]
media: atomisp: make sh_css_sp_init_pipeline() ISP version independent

This function call has two parameters that are used only with
ISP2401, enclosed on some ugly ifdefs. Make the function independent,
passing NULL values for ISP2400.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: make sh_css_struct.h independent of ISP version
Mauro Carvalho Chehab [Thu, 23 Apr 2020 06:38:49 +0000 (08:38 +0200)]
media: atomisp: make sh_css_struct.h independent of ISP version

Use the same struct for both ISP2400 and ISP2401.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: sh_css_defs.h: get rid of build time dependencies
Mauro Carvalho Chehab [Wed, 22 Apr 2020 13:17:30 +0000 (15:17 +0200)]
media: atomisp: sh_css_defs.h: get rid of build time dependencies

There are several #ifdefs checking for ISP version there. Some
of them are just two different ways to represent the same contants,
while 3 parameters are actually different, depending on the ISP
version.

Change the header in a way that it will be compatible with both
versions, and change dependent code to keep running, removing
ifdefs there only when possible.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: atomisp_compat_ioctl32.c: be independent of ISP version
Mauro Carvalho Chehab [Wed, 22 Apr 2020 12:33:07 +0000 (14:33 +0200)]
media: atomisp: atomisp_compat_ioctl32.c: be independent of ISP version

There are two ioctls that are only available with ISP2401. Yet,
at the compat level, we don't really need to take care, as
the native ioctl handler will already return an error code if
the ioctl doesn't exist.

So, let's just remove the ifdefs here.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: atomisp_compat_css20.c: detect ISP at runtime
Mauro Carvalho Chehab [Wed, 22 Apr 2020 12:28:47 +0000 (14:28 +0200)]
media: atomisp: atomisp_compat_css20.c: detect ISP at runtime

Remove ifdefs that check ISP version from the code, switching
to specific ISP-dependent code at runtime.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: atomisp_csi2.c: remove useless ifdefs
Mauro Carvalho Chehab [Wed, 22 Apr 2020 12:20:14 +0000 (14:20 +0200)]
media: atomisp: atomisp_csi2.c: remove useless ifdefs

The ifdefs there are meaningless. Just remove them for good.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: atomisp_subdev.c check ISP version on runtime
Mauro Carvalho Chehab [Wed, 22 Apr 2020 12:17:45 +0000 (14:17 +0200)]
media: atomisp: atomisp_subdev.c check ISP version on runtime

Remove ISP-version-dependent ifdefs.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: atomisp_v4l2.c: set wdt timers according with ISP version
Mauro Carvalho Chehab [Wed, 22 Apr 2020 12:06:58 +0000 (14:06 +0200)]
media: atomisp: atomisp_v4l2.c: set wdt timers according with ISP version

Add a runtime check to use the proper wdt timer init at runtime,
depending on the chipset revision.

For now, we can't get rid of the remaining version checks, as
the rest of the code is not prepared yet to detect the ISP
version on runtime.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: atomisp_ioctl.c: get rid of a ISP2400/ISP2401 dependency
Mauro Carvalho Chehab [Wed, 22 Apr 2020 11:49:34 +0000 (13:49 +0200)]
media: atomisp: atomisp_ioctl.c: get rid of a ISP2400/ISP2401 dependency

Replace #ifdef occurrences there with runtime checks.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: pci/atomisp2/*.h remove #ifdef ISP2401
Mauro Carvalho Chehab [Mon, 20 Apr 2020 10:33:51 +0000 (12:33 +0200)]
media: atomisp: pci/atomisp2/*.h remove #ifdef ISP2401

Those ifs can easily be removed without breaking the code.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: atomisp_dfs_tables.h: don't depend on ISP version
Mauro Carvalho Chehab [Mon, 20 Apr 2020 10:42:52 +0000 (12:42 +0200)]
media: atomisp: atomisp_dfs_tables.h: don't depend on ISP version

There's a dependency on this header for the ISP model. While
this sounds really weird (as just one resolution needs it),
as we don't know what's the right value, let's just keep it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: atomisp_cmd.c test ISP version in runtime
Mauro Carvalho Chehab [Mon, 20 Apr 2020 08:33:36 +0000 (10:33 +0200)]
media: atomisp: atomisp_cmd.c test ISP version in runtime

The logic there has lots of ifdef dependencies if the hardware
is either ISP2400 or ISP2041.

Replace them by runtime checks.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: add a way for the driver to know the chipset version
Mauro Carvalho Chehab [Mon, 20 Apr 2020 07:19:56 +0000 (09:19 +0200)]
media: atomisp: add a way for the driver to know the chipset version

The atomisp supports two different chipsets: ISP2400 and ISP2401.
Right now, this is controlled by ugly #defines inside the driver.

Add a global bolean to identify the type of hardware. While this
is hacky, it would be a quick way to start removing the ugly
ifdefs.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: simplify math_support.h
Mauro Carvalho Chehab [Sun, 19 Apr 2020 17:12:04 +0000 (19:12 +0200)]
media: atomisp: simplify math_support.h

There are some uneeded defines there. Simplify it, and make
it independent of defines.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: remove some dead code
Mauro Carvalho Chehab [Sun, 19 Apr 2020 16:27:51 +0000 (18:27 +0200)]
media: atomisp: remove some dead code

There are several parts of atomisp that are meant to be
built on different environments, tested using ifdefs.

Remove some of them, as this code should build only on
Linux.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: do lots of other coding style cleanups
Mauro Carvalho Chehab [Sun, 19 Apr 2020 15:51:29 +0000 (17:51 +0200)]
media: atomisp: do lots of other coding style cleanups

Use some auto-reformat tools to make the atomisp style
a little better. There are still lots of weird things there,
but this will hopefully reduce the number of pure coding
style patches submitted upstream.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix several coding style issues
Mauro Carvalho Chehab [Sun, 19 Apr 2020 14:06:45 +0000 (16:06 +0200)]
media: atomisp: fix several coding style issues

Use checkpatch.pl --fix-inplace --strict to solve several
coding style issues, manually reviewing the produced code and
fixing some troubles caused by checkpatch.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix several typos
Mauro Carvalho Chehab [Sun, 19 Apr 2020 12:38:57 +0000 (14:38 +0200)]
media: atomisp: fix several typos

Running checkpatch.pl codespell logic found several typos at atomisp
driver.

Fix them using --fix-inline.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: select IOSF_MBI dependency
Mauro Carvalho Chehab [Wed, 20 May 2020 10:30:23 +0000 (12:30 +0200)]
media: atomisp: select IOSF_MBI dependency

This driver needs IOSF_MBI in order to talk with some PM
registers. Select it at compile time.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: allow building the driver again
Mauro Carvalho Chehab [Sun, 19 Apr 2020 12:33:52 +0000 (14:33 +0200)]
media: atomisp: allow building the driver again

The atomisp driver builds again. So, remove depends on BROKEN.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix a broken compat32 code
Mauro Carvalho Chehab [Sun, 19 Apr 2020 12:02:03 +0000 (14:02 +0200)]
media: atomisp: fix a broken compat32 code

There's a typo at the compat32 code, with forgot to get the
pointer address, causing the driver to not build.

Not sure why this didn't produce an error back when the
driver got removed.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: use new ida API
Mauro Carvalho Chehab [Sun, 19 Apr 2020 12:28:10 +0000 (14:28 +0200)]
media: atomisp: use new ida API

The old ida API got replaced by a new one, with avoids
locking issues. As the old API was removed, start using the
new one, as defined by changeset b03f8e43c926 ("ida: Remove old API").

Fixes: b03f8e43c926 ("ida: Remove old API")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: use cpu_latency_qos_*() instead of pm_qos_update*()
Mauro Carvalho Chehab [Sun, 19 Apr 2020 11:17:14 +0000 (13:17 +0200)]
media: atomisp: use cpu_latency_qos_*() instead of pm_qos_update*()

Those functions got renamed. Update them on atomisp driver.

Fixes: 67b06ba01857 ("PM: QoS: Drop PM_QOS_CPU_DMA_LATENCY and rename related functions")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: Fix support for time 64 API
Mauro Carvalho Chehab [Sun, 19 Apr 2020 11:05:47 +0000 (13:05 +0200)]
media: atomisp: Fix support for time 64 API

The time 64 API patchset changed the ts stamp to u64.

Update this driver accordingly.

Fixes: 15a40b27beb0 ("media: videobuf: use u64 for the timestamp internally")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: replace VFL_TYPE_GRABBER by VFL_TYPE_VIDEO
Mauro Carvalho Chehab [Sun, 19 Apr 2020 10:49:32 +0000 (12:49 +0200)]
media: atomisp: replace VFL_TYPE_GRABBER by VFL_TYPE_VIDEO

This type was renamed in the past by a more meaningul
name. Change it on atomisp too.

Fixes: 238e4a5baa36 ("media: rename VFL_TYPE_GRABBER to _VIDEO")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: totalram_pages is now a function
Mauro Carvalho Chehab [Sun, 19 Apr 2020 10:46:57 +0000 (12:46 +0200)]
media: atomisp: totalram_pages is now a function

Fix the usage of totalram_pages, as this is now a function.

Fixes: ca79b0c211af ("mm: convert totalram_pages and totalhigh_pages variables to atomic")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix usage of access_ok() kAPI
Mauro Carvalho Chehab [Sun, 19 Apr 2020 10:43:55 +0000 (12:43 +0200)]
media: atomisp: fix usage of access_ok() kAPI

This macro had its first parameter lost. Remove it.

While on it, fix the alignments where this macro is used.

Fixes: 96d4f267e40f ("Remove 'type' argument from access_ok() function")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agoMAINTAINERS: adjust atomisp maintainership
Mauro Carvalho Chehab [Wed, 20 May 2020 09:26:17 +0000 (11:26 +0200)]
MAINTAINERS: adjust atomisp maintainership

From now on, I'll be maintaining the atomisp driver, and
Sakari will be reviewing it.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agoRevert "media: staging: atomisp: Remove driver"
Mauro Carvalho Chehab [Sun, 19 Apr 2020 10:18:13 +0000 (12:18 +0200)]
Revert "media: staging: atomisp: Remove driver"

There are some interest on having this driver back, and I
can probably dedicate some time to address its issue. So,
let's ressurect it.

For now, the driver causes a recursive error and doesn't
build, so, make it depend on BROKEN.

This reverts commit 51b8dc5163d2ff2bf04019f8bf7e3bd0e75bb654.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: i2c: imx219: Parse and register properties
Jacopo Mondi [Sat, 9 May 2020 09:04:55 +0000 (11:04 +0200)]
media: i2c: imx219: Parse and register properties

Parse device properties and register controls for them using the newly
introduced helpers.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: i2c: ov13858: Parse and register properties
Jacopo Mondi [Sat, 9 May 2020 09:04:54 +0000 (11:04 +0200)]
media: i2c: ov13858: Parse and register properties

Parse device properties and register controls for them using the newly
introduced helpers.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: i2c: ov5670: Parse and register properties
Jacopo Mondi [Sat, 9 May 2020 09:04:53 +0000 (11:04 +0200)]
media: i2c: ov5670: Parse and register properties

Parse device properties and register controls for them using the newly
introduced helpers.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-ctrls: Add helper to register properties
Jacopo Mondi [Sat, 9 May 2020 09:04:52 +0000 (11:04 +0200)]
media: v4l2-ctrls: Add helper to register properties

Add an helper function to v4l2-ctrls to register controls associated
with a device property.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-ctrls: Sort includes alphabetically
Jacopo Mondi [Sat, 9 May 2020 09:04:51 +0000 (11:04 +0200)]
media: v4l2-ctrls: Sort includes alphabetically

Before adding a new include directive, sort the existing ones in
alphabetical order.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: include: v4l2-ctrl: Sort forward declarations
Jacopo Mondi [Sat, 9 May 2020 09:04:50 +0000 (11:04 +0200)]
media: include: v4l2-ctrl: Sort forward declarations

Before adding a new forward declaration to the v4l2-ctrls.h header file,
sort the existing ones alphabetically.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-fwnode: Add helper to parse device properties
Jacopo Mondi [Sat, 9 May 2020 09:04:49 +0000 (11:04 +0200)]
media: v4l2-fwnode: Add helper to parse device properties

Add an helper function to parse common device properties in the same
way as v4l2_fwnode_endpoint_parse() parses common endpoint properties.

Parse the 'rotation' and 'orientation' properties from the firmware
interface.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-ctrls: Add camera orientation and rotation
Jacopo Mondi [Sat, 9 May 2020 09:04:48 +0000 (11:04 +0200)]
media: v4l2-ctrls: Add camera orientation and rotation

Add support for the newly defined V4L2_CID_CAMERA_ORIENTATION
and V4L2_CID_CAMERA_SENSOR_ROTATION read-only controls used to report
the camera device mounting position and orientation respectively.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-ctrl: Document V4L2_CID_CAMERA_SENSOR_ROTATION
Jacopo Mondi [Sat, 9 May 2020 09:04:47 +0000 (11:04 +0200)]
media: v4l2-ctrl: Document V4L2_CID_CAMERA_SENSOR_ROTATION

Add documentation for the V4L2_CID_CAMERA_SENSOR_ROTATION camera
control. The newly added read-only control reports the rotation
correction to be applied to images before displaying them to the user.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-ctrl: Document V4L2_CID_CAMERA_ORIENTATION
Jacopo Mondi [Sat, 9 May 2020 09:04:46 +0000 (11:04 +0200)]
media: v4l2-ctrl: Document V4L2_CID_CAMERA_ORIENTATION

Add documentation for the V4L2_CID_CAMERA_ORIENTATION camera
control. The newly added read-only control reports the camera device
orientation relative to the usage orientation of the system the camera
is installed on.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dt-bindings: video-interface: Replace 'rotation' description
Jacopo Mondi [Sat, 9 May 2020 09:04:45 +0000 (11:04 +0200)]
media: dt-bindings: video-interface: Replace 'rotation' description

Replace the 'rotation' property description by providing a definition
relative to the camera sensor pixel array coordinate system and the
captured scene.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dt-bindings: video-interfaces: Document 'orientation' property
Jacopo Mondi [Sat, 9 May 2020 09:04:44 +0000 (11:04 +0200)]
media: dt-bindings: video-interfaces: Document 'orientation' property

Add the 'orientation' device property, used to specify the device mounting
position. The property is particularly meaningful for mobile devices
with a well defined usage orientation.

Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: TODO: Remove media link creation todos
Steve Longerbeam [Fri, 1 May 2020 17:15:56 +0000 (19:15 +0200)]
media: imx: TODO: Remove media link creation todos

Remove the TODO items regarding media link creation, these issues are
resolved by moving media link creation to individual entity bound
callbacks and the implementation of the get_fwnode_pad operation.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: silence a couple debug messages
Steve Longerbeam [Fri, 1 May 2020 17:15:55 +0000 (19:15 +0200)]
media: imx: silence a couple debug messages

Convert to dev_dbg the "subdev bound" and IPU-internal media-link
creation messages.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: Create missing links from CSI-2 receiver
Steve Longerbeam [Fri, 1 May 2020 17:15:54 +0000 (19:15 +0200)]
media: imx: Create missing links from CSI-2 receiver

The entities external to the i.MX6 IPU and i.MX7 now create the links
to their fwnode-endpoint connected entities in their notifier bound
callbacks. Which means imx_media_create_of_links() and
imx_media_create_csi_of_links() are no longer needed and are removed.

However there is still one case in which imx-media needs to create
fwnode-endpoint based links at probe completion. The v4l2-async framework
does not allow multiple subdevice notifiers to contain a duplicate
subdevice in their asd_list. Only the first subdev notifier that discovers
and adds that one subdevice to its asd_list will receive a bound callback
for it. Other subdevices that also have firmware endpoint connections to
this duplicate subdevice will not have it in their asd_list, and thus will
never receive a bound callback for it. In the case of imx-media, the one
duplicate subdevice in question is the i.MX6 MIPI CSI-2 receiver.

Until there is a solution to that problem, rewrite imx_media_create_links()
to add the missing links from the CSI-2 receiver to the CSIs and CSI muxes.
The function is renamed imx_media_create_csi2_links().

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode
Steve Longerbeam [Fri, 1 May 2020 17:15:53 +0000 (19:15 +0200)]
media: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode

Fix the 1:1 port-id:pad-index assumption for the upstream subdevice, by
searching the upstream subdevice's endpoints for one that maps to the
pad's index. This is carried out by a new reverse mapping function
imx_media_get_pad_fwnode().

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx5/6/7: csi: Mark a bound video mux as a CSI mux
Steve Longerbeam [Fri, 1 May 2020 17:15:52 +0000 (19:15 +0200)]
media: imx5/6/7: csi: Mark a bound video mux as a CSI mux

For i.MX5/6, if the bound subdev is a video mux, it must be one of the
CSI muxes, and for i.MX7, the bound subdev must always be a CSI mux.

So if the bound subdev is a video mux, mark it as a CSI mux with a new
group id IMX_MEDIA_GRP_ID_CSI_MUX.

In the process use the new group id in csi_get_upstream_endpoint(), and
do some cleanup in that function for better readability.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx7: csi: Remove imx7_csi_get_upstream_endpoint()
Steve Longerbeam [Fri, 1 May 2020 17:15:51 +0000 (19:15 +0200)]
media: imx7: csi: Remove imx7_csi_get_upstream_endpoint()

The function imx7_csi_get_upstream_endpoint() is not necessary for
imx7. First, the imx7 CSI only receives from the CSI mux, so much of
the code in there is pointless. Second, it is only used to determine
whether the CSI mux has selected the CSI-2 input or the parallel input.
This can be accomplished much more simply by getting the function type
of selected input entity to the CSI mux.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: csi: Create media links in bound notifier
Steve Longerbeam [Fri, 1 May 2020 17:15:50 +0000 (19:15 +0200)]
media: imx: csi: Create media links in bound notifier

Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the CSI sink pad.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx7: csi: Create media links in bound notifier
Steve Longerbeam [Fri, 1 May 2020 17:15:49 +0000 (19:15 +0200)]
media: imx7: csi: Create media links in bound notifier

Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the CSI sink pad.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx7: mipi csis: Create media links in bound notifier
Steve Longerbeam [Fri, 1 May 2020 17:15:48 +0000 (19:15 +0200)]
media: imx7: mipi csis: Create media links in bound notifier

Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the mipi csi-2 receiver sink pad.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: mipi csi-2: Create media links in bound notifier
Steve Longerbeam [Fri, 1 May 2020 17:15:47 +0000 (19:15 +0200)]
media: imx: mipi csi-2: Create media links in bound notifier

Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the mipi csi-2 receiver sink pad.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: video-mux: Create media links in bound notifier
Steve Longerbeam [Fri, 1 May 2020 17:15:46 +0000 (19:15 +0200)]
media: video-mux: Create media links in bound notifier

Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the video-mux sink pad(s).

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-media-csi: Implement get_fwnode_pad op
Steve Longerbeam [Fri, 1 May 2020 17:15:45 +0000 (19:15 +0200)]
media: imx: imx7-media-csi: Implement get_fwnode_pad op

Use v4l2_subdev_get_fwnode_pad_1_to_1() as the get_fwnode_pad operation.
The i.MX7 CSI maps port numbers and pad indexes 1:1.

Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: imx7-mipi-csis: Implement get_fwnode_pad op
Steve Longerbeam [Fri, 1 May 2020 17:15:44 +0000 (19:15 +0200)]
media: imx: imx7-mipi-csis: Implement get_fwnode_pad op

Use v4l2_subdev_get_fwnode_pad_1_to_1() as the get_fwnode_pad operation.
The imx7-mipi-csis maps port numbers and pad indexes 1:1.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: mipi csi-2: Implement get_fwnode_pad op
Steve Longerbeam [Fri, 1 May 2020 17:15:43 +0000 (19:15 +0200)]
media: imx: mipi csi-2: Implement get_fwnode_pad op

Use v4l2_subdev_get_fwnode_pad_1_to_1() as the get_fwnode_pad operation.
The MIPI CSI-2 receiver maps port numbers and pad indexes 1:1.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: video-mux: Implement get_fwnode_pad op
Steve Longerbeam [Fri, 1 May 2020 17:15:42 +0000 (19:15 +0200)]
media: video-mux: Implement get_fwnode_pad op

Use v4l2_subdev_get_fwnode_pad_1_to_1() as the get_fwnode_pad operation.
The video mux maps fwnode port numbers and pad indexes 1:1.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: csi: Implement get_fwnode_pad op
Steve Longerbeam [Fri, 1 May 2020 17:15:41 +0000 (19:15 +0200)]
media: imx: csi: Implement get_fwnode_pad op

The CSI does not have a 1:1 relationship between fwnode port numbers and
pad indexes. In fact the CSI fwnode device is itself a port which is the
sink, containing only a single fwnode endpoint. Implement media_entity
operation get_fwnode_pad to first verify the given endpoint is the CSI's
sink endpoint, and if so return the CSI sink pad index.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Revert "media: v4l2-fwnode: Add a convenience function for registering subdevs...
Steve Longerbeam [Fri, 1 May 2020 17:15:40 +0000 (19:15 +0200)]
media: Revert "media: v4l2-fwnode: Add a convenience function for registering subdevs with notifiers"

The users of v4l2_async_register_fwnode_subdev() have switched to
parsing their endpoints and setting up async sub-device lists in their
notifiers locally, without using the endpoint parsing callbacks. There
are no more users of v4l2_async_register_fwnode_subdev() so this
convenience function can be removed.

This reverts commit 1634f0eded87d1f150e823fa56cd782ea0775eb2.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: imx: Parse information from firmware without using callbacks
Steve Longerbeam [Fri, 1 May 2020 17:15:39 +0000 (19:15 +0200)]
media: imx: Parse information from firmware without using callbacks

Instead of using the convenience functions
v4l2_async_notifier_parse_fwnode_endpoints*() or
v4l2_async_register_fwnode_subdev(), parse the input endpoints
and set up the async sub-devices without using callbacks. The drivers
know which ports it must parse and how to handle unconnected remotes,
so it makes the code simpler to transfer control of endpoint parsing
to the driver.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: video-mux: Parse information from firmware without using callbacks
Steve Longerbeam [Fri, 1 May 2020 17:15:38 +0000 (19:15 +0200)]
media: video-mux: Parse information from firmware without using callbacks

Instead of using the convenience function
v4l2_async_register_fwnode_subdev(), parse the video-mux input endpoints
and set up the async sub-devices without using callbacks. The video-mux
knows which ports it must parse (the input ports) and how to handle
unconnected remotes, so it makes the code simpler to transfer control
of endpoint parsing to the driver.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-mc: add v4l2_create_fwnode_links helpers
Steve Longerbeam [Fri, 1 May 2020 17:15:37 +0000 (19:15 +0200)]
media: v4l2-mc: add v4l2_create_fwnode_links helpers

Add functions to create media links between source and sink subdevices,
based on the fwnode endpoint connections between them:

v4l2_create_fwnode_links_to_pad() - create links from a source subdev to
                                    a single sink pad based on fwnode
                                    endpoint connections.

v4l2_create_fwnode_links() - create all links from a source to sink subdev
                             based on fwnode endpoint connections.

These functions can be used in a sink's v4l2-async notifier subdev
bound callback to make the links from the bound subdev.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-subdev: add v4l2_subdev_get_fwnode_pad_1_to_1
Steve Longerbeam [Fri, 1 May 2020 17:15:36 +0000 (19:15 +0200)]
media: v4l2-subdev: add v4l2_subdev_get_fwnode_pad_1_to_1

Add a convenience function that can be used as the .get_fwnode_pad
operation for subdevices that map port numbers and pad indexes 1:1.
The function verifies the endpoint is owned by the subdevice, and if
so returns the endpoint port number.

Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: entity: Pass entity to get_fwnode_pad operation
Steve Longerbeam [Fri, 1 May 2020 17:15:35 +0000 (19:15 +0200)]
media: entity: Pass entity to get_fwnode_pad operation

Add a missing pointer to the entity in the media_entity operation
get_fwnode_pad. There are no implementers of this op yet, but a future
entity that does so will almost certainly need a reference to itself
to carry out the work.

operation")

Fixes: ae45cd5efc120 ("[media] media: entity: Add get_fwnode_pad entity
Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: i2c: imx219: Fix a bug in imx219_enum_frame_size
Dafna Hirschfeld [Tue, 31 Mar 2020 18:06:30 +0000 (20:06 +0200)]
media: i2c: imx219: Fix a bug in imx219_enum_frame_size

When enumerating the frame sizes, the value sent to
imx219_get_format_code should be fse->code
(the code from the ioctl) and not imx219->fmt.code
which is the code set currently in the driver.

Fixes: 22da1d56e982 ("media: i2c: imx219: Add support for RAW8 bit bayer format")
Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Helen Koike <helen.koike@collabora.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: i2c: imx219: Implement get_selection
Jacopo Mondi [Wed, 29 Apr 2020 09:50:38 +0000 (11:50 +0200)]
media: i2c: imx219: Implement get_selection

Implement the get_selection pad operation for the IMX219 sensor driver.
The supported targets report the sensor's native size, the crop default
rectangle and the crop rectangle.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: media: sh_veu: Remove driver
Geert Uytterhoeven [Thu, 7 May 2020 12:27:57 +0000 (14:27 +0200)]
media: media: sh_veu: Remove driver

Since its inclusion in v3.9, no users of the SuperH VEU mem2mem video
processing driver have appeared upstream.  All VEU devices in SuperH
board code still bind to the "uio_pdrv_genirq" driver instead.
The original author marked the driver orphaned in v3.15.

Remove the driver; it can always be resurrected from git history when
needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Rob Landley <rob@landley.net>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dvb-frontends: remove redundant initialization of variable status
Colin Ian King [Thu, 7 May 2020 22:00:40 +0000 (00:00 +0200)]
media: dvb-frontends: remove redundant initialization of variable status

The variable status is being initialized with a value that is never read
and it is being updated later with a new value.  The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: mantis_dvb: remove redundant initialization to variable result
Colin Ian King [Thu, 7 May 2020 21:43:31 +0000 (23:43 +0200)]
media: mantis_dvb: remove redundant initialization to variable result

The variable result is being initialized with a value that is never read
and it is being updated later with a new value.  The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: usb: ttusb-dec: reduce the number of memory reads in ttusb_dec_handle_irq()
Jia-Ju Bai [Thu, 7 May 2020 10:25:21 +0000 (12:25 +0200)]
media: usb: ttusb-dec: reduce the number of memory reads in ttusb_dec_handle_irq()

In ttusb_dec_handle_irq(), buffer[4] is continuously read from memory
three times, without being modified.
To reduce the number of memory reads, buffer[4] is first assigned to a
local variable index, and then index is used to replace buffer[4].

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: stv0900_core: remove redundant assignment to variable val
Colin Ian King [Sat, 25 Apr 2020 11:22:05 +0000 (13:22 +0200)]
media: stv0900_core: remove redundant assignment to variable val

The variable val is being initializeed with a value that is never read
and it is being updated later with a new value. The initialization
is redundant and can be removed.

Addresses-Coverity: ("Unused value")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: dvb: remove redundant assignment to variable bw
Colin Ian King [Fri, 24 Apr 2020 11:16:00 +0000 (13:16 +0200)]
media: dvb: remove redundant assignment to variable bw

The variable bw is being initialized with a value that is
never read and it is being updated later with a new value.  The
initialization is redundant and can be removed.

Addresses-Coverity: ("Unused value")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: gpio-ir-tx: allow transmission without carrier
Sean Young [Wed, 6 May 2020 09:54:39 +0000 (11:54 +0200)]
media: gpio-ir-tx: allow transmission without carrier

Some IR protocols do not use a carrier.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: gpio-ir-tx: improve precision of transmitted signal due to scheduling
Sean Young [Sat, 2 May 2020 12:50:52 +0000 (14:50 +0200)]
media: gpio-ir-tx: improve precision of transmitted signal due to scheduling

usleep_range() may take longer than the max argument due to scheduling,
especially under load. This is causing random errors in the transmitted
IR. Remove the usleep_range() in favour of busy-looping with udelay().

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l: document VIDIOC_SUBDEV_QUERYCAP
Hans Verkuil [Thu, 7 May 2020 15:12:53 +0000 (17:12 +0200)]
media: v4l: document VIDIOC_SUBDEV_QUERYCAP

Add documentation for the new VIDIOC_SUBDEV_QUERYCAP ioctl.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
Hans Verkuil [Thu, 7 May 2020 15:12:52 +0000 (17:12 +0200)]
media: v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl

While normal video/radio/vbi/swradio nodes have a proper QUERYCAP ioctl
that apps can call to determine that it is indeed a V4L2 device, there
is currently no equivalent for v4l-subdev nodes. Adding this ioctl will
solve that, and it will allow utilities like v4l2-compliance to be used
with these devices as well.

SUBDEV_QUERYCAP currently returns the version and capabilities of the
subdevice. Define a capability flag to report if the subdevice is
registered in read-only mode.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-subdev: Guard whole fops and ioctl hdlr
Jacopo Mondi [Thu, 7 May 2020 15:12:51 +0000 (17:12 +0200)]
media: v4l2-subdev: Guard whole fops and ioctl hdlr

A sub-device device node can be registered in user space only if the
CONFIG_VIDEO_V4L2_SUBDEV_API Kconfig option is selected. Currently the
open/close file operations and the ioctl handler have some parts of
their implementations guarded by #if
defined(CONFIG_VIDEO_V4L2_SUBDEV_API), while they are actually not
accessible without a video device node registered to user space.

Guard the whole open, close and ioctl handler and provide stubs if the
VIDEO_V4L2_SUBDEV_API Kconfig option is not selected.

This slightly reduces the kernel size when the option is not selected
and simplifies the file ops and ioctl implementations.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-dev: Add v4l2_device_register_ro_subdev_node()
Jacopo Mondi [Thu, 7 May 2020 15:12:50 +0000 (17:12 +0200)]
media: v4l2-dev: Add v4l2_device_register_ro_subdev_node()

Add to the V4L2 core a function to register device nodes for video
subdevices in read-only mode.

Registering a device node in read-only mode is useful to expose to
userspace the current sub-device configuration, without allowing
application to change it by using the V4L2 subdevice ioctls.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Documentation: media: Document read-only subdevice
Jacopo Mondi [Thu, 7 May 2020 15:12:49 +0000 (17:12 +0200)]
media: Documentation: media: Document read-only subdevice

Document a new kAPI function to register subdev device nodes in read only
mode and for each affected ioctl report how access is restricted.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Documentation: media: Update sub-device API intro
Jacopo Mondi [Thu, 7 May 2020 15:12:48 +0000 (17:12 +0200)]
media: Documentation: media: Update sub-device API intro

Update the V4L2 sub-device userspace API introduction to provide more
details on why complex devices might want to register devnodes for the
connected subdevices.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ipu3.rst: fix a build warning
Mauro Carvalho Chehab [Wed, 6 May 2020 11:20:51 +0000 (13:20 +0200)]
media: ipu3.rst: fix a build warning

Sphinx 2.4.4 produces this warning:

Documentation/admin-guide/media/ipu3.rst:235: WARNING: Title underline too short.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vidioc-enum-fmt.rst: make the ENUM_FMT text clearer
Hans Verkuil [Wed, 6 May 2020 12:16:00 +0000 (14:16 +0200)]
media: vidioc-enum-fmt.rst: make the ENUM_FMT text clearer

Rework the documentation to make it easier for the reader to understand
the differences in behavior of this ioctl between MC and non-MC drivers.

Note the addition of the 'video-node-centric' and 'MC-centric' terms to
help understand what the IO_MC capability really means.

Also mention in the beginning that mbus_code is one of the fields that
application should initialize, and add META_OUTPUT as one of the types that
this ioctl supports (that was never added here when the META_OUTPUT buffer
type was added).

Finally document that EINVAL will be returned if mbus_code is unsupported.

Fixes: e5b6b07a1b45 ("media: v4l2: Extend VIDIOC_ENUM_FMT to support MC-centric devices")
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: Make use of V4L2_CAP_IO_MC
Niklas Söderlund [Tue, 21 Apr 2020 13:57:43 +0000 (15:57 +0200)]
media: vimc: Make use of V4L2_CAP_IO_MC

Set the V4L2_CAP_IO_MC capability flag to report this vimc
inputs/outputs are controlled by the media graph.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging/intel-ipu3: Make use of V4L2_CAP_IO_MC
Niklas Söderlund [Tue, 21 Apr 2020 13:57:42 +0000 (15:57 +0200)]
media: staging/intel-ipu3: Make use of V4L2_CAP_IO_MC

Set the V4L2_CAP_IO_MC capability flag and remove the driver specific
vidioc_enum_{input,output}, vidioc_g_{input,output} and
vidioc_s_{input,output} callbacks.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: rcar-vin: Make use of V4L2_CAP_IO_MC
Niklas Söderlund [Tue, 21 Apr 2020 13:57:41 +0000 (15:57 +0200)]
media: rcar-vin: Make use of V4L2_CAP_IO_MC

Set the V4L2_CAP_IO_MC capability flag and remove the driver specific
vidioc_enum_input, vidioc_g_input and vidioc_s_input callbacks for the
media controller enabled part of the driver. Also add support mbus_code
filtering for format enumeration.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2: Extend VIDIOC_ENUM_FMT to support MC-centric devices
Laurent Pinchart [Fri, 24 Apr 2020 13:43:31 +0000 (15:43 +0200)]
media: v4l2: Extend VIDIOC_ENUM_FMT to support MC-centric devices

The VIDIOC_ENUM_FMT ioctl enumerates all formats supported by a video
node. For MC-centric devices, its behaviour has always been ill-defined,
with drivers implementing one of the following behaviours:

- No support for VIDIOC_ENUM_FMT at all
- Enumerating all formats supported by the video node, regardless of the
  configuration of the pipeline
- Enumerating formats supported by the video node for the active
  configuration of the connected subdevice

The first behaviour is obviously useless for applications. The second
behaviour provides the most information, but doesn't offer a way to find
what formats are compatible with a given pipeline configuration. The
third behaviour fixes that, but with the drawback that applications
can't enumerate all supported formats anymore, and have to modify the
active configuration of the pipeline to enumerate formats.

The situation is messy as none of the implemented behaviours are ideal,
and userspace can't predict what will happen as the behaviour is
driver-specific.

To fix this, let's extend the VIDIOC_ENUM_FMT with a missing capability:
enumerating pixel formats for a given media bus code. The media bus code
is passed through the v4l2_fmtdesc structure in a new mbus_code field
(repurposed from the reserved fields). With this capability in place,
applications can enumerate pixel formats for a given media bus code
without modifying the active configuration of the device.

The current behaviour of the ioctl is preserved when the new mbus_code
field is set to 0, ensuring compatibility with existing userspace. The
API extension is documented as mandatory for MC-centric devices (as
advertised through the V4L2_CAP_IO_MC capability), allowing applications
and compliance tools to easily determine the availability of the
VIDIOC_ENUM_FMT extension.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: pci: Fill v4l2_fmtdesc with designated initializers
Laurent Pinchart [Tue, 21 Apr 2020 13:57:39 +0000 (15:57 +0200)]
media: pci: Fill v4l2_fmtdesc with designated initializers

Replace initialization of static const v4l2_fmtdesc instances that
specify every struct member with designated initializers. This allows
not zeroing the reserved fields explicitly, and will avoid a need to
patch these drivers every time a reserved field is repurposed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-dev/ioctl: Add V4L2_CAP_IO_MC
Niklas Söderlund [Tue, 21 Apr 2020 13:57:38 +0000 (15:57 +0200)]
media: v4l2-dev/ioctl: Add V4L2_CAP_IO_MC

Add a video device capability flag to indicate that its inputs and/or
outputs are controlled by the Media Controller instead of the V4L2 API.
When this flag is set, ioctl for enum inputs and outputs are
automatically enabled and programmed to call a helper function.

Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: admin-guide: split cardlist.rst file
Mauro Carvalho Chehab [Wed, 22 Apr 2020 08:44:21 +0000 (10:44 +0200)]
media: admin-guide: split cardlist.rst file

After adding all cardlists, this file became too big. Split
it on smaller files, in order to make easier to maintain.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: admin-guide: make clear about PCI subsystem IDs
Mauro Carvalho Chehab [Wed, 22 Apr 2020 07:25:00 +0000 (09:25 +0200)]
media: admin-guide: make clear about PCI subsystem IDs

On several parts of the document, it mentions "PCI ID", when
it is actually referring to the subsystem's part of the PCI
ID.

Change the language to let it be clear.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: cec: silence shift wrapping warning in __cec_s_log_addrs()
Dan Carpenter [Tue, 5 May 2020 08:25:56 +0000 (10:25 +0200)]
media: cec: silence shift wrapping warning in __cec_s_log_addrs()

The log_addrs->log_addr_type[i] value is a u8 which is controlled by
the user and comes from the ioctl.  If it's over 31 then that results in
undefined behavior (shift wrapping) and that leads to a Smatch static
checker warning.  We already cap the value later so we can silence the
warning just by re-ordering the existing checks.

I think the UBSan checker will also catch this bug at runtime and
generate a warning.  But otherwise the bug is harmless.

Fixes: 9881fe0ca187 ("[media] cec: add HDMI CEC framework (adapter)")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: sun8i: Fix an error handling path in 'deinterlace_runtime_resume()'
Christophe JAILLET [Tue, 5 May 2020 07:50:34 +0000 (09:50 +0200)]
media: sun8i: Fix an error handling path in 'deinterlace_runtime_resume()'

It is spurious to call 'clk_disable_unprepare()' when
'clk_prepare_enable()' has not been called yet.
Re-order the error handling path to avoid it.

Fixes: a4260ea49547 ("media: sun4i: Add H3 deinterlace driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: err_exlusive_rate -> err_exclusive_rate]
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: deb: Add support for {RGB,BGR,GBR}888 bus formats on source pad
Nícolas F. R. A. Prado [Fri, 1 May 2020 13:11:23 +0000 (15:11 +0200)]
media: vimc: deb: Add support for {RGB,BGR,GBR}888 bus formats on source pad

Add support for RGB888_*, BGR888_* and GBR888_* media bus formats on
the source pad of debayer subdevices.

Acked-by: Helen Koike <helen.koike@collabora.com>
Co-developed-by: Vitor Massaru Iha <vitor@massaru.org>
Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: Add missing {RGB,BGR,GBR}888 media bus codes
Nícolas F. R. A. Prado [Fri, 1 May 2020 13:11:12 +0000 (15:11 +0200)]
media: vimc: Add missing {RGB,BGR,GBR}888 media bus codes

Add missing RGB888_*, BGR888_* and GBR888_* media bus codes in the
vimc_pix_map_list. Since there is no GBR24 pixelformat, use the RGB24
pixelformat for MEDIA_BUS_FMT_GBR888_1X24.

Acked-by: Helen Koike <helen.koike@collabora.com>
Co-developed-by: Vitor Massaru Iha <vitor@massaru.org>
Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: vimc: Support multiple media bus codes for each pixelformat
Nícolas F. R. A. Prado [Fri, 1 May 2020 13:11:02 +0000 (15:11 +0200)]
media: vimc: Support multiple media bus codes for each pixelformat

Change vimc_pix_map_list to allow multiple media bus codes to map to the
same pixelformat, making it possible to add media bus codes for which
there are no pixelformat.

Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: fix sparse warning: const u32 -> u32]
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: ti-vpe: avoid gcc-9 warning
Arnd Bergmann [Tue, 28 Apr 2020 21:34:19 +0000 (23:34 +0200)]
media: ti-vpe: avoid gcc-9 warning

gcc warns about empty array declarations, which we get in this driver
when compile-testing without CONFIG_OF:

drivers/media/platform/ti-vpe/cal.c:2194:34: warning: array 'cal_of_match' assumed to have one element
 2194 | static const struct of_device_id cal_of_match[];

Since all users of this driver do need CONFIG_OF anyway, there is no
point in making the array definition conditional to save space, so
just remove the #ifdef and move the array up a little.

Fixes: 343e89a792a5 ("[media] media: ti-vpe: Add CAL v4l2 camera capture driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: media: usbvision: usbvision-core Correct spelling
John Oldman [Tue, 28 Apr 2020 17:26:55 +0000 (19:26 +0200)]
media: staging: media: usbvision: usbvision-core Correct spelling

Correct spelling in comment

Signed-off-by: John Oldman <john.oldman@polehill.co.uk>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: media: imx: no need to check return value of debugfs_create functions
Greg Kroah-Hartman [Tue, 28 Apr 2020 17:04:05 +0000 (19:04 +0200)]
media: staging: media: imx: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: Steve Longerbeam <slongerbeam@gmail.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: devel@driverdev.osuosl.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: MAINTAINERS: update the Amlogic VDEC driver maintainer entry
Neil Armstrong [Tue, 28 Apr 2020 12:50:36 +0000 (14:50 +0200)]
media: MAINTAINERS: update the Amlogic VDEC driver maintainer entry

Add myself as co-maintainer of the Amlogic VDEC driver, and add the
missing vdec DT yaml bindings.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: meson: vdec: enable mcrcc for VP9
Maxime Jourdan [Tue, 28 Apr 2020 12:50:34 +0000 (14:50 +0200)]
media: meson: vdec: enable mcrcc for VP9

The motion compensation reference cache controller allows caching
parts of reference frames for faster decoding.

Fixes: 00c43088aa68 ("media: meson: vdec: add VP9 decoder support")
Signed-off-by: Maxime Jourdan <mjourdan@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>