Commit Graph

15 Commits

Author SHA1 Message Date
Dafna Hirschfeld 2f49146349 media: vivid: Add support to the CSC API
The CSC API (Colorspace conversion) allows userspace to try
to configure the colorspace, transfer function, Y'CbCr/HSV encoding
and the quantization for capture devices. This patch adds support
to the CSC API in vivid.
Using the CSC API, userspace is allowed to do the following:

- Set the colorspace.
- Set the xfer_func.
- Set the ycbcr_enc function for YUV formats.
- Set the hsv_enc function for HSV formats
- Set the quantization for YUV and RGB formats.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-26 10:21:34 +02:00
Hans Verkuil d034731bb4 media: vivid: fix compile warning/error
Fix this warning:

vivid-core.c: In function 'vivid_create_devnodes':
vivid-core.c:1318:11: warning: unused variable 'i' [-Wunused-variable]
 1318 |  int ret, i;
      |           ^

and this error:

vivid-core.c: In function 'vivid_create_instance':
vivid-core.c:1885:47: error: 'cec_tx_bus_cnt' undeclared (first use in this function)
 1885 |  ret = vivid_create_devnodes(pdev, dev, inst, cec_tx_bus_cnt,
      |                                               ^~~~~~~~~~~~~~
vivid-core.c:1885:47: note: each undeclared identifier is reported only once for each function it appears in

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-08 11:54:00 +02:00
Mauro Carvalho Chehab 49a3d74b46 media: vivid: fix error path
If something fails after calling v4l2_device_register(),
it should call v4l2_device_put().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-07 16:02:51 +02:00
Mauro Carvalho Chehab 62c6b4c9e3 media: vivid: move the devnode creation logic to a separate function
In order to reduce even further the size of the big
vivid_create_instance() function, let's place the part of the
logic which creates the device nodes into a separate function.

    With this and the past patches, those warnings finally
    vanishes:

            drivers/media/test-drivers/vivid/vivid-core.c: drivers/media/test-drivers/vivid/vivid-core.c:1189 vivid_create_instance() parse error: turning off implications after 60 seconds
            drivers/media/test-drivers/vivid/vivid-core.c: drivers/media/test-drivers/vivid/vivid-core.c:1257 vivid_create_instance() parse error: __split_smt: function too hairy.  Giving up after 303 seconds

The init code also seems more organized after breaking the long
function into a smaller set.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-07 16:01:57 +02:00
Mauro Carvalho Chehab faf21f2867 media: vivid: move the create queues to a separate function
Instead of placing everything inside vivid_create_instance(),
we can move the part which creates per-type video queues
into a separate function.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-07 16:01:40 +02:00
Mauro Carvalho Chehab d92c8e3145 media: vivid: place dt timings init code on a separate function
Move those out of the big vivid_create_instance() function.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-07 16:00:56 +02:00
Mauro Carvalho Chehab 4306c5379d media: vivid: move set_capabilities logic to a separate function
Move such logic from vivid_create_instance(), as otherwise
smatch takes forever.

The vivid_create_instance() is still a too big for my taste.
So, further cleanups are still needed.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-07 16:00:15 +02:00
Mauro Carvalho Chehab fcaeb01929 media: vivid: place the logic which disables ioctl on a separate function
Move this code out of the long vivid_create_instance() function.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-07 15:59:15 +02:00
Mauro Carvalho Chehab 31b97d358d media: vivid: move the detection part out of vivid_create_instance
The vivid_create_instance() function is too harry. Smatch can't
process it, because it takes too long.

The detection part is an important piece of it. As such, there
are even comments before and after such block.

So, it makes sense to just move it to a separate function.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-07 15:58:55 +02:00
Gustavo A. R. Silva 1771e9fb67 media: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-08-29 08:35:27 +02:00
Hans Verkuil bda24f4330 media: media/test-drivers: use vb2_video_unregister_device()
Use vb2_video_unregister_device() to automatically stop streaming
at unregister time.

This avoids the use of vb2_queue_release() which should not be
called by drivers that set vdev->queue.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-08-28 15:05:40 +02:00
Peilin Ye e3158a5e7e media: vivid: Fix global-out-of-bounds read in precalculate_color()
vivid_meta_out_process() is setting `brightness`, `contrast`, `saturation`
and `hue` using tpg_s_*(). This is wrong, since tpg_s_*() do not provide
range checks. Using tpg_s_*() here also makes the control framework
out-of-sync with the actual values. Use v4l2_ctrl_s_ctrl() instead.

This issue has been reported by syzbot as an out-of-bounds read bug in
precalculate_color().

Reported-and-tested-by: syzbot+02d9172bf4c43104cd70@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=02d9172bf4c43104cd70

Fixes: 746facd393 ("media: vivid: Add metadata output support")
Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-08-26 18:51:16 +02:00
Gustavo A. R. Silva a32e8adf2f media: test_drivers: vivid-core: Use array_size() helper
The tpg_alloc() and vmalloc() functions have no 2-factor argument form, so
multiplication factors need to be wrapped in array_size().

This issue was found with the help of Coccinelle and, audited and fixed
manually.

Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-07-04 12:42:19 +02:00
Sergey Senozhatsky 62a4cd0130 media: vivid: add cache_hints module param
Add a cache_hints module param to control per-queue user space cache
hints support.

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-06-23 13:40:35 +02:00
Hans Verkuil dacca5f0fa media: media/test_drivers: rename to test-drivers
We never use _ in directory names in the media subsystem, so
rename to test-drivers instead for consistency.

Also update MAINTAINERS with the new path.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-04-16 10:38:31 +02:00