linux-2.6-microblaze.git
8 months agomedia: imon: fix access to invalid resource for the second interface
Takashi Iwai [Fri, 22 Sep 2023 12:38:07 +0000 (14:38 +0200)]
media: imon: fix access to invalid resource for the second interface

imon driver probes two USB interfaces, and at the probe of the second
interface, the driver assumes blindly that the first interface got
bound with the same imon driver.  It's usually true, but it's still
possible that the first interface is bound with another driver via a
malformed descriptor.  Then it may lead to a memory corruption, as
spotted by syzkaller; imon driver accesses the data from drvdata as
struct imon_context object although it's a completely different one
that was assigned by another driver.

This patch adds a sanity check -- whether the first interface is
really bound with the imon driver or not -- for avoiding the problem
above at the probe time.

Reported-by: syzbot+59875ffef5cb9c9b29e9@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/000000000000a838aa0603cc74d6@google.com/
Tested-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20230922005152.163640-1-ricardo@marliere.net
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: rc: keymaps: add missing MODULE_DESCRIPTION to keymaps
Hans Verkuil [Tue, 26 Sep 2023 09:58:42 +0000 (11:58 +0200)]
media: rc: keymaps: add missing MODULE_DESCRIPTION to keymaps

When building the modules 'modpost' warns about missing MODULE_DESCRIPTION.

Since almost none of the rc keymap modules have this, it produces a lot of
warnings.

As a first step to fixing all media modules, add this line to all keymaps.
The description should be a human-readable string describing the remote
or the remote controller that the keymap can be used with.

Note that keymaps/rc-cec.c is actually compiled into the rc-core, so that
is the sole keymap source that didn't need this.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sean Young <sean@mess.org>
8 months agomedia: Documentation: Split camera sensor documentation
Sakari Ailus [Wed, 27 Sep 2023 11:22:52 +0000 (14:22 +0300)]
media: Documentation: Split camera sensor documentation

Split camera sensor documentation into user and kernel portions. This
should make it easier for the user space developers to find the relevant
documentation.

Also add a list of exemplary drivers and add imx219 driver to it, besides
those that were already mentioned.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: Add MIPI CSI-2 generic long packet type definition
Sakari Ailus [Tue, 12 Sep 2023 08:36:51 +0000 (11:36 +0300)]
media: Add MIPI CSI-2 generic long packet type definition

Add a definition for MIPI CSI-2 generic long packet types. The generic
long packet types are numbered from 1 to 4.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: mc: Check pad flag validity
Sakari Ailus [Tue, 25 Apr 2023 09:30:45 +0000 (12:30 +0300)]
media: mc: Check pad flag validity

Check the validity of pad flags on entity init. Exactly one of the flags
must be set.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: v4l: subdev: Print debug information on frame descriptor
Sakari Ailus [Tue, 12 Sep 2023 11:55:24 +0000 (14:55 +0300)]
media: v4l: subdev: Print debug information on frame descriptor

Print debug level information on returned frame descriptors.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: v4l: subdev: Clear frame descriptor before get_frame_desc
Sakari Ailus [Fri, 15 Sep 2023 11:23:28 +0000 (14:23 +0300)]
media: v4l: subdev: Clear frame descriptor before get_frame_desc

Clear frame descriptor before calling transmitter's get_frame_desc() op.
Also remove the corresponding memset() calls from drivers.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ov2740: Return -EPROBE_DEFER if no endpoint is found
Sakari Ailus [Fri, 8 Sep 2023 09:56:16 +0000 (12:56 +0300)]
media: ov2740: Return -EPROBE_DEFER if no endpoint is found

With ipu bridge, endpoints may only be created when ipu bridge has
initialised. This may happen after the sensor driver has first probed.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ov2740: Use sub-device active state
Sakari Ailus [Thu, 7 Sep 2023 12:10:03 +0000 (15:10 +0300)]
media: ov2740: Use sub-device active state

Use sub-device active state. Rely on control handler lock to serialise
access to the active state. Also clean up locking on s_stream handler.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ov2740: Enable runtime PM before registering the async subdev
Sakari Ailus [Fri, 8 Sep 2023 08:52:12 +0000 (11:52 +0300)]
media: ov2740: Enable runtime PM before registering the async subdev

Enable runtime PM before registering the async subdev as the driver UAPI
may become accessible immediately after the registration. Runtime PM needs
to be enabled by that time.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Drop re-entrant s_stream support
Sakari Ailus [Fri, 29 Sep 2023 08:32:46 +0000 (11:32 +0300)]
media: ccs: Drop re-entrant s_stream support

The s_stream is called to enable and to disable streaming on a sub-device.
The caller may only call it to change the state, enabling streaming is not
allowed when it is already disabled, and similarly for disabling
streaming. Remove the check from the CCS driver.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Partially revert "media: i2c: Use pm_runtime_resume_and_get()"
Sakari Ailus [Fri, 29 Sep 2023 09:00:42 +0000 (12:00 +0300)]
media: ccs: Partially revert "media: i2c: Use pm_runtime_resume_and_get()"

ccs_pm_get_init() depends on the return values > 0 of
pm_runtime_get_sync(), thus it can't use pm_runtime_resume_and_get().
There's even a comment in the driver on this, a few lines above the code.

Fixes: aa0adb399d09 ("media: i2c: Use pm_runtime_resume_and_get()")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Use sub-device active state
Sakari Ailus [Thu, 24 Aug 2023 07:31:10 +0000 (10:31 +0300)]
media: ccs: Use sub-device active state

Make use of sub-device active state. In most cases the effect on need for
acquiring the mutex is non-existent as access to the driver's core data
structure still needs to be serialised.

This still removes a lot of code as the code paths for active and try
state are the same in many cases.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Obtain media bus formats before initialising up sub-devices
Sakari Ailus [Mon, 2 Oct 2023 10:29:22 +0000 (13:29 +0300)]
media: ccs: Obtain media bus formats before initialising up sub-devices

The available mbus codes will soon be needed earlier, at the time
sub-devices are initialisaed. This is due to calling init_cfg() op via the
v4l2_subdev_init_finalize().

Move ccs_get_mbus_formats() before ccs_init_subdev() calls.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Move media_entity_pads_init to init from register
Sakari Ailus [Mon, 2 Oct 2023 07:25:37 +0000 (10:25 +0300)]
media: ccs: Move media_entity_pads_init to init from register

The media entity will soon need to be initialised before the sub-device
init finalisation that allocates memory for sub-device state. Do that now.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Rename ccs_create_subdev as ccs_init_subdev
Sakari Ailus [Mon, 2 Oct 2023 07:19:15 +0000 (10:19 +0300)]
media: ccs: Rename ccs_create_subdev as ccs_init_subdev

The ccs_create_subdev() function initialises a sub-device in the CCS
driver, including CCS specific needs. Rename it as ccs_init_subdev() as it
better reflects what the function does.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Switch to init_cfg
Sakari Ailus [Wed, 9 Aug 2023 13:12:38 +0000 (16:12 +0300)]
media: ccs: Switch to init_cfg

Use init_cfg() instead of manually setting up defaults in file handle
open.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Correct error handling in ccs_register_subdev
Sakari Ailus [Wed, 23 Aug 2023 08:44:37 +0000 (11:44 +0300)]
media: ccs: Correct error handling in ccs_register_subdev

ccs_register_subdev() did not clean up the media entity in error case, do
that now. Also switch to goto based error handling.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Correctly initialise try compose rectangle
Sakari Ailus [Mon, 4 Sep 2023 12:57:37 +0000 (15:57 +0300)]
media: ccs: Correctly initialise try compose rectangle

Initialise the try sink compose rectangle size to the sink compose
rectangle for binner and scaler sub-devices. This was missed due to the
faulty condition that lead to the compose rectangles to be initialised for
the pixel array sub-device where it is not relevant.

Fixes: ccfc97bdb5ae ("[media] smiapp: Add driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ccs: Fix driver quirk struct documentation
Sakari Ailus [Thu, 24 Aug 2023 12:18:18 +0000 (15:18 +0300)]
media: ccs: Fix driver quirk struct documentation

Fix documentation for struct ccs_quirk, a device specific struct for
managing deviations from the standard. The flags field was drifted away
from where it should have been.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: Documentation: Align numbered list, make it a proper ReST
Sakari Ailus [Wed, 2 Aug 2023 12:11:50 +0000 (15:11 +0300)]
media: Documentation: Align numbered list, make it a proper ReST

Align lines for numbered list so that Sphinx produces an uniform output
for all list entries. Also indent paragraphs of such list entries for
consistency.

Also use ReST numbered list syntax for the entries.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Move variables to inner scope
Laurent Pinchart [Sun, 24 Sep 2023 15:33:09 +0000 (18:33 +0300)]
media: i2c: imx219: Move variables to inner scope

The exposure_max, exposure_def and hblank variables are only used in an
inner scope in the imx219_set_pad_format() function. Move them to that
scope to keep them closer to their usage and improve readability.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Name all subdev state variables 'state'
Laurent Pinchart [Sun, 24 Sep 2023 15:33:08 +0000 (18:33 +0300)]
media: i2c: imx219: Name all subdev state variables 'state'

Subdev state variables are named with a mix of 'state' and 'sd_state'
through the driver. To improve consistency, name them all 'state'.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Calculate crop rectangle dynamically
Laurent Pinchart [Sun, 24 Sep 2023 15:33:07 +0000 (18:33 +0300)]
media: i2c: imx219: Calculate crop rectangle dynamically

Calculate the crop rectangle size and location dynamically when setting
the format, instead of storing it in the imx219_mode structure. This
removes duplicated information from the mode, to guarantee consistency.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Separate horizontal and vertical binning
Laurent Pinchart [Sun, 24 Sep 2023 15:33:06 +0000 (18:33 +0300)]
media: i2c: imx219: Separate horizontal and vertical binning

The IMX219 has distinct binning registers for the horizontal and
vertical directions. Calculate their value and write them separately.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Implement .init_cfg() using .set_fmt()
Laurent Pinchart [Sun, 24 Sep 2023 15:33:05 +0000 (18:33 +0300)]
media: i2c: imx219: Implement .init_cfg() using .set_fmt()

Instead of duplicating the logical implemented in the .set_fmt()
operation in .init_cfg(), call .set_fmt() directly. This centralizes the
format and crop rectangle calculations in a single place.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Remove unneeded goto
Laurent Pinchart [Sun, 24 Sep 2023 15:33:04 +0000 (18:33 +0300)]
media: i2c: imx219: Remove unneeded goto

Simplify the imx219_set_stream() by removing an unneeded goto statement,
and its corresponding error label. The natural flow of the function is
correct.

While at it, drop a useless comment.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Group functions by purpose
Laurent Pinchart [Sun, 24 Sep 2023 15:33:03 +0000 (18:33 +0300)]
media: i2c: imx219: Group functions by purpose

Move functions around to group them by purpose, in order to improve
readability. No functional change is intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Drop IMX219_VTS_* macros
Laurent Pinchart [Sun, 24 Sep 2023 15:33:02 +0000 (18:33 +0300)]
media: i2c: imx219: Drop IMX219_VTS_* macros

The IMX219_VTS_* macros define default VTS values for the modes
supported by the driver. They are used in a single place, and hinder
readability compared to using the value directly as a decimal number.
Drop them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Don't store the current mode in the imx219 structure
Laurent Pinchart [Sun, 24 Sep 2023 15:33:01 +0000 (18:33 +0300)]
media: i2c: imx219: Don't store the current mode in the imx219 structure

The mode field of the imx219 structure is only used in
imx219_init_controls(), after the probe function sets it to point to the
default mode. Use the default mode directly when initializing controls,
and drop the mode field from the imx219 structure.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Access height from active format in imx219_set_ctrl
Laurent Pinchart [Sun, 24 Sep 2023 15:33:00 +0000 (18:33 +0300)]
media: i2c: imx219: Access height from active format in imx219_set_ctrl

Use the active format height instead of the mode height in
imx219_set_ctrl(). This prepares for dropping the mode field from the
imx219 structure.

The state is retrieved using v4l2_subdev_get_locked_active_state() as
the subdev active state and the control handler share the same lock.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Infer binning settings from format and crop
Laurent Pinchart [Sun, 24 Sep 2023 15:32:59 +0000 (18:32 +0300)]
media: i2c: imx219: Infer binning settings from format and crop

Compare the format and crop rectangle dimensions to infer binning
settings, instead of storing the binning mode in the imx219_mode
structure. This removes duplicate information from the mode.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Use active crop rectangle to configure registers
Laurent Pinchart [Sun, 24 Sep 2023 15:32:58 +0000 (18:32 +0300)]
media: i2c: imx219: Use active crop rectangle to configure registers

Configure the crop-related registers from the values stored in the
active crop rectangle instead of the mode structure. This removes usage
of the mode from the imx219_set_framefmt(). No functional change is
intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Initialize ycbcr_enc
Laurent Pinchart [Sun, 24 Sep 2023 15:32:57 +0000 (18:32 +0300)]
media: i2c: imx219: Initialize ycbcr_enc

While the ycbcr_enc field doesn't apply to raw formats, leaving it
uninitialized makes the driver behave in a less deterministic way. Fix
it by picking the default value for the colorspace.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Merge format and binning setting functions
Laurent Pinchart [Sun, 24 Sep 2023 15:32:56 +0000 (18:32 +0300)]
media: i2c: imx219: Merge format and binning setting functions

The imx219_set_binning() function sets registers based on the bpp value,
which is computed in imx219_set_framefmt(). As both functions are called
from the same place consecutively, and set registers based on the
selected mode, merge them together to simplify the code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Set mode registers programmatically
Laurent Pinchart [Sun, 24 Sep 2023 15:32:55 +0000 (18:32 +0300)]
media: i2c: imx219: Set mode registers programmatically

Replace the per-mode register arrays with code that sets the same
register values using the mode definitions. This avoids duplicating
information in two different places.

The error check for invalid formats in imx219_set_framefmt() is dropped
as the format is guaranteed to be valid.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Fix test pattern window for 640x480 mode
Laurent Pinchart [Sun, 24 Sep 2023 15:32:54 +0000 (18:32 +0300)]
media: i2c: imx219: Fix test pattern window for 640x480 mode

The 640x480 mode specifies incorrect values for the TP_WINDOW_WIDTH and
TP_WINDOW_HEIGHT registers, which likely got copied from the 1640x1232
mode. They should be identical to the X_OUTPUT_SIZE and Y_OUTPUT_SIZE
registers as for all the other modes, to avoid cropping the test
pattern. Fix them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Drop IMX219_REG_CSI_LANE_MODE from common regs array
Laurent Pinchart [Sun, 24 Sep 2023 15:32:53 +0000 (18:32 +0300)]
media: i2c: imx219: Drop IMX219_REG_CSI_LANE_MODE from common regs array

The IMX219_REG_CSI_LANE_MODE is configured twice, once with a hardcoded
value in the imx219_common_regs registers array, and once with the value
appropriate for the system in imx219_configure_lanes(). The latter is
enough, drop the former.

Fixes: ceddfd4493b3 ("media: i2c: imx219: Support four-lane operation")
Suggested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Replace register addresses with macros
Laurent Pinchart [Sun, 24 Sep 2023 15:32:52 +0000 (18:32 +0300)]
media: i2c: imx219: Replace register addresses with macros

Define macros for all the known registers used in the register arrays,
and use them to replace the numerical addresses. This improves
readability.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Drop unused macros
Laurent Pinchart [Sun, 24 Sep 2023 15:32:51 +0000 (18:32 +0300)]
media: i2c: imx219: Drop unused macros

Drop a handful of macros that are not used and don't provide any value.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: imx219: Convert to CCI register access helpers
Laurent Pinchart [Sun, 24 Sep 2023 15:32:50 +0000 (18:32 +0300)]
media: i2c: imx219: Convert to CCI register access helpers

Use the new common CCI register access helpers to replace the private
register access helpers in the imx219 driver. This simplifies the driver
by reducing the amount of code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: Add driver for onsemi MT9M114 camera sensor
Laurent Pinchart [Wed, 20 Sep 2023 17:11:54 +0000 (20:11 +0300)]
media: i2c: Add driver for onsemi MT9M114 camera sensor

The MT9M114 is a CMOS camera sensor that combines a 1296x976 pixel array
with a 10-bit dynamic range together with an internal ISP. The driver
exposes two subdevs, one for the pixel array and one for the ISP (named
IFP for Image Flow Processor). Major supported features are

- Full configuration of analog crop and binning in the pixel array
- Full configuration of scaling in the ISP
- Automatic exposure and white balance
- Manual exposure and analog gain
- Horizontal and vertical flip

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: dt-bindings: media: i2c: Add MT9M114 camera sensor binding
Laurent Pinchart [Wed, 20 Sep 2023 17:11:53 +0000 (20:11 +0300)]
media: dt-bindings: media: i2c: Add MT9M114 camera sensor binding

Add device tree binding for the onsemi MT9M114 CMOS camera sensor.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c/hi556: add a new mode 1296x722 settings
Bingbu Cao [Mon, 18 Sep 2023 02:58:12 +0000 (10:58 +0800)]
media: i2c/hi556: add a new mode 1296x722 settings

Add a new mode - 16:9 resolution 1296x722 for hi556.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Qingwu Zhang <qingwu.zhang@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: imx334: Orphan the driver
Sakari Ailus [Tue, 19 Sep 2023 11:09:57 +0000 (14:09 +0300)]
media: imx334: Orphan the driver

The current maintainers won't be looking after this driver anymore. Mark
it orphan.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: imx335: Orphan the driver
Sakari Ailus [Tue, 19 Sep 2023 11:09:32 +0000 (14:09 +0300)]
media: imx335: Orphan the driver

The current maintainers won't be looking after this driver anymore. Mark
it orphan.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: imx412: Orphan the driver
Sakari Ailus [Tue, 19 Sep 2023 11:06:06 +0000 (14:06 +0300)]
media: imx412: Orphan the driver

The current maintainers won't be looking after this driver anymore. Mark
it orphan.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: ov9282: Assign maintenance to Dave
Sakari Ailus [Tue, 19 Sep 2023 11:04:47 +0000 (14:04 +0300)]
media: ov9282: Assign maintenance to Dave

The current maintainers won't be looking after this driver anymore. Dave
offered to take over the driver, assign maintenance to him.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: platform: cros-ec: Add Taranza to the match table
Ken Lin [Thu, 5 Oct 2023 01:38:41 +0000 (09:38 +0800)]
media: platform: cros-ec: Add Taranza to the match table

Taranza has two HDMI ports which support CEC:
Port D is EC port 0
Port B is EC port 1

Signed-off-by: Ken Lin <ken_lin5@hotmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: platform: cros-ec: Rename conns array for the match table
Ken Lin [Thu, 5 Oct 2023 01:38:40 +0000 (09:38 +0800)]
media: platform: cros-ec: Rename conns array for the match table

Rename conns array to port_**_conns, ** is the ports which support cec.
ex: dibbi_conns support Port D and B will be renamed to port_db_conns.
Make it much cleaner and readable.

Signed-off-by: Ken Lin <ken_lin5@hotmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: dvb-frontends: drop check because i2c_unregister_device() is NULL safe
Wolfram Sang [Fri, 22 Sep 2023 08:04:20 +0000 (10:04 +0200)]
media: dvb-frontends: drop check because i2c_unregister_device() is NULL safe

No need to check the argument of i2c_unregister_device() because the
function itself does it.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: drop check because i2c_unregister_device() is NULL safe
Wolfram Sang [Fri, 22 Sep 2023 08:04:19 +0000 (10:04 +0200)]
media: i2c: drop check because i2c_unregister_device() is NULL safe

No need to check the argument of i2c_unregister_device() because the
function itself does it.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: cedrus: Fix clock/reset sequence
Jernej Skrabec [Mon, 11 Sep 2023 18:46:12 +0000 (20:46 +0200)]
media: cedrus: Fix clock/reset sequence

According to H6 user manual, resets should always be de-asserted before
clocks are enabled. This is also consistent with vendor driver.

Fixes: d5aecd289bab ("media: cedrus: Implement runtime PM")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: visl: use canonical ftrace path
Ross Zwisler [Tue, 29 Aug 2023 20:46:01 +0000 (14:46 -0600)]
media: visl: use canonical ftrace path

The canonical location for the tracefs filesystem is at
/sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

  Before 4.1, all ftrace tracing control files were within the debugfs
  file system, which is typically located at /sys/kernel/debug/tracing.
  For backward compatibility, when mounting the debugfs file system,
  the tracefs file system will be automatically mounted at:

  /sys/kernel/debug/tracing

Update the visl decoder driver documentation to use this tracefs path.

Signed-off-by: Ross Zwisler <zwisler@google.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: vidtv: mux: Add check and kfree for kstrdup
Jiasheng Jiang [Mon, 19 Jun 2023 08:12:02 +0000 (16:12 +0800)]
media: vidtv: mux: Add check and kfree for kstrdup

Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.
Moreover, use kfree() in the later error handling in order to avoid
memory leak.

Fixes: c2f78f0cb294 ("media: vidtv: psi: add a Network Information Table (NIT)")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: vidtv: psi: Add check for kstrdup
Jiasheng Jiang [Mon, 19 Jun 2023 08:12:01 +0000 (16:12 +0800)]
media: vidtv: psi: Add check for kstrdup

Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.

Fixes: 7a7899f6f58e ("media: vidtv: psi: Implement an Event Information Table (EIT)")
Fixes: c2f78f0cb294 ("media: vidtv: psi: add a Network Information Table (NIT)")
Fixes: f90cf6079bf6 ("media: vidtv: add a bridge driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: nuvoton: npcm-video: Fix IS_ERR() vs NULL bug
Dan Carpenter [Wed, 27 Sep 2023 12:39:43 +0000 (15:39 +0300)]
media: nuvoton: npcm-video: Fix IS_ERR() vs NULL bug

The of_parse_phandle() function returns NULL on error.  It never returns
error pointers.  Update the check accordingly.

Fixes: 70721089985c ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: s5p-mfc: Fix potential deadlock on condlock
Chengfeng Ye [Tue, 26 Sep 2023 10:53:30 +0000 (10:53 +0000)]
media: s5p-mfc: Fix potential deadlock on condlock

As &dev->condlock is acquired under irq context along the following
call chain from s5p_mfc_irq(), other acquisition of the same lock
inside process context or softirq context should disable irq avoid double
lock. enc_post_frame_start() seems to be one such function that execute
under process context or softirq context.

<deadlock #1>

enc_post_frame_start()
--> clear_work_bit()
--> spin_loc(&dev->condlock)
<interrupt>
   --> s5p_mfc_irq()
   --> s5p_mfc_handle_frame()
   --> clear_work_bit()
   --> spin_lock(&dev->condlock)

This flaw was found by an experimental static analysis tool I am
developing for irq-related deadlock.

To prevent the potential deadlock, the patch change clear_work_bit()
inside enc_post_frame_start() to clear_work_bit_irqsave().

Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: mediatek: vcodec: add encoder power management helper functions
Irui Wang [Mon, 25 Sep 2023 04:02:00 +0000 (12:02 +0800)]
media: mediatek: vcodec: add encoder power management helper functions

Remove PM functions at start/stop streaming, add PM helper functions
to get PM before encoding frame start and put PM after encoding frame
done. Meanwhile, remove unnecessary clock operations.

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: tvp541x: Sort header files
Biju Das [Sat, 23 Sep 2023 16:36:41 +0000 (17:36 +0100)]
media: tvp541x: Sort header files

Sort header files alphabetically.

Suggested-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: tvp541x: Drop CONFIG_OF ifdeffery
Biju Das [Sat, 23 Sep 2023 16:36:40 +0000 (17:36 +0100)]
media: tvp541x: Drop CONFIG_OF ifdeffery

Drop of_match_ptr() from tvp514x_driver and get rid of ugly CONFIG_OF
if check. This slightly increases the size of tvp514x_driver on non-OF
system and shouldn't be an issue.

Add mod_devicetable.h include.

It also allows, in case if needed, to enumerate this device via ACPI with
PRP0001 magic.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: tvp541x: Extend match support for OF tables
Biju Das [Sat, 23 Sep 2023 16:36:39 +0000 (17:36 +0100)]
media: tvp541x: Extend match support for OF tables

The driver has an OF match table, still, it uses an ID lookup table for
retrieving match data. Currently, the driver is working on the
assumption that an I2C device registered via OF will always match a
legacy I2C device ID. The correct approach is to have an OF device ID
table using i2c_get_match_data() if the devices are registered via OF/ID.

Unify the OF/ID table by using tvp514x_reg as match data for both
these tables and replace the ID lookup table for the match data by
i2c_get_match_data() and simplifly probe().

While at it, remove the trailing comma in the terminator entry for the OF
table making code robust against (theoretical) misrebases or other similar
things where the new entry goes _after_ the termination without the
compiler noticing.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: v4l2-event: Annotate struct v4l2_subscribed_event with __counted_by
Kees Cook [Fri, 22 Sep 2023 17:49:52 +0000 (10:49 -0700)]
media: v4l2-event: Annotate struct v4l2_subscribed_event with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for
struct v4l2_subscribed_event.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: lijian <lijian@yulong.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: allegro: Annotate struct mcu_msg_push_buffers_internal with __counted_by
Kees Cook [Fri, 22 Sep 2023 17:49:36 +0000 (10:49 -0700)]
media: allegro: Annotate struct mcu_msg_push_buffers_internal with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for
struct mcu_msg_push_buffers_internal.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Michael Tretter <m.tretter@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: s3c-camif: Avoid inappropriate kfree()
Katya Orlova [Fri, 22 Sep 2023 11:55:06 +0000 (14:55 +0300)]
media: s3c-camif: Avoid inappropriate kfree()

s3c_camif_register_video_node() works with video_device structure stored
as a field of camif_vp, so it should not be kfreed.
But there is video_device_release() on error path that do it.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: babde1c243b2 ("[media] V4L: Add driver for S3C24XX/S3C64XX SoC series camera interface")
Signed-off-by: Katya Orlova <e.orlova@ispras.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: cobalt: Use FIELD_GET() to extract Link Width
Ilpo Järvinen [Wed, 13 Sep 2023 12:27:40 +0000 (15:27 +0300)]
media: cobalt: Use FIELD_GET() to extract Link Width

Use FIELD_GET() to extract PCIe Negotiated and Maximum Link Width fields
instead of custom masking and shifting.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: adv7180: Drop CONFIG_OF ifdeffery
Biju Das [Sun, 10 Sep 2023 15:22:00 +0000 (16:22 +0100)]
media: i2c: adv7180: Drop CONFIG_OF ifdeffery

Drop of_match_ptr() from adv7180_driver and get rid of ugly CONFIG_OF
if check. This slightly increases the size of adv7180_driver on non-OF
system and shouldn't be an issue.

Add mod_devicetable.h include.

It also allows, in case if needed, to enumerate this device via ACPI with
PRP0001 magic.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: i2c: adv7180: Extend match support for OF tables
Biju Das [Sun, 10 Sep 2023 15:21:59 +0000 (16:21 +0100)]
media: i2c: adv7180: Extend match support for OF tables

The driver has an OF match table, still, it uses an ID lookup table for
retrieving match data. Currently, the driver is working on the
assumption that an I2C device registered via OF will always match a
legacy I2C device ID. The correct approach is to have an OF device ID
table using i2c_get_match_data() if the devices are registered via OF/ID.

Unify the OF/ID table by using struct adv7180_chip_info as match data for
both these tables and replace the ID lookup table for the match data by
i2c_get_match_data().

While at it, remove the trailing comma in the terminator entry for the OF
table making code robust against (theoretical) misrebases or other similar
things where the new entry goes _after_ the termination without the
compiler noticing.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: mtk-jpegenc: Fix bug in JPEG encode quality selection
Fei Shao [Fri, 8 Sep 2023 13:28:04 +0000 (21:28 +0800)]
media: mtk-jpegenc: Fix bug in JPEG encode quality selection

The driver uses the upper-bound approach to decide the target JPEG
encode quality, but there's a logic bug that if the desired quality is
higher than what the driver can support, the driver falls back to using
the worst quality.

Fix the bug by assuming using the best quality in the beginning, and
with trivial refactor to avoid long lines.

Fixes: 45f13a57d813 ("media: platform: Add jpeg enc feature")
Signed-off-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: platform: mtk-mdp3: add missing of_node_put
Julia Lawall [Thu, 7 Sep 2023 09:55:21 +0000 (11:55 +0200)]
media: platform: mtk-mdp3: add missing of_node_put

for_each_child_of_node performs an of_node_get on each
iteration, so a break out of the loop requires an
of_node_put.

This was done using the Coccinelle semantic patch
iterators/for_each_child.cocci

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: Documentation: dv-timings.rst: explain basic approach
Hans Verkuil [Thu, 7 Sep 2023 08:54:31 +0000 (10:54 +0200)]
media: Documentation: dv-timings.rst: explain basic approach

Explain how the DV Timings API and the V4L2_EVENT_SOURCE_CHANGE
event work together to handle video source changes.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: amphion: handle firmware debug message
Ming Qian [Thu, 7 Sep 2023 01:51:00 +0000 (09:51 +0800)]
media: amphion: handle firmware debug message

decoder firmware may notify host some debug message,
it can help analyze the state of the firmware in case of error

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Comment CSID dt_id field
Bryan O'Donoghue [Thu, 28 Sep 2023 00:58:25 +0000 (01:58 +0100)]
media: qcom: camss: Comment CSID dt_id field

Digging into the documentation we find that the DT_ID bitfield is used to
map the six bit DT to a two bit ID code. This value is concatenated to the
VC bitfield to create a CID value. DT_ID is the two least significant bits
of CID and VC the most significant bits.

Originally we set dt_id = vc * 4 in and then subsequently set dt_id = vc.

commit 3c4ed72a16bc ("media: camss: sm8250: Virtual channels for CSID")
silently fixed the multiplication by four which would give a better
value for the generated CID without mentioning what was being done or why.

Next up I haplessly changed the value back to "dt_id = vc * 4" since there
didn't appear to be any logic behind it.

Hans asked what the change was for and I honestly couldn't remember the
provenance of it, so I dug in.

Link: https://lore.kernel.org/linux-arm-msm/edd4bf9b-0e1b-883c-1a4d-50f4102c3924@xs4all.nl/
Add a comment so the next hapless programmer doesn't make this same
mistake.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Propagate vfe_reset error up the callstack
Bryan O'Donoghue [Mon, 25 Sep 2023 15:47:06 +0000 (16:47 +0100)]
media: qcom: camss: Propagate vfe_reset error up the callstack

A previous patch I had removed the returns from vfe_disable() since we
didn't trap any meaningful errors. Konrad pointed out vfe_reset() could
return an error, which is true.

Trap the vfe_reset() error code and throw it up the callstack.

Suggested-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Move vfe_disable into a common routine where applicable
Bryan O'Donoghue [Mon, 25 Sep 2023 15:47:05 +0000 (16:47 +0100)]
media: qcom: camss: Move vfe_disable into a common routine where applicable

We can move vfe_disable() into a common routine in the core VFE file
provided we make wm_stop() a VFE specific callback.

The callback is required to capture the case where VFE 17x currently isn't
VC enabled where as VFE 480 is.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Support RDI3 for VFE 17x
Bryan O'Donoghue [Mon, 25 Sep 2023 15:47:04 +0000 (16:47 +0100)]
media: qcom: camss: Support RDI3 for VFE 17x

Some VFEs have four RDIs apiece. Right now the ISR code has a hard-coded
value which tops-out at RDI2 meaning only three RDIs can be utilised in
practice.

Extend out the various routines in camss-vfe-17x.c to support the higher
RDI count.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Fix support for setting CSIPHY clock name csiphyX
Bryan O'Donoghue [Mon, 25 Sep 2023 15:47:03 +0000 (16:47 +0100)]
media: qcom: camss: Fix support for setting CSIPHY clock name csiphyX

Several of our upstream and soon-to-be upstream SoC CAMSS dtsi declare
csiphyX as opposed to the older clock name csiX_phy.

Right now the CAMSS code will fail to set the csiphyX clock even if we have
declared it in our list of clocks. For sdm845 and sm8250 we appear to "get
away" with this error, however on sc8280xp we don't.

The right approach here is to set the clock when it is declared. If a SoC
doesn't require or a SoC driver implementer doesn't think we need, then the
clock ought to simply be omitted from the clock list.

Include csiphyX in the set of permissible strings which will subsequently
lead to the csiphyX clock being set during csiphy_set_clock_rates() phase.

sdm845 and sm8250 will work with the code as-is so I've omitted this from a
suggested Fixes list.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Functionally decompose CSIPHY clock lookups
Bryan O'Donoghue [Mon, 25 Sep 2023 15:47:02 +0000 (16:47 +0100)]
media: qcom: camss: Functionally decompose CSIPHY clock lookups

The csiphyX_timer and csiX_phy values need not be hard-coded. We can
functionally decompose the string matching inside of a loop.

Static string values are brittle, difficult to extend and not required
anyway since the camss->res->csiphy_num value informs us of the number
of CSIPHYs and hence the set of potential clocks for a given CSIPHY.

In simple terms if we have five CSIPHYs we can have no more and no less
than five csiphy_timer clocks. Similarly csi_phy core clocks have a 1:1
relationship with the PHY they clock.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Allow clocks vfeN vfe_liteN or vfe_lite
Bryan O'Donoghue [Mon, 25 Sep 2023 15:47:01 +0000 (16:47 +0100)]
media: qcom: camss: Allow clocks vfeN vfe_liteN or vfe_lite

The number of Video Front End - VFE or Image Front End - IFE supported
with new SoCs can vary both for the full and lite cases.

For example sdm845 has one vfe_lite and two vfe interfaces with the vfe
clock called simply "vfe_lite" with no integer postfix. sc8280xp has four
vfe and four vfe lite blocks.

At the moment we declare vfe_lite0 and vfe_lite1 for sm8250 but never set
those clocks because we don't match the strings.

We need to support the following clock name formats

- vfeN
- vfe_liteN
- vfe_lite

with N being any reasonably sized integer.

There are two sites in this code which need to do the same thing,
constructing and matching strings with the pattern above, so encapsulate
the logic in one function.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Untangle if/else spaghetti in camss
Bryan O'Donoghue [Mon, 25 Sep 2023 15:47:00 +0000 (16:47 +0100)]
media: qcom: camss: Untangle if/else spaghetti in camss

We have a very convoluted if/else legacy here which needs to be
rationalised to make it more sustainable.

Adding in another Soc or two will make some of these if statements into
increasingly large multi-clause behemoths.

Introduce switches in the obvious places to despaghetiify.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Remove special case for VFE get/put
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:59 +0000 (16:46 +0100)]
media: qcom: camss: Remove special case for VFE get/put

From sdm845 onwards we need to ensure the VFE is powered on prior to
switching on the CSID.

Currently the code tests for sdm845, sm8250 and then does get/set. This is
not extensible and it turns out is not necessary either since vfe_get and
vfe_set reference count.

Remove the over-conservative SoC version check.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # rb3 # db410c
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Assign the correct number of RDIs per VFE
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:58 +0000 (16:46 +0100)]
media: qcom: camss: Assign the correct number of RDIs per VFE

Each Video Front End - VFE - has a variable number of Raw Data Interfaces -
RDIs associated with it.

The CAMSS code started from a naive implementation where a fixed define was
used as a control in a for(){} loop iterating through RDIs.

That model scales badly. An attempt was made with  VFE_LINE_NUM_GEN2 and
VFE_LINE_NUM_GEN1 to differentiate between SoCs but, the problem with that
is "gen1" and "gen2" have no meaning in the silicon. There is no fixed
constraint in the silicon between VFE and RDI, it is entirely up to the SoC
designers how many VFEs are populated and how many RDIs to associate with
each VFE.

As an example sdm845 has VFE version 175 and sm8250 VFE version 480.
sdm845 has 2 VFEs with 4 RDIs and 1 VFE Lite with 4 RDIs.
sm8250 has 2 VFEs with 3 RDIs and 2 VFE Lite with 4 RDIs.

Clearly then we need a more granular model to capture the necessary data.

The defines have gone away to be replaced with per-SoC data but, we haven't
populated the parameter data with the real values.

Let's call those values out now

msm8916:
1 x VFE
3 x RDI per VFE (not 4)

msm8996:
2 x VFE
3 x RDI per VFE (not 4)

sdm660:
2 x VFE
3 x RDI per VFE (not 4)

sdm845:
2 x VFE
4 x RDI per VFE (not 3)
1 x VFE Lite
4 x RDI per VFE Lite (not 3)

sm8250:
2 x VFE
3 x RDI per VFE (not 4)
2 x VFE Lite
4 x RDI per VFE Lite

This more complex and correct mapping was not possible prior to passing
values via driver data. Now that we have that change in place we can
correctly map VFEs to RDIs for each VFE.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Pass CAMSS subdev callbacks via resource ops pointer
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:57 +0000 (16:46 +0100)]
media: qcom: camss: Pass CAMSS subdev callbacks via resource ops pointer

It is possible to pass all of the CAMSS subdevice internal operations
pointers from the controlling resources structure with an additional
pointer added to the resources structure.

This allows for the removal of most of the probe-time control structures.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Pass line_num from compat resources
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:56 +0000 (16:46 +0100)]
media: qcom: camss: Pass line_num from compat resources

line_num indicates the number of RDI - raw data interface channels which
are associated with a given IFE/VFE - image/video front end.

On several SoCs the RDI number is not static for each VFE - for example
on sm8250 VFE Lite has four RDIs where regular VFE has three.

Assigning line_num statically in the subdev_init() phase initialises
each VFE to the lower number, meaning in practical terms that we are
lobbing off one RDI on some VFEs.

Interrupt handling uses static for (i = RDI0; i < RDI2; i++) {} in some
of our VFE blocks but this can't work for situations where we have a
mixture of VFE @ 3 RDI and VFE-lite @ 4 RDI blocks.

First step to remediate is to pass line_num from a compat string
controlled data-structure and do so on a per-VFE basis.

Later patches will assign the correct number of RDI blocks per VFE.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Pass remainder of variables as resources
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:55 +0000 (16:46 +0100)]
media: qcom: camss: Pass remainder of variables as resources

The following variables are being assigned statically based on
compatible strings in the probe path.

* enum camss_version version;
* unsigned int csiphy_num;
* unsigned int csid_num;
* unsigned int vfe_num;
* unsigned int vfe_lite_num;
* unsigned int vfe_total_num;

Migrate those variables to resource parameters passed in on platform
probe arguments. The one caveat is for VFE it has been necessary to
intoduce a new variable vfe_total_num to capture the aggregate value of
vfe_num + vfe_lite_num.

All the rest of the changes are rote camss->variable to
camss->res->variable with the parameter tables now populating the listed
variables.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Pass icc bandwidth table as a platform parameter
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:54 +0000 (16:46 +0100)]
media: qcom: camss: Pass icc bandwidth table as a platform parameter

Pass the bandwidth table as a platform parameter not if/else derived
pointer to the static table.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Start to move to module compat matched resources
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:53 +0000 (16:46 +0100)]
media: qcom: camss: Start to move to module compat matched resources

There is a lot of unnecessary if/elsing in this code that arguably
should never have made it upstream when adding a second let alone
subsequent SoC.

I'm guilty of not fixing the mess myself when adding in the sm8250.
Before adding in any new SoCs or resources lets take the time to cleanup
the resource passing.

First step is to pass the generic struct camss_resources as a parameter
per the compatible list.

Subsequent patches will address the other somewhat disparate strutures
which we are also doing if/else on and assigning statically.

Squashed down a commit to drop useless NULL assignment for ispif resources.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Rename camss struct resources to camss_subdev_resources
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:52 +0000 (16:46 +0100)]
media: qcom: camss: Rename camss struct resources to camss_subdev_resources

Rename non-specific struct resources {} to struct camss_subdev_resources {}

Each logical block in CAMSS has a number of regulators, clocks and resets
associated with it. We represent these blocks as v4l subdevices.

The name "struct camss_subdev_resources" is a more descriptive and accurate
name.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: qcom: camss: Amalgamate struct resource with struct resource_ispif
Bryan O'Donoghue [Mon, 25 Sep 2023 15:46:51 +0000 (16:46 +0100)]
media: qcom: camss: Amalgamate struct resource with struct resource_ispif

There is no good reason to differentiate the two resource structures
here. As part of a general tidyup of the declaration and passing of
resources within in the CAMSS driver it will be advantageous to have
one unified resource structure.

The two structures are very similar anyway thus leading more credence
still to the argument there should be only one.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: Documentation: Added Digiteq Automotive MGB4 driver documentation
Martin Tůma [Mon, 25 Sep 2023 14:36:05 +0000 (16:36 +0200)]
media: Documentation: Added Digiteq Automotive MGB4 driver documentation

The "admin-guide" documentation for the Digiteq Automotive MGB4 driver.

Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 months agomedia: pci: mgb4: Added Digiteq Automotive MGB4 driver
Martin Tůma [Mon, 25 Sep 2023 14:36:04 +0000 (16:36 +0200)]
media: pci: mgb4: Added Digiteq Automotive MGB4 driver

Digiteq Automotive MGB4 is a modular frame grabber PCIe card for automotive
video interfaces. As for now, two modules - FPD-Link and GMSL - are
available and supported by the driver. The card has two inputs and two
outputs (FPD-Link only).

In addition to the video interfaces it also provides a trigger signal
interface and a MTD interface for FPGA firmware upload.

Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: radio-si476x: don't fill in bus_info
Hans Verkuil [Sat, 23 Sep 2023 15:21:07 +0000 (17:21 +0200)]
media: radio-si476x: don't fill in bus_info

Let the V4L2 core fill in bus_info.

This fixes this warning:

drivers/media/radio/radio-si476x.c: In function 'si476x_radio_querycap':
drivers/media/radio/radio-si476x.c:333:28: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 23 [-Wformat-truncation=]
  333 |                  "platform:%s", radio->v4l2dev.name);
      |                            ^~
drivers/media/radio/radio-si476x.c:332:9: note: 'snprintf' output between 10 and 45 bytes into a destination of size 32
  332 |         snprintf(capability->bus_info, sizeof(capability->bus_info),
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  333 |                  "platform:%s", radio->v4l2dev.name);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: verisilicon: replace snprintf with strscpy+strlcat
Hans Verkuil [Sat, 23 Sep 2023 15:21:06 +0000 (17:21 +0200)]
media: verisilicon: replace snprintf with strscpy+strlcat

Fixes this warning:

drivers/media/platform/verisilicon/hantro_drv.c: In function 'hantro_add_func':
drivers/media/platform/verisilicon/hantro_drv.c:902:49: warning: '%s' directive output may be truncated writing up to 127 bytes into a region of size 64 [-Wformat-truncation=]
  902 |         snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
      |                                                 ^~
drivers/media/platform/verisilicon/hantro_drv.c:902:9: note: 'snprintf' output between 5 and 132 bytes into a destination of size 64
  902 |         snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903 |                  funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? "enc" : "dec");
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/verisilicon/hantro_drv.c:902:49: warning: '%s' directive output may be truncated writing up to 127 bytes into a region of size 64 [-Wformat-truncation=]
  902 |         snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
      |                                                 ^~
drivers/media/platform/verisilicon/hantro_drv.c:902:9: note: 'snprintf' output between 5 and 132 bytes into a destination of size 64
  902 |         snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903 |                  funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? "enc" : "dec");
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: radio-miropcm20: set bus_info to explicit name
Hans Verkuil [Sat, 23 Sep 2023 15:21:05 +0000 (17:21 +0200)]
media: radio-miropcm20: set bus_info to explicit name

Fill in bus_info with fixed name.

This fixes this compiler warning:

drivers/media/radio/radio-miropcm20.c: In function 'vidioc_querycap':
drivers/media/radio/radio-miropcm20.c:206:57: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 28 [-Wformat-truncation=]
  206 |         snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", dev->v4l2_dev.name);
      |                                                         ^~
drivers/media/radio/radio-miropcm20.c:206:9: note: 'snprintf' output between 5 and 40 bytes into a destination of size 32
  206 |         snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", dev->v4l2_dev.name);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: radio-isa: use dev_name to fill in bus_info
Hans Verkuil [Sat, 23 Sep 2023 15:21:04 +0000 (17:21 +0200)]
media: radio-isa: use dev_name to fill in bus_info

This fixes this warning:

drivers/media/radio/radio-isa.c: In function 'radio_isa_querycap':
drivers/media/radio/radio-isa.c:39:57: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 28 [-Wformat-truncation=]
   39 |         snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", isa->v4l2_dev.name);
      |                                                         ^~
drivers/media/radio/radio-isa.c:39:9: note: 'snprintf' output between 5 and 40 bytes into a destination of size 32
   39 |         snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", isa->v4l2_dev.name);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: atmel: drop bus_info
Hans Verkuil [Sat, 23 Sep 2023 15:21:03 +0000 (17:21 +0200)]
media: atmel: drop bus_info

Let the V4L2 core fill this in.

Fixes this warning:

drivers/staging/media/deprecated/atmel/atmel-isc-base.c: In function 'isc_querycap':
drivers/staging/media/deprecated/atmel/atmel-isc-base.c:496:28: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 23 [-Wformat-truncation=]
  496 |                  "platform:%s", isc->v4l2_dev.name);
      |                            ^~
drivers/staging/media/deprecated/atmel/atmel-isc-base.c:495:9: note: 'snprintf' output between 10 and 45 bytes into a destination of size 32
  495 |         snprintf(cap->bus_info, sizeof(cap->bus_info),
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  496 |                  "platform:%s", isc->v4l2_dev.name);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
9 months agomedia: am437x: don't fill in bus_info
Hans Verkuil [Sat, 23 Sep 2023 15:21:02 +0000 (17:21 +0200)]
media: am437x: don't fill in bus_info

Let the V4L2 core fill this in.

This fixes this warning:

drivers/media/platform/ti/am437x/am437x-vpfe.c: In function 'vpfe_querycap':
drivers/media/platform/ti/am437x/am437x-vpfe.c:1279:35: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 23 [-Wformat-truncation=]
 1279 |                         "platform:%s", vpfe->v4l2_dev.name);
      |                                   ^~
drivers/media/platform/ti/am437x/am437x-vpfe.c:1278:9: note: 'snprintf' output between 10 and 45 bytes into a destination of size 32
 1278 |         snprintf(cap->bus_info, sizeof(cap->bus_info),
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1279 |                         "platform:%s", vpfe->v4l2_dev.name);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Lad Prabhakar <prabhakar.csengg@gmail.com>
9 months agomedia: rcar_drif: use explicit name for bus_info
Hans Verkuil [Sat, 23 Sep 2023 15:21:01 +0000 (17:21 +0200)]
media: rcar_drif: use explicit name for bus_info

Fixes this compiler warning:

drivers/media/platform/renesas/rcar_drif.c: In function 'rcar_drif_querycap':
drivers/media/platform/renesas/rcar_drif.c:874:66: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 23 [-Wformat-truncation=]
  874 |         snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
      |                                                                  ^~
drivers/media/platform/renesas/rcar_drif.c:874:9: note: 'snprintf' output between 10 and 73 bytes into a destination of size 32
  874 |         snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  875 |                  sdr->vdev->name);
      |                  ~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
9 months agomedia: microchip: don't set bus_info
Hans Verkuil [Sat, 23 Sep 2023 15:21:00 +0000 (17:21 +0200)]
media: microchip: don't set bus_info

Let the V4L2 core fill this in.

Fixes these compiler warnings:

drivers/media/platform/microchip/microchip-isc-base.c: In function 'isc_querycap':
drivers/media/platform/microchip/microchip-isc-base.c:486:28: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 23 [-Wformat-truncation=]
  486 |                  "platform:%s", isc->v4l2_dev.name);
      |                            ^~
drivers/media/platform/microchip/microchip-isc-base.c:485:9: note: 'snprintf' output between 10 and 45 bytes into a destination of size 32
  485 |         snprintf(cap->bus_info, sizeof(cap->bus_info),
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  486 |                  "platform:%s", isc->v4l2_dev.name);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/microchip/microchip-isc-base.c: In function 'isc_mc_init':
drivers/media/platform/microchip/microchip-isc-base.c:1996:76: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 23 [-Wformat-truncation=]
 1996 |         snprintf(isc->mdev.bus_info, sizeof(isc->mdev.bus_info), "platform:%s",
      |                                                                            ^~
drivers/media/platform/microchip/microchip-isc-base.c:1996:9: note: 'snprintf' output between 10 and 45 bytes into a destination of size 32
 1996 |         snprintf(isc->mdev.bus_info, sizeof(isc->mdev.bus_info), "platform:%s",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1997 |                  isc->v4l2_dev.name);
      |                  ~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
9 months agomedia: vivid: use VIVID_MODULE_NAME to fill bus_info
Hans Verkuil [Sat, 23 Sep 2023 15:20:59 +0000 (17:20 +0200)]
media: vivid: use VIVID_MODULE_NAME to fill bus_info

Fixes this compiler warning:

drivers/media/test-drivers/vivid/vivid-core.c: In function 'vidioc_querycap':
drivers/media/test-drivers/vivid/vivid-core.c:243:35: warning: '%s' directive output may be truncated writing up to 35 bytes into a region of size 23 [-Wformat-truncation=]
  243 |                         "platform:%s", dev->v4l2_dev.name);
      |                                   ^~
drivers/media/test-drivers/vivid/vivid-core.c:242:9: note: 'snprintf' output between 10 and 45 bytes into a destination of size 32
  242 |         snprintf(cap->bus_info, sizeof(cap->bus_info),
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  243 |                         "platform:%s", dev->v4l2_dev.name);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>