platform/kernel/linux-starfive.git
13 months agomedia: video-mux: update driver to active state
Philipp Zabel [Wed, 24 May 2023 13:29:25 +0000 (14:29 +0100)]
media: video-mux: update driver to active state

Drop the open coded pad format array, use subdev active state instead.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: video-mux: fix error paths
Philipp Zabel [Wed, 24 May 2023 13:29:24 +0000 (14:29 +0100)]
media: video-mux: fix error paths

Move notifier cleanup into video_mux_async_register() to avoid calling
v4l2_async_nf_unregister() when v4l2_async_subdev_nf_register() failed.
In case video_mux_async_register() fails, call media_entity_cleanup().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: pci: cx18-av-vbi: Replace one-element array with flexible-array member
Gustavo A. R. Silva [Wed, 24 May 2023 00:20:38 +0000 (01:20 +0100)]
media: pci: cx18-av-vbi: Replace one-element array with flexible-array member

One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element arrays with flexible-array
members in struct vbi_anc_data.

This results in no differences in binary output.

Link: https://github.com/KSPP/linux/issues/79
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: Revert "media: exynos4-is: Remove dependency on obsolete SoC support"
Artur Weber [Fri, 19 May 2023 18:28:53 +0000 (19:28 +0100)]
media: Revert "media: exynos4-is: Remove dependency on obsolete SoC support"

Support for the Exynos4212 SoC was originally dropped as there were
no boards using it. We will be adding a device that uses it, so add
it back.

This reverts commit 2d41a0c9ae51ac363d107f2510022106e7234b33.

Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: staging: max96712: Switch i2c driver back to use .probe()
Uwe Kleine-König [Wed, 24 May 2023 15:16:44 +0000 (16:16 +0100)]
media: staging: max96712: Switch i2c driver back to use .probe()

After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
commit 03c835f498b5 ("i2c: Switch .probe() to not take an id parameter")
convert back to (the new) .probe() to be able to eventually drop
.probe_new() from struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: mediatek: vcodec: using empty lat buffer as the last one
Yunfei Dong [Thu, 25 May 2023 01:40:09 +0000 (02:40 +0100)]
media: mediatek: vcodec: using empty lat buffer as the last one

Adding one empty lat buffer with parameter 'is_empty_flag = true'
used to flush core work queue decode.

Queue the empty lat buffer to core list when driver need to flush decode.
It's mean core already decode all existed lat buffer when get empty lat
buffer, then wake up core decode done event, the driver will exit when
getting core dec done event.

Fixes: d227af847ac2 ("media: mediatek: vcodec: add core decode done event")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: mediatek: vcodec: move core context from device to each instance
Yunfei Dong [Thu, 25 May 2023 01:40:08 +0000 (02:40 +0100)]
media: mediatek: vcodec: move core context from device to each instance

There are so many lat buffer in core context list, some instances
maybe be scheduled for a very long time. Moving the core context to
each instance, it only be used to control lat buffer of each instance.
And the core work queue of each instance is scheduled by system.

Fixes: 2cfca6c1bf80 ("media: mediatek: vcodec: move lat_buf to the top of core list")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: mediatek: vcodec: using decoder status instead of core work count
Yunfei Dong [Thu, 25 May 2023 01:40:07 +0000 (02:40 +0100)]
media: mediatek: vcodec: using decoder status instead of core work count

Adding the definition of decoder status to separate different decoder
period for core hardware.

core_work_cnt is the number of core work queued to work queue, the control
is very complex, leading to some unreasonable test result.

Using parameter status to indicate whether queue core work to work queue.

Fixes: 2e0ef56d81cb ("media: mediatek: vcodec: making sure queue_work successfully")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: mediatek: vcodec: Avoid unneeded error logging
Yunfei Dong [Thu, 25 May 2023 01:40:06 +0000 (02:40 +0100)]
media: mediatek: vcodec: Avoid unneeded error logging

Since the LAT decoder works faster than its CORE, getting the trans
buffer may be done only after CORE finishes processing: avoid printing
an error if the decode function returns -EAGAIN, as this means that
the buffer from CORE is not yet available, but will be at a later time.

Also change the log level for calls to vdec_msg_queue_dqbuf() in H264
and VP9 LAT decoder drivers to avoid excessive logging.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: staging: media: imx: initialize hs_settle to avoid warning
Hans Verkuil [Tue, 18 Apr 2023 07:46:52 +0000 (08:46 +0100)]
media: staging: media: imx: initialize hs_settle to avoid warning

Initialize hs_settle to 0 to avoid this compiler warning:

imx8mq-mipi-csi2.c: In function 'imx8mq_mipi_csi_start_stream.part.0':
imx8mq-mipi-csi2.c:91:55: warning: 'hs_settle' may be used uninitialized [-Wmaybe-uninitialized]
   91 | #define GPR_CSI2_1_S_PRG_RXHS_SETTLE(x) (((x) & 0x3f) << 2)
      |                                                       ^~
imx8mq-mipi-csi2.c:357:13: note: 'hs_settle' was declared here
  357 |         u32 hs_settle;
      |             ^~~~~~~~~

It's a false positive, but it is too complicated for the compiler to detect that.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
13 months agomedia: v4l2-mc: Drop subdev check in v4l2_create_fwnode_links_to_pad()
Vaishnav Achath [Fri, 21 Apr 2023 10:04:30 +0000 (11:04 +0100)]
media: v4l2-mc: Drop subdev check in v4l2_create_fwnode_links_to_pad()

While updating v4l2_create_fwnode_links_to_pad() to accept non-subdev
sinks, the check is_media_entity_v4l2_subdev() was not removed which
prevented the function from being used with non-subdev sinks, Drop the
unnecessary check.

Fixes: bd5a03bc5be8 ("media: Accept non-subdev sinks in v4l2_create_fwnode_links_to_pad()")
Signed-off-by: Vaishnav Achath <vaishnav.a@ti.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@kernel.org>
13 months agomedia: sti: c8sectpfe: drop of_match_ptr() to avoid unused variables
Alain Volmat [Sat, 4 Feb 2023 20:29:40 +0000 (21:29 +0100)]
media: sti: c8sectpfe: drop of_match_ptr() to avoid unused variables

When CONFIG_OF is not set, "of_match_ptr(<match_table>)" compiles to NULL,
which leaves <match_table> unused, leading to warning such as:

drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c:1175:34:
warning: unused variable 'c8sectpfe_match' [-Wunused-const-variable]

Drop the of_match_ptr usage to avoid such warning.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alain Volmat <avolmat@me.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: c8sectpfe: switch to using gpiod API
Dmitry Torokhov [Fri, 3 Feb 2023 23:13:48 +0000 (15:13 -0800)]
media: c8sectpfe: switch to using gpiod API

This switches the driver from using legacy gpio API and to the newer
gpiod API. Since ordinary gpiod APIs operate on logical and not
electrical levels, handling of the reset GPIO is adjusted accordingly.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: rcar-vin: Add support for R-Car V4H
Niklas Söderlund [Sat, 11 Feb 2023 14:55:19 +0000 (15:55 +0100)]
media: rcar-vin: Add support for R-Car V4H

Add support for R-Car V4H. The V4H uses the ISP Channel Selector as its
only possible video input source. Even tho V4H is a Gen3 board the VIN
interface is very close to the one found on the V3U, for this reason
mark it as a Gen3 model internally.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: rcar-isp: Add support for R-Car V4H
Niklas Söderlund [Sat, 11 Feb 2023 14:54:36 +0000 (15:54 +0100)]
media: rcar-isp: Add support for R-Car V4H

Add support for R-Car V4H. The ISP Channel Selector is used to route
channels to the different VIN modules. The ISP CS found in the V4H is
very similar to the one found on the V3U.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: staging: max96712: Add support for 3-lane C-PHY
Niklas Söderlund [Sat, 11 Feb 2023 14:46:14 +0000 (15:46 +0100)]
media: staging: max96712: Add support for 3-lane C-PHY

Add basic support for outputting the test patterns on a 3-lane CSI-2
C-PHY bus. As the driver only can output frames form its internal test
pattern generator, enabling C-PHY output is as simple as setting the
output mode to C-PHY instead of D-PHY.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
[Sakari Ailus: Wrap long lines.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt()
Laurent Pinchart [Wed, 19 Apr 2023 07:07:12 +0000 (09:07 +0200)]
media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt()

Use the __imx7_csi_video_try_fmt() helper function to initialize the
default format at probe time. This improves consistency by using the
same code path for both default initialization and validation at
runtime, and allows dropping the now unused imx7_csi_find_pixel_format()
function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: imx: imx7-media-csi: Relax width constraints for non-8bpp formats
Alexander Stein [Wed, 19 Apr 2023 07:07:11 +0000 (09:07 +0200)]
media: imx: imx7-media-csi: Relax width constraints for non-8bpp formats

The driver unconditionally aligns the image width to multiples of 8
pixels. The real alignment constraint is 8 bytes, as indicated by the
CSI_IMAG_PARA.IMAGE_WIDTH documentation that calls for 8 pixel alignment
for 8bpp formats and 4 pixel alignment for other formats.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: imx: imx7-media-csi: Remove incorrect interlacing support
Alexander Stein [Wed, 19 Apr 2023 07:07:10 +0000 (09:07 +0200)]
media: imx: imx7-media-csi: Remove incorrect interlacing support

The driver doesn't currently support interlacing, but due to legacy
leftovers, it accepts values for the pixel format "field" field other
than V4L2_FIELD_NONE. Fix it by hardcoding V4L2_FIELD_NONE. Proper
interlacing support can be implemented later if desired.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt
Alexander Stein [Wed, 19 Apr 2023 07:07:09 +0000 (09:07 +0200)]
media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt

There is no need to convert input pixformat to mbus_framefmt and back
again. Instead apply pixformat width constrains directly.
Assign compose values before adjusting pixformat height/width.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: hi846: fix usage of pm_runtime_get_if_in_use()
Martin Kepplinger [Tue, 25 Apr 2023 09:47:47 +0000 (11:47 +0200)]
media: hi846: fix usage of pm_runtime_get_if_in_use()

pm_runtime_get_if_in_use() does not only return nonzero values when
the device is in use, it can return a negative errno too.

And especially during resuming from system suspend, when runtime pm
is not yet up again, -EAGAIN is being returned, so the subsequent
pm_runtime_put() call results in a refcount underflow.

Fix system-resume by handling -EAGAIN of pm_runtime_get_if_in_use().

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Fixes: e8c0882685f9 ("media: i2c: add driver for the SK Hynix Hi-846 8M pixel camera")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: rcar-csi2: Prepare for C-PHY support
Niklas Söderlund [Mon, 24 Apr 2023 18:59:33 +0000 (20:59 +0200)]
media: rcar-csi2: Prepare for C-PHY support

Gen4 will support both D-PHY and C-PHY, while Gen3 only supports D-PHY.
Add two flags to the device information structure to be able to record
what each SoC supports.

Extend the device node parsing to accept both CSI_2 D-PHY and C-PHY
buses, while at the same time taking the SoC support into account.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
[Sakari Ailus: Line wrap.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: rcar-csi2: Prepare for Gen4 support
Niklas Söderlund [Mon, 24 Apr 2023 18:59:32 +0000 (20:59 +0200)]
media: rcar-csi2: Prepare for Gen4 support

Prepare the driver for supporting R-Car Gen4. The starting of the
receiver and how to enter standby differs between Gen3 and Gen4,
create function pointers in the device info structure to control the
different behavior.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: i2c: add ov01a10 image sensor driver
Bingbu Cao [Sun, 23 Apr 2023 08:06:55 +0000 (16:06 +0800)]
media: i2c: add ov01a10 image sensor driver

Add v4l2 device driver for OmniVision ov01a10 image sensor, ov01a10
image sensor can deliver 1280x800 resolution BGGR10 images at 60 fps.

Signed-off-by: Yating Wang <yating.wang@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: renesas: fdp1: Identify R-Car Gen2 versions
Geert Uytterhoeven [Wed, 26 Apr 2023 10:18:24 +0000 (12:18 +0200)]
media: renesas: fdp1: Identify R-Car Gen2 versions

On R-Car M2-W:

    rcar_fdp1 fe940000.fdp1: FDP1 Unidentifiable (0x02010101)
    rcar_fdp1 fe944000.fdp1: FDP1 Unidentifiable (0x02010101)

Although the IP Internal Data Register on R-Car Gen2 is documented to
contain all zeros, the actual register contents seem to match the FDP1
version ID of R-Car H3 ES1.*, which has just been removed.
Fortunately this version is not used for any other purposes yet.

Fix this by re-adding the ID, now using an R-Car Gen2-specific name.

Fixes: af4273b43f2b ("media: renesas: fdp1: remove R-Car H3 ES1.* handling")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: st-mipid02: Propagate format from sink to source pad
Daniel Scally [Tue, 2 May 2023 10:35:47 +0000 (11:35 +0100)]
media: st-mipid02: Propagate format from sink to source pad

When setting formats on the sink pad, propagate the adjusted format over
to the subdev's source pad. Use the MIPID02_SOURCE macro to fetch the
pad's try format rather than relying on the pad field of the format to
facilitate this - the function is specific to the source pad anyway.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
[Sakari Ailus: Line wrap, fix subject]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: i2c: Correct format propagation for st-mipid02
Daniel Scally [Tue, 2 May 2023 10:35:46 +0000 (11:35 +0100)]
media: i2c: Correct format propagation for st-mipid02

Format propagation in the st-mipid02 driver is incorrect in that when
setting format for V4L2_SUBDEV_FORMAT_TRY on the source pad, the
_active_ rather than _try_ format from the sink pad is propagated.
This causes problems with format negotiation - update the function to
propagate the correct format.

Fixes: 642bb5e88fed ("media: st-mipid02: MIPID02 CSI-2 to PARALLEL bridge driver")
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: video-mux: Add missing media_entity_cleanup upon async register fail
Alexander Stein [Tue, 2 May 2023 14:15:43 +0000 (16:15 +0200)]
media: video-mux: Add missing media_entity_cleanup upon async register fail

Although media_entity_pads_init has been called, a call to
media_entity_cleanup in the cleanup code was missing.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: i2c: video: constify pointers to hwmon_channel_info
Krzysztof Kozlowski [Thu, 11 May 2023 17:54:41 +0000 (19:54 +0200)]
media: i2c: video: constify pointers to hwmon_channel_info

Statically allocated array of pointers to hwmon_channel_info can be made
const for safety.

Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: ov5640: Drop dead code using frame_interval
Jacopo Mondi [Fri, 5 May 2023 07:16:19 +0000 (09:16 +0200)]
media: ov5640: Drop dead code using frame_interval

The ov5640_update_pixel_rate() function handles the parallel and MIPI
CSI-2 cases separately.

When running on a parallel setup the V4L2_CID_PIXEL_RATE value is
calculated at the beginning of the function using the values configured
with the frame_interval operations, and then the function immediately
returns.

The remaining of the function handles the MIPI CSI-2 configuration and
should not use the 'current_fr' and 'def_fps' fields as those are only
relevant for parallel mode.

Drop a small section of dead code that updates vblank using
frame_interval on a MIPI CSI-2 setup.

Signed-off-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>
13 months agomedia: ov5640: Remove unused 'framerate' parameter
Jacopo Mondi [Fri, 5 May 2023 07:16:18 +0000 (09:16 +0200)]
media: ov5640: Remove unused 'framerate' parameter

The 'current framerate' parameter passed to ov5640_try_fmt_internal() is
unsued. Drop it.

Signed-off-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>
13 months agomedia: ov5640: correct comments for default VGA to avoid confusion
Guoniu.zhou [Tue, 9 May 2023 06:56:45 +0000 (14:56 +0800)]
media: ov5640: correct comments for default VGA to avoid confusion

When OV5640 work at DVP mode, the default initialization settings
make it output 30 frames per second. But when it work at CSI-2 mode
the default link frequency will make it output 60 frames per second,
so correct the comments to make it more clear.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.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>
13 months agodt-bindings: i2c: maxim,max96712: Require setting bus-type property
Niklas Söderlund [Tue, 9 May 2023 19:00:31 +0000 (21:00 +0200)]
dt-bindings: i2c: maxim,max96712: Require setting bus-type property

The MAX96712 can support both a CSI-2 C-PHY and D-PHY bus. The initial
staging driver however only supported D-PHY and the bus-type property
was left optional.

In preparation for adding C-PHY support to the staging driver make the
bus-type property mandatory as it is needed to select the correct PHY
mode. Without the bus-type property present, the driver falls-back to
D-PHY mode, so the change is functionally backward compatible with old
DTS files lacking the property.

The only in-tree DTS file (renesas/r8a779a0-falcon-csi-dsi.dtsi) that
lacked the property uses D-PHY and have been updated.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: i2c: imx334: update pixel, hblank and link frequency
Shravan Chippa [Fri, 14 Apr 2023 12:33:11 +0000 (18:03 +0530)]
media: i2c: imx334: update pixel, hblank and link frequency

Update pixel_rate and link frequency for 1920x1080@30
while changing mode.

Update vblank value while changing mode

Add support to handle multiple link frequencies.

Add dummy ctrl cases for pixel_rate and link frequency
to avoid error while changing the modes dynamically.

Update default link frequency from device tree max link
frequency value.

Update init_cfg() function to update the link frequency
menu_skip_mask value.

Suggested-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Shravan Chippa <shravan.chippa@microchip.com>
[Sakari Ailus: Document menu_skip_mask, remove extra blank line.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: ipu3-cio2: Fix container_of() macro wrapper arguments
Sakari Ailus [Mon, 17 Apr 2023 09:29:59 +0000 (12:29 +0300)]
media: ipu3-cio2: Fix container_of() macro wrapper arguments

The argument of the to_sensor_asd() is called the same as the field name
for the container_of() macro, so it only works if the argument name is
"asd". Fix it.

Also switch to container_of_const().

Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: uapi: Fix [GS]_ROUTING ACTIVE flag value
Sakari Ailus [Mon, 24 Apr 2023 12:22:37 +0000 (15:22 +0300)]
media: uapi: Fix [GS]_ROUTING ACTIVE flag value

The value of the V4L2_SUBDEV_ROUTE_FL_ACTIVE is 1, not 0. Use hexadecimal
numbers as is done elsewhere in the documentation.

Cc: stable@vger.kernel.org # for >= v6.3
Fixes: ea73eda50813 ("media: Documentation: Add GS_ROUTING documentation")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: dt-bindings: qcom: camss: correct unit address
Krzysztof Kozlowski [Thu, 20 Apr 2023 07:24:42 +0000 (09:24 +0200)]
media: dt-bindings: qcom: camss: correct unit address

Match unit-address to first reg entry.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: ov5693: Simplify an error message
Christophe JAILLET [Sat, 15 Apr 2023 16:28:58 +0000 (18:28 +0200)]
media: ov5693: Simplify an error message

dev_err_probe() already display the error code. There is no need to
duplicate it explicitly in the error message.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: uapi: Use unsigned int values for assigning bits in u32 fields
Sakari Ailus [Mon, 24 Apr 2023 09:52:12 +0000 (12:52 +0300)]
media: uapi: Use unsigned int values for assigning bits in u32 fields

Use unsigned int values annoted by "U" for u32 fields. While this is a
good practice, there doesn't appear to be a bug that this patch would fix.

The patch has been generated using the following command:

perl -i -pe 's/\([0-9]+\K <</U <</g; s/\|\s*0\K\)/U\)/' \
include/uapi/linux/media.h

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>
13 months agomedia: Documentation: Rename meta format files
Sakari Ailus [Wed, 26 Apr 2023 09:50:39 +0000 (12:50 +0300)]
media: Documentation: Rename meta format files

Rename meta format files, using "metafmt" prefix instead of "pixfmt-meta".
These are metadata formats, not pixel formats.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Bingbu Cao <bingbu.cao@intel.com>
Cc: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: mc: Make media_get_pad_index() use pad type flag
Sakari Ailus [Tue, 25 Apr 2023 10:23:00 +0000 (13:23 +0300)]
media: mc: Make media_get_pad_index() use pad type flag

Use the pad flag specifying the pad type instead of a boolean in
preparation for internal source pads.

Also make the loop variable unsigned.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: pci: ipu3-cio2: Obtain remote pad from endpoint
Sakari Ailus [Tue, 2 May 2023 09:14:08 +0000 (12:14 +0300)]
media: pci: ipu3-cio2: Obtain remote pad from endpoint

Use the endpoint fwnode to find out the remote pad, instead of using the
first source pad found. Also improve error messages.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: mc: Make media_entity_get_fwnode_pad() fwnode argument const
Sakari Ailus [Fri, 5 May 2023 13:27:49 +0000 (16:27 +0300)]
media: mc: Make media_entity_get_fwnode_pad() fwnode argument const

fwnode_graph_parse_endpoint() fwnode argument is now const, therefore make
media_entity_get_fwnode_pad() fwnode argument const as well.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agoDocumentation: v4l: Document rotation and orientation for sensor drivers
Sakari Ailus [Tue, 28 Mar 2023 12:54:59 +0000 (15:54 +0300)]
Documentation: v4l: Document rotation and orientation for sensor drivers

Document how rotation and orientation should be taken into account in
writing camera sensor drivers.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: admin-guide: Update rkisp1.rst
Jack Zhu [Wed, 15 Mar 2023 03:00:40 +0000 (11:00 +0800)]
media: admin-guide: Update rkisp1.rst

Update Rockchip ISP1 driver file path

Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: i2c: imx296: fix error checking in imx296_read_temperature()
Dan Carpenter [Wed, 22 Feb 2023 13:59:51 +0000 (16:59 +0300)]
media: i2c: imx296: fix error checking in imx296_read_temperature()

The "& IMX296_TMDOUT_MASK" means that "tmdout" can't be negative so the
error checking will not work.

Fixes: cb33db2b6ccf ("media: i2c: IMX296 camera sensor driver")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: mediatek: vcodec: support stateless hevc decoder
Yunfei Dong [Wed, 24 May 2023 08:07:39 +0000 (16:07 +0800)]
media: mediatek: vcodec: support stateless hevc decoder

Add mediatek hevc decoder linux driver which use the stateless API in
MT8195.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Nathan Hebert <nhebert@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: add () around 'flag' in macro]

13 months agomedia: uapi: HEVC: Add num_delta_pocs_of_ref_rps_idx field
Benjamin Gaignard [Wed, 24 May 2023 08:07:38 +0000 (16:07 +0800)]
media: uapi: HEVC: Add num_delta_pocs_of_ref_rps_idx field

Some drivers firmwares parse by themselves slice header and need
num_delta_pocs_of_ref_rps_idx value to parse slice header
short_term_ref_pic_set().
Use one of the 4 reserved bytes to store this value without
changing the v4l2_ctrl_hevc_decode_params structure size and padding.

This value also exist in DXVA API.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: fix typo in num_delta_pocs_of_ref_rps_idx doc]

13 months agomedia: Switch i2c drivers back to use .probe()
Uwe Kleine-König [Sun, 14 May 2023 12:04:07 +0000 (14:04 +0200)]
media: Switch i2c drivers back to use .probe()

After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
commit 03c835f498b5 ("i2c: Switch .probe() to not take an id parameter")
convert back to (the new) .probe() to be able to eventually drop
.probe_new() from struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: Add common header file with JPEG marker definitions
Geert Uytterhoeven [Tue, 23 May 2023 15:16:00 +0000 (17:16 +0200)]
media: Add common header file with JPEG marker definitions

When compile-testing on mips/RB532 with W=1:

    arch/mips/include/asm/mach-rc32434/rb.h:13: note: this is the location of the previous definition
       13 | #define RST  (1 << 15)
  |
    drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_parse.c:15: warning: "RST" redefined
       15 | #define RST 0xd0
  |
    drivers/media/platform/renesas/rcar_jpu.c:77: warning: "RST" redefined
       77 | #define RST 0xd0
  |

"RST" is indeed a name too short to be conflict-free.

Fix this by creating a common <media/jpeg.h> header file, containing
definitions for all JPEG markers used, prefixed by "JPEG_MARKER_", based
on the existing private definitions in the Samsung S5P JPEG driver, and
convert all affected drivers.

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202304152346.hJOPxPRh-lkp@intel.com/
Link: https://lore.kernel.org/oe-kbuild-all/202304150059.bHUyuriy-lkp@intel.com/
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> (s5p-jpeg)
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: nxp: remove unneeded semicolon
Jiapeng Chong [Fri, 5 May 2023 06:06:17 +0000 (14:06 +0800)]
media: nxp: remove unneeded semicolon

No functional modification involved.

./drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c:226:2-3: Unneeded semicolon.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4868
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: mediatek: vcodec: mtk_vcodec_dec_hw: Use devm_pm_runtime_enable()
Fei Shao [Mon, 15 May 2023 06:16:10 +0000 (14:16 +0800)]
media: mediatek: vcodec: mtk_vcodec_dec_hw: Use devm_pm_runtime_enable()

Convert pm_runtime_enable() to the managed version, and clean up error
handling and unnecessary .remove() callback accordingly.

Signed-off-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Suggested-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: rockchip: rga: use v4l2_m2m_buf_copy_metadata
Michael Tretter [Tue, 23 May 2023 09:03:09 +0000 (11:03 +0200)]
media: rockchip: rga: use v4l2_m2m_buf_copy_metadata

The v4l2_m2m_buf_copy_metadata function correctly copies the metadata of
the buffer. Use that function instead of open-coding the metadata copy.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: usb: siano: Fix warning due to null work_func_t function pointer
Duoming Zhou [Mon, 22 May 2023 23:59:32 +0000 (07:59 +0800)]
media: usb: siano: Fix warning due to null work_func_t function pointer

The previous commit ebad8e731c1c ("media: usb: siano: Fix use after
free bugs caused by do_submit_urb") adds cancel_work_sync() in
smsusb_stop_streaming(). But smsusb_stop_streaming() may be called,
even if the work_struct surb->wq has not been initialized. As a result,
the warning will occur. One of the processes that could lead to warning
is shown below:

smsusb_probe()
  smsusb_init_device()
    if (!dev->in_ep || !dev->out_ep || align < 0) {
         smsusb_term_device(intf);
           smsusb_stop_streaming()
             cancel_work_sync(&dev->surbs[i].wq);
               __cancel_work_timer()
                 __flush_work()
                   if (WARN_ON(!work->func)) // work->func is null

The log reported by syzbot is shown below:

WARNING: CPU: 0 PID: 897 at kernel/workqueue.c:3066 __flush_work+0x798/0xa80 kernel/workqueue.c:3063
Modules linked in:
CPU: 0 PID: 897 Comm: kworker/0:2 Not tainted 6.2.0-rc1-syzkaller #0
RIP: 0010:__flush_work+0x798/0xa80 kernel/workqueue.c:3066
...
RSP: 0018:ffffc9000464ebf8 EFLAGS: 00010246
RAX: 1ffff11002dbb420 RBX: 0000000000000021 RCX: 1ffffffff204fa4e
RDX: dffffc0000000000 RSI: 0000000000000001 RDI: ffff888016dda0e8
RBP: ffffc9000464ed98 R08: 0000000000000001 R09: ffffffff90253b2f
R10: 0000000000000001 R11: 0000000000000000 R12: ffff888016dda0e8
R13: ffff888016dda0e8 R14: ffff888016dda100 R15: 0000000000000001
FS:  0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffd4331efe8 CR3: 000000000b48e000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 __cancel_work_timer+0x315/0x460 kernel/workqueue.c:3160
 smsusb_stop_streaming drivers/media/usb/siano/smsusb.c:182 [inline]
 smsusb_term_device+0xda/0x2d0 drivers/media/usb/siano/smsusb.c:344
 smsusb_init_device+0x400/0x9ce drivers/media/usb/siano/smsusb.c:419
 smsusb_probe+0xbbd/0xc55 drivers/media/usb/siano/smsusb.c:567
...

This patch adds check before cancel_work_sync(). If surb->wq has not
been initialized, the cancel_work_sync() will not be executed.

Reported-by: syzbot+27b0b464864741b18b99@syzkaller.appspotmail.com
Fixes: ebad8e731c1c ("media: usb: siano: Fix use after free bugs caused by do_submit_urb")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: mtk-jpeg: move data/code inside CONFIG_OF blocks
Randy Dunlap [Sat, 20 May 2023 23:41:42 +0000 (16:41 -0700)]
media: mtk-jpeg: move data/code inside CONFIG_OF blocks

Lots of data and functions here are not needed when CONFIG_OF is not
set, so move them inside #ifdef CONFIG_OF blocks to prevent the warnings.

../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1645:29: warning: ‘mtk_jpeg_clocks’ defined but not used [-Wunused-variable]
 1645 | static struct clk_bulk_data mtk_jpeg_clocks[] = {
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1640:29: warning: ‘mt8173_jpeg_dec_clocks’ defined but not used [-Wunused-variable]
 1640 | static struct clk_bulk_data mt8173_jpeg_dec_clocks[] = {
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1481:20: warning: ‘mtk_jpeg_dec_irq’ defined but not used [-Wunused-function]
 1481 | static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1461:20: warning: ‘mtk_jpeg_enc_irq’ defined but not used [-Wunused-function]
 1461 | static irqreturn_t mtk_jpeg_enc_irq(int irq, void *priv)
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1180:13: warning: ‘mtk_jpegdec_worker’ defined but not used [-Wunused-function]
 1180 | static void mtk_jpegdec_worker(struct work_struct *work)
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:986:13: warning: ‘mtk_jpegenc_worker’ defined but not used [-Wunused-function]
  986 | static void mtk_jpegenc_worker(struct work_struct *work)
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:79:28: warning: ‘mtk_jpeg_dec_formats’ defined but not used [-Wunused-variable]
   79 | static struct mtk_jpeg_fmt mtk_jpeg_dec_formats[] = {
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:31:28: warning: ‘mtk_jpeg_enc_formats’ defined but not used [-Wunused-variable]
   31 | static struct mtk_jpeg_fmt mtk_jpeg_enc_formats[] = {
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1222:20: warning: ‘mtk_jpeg_enc_done’ defined but not used [-Wunused-function]
 1222 | static irqreturn_t mtk_jpeg_enc_done(struct mtk_jpeg_dev *jpeg)
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1072:12: warning: ‘mtk_jpegdec_set_hw_param’ defined but not used [-Wunused-function]
 1072 | static int mtk_jpegdec_set_hw_param(struct mtk_jpeg_ctx *ctx,
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1060:12: warning: ‘mtk_jpegdec_put_hw’ defined but not used [-Wunused-function]
 1060 | static int mtk_jpegdec_put_hw(struct mtk_jpeg_dev *jpeg, int hw_id)
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:1038:12: warning: ‘mtk_jpegdec_get_hw’ defined but not used [-Wunused-function]
 1038 | static int mtk_jpegdec_get_hw(struct mtk_jpeg_ctx *ctx)
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:977:12: warning: ‘mtk_jpegenc_put_hw’ defined but not used [-Wunused-function]
  977 | static int mtk_jpegenc_put_hw(struct mtk_jpeg_dev *jpeg, int hw_id)
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:963:12: warning: ‘mtk_jpegenc_set_hw_param’ defined but not used [-Wunused-function]
  963 | static int mtk_jpegenc_set_hw_param(struct mtk_jpeg_ctx *ctx,
../drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c:941:12: warning: ‘mtk_jpegenc_get_hw’ defined but not used [-Wunused-function]
  941 | static int mtk_jpegenc_get_hw(struct mtk_jpeg_ctx *ctx)

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/linux-media/202305042146.j4ZxuvpM-lkp@intel.com/
Cc: Bin Liu <bin.liu@mediatek.com>
Cc: oushixiong <oushixiong@kylinos.cn>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: camss: set VFE bpl_alignment to 16 for sdm845 and sm8250
Andrey Konovalov [Thu, 18 May 2023 21:52:35 +0000 (00:52 +0300)]
media: camss: set VFE bpl_alignment to 16 for sdm845 and sm8250

From the experiments with camera sensors using SGRBG10_1X10/3280x2464 and
SRGGB10_1X10/3280x2464 formats, it becomes clear that on sdm845 and sm8250
VFE outputs the lines padded to a length multiple of 16 bytes. As in the
current driver the value of the bpl_alignment is set to 8 bytes, the frames
captured in formats with the bytes-per-line value being not a multiple of
16 get corrupted.

Set the bpl_alignment of the camss video output device to 16 for sdm845 and
sm8250 to fix that.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: videodev2.h: Fix struct v4l2_input tuner index comment
Marek Vasut [Thu, 18 May 2023 13:36:49 +0000 (15:36 +0200)]
media: videodev2.h: Fix struct v4l2_input tuner index comment

VIDIOC_ENUMINPUT documentation describes the tuner field of
struct v4l2_input as index:

Documentation/userspace-api/media/v4l/vidioc-enuminput.rst
"
* - __u32
  - ``tuner``
  - Capture devices can have zero or more tuners (RF demodulators).
    When the ``type`` is set to ``V4L2_INPUT_TYPE_TUNER`` this is an
    RF connector and this field identifies the tuner. It corresponds
    to struct :c:type:`v4l2_tuner` field ``index``. For
    details on tuners see :ref:`tuner`.
"

Drivers I could find also use the 'tuner' field as an index, e.g.:
drivers/media/pci/bt8xx/bttv-driver.c bttv_enum_input()
drivers/media/usb/go7007/go7007-v4l2.c vidioc_enum_input()

However, the UAPI comment claims this field is 'enum v4l2_tuner_type':
include/uapi/linux/videodev2.h

This field being 'enum v4l2_tuner_type' is unlikely as it seems to be
never used that way in drivers, and documentation confirms it. It seem
this comment got in accidentally in the commit which this patch fixes.
Fix the UAPI comment to stop confusion.

This was pointed out by Dmitry while reviewing VIDIOC_ENUMINPUT
support for strace.

Fixes: 6016af82eafc ("[media] v4l2: use __u32 rather than enums in ioctl() structs")
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: av7110: Remove unnecessary (void*) conversions
Atin Bainada [Thu, 18 May 2023 09:17:47 +0000 (09:17 +0000)]
media: av7110: Remove unnecessary (void*) conversions

No need cast (void*) to (struct dvb_demux_feed *) or (struct av7110 *).

Signed-off-by: Atin Bainada <hi@atinb.me>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: pci: remove unnecessary (void*) conversions
Su Hui [Fri, 12 May 2023 01:41:59 +0000 (09:41 +0800)]
media: pci: remove unnecessary (void*) conversions

No need cast (void*) to (struct dst_state *),
(struct cx18_stream *), (struct saa7164_port *)
or (struct budget *).

Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: platform: Remove unnecessary (void*) conversions
Su Hui [Wed, 10 May 2023 01:29:44 +0000 (09:29 +0800)]
media: platform: Remove unnecessary (void*) conversions

No need cast (void*) to (struct stdemux *),(struct hva_h264_ctx *)
or (struct hva_h264_task *).

Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: usb: remove unnecessary (void*) conversions
Su Hui [Tue, 9 May 2023 07:40:01 +0000 (15:40 +0800)]
media: usb: remove unnecessary (void*) conversions

No need cast (void*) to (struct dvb_usb_device *) or
(struct filter_info *).

Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: drop the obsolete dvb-usb/az6027.c and dvb-usb/pctv452e.c changes]

13 months agomedia: stk1160: Simplify the build config definition
Lukas Bulwahn [Mon, 8 May 2023 04:13:39 +0000 (06:13 +0200)]
media: stk1160: Simplify the build config definition

Commit dfb9f94e8e5e ("[media] stk1160: Build as a module if SND is m and
audio support is selected") had to introduce some complex config dependency
handling to compile for all combinations of configs VIDEO_STK1160 and
VIDEO_STK1160_AC97.

Later, commit e36e6b5f26c1 ("[media] stk1160: Remove stk1160-mixer and
setup internal AC97 codec automatically") removes the config
VIDEO_STK1160_AC97, which renders the previous dependency handling
unnecessary. The commit already simplified the dependency of the remaining
config VIDEO_STK1160, but it misses the opportunity to merge VIDEO_STK1160
and VIDEO_STK1160_COMMON.

So, do that now and simplify the build config definition of the STK1160 USB
video capture support.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: amphion: initiate a drain of the capture queue in dynamic resolution change
Ming Qian [Sat, 6 May 2023 08:47:35 +0000 (16:47 +0800)]
media: amphion: initiate a drain of the capture queue in dynamic resolution change

The last buffer from before the change must be marked
with the V4L2_BUF_FLAG_LAST flag,
similarly to the Drain sequence above.

initiate a drain of the capture queue in dynamic resolution change

Fixes: 6de8d628df6e ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: staging: media: imx6-mipi-csi2: Add log_status core callback
Alexander Stein [Tue, 2 May 2023 14:09:02 +0000 (16:09 +0200)]
media: staging: media: imx6-mipi-csi2: Add log_status core callback

This prints all register values.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: docs: vidioc-g-ext-ctrls.rst: Update p_s32 and p_s64 types
Daniel Lundberg Pedersen [Mon, 1 May 2023 14:57:07 +0000 (16:57 +0200)]
media: docs: vidioc-g-ext-ctrls.rst: Update p_s32 and p_s64 types

The pointer types of p_s32 and p_s64 in v4l2_ext_control has been
updated, match the change in documentation.
Signed-off-by: Daniel Lundberg Pedersen <dlp@qtec.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: videodev2.h: Fix p_s32 and p_s64 pointer types
Daniel Lundberg Pedersen [Mon, 1 May 2023 14:57:06 +0000 (16:57 +0200)]
media: videodev2.h: Fix p_s32 and p_s64 pointer types

Use the intended pointer types for p_s32 and p_64 in the union of the
struct v4l2_ext_control.

Fixes: e77eb66342c7 ("videodev2.h: add p_s32 and p_s64 pointers")
Signed-off-by: Daniel Lundberg Pedersen <dlp@qtec.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: MAINTAINERS: Add myself as Venus reviewer
Bryan O'Donoghue [Mon, 1 May 2023 10:39:14 +0000 (11:39 +0100)]
media: MAINTAINERS: Add myself as Venus reviewer

I'd like to be looped in on changes to venus so that I can help ensure no
obvious regressions creep in. I'm happy to run some simple tests for venus
on the hardware I have access to

- db410c
- db820
- rb3
- rb5

and one of rb1 / rb2 in the future when they are delivered.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: common: saa7146: Avoid a leak in vmalloc_to_sg()
Christophe JAILLET [Tue, 25 Apr 2023 13:25:46 +0000 (15:25 +0200)]
media: common: saa7146: Avoid a leak in vmalloc_to_sg()

Commit in Fixes turned a BUG() into a "normal" memory allocation failure.
While at it, it introduced a memory leak.
So fix it.

Also update the comment on top of the function to reflect what has been
change by the commit in Fixes.

Fixes: 40e986c99624 ("media: common: saa7146: replace BUG_ON by WARN_ON")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agoRevert "media: mediatek: vcodec: Fix bitstream crop information error"
Nícolas F. R. A. Prado [Tue, 18 Apr 2023 21:50:52 +0000 (17:50 -0400)]
Revert "media: mediatek: vcodec: Fix bitstream crop information error"

This reverts commit cd61f3c6794bea2b717fe6083ca2ad189db75418. That
commit's purpose was to prevent the padding from being decoded when
userspace didn't set a selection, relying on the default one.

However, as described in the Step 6 of the Initialization procedure for
the Memory-to-Memory Stateful Video Encoder Interface [1]:

"Set the visible resolution for the stream metadata via
VIDIOC_S_SELECTION() on the OUTPUT queue if it is desired to be
different than the full OUTPUT resolution."

And from the Note:

"To avoid encoding the padding, the client needs to explicitly configure
this selection target"

Hence the behavior in the original commit doesn't follow the interface
and needs to be reverted.

This fixes the following v4l2-compliance failure observed on
mt8192-asurada-spherion:

fail: v4l2-test-formats.cpp(924): sel.r.width != fmt.g_width()
test VIDIOC_S_FMT: FAIL

[1] https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/dev-encoder.html#initialization

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: v4l2-mem2mem: add lock to protect parameter num_rdy
Yunfei Dong [Mon, 17 Apr 2023 08:17:40 +0000 (16:17 +0800)]
media: v4l2-mem2mem: add lock to protect parameter num_rdy

Getting below error when using KCSAN to check the driver. Adding lock to
protect parameter num_rdy when getting the value with function:
v4l2_m2m_num_src_bufs_ready/v4l2_m2m_num_dst_bufs_ready.

kworker/u16:3: [name:report&]BUG: KCSAN: data-race in v4l2_m2m_buf_queue
kworker/u16:3: [name:report&]

kworker/u16:3: [name:report&]read-write to 0xffffff8105f35b94 of 1 bytes by task 20865 on cpu 7:
kworker/u16:3:  v4l2_m2m_buf_queue+0xd8/0x10c

Signed-off-by: Pina Chen <pina.chen@mediatek.com>
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: vivid: Extend FPS rates offered by simulated webcam
Max Staudt [Fri, 14 Apr 2023 07:24:19 +0000 (16:24 +0900)]
media: vivid: Extend FPS rates offered by simulated webcam

This adds an option for higher frame rates from a simulated webcam.

Currently, vivid emulates (amongst other things) a webcam with somewhat
limited bandwidth - higher resolutions deliver fewer frames per second.

$ yavta --enum-formats -c /dev/video0
Device /dev/video0 opened.
Device `vivid' on `platform:vivid-000' (driver 'vivid') supports video, capture, without mplanes.
- Available formats:
Format 0: YUYV (56595559)
Type: Video capture (1)
Name: YUYV 4:2:2
Frame size: 320x180 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15, 1/25, 1/30, 1/40, 1/50, 1/60)
Frame size: 640x360 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15, 1/25, 1/30, 1/40)
Frame size: 640x480 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15, 1/25)
Frame size: 1280x720 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25)
Frame size: 1920x1080 (1/1, 1/2, 1/4, 1/5)
Frame size: 3840x2160 (1/1, 1/2)

In some test cases, it is useful to allow for higher frame rates, as
configurations such as 720p@30 FPS have become commonplace now.

This patch allows:
   0- 719p - 120fps
 720-1079p - 60fps
1080-2159p - 30fps
     2160p - 15fps

$ yavta --enum-formats -c /dev/video0
Device /dev/video0 opened.
Device `vivid' on `platform:vivid-000' (driver 'vivid') supports video, capture, without mplanes.
- Available formats:
Format 0: YUYV (56595559)
Type: Video capture (1)
Name: YUYV 4:2:2
Frame size: 320x180 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15, 1/25, 1/30, 1/40, 1/50, 1/60, 1/120)
Frame size: 640x360 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15, 1/25, 1/30, 1/40, 1/50, 1/60, 1/120)
Frame size: 640x480 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15, 1/25, 1/30, 1/40, 1/50, 1/60, 1/120)
Frame size: 1280x720 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15, 1/25, 1/30, 1/40, 1/50, 1/60)
Frame size: 1920x1080 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15, 1/25, 1/30)
Frame size: 3840x2160 (1/1, 1/2, 1/4, 1/5, 1/10, 2/25, 1/15)

Passes: v4l2-compliance 1.25.0-5039 from v4l-utils git ccc08732823f

Signed-off-by: Max Staudt <mstaudt@chromium.org>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: unsigned -> unsigned int]

13 months agomedia: amphion: drop repeated codec data for vc1g format
Ming Qian [Fri, 14 Apr 2023 01:55:43 +0000 (09:55 +0800)]
media: amphion: drop repeated codec data for vc1g format

For format V4L2_PIX_FMT_VC1_ANNEX_G,
the separate codec data is required only once.
The repeated codec data may introduce some decoding error.
so drop the repeated codec data.

It's amphion vpu's limitation

Fixes: e670f5d672ef ("media: amphion: only insert the first sequence startcode for vc1l format")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Tested-by: xiahong.bao <xiahong.bao@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: amphion: drop repeated codec data for vc1l format
Ming Qian [Fri, 14 Apr 2023 01:55:42 +0000 (09:55 +0800)]
media: amphion: drop repeated codec data for vc1l format

For format V4L2_PIX_FMT_VC1_ANNEX_L,
the codec data is replaced with startcode,
and then driver drop it, otherwise it may led to decoding error.

It's amphion vpu's limitation

Driver has dropped the first codec data,
but need to drop the repeated codec data too.

Fixes: e670f5d672ef ("media: amphion: only insert the first sequence startcode for vc1l format")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Tested-by: xiahong.bao <xiahong.bao@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: imx: utils: Enclose IMX_BUS_FMTS macro in parenthesis
Angel Alberto Carretero [Wed, 12 Apr 2023 17:51:01 +0000 (19:51 +0200)]
media: imx: utils: Enclose IMX_BUS_FMTS macro in parenthesis

Conform to kernel coding style by wrapping macro in parenthesis. Issue
found by checkpatch.

Signed-off-by: Angel Alberto Carretero <angelalbertoc.r@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: verisilicon: Simplify error handling in tile_buffer_reallocate()
Benjamin Gaignard [Thu, 23 Mar 2023 13:17:04 +0000 (14:17 +0100)]
media: verisilicon: Simplify error handling in tile_buffer_reallocate()

Rework allocation errors cases handling to simply it
by removing useless tests.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reported-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: usb: Check az6007_read() return value
Daniil Dulov [Tue, 14 Mar 2023 17:04:49 +0000 (10:04 -0700)]
media: usb: Check az6007_read() return value

If az6007_read() returns error, there is no sence to continue.

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

Fixes: 3af2f4f15a61 ("[media] az6007: Change the az6007 read/write routine parameter")
Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: platform: mtk-mdp3: release node reference before returning
Deepak R Varma [Sat, 11 Feb 2023 11:09:50 +0000 (16:39 +0530)]
media: platform: mtk-mdp3: release node reference before returning

The iterator for_each_child_of_node() increments the refcount of the
child node it is processing. Release such a reference when the loop
needs to break due to an error during its execution.
Issue identified using for_each_child.cocci Coccinelle semantic patch.

Signed-off-by: Deepak R Varma <drv@mailo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agomedia: platform: rzg2l-cru: rzg2l-csi2: Enclose the macro in parentheses
Lad Prabhakar [Wed, 23 Nov 2022 10:50:22 +0000 (10:50 +0000)]
media: platform: rzg2l-cru: rzg2l-csi2: Enclose the macro in parentheses

Fix the below error reported by checkpatch:

ERROR: Macros with complex values should be enclosed in parentheses
CSIDPHYSKW0_UTIL_DL1_SKW_ADJ(1) | \
CSIDPHYSKW0_UTIL_DL2_SKW_ADJ(1) | \
CSIDPHYSKW0_UTIL_DL3_SKW_ADJ(1)

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: add support for Tegra20 parallel input
Luca Ceresoli [Tue, 18 Apr 2023 08:00:54 +0000 (10:00 +0200)]
staging: media: tegra-video: add support for Tegra20 parallel input

The VI peripheral of Tegra supports capturing from MIPI CSI-2 or parallel
video (called VIP in the docs).

The staging tegra-video driver currently implements MIPI CSI-2 video
capture for Tegra210. Add support for parallel video capture (VIP) on
Tegra20. With the generalizations added to the VI driver in previous
commits, this is only a matter of adding the vip.c and tegra20.c
implementations and registering them.

Unfortunately there was no documentation available for the VI or VIP
peripherals of Tegra20 (or any other Tegra chips). This implementation has
been based entirely on the code from a vendor kernel based on Linux 3.1 and
massively adapted to fit into the tegra-video driver. Parts of this code is
definitely non-optimal to say the least (especially tegra20_vi_enable() and
the single-frame capture logic), but it was impossible to improve it.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: fix host1x_client_unregister usage: it's now a void func]

13 months agostaging: media: tegra-video: add H/V flip controls
Luca Ceresoli [Tue, 18 Apr 2023 08:00:53 +0000 (10:00 +0200)]
staging: media: tegra-video: add H/V flip controls

Tegra20 can do horizontal and vertical image flip, but Tegra210 cannot
(either the hardware, or this driver).

In preparation to adding Tegra20 support, add a flag in struct tegra_vi_soc
so the generic vi.c code knows whether the flip controls should be added or
not.

Also provide a generic implementation that simply sets two flags in the
channel struct. The Tegra20 implementation will enable flipping at stream
start based on those flags.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: add hooks for planar YUV and H/V flip
Luca Ceresoli [Tue, 18 Apr 2023 08:00:52 +0000 (10:00 +0200)]
staging: media: tegra-video: add hooks for planar YUV and H/V flip

Tegra20 supports planar YUV422 capture, which can be implemented by writing
U and V base address registers in addition to the "main" base buffer
address register.

It also supports H and V flip, which among others requires to write the
start address (i.e. the 1st offset to write, at the end of the buffer or
line) in more registers for Y and, for planar formats, U and V.

Add minimal hooks in VI to allow per-SoC optional support to those
features:

 - variables in struct tegra_vi for the U and V buffer base offsets
 - variables in struct tegra_vi for the Y, U and V buffer start offsets
 - an optional per-soc VI operation to compute those values on queue setup

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: add syncpts for Tegra20 to struct tegra_vi
Luca Ceresoli [Tue, 18 Apr 2023 08:00:51 +0000 (10:00 +0200)]
staging: media: tegra-video: add syncpts for Tegra20 to struct tegra_vi

In preparation to implement Tegra20 parallel video capture, add a variable
to hold the required syncpt and document all the syncpt variables.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: move syncpt init/free to a per-soc op
Luca Ceresoli [Tue, 18 Apr 2023 08:00:50 +0000 (10:00 +0200)]
staging: media: tegra-video: move syncpt init/free to a per-soc op

tegra_channel_host1x_syncpt_init() gets the host1x syncpts needed for the
Tegra210 implementation, and tegra_channel_host1x_syncpts_free() puts
them.

Tegra20 needs to get and put a different syncpt. In preparation for adding
Tegra20 support, move these functions to new ops in the soc-specific
`struct tegra_vi_ops` .

No functional changes.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: add a per-soc enable/disable op
Luca Ceresoli [Tue, 18 Apr 2023 08:00:49 +0000 (10:00 +0200)]
staging: media: tegra-video: add a per-soc enable/disable op

The Tegra20 VI needs an additional operation to enable the VI, add an
operation for that.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: move MIPI calibration calls from VI to CSI
Luca Ceresoli [Tue, 18 Apr 2023 08:00:48 +0000 (10:00 +0200)]
staging: media: tegra-video: move MIPI calibration calls from VI to CSI

The CSI module does not handle all the MIPI lane calibration procedure,
leaving a small part of it to the VI module. In doing this,
tegra_channel_enable_stream() (vi.c) manipulates the private data of the
upstream subdev casting it to struct 'tegra_csi_channel', which will be
wrong after introducing a VIP (parallel video input) channel.

This prevents adding support for the VIP module.  It also breaks the
logical isolation between modules.

Since the lane calibration requirement does not exist in the parallel input
module, moving the calibration function to a per-module op is not
optimal. Instead move the calibration procedure in the CSI module, together
with the rest of the calibration procedures. After this change,
tegra_channel_enable_stream() just calls v4l2_subdev_call() to ask for a
stream start/stop to the CSI module, which in turn knows all the
CSI-specific details to implement it.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: move default format to soc-specific data
Luca Ceresoli [Tue, 18 Apr 2023 08:00:47 +0000 (10:00 +0200)]
staging: media: tegra-video: move default format to soc-specific data

The tegra_default_format in vi.c is specific to Tegra210 CSI.

In preparation for adding Tegra20 VIP support, move the default format to a
new field in the soc-specific `struct tegra_vi_soc`. Instead of an entire
format struct, only store a pointer to an item in the existing format
array.

No functional changes. The format pointed to is the same that used to be in
vi.c.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: move tegra_channel_fmt_align to a per-soc op
Luca Ceresoli [Tue, 18 Apr 2023 08:00:46 +0000 (10:00 +0200)]
staging: media: tegra-video: move tegra_channel_fmt_align to a per-soc op

tegra_channel_fmt_align() takes care of the size constraints, alignment and
rounding requirements of the Tegra210 VI peripheral. Tegra20 has different
constraints.

In preparation for adding Tegra20 support, move this function to a new op
in the soc-specific `struct tegra_vi_ops` .

Also move to tegra210.c the T210-specific defines used in the moved code.

No functional changes.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: Kconfig: allow TPG only on Tegra210
Luca Ceresoli [Tue, 18 Apr 2023 08:00:45 +0000 (10:00 +0200)]
staging: media: tegra-video: Kconfig: allow TPG only on Tegra210

We are about to add support for the Tegra20 parallel video capture, which
has no TPG. In preparation for that, limit the VIDEO_TEGRA_TPG option to
Tegra210 which is the only implementation currently provided by this
driver.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: remove unneeded include
Luca Ceresoli [Tue, 18 Apr 2023 08:00:44 +0000 (10:00 +0200)]
staging: media: tegra-video: remove unneeded include

There is only a pointer reference to struct tegra_vi in video.h, thus vi.h
is not needed.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: move tegra210_csi_soc to C file
Luca Ceresoli [Tue, 18 Apr 2023 08:00:43 +0000 (10:00 +0200)]
staging: media: tegra-video: move tegra210_csi_soc to C file

This declaration is used only in csi.c, no need to export it elsewhere.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: move private struct declaration to C file
Luca Ceresoli [Tue, 18 Apr 2023 08:00:42 +0000 (10:00 +0200)]
staging: media: tegra-video: move private struct declaration to C file

struct tegra_vi_graph_entity is an internal implementation detail of the VI
module. Move its declaration from vi.h to vi.c.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: slightly simplify cleanup on errors
Luca Ceresoli [Tue, 18 Apr 2023 08:00:41 +0000 (10:00 +0200)]
staging: media: tegra-video: slightly simplify cleanup on errors

of_node_put(node) does nothing if node == NULL, so it can be moved to the
cleanup section at the bottom.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: improve error messages
Luca Ceresoli [Tue, 18 Apr 2023 08:00:40 +0000 (10:00 +0200)]
staging: media: tegra-video: improve error messages

tegra_vi_channels_alloc() can primarily fail for two reasons:

 1. "ports" node not found
 2. port_num > vi->soc->vi_max_channels

Case 1 prints nothing, case 2 has a dev_err(). The caller [tegra_vi_init()]
has a generic dev_err() on any failure. This mean that in case 2 we print
two messages, and in case 1 we only print a generic message.

Remove the generic message and add a specific message when case 1 happens,
so that we always have one specific message without even increasing the
number of dev_dbg*() calls.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: fix typos in comment
Luca Ceresoli [Tue, 18 Apr 2023 08:00:39 +0000 (10:00 +0200)]
staging: media: tegra-video: fix typos in comment

Add "skip" in "so we can *skip* the current channel" or it doesn't make
sense.

Also add articles where appropriate to fix English grammar.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: document tegra_channel_get_remote_source_subdev
Luca Ceresoli [Tue, 18 Apr 2023 08:00:38 +0000 (10:00 +0200)]
staging: media: tegra-video: document tegra_channel_get_remote_source_subdev

Clarify what this function does.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agostaging: media: tegra-video: improve documentation of tegra_video_format fields
Luca Ceresoli [Tue, 18 Apr 2023 08:00:37 +0000 (10:00 +0200)]
staging: media: tegra-video: improve documentation of tegra_video_format fields

Some fields are irrelevant for Tegra20/VIP. Add a note to clarify that.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agodt-bindings: display: tegra: vi: add 'vip' property and example
Luca Ceresoli [Tue, 18 Apr 2023 08:00:36 +0000 (10:00 +0200)]
dt-bindings: display: tegra: vi: add 'vip' property and example

The Tegra20 VI peripheral can receive parallel input from the VIP parallel
input module. Add it to the allowed properties and augment the existing
nvidia,tegra20-vi example to show a 'vip' property.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 months agodt-bindings: display: tegra: add Tegra20 VIP
Luca Ceresoli [Tue, 18 Apr 2023 08:00:35 +0000 (10:00 +0200)]
dt-bindings: display: tegra: add Tegra20 VIP

VIP is the parallel video capture component within the video input
subsystem of Tegra20 (and other Tegra chips, apparently).

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
14 months agodocs: uapi: media: ignore new DVB-S2X FEC values
Mauro Carvalho Chehab [Mon, 15 May 2023 05:43:43 +0000 (06:43 +0100)]
docs: uapi: media: ignore new DVB-S2X FEC values

Some new FEC values was added to support DVB-S2X. They're properly
documented, but its addition adds some extra warnings to htmldocs
build. So, add them to the ignore list.

Fixes: 1825788e2a96 ("media: dvb: add missing DVB-S2X FEC parameter values")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
14 months agoMerge tag 'v6.4-rc2' into media_stage
Mauro Carvalho Chehab [Sun, 14 May 2023 21:55:40 +0000 (22:55 +0100)]
Merge tag 'v6.4-rc2' into media_stage

Linux 6.4-rc2

* tag 'v6.4-rc2': (162 commits)
  Linux 6.4-rc2
  parisc: Fix encoding of swp_entry due to added SWP_EXCLUSIVE flag
  ext4: bail out of ext4_xattr_ibody_get() fails for any reason
  ext4: add bounds checking in get_max_inline_xattr_value_size()
  ext4: add indication of ro vs r/w mounts in the mount message
  ext4: fix deadlock when converting an inline directory in nojournal mode
  ext4: improve error recovery code paths in __ext4_remount()
  ext4: improve error handling from ext4_dirhash()
  ext4: don't clear SB_RDONLY when remounting r/w until quota is re-enabled
  ext4: check iomap type only if ext4_iomap_begin() does not fail
  ext4: avoid a potential slab-out-of-bounds in ext4_group_desc_csum
  ext4: fix data races when using cached status extents
  ext4: avoid deadlock in fs reclaim with page writeback
  ext4: fix invalid free tracking in ext4_xattr_move_to_block()
  ext4: remove a BUG_ON in ext4_mb_release_group_pa()
  ext4: allow ext4_get_group_info() to fail
  cxl: Add missing return to cdat read error path
  tools/testing/cxl: Use DEFINE_STATIC_SRCU()
  x86/retbleed: Fix return thunk alignment
  Documentation/block: drop the request.rst file
  ...