Stanimir Varbanov [Mon, 17 Aug 2020 14:28:20 +0000 (16:28 +0200)]
media: venus: Delete not used core caps
The core caps are filled but not used, delete them. In case we
need them we can re-introduce.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Stanimir Varbanov [Wed, 11 Nov 2020 14:37:52 +0000 (15:37 +0100)]
media: venus: pm_helpers: Check instance state when calculate instance frequency
Skip calculating instance frequency if it is not in running state.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Stanimir Varbanov [Wed, 11 Nov 2020 14:37:51 +0000 (15:37 +0100)]
media: venus: helpers: Calculate properly compressed buffer size
For resolutions below 720p the size of the compressed buffer must
be bigger. Correct this by checking the resolution when calculating
buffer size and multiply by eight.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Stanimir Varbanov [Fri, 4 Dec 2020 10:01:39 +0000 (11:01 +0100)]
media: venus: hfi: Correct session init return error
The hfi_session_init can be called many times and it returns
EINVAL when the session was already initialized. This error code
(EINVAL) is confusing for the callers. Change hfi_session_init to
return EALREADY error code when the session has been already
initialized.
Tested-by: Fritz Koenig <frkoenig@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Vikash Garodia [Fri, 4 Dec 2020 10:01:38 +0000 (11:01 +0100)]
media: venus: request for interrupt from venus
For synchronous commands, update the message queue variable.
This would inform video firmware to raise interrupt on host
CPU whenever there is a response for such commands.
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
Tested-by: Fritz Koenig <frkoenig@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Stanimir Varbanov [Fri, 4 Dec 2020 10:01:37 +0000 (11:01 +0100)]
media: venus: Limit HFI sessions to the maximum supported
Currently we rely on firmware to return error when we reach the maximum
supported number of sessions. But this errors are happened at reqbuf
time which is a bit later. The more reasonable way looks like is to
return the error on driver open.
To achieve that modify hfi_session_create to return error when we reach
maximum count of sessions and thus refuse open.
Tested-by: Fritz Koenig <frkoenig@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Stanimir Varbanov [Fri, 4 Dec 2020 10:01:36 +0000 (11:01 +0100)]
media: venus: venc: Init the session only once in queue_setup
Init the hfi session only once in queue_setup and also cover that
with inst->lock.
Tested-by: Fritz Koenig <frkoenig@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fritz Koenig [Tue, 1 Dec 2020 04:23:23 +0000 (05:23 +0100)]
media: venus: vdec: Handle DRC after drain
If the DRC is near the end of the stream the client
may send a V4L2_DEC_CMD_STOP before the DRC occurs.
V4L2_DEC_CMD_STOP puts the driver into the
VENUS_DEC_STATE_DRAIN state. DRC must be aware so
that after the DRC event the state can be restored
correctly.
Signed-off-by: Fritz Koenig <frkoenig@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Alexandre Courbot [Wed, 2 Dec 2020 05:34:24 +0000 (06:34 +0100)]
media: venus: preserve DRC state across seeks
DRC events can happen virtually at anytime, including when we are
starting a seek. Should this happen, we must make sure to return to the
DRC state, otherwise the firmware will expect buffers of the new
resolution whereas userspace will still work with the old one.
Returning to the DRC state upon resume for seeking makes sure that the
client will get the DRC event and will reallocate the buffers to fit the
firmware's expectations.
Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Stanimir Varbanov [Mon, 28 Sep 2020 16:44:31 +0000 (18:44 +0200)]
media: venus: helpers: Lock outside of buffer queue helper
After adding more logic in vdec buf_queue vb2 op it is not
practical to have two lock/unlock for one decoder buf_queue.
So move the instance lock in encoder and decoder vb2 buf_queue
operations.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Stanimir Varbanov [Mon, 28 Sep 2020 16:44:30 +0000 (18:44 +0200)]
media: venus: vdec: Make decoder return LAST flag for sufficient event
This makes the decoder to behaives equally for sufficient and
insufficient events. After this change the LAST buffer flag will be set
when the new resolution (in dynamic-resolution-change state) is smaller
then the old bitstream resolution.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Stanimir Varbanov [Mon, 28 Sep 2020 16:44:29 +0000 (18:44 +0200)]
media: venus: vdec: Fix non reliable setting of LAST flag
In real use of dynamic-resolution-change it is observed that the
LAST buffer flag (which marks the last decoded buffer with the
resolution before the resolution-change event) is not reliably set.
Fix this by set the LAST buffer flag on next queued capture buffer
after the resolution-change event.
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Alexandre Courbot [Mon, 14 Dec 2020 12:57:03 +0000 (13:57 +0100)]
media: venus: use contig vb2 ops
This driver uses the SG vb2 ops, but effectively only ever accesses the
first entry of the SG table, indicating that it expects a flat layout.
Switch it to use the contiguous ops to make sure this expected invariant
is always enforced. Since the device is supposed to be behind an IOMMU
this should have little to none practical consequences beyond making the
driver not rely on a particular behavior of the SG implementation.
Reported-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Zhang Changzhong [Fri, 4 Dec 2020 08:27:58 +0000 (09:27 +0100)]
media: aspeed: fix error return code in aspeed_video_setup_video()
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.
Fixes:
d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Matwey V. Kornilov [Mon, 4 Jan 2021 17:00:07 +0000 (18:00 +0100)]
media: pwc: Use correct device for DMA
This fixes the following newly introduced warning:
[ 15.518253] ------------[ cut here ]------------
[ 15.518941] WARNING: CPU: 0 PID: 246 at kernel/dma/mapping.c:149 dma_map_page_attrs+0x1a8/0x1d0
[ 15.520634] Modules linked in: pwc videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common videodev mc efivarfs
[ 15.522335] CPU: 0 PID: 246 Comm: v4l2-test Not tainted 5.11.0-rc1+ #1
[ 15.523281] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
[ 15.524438] RIP: 0010:dma_map_page_attrs+0x1a8/0x1d0
[ 15.525135] Code: 10 5b 5d 41 5c 41 5d c3 4d 89 d0 eb d7 4d 89 c8 89 e9 48 89 da e8 68 29 00 00 eb d1 48 89 f2 48 2b 50 18 48 89 d0 eb 83 0f 0b <0f> 0b 48 c7 c0 ff ff ff ff eb b8 48 89 d9 48 8b 40 40 e8 61 69 d2
[ 15.527938] RSP: 0018:
ffffa2694047bca8 EFLAGS:
00010246
[ 15.528716] RAX:
0000000000000000 RBX:
0000000000002580 RCX:
0000000000000000
[ 15.529782] RDX:
0000000000000000 RSI:
ffffcdce000ecc00 RDI:
ffffa0b4bdb888a0
[ 15.530849] RBP:
0000000000000002 R08:
0000000000000002 R09:
0000000000000000
[ 15.531881] R10:
0000000000000004 R11:
000000000002d8c0 R12:
0000000000000000
[ 15.532911] R13:
ffffa0b4bdb88800 R14:
ffffa0b483820000 R15:
ffffa0b4bdb888a0
[ 15.533942] FS:
00007fc5fbb5e4c0(0000) GS:
ffffa0b4fc000000(0000) knlGS:
0000000000000000
[ 15.535141] CS: 0010 DS: 0000 ES: 0000 CR0:
0000000080050033
[ 15.535988] CR2:
00007fc5fb6ea138 CR3:
0000000003812000 CR4:
00000000001506f0
[ 15.537025] Call Trace:
[ 15.537425] start_streaming+0x2e9/0x4b0 [pwc]
[ 15.538143] vb2_start_streaming+0x5e/0x110 [videobuf2_common]
[ 15.538989] vb2_core_streamon+0x107/0x140 [videobuf2_common]
[ 15.539831] __video_do_ioctl+0x18f/0x4a0 [videodev]
[ 15.540670] video_usercopy+0x13a/0x5b0 [videodev]
[ 15.541349] ? video_put_user+0x230/0x230 [videodev]
[ 15.542096] ? selinux_file_ioctl+0x143/0x200
[ 15.542752] v4l2_ioctl+0x40/0x50 [videodev]
[ 15.543360] __x64_sys_ioctl+0x89/0xc0
[ 15.543930] do_syscall_64+0x33/0x40
[ 15.544448] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 15.545236] RIP: 0033:0x7fc5fb671587
[ 15.545780] Code: b3 66 90 48 8b 05 11 49 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d e1 48 2c 00 f7 d8 64 89 01 48
[ 15.548486] RSP: 002b:
00007fff0f71f038 EFLAGS:
00000246 ORIG_RAX:
0000000000000010
[ 15.549578] RAX:
ffffffffffffffda RBX:
0000000000000003 RCX:
00007fc5fb671587
[ 15.550664] RDX:
00007fff0f71f060 RSI:
0000000040045612 RDI:
0000000000000003
[ 15.551706] RBP:
0000000000000000 R08:
0000000000000000 R09:
0000000000000000
[ 15.552738] R10:
0000000000000000 R11:
0000000000000246 R12:
00007fff0f71f060
[ 15.553817] R13:
00007fff0f71f1d0 R14:
0000000000de1270 R15:
0000000000000000
[ 15.554914] ---[ end trace
7be03122966c2486 ]---
Fixes:
1161db6776bd ("media: usb: pwc: Don't use coherent DMA buffers for ISO transfer")
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dinghao Liu [Sat, 2 Jan 2021 08:26:37 +0000 (09:26 +0100)]
media: tm6000: Fix memleak in tm6000_start_stream
When usb_clear_halt() fails, dvb->bulk_urb->transfer_buffer
and dvb->bulk_urb should be freed just like when
usb_submit_urb() fails.
Fixes:
3169c9b26fffa ("V4L/DVB (12788): tm6000: Add initial DVB-T support")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dinghao Liu [Sat, 2 Jan 2021 06:27:22 +0000 (07:27 +0100)]
media: media/pci: Fix memleak in empress_init
When vb2_queue_init() fails, dev->empress_dev
should be released just like other error handling
paths.
Fixes:
2ada815fc48bb ("[media] saa7134: convert to vb2")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Zheng Yongjun [Mon, 28 Dec 2020 13:51:04 +0000 (14:51 +0100)]
media: platform: davinci: Use DEFINE_SPINLOCK() for spinlock
spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Reviewed-by: Lad Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dinghao Liu [Mon, 28 Dec 2020 13:02:05 +0000 (14:02 +0100)]
media: em28xx: Fix use-after-free in em28xx_alloc_urbs
When kzalloc() fails, em28xx_uninit_usb_xfer() will free
usb_bufs->buf and set it to NULL. Thus the later access
to usb_bufs->buf[i] will lead to null pointer dereference.
Also the kfree(usb_bufs->buf) after that is redundant.
Fixes:
d571b592c6206 ("media: em28xx: don't use coherent buffer for DMA transfers")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Nigel Christian [Fri, 18 Dec 2020 06:31:17 +0000 (07:31 +0100)]
media: cec: fix trivial style warnings
Comment has 'then' repeated twice. Let's clean it up.
Use unsigned int to maintain naming consistency.
Signed-off-by: Nigel Christian <nigel.l.christian@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Kieran Bingham [Wed, 16 Dec 2020 11:45:48 +0000 (12:45 +0100)]
media: vsp1: Use BIT macro for feature identification
These entries can only ever be single bits. Make use of the BIT macro
accordingly.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Christophe JAILLET [Sat, 12 Dec 2020 17:41:19 +0000 (18:41 +0100)]
media: vsp1: Fix an error handling path in the probe function
A previous 'rcar_fcp_get()' call must be undone in the error handling path,
as already done in the remove function.
Fixes:
94fcdf829793 ("[media] v4l: vsp1: Add FCP support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sebastian Fricke [Sat, 12 Dec 2020 18:53:06 +0000 (19:53 +0100)]
media: rkisp1: isp: Add the enum_frame_size ioctl
Implement the VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl for the isp entity,
check if the mbus code is valid for the given pad.
This call is not available for the parameter or metadata pads of the
RkISP1.
Signed-off-by: Sebastian Fricke <sebastian.fricke.linux@gmail.com>
Acked-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Geert Uytterhoeven [Fri, 11 Dec 2020 13:38:06 +0000 (14:38 +0100)]
media: sh_vou: Drop bogus __refdata annotation
Since commit
4c62e9764ab403d4 ("Drivers: media: remove __dev*
attributes.") in v3.8, the SuperH Video Output Unit driver no longer has
any code or data located in initmem, hence there is no need to annotate
the sh_vou structure with __refdata. Drop the annotation, to avoid
suppressing future section warnings.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Lukas Bulwahn [Wed, 9 Dec 2020 07:46:58 +0000 (08:46 +0100)]
media: MAINTAINERS: correct entry in Amlogic GE2D driver section
Commit
aa821b2b9269 ("media: MAINTAINERS: Add myself as maintainer of the
Amlogic GE2D driver") introduced a new MAINTAINERS section, but the file
entry points to the wrong location.
Hence, ./scripts/get_maintainer.pl --self-test=patterns warns:
warning: no file matches F: drivers/media/meson/ge2d/
Adjust the entry to the actual location of the driver.
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dan Carpenter [Wed, 9 Dec 2020 06:51:30 +0000 (07:51 +0100)]
media: camss: missing error code in msm_video_register()
This error path returns success but it should return -EINVAL.
Fixes:
cba3819d1e93 ("media: camss: Format configuration per hardware version")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dan Carpenter [Wed, 9 Dec 2020 06:50:34 +0000 (07:50 +0100)]
media: camss: Fix signedness bug in video_enum_fmt()
This test has a problem because we want to know if "k" is -1 or a
positive value less than "f->index". But the "f->index" variable is a
u32 so if "k == -1" then -1 gets type promoted to UINT_MAX which is
larger than "f->index". I've added an explicit test to check for -1.
Fixes:
a3d412d4b9f3 ("media: Revert "media: camss: Make use of V4L2_CAP_IO_MC"")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Reviewed-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Travis Carter [Fri, 4 Dec 2020 23:37:43 +0000 (00:37 +0100)]
media: staging:rkvdec: Fixed "replace comma with semicolon" Warning
Corrected the following Warning:
drivers/staging/media/rkvdec/rkvdec.c:133: WARNING: Possible comma where semicolon could be used
Signed-off-by: Travis Carter <traviscarter2@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Travis Carter [Fri, 4 Dec 2020 23:51:50 +0000 (00:51 +0100)]
media: staging:hantro: Fixed "replace comma with semicolon" Warning
Corrected the following Warning:
drivers/staging/media/hantro/hantro_v4l2.c:319: WARNING: Possible comma where semicolon could be used
Signed-off-by: Travis Carter <traviscarter2@gmail.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Zhang Changzhong [Fri, 4 Dec 2020 08:29:34 +0000 (09:29 +0100)]
media: mtk-vcodec: fix error return code in vdec_vp9_decode()
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.
Fixes:
dea42fb79f4f ("media: mtk-vcodec: reset segment data then trig decoder")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Arnd Bergmann [Thu, 3 Dec 2020 23:07:30 +0000 (00:07 +0100)]
media: ti-vpe: cal: avoid FIELD_GET assertion
FIELD_GET() must only be used with a mask that is a compile-time
constant:
drivers/media/platform/ti-vpe/cal.h: In function 'cal_read_field':
include/linux/compiler_types.h:320:38: error: call to '__compiletime_assert_247' declared with attribute error: FIELD_GET: mask is not constant
include/linux/bitfield.h:46:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
46 | BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \
| ^~~~~~~~~~~~~~~~
drivers/media/platform/ti-vpe/cal.h:220:9: note: in expansion of macro 'FIELD_GET'
220 | return FIELD_GET(mask, cal_read(cal, offset));
| ^~~~~~~~~
The problem here is that the function is not always inlined. Mark it
__always_inline to avoid the problem.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Enrico Weigelt [Thu, 3 Dec 2020 12:47:57 +0000 (13:47 +0100)]
media: drivers: staging: media: remove unneeded MODULE_VERSION() call
Remove MODULE_VERSION(), as it doesn't seem to serve any practical purpose.
For in-tree drivers, the kernel version matters. The code received lots of
changes, but module version remained constant, since the driver landed in
mainline. So, this version doesn't seem have any practical meaning anymore.
Signed-off-by: Enrico Weigelt <info@metux.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Ezequiel Garcia [Mon, 4 Jan 2021 20:34:41 +0000 (21:34 +0100)]
media: imx: Clean capture unregister
No locking is needed to call video_unregister_device(). Drop it.
Also, drop the superfluous video_is_registered() call, which is
done by video_unregister_device(), and re-order media_entity_cleanup()
and video_unregister_device() calls.
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Ezequiel Garcia [Mon, 4 Jan 2021 20:34:40 +0000 (21:34 +0100)]
media: imx: Fix csc/scaler unregister
The csc/scaler device private struct is released by
ipu_csc_scaler_video_device_release(), which can be called
by video_unregister_device() if there are no users
of the underlying struct video device.
Therefore, the mutex can't be held when calling
video_unregister_device() as its memory may be freed
by it, leading to a kernel oops.
Fortunately, the fix is quite simple as no locking
is needed when calling video_unregister_device(): v4l2-core
already has its own internal locking, and the structures
are also properly refcounted.
Fixes:
a8ef0488cc59 ("media: imx: add csc/scaler mem2mem device")
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Ezequiel Garcia [Mon, 4 Jan 2021 20:34:39 +0000 (21:34 +0100)]
media: imx: Unregister csc/scaler only if registered
The csc/scaler device pointer (imxmd->m2m_vdev) is assigned
after the imx media device v4l2-async probe completes,
therefore we need to check if the device is non-NULL
before trying to unregister it.
This can be the case if the non-completed imx media device
is unbinded (or the driver is removed), leading to a kernel oops.
Fixes:
a8ef0488cc59 ("media: imx: add csc/scaler mem2mem device")
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Martin Kepplinger [Wed, 2 Dec 2020 13:12:51 +0000 (14:12 +0100)]
media: staging: media: imx: Kconfig: support VIDEO_IMX7_CSI for imx8m
As described in NXPs' linux tree, the imx8m SoC includes the same
CSI bridge hardware that is part of imx7d. We should be able to
use the "fsl,imx7-csi" driver for imx8m directly.
Since ipuv3 is not relevant for imx8m, move that dependency to
VIDEO_IMX_CSI. That makes VIDEO_IMX7_CSI available to support imx8m
too.
Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Fri, 11 Dec 2020 11:30:09 +0000 (12:30 +0100)]
media: ccs: Small definition cleanup
struct device is used in ccs-data.h but no definition is included. Add a
forward definition.
Also ccs-data.c includes linux/types.h but this is already included in
ccs-data.h which ccs-data.c includes. Do don't include linux/types.h in
ccs-data.c.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Mon, 7 Dec 2020 16:34:57 +0000 (17:34 +0100)]
media: Revert "media: ccs-pll: Fix MODULE_LICENSE"
This reverts commit
b3c0115e34adcabe12fce8845e24ca6f04c1554e.
As per Documentation/process/license-rules.rst "GPL v2" exists only for
historical reasons and has the same meaning as "GPL". So revert this
patch.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 26 Nov 2020 20:02:54 +0000 (21:02 +0100)]
media: ccs: Switch from standard integer types to kernel ones
The preferred integer types in the kernel are the Linux specific ones,
switch from standard C types to u32 and alike.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 26 Nov 2020 20:01:54 +0000 (21:01 +0100)]
media: ccs-pll: Switch from standard integer types to kernel ones
The preferred integer types in the kernel are the Linux specific ones,
switch from standard C types to u32 and alike.
The patch has been produced with the following Coccinelle spatch, with few
alignment adjustments:
@@
typedef uint32_t;
typedef u32;
@@
- uint32_t
+ u32
@@
typedef uint16_t;
typedef u16;
@@
- uint16_t
+ u16
@@
typedef uint8_t;
typedef u8;
@@
- uint8_t
+ u8
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Mon, 16 Nov 2020 17:25:12 +0000 (18:25 +0100)]
media: Documentation: Include CCS PLL calculator to CCS driver documentation
Include existing CCS PLL calculator kerneldoc documentation to the
documentation build.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Fri, 9 Oct 2020 10:57:06 +0000 (12:57 +0200)]
media: ccs: Support and default to auto PHY control
CCS supports three variants of PHY timing control, auto, UI based and
manual. The driver previously assumed UI based control that requires
updating the link rate to the sensor. Now default to automatic control
instead, and only write the link rate to the sensor in UI mode.
If neither auto or UI control is supported, return an error in probe.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 8 Oct 2020 16:43:56 +0000 (18:43 +0200)]
media: ccs: Add a sanity check for external clock frequency
The driver depends on the external clock frequency. Add a sanity check for
the frequency, by returning an error from probe if it's zero.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 8 Oct 2020 16:24:39 +0000 (18:24 +0200)]
media: ccs: Hardware requires a delay after starting the clock of lifting reset
A CCS compliant device requires a delay before the first I²C transaction
after pulling xshutdown up or starting the external clock. This is what
the driver does. However, if neither is actually there, there's no need
for the delay.
This also has the effect of removing an unnecessary delay on ACPI systems
where ACPI is responsible for the power-up sequence.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 8 Oct 2020 10:09:07 +0000 (12:09 +0200)]
media: ccs: Wait until software reset is done
Verify the software reset has been completed until proceeding.
The spec does not guarantee a delay but presumably 100 ms should be
enough.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 8 Oct 2020 08:59:26 +0000 (10:59 +0200)]
media: ccs: Only do software reset if we have no hardware reset
The driver always used software reset after the sensor's power sequence
that includes a hardware reset if we have a reset GPIO. Do not use
software reset if we just brought the sensor up from hardware reset state.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 8 Oct 2020 08:56:48 +0000 (10:56 +0200)]
media: ccs: Don't change the I²C address just for software reset
The sensor's address was changed before resetting and changing the
address again. Don't do it before reset as it's useless.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Wed, 7 Oct 2020 11:09:19 +0000 (13:09 +0200)]
media: ccs: Get the endpoint by port rather than any next endpoint
Get the first endpoint from port 0 instead of the next one, whatever it
might be. There are no other ports so there's no functional change.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Fri, 25 Sep 2020 08:30:32 +0000 (10:30 +0200)]
media: ccs: Add shading correction and luminance correction level controls
Add controls for supporting lens shading correction, including colour
shading and luminance correction level.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Fri, 25 Sep 2020 08:28:56 +0000 (10:28 +0200)]
media: v4l: uapi: ccs: Add CCS controls for shading correction
Add V4L2 controls for controlling CCS lens shading correction as well as
conveying its capabilities.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 24 Sep 2020 21:34:27 +0000 (23:34 +0200)]
media: ccs: Add debug prints for MSR registers
Also print out MSR registers written to the sensor. This isn't entirely
optimal as the debug strings are produced even if they're not used but
that isn't really a grave issue --- the I²C bus is very slow anyway.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Wed, 23 Sep 2020 22:55:00 +0000 (00:55 +0200)]
media: ccs: Add support for alternate analogue global gain
The CCS spec defines an alternative implementation for global analogue
gain. Add support for that in the driver.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 24 Sep 2020 19:57:52 +0000 (21:57 +0200)]
media: v4l: uapi: ccs: Add controls for CCS alternative analogue gain
Add two new controls for alternative analogue gain some CCS compliant
camera sensors support.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Wed, 23 Sep 2020 22:38:07 +0000 (00:38 +0200)]
media: ccs: Add support for analogue gain coefficient controls
Add four controls for reading CCS analogue gain coefficients. The
values are constants that are device specific.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Wed, 23 Sep 2020 22:21:32 +0000 (00:21 +0200)]
media: v4l: uapi: ccs: Add controls for analogue gain constants
Add V4L2 controls for analogue gain constants required to control
analogue gain. The values are device specific and thus need to be obtained
from the driver.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Fri, 13 Nov 2020 16:12:28 +0000 (17:12 +0100)]
media: Documentation: ccs: Add user documentation for the CCS driver
Add user documentation for the CCS driver. This includes e.g. sub-devices
implemented by the driver.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 24 Sep 2020 19:44:13 +0000 (21:44 +0200)]
media: v4l: uapi: Add user control base for CCS controls
Add a control base for CCS controls, and reserve 128 controls. Luckily
these numbers are cheap.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Wed, 23 Sep 2020 22:43:55 +0000 (00:43 +0200)]
media: ccs: Only add analogue gain control if the device supports it
Some devices do not implement analogue gain this way. Only add the control
when a device does have the support.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Wed, 23 Sep 2020 22:40:45 +0000 (00:40 +0200)]
media: ccs: Remove analogue gain field
The analogue gain control was stored to the device specific struct but was
never used. Remove it.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Wed, 23 Sep 2020 14:38:24 +0000 (16:38 +0200)]
media: ccs: Add support for old-style SMIA digital gain
SMIA only has per-component digital gain. Add support for it.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Wed, 23 Sep 2020 14:26:33 +0000 (16:26 +0200)]
media: ccs: Add digital gain support
CCS supports global (all-component) digital gain. Add support for it.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Ezequiel Garcia [Sat, 2 Jan 2021 13:29:39 +0000 (14:29 +0100)]
media: mt9v111: Remove unneeded device-managed puts
Drivers don't need to explicitly call devm_{}_put on driver
removal, as it's automatically called by the device driver
resource management code.
Fixes:
aab7ed1c3927 ("media: i2c: Add driver for Aptina MT9V111")
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Paul Kocialkowski [Thu, 31 Dec 2020 14:27:01 +0000 (15:27 +0100)]
media: i2c: Add support for the OV8865 image sensor
The OV8865 is a 8 Mpx CMOS image sensor producing 3264x2448 at 30 fps.
Other modes (including some with sub-sampling) are available too.
It outputs 10-bit bayer CFA data through a MIPI CSI-2 interface with
up to 4 lanes supported.
Some register initialisation sequences are still needed for this driver,
as they cover registers for which no documentation is available.
This work is based on the first version of the driver submitted by
Kévin L'hôpital, which was adapted to mainline from the Allwinner BSP.
This version is a rewrite of the first version that matches the structure
of the OV5648 driver, with explicit PLL configuration, all the necessary
mode-specific fields, associatied registers and reduced static sequences.
It was tested with the Banana Pi Camera Board v3 and the Banana Pi M3.
Co-developed-by: Kévin L'hôpital <kevin.lhopital@bootlin.com>
Signed-off-by: Kévin L'hôpital <kevin.lhopital@bootlin.com>
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Paul Kocialkowski [Thu, 31 Dec 2020 14:27:00 +0000 (15:27 +0100)]
media: dt-bindings: media: i2c: Add OV8865 bindings documentation
This introduces YAML bindings documentation for the OV8865
image sensor.
Co-developed-by: Kévin L'hôpital <kevin.lhopital@bootlin.com>
Signed-off-by: Kévin L'hôpital <kevin.lhopital@bootlin.com>
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.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+huawei@kernel.org>
Paul Kocialkowski [Thu, 31 Dec 2020 14:23:57 +0000 (15:23 +0100)]
media: i2c: Add support for the OV5648 image sensor
The OV5648 is a 5 Mpx CMOS image sensor, connected via MIPI CSI-2
in a one or two lane configuration.
Most of the features of the hardware are supported, including:
- Auto and manual exposition/gain
- Auto and manual white balance
- Horizontal and vertical flip
- Test patterns
But the following are still missing:
- Debanding, based on power source frequency;
- Exposition setting correlated to time units.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Paul Kocialkowski [Thu, 31 Dec 2020 14:23:56 +0000 (15:23 +0100)]
media: dt-bindings: media: i2c: Add OV5648 bindings documentation
This introduces YAML bindings documentation for the OV5648
image sensor.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.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+huawei@kernel.org>
Pavel Machek [Wed, 30 Dec 2020 12:55:50 +0000 (13:55 +0100)]
media: ipu3-cio2: Fix mbus_code processing in cio2_subdev_set_fmt()
Loop was useless as it would always exit on the first iteration. Fix
it with right condition.
Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
Fixes:
a86cf9b29e8b ("media: ipu3-cio2: Validate mbus format in setting subdev format")
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: stable@vger.kernel.org # v4.16 and up
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Mon, 21 Dec 2020 17:52:20 +0000 (18:52 +0100)]
media: i2c: ov5670: Fix PIXEL_RATE minimum value
The driver currently reports a single supported value for
V4L2_CID_PIXEL_RATE and initializes the control's minimum value to 0,
which is very risky, as userspace might accidentally use it as divider
when calculating the time duration of a line.
Fix this by using as minimum the only supported value when registering
the control.
Fixes:
5de35c9b8dcd1 ("media: i2c: Add Omnivision OV5670 5M sensor support")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Fri, 11 Dec 2020 17:56:04 +0000 (18:56 +0100)]
media: Documentation: media: Document clock handling in camera sensor drivers
Document pratices of handling clocks in camera sensor drivers on both DT
and ACPI.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Andy Shevchenko [Mon, 14 Dec 2020 15:28:32 +0000 (16:28 +0100)]
media: ipu3-cio2: Build only for x86
According to the original code in the driver it was never assumed to work
with big page sizes: unsigned short type followed by PAGE_SHIFT and
PAGE_MASK which may be different on non-x86 architectures.
Recently LKP found an issue on non-x86 architectures due to above
mentioned limitations. Since Sakari acknowledges that it's not really
useful to be able to compile this elsewhere, mark it x86 only.
Fixes:
a31d19f88932 ("media: ipu3: allow building it with COMPILE_TEST on non-x86 archs")
Reported-by: kernel test robot <lkp@intel.com>
Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-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+huawei@kernel.org>
Sakari Ailus [Sun, 20 Dec 2020 20:17:17 +0000 (21:17 +0100)]
media: v4l: ioctl: Use kmalloc to allocate a small chunk of memory
kvmalloc() was used to allocate the temporary memory buffer that was used
to contain both the IOCTL argument as well as a possible array argument
that could have been large. Now that the two are separated, the IOCTL
argument is known to be small in size. Use kmalloc to allocate it instead
of kvmalloc. Similarly for releasing it.
Suggested-by: Arnd Bergmann <arnd@kernel.org>
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+huawei@kernel.org>
Sakari Ailus [Sat, 19 Dec 2020 22:29:58 +0000 (23:29 +0100)]
media: v4l: ioctl: Fix memory leak in video_usercopy
When an IOCTL with argument size larger than 128 that also used array
arguments were handled, two memory allocations were made but alas, only
the latter one of them was released. This happened because there was only
a single local variable to hold such a temporary allocation.
Fix this by adding separate variables to hold the pointers to the
temporary allocations.
Reported-by: Arnd Bergmann <arnd@kernel.org>
Reported-by: syzbot+1115e79c8df6472c612b@syzkaller.appspotmail.com
Fixes:
d14e6d76ebf7 ("[media] v4l: Add multi-planar ioctl handling code")
Cc: stable@vger.kernel.org
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Thu, 17 Dec 2020 18:27:08 +0000 (19:27 +0100)]
media: uapi: Add an entity type for Image Signal Processors
Add and document a media entity type for Image Signal Processor devices.
Surprisingly we didn't have one, so add one now. More or less all ISP
drivers should use this type instead of what they currently are using (or
not using anything).
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+huawei@kernel.org>
Sakari Ailus [Mon, 14 Dec 2020 21:31:21 +0000 (22:31 +0100)]
media: v4l: fwnode: v4l2_async_notifier_parse_fwnode_endpoints is deprecated
Document that v4l2_async_notifier_parse_fwnode_endpoints() is deprecated.
Its functionality has been replaced by other, better functions. Also add a
reference to an example if someone ends up wandering here.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Sakari Ailus [Fri, 11 Dec 2020 22:15:04 +0000 (23:15 +0100)]
media: Documentation: media: Update pixel rate formula for C-PHY
Update the formula to calculate the pixel rate on the link for C-PHY.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:37:53 +0000 (17:37 +0100)]
media: ov5647: Remove 640x480 SBGGR8 mode
Capturing in 640x480 SBGGR8_1X8 hangs the system when capturing
with the unicam driver on RaspberryPi 4 platform.
Remove it and remove the support for multiple media bus codes in
the driver.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:35:49 +0000 (17:35 +0100)]
media: ov5647: Support VIDIOC_SUBSCRIBE_EVENT
The driver reports the V4L2_SUBDEV_FL_HAS_EVENTS flag but does not
support subscribing and unsubscribing to events.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:35:48 +0000 (17:35 +0100)]
media: ov5647: Constify oe_enable/disable reglist
Make the two register-value lists const.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:35:47 +0000 (17:35 +0100)]
media: ov5647: Apply controls only when powered
Use pm_runtime_get_if_in_use() in s_ctrl to apply controls
only when the device is powered on.
Rework the control set function to balance the
pm_runtime_get_if_in_use() call with
pm_runtime_put() at the end of the function.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:35:46 +0000 (17:35 +0100)]
media: ov5647: Rework s_stream() operation
Rework the s_stream() operation to turn the sensor on and
off at stream enable/disable time using the pm_runtime infrastructure.
Protect the stream on/off from being called multiple times in
sequence with a 'streaming' flag.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:35:45 +0000 (17:35 +0100)]
media: ov5647: Use pm_runtime infrastructure
Use the pm_runtime framework to replace the legacy s_power() operation.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dave Stevenson [Thu, 19 Nov 2020 16:35:44 +0000 (17:35 +0100)]
media: ov5647: Advertise the correct exposure range
Exposure is clipped by the VTS of the mode, so it needs to be updated
when this is changed.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dave Stevenson [Thu, 19 Nov 2020 16:35:43 +0000 (17:35 +0100)]
media: ov5647: Support V4L2_CID_VBLANK control
Adds vblank control to allow for frame rate control.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:35:42 +0000 (17:35 +0100)]
media: ov5647: Support V4L2_CID_HBLANK control
Add support for the V4L2_CID_HBLANK read-only control.
The implementation has been upported from RaspberryPi BSP commit:
commit
d82f202156605 ("media: i2c: ov5647: Set V4L2_SUBDEV_FL_HAS_EVENTS flag")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dave Stevenson [Thu, 19 Nov 2020 16:35:41 +0000 (17:35 +0100)]
media: ov5647: Support V4L2_CID_PIXEL_RATE
Clients need to know the pixel rate in order to compute exposure
and frame rate values. Advertise it.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dave Stevenson [Thu, 19 Nov 2020 16:35:40 +0000 (17:35 +0100)]
media: ov5647: Set V4L2_SUBDEV_FL_HAS_EVENTS flag
The ov5647 subdev can generate control events, therefore set
the V4L2_SUBDEV_FL_HAS_EVENTS flag.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:32:38 +0000 (17:32 +0100)]
media: ov5647: Implement set_fmt pad operation
Now that the driver supports more than a single mode, implement the
.set_fmt pad operation and adjust the existing .get_fmt one to report
the currently applied format.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:32:37 +0000 (17:32 +0100)]
media: ov5647: Use SBGGR10_1X10 640x480 as default
The SBGGR10_1X10 formats support more resolutions than SBGGR8_1X8.
Make it the default sensor format and set 2x2 binned 640x480 resolution
as default sensor size as it maximizes the FOV and framerate.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:32:36 +0000 (17:32 +0100)]
media: ov5647: Add SGGBR10_1X10 modes
Add 4 additional sensor modes in SBGGR10_1X10 format.
Add the following resolutions:
- 2592x1944 full resolution
- 1920x1080 1080p cropped
- 1296x972 2x2 binned
- 640x480 2x2 binned, 2x2 subsampled
The register lists and modes definition have been upported from the
RaspberryPi BSP at revision:
commit
581dfda6d0a62 ("media: i2c: ov5647: Advertise the correct exposure range")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:32:35 +0000 (17:32 +0100)]
media: ov5647: Rename SBGGR8 VGA mode
Before adding new modes, rename the only existing one to report
the bit depth to distinguish it from future additions.
While at it, briefly describe the mode.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Dave Stevenson [Thu, 19 Nov 2020 16:32:34 +0000 (17:32 +0100)]
media: ov5647: Add support for get_selection()
Support the get_selection() pad operation to report the device
full pixel array size, the currently applied analogue crop rectangle and
the active pixel array dimensions.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:32:33 +0000 (17:32 +0100)]
media: ov5647: Break out format handling
Break format handling out from the main driver structure.
This commit prepares for the introduction of more sensor formats and
resolutions by instrumenting the existing operation to work on multiple
modes instead of assuming a single supported one.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:32:32 +0000 (17:32 +0100)]
media: ov5647: Rationalize driver structure name
The driver structure name is referred to with different names ('ov5647',
'state', 'sensor') in different functions in the driver.
Polish this up by using 'struct ov5647 *sensor' everywhere.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
David Plowman [Thu, 19 Nov 2020 16:32:31 +0000 (17:32 +0100)]
media: ov5647: Support gain, exposure and AWB controls
Add controls to support AWB, AEC and AGC. Also add control support to
set exposure (in lines) and analogue gain (as a register code).
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:32:30 +0000 (17:32 +0100)]
media: ov5647: Protect s_stream() with mutex
Use the driver mutex to protect s_stream() operations.
This will become more relevant once the sensor will support more formats
and set_format() could be issue concurrently to s_stream().
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:32:29 +0000 (17:32 +0100)]
media: ov5647: Implement enum_frame_size()
Implement the .enum_frame_size subdev pad operation.
As the driver only supports one format and one resolution at the moment
the implementation is trivial.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:19:35 +0000 (17:19 +0100)]
media: ov5647: Program mode at s_stream(1) time
Rename __sensor_init() function to ov5647_set_mode() as the function
is a regular one and the double underscores prefix shall be removed, and
then move it to program the mode at s_stream(1) time, not at sensor power
up.
Break out from __sensor_init() the stream_off() operation call at sensor
power up to coax the lanes in LP-11 state.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:19:34 +0000 (17:19 +0100)]
media: ov5647: Fix return value from read/write
The ov5647_read()/ov5647_write() return in case of success the number
of bytes read or written respectively. This requires callers to check
if the return value is less than zero to detect an error. Unfortunately,
in several places, callers directly return the result of a read/write
call, causing issues when the returned valued is checked to be different
from zero to detect an error.
Fix this by returning zero if i2c_master_send() and i2c_master_read()
return a positive value (the number of bytes written or read).
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:19:33 +0000 (17:19 +0100)]
media: ov5647: Replace license with SPDX identifier
Replace the boilerplate license text with the SPDX identifier.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Jacopo Mondi [Thu, 19 Nov 2020 16:19:32 +0000 (17:19 +0100)]
media: ov5647: Fix style issues
The driver has some obvious style issues which are worth fixing before
expanding the driver capabilities.
Fix:
- Variable declaration order
- Function parameters alignment
- Multi-line comments and spurious line breaks
- Use lowercase for hexadecimal values
- > 80 cols lines
Cosmetic change, no functional changes intended.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>