summaryrefslogtreecommitdiff
path: root/drivers/staging/media/rkisp1
AgeCommit message (Collapse)Author
2020-11-17media: rockchip: rkisp1: destage Rockchip ISP1 driverHelen Koike
All the items in the TODO list were addressed, uapi was reviewed, documentation written, checkpatch errors fixed, several bugs fixed. There is no big reason to keep this driver in staging, so move it out. Dt-bindings Verified with: make ARCH=arm64 dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/media/rockchip-isp1.yaml Fields of MAINTAINERS file sorted according to output of ./scripts/parse-maintainers.pl --input=MAINTAINERS --output=MAINTAINERS --order [dt-bindings: media: rkisp1: move rockchip-isp1 bindings out of staging] [dt-bindings: media: rkisp1: move rockchip-isp1 bindings out of staging] [hverkuil: fix various checkpatch alignment warnings] Signed-off-by: Helen Koike <helen.koike@collabora.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-17media: videodev2.h, v4l2-ioctl: add rkisp1 meta buffer formatShunqian Zheng
Add the Rockchip ISP1 specific processing parameter format V4L2_META_FMT_RK_ISP1_PARAMS and metadata format V4L2_META_FMT_RK_ISP1_STAT_3A for 3A. Signed-off-by: Shunqian Zheng <zhengsq@rock-chips.com> Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com> Signed-off-by: Helen Koike <helen.koike@collabora.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>
2020-11-17media: staging: rkisp1: cap: fix timeout when stopping the streamHelen Koike
The dma engine should be stopped first. The driver waits for an interrupt to stop the stream in a known state after a frame. If rkisp1_cap_stream_disable() is called after stopping the rest of the pipeline, then most likely the interrupt won't arrive, we'll get a timeout and debugfs variables mp_stop_timeout or sp_stop_timeout will be incremented. Fixes: 37db540bb9d1f ("media: staging: rkisp1: cap: refactor enable/disable stream to allow multistreaming") Signed-off-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>
2020-11-16media: staging: rkisp1: isp: set metadata pads to MEDIA_BUS_FMT_METADATA_FIXEDDafna Hirschfeld
Set the code of the metadata pads of the isp entity to MEDIA_BUS_FMT_METADATA_FIXED and set the width and height of their formats to 0. This solves the TODO item: "Fix pad format size for statistics and parameters entities." Signed-off-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>
2020-11-16media: staging: rkisp1: cap: fix runtime PM imbalance on errorZhang Qilong
pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to pm_runtime_put_noidle will result in reference imbalance in rkisp1_vb2_start_streaming, so we should fix it. Fixes: 56e3b29f9f6b2 ("media: staging: rkisp1: add streaming paths") Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: rkisp1: rsz: make const array static, makes object smallerColin Ian King
Don't populate the const array dev_names on the stack but instead it static. Makes the object code smaller by 15 bytes. Before: text data bss dec hex filename 17091 2648 64 19803 4d5b media/rkisp1/rkisp1-resizer.o After: text data bss dec hex filename 17012 2712 64 19788 4d4c media/rkisp1/rkisp1-resizer.o (gcc version 10.2.0) Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: rkisp1: remove unecessary clocksHelen Koike
aclk_isp_wrap is a child of aclk_isp, and hclk_isp_wrap is a child of hclk_isp, thus we can remove parents from the list. Also, for the isp0, we only need the ISP clock, ACLK and HCLK. In the future we'll need a pixel clock for RK3288 and RK3399, and a JPEG clock for RK3288. So with the goal to cleanup the dt-bindings and remove it from staging, simplify clock names to isp, aclk and hclk. Assigned clocks are meant to refer to the full path in the clock tree, i.e. the leaf in the tree. For instance, in RK3399, the clock responsible for ACLK (ISP AXI CLOCK) is aclk_isp0_wrapper. For reference, this is the isp clock topology on RK3399: xin24m pll_npll npll clk_isp1 clk_isp0 pll_cpll cpll aclk_isp1 aclk_isp1_noc hclk_isp1 aclk_isp1_wrapper hclk_isp1_noc aclk_isp0 hclk_isp1_wrapper aclk_isp0_wrapper aclk_isp0_noc hclk_isp0 hclk_isp0_wrapper hclk_isp0_noc pclkin_isp1_wrapper Signed-off-by: Helen Koike <helen.koike@collabora.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: dt-bindings: rkisp1: drop parent unit addressHelen Koike
Fix the following error found with make ARCH=arm64 dt_binding_check: Documentation/devicetree/bindings/media/rockchip-isp1.example.dts:24.27-101.11: Warning (unit_address_vs_reg): /example-0/parent@0: node has a unit name, but no reg or ranges property Reported-by: Johan Jonker <jbx6244@gmail.com> Signed-off-by: Helen Koike <helen.koike@collabora.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: dt-bindings: rkisp1: re-order propertiesHelen Koike
Organize properties order in dt-bindings to move it out of staging. On top: compatible, reg and interrupts. Then alphabetical order, then properties starting with '#'. Signed-off-by: Helen Koike <helen.koike@collabora.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: dt-bindings: rkisp1: drop i2c unit addressHelen Koike
Add missing required items in Rockchip ISP1 dt-bindings example for a complete i2c node. Drop unit address to Fix error: /example-0/parent/i2c@ff160000: node has a unit name, but no reg or ranges property Remove unecessary fields for the example. Signed-off-by: Helen Koike <helen.koike@collabora.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: dt-bindings: rkisp1: add missing required nodesHelen Koike
Add missing required nodes in json-schema yaml file for Rockchip ISP1 dt-bindings. Signed-off-by: Helen Koike <helen.koike@collabora.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: rkisp1: cap: refactor enable/disable stream to allow ↵Helen Koike
multistreaming Allow streaming from self picture path and main picture path at the same time. Take care for s_stream() callbacks to not be called twice. When starting a stream, s_stream(true) shouldn't be called for the isp and the sensor if the other stream is already enabled (since it was already called). When stopping a stream, s_stream(false) shouldn't be called for isp and the sensor if the other stream is still enabled. Remove the callback function scheme for navigating through the topology, simplifying the code, improving readability. Remove multistreaming item from the TODO list. Signed-off-by: Helen Koike <helen.koike@collabora.com> Reviewed-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: rkisp1: capture: set default quantization on 'set_fmt'Dafna Hirschfeld
On 's/try_fmt' ioctl, set the quantization field to V4L2_QUANTIZATION_DEFAULT. This fixes the compliance errors: fail: v4l2-test-formats.cpp(357): quantization >= 0xff fail: v4l2-test-formats.cpp(473): testColorspace(!node->is_io_mc, pix_mp.pixelformat, pix_mp.colorspace, pix_mp.ycbcr_enc, pix_mp.quantization) test VIDIOC_TRY_FMT: FAIL fail: v4l2-test-formats.cpp(357): quantization >= 0xff fail: v4l2-test-formats.cpp(473): testColorspace(!node->is_io_mc, pix_mp.pixelformat, pix_mp.colorspace, pix_mp.ycbcr_enc, pix_mp.quantization) test VIDIOC_S_FMT: FAIL Signed-off-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>
2020-11-16media: staging: rkisp1: uapi: add "WITH Linux-syscall-note"Dafna Hirschfeld
Add "WITH Linux-syscall-note" to the uapi header SPDX comment. Signed-off-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>
2020-11-16media: staging: rkisp1: params: remove unnecessary parenthesesDafna Hirschfeld
There are several 'if' expression where double parentheses is used when one is enough. Remove the extra parentheses. Signed-off-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>
2020-11-16media: staging: rkisp1: params: remove unnecessary "!!"Dafna Hirschfeld
There are several 'if' conditions of the form: if (!!(module_ens & SOME_FLAG)) Those can be replaced with: if (module_ens & SOME_FLAG) Signed-off-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>
2020-11-16media: staging: rkisp1: remove the 'is_streaming' field from stats and paramsDafna Hirschfeld
The params and stats entities have a field 'is_streaming'. This field is not needed since the entities can have available buffers only if they stream and therefore it is enough to check if there are buffers available. As a result, their start_stream callbacks can be removed since they only set the 'is_streaming' field. Signed-off-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>
2020-11-16media: staging: rkisp1: initialize buffer lists only on probeDafna Hirschfeld
The buffer lists of stats and params entities are initialized in queue_setup callback with 'INIT_LIST_HEAD'. It is enough to initialize the lists only upon registration. For the stats entity the list is already initialize upon registration. Signed-off-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>
2020-11-16media: staging: rkisp1: params: in stop_streaming, use list_splice_init to ↵Dafna Hirschfeld
move the buffers Currently the code uses 'list_cut_position' to move the buffers to a temporary list. Replace it with 'list_splice_init'. This is nicer since we don't need to access params.prev. Also, replace INIT_LIST_HEAD with the simpler LIST_HEAD. Signed-off-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>
2020-11-16media: staging: rkisp1: validate links before powering and streamingDafna Hirschfeld
In function rkisp1_vb2_start_streaming, the call to media_pipeline_start should be the first thing in order to validate the links and prevents their state from being modified before power up and streaming. Adjust stop streaming to the same logic, call media_pipeline_stop after we disable streaming on the entities in the topology. Signed-off-by: Helen Koike <helen.koike@collabora.com> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-11-16media: staging: rkisp1: remove TODO item to document quantization handlingDafna Hirschfeld
The quantization handling is already documented in the file rkisp1.rst so this item can be removed. Fixes: 6616726907418 (media: staging: rkisp1: allow quantization setting by userspace on the isp source pad) 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-10-08media: staging: rkisp1: uapi: Do not use BIT() macroNiklas Söderlund
The BIT() macro is not available to uAPI headers, replace the few usages of it by open coding it. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Acked-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-27media: staging: rkisp1: cap: protect access to buf with the spin lockDafna Hirschfeld
The function 'rkisp1_stream_start' calls 'rkisp1_set_next_buf' which access the buffers, so the call should be protected by taking the cap->buf.lock. After this patch, all locks are reviewed and commented so remove the TODO item "review and comment every lock" 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-27media: staging: rkisp1: use the right variants of spin_lockDafna Hirschfeld
When locking, use either 'spin_lock' or 'spin_lock_irq' according to the context. There is nowhere need to use 'spin_lock_irqsave'. Outside of irq context, always use 'spin_lock_irq' to be on the safe side. 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-27media: staging: rkisp1: params: no need to lock default configDafna Hirschfeld
In the function 'rkisp1_params_config_parameter' the lock is taken while applying the default config. But the lock only needs to protect the buffers list and the 'is_streaming' field, so move the locking to lock only what is needed. Signed-off-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>
2020-09-27media: staging: rkisp1: stats: protect write to 'is_streaming' in ↵Dafna Hirschfeld
start_streaming cb The field stats->is_streaming is written in 'start_streaming' callback without the stats->lock protection. The isr might run together with the callback so 'spin_lock_irq' should be used. Signed-off-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>
2020-09-27media: staging: rkisp1: isp: don't enable signal RKISP1_CIF_ISP_FRAME_INDafna Hirschfeld
The signal RKISP1_CIF_ISP_FRAME_IN is not used in the isr so there is no need to enable it. Signed-off-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>
2020-09-27media: staging: rkisp1: isp: add a warning and debugfs var for irq delayDafna Hirschfeld
The signal RKISP1_CIF_ISP_FRAME is set when the ISP completes outputting the frame to the next block in the pipeline. In order to keep buffer synchronization we assume that the RKISP1_CIF_ISP_V_START signal never arrives together with the RKISP1_CIF_ISP_FRAME signal. In case those signals arrive together then the code is not able to tell if the RKISP1_CIF_ISP_FRAME signal relates to the frame of the current v-start or the previous. This patch adds a WARN_ONCE and a debugfs var to catch it. 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-27media: staging: rkisp1: remove atomic operations for frame sequenceDafna Hirschfeld
The isp.frame_sequence is now read only from the irq handlers that are all fired from the same interrupt, so there is not need for atomic operation. In addition, the frame seq incrementation is moved from rkisp1_isp_queue_event_sof to rkisp1_isp_isr to make the code clearer and the incorrect inline comment is removed. Signed-off-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>
2020-09-27media: staging: rkisp1: params: set vb.sequence to be the isp's ↵Dafna Hirschfeld
frame_sequence + 1 The params isr is called when the ISP finishes processing a frame (RKISP1_CIF_ISP_FRAME). Configurations performed in the params isr will be applied on the next frame. Since frame_sequence is updated on the vertical sync signal, we should use frame_sequence + 1 as the vb.sequence of the params buffer to indicate to userspace on which frame these parameters are being applied. Signed-off-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>
2020-09-27media: staging: rkisp1: params: avoid using buffer if params is not streamingDafna Hirschfeld
Currently, the first buffer queued in the params node is returned immediately to userspace and a copy of it is saved in the field 'cur_params'. The copy is later used for the first configuration when the stream is initiated by one of selfpath/mainpath capture nodes. There are 3 problems with this implementation: - The first params buffer is applied and returned to userspace even if userspace never calls to streamon on the params node. - If the first params buffer is queued after the stream started on the params node then it will return to userspace but will never be used. - The frame_sequence of the first buffer is set to -1 if the main/selfpath did not start streaming. A correct implementation is to apply the first params buffer when stream is started from mainpath/selfpath and only if params is also streaming. The patch adds a new function 'rkisp1_params_apply_params_cfg' which takes a buffer from the buffers queue, apply it and returns it to userspace. The function is called from the irq handler and when main/selfpath stream starts - in the function 'rkisp1_params_config_parameter' Also remove the fields 'cur_params', 'is_first_params' which are no more needed. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reported-by: kernel test robot <lkp@intel.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>
2020-09-27media: staging: rkisp1: params: use the new effect value in cproc configDafna Hirschfeld
The cproc (color processing) configuration needs to know if an image effect is configured. The code uses the image effect in 'cur_params' which is the first params buffer queued in the stream. This is the wrong place to read the value. The value should be taken from the current params buffer. Signed-off-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>
2020-09-27media: staging: rkisp1: params: in the isr, return if buffer list is emptyDafna Hirschfeld
Currently the code in the isr checks if the buffer list is not empty before referencing a buffer and then check again if the buffer is not NULL. Instead we can save one 'if' statement by returning if the buffers list is empty. Also remove non-helpful inline doc 'get one empty buffer' Signed-off-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>
2020-09-27media: staging: rkisp1: params: upon stream stop, iterate a local list to ↵Dafna Hirschfeld
return the buffers The code in '.stop_streaming' callback releases and acquire the lock at each iteration when returning the buffers. Holding the lock disables interrupts so it should be minimized. To make the code cleaner and still minimize holding the lock, the buffer list is first moved to a local list and then can be iterated without the lock. Signed-off-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>
2020-09-27media: pixfmt-meta-rkisp1.rst: add description of rkisp1 metadata formats in ↵Dafna Hirschfeld
pixfmt-meta-rkisp1.rst The metadata formats V4L2_META_FMT_RK_ISP1_PARAMS, V4L2_META_FMT_RK_ISP1_STAT_3A are currently described in two files under drivers/staging/media/rkisp1/Documentation/media/uapi/v4l This patch moves the description to one file: Documentation/userspace-api/media/v4l/pixfmt-meta-rkisp1.rst The patch also extends the description and adds the rst file to toctree. Signed-off-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>
2020-09-27media: staging: rkisp1: fix configuration for GREY pixelformatDafna Hirschfeld
This patch changes the device configuration to support capture of V4L2_PIX_FMT_GREY video. The 'write_format' field of the format description should be planar. Also the array 'pixm->plane_fmt' that describes the planes should be memset to 0 before filling it since the the cb, cr planes should be 0. Signed-off-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>
2020-09-27media: staging: rkisp1: cap: simplify link validation by comparing media bus ↵Dafna Hirschfeld
code The capture has a mapping of the mbus code needed for each pixelformat. This can be used to simplify the link validation by comparing the mbus code in the capture with the code in the resizer. Signed-off-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>
2020-09-27media: staging: rkisp1: rsz: Add support to more YUV encoded mbus codes on ↵Dafna Hirschfeld
src pad Add support to more YUV encoded media bus formats on the resizer's source pad. The patch defines an array rkisp1_rsz_yuv_formats[] with the list of supported YUV media bus formats and their {hv}div values. The {hv}div are used in the function 'rkisp1_rsz_config' instead of the macros RKISP1_MBUS_FMT_(HV)DIV, and instead of checking the capture format. Signed-off-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>
2020-09-27media: staging: rkisp1: rsz: enumerate the formats on the src pad according ↵Dafna Hirschfeld
to the capture Currently the resizer outputs the same media bus format as the input. This is wrong since the resizer is also used to downscale YUV formats. This patch changes the enumeration of the supported formats. The supported formats on the sink pad should be taken from the isp entity and the supported formats on the source pad should be taken from the capture entity. Signed-off-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>
2020-09-27media: staging: rkisp1: add a helper function to enumerate supported mbus ↵Dafna Hirschfeld
formats on capture Add a function 'rkisp1_cap_enum_mbus_codes' that receive a pointer to 'v4l2_subdev_mbus_code_enum' and returns the next supported mbus format of the capture. The function assumes that pixel formats with identical 'mbus' are grouped together in the hardcoded arrays, therefore the order of the entries in the array 'rkisp1_sp_fmts' are adjusted. This function is a helper for the media bus enumeration of the source pad of the resizer entity. Signed-off-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>
2020-09-27media: staging: rkisp1: add capability V4L2_CAP_IO_MC to capture devicesDafna Hirschfeld
The capture devices supports YUV, RGB, and Bayer formats. Adding V4L2_CAP_IO_MC capability will reflect userspace what format should be set on the resizer in order to stream each of the video formats. The patch adds a 'mbus' field to the struct 'rkisp1_capture_fmt_cfg' which maps the video format to the needed mbus format. Signed-off-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>
2020-09-27media: staging: rkisp1: don't support bayer format on selfpath resizerDafna Hirschfeld
The selfpath capture does not support bayer formats. Therefore there is no reason to support bayer formats on the selfpath resizer. The selfpath resizer should support only MEDIA_BUS_FMT_YUYV8_2X8. Signed-off-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>
2020-09-27media: staging: rkisp1: cap: remove unsupported format YUV444Dafna Hirschfeld
It is not clear if the device is able to support format V4L2_PIX_FMT_YUV444M so remove it. Signed-off-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>
2020-09-27media: staging: rkisp1: cap: remove unsupported formatsDafna Hirschfeld
For Ycbcr packed formats only YUYV can be supported by the driver. This patch removes the other formats. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Acked-by: Helen Koike <helen.koike@collabora.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>
2020-09-27media: staging: rkisp1: cap: change RGB24 format to XBGR32Dafna Hirschfeld
According to the TRM [1], the YUV->RGB conversion outputs RGB 888 format with 4 bytes, where the last byte is ignored, using big endian representation: |___X___|___R___|___G___|___B___| 31 24 16 8 0 Which matches format V4L2_PIX_FMT_XBGR32 in little endian representation, so replace it accordingly. "24 bit word". What it means is that 4 bytes are used with 24bit for the RGB and the last byte is ignored. This matches format V4L2_PIX_FMT_XBGR32. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Acked-by: Helen Koike <helen.koike@collabora.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-26media: staging: rkisp1: rsz: set flags to 0 in enum_mbus_code cbDafna Hirschfeld
The resizer calls the enum_mbus_code cb on the source pad of the isp entity since they support the same formats. The only difference is that the isp entity allows setting the quantization and sets the flag V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION. The resizer should therefore set the flags to 0. 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-26media: staging: rkisp1: allow quantization setting by userspace on the isp ↵Dafna Hirschfeld
source pad The isp entity has hardware support to force full range quantization for YUV formats. Use the subdev CSC API to allow userspace to set the quantization for YUV formats on the isp entity. - The flag V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION is set for YUV formats during enumeration of the isp formats on the source pad. - The full quantization is set on YUV formats if userspace asks it on the isp entity using the flag V4L2_MBUS_FRAMEFMT_SET_CSC. On the capture and the resizer, the quantization is read-only and always set to the default quantization. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Helen Koike <helen.koike@collabora.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-08-29media: staging: rkisp1: uapi: remove __packedHelen Koike
The driver access struct's fields one by one, they are not blindly copied to/from the hardware, so we can remove __packed from the structs. Tested on Scarlet Chromebook with ChromeOS stack and verified images with the Camera app. Signed-off-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>
2020-08-29media: staging: rkisp1: params: don't release lock in isr before buffer is doneDafna Hirschfeld
In the irq handler 'rkisp1_params_isr', the lock 'config_lock' should be held as long as the current buffer is used. Otherwise the stop_streaming calback might remove it from the list and pass it to userspace while it is referenced in the irq handler. Signed-off-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>
2020-08-29media: staging: rkisp1: params: use rkisp1_param_set_bits to set reg in isrDafna Hirschfeld
replace a read and write of RKISP1_CIF_ISP_CTRL register in the isr with the 'rkisp1_param_set_bits' function that does that. Signed-off-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>