platform/kernel/linux-rpi.git
2 years agomedia: ov5640: Update pixel_rate and link_freq
Jacopo Mondi [Fri, 13 May 2022 14:13:54 +0000 (15:13 +0100)]
media: ov5640: Update pixel_rate and link_freq

After having set a new format re-calculate the pixel_rate and link_freq
control values and update them when in MIPI mode.

Take into account the limitation of the link frequency having to be
strictly smaller than 1GHz when computing the desired link_freq, and
adjust the resulting pixel_rate acounting for the clock tree
configuration.

[Adjust link_freq calculation]

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov5640: Add LINK_FREQ control
Jacopo Mondi [Fri, 13 May 2022 14:13:53 +0000 (15:13 +0100)]
media: ov5640: Add LINK_FREQ control

Add the V4L2_CID_LINK_FREQ control to the ov5640 driver.
Make the control read-only for the moment.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Associate bpp with formats
Jacopo Mondi [Fri, 13 May 2022 14:13:52 +0000 (15:13 +0100)]
media: ov5640: Associate bpp with formats

Associate the bit depth to each format supported by the sensor.

The bpp will be used to calculate the line length.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Add ov5640_is_csi2() function
Jacopo Mondi [Fri, 13 May 2022 14:13:51 +0000 (15:13 +0100)]
media: ov5640: Add ov5640_is_csi2() function

Checking if the sensor is used in DVP or MIPI CSI-2 mode is a repeated
pattern which is about to be repeated more often.

Provide an inline function to shortcut that.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5604: Re-arrange modes definition
Jacopo Mondi [Fri, 13 May 2022 14:13:50 +0000 (15:13 +0100)]
media: ov5604: Re-arrange modes definition

The array of supported modes is close to unreadable.
Re-arrange it giving it some room to breath.

Cosmetic change only.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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>
2 years agomedia: ov5640: Add pixel rate to modes
Jacopo Mondi [Fri, 13 May 2022 14:13:49 +0000 (15:13 +0100)]
media: ov5640: Add pixel rate to modes

Add to each mode supported by the sensor the ideal pixel rate, as
defined by Table 2.1 in the chip manual.

The ideal pixel rate will be used to compute the MIPI CSI-2 clock tree.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Adam Ford <aford173@gmail.com> #imx8mm-beacon-kit
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: stm32-dcmi: add support of 1X16 serial pixel formats variant
Hugues Fruchet [Mon, 16 May 2022 09:20:48 +0000 (10:20 +0100)]
media: stm32-dcmi: add support of 1X16 serial pixel formats variant

Add support of 1X16 serial pixel formats in order to support
CSI-2 camera sensor exposing 1x16 pixel formats only.

Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: st-mipid02: expose 1X16 serial pixel format
Hugues Fruchet [Mon, 16 May 2022 09:19:34 +0000 (10:19 +0100)]
media: st-mipid02: expose 1X16 serial pixel format

Expose RGB & YUV 1X16 serial pixel format variants to comply
with CSI-2 camera sensor pixel formats.

Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: st-mipid02: add support for YVYU and VYUY formats
Alain Volmat [Mon, 16 May 2022 09:19:33 +0000 (10:19 +0100)]
media: st-mipid02: add support for YVYU and VYUY formats

Those two formats were missing in the list of supported MBUS
formats.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: st-mipid02: add support of pixel clock polarity
Hugues Fruchet [Mon, 16 May 2022 09:19:32 +0000 (10:19 +0100)]
media: st-mipid02: add support of pixel clock polarity

Add support of pixel clock polarity.

Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ov7251: Fix multiple problems in s_stream callback
Sakari Ailus [Wed, 18 May 2022 15:52:36 +0000 (16:52 +0100)]
media: ov7251: Fix multiple problems in s_stream callback

The s_stream callback had several issues:

- If pm_runtime_get_sync() fails, the usage_count is not put.

- The sensor wasn't suspended if s_stream(subdev, 1) failed.

Fix this.

Fixes: ("media: i2c: Add pm_runtime support to ov7251")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: sunxi: Add support for the A83T MIPI CSI-2 controller
Paul Kocialkowski [Wed, 25 May 2022 19:03:00 +0000 (20:03 +0100)]
media: sunxi: Add support for the A83T MIPI CSI-2 controller

The A83T supports MIPI CSI-2 with a composite controller, covering
both the protocol logic and the D-PHY implementation. This controller
seems to be found on the A83T only and probably was abandoned since.

This implementation splits the protocol and D-PHY registers and
uses the PHY framework internally. The D-PHY is not registered as a
standalone PHY driver since it cannot be used with any other
controller.

There are a few notable points about the controller:
- The initialisation sequence involes writing specific magic init
  values that do not seem to make any particular sense given the
  concerned register fields;
- Interrupts appear to be hitting regardless of the interrupt mask
  registers, which can cause a serious flood when transmission errors
  occur.

Only 8-bit and 10-bit Bayer formats are currently supported.
While up to 4 internal channels to the CSI controller exist, only one
is currently supported by this implementation.

This work is based on the first version of the driver submitted by
Kévin L'hôpital, which was adapted to mainline from the Allwinner BSP.
This version integrates MIPI CSI-2 support as a standalone V4L2 subdev
instead of merging it in the sun6i-csi driver.

It was tested on a Banana Pi M3 board with an OV8865 sensor in a 4-lane
configuration.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: media: Add Allwinner A83T MIPI CSI-2 bindings documentation
Paul Kocialkowski [Wed, 25 May 2022 19:02:59 +0000 (20:02 +0100)]
media: dt-bindings: media: Add Allwinner A83T MIPI CSI-2 bindings documentation

This introduces YAML bindings documentation for the Allwinner A83T
MIPI CSI-2 controller.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: Add entry for the Allwinner A31 MIPI CSI-2 bridge driver
Paul Kocialkowski [Wed, 25 May 2022 19:02:58 +0000 (20:02 +0100)]
media: MAINTAINERS: Add entry for the Allwinner A31 MIPI CSI-2 bridge driver

Add myself as maintainer of the Allwinner A31 MIPI CSI-2 bridge media
driver.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: sunxi: Add support for the A31 MIPI CSI-2 controller
Paul Kocialkowski [Wed, 25 May 2022 19:02:57 +0000 (20:02 +0100)]
media: sunxi: Add support for the A31 MIPI CSI-2 controller

The A31 MIPI CSI-2 controller is a dedicated MIPI CSI-2 bridge
found on Allwinner SoCs such as the A31 and V3/V3s.

It is a standalone block, connected to the CSI controller on one side
and to the MIPI D-PHY block on the other. It has a dedicated address
space, interrupt line and clock.

It is represented as a V4L2 subdev to the CSI controller and takes a
MIPI CSI-2 sensor as its own subdev, all using the fwnode graph and
media controller API.

Only 8-bit and 10-bit Bayer formats are currently supported.
While up to 4 internal channels to the CSI controller exist, only one
is currently supported by this implementation.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: media: Add Allwinner A31 MIPI CSI-2 bindings documentation
Paul Kocialkowski [Wed, 25 May 2022 19:02:56 +0000 (20:02 +0100)]
media: dt-bindings: media: Add Allwinner A31 MIPI CSI-2 bindings documentation

This introduces YAML bindings documentation for the Allwinner A31 MIPI
CSI-2 controller.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-bindings: media: sun6i-a31-csi: Add MIPI CSI-2 input port
Paul Kocialkowski [Wed, 25 May 2022 19:02:55 +0000 (20:02 +0100)]
media: dt-bindings: media: sun6i-a31-csi: Add MIPI CSI-2 input port

The A31 CSI controller supports two distinct input interfaces:
parallel and an external MIPI CSI-2 bridge. The parallel interface
is often connected to a set of hardware pins while the MIPI CSI-2
bridge is an internal FIFO-ish link. As a result, these two inputs
are distinguished as two different ports.

Note that only one of the two may be present on a controller instance.
For example, the V3s has one controller dedicated to MIPI-CSI2 and one
dedicated to parallel.

Update the binding with an explicit ports node that holds two distinct
port nodes: one for parallel input and one for MIPI CSI-2.

This is backward-compatible with the single-port approach that was
previously taken for representing the parallel interface port, which
stays enumerated as fwnode port 0.

Note that additional ports may be added in the future, especially to
support feeding the CSI controller's output to the ISP.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hantro: Add support for RK356x encoder
Nicolas Frattaroli [Sun, 12 Jun 2022 15:53:45 +0000 (16:53 +0100)]
media: hantro: Add support for RK356x encoder

The RK3566 and RK3568 SoCs come with a small Hantro instance which is
solely dedicated to encoding. This patch adds the necessary structs to
the Hantro driver to allow the JPEG encoder of it to function.

Through some sleuthing through the vendor's MPP source code and after
closer inspection of the TRM, it was determined that the hardware likely
supports VP8 and H.264 as well.

Tested with the following GStreamer command:

gst-launch-1.0 videotestsrc ! v4l2jpegenc ! matroskamux ! \
               filesink location=foo.mkv

Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: dt-binding: media: Add rk3568-vepu binding
Nicolas Frattaroli [Sun, 12 Jun 2022 15:53:44 +0000 (16:53 +0100)]
media: dt-binding: media: Add rk3568-vepu binding

The RK3568 and RK3566 have a Hantro VPU node solely dedicated to
encoding. This patch adds a new binding to describe it, as it
does not really fit the rockchip-vpu binding, since there is no
decoder.

Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: amphion: release core lock before reset vpu core
Ming Qian [Tue, 28 Jun 2022 05:19:52 +0000 (06:19 +0100)]
media: amphion: release core lock before reset vpu core

In reset vpu core, driver will wait for a response event,
but if there are still some events unhandled,
they will be handled first, driver may acquire core lock for that.
So if we do reset in core lock, it may led to reset timeout.

Fixes: 9f599f351e86a ("media: amphion: add vpu core driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: Fix incorrect P010 chroma order description
Sebastian Fricke [Mon, 27 Jun 2022 07:12:23 +0000 (08:12 +0100)]
media: Fix incorrect P010 chroma order description

The chroma order of P010 is `CbCr`,
match with the descriptions in `include/uapi/linux/videodev2.h` and the
documentation.

Fixes: 5374d8fb75f3 ("media: Add P010 video format")
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: docs: Fix VIVIOC typo
Marek Vasut [Sun, 26 Jun 2022 16:46:08 +0000 (17:46 +0100)]
media: docs: Fix VIVIOC typo

Replace VIVIOC_ with VIDIOC_ , trivial typo fix.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2-ctrls: Fix missing newline in examples
Marek Vasut [Sun, 26 Jun 2022 14:47:01 +0000 (15:47 +0100)]
media: v4l2-ctrls: Fix missing newline in examples

Replace supportedn with supported\n , i.e. add the missing backslash.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: mtk-mdp: Fix mdp_ipi_comm structure alignment
AngeloGioacchino Del Regno [Thu, 23 Jun 2022 13:55:46 +0000 (14:55 +0100)]
media: platform: mtk-mdp: Fix mdp_ipi_comm structure alignment

The mdp_ipi_comm structure defines a command that is either
PROCESS (start processing) or DEINIT (destroy instance); we
are using this one to send PROCESS or DEINIT commands from Linux
to an MDP instance through a VPU write but, while the first wants
us to stay 4-bytes aligned, the VPU instead requires an 8-bytes
data alignment.

Keeping in mind that these commands are executed immediately
after sending them (hence not chained with others before the
VPU/MDP "actually" start executing), it is fine to simply add
a padding of 4 bytes to this structure: this keeps the same
performance as before, as we're still stack-allocating it,
while avoiding hackery inside of mtk-vpu to ensure alignment
bringing a definitely bigger performance impact.

Fixes: c8eb2d7e8202 ("[media] media: Add Mediatek MDP Driver")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Houlong Wei <houlong.wei@mediatek.com>
Reviewed-by: Irui Wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: pvrusb2: drop unexpected word 'a' in comments
Jiang Jian [Thu, 23 Jun 2022 07:42:57 +0000 (08:42 +0100)]
media: pvrusb2: drop unexpected word 'a' in comments

there is an unexpected word 'a' in the comments that need to be dropped

file - drivers/media/usb/pvrusb2/pvrusb2-hdw.c
line - 5044

But now it's a a chicken and egg problem...) */

changed to:

But now it's a chicken and egg problem...) */

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ti: drop unexpected word 'a' in comments
Jiang Jian [Thu, 23 Jun 2022 07:35:04 +0000 (08:35 +0100)]
media: ti: drop unexpected word 'a' in comments

there is an unexpected word 'a' in the comments that need to be dropped

file - drivers/media/platform/ti/cal/cal-camerarx.c
line - 308

 * DRA80xM TRMs have a a slightly simplified sequence.

changed to:

 * DRA80xM TRMs have a slightly simplified sequence.

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: gspca: drop unexpected word 'is' in the comments
Jiang Jian [Wed, 22 Jun 2022 17:11:37 +0000 (18:11 +0100)]
media: gspca: drop unexpected word 'is' in the comments

there is an unexpected word 'is' in the comments that need to be dropped

file - drivers/media/usb/gspca/spca501.c
line - 491

* This is is for the 3com HomeConnect Lite which is spca501a based.

changed to:

* This is for the 3com HomeConnect Lite which is spca501a based.

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: cx18: Fix typo in comments
Jiang Jian [Wed, 22 Jun 2022 14:41:51 +0000 (15:41 +0100)]
media: cx18: Fix typo in comments

Remove the repeated word 'and' from comments

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: c8sectpfe: Remove unneeded NULL check before clk_disable_unprepare
Wan Jiabing [Mon, 16 May 2022 13:12:54 +0000 (14:12 +0100)]
media: c8sectpfe: Remove unneeded NULL check before clk_disable_unprepare

clk_disable_unprepare() already checks NULL by using IS_ERR_OR_NULL.
Remove unneeded NULL check for fei->c8sectpfeclk.

Link: https://lore.kernel.org/linux-media/20220516131254.13816-1-wanjiabing@vivo.com
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: c8sectpfe: Clean up handling of *_buffer_aligned
Andy Shevchenko [Wed, 9 Feb 2022 18:25:21 +0000 (18:25 +0000)]
media: c8sectpfe: Clean up handling of *_buffer_aligned

There are a few cases where code is harder than needed to read.
Improve those by:
- dropping unnecessary castings (see note below)
- use PTR_ALING() to be more explicit on what's going on there
- use proper definitions instead of hard coded values

Note, dropping castings will allow to perform an additional check
that type is not changed from void * to something else, e.g. u64,
which may very well break the bitmap APIs.

Link: https://lore.kernel.org/linux-media/20220209182521.55632-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: hfi_platform: Correct supported codecs for sc7280
Vikash Garodia [Mon, 23 May 2022 13:43:41 +0000 (14:43 +0100)]
media: venus: hfi_platform: Correct supported codecs for sc7280

VP8 codec is deprecated for sc7280 SOC. Fix in platform layer to
update the supported codecs accordingly.

Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Tested-by: Fritz Koenig<frkoenig@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: venus: Add support for SSR trigger using fault injection
Dikshita Agarwal [Thu, 16 Jun 2022 11:02:02 +0000 (12:02 +0100)]
media: venus: Add support for SSR trigger using fault injection

Here we introduce a new fault injection for SSR trigger.

To trigger the SSR:
 echo 100 >  /sys/kernel/debug/venus/fail_ssr/probability
 echo 1 >  /sys/kernel/debug/venus/fail_ssr/times

Co-developed-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: isl7998x: select V4L2_FWNODE to fix build error
Randy Dunlap [Wed, 30 Mar 2022 01:56:52 +0000 (02:56 +0100)]
media: isl7998x: select V4L2_FWNODE to fix build error

Fix build error when VIDEO_ISL7998X=y and V4L2_FWNODE=m
by selecting V4L2_FWNODE.

microblaze-linux-ld: drivers/media/i2c/isl7998x.o: in function `isl7998x_probe':
(.text+0x8f4): undefined reference to `v4l2_fwnode_endpoint_parse'

Cc: stable@vger.kernel.org # 5.18 and above
Fixes: 51ef2be546e2 ("media: i2c: isl7998x: Add driver for Intersil ISL7998x")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kernel test robot <lkp@intel.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Report supported bitrate modes
Hirokazu Honda [Wed, 22 Jun 2022 08:36:24 +0000 (09:36 +0100)]
media: mediatek: vcodec: Report supported bitrate modes

The media driver supports constant bitrate mode only.
The supported rate control mode is reported through querymenu() and
s_ctrl() fails if non constant bitrate mode (e.g. VBR) is requested.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Irui Wang <irui.wang@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: av7110: Remove duplicate 'with' in two places.
Jiang Jian [Tue, 21 Jun 2022 16:30:30 +0000 (17:30 +0100)]
media: av7110: Remove duplicate 'with' in two places.

file: ./drivers/staging/media/av7110/av7110.c
line: 2367
         * reset with with MASK_31 to MC1
changed to
         * reset with MASK_31 to MC1

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: saa7164: Remove duplicate 'on' in two places.
Jiang Jian [Tue, 21 Jun 2022 15:05:28 +0000 (16:05 +0100)]
media: saa7164: Remove duplicate 'on' in two places.

file: drivers/media/pci/saa7164/saa7164-api.c
line: 804
/* Assumption: Hauppauge eeprom is at 0xa0 on on bus 0 */
changed to
/* Assumption: Hauppauge eeprom is at 0xa0 on bus 0 */

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Fix non subdev architecture open power fail
Yunfei Dong [Fri, 17 Jun 2022 07:25:21 +0000 (08:25 +0100)]
media: mediatek: vcodec: Fix non subdev architecture open power fail

According to subdev_bitmap bit value to open hardware power, need to
set subdev_bitmap value for non subdev architecture.

Fixes: c05bada35f01 ("media: mtk-vcodec: Add to support multi hardware decode")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: usb: gspca: aligned '*' each line
Jiang Jian [Tue, 21 Jun 2022 06:55:02 +0000 (07:55 +0100)]
media: usb: gspca: aligned '*' each line

Consider "*" alignment in comments

Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: tw686x: Fix memory leak in tw686x_video_init
Miaoqian Lin [Tue, 21 Jun 2022 05:30:30 +0000 (06:30 +0100)]
media: tw686x: Fix memory leak in tw686x_video_init

video_device_alloc() allocates memory for vdev,
when video_register_device() fails, it doesn't release the memory and
leads to memory leak, call video_device_release() to fix this.

Fixes: 704a84ccdbf1 ("[media] media: Support Intersil/Techwell TW686x-based video capture cards")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: driver/nxp/imx-jpeg: fix a unexpected return value problem
Jian Zhang [Mon, 20 Jun 2022 08:34:23 +0000 (09:34 +0100)]
media: driver/nxp/imx-jpeg: fix a unexpected return value problem

In function mxc_jpeg_probe(), when devm_clk_get() fail, the return value
will be unexpected, and it should be the devm_clk_get's error code.

Fixes: 4c2e5156d9fa6 ("media: imx-jpeg: Add pm-runtime support for imx-jpeg")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jian Zhang <zhangjian210@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: add Yunfei Dong as mediatek vcodec driver maintainer
Yunfei Dong [Mon, 20 Jun 2022 07:18:17 +0000 (08:18 +0100)]
media: MAINTAINERS: add Yunfei Dong as mediatek vcodec driver maintainer

I have been working on mediatek driver development for a very long time,
and sent many patches to change the driver architecture. Add myself as
co-maintainer for mediatek vcodec driver.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Skip SOURCE_CHANGE & EOS events for stateless
Chen-Yu Tsai [Mon, 20 Jun 2022 06:33:49 +0000 (07:33 +0100)]
media: mediatek: vcodec: Skip SOURCE_CHANGE & EOS events for stateless

The stateless decoder API does not specify the usage of SOURCE_CHANGE
and EOF events. These events are used by stateful decoders to signal
changes in the bitstream. They do not make sense for stateless decoders.

Do not handle subscription for these two types of events for stateless
decoder instances. This fixes the last v4l2-compliance error:

Control ioctls:
fail: v4l2-test-controls.cpp(946): have_source_change || have_eos
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL

Fixes: 8cdc3794b2e3 ("media: mtk-vcodec: vdec: support stateless API")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: tw686x: Fix an error handling path in tw686x_probe()
Christophe JAILLET [Mon, 20 Jun 2022 05:31:53 +0000 (06:31 +0100)]
media: tw686x: Fix an error handling path in tw686x_probe()

The commit in Fixes: is incomplete. It has moved some code in the probe but
not all error handling paths have been updated.

Now, if request_irq() fails, we must release some resources.

Fixes: c8946454ed96 ("media: tw686x: Register the irq at the end of probe")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: stm32: dcmi: Drop always NULL sd_state from dcmi_pipeline_s_fmt()
Marek Vasut [Sat, 18 Jun 2022 22:23:54 +0000 (23:23 +0100)]
media: stm32: dcmi: Drop always NULL sd_state from dcmi_pipeline_s_fmt()

The second argument is always NULL, stop passing it to the function.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Amelie DELAUNAY <amelie.delaunay@foss.st.com>
Cc: Hugues FRUCHET <hugues.fruchet@foss.st.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Philippe CORNU <philippe.cornu@foss.st.com>
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: stm32: dcmi: Fill in remaining Bayer formats
Marek Vasut [Sat, 18 Jun 2022 22:23:17 +0000 (23:23 +0100)]
media: stm32: dcmi: Fill in remaining Bayer formats

Fill in 10, 12, 14 bit Bayer formats into the DCMI driver.
Those are useful e.g. when MT9P006 sensor is connected.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Amelie DELAUNAY <amelie.delaunay@foss.st.com>
Cc: Hugues FRUCHET <hugues.fruchet@foss.st.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Philippe CORNU <philippe.cornu@foss.st.com>
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Initialize decoder parameters after getting dec_capability
Yunfei Dong [Sat, 18 Jun 2022 07:29:29 +0000 (08:29 +0100)]
media: mediatek: vcodec: Initialize decoder parameters after getting dec_capability

Need to get dec_capability from scp first, then initialize decoder
supported format and other parameters according to dec_capability value.

Fixes: fd00d90330d1 ("media: mtk-vcodec: vdec: move stateful ops into their own file")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkvdec:Remove redundant memset
Zhang Zekun [Fri, 17 Jun 2022 09:39:25 +0000 (10:39 +0100)]
media: rkvdec:Remove redundant memset

As dma_alloc_coherent() will return a zeroed buffer, we
don't need to memset the returned buffer.
priv_tbl = dma_alloc_coherent() and count_tbl = dma_alloc_coherent()
should be enough.

-see commit 750afb08ca71 ("cross-tree: phase out dma_zalloc_coherent()")

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atmel: atmel-isc-base: allow wb ctrls to be changed when isc is not configured
Eugen Hristev [Thu, 16 Jun 2022 14:42:59 +0000 (15:42 +0100)]
media: atmel: atmel-isc-base: allow wb ctrls to be changed when isc is not configured

When attempting to change the white balance (WB) ctrls before starting
streaming, e.g.:

 # v4l2-ctl -L

User Controls
..
            blue_component_gain 0x009819c1 (int)    : min=0 max=8191 step=1 default=512 value=512 flags=slider
..
 # v4l2-ctl --set-ctrl=blue_component_gain=500
 # v4l2-ctl -L
..
            blue_component_gain 0x009819c1 (int)    : min=0 max=8191 step=1 default=512 value=500 flags=slider
..

These will not be written to the internal data struct and will not be
written to the WB hardware module.
Thus, after starting streaming, they will be reset to default:

 # v4l2-ctl -L
..
            blue_component_gain 0x009819c1 (int)    : min=0 max=8191 step=1 default=512 value=512 flags=slider
..

It does not make much sense to not be able to configure the WB controls
at all times. Even if the sensor would not be RAW Bayer (and in this case the
WB module is unavailable), the user could configure the ISC itself, as the
ISC should not care about the sensor format.
Thus, when WB module is available (if the sensor changes format e.g.) it will
be already configured as be user's desires.
In consequence, remove the check in isc_s_awb_ctrl that will return if ISC
does not know the sensor format.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: sta2x11: remove VIRT_TO_BUS dependency
Arnd Bergmann [Thu, 16 Jun 2022 08:52:42 +0000 (09:52 +0100)]
media: sta2x11: remove VIRT_TO_BUS dependency

This driver does not use the virt_to_bus() function, though it
depends on x86 specific fixups in the swiotlb code, which was
last rewritten in commit e380a0394c36 ("x86/PCI: sta2x11: use
default DMA address translation").

It is possible that the driver still fails to build on some
architectures that are missing CONFIG_VIRT_TO_BUS, but it is
always set on x86 machines with the STA2X11 platform enabled.

More likely though is that it was never meant to depend on
CONFIG_VIRT_TO_BUS, and the Kconfig dependency was kept from
an out-of-tree version when the driver was originally merged.

Fixes: efeb98b4e2b2 ("[media] STA2X11 VIP: new V4L2 driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: return EINVAL if plane is too small
Justin Green [Wed, 15 Jun 2022 15:38:27 +0000 (16:38 +0100)]
media: mediatek: vcodec: return EINVAL if plane is too small

Modify vb2ops_vdec_buf_prepare to return EINVAL if the size of the plane
is less than the size of the image. Currently we just log an error and
return 0 anyway, which may cause a buffer overrun bug.

Signed-off-by: Justin Green <greenjustin@chromium.org>
Suggested-by: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set
Ming Qian [Wed, 15 Jun 2022 03:19:20 +0000 (04:19 +0100)]
media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set

If the last buffer was dequeued from the capture queue,
signal userspace. DQBUF(CAPTURE) will return -EPIPE.

But if output queue is empty and capture queue is empty,
v4l2_m2m_poll_for_data will return EPOLLERR,
This is very easy to happen in drain.

When last_buffer_dequeued is set, we shouldn't return EPOLLERR,
but return EPOLLIN | EPOLLRDNORM.

Fixes: 1698a7f151126 ("media: v4l2-mem2mem: simplify poll logic")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: remove unneeded semicolon
Yang Li [Wed, 15 Jun 2022 00:59:46 +0000 (01:59 +0100)]
media: mediatek: vcodec: remove unneeded semicolon

Eliminate the following coccicheck warning:
./drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c:71:2-3: Unneeded semicolon

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: hdpvr: fix error value returns in hdpvr_read
Niels Dossche [Tue, 14 Jun 2022 17:50:02 +0000 (18:50 +0100)]
media: hdpvr: fix error value returns in hdpvr_read

Error return values are supposed to be negative in hdpvr_read. Most
error returns are currently handled via an unsigned integer "ret". When
setting a negative error value to "ret", the value actually becomes a
large positive value, because "ret" is unsigned. Later on, the "ret"
value is returned. But as ssize_t is a 64-bit signed number, the error
return value stays a large positive integer instead of a negative
integer. This can cause an error value to be interpreted as the read
size, which can cause a buffer overread for applications relying on the
returned size.

Fixes: 9aba42efe85b ("V4L/DVB (11096): V4L2 Driver for the Hauppauge HD PVR usb capture device")
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: fix minmax.cocci warning
Guo Zhengkui [Tue, 14 Jun 2022 07:25:59 +0000 (08:25 +0100)]
media: mediatek: vcodec: fix minmax.cocci warning

Fix the following coccicheck warning:

drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c:
694:15-16: WARNING opportunity for min().

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: MAINTAINERS: add include/dt-bindings/media to MEDIA INPUT INFRASTRUCTURE
Lukas Bulwahn [Mon, 13 Jun 2022 12:10:07 +0000 (13:10 +0100)]
media: MAINTAINERS: add include/dt-bindings/media to MEDIA INPUT INFRASTRUCTURE

Maintainers of the directory Documentation/devicetree/bindings/media
are also the maintainers of the corresponding directory
include/dt-bindings/media.

Add the file entry for include/dt-bindings/media to the appropriate
section in MAINTAINERS.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ddbridge: Remove useless license text when SPDX-License-Identifier is already...
Christophe JAILLET [Sat, 11 Jun 2022 10:39:47 +0000 (11:39 +0100)]
media: ddbridge: Remove useless license text when SPDX-License-Identifier is already used

An SPDX-License-Identifier is already in place. There is no need to
duplicate part of the corresponding license.

While at it, a few comments at the end of some .h files have been updated
to reflect the correct include guard name (missing '_' and co.)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: em28xx: Remove useless license text when SPDX-License-Identifier is already...
Christophe JAILLET [Sat, 11 Jun 2022 10:24:32 +0000 (11:24 +0100)]
media: em28xx: Remove useless license text when SPDX-License-Identifier is already used

An SPDX-License-Identifier is already in place. There is no need to
duplicate part of the corresponding license.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rcar_drif: Remove useless license text when SPDX-License-Identifier is already...
Christophe JAILLET [Sat, 11 Jun 2022 10:22:12 +0000 (11:22 +0100)]
media: rcar_drif: Remove useless license text when SPDX-License-Identifier is already used

An SPDX-License-Identifier is already in place. There is no need to
duplicate part of the corresponding license.

This is a left-over from commit adeb69705682 ("media: rcar_drif: convert to
SPDX identifiers")

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: cros-ec: Add kinox to the match table
Ajye Huang [Fri, 10 Jun 2022 13:33:42 +0000 (14:33 +0100)]
media: platform: cros-ec: Add kinox to the match table

The Google Kinox device uses the same approach as the Google Brask
which enables the HDMI CEC via the cros-ec-cec driver.

Signed-off-by: Ajye Huang <ajye_huang@compal.corp-partner.google.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: amphion: output firmware error message
Ming Qian [Fri, 10 Jun 2022 06:26:11 +0000 (07:26 +0100)]
media: amphion: output firmware error message

Firmware may send the error event with some error message,
and it help locate the firmware error,
so output the error message if it exists

Fixes: 61cbf1c1fa6d7 ("media: amphion: implement vpu core communication based on mailbox")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: Disable slot interrupt when frame done
Ming Qian [Fri, 10 Jun 2022 02:00:57 +0000 (03:00 +0100)]
media: imx-jpeg: Disable slot interrupt when frame done

The interrupt STMBUF_HALF may be triggered after frame done.
It may led to system hang if driver try to access the register after
power off.

Disable the slot interrupt when frame done.

Fixes: 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Tested-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Change encoder v4l2 capability value
Yunfei Dong [Fri, 10 Jun 2022 01:53:15 +0000 (02:53 +0100)]
media: mediatek: vcodec: Change encoder v4l2 capability value

Change the value of v4l2 capability parameters: driver and card.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Fix encoder v4l2 bus_info not correctly
Yunfei Dong [Fri, 10 Jun 2022 01:53:14 +0000 (02:53 +0100)]
media: mediatek: vcodec: Fix encoder v4l2 bus_info not correctly

Fix v4l2 capability bus_info value with correct chip name according to
compatible.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Change decoder v4l2 capability value
Yunfei Dong [Fri, 10 Jun 2022 01:53:13 +0000 (02:53 +0100)]
media: mediatek: vcodec: Change decoder v4l2 capability value

Change the value of v4l2 capability parameters: driver and card.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Fix decoder v4l2 bus_info not correctly
Yunfei Dong [Fri, 10 Jun 2022 01:53:12 +0000 (02:53 +0100)]
media: mediatek: vcodec: Fix decoder v4l2 bus_info not correctly

Fix v4l2 capability bus_info value with correct chip name according to
compatible.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: Drop parentheses and fix indentation in rkisp1_probe()
Laurent Pinchart [Sun, 27 Feb 2022 20:56:16 +0000 (20:56 +0000)]
media: rkisp1: Drop parentheses and fix indentation in rkisp1_probe()

Fix a small indentation issue to increase code readability, and drop
unneeded parentheses.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: Align macro definitions
Laurent Pinchart [Sun, 27 Feb 2022 20:43:03 +0000 (20:43 +0000)]
media: rkisp1: Align macro definitions

Make the code more readable by using the same alignment for all macros
in rkisp1-common.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: capture: Bypass the main device for handling querycap
Paul Elder [Tue, 22 Feb 2022 08:52:07 +0000 (08:52 +0000)]
media: rkisp1: capture: Bypass the main device for handling querycap

When handling querycap, the capture node would access the main rkisp1
device unnecessarily. Get the information from the most direct source.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: debug: Update max register name length
Laurent Pinchart [Sun, 6 Mar 2022 16:00:16 +0000 (16:00 +0000)]
media: rkisp1: debug: Update max register name length

Update the maximum register name length to match all the registers being
printed. This helps getting a consistent alignment of register dumps
when concatenating multiple debugfs files.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: debug: Consolidate reg dumps for shadow registers
Laurent Pinchart [Sun, 6 Mar 2022 16:00:16 +0000 (16:00 +0000)]
media: rkisp1: debug: Consolidate reg dumps for shadow registers

Extend the rkisp1_debug_register structure and the
rkisp1_debug_dump_regs() function to support shadow registers, and
replace the manual registers dump implementation in
rkisp1_debug_dump_rsz_regs_show() with a call to
rkisp1_debug_dump_regs().

Support for printing register values in decimal is dropped, as it was
actually confusing to print resizer register expressed as fixed-point
values in decimal.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: debug: Move resizer register dump to debugfs
Laurent Pinchart [Sun, 27 Feb 2022 15:20:48 +0000 (15:20 +0000)]
media: rkisp1: debug: Move resizer register dump to debugfs

The debugfs support already includes support to dump core and ISP
registers. Move the resizer register dump there too to make the
userspace interface consistent.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: debug: Add debugfs files to dump core and ISP registers
Laurent Pinchart [Sun, 27 Feb 2022 13:41:09 +0000 (13:41 +0000)]
media: rkisp1: debug: Add debugfs files to dump core and ISP registers

It's useful to dump the value of registers for debugging purpose. Add
two debugfs files to dump key core and ISP registers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD
Laurent Pinchart [Sat, 26 Feb 2022 07:57:09 +0000 (07:57 +0000)]
media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD

The ISP_FLAGS_SHD register exposes the ISP parallel input signals (data
and synchronization) in real time. This can help debugging when the
device doesn't output any image. Sample the register 10000 times with a
1µs delay and expose the result through debugfs.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: Compile debugfs support conditionally
Laurent Pinchart [Sat, 26 Feb 2022 07:57:09 +0000 (07:57 +0000)]
media: rkisp1: Compile debugfs support conditionally

When CONFIG_DEBUGFS is disabled, there's no need to compile the debugfs
support in. Make it conditional.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: Move debugfs code to a separate file
Laurent Pinchart [Sat, 26 Feb 2022 07:57:09 +0000 (07:57 +0000)]
media: rkisp1: Move debugfs code to a separate file

To avoid cluttering the main rkisp1-dev.c driver file, move debugfs code
to a separate source file. This prepares for extensions to the debugfs
infrastructure.

While at it, add a missing forward declaration for struct dentry in
rkisp1-common.h to avoid depending on indirect includes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: resizer: Simplify register access
Laurent Pinchart [Sun, 27 Feb 2022 14:38:47 +0000 (14:38 +0000)]
media: rkisp1: resizer: Simplify register access

The registers for the mainpath and selfpath resizers are located at the
same offset from the instance-specific base. Use this to simplify
register access, removing the need to store per-register offsets in the
rkisp1_rsz_config structure.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: Swap value and address arguments to rkisp1_write()
Laurent Pinchart [Thu, 3 Mar 2022 15:35:10 +0000 (15:35 +0000)]
media: rkisp1: Swap value and address arguments to rkisp1_write()

While writel() takes the value and address arguments in that order, most
write functions (including in the regmap API) use the opposite
convention. Having the value first is considered confusing, and often
leads to more difficult to read code compared to the opposite convention
where the write call and the register name often fit on a single line:

rkisp1_write(rkisp1, RKISP1_CIF_THE_REG_NAME,
     complicate_calculation + for / the_register
     value + goes | here);

Swap the arguments of the rkisp1_write() function, and use the following
semantic patch to update the callers:

@@
expression rkisp1, value, address;
@@

- rkisp1_write(rkisp1, value, address)
+ rkisp1_write(rkisp1, address, value)

This commit also includes a few additional line break cleanups in the
rkisp1_write() calls, but no other manual change.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: regs: Rename CCL, ICCL and IRCL registers with VI_ prefix
Laurent Pinchart [Sat, 26 Feb 2022 18:09:58 +0000 (18:09 +0000)]
media: rkisp1: regs: Rename CCL, ICCL and IRCL registers with VI_ prefix

The documentation names the CCL, ICCL and IRCL registers with a VI_
prefix, like the VI_ID and VI_DPCL registers. Fix the macro names
accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: regs: Don't use BIT() macro for multi-bit register fields
Laurent Pinchart [Sat, 26 Feb 2022 18:09:58 +0000 (18:09 +0000)]
media: rkisp1: regs: Don't use BIT() macro for multi-bit register fields

The BIT() macro is meant to represent a single bit. It is incorrectly
used for register field values that store the value 1 in a multi-bit
field. Use the usual (1 << n) construct for those.

While at it, move RKISP1_CIF_MI_DMA_CTRL_READ_FMT_PACKED where it
belongs with the other READ_FMT values.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: Simplify rkisp1_entities_register() error path
Laurent Pinchart [Thu, 24 Feb 2022 14:24:10 +0000 (14:24 +0000)]
media: rkisp1: Simplify rkisp1_entities_register() error path

Now that all the unregistration functions are safe to call on
non-registered entities, the error path in rkisp1_entities_register()
can be simplified. Factor out the unregistration to a separate function
to share code with rkisp1_remove().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: stats: Simplify (un)registration
Laurent Pinchart [Thu, 24 Feb 2022 12:58:40 +0000 (12:58 +0000)]
media: rkisp1: stats: Simplify (un)registration

Simplify error handling at registration time as media_entity_cleanup()
can be called on an uninitialized entity, and make
rkisp1_stats_unregister() safe to be called on an unregistered stats
node to prepare for simplification of error handling at probe time.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: params: Fix and simplify (un)registration
Laurent Pinchart [Thu, 24 Feb 2022 12:58:40 +0000 (12:58 +0000)]
media: rkisp1: params: Fix and simplify (un)registration

The rkisp1_params_register() and rkisp1_params_unregister() functions
don't destroy the mutex (in the error path for the former). Fix this,
simplify error handling at registration time as media_entity_cleanup()
can be called on an uninitialized entity, and make
rkisp1_params_unregister() safe to be called on an unregistered params
node to prepare for simplification of error handling at probe time.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: resizer: Fix and simplify (un)registration
Laurent Pinchart [Thu, 24 Feb 2022 12:58:40 +0000 (12:58 +0000)]
media: rkisp1: resizer: Fix and simplify (un)registration

The rkisp1_rsz_register() and rkisp1_rsz_unregister() functions don't
destroy the mutex (in the error path for the former). Fix this, simplify
error handling at registration time as media_entity_cleanup() can be
called on an uninitialized entity, and make rkisp1_rsz_unregister() and
rkisp1_resizer_devs_unregister() safe to be called on an unregistered
resizer subdev to prepare for simplification of error handling at probe
time.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: isp: Fix and simplify (un)registration
Laurent Pinchart [Thu, 24 Feb 2022 12:58:40 +0000 (12:58 +0000)]
media: rkisp1: isp: Fix and simplify (un)registration

The rkisp1_isp_register() and rkisp1_isp_unregister() functions don't
destroy the mutex (in the error path for the former). Fix this, simplify
error handling at registration time as media_entity_cleanup() can be
called on an uninitialized entity, and make rkisp1_isp_unregister() and
safe to be called on an unregistered isp subdev to prepare for
simplification of error handling at probe time.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: capture: Fix and simplify (un)registration
Laurent Pinchart [Thu, 24 Feb 2022 12:58:40 +0000 (12:58 +0000)]
media: rkisp1: capture: Fix and simplify (un)registration

The rkisp1_register_capture() and rkisp1_unregister_capture() functions
don't destroy the mutex (in the error path for the former). Fix this and
make rkisp1_unregister_capture() and rkisp1_capture_devs_unregister()
safe to be called on an unregistered capture node to prepare for
simplification of error handling at probe time.

While at it, drop the double initialization of cap->rkisp1 in
rkisp1_capture_devs_register() as the field is already initialized in
rkisp1_capture_init().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rkisp1: capture: Initialize entity before video device
Laurent Pinchart [Thu, 24 Feb 2022 13:57:32 +0000 (13:57 +0000)]
media: rkisp1: capture: Initialize entity before video device

The media_entity embedded in the video_device needs to be initialized
before registering the video_device. Do so.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Dafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: pvrusb2: fix memory leak in pvr_probe
Dongliang Mu [Thu, 9 Jun 2022 07:35:28 +0000 (08:35 +0100)]
media: pvrusb2: fix memory leak in pvr_probe

The error handling code in pvr2_hdw_create forgets to unregister the
v4l2 device. When pvr2_hdw_create returns back to pvr2_context_create,
it calls pvr2_context_destroy to destroy context, but mp->hdw is NULL,
which leads to that pvr2_hdw_destroy directly returns.

Fix this by adding v4l2_device_unregister to decrease the refcount of
usb interface.

Reported-by: syzbot+77b432d57c4791183ed4@syzkaller.appspotmail.com
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: rcar-vin: Fix channel routing for Ebisu
Niklas Söderlund [Wed, 8 Jun 2022 20:46:57 +0000 (21:46 +0100)]
media: rcar-vin: Fix channel routing for Ebisu

When converting to full Virtual Channel routing an error crept into the
routing table for Ebisu (r8a77990). The routing information is used at
probe time preventing rcar-vin from probing correctly on this SoC, solve
by correcting the routing table.

Fixes: 3e52419ec04f9769 ("media: rcar-{csi2,vin}: Move to full Virtual Channel routing per CSI-2 IP")
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek/vcodec: Enable incoherent buffer allocation
Justin Green [Mon, 6 Jun 2022 17:24:11 +0000 (18:24 +0100)]
media: mediatek/vcodec: Enable incoherent buffer allocation

Set allow_cache_hints to 1 for the vb2_queue source and destination queues
in the mediatek vcodec V4L2 driver. This allows us to allocate buffers
with the V4L2_MEMORY_FLAG_NON_COHERENT set. On Mediatek SoCs, this enables
caching for this memory, which vastly improves performance when being read
from CPU. Read performance for these buffers is in turn important for
detiling MM21 video frames in userspace software, such as libyuv or
gstreamer.

This change should be safe from race conditions since videobuf2 already
invalidates or flushes the appropriate cache lines in its prepare() and
finish() methods.

Tested on a MT8183 SoC. Resulted in both correct detiling and a 10X
speedup.

Signed-off-by: Justin Green <greenjustin@chromium.org>
Suggested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: amphion: delete unnecessary NULL check
Ziyang Xuan [Mon, 6 Jun 2022 13:10:42 +0000 (14:10 +0100)]
media: amphion: delete unnecessary NULL check

vfree(NULL) is safe. NULL check before vfree() is not needed.
Delete them to simplify the code.

Generated by coccinelle script:
scripts/coccinelle/free/ifnullfree.cocci

Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: ming_qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: Implement drain using v4l2-mem2mem helpers
Ming Qian [Mon, 30 May 2022 07:50:02 +0000 (08:50 +0100)]
media: imx-jpeg: Implement drain using v4l2-mem2mem helpers

v4l2 m2m has supplied some helper function to handle drain,
so the driver can use the helper function directly.

Fixes: d8ebe298d008c ("media: imx-jpeg: Set V4L2_BUF_FLAG_LAST at eos")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: Align upwards buffer size
Ming Qian [Mon, 30 May 2022 07:49:19 +0000 (08:49 +0100)]
media: imx-jpeg: Align upwards buffer size

The hardware can support any image size WxH,
with arbitrary W (image width) and H (image height) dimensions.

Align upwards buffer size for both encoder and decoder.
and leave the picture resolution unchanged.

For decoder, the risk of memory out of bounds can be avoided.
For both encoder and decoder, the driver will lift the limitation of
resolution alignment.

For example, the decoder can support jpeg whose resolution is 227x149
the encoder can support nv12 1080P, won't change it to 1920x1072.

Fixes: 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: Leave a blank space before the configuration data
Ming Qian [Mon, 30 May 2022 07:48:37 +0000 (08:48 +0100)]
media: imx-jpeg: Leave a blank space before the configuration data

There is a hardware bug that it will load
the first 128 bytes of configuration data twice,
it will led to some configure error.
so shift the configuration data 128 bytes,
and make the first 128 bytes all zero,
then hardware will load the 128 zero twice,
and ignore them as garbage.
then the configuration data can be loaded correctly

Fixes: 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: imx-jpeg: Correct some definition according specification
Ming Qian [Mon, 30 May 2022 07:47:31 +0000 (08:47 +0100)]
media: imx-jpeg: Correct some definition according specification

the register CAST_NOMFRSIZE_LO should be equal to CAST_STATUS16
the register CAST_NOMFRSIZE_HI should be equal to CAST_STATUS17
the register CAST_OFBSIZE_LO should be equal to CAST_STATUS18
the register CAST_OFBSIZE_HI should be equal to CAST_STATUS19

Fixes: 2db16c6ed72ce ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: fix missing/incorrect resource cleanup in error case
Chengguang Xu [Sun, 29 May 2022 15:34:56 +0000 (16:34 +0100)]
media: platform: fix missing/incorrect resource cleanup in error case

In error case of s5p_mfc_power_on() we should call
clk_disable_unprepare() for the
clocks(from pm->clocks[0] to pm->clocks[i-1]).

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: amphion: Replace zero-length array with flexible-array member
Kees Cook [Fri, 27 May 2022 21:29:53 +0000 (22:29 +0100)]
media: amphion: Replace zero-length array with flexible-array member

There is a regular need in the kernel to provide a way to declare
having a dynamically sized set of trailing elements in a structure.
Kernel code should always use “flexible array members”[1] for these
cases. The older style of one-element or zero-length arrays should no
longer be used[2][3].

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
[3] https://github.com/KSPP/linux/issues/78

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Cc: Ming Qian <ming.qian@nxp.com>
Cc: Shijie Qin <shijie.qin@nxp.com>
Cc: Zhou Peng <eagle.zhou@nxp.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: ming_qian <ming.qian@nxp.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: Hantro: Correct G2 init qp field
Benjamin Gaignard [Tue, 24 May 2022 11:59:45 +0000 (12:59 +0100)]
media: Hantro: Correct G2 init qp field

Documentation said that g2 init_qp field use bits 24 to 30 of
the 8th register.
Change the field mask to be able to set 7 bits and not only 6 of them.

Conformance test INITQP_B_Main10_Sony_1 decoding is OK with this
patch.

Fixes: cb5dd5a0fa518 ("media: hantro: Introduce G2/HEVC decoder")
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: Use kmemdup rather than kmalloc/memcpy
Haowen Bai [Tue, 24 May 2022 03:42:21 +0000 (04:42 +0100)]
media: mediatek: vcodec: Use kmemdup rather than kmalloc/memcpy

kmemdup is introduced to duplicate a region of memory in a neat way.
Rather than kmalloc/kzalloc + memcpy, which the programmer needs to
write the size twice (sometimes lead to mistakes), kmemdup improves
readability, leads to smaller code and also reduce the chances of mistakes.
Suggestion to use kmemdup rather than using kmalloc/kzalloc + memcpy.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: atmel: atmel-isc-base: move cropping settings outside start_dma
Eugen Hristev [Mon, 23 May 2022 14:17:05 +0000 (15:17 +0100)]
media: atmel: atmel-isc-base: move cropping settings outside start_dma

The cropping configuration of the Parallel Front Engine (PFE) can be done
just once when the streaming starts. The ISC configuration is in place and
will not be changed while streaming.
It is not effective to keep rewriting the crop registers configuration
everytime start_dma is called, as this can be called for each queued
buffer.
Thus we can configure the cropping at start_streaming time.
This change moves the code to a dedicated function.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: camss: Move and unexport functions specific to ISPIF
Vladimir Zapolskiy [Mon, 23 May 2022 12:25:13 +0000 (13:25 +0100)]
media: camss: Move and unexport functions specific to ISPIF

Common exported functions msm_vfe_get_vfe_id() and
msm_vfe_get_vfe_line_id() do not have any users outside of camss-ispif.c,
move them to the latter object and staticize.

The change is supposed to be a non-functional one.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>