platform/kernel/linux-starfive.git
11 months agomedia: mediatek: vcodec: Improve an error message
Dan Carpenter [Wed, 14 Jun 2023 13:19:41 +0000 (16:19 +0300)]
media: mediatek: vcodec: Improve an error message

This is intended to print the error code but there is a typo so it
prints IS_ERR() instead of PTR_ERR().

Fixes: 77f3b023f452 ("media: mediatek: vcodec: Add debugfs interface to get debug information")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: mediatek: vcodec: Fix potential crash in mtk_vcodec_dbgfs_remove()
Dan Carpenter [Wed, 14 Jun 2023 13:07:15 +0000 (16:07 +0300)]
media: mediatek: vcodec: Fix potential crash in mtk_vcodec_dbgfs_remove()

The list iterator "dbgfs_inst" is always non-NULL.  This means that the
test for NULL inside the loop is unnecessary and it also means that the
test for NULL outside the loop will not work.  If we do not find the item
on the list with the correct the ctx_id then it will free invalid memory
leading to a crash.

Fixes: cd403a6a0419 ("media: mediatek: vcodec: Add a debugfs file to get different useful information")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: amphion: ensure the bitops don't cross boundaries
Ming Qian [Tue, 18 Jul 2023 09:50:13 +0000 (17:50 +0800)]
media: amphion: ensure the bitops don't cross boundaries

the supported_instance_count determine the instance index range,
it shouldn't exceed the bits number of instance_mask,
otherwise the bitops of instance_mask may cross boundaries

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: amphion: fix UNUSED_VALUE issue reported by coverity
Ming Qian [Tue, 18 Jul 2023 09:50:12 +0000 (17:50 +0800)]
media: amphion: fix UNUSED_VALUE issue reported by coverity

assign value '-EINVAL' to ret, but the stored value is overwritten
before it can be used

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: amphion: fix UNINIT issues reported by coverity
Ming Qian [Tue, 18 Jul 2023 09:50:11 +0000 (17:50 +0800)]
media: amphion: fix UNINIT issues reported by coverity

using uninitialized value may introduce risk

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: amphion: fix REVERSE_INULL issues reported by coverity
Ming Qian [Tue, 18 Jul 2023 09:50:10 +0000 (17:50 +0800)]
media: amphion: fix REVERSE_INULL issues reported by coverity

null-checking of a pointor is suggested before dereferencing it

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: amphion: fix CHECKED_RETURN issues reported by coverity
Ming Qian [Tue, 18 Jul 2023 09:50:09 +0000 (17:50 +0800)]
media: amphion: fix CHECKED_RETURN issues reported by coverity

calling "vpu_cmd_send/vpu_get_buffer_state/vpu_session_alloc_fs"
without checking return value

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: rkvdec: increase max supported height for H.264
Benjamin Gaignard [Mon, 17 Jul 2023 15:06:11 +0000 (17:06 +0200)]
media: rkvdec: increase max supported height for H.264

After testing it is possible for the hardware to decode H264
bistream with a height up to 2560.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: amphion: decoder support display delay for all formats
Ming Qian [Mon, 10 Jul 2023 07:44:11 +0000 (15:44 +0800)]
media: amphion: decoder support display delay for all formats

the firmware only support low latency mode for h264,
but firmware will notify an event to driver
when one frame is decoded,
if V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE is enabled,
and V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY is set to 0,
driver can display the decoded frame immediately.

Fixes: ffa331d9bf94 ("media: amphion: decoder implement display delay enable")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: mtk-jpeg: Fix use after free bug due to uncanceled work
Zheng Wang [Fri, 7 Jul 2023 09:24:14 +0000 (17:24 +0800)]
media: mtk-jpeg: Fix use after free bug due to uncanceled work

In mtk_jpeg_probe, &jpeg->job_timeout_work is bound with
mtk_jpeg_job_timeout_work. Then mtk_jpeg_dec_device_run
and mtk_jpeg_enc_device_run may be called to start the
work.
If we remove the module which will call mtk_jpeg_remove
to make cleanup, there may be a unfinished work. The
possible sequence is as follows, which will cause a
typical UAF bug.

Fix it by canceling the work before cleanup in the mtk_jpeg_remove

CPU0                  CPU1

                    |mtk_jpeg_job_timeout_work
mtk_jpeg_remove     |
  v4l2_m2m_release  |
    kfree(m2m_dev); |
                    |
                    | v4l2_m2m_get_curr_priv
                    |   m2m_dev->curr_ctx //use
Fixes: b2f0d2724ba4 ("[media] vcodec: mediatek: Add Mediatek JPEG Decoder Driver")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: verisilicon: Fix TRY_FMT on encoder OUTPUT
Michael Tretter [Thu, 6 Jul 2023 07:15:10 +0000 (09:15 +0200)]
media: verisilicon: Fix TRY_FMT on encoder OUTPUT

Commit f100ce3bbd6a ("media: verisilicon: Fix crash when probing
encoder") removed vpu_fmt from hantro_try_fmt(), since it was
initialized from vpu_dst_fmt, which may not be initialized, when TRY_FMT
is called. It was replaced by fmt, which is found using the pixelformat.

For the encoder, this changed the fmt to contain the raw format instead
of the coded format. The format constraints as of fmt->frmsize are only
valid for the coded format and are 0 for the raw formats. Therefore, the
size of a encoder OUTPUT device is constrained to 0 and the
v4l2-compliance tests for G_FMT, TRY_FMT, and SET_FMT fail.

Bring back vpu_fmt to use the coded format on an encoder OUTPUT device,
but initialize it using the currently set pixelformat on dst_fmt, which
is the coded format on an encoder.

Fixes: f100ce3bbd6a ("media: verisilicon: Fix crash when probing encoder")
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: rkvdec: removed redundant blank line
Emma Christy [Wed, 21 Jun 2023 15:42:47 +0000 (18:42 +0300)]
media: rkvdec: removed redundant blank line

Adhere to Linux kernel coding style. Removed redundant blank line.
Issue found by checkpatch.

Signed-off-by: Emma Christy <emma.t.christy@gmail.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: meson: vdec: Add MODULE_FIRMWARE macro
Juerg Haefliger [Tue, 13 Jun 2023 15:39:39 +0000 (17:39 +0200)]
media: meson: vdec: Add MODULE_FIRMWARE macro

The meson-vdec module loads firmware so add MODULE_FIRMWARE macros to
provide that information via modinfo.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: amphion: add helper function to get id name
Ming Qian [Tue, 13 Jun 2023 09:14:08 +0000 (17:14 +0800)]
media: amphion: add helper function to get id name

convert numbers into meaningful names,
then it can improve the log readability

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: amphion: reinit vpu if reqbufs output 0
Ming Qian [Tue, 13 Jun 2023 07:48:46 +0000 (15:48 +0800)]
media: amphion: reinit vpu if reqbufs output 0

according to v4l2 stateful decoder document 4.5.1.3. State Machine,
the state should change from seek to initialization
if call VIDIOC_REQBUFS(OUTPUT, 0).

so reinit the vpu decoder if reqbufs output 0

Fixes: 6de8d628df6e ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: pci: saa7164: replace BUG with error return
Hans Verkuil [Fri, 21 Jul 2023 08:24:01 +0000 (10:24 +0200)]
media: pci: saa7164: replace BUG with error return

It was completely unnecessary to use BUG in saa7164_s_frequency,
just return an error instead. This also solves a smatch error:

drivers/media/pci/saa7164/saa7164-encoder.c:388 saa7164_s_frequency() error: potentially dereferencing uninitialized 'tsport'.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: pci: cx23885: replace BUG with error return
Hans Verkuil [Fri, 21 Jul 2023 08:23:42 +0000 (10:23 +0200)]
media: pci: cx23885: replace BUG with error return

It was completely unnecessary to use BUG in buffer_prepare().
Just replace it with an error return. This also fixes a smatch warning:

drivers/media/pci/cx23885/cx23885-video.c:422 buffer_prepare() error: uninitialized symbol 'ret'.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agostaging: media: tegra-video: include video.h header
Hans Verkuil [Thu, 20 Jul 2023 07:20:03 +0000 (09:20 +0200)]
staging: media: tegra-video: include video.h header

This tells sparse that tegra_vip_driver is actually used,
and so avoids this warning:

drivers/staging/media/tegra-video/vip.c:280:31: warning: 'tegra_vip_driver' defined but not used [-Wunused-variable]
  280 | static struct platform_driver tegra_vip_driver = {
      |                               ^~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
11 months agostaging: media: sun6i-isp: drop of_match_ptr for ID table
Hans Verkuil [Thu, 20 Jul 2023 07:18:22 +0000 (09:18 +0200)]
staging: media: sun6i-isp: drop of_match_ptr for ID table

The driver can match only via the DT table so the table should be always
used and the of_match_ptr does not make any sense.

This also fixes this !CONFIG_OF error:

drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c:529:34: warning: 'sun6i_isp_of_match' defined but not used [-Wunused-const-variable=]
  529 | static const struct of_device_id sun6i_isp_of_match[] = {
      |                                  ^~~~~~~~~~~~~~~~~

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
11 months agomedia: tuners: qt1010: replace BUG_ON with a regular error
Hans Verkuil [Thu, 20 Jul 2023 06:20:51 +0000 (08:20 +0200)]
media: tuners: qt1010: replace BUG_ON with a regular error

BUG_ON is unnecessary here, and in addition it confuses smatch.
Replacing this with an error return help resolve this smatch
warning:

drivers/media/tuners/qt1010.c:350 qt1010_init() error: buffer overflow 'i2c_data' 34 <= 34

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agoMAINTAINERS: update amphion vpu driver entry
Ming Qian [Thu, 20 Jul 2023 03:09:52 +0000 (11:09 +0800)]
MAINTAINERS: update amphion vpu driver entry

Shijie has not been actively working on the driver,
his e-mail address is bouncing for quite awhile now.
remove him from the maintainer list here.
I do want to thank him for his work on the driver.

Signed-off-by: Zhou Peng <eagle.zhou@nxp.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: drxk: Use %*ph for printing hexdump of a small buffer
Andy Shevchenko [Wed, 19 Jul 2023 13:14:45 +0000 (16:14 +0300)]
media: drxk: Use %*ph for printing hexdump of a small buffer

The kernel already has a helper to print a hexdump of a small
buffer via pointer extension. Use that instead of open coded
variant.

In long term it helps to kill pr_cont() or at least narrow down
its use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: i2c: ds90ub913: Fix a warning about use of uninitialized variable
Tomi Valkeinen [Wed, 19 Jul 2023 14:31:37 +0000 (17:31 +0300)]
media: i2c: ds90ub913: Fix a warning about use of uninitialized variable

Fix the following warning:

drivers/media/i2c/ds90ub913.c:488:9: warning: 'v' may be used uninitialized [-Wmaybe-uninitialized]
  488 |         ub913_write(priv, UB913_REG_GENERAL_CFG,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  489 |                     v | UB913_REG_GENERAL_CFG_CRC_ERR_RESET);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/ds90ub913.c:477:12: note: 'v' was declared here
  477 |         u8 v, v1, v2;
      |            ^

Fix the warning by initializing the variable to 0. Proper error handling
here would be somewhat pointless, as we are just printing register
values, and the user will see an error about the failed i2c transaction.

Fixes: c158d0d4ff15 ("media: i2c: add DS90UB913 driver")
Reported-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Closes: https://lore.kernel.org/all/a0180488-f7f5-8538-a8bb-52ae52912835@xs4all.nl/
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: Remove flag FBINFO_FLAG_DEFAULT from fbdev drivers
Thomas Zimmermann [Sat, 15 Jul 2023 18:51:53 +0000 (20:51 +0200)]
media: Remove flag FBINFO_FLAG_DEFAULT from fbdev drivers

The flag FBINFO_FLAG_DEFAULT is 0 and has no effect, as struct
fbinfo.flags has been allocated to zero by kzalloc(). So do not
set it.

Flags should signal differences from the default values. After cleaning
up all occurrences of FBINFO_DEFAULT, the token will be removed.

v2:
* fix commit message (Miguel)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: ti: cal: Implement get_frame_desc for camera-rx
Tomi Valkeinen [Mon, 19 Jun 2023 11:40:07 +0000 (14:40 +0300)]
media: ti: cal: Implement get_frame_desc for camera-rx

CAL uses get_frame_desc to get the VC and DT for the incoming CSI-2
stream, but does it in a bit hacky way. Clean this up by implementing
.get_frame_desc to camera-rx, and calling that from cal.c.

No functional change intended.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: ti: cal: Use subdev state
Tomi Valkeinen [Mon, 19 Jun 2023 11:40:06 +0000 (14:40 +0300)]
media: ti: cal: Use subdev state

Change TI CAL driver to use subdev state. No functional changes
(intended).

This allows us to get rid of the 'formats' field, as the formats are
kept in the state, and also the 'mutex' as we already have state locking.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: ti: cal: Fix cal_camerarx_create() error handling
Tomi Valkeinen [Mon, 19 Jun 2023 11:40:05 +0000 (14:40 +0300)]
media: ti: cal: Fix cal_camerarx_create() error handling

We don't do a proper job at freeing resources in cal_camerarx_create's
error paths.

Fix these, and also switch the phy allcation from kzalloc to
devm_kzalloc to simplify the code further.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: ti: cal: Clean up mbus formats uses
Tomi Valkeinen [Mon, 19 Jun 2023 11:40:04 +0000 (14:40 +0300)]
media: ti: cal: Clean up mbus formats uses

Clean up the CAL drivers uses of mbus formats:

- Switch all YUV formats from 2X8 formats to 1X16, as those are what
  should be used for CSI-2 bus.

- Drop 24 and 32 bit formats, as the driver doesn't support them (see
  cal_ctx_pix_proc_config()).

- Switch RGB565_2X8_LE to RGB565_1X16 (for the same reason as for the
  YUV formats) and drop RGB565_2X8_BE as it cannot be supported with
  CSI-2.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: imx: Unstage the imx8mq-mipi-csi2 driver
Martin Kepplinger [Tue, 25 Apr 2023 09:08:04 +0000 (11:08 +0200)]
media: imx: Unstage the imx8mq-mipi-csi2 driver

The imx8mq-mipi-csi2 MIPI CSI-2 receiver driver is used and maintained.
There is no reason to keep it in staging. The accompanying CSI bridge
driver that uses it is in drivers/media/platform/nxp as well.

One TODO is to get rid of csi_state's "state" and "lock" variables.
Especially make sure suspend/resume is working without them. That can
very well be worked on from the new location.

Also add a MAINTAINERS section for the imx8mq-mipi-csi2 mipi receiver
driver.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agostaging: media: ipu3: code style fix - avoid multiple line dereference
Nikolay Kyx [Sun, 21 Feb 2021 12:10:20 +0000 (15:10 +0300)]
staging: media: ipu3: code style fix - avoid multiple line dereference

This patch fixes the following checkpatch.pl warning:

WARNING: Avoid multiple line dereference

in file ipu3-css.c

Signed-off-by: Nikolay Kyx <knv418@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: i2c: ov01a10: Switch back to use struct i2c_driver::probe
Uwe Kleine-König [Mon, 26 Jun 2023 09:05:33 +0000 (11:05 +0200)]
media: i2c: ov01a10: Switch back to use struct i2c_driver::probe

struct i2c_driver::probe_new is about to go away. Switch the driver to
use the probe callback with the same prototype.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: aspeed: Fix memory overwrite if timing is 1600x900
Jammy Huang [Wed, 19 Jul 2023 06:33:18 +0000 (06:33 +0000)]
media: aspeed: Fix memory overwrite if timing is 1600x900

When capturing 1600x900, system could crash when system memory usage is
tight.

The way to reproduce this issue:
1. Use 1600x900 to display on host
2. Mount ISO through 'Virtual media' on OpenBMC's web
3. Run script as below on host to do sha continuously
  #!/bin/bash
  while [ [1] ];
  do
find /media -type f -printf '"%h/%f"\n' | xargs sha256sum
  done
4. Open KVM on OpenBMC's web

The size of macro block captured is 8x8. Therefore, we should make sure
the height of src-buf is 8 aligned to fix this issue.

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: ds90ub9xx: switch three more drivers back to use struct i2c_driver::probe()
Uwe Kleine-König [Tue, 18 Jul 2023 20:45:41 +0000 (22:45 +0200)]
media: ds90ub9xx: switch three more drivers back to use struct i2c_driver::probe()

struct i2c_driver::probe_new() is about to go away. Since I converted
all drivers below drivers/media use struct i2c_driver::probe, three more
drivers were added in the following commits that use .probe_new():

commit 6363db1c9d45 ("media: i2c: add DS90UB953 driver")
commit c158d0d4ff15 ("media: i2c: add DS90UB913 driver")
commit afe267f2d368 ("media: i2c: add DS90UB960 driver")

Switch these driver to use the probe callback.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: use proper commit description style]

11 months agomedia: i2c: ds90ub960: fix error handling in ub960_rxport_add_serializer()
Harshit Mogalapalli [Tue, 18 Jul 2023 14:06:58 +0000 (07:06 -0700)]
media: i2c: ds90ub960: fix error handling in ub960_rxport_add_serializer()

Smatch warns:
 drivers/media/i2c/ds90ub960.c:1671 ub960_rxport_add_serializer():
 err: 'rxport->ser.client' dereferencing possible ERR_PTR()

i2c_new_client_device() returns error pointers on failure and in
dev_dbg statement we are dereferencing error pointer which is a bug.

Fix this by using IS_ERR() which checks for error pointers.

Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: i2c: ds90ub953: No need to set device_driver owner
Yang Li [Tue, 18 Jul 2023 01:01:54 +0000 (09:01 +0800)]
media: i2c: ds90ub953: No need to set device_driver owner

Remove .owner field if calls are used which set it automatically.

to silence the warning:
./drivers/media/i2c/ds90ub953.c:1390:3-8: No need to set .owner here.  The core will do it.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5902
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: Explicitly include correct DT includes
Rob Herring [Fri, 14 Jul 2023 17:47:08 +0000 (11:47 -0600)]
media: Explicitly include correct DT includes

The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: dvb-usb-v2: gl861: Fix null-ptr-deref in gl861_i2c_master_xfer
Zhang Shurong [Mon, 10 Jul 2023 05:32:13 +0000 (13:32 +0800)]
media: dvb-usb-v2: gl861: Fix null-ptr-deref in gl861_i2c_master_xfer

In gl861_i2c_master_xfer, msg is controlled by user. When msg[i].buf
is null and msg[i].len is zero, former checks on msg[i].buf would be
passed. Malicious data finally reach gl861_i2c_master_xfer. If accessing
msg[i].buf[0] without sanity check, null ptr deref would happen.
We add check on msg[i].len to prevent crash.

Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: dvb-usb: opera1: fix uninit-value in dvb_usb_adapter_dvb_init
Zhang Shurong [Sun, 9 Jul 2023 05:04:09 +0000 (13:04 +0800)]
media: dvb-usb: opera1: fix uninit-value in dvb_usb_adapter_dvb_init

If opera1_xilinx_rw fails, the mac address is not initialized.
And opera1_read_mac_address does not handle this failure, which leads to
the uninit-value in dvb_usb_adapter_dvb_init.

Fix this by handling the failure of opera1_xilinx_rw.

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: az6007: Fix null-ptr-deref in az6007_i2c_xfer()
Zhang Shurong [Sat, 8 Jul 2023 16:28:17 +0000 (00:28 +0800)]
media: az6007: Fix null-ptr-deref in az6007_i2c_xfer()

In az6007_i2c_xfer, msg is controlled by user. When msg[i].buf
is null and msg[i].len is zero, former checks on msg[i].buf would be
passed. Malicious data finally reach az6007_i2c_xfer. If accessing
msg[i].buf[0] without sanity check, null ptr deref would happen.
We add check on msg[i].len to prevent crash.

Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: anysee: fix null-ptr-deref in anysee_master_xfer
Zhang Shurong [Sat, 8 Jul 2023 16:02:20 +0000 (00:02 +0800)]
media: anysee: fix null-ptr-deref in anysee_master_xfer

In anysee_master_xfer, msg is controlled by user. When msg[i].buf
is null and msg[i].len is zero, former checks on msg[i].buf would be
passed. Malicious data finally reach anysee_master_xfer. If accessing
msg[i].buf[0] without sanity check, null ptr deref would happen.
We add check on msg[i].len to prevent crash.

Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: add spaces around +]

11 months agomedia: af9005: Fix null-ptr-deref in af9005_i2c_xfer
Zhang Shurong [Sat, 8 Jul 2023 15:24:11 +0000 (23:24 +0800)]
media: af9005: Fix null-ptr-deref in af9005_i2c_xfer

In af9005_i2c_xfer, msg is controlled by user. When msg[i].buf
is null and msg[i].len is zero, former checks on msg[i].buf would be
passed. Malicious data finally reach af9005_i2c_xfer. If accessing
msg[i].buf[0] without sanity check, null ptr deref would happen.
We add check on msg[i].len to prevent crash.

Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: dw2102: Fix null-ptr-deref in dw2102_i2c_transfer()
Zhang Shurong [Sat, 8 Jul 2023 10:22:52 +0000 (18:22 +0800)]
media: dw2102: Fix null-ptr-deref in dw2102_i2c_transfer()

In dw2102_i2c_transfer, msg is controlled by user. When msg[i].buf
is null and msg[i].len is zero, former checks on msg[i].buf would be
passed. Malicious data finally reach dw2102_i2c_transfer. If accessing
msg[i].buf[0] without sanity check, null ptr deref would happen.
We add check on msg[i].len to prevent crash.

Similar commit:
commit 950e252cb469
("[media] dw2102: limit messages to buffer size")

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: sh_vou: Convert to devm_platform_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:59 +0000 (18:10 +0800)]
media: sh_vou: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: fimc-core: Convert to devm_platform_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:58 +0000 (18:10 +0800)]
media: fimc-core: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: platform: ti: Use devm_platform_get_and_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:57 +0000 (18:10 +0800)]
media: platform: ti: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: retained the line wrap]

11 months agomedia: stm32-dcmi: Use devm_platform_get_and_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:56 +0000 (18:10 +0800)]
media: stm32-dcmi: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: verisilicon: Convert to devm_platform_ioremap_resource() and devm_platform_ior...
Yangtao Li [Thu, 6 Jul 2023 10:10:55 +0000 (18:10 +0800)]
media: verisilicon: Convert to devm_platform_ioremap_resource() and devm_platform_ioremap_resource_byname()

Use devm_platform_ioremap_resource() and
devm_platform_ioremap_resource_byname() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: microchip-sama7g5-isc: Convert to devm_platform_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:54 +0000 (18:10 +0800)]
media: microchip-sama7g5-isc: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: fimc-lite: Convert to devm_platform_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:53 +0000 (18:10 +0800)]
media: fimc-lite: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: microchip-sama5d2-isc: Convert to devm_platform_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:52 +0000 (18:10 +0800)]
media: microchip-sama5d2-isc: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: marvell: Use devm_platform_get_and_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:51 +0000 (18:10 +0800)]
media: marvell: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: pxa_camera: Use devm_platform_get_and_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:50 +0000 (18:10 +0800)]
media: pxa_camera: Use devm_platform_get_and_ioremap_resource()

Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: atmel-isi: Convert to devm_platform_ioremap_resource()
Yangtao Li [Thu, 6 Jul 2023 10:10:49 +0000 (18:10 +0800)]
media: atmel-isi: Convert to devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: dvb-usb-v2: af9035: Fix null-ptr-deref in af9035_i2c_master_xfer
Zhang Shurong [Wed, 5 Jul 2023 16:06:54 +0000 (00:06 +0800)]
media: dvb-usb-v2: af9035: Fix null-ptr-deref in af9035_i2c_master_xfer

In af9035_i2c_master_xfer, msg is controlled by user. When msg[i].buf
is null and msg[i].len is zero, former checks on msg[i].buf would be
passed. Malicious data finally reach af9035_i2c_master_xfer. If accessing
msg[i].buf[0] without sanity check, null ptr deref would happen.
We add check on msg[i].len to prevent crash.

Similar commit:
commit 0ed554fd769a
("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agodrivers: saa7164: remove duplicate assignments
Minjie Du [Wed, 5 Jul 2023 06:49:22 +0000 (14:49 +0800)]
drivers: saa7164: remove duplicate assignments

make second_timeout avoid double assignment.

Signed-off-by: Minjie Du <duminjie@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: wl128x: Fix spelling mistake "Transfered" -> "Transferred"
Colin Ian King [Fri, 30 Jun 2023 07:57:44 +0000 (08:57 +0100)]
media: wl128x: Fix spelling mistake "Transfered" -> "Transferred"

There is a spelling mistake in a fmdbg message. Fix it.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: split overly long line over two lines]

11 months agomedia: docs: qcom_camss: Update Code Aurora references
Jeffrey Hugo [Wed, 28 Jun 2023 19:04:33 +0000 (13:04 -0600)]
media: docs: qcom_camss: Update Code Aurora references

source.codeaurora.org is no longer accessible and so the reference links
in the documentation are not useful.  The content was mirrored over to
Code Linaro so lets update the references to point there instead.

Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: cx24120: Add retval check for cx24120_message_send()
Daniil Dulov [Fri, 2 Jun 2023 08:55:01 +0000 (01:55 -0700)]
media: cx24120: Add retval check for cx24120_message_send()

If cx24120_message_send() returns error, we should keep local struct
unchanged.

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

Fixes: 5afc9a25be8d ("[media] Add support for TechniSat Skystar S2")
Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: mdp3: Fix resource leaks in of_find_device_by_node
Lu Hongfei [Tue, 30 May 2023 10:17:18 +0000 (18:17 +0800)]
media: mdp3: Fix resource leaks in of_find_device_by_node

Use put_device to release the object get through of_find_device_by_node,
avoiding resource leaks.

Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: dvb-usb: m920x: Fix a potential memory leak in m920x_i2c_xfer()
Christophe JAILLET [Mon, 29 May 2023 05:58:36 +0000 (07:58 +0200)]
media: dvb-usb: m920x: Fix a potential memory leak in m920x_i2c_xfer()

'read' is freed when it is known to be NULL, but not when a read error
occurs.

Revert the logic to avoid a small leak, should a m920x_read() call fail.

Fixes: a2ab06d7c4d6 ("media: m920x: don't use stack on USB reads")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: tc358743: Add error code to error message
Alexander Stein [Tue, 25 Apr 2023 07:33:46 +0000 (09:33 +0200)]
media: tc358743: Add error code to error message

Add the error code of a failed i2c transfer to the error message.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: dib7000p: Fix potential division by zero
Daniil Dulov [Fri, 24 Mar 2023 13:38:32 +0000 (06:38 -0700)]
media: dib7000p: Fix potential division by zero

Variable loopdiv can be assigned 0, then it is used as a denominator,
without checking it for 0.

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

Fixes: 713d54a8bd81 ("[media] DiB7090: add support for the dib7090 based")
Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil: (bw != NULL) -> bw]

11 months agomedia: cx18: remove unnecessary (void*) conversions
Yu Zhe [Mon, 20 Mar 2023 08:45:02 +0000 (16:45 +0800)]
media: cx18: remove unnecessary (void*) conversions

Pointer variables of void * type do not require type cast.

Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: ttpci: remove unnecessary (void*) conversions
Yu Zhe [Mon, 20 Mar 2023 08:16:51 +0000 (16:16 +0800)]
media: ttpci: remove unnecessary (void*) conversions

Pointer variables of void * type do not require type cast.

Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: ttusb-dec: remove unnecessary (void*) conversions
Yu Zhe [Mon, 20 Mar 2023 06:52:22 +0000 (14:52 +0800)]
media: ttusb-dec: remove unnecessary (void*) conversions

Pointer variables of void * type do not require type cast.

Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agodrivers: usb: smsusb: fix error handling code in smsusb_init_device
Dongliang Mu [Mon, 27 Feb 2023 10:24:08 +0000 (18:24 +0800)]
drivers: usb: smsusb: fix error handling code in smsusb_init_device

The previous commit 4b208f8b561f ("[media] siano: register media controller
earlier")moves siano_media_device_register before smscore_register_device,
and adds corresponding error handling code if smscore_register_device
fails. However, it misses the following error handling code of
smsusb_init_device.

Fix this by moving error handling code at the end of smsusb_init_device
and adding a goto statement in the following error handling parts.

Fixes: 4b208f8b561f ("[media] siano: register media controller earlier")
Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agodrivers/media/common/siano/smsendian.c : eliminate unnecessary type conversions
Dong Chuanjian [Mon, 26 Dec 2022 03:10:05 +0000 (11:10 +0800)]
drivers/media/common/siano/smsendian.c : eliminate unnecessary type conversions

remove unnecessary void* type casting.

Signed-off-by: Dong Chuanjian <chuanjian@nfschina.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: siano: Convert to use sysfs_emit_at() API
ye xingchen [Thu, 8 Dec 2022 03:40:06 +0000 (11:40 +0800)]
media: siano: Convert to use sysfs_emit_at() API

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: pvrusb2: use sysfs_emit() to instead of scnprintf()
ye xingchen [Thu, 1 Dec 2022 11:27:59 +0000 (19:27 +0800)]
media: pvrusb2: use sysfs_emit() to instead of scnprintf()

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
11 months agomedia: v4l2-core: Fix a potential resource leak in v4l2_fwnode_parse_link()
Christophe JAILLET [Wed, 14 Jun 2023 18:31:05 +0000 (20:31 +0200)]
media: v4l2-core: Fix a potential resource leak in v4l2_fwnode_parse_link()

If fwnode_graph_get_remote_endpoint() fails, 'fwnode' is known to be NULL,
so fwnode_handle_put() is a no-op.

Release the reference taken from a previous fwnode_graph_get_port_parent()
call instead.

Also handle fwnode_graph_get_port_parent() failures.

In order to fix these issues, add an error handling path to the function
and the needed gotos.

Fixes: ca50c197bd96 ("[media] v4l: fwnode: Support generic fwnode for parsing standardised properties")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: i2c: add DS90UB953 driver
Tomi Valkeinen [Mon, 19 Jun 2023 12:22:12 +0000 (14:22 +0200)]
media: i2c: add DS90UB953 driver

Add driver for TI DS90UB953 FPD-Link III Serializer.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: i2c: add DS90UB913 driver
Tomi Valkeinen [Mon, 19 Jun 2023 12:22:11 +0000 (14:22 +0200)]
media: i2c: add DS90UB913 driver

Add driver for TI DS90UB913 FPD-Link III Serializer.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: i2c: add DS90UB960 driver
Tomi Valkeinen [Mon, 19 Jun 2023 12:22:10 +0000 (14:22 +0200)]
media: i2c: add DS90UB960 driver

Add driver for TI DS90UB960 FPD-Link III Deserializer.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: dt-bindings: media: add TI DS90UB960 FPD-Link III Deserializer
Tomi Valkeinen [Mon, 19 Jun 2023 12:22:09 +0000 (14:22 +0200)]
media: dt-bindings: media: add TI DS90UB960 FPD-Link III Deserializer

Add DT bindings for TI DS90UB960 FPD-Link III Deserializer.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Rob Herring <robh@kernel.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>
11 months agomedia: dt-bindings: media: add TI DS90UB953 FPD-Link III Serializer
Tomi Valkeinen [Mon, 19 Jun 2023 12:22:08 +0000 (14:22 +0200)]
media: dt-bindings: media: add TI DS90UB953 FPD-Link III Serializer

Add DT bindings for TI DS90UB953 FPD-Link III Serializer.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: dt-bindings: media: add TI DS90UB913 FPD-Link III Serializer
Tomi Valkeinen [Mon, 19 Jun 2023 12:22:07 +0000 (14:22 +0200)]
media: dt-bindings: media: add TI DS90UB913 FPD-Link III Serializer

Add DT bindings for TI DS90UB913 FPD-Link III Serializer.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: i2c: add I2C Address Translator (ATR) support
Luca Ceresoli [Mon, 19 Jun 2023 12:22:06 +0000 (14:22 +0200)]
media: i2c: add I2C Address Translator (ATR) support

An ATR is a device that looks similar to an i2c-mux: it has an I2C
slave "upstream" port and N master "downstream" ports, and forwards
transactions from upstream to the appropriate downstream port. But it
is different in that the forwarded transaction has a different slave
address. The address used on the upstream bus is called the "alias"
and is (potentially) different from the physical slave address of the
downstream chip.

Add a helper file (just like i2c-mux.c for a mux or switch) to allow
implementing ATR features in a device driver. The helper takes care of
adapter creation/destruction and translates addresses at each transaction.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: dt-bindings: i2c: Add I2C Address Translator (ATR)
Tomi Valkeinen [Mon, 19 Jun 2023 12:22:05 +0000 (14:22 +0200)]
media: dt-bindings: i2c: Add I2C Address Translator (ATR)

Add bindings for I2C Address Translator. Only one property is added,
'i2c-alias-pool', which can be used in the bindings for the device that
supports ATR.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: i2c: tvp5150: check return value of devm_kasprintf()
Claudiu Beznea [Thu, 15 Jun 2023 10:30:30 +0000 (12:30 +0200)]
media: i2c: tvp5150: check return value of devm_kasprintf()

devm_kasprintf() returns a pointer to dynamically allocated memory.
Pointer could be NULL in case allocation fails. Check pointer validity.
Identified with coccinelle (kmerr.cocci script).

Fixes: 0556f1d580d4 ("media: tvp5150: add input source selection of_graph support")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ov13b10: add PM control support based on power resources
Bingbu Cao [Thu, 15 Jun 2023 05:54:16 +0000 (07:54 +0200)]
media: ov13b10: add PM control support based on power resources

On ACPI based platforms, the ov13b10 camera sensor need to be powered
up by acquire the PM resource from INT3472. INT3472 will register one
regulator 'avdd', one reset gpio and clock source for ov13b10.
Add 2 power interfaces that are registered as runtime PM callbacks.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Hao Yao <hao.yao@intel.com>
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ad5820: Drop unsupported ad5823 from i2c_ and of_device_id tables
Hans de Goede [Sun, 18 Jun 2023 18:17:40 +0000 (20:17 +0200)]
media: ad5820: Drop unsupported ad5823 from i2c_ and of_device_id tables

The supported ad5820 and ad5821 VCMs both use a single 16 bit register
which is written by sending 2 bytes with the data directly after sending
the i2c-client address.

The ad5823 OTOH has a more typical i2c / smbus device setup with multiple
8 bit registers where the first byte send after the i2c-client address is
the register address and the actual data only starts from the second byte
after the i2c-client address.

The ad5823 i2c_ and of_device_id-s was added at the same time as
the ad5821 ids with as rationale:

"""
Some camera modules also refer that AD5823 is a replacement of AD5820:
https://download.kamami.com/p564094-OV8865_DS.pdf
"""

The AD5823 may be an electrical and functional replacement of the AD5820,
but from a software pov it is not compatible at all and it is going to
need its own driver, drop its id from the ad5820 driver.

Fixes: b8bf73136bae ("media: ad5820: Add support for ad5821 and ad5823")
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Ricardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: i2c: imx290: drop format param from imx290_ctrl_update
Tommaso Merciai [Tue, 13 Jun 2023 08:07:34 +0000 (10:07 +0200)]
media: i2c: imx290: drop format param from imx290_ctrl_update

The format param actually is not used in imx290_ctrl_update
function, let's drop this

Fixes: bc35f9a21a55 ("media: i2c: imx290: Fix the pixel rate at 148.5Mpix/s")
Signed-off-by: Tommaso Merciai <tomm.merciai@gmail.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ov13b10: support new ACPI HID 'OVTI13B1'
Bingbu Cao [Fri, 26 May 2023 10:07:23 +0000 (12:07 +0200)]
media: ov13b10: support new ACPI HID 'OVTI13B1'

On ACPI systems, the HID of ov13b10 is 'OVTI13B1', add this new
HID in acpi IDs table to make driver support it.

Signed-off-by: Hao Yao <hao.yao@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: MAINTAINERS: Orphan the OV7740 driver
Nicolas Ferre [Mon, 22 May 2023 13:47:51 +0000 (15:47 +0200)]
media: MAINTAINERS: Orphan the OV7740 driver

Wenyou's email is bouncing, remove him from this camera driver's entry
and mark it as orphan.

Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ov13b10: Defer probe if no endpoint found
Bingbu Cao [Tue, 13 Jun 2023 04:55:43 +0000 (06:55 +0200)]
media: ov13b10: Defer probe if no endpoint found

The ov13b10 need be connected to a CIO2 or IPU device by bridge, sometimes
the bridge driver was not probed before ov13b10 driver, then the absence
of the fwnode endpoint for this device is expected, so driver return
-EPROBE_DEFER in this case to let the probe occur after bridge driver.

Signed-off-by: Hao Yao <hao.yao@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ov5640: fix low resolution image abnormal issue
Guoniu.zhou [Mon, 12 Jun 2023 02:43:40 +0000 (04:43 +0200)]
media: ov5640: fix low resolution image abnormal issue

OV5640 will output abnormal image data when work at low resolution
(320x240, 176x144 and 160x120) after switching from high resolution,
such as 1080P, the time interval between high and low switching must
be less than 1000ms in order to OV5640 don't enter suspend state during
the time.

The reason is by 0x3824 value don't restore to initialize value when
do resolution switching. In high resolution setting array, 0x3824 is
set to 0x04, but low resolution setting array remove 0x3824 in commit
db15c1957a2d ("media: ov5640: Remove duplicated mode settings"). So
when do resolution switching from high to low, such as 1080P to 320x240,
and the time interval is less than auto suspend delay time which means
global initialize setting array will not be loaded, the output image
data are abnormal. Hence move 0x3824 from ov5640_init_setting[] table
to ov5640_setting_low_res[] table and also move 0x4407 0x460b, 0x460c
to avoid same issue.

Fixes: db15c1957a2d ("media: ov5640: Remove duplicated mode settings")
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: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ov08x40: Fix hblank out of range issue
Jason Chen [Mon, 29 May 2023 11:10:41 +0000 (13:10 +0200)]
media: ov08x40: Fix hblank out of range issue

The HTS value cannot be directly compared to the sensor's output
size. It needs to be converted to an absolute time unit.
Additionally, the hblank value need to be modified as it was
previous invalid.

Signed-off-by: Jason Chen <jason.z.chen@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: i2c: Remove Shawn's and Chiranjeevi's e-mail addresses
Sakari Ailus [Fri, 9 Jun 2023 09:19:28 +0000 (11:19 +0200)]
media: i2c: Remove Shawn's and Chiranjeevi's e-mail addresses

Remove Shawn Tu's and Chiranjeevi Rapolu's e-mail addresses as they are no
longer function.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: MAINTAINERS: Pick ov5670 maintenance
Sakari Ailus [Thu, 8 Jun 2023 11:13:07 +0000 (13:13 +0200)]
media: MAINTAINERS: Pick ov5670 maintenance

Chiranjeevi's e-mail is bouncing:

   chiranjeevi.rapolu@intel.com
   DM3NAM02FT041.mail.protection.outlook.com
   Remote Server returned '550 5.4.1 Recipient address rejected: Access
   denied. AS(201806281)'

Assign the driver to myself.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: MAINTAINERS: Orphan dw9768 and ov02a10 drivers
Sakari Ailus [Thu, 8 Jun 2023 11:10:00 +0000 (13:10 +0200)]
media: MAINTAINERS: Orphan dw9768 and ov02a10 drivers

Dongchun's e-mail is no longer active and he hasn't given a new one:

The following message to <dongchun.zhu@mediatek.com> was
undeliverable.
The reason for the problem:
5.1.0 - Unknown address error 550-'Relaying mail to
dongchun.zhu@mediatek.com is not allowed'

Mark the drivers as orphaned.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: MAINTAINERS: Add an entry for V4L2 sensor and lens drivers
Sakari Ailus [Thu, 8 Jun 2023 09:35:22 +0000 (11:35 +0200)]
media: MAINTAINERS: Add an entry for V4L2 sensor and lens drivers

I maintain V4L2 sensor and lens drivers but there hasn't been a specific
MAINTAINERS entry for them. Add it now.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: MAINTAINERS: Assign Shawn Tu's sensor drivers to myself
Sakari Ailus [Thu, 8 Jun 2023 09:01:38 +0000 (11:01 +0200)]
media: MAINTAINERS: Assign Shawn Tu's sensor drivers to myself

Shawn Tu's e-mail address is bouncing:

   shawnx.tu@intel.com
   Remote Server returned '550 5.1.10 RESOLVER.ADR.RecipientNotFound;
   Recipient not found by SMTP address lookup'

Assign the sensor drivers Shawn maintained to myself.

Reported-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ipu3-cio2: rename ipu3-cio2-main.c back to ipu3-cio2.c
Bingbu Cao [Thu, 18 May 2023 10:05:23 +0000 (12:05 +0200)]
media: ipu3-cio2: rename ipu3-cio2-main.c back to ipu3-cio2.c

cio2 bridge driver is moved out of ipu3, current ipu3 cio2 driver only has
1 source file, then we can rename the source file back to ipu3-cio2.c.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ipu-bridge: use IPU_MAX_PORTS for bridge instead of CIO2_NUM_PORTS
Bingbu Cao [Thu, 18 May 2023 10:05:22 +0000 (12:05 +0200)]
media: ipu-bridge: use IPU_MAX_PORTS for bridge instead of CIO2_NUM_PORTS

Before bridge driver use CIO2_NUM_PORTS as the maximum supported CSI2 port
number. Current bridge driver is moved out of ipu3, so define a new macro
in ipu bridge for all IPUs instead of including CIO2 definition.
This patch also removes the ipu3-cio2.h inclusion in ipu-bridge.h.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: ipu3-cio2: rename cio2 bridge to ipu bridge and move out of ipu3
Bingbu Cao [Thu, 18 May 2023 10:05:21 +0000 (12:05 +0200)]
media: ipu3-cio2: rename cio2 bridge to ipu bridge and move out of ipu3

cio2 bridge was involved along with IPU3. However, in fact all Intel IPUs
besides IPU3 CIO2 need this bridge driver. This patch move bridge driver
out of ipu3 directory and rename as ipu-bridge. Then it can be worked with
IPU3 and other Intel IPUs.

Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: cadence: Add support for JH7110 SoC
Jack Zhu [Tue, 23 May 2023 08:56:26 +0000 (10:56 +0200)]
media: cadence: Add support for JH7110 SoC

Add support for Starfive JH7110 SoC which has the cadence csi2 receiver.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: cadence: Add support for external dphy
Jack Zhu [Tue, 23 May 2023 08:56:25 +0000 (10:56 +0200)]
media: cadence: Add support for external dphy

Add support for external MIPI D-PHY.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: cadence: Add operation on reset
Jack Zhu [Tue, 23 May 2023 08:56:24 +0000 (10:56 +0200)]
media: cadence: Add operation on reset

Add operation on reset for Cadence MIPI-CSI2 RX Controller.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: dt-bindings: cadence-csi2rx: Add resets property
Jack Zhu [Tue, 23 May 2023 08:56:23 +0000 (10:56 +0200)]
media: dt-bindings: cadence-csi2rx: Add resets property

Add resets property for Cadence MIPI-CSI2 RX controller

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
11 months agomedia: dt-bindings: cadence-csi2rx: Convert to DT schema
Jack Zhu [Tue, 23 May 2023 08:56:22 +0000 (10:56 +0200)]
media: dt-bindings: cadence-csi2rx: Convert to DT schema

Convert DT bindings document for Cadence MIPI-CSI2 RX controller to
DT schema format.

For compatible, new compatibles should not be messed with conversion,
but the original binding did not specify any SoC-specific compatible
string, so add the StarFive compatible string.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>