platform/kernel/linux-starfive.git
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>
2 years agomedia: amphion: return error if format is unsupported by vpu
Ming Qian [Thu, 9 Jun 2022 09:27:59 +0000 (10:27 +0100)]
media: amphion: return error if format is unsupported by vpu

return error if format is unsupported by vpu,
otherwise the vpu will be stalled at decoding

Fixes: 3cd084519c6f9 ("media: amphion: add vpu v4l2 m2m support")
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: staging: atomisp: fix typo in comment
Julia Lawall [Sat, 21 May 2022 11:11:05 +0000 (12:11 +0100)]
media: staging: atomisp: fix typo in comment

Spelling mistake (triple letters) in comment.
Detected with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: exynos4-is: fix typos in comments
Julia Lawall [Sat, 21 May 2022 11:10:51 +0000 (12:10 +0100)]
media: platform: exynos4-is: fix typos in comments

Spelling mistakes (triple letters) in comments.
Detected with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: mediatek: vcodec: fix typo in comment
Julia Lawall [Sat, 21 May 2022 11:10:40 +0000 (12:10 +0100)]
media: mediatek: vcodec: fix typo in comment

Spelling mistake (triple letters) in comment.
Detected with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: exynos-gsc: fix typo in comment
Julia Lawall [Sat, 21 May 2022 11:10:28 +0000 (12:10 +0100)]
media: platform: exynos-gsc: fix typo in comment

Spelling mistake (triple letters) in comment.
Detected with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: tw686x: Register the irq at the end of probe
Zheyu Ma [Sat, 21 May 2022 06:24:01 +0000 (07:24 +0100)]
media: tw686x: Register the irq at the end of probe

We got the following warning when booting the kernel:

[    3.243674] INFO: trying to register non-static key.
[    3.243922] The code is fine but needs lockdep annotation, or maybe
[    3.244230] you didn't initialize this object before use?
[    3.245642] Call Trace:
[    3.247836]  lock_acquire+0xff/0x2d0
[    3.248727]  tw686x_audio_irq+0x1a5/0xcc0 [tw686x]
[    3.249211]  tw686x_irq+0x1f9/0x480 [tw686x]

The lock 'vc->qlock' will be initialized in tw686x_video_init(), but the
driver registers the irq before calling the tw686x_video_init(), and we
got the warning.

Fix this by registering the irq at the end of probe

Fixes: 704a84ccdbf1 ("[media] media: Support Intersil/Techwell TW686x-based video capture cards")
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: tw5864: Convert to use managed functions pcim* and devm*
Zheyu Ma [Sat, 21 May 2022 05:55:17 +0000 (06:55 +0100)]
media: tw5864: Convert to use managed functions pcim* and devm*

When removing the module, we will get the follow flaw:

[   69.323999] remove_proc_entry: removing non-empty directory 'irq/21', leaking at least 'tw5864'
[   69.324449] WARNING: CPU: 0 PID: 395 at fs/proc/generic.c:717 remove_proc_entry+0x389/0x3f0
[   69.326909] RIP: 0010:remove_proc_entry+0x389/0x3f0
[   69.331089] Call Trace:
[   69.331215]  <TASK>
[   69.331327]  unregister_irq_proc+0x14c/0x170
[   69.332579]  tw5864_finidev+0x12a/0x190 [tw5864]
[   69.332811]  pci_device_remove+0x92/0x240

Fix this by using managed functions, this makes the error handling more
simpler.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
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 moli to the match table
Scott Chao [Fri, 20 May 2022 11:08:31 +0000 (12:08 +0100)]
media: platform: cros-ec: Add moli to the match table

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

Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: platform: omap: Pass a pointer to virt_to_page()
Linus Walleij [Thu, 19 May 2022 21:39:06 +0000 (22:39 +0100)]
media: platform: omap: Pass a pointer to virt_to_page()

A pointer into virtual memory is represented by a (void *)
not an u32, so the compiler warns:

drivers/media/platform/ti/omap/omap_voutlib.c:317:54: warning:
  passing argument 1 of 'virt_to_pfn' makes pointer from integer
  without a cast [-Wint-conversion]

Fix this with an explicit cast.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: Archit Taneja <architt@codeaurora.org>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: amphion: vdec check format in enum_fmt
Ming Qian [Thu, 19 May 2022 08:43:46 +0000 (09:43 +0100)]
media: amphion: vdec check format in enum_fmt

vdec check the pixel format is supported by vpu,
or is it disabled.
And don't report it if the result is false

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: camss: Allocate camss struct as a managed device resource
Vladimir Zapolskiy [Thu, 19 May 2022 05:14:15 +0000 (06:14 +0100)]
media: camss: Allocate camss struct as a managed device resource

The change simplifies driver's probe and remove functions, no functional
change is intended.

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>
2 years agomedia: hantro: Be more accurate on pixel formats step_width constraints
Benjamin Gaignard [Wed, 18 May 2022 08:53:49 +0000 (09:53 +0100)]
media: hantro: Be more accurate on pixel formats step_width constraints

On Hantro G2 decoder on IMX8MQ strides requirements aren't the same
for NV12_4L4 and NV12 pixel formats. The first one use a 4 bytes padding
while the last one needs 16 bytes.
To be sure to provide the correct stride in all cases we need:
- to relax the constraints on codec formats so set step_width to 4
- use capture queue format and not the output queue format when applying
  the pixel format constraints.
- put the correct step_width constraints on each pixel format.

Move HEVC SPS validation in hantro_hevc.c to be able to perform it
when setting sps control and when starting to decode the bitstream.
Add a new test in HEVC SPS validation function to check if resolution
is still matching the hardware constraints.

With this SAODBLK_A_MainConcept_4 and SAODBLK_B_MainConcept_4 conformance
tests files are correctly decoded with both NV12 and NV12_4L4 pixel
formats. These two files have a resolution of 1016x760.

Add defines for the various used resolutions.
For other variants than Hantro G2 on IMX8M keep the same step_width to
avoid regressions.

Fluster HEVC test score is now 128/147 vs 126/147 with the both pixel
formats as decoder output.
Fluster VP9 test score stay at 147/303.

[hverkuil: fix trivial checkpatch warnings]

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: airspy: respect the DMA coherency rules
Oliver Neukum [Wed, 18 May 2022 08:10:45 +0000 (09:10 +0100)]
media: airspy: respect the DMA coherency rules

If we want to avoid memory corruption
on incoherent architectures, buffers for DMA
must not reside
- on the stack
- embedded within other structures

Allocate them separately.

v2: fix uninitialized return value

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: media: jpegenc: set bit mask for jpegenc
kyrie wu [Wed, 8 Jun 2022 06:07:55 +0000 (07:07 +0100)]
media: media: jpegenc: set bit mask for jpegenc

set jpeg encode DMA bit mask to support 34bits
iova space(16GB) that the mt8186 iommu HW support.
Whole the iova range separate to 0~4G/4G~8G/8G~12G/12G~16G,
regarding which iova range jpgenc actually locate, it
depends on the dma-ranges property of vdec dtsi node.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: media: jpegenc: add mediatek,mt8186-jpgenc compatible
kyrie wu [Wed, 8 Jun 2022 06:07:54 +0000 (07:07 +0100)]
media: media: jpegenc: add mediatek,mt8186-jpgenc compatible

Add mediatek,mt8186-jpgenc compatible to binding document.

MT8186 iommu support 0~16GB iova. We separate it to four banks:
0~4G; 4G~8G; 8G~12G; 12G~16G.

The "dma-ranges" could be used to adjust the bank we locate.
If we don't set this property. The default range always is 0~4G.

Signed-off-by: kyrie wu <kyrie.wu@mediatek.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: rc: Directly use ida_free()
keliu [Fri, 27 May 2022 10:30:17 +0000 (11:30 +0100)]
media: rc: Directly use ida_free()

Use ida_alloc() and ida_free() instead of the deprecated
ida_simple_get() and ida_simple_remove().

Signed-off-by: keliu <liuke94@huawei.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2 years agomedia: ttusbir: avoid unnecessary usb_unlink_urb()
Oliver Neukum [Thu, 12 May 2022 13:41:41 +0000 (14:41 +0100)]
media: ttusbir: avoid unnecessary usb_unlink_urb()

While the completion handler is running,
usb_unlink_urb() on yourself is a NOP. Remove it.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>