aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/qcom/venus/vdec.c
AgeCommit message (Collapse)Author
2020-10-29media: venus: fixes for list corruptionVikash Garodia
[ Upstream commit e1c69c4eef61ffe295b747992c6fd849e6cd747d ] There are few list handling issues while adding and deleting node in the registered buf list in the driver. 1. list addition - buffer added into the list during buf_init while not deleted during cleanup. 2. list deletion - In capture streamoff, the list was reinitialized. As a result, if any node was present in the list, it would lead to issue while cleaning up that node during buf_cleanup. Corresponding call traces below: [ 165.751014] Call trace: [ 165.753541] __list_add_valid+0x58/0x88 [ 165.757532] venus_helper_vb2_buf_init+0x74/0xa8 [venus_core] [ 165.763450] vdec_buf_init+0x34/0xb4 [venus_dec] [ 165.768271] __buf_prepare+0x598/0x8a0 [videobuf2_common] [ 165.773820] vb2_core_qbuf+0xb4/0x334 [videobuf2_common] [ 165.779298] vb2_qbuf+0x78/0xb8 [videobuf2_v4l2] [ 165.784053] v4l2_m2m_qbuf+0x80/0xf8 [v4l2_mem2mem] [ 165.789067] v4l2_m2m_ioctl_qbuf+0x2c/0x38 [v4l2_mem2mem] [ 165.794624] v4l_qbuf+0x48/0x58 [ 1797.556001] Call trace: [ 1797.558516] __list_del_entry_valid+0x88/0x9c [ 1797.562989] vdec_buf_cleanup+0x54/0x228 [venus_dec] [ 1797.568088] __buf_prepare+0x270/0x8a0 [videobuf2_common] [ 1797.573625] vb2_core_qbuf+0xb4/0x338 [videobuf2_common] [ 1797.579082] vb2_qbuf+0x78/0xb8 [videobuf2_v4l2] [ 1797.583830] v4l2_m2m_qbuf+0x80/0xf8 [v4l2_mem2mem] [ 1797.588843] v4l2_m2m_ioctl_qbuf+0x2c/0x38 [v4l2_mem2mem] [ 1797.594389] v4l_qbuf+0x48/0x58 Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org> Reviewed-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> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-05-05media: venus: venc,vdec: Return EBUSY on S_FMT while streamingStanimir Varbanov
According to the v4l spec s_fmt must return EBUSY while the particular queue is streaming. Add such check in encoder and decoder s_fmt methods. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-05media: venus: Mark last capture bufferStanimir Varbanov
According to stateful Codec API the decoder will process all remaining buffers from before the source change event in dynamic-resolution-change state and mark the last buffer with V4L2_BUF_FLAG_LAST. In Venus case the firmware doesn't mark that last buffer and some mechanism have to be created in v4l decoder driver. Fortunately the firmware interface (HFI) claims that the decoder output buffers will be returned to v4l decoder driver before it send the insufficient event. In order to do that we save last queued in the driver capture buffer in the event_notify and issue flush on output firmware buffers queue. Once the saved buffer is returned (as a result of flush command) we mark it as LAST. For all that possible we extend HFI flush command with one more argument and one more flush_done HFI driver callback. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-05media: venus: vdec: Init registered list unconditionallyStanimir Varbanov
Presently the list initialization is done only in dynamic-resolution-change state, which leads to list corruptions and use-after-free. Init list_head unconditionally in vdec_stop_capture called by vb2 stop_streaming without takeing into account current codec state. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-05media: venus: vdec: Mark flushed buffers with error stateStanimir Varbanov
Once the hfi_session_flush is issued by the vdec all queued buffers to firmware should be returned to the v4l driver. Some of those buffers are not processed at the time of flush command, those buffers has filled len zero (no data). Catch that in buffer_done callback and mark not filled capture buffers with error state so that client can discard them. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-05-05media: venus: helpers: Done buffers per queue typeStanimir Varbanov
Currently calling venus_helper_buffers_done() will return buffers to user for both capture and output queues in the same call. This is wrong because both queues are really separate and calling stop_streaming on one queue shouldn't return buffers for the other. Solve this by add a new queue type argument and fix the clients of the helper function. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-04-14media: venus: vdec: Use pmruntime autosuspendStanimir Varbanov
Implement pmruntime autosuspend in video decoder. This will allow to save power while the userspace is inactive for some reasonable period of time. Here we power-off venus core clocks and power domain and don't touch vcodec because it is under hardware control. The later decision is made to simplify the code and avoid a mess in the power management code. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-03-12media: venus: vdec: Fix forgotten mutex unlock in start streamingStanimir Varbanov
This fixes the following smatch warning in the error path: drivers/media/platform/qcom/venus/vdec.c:968 vdec_start_streaming() warn: inconsistent returns 'mutex:&inst->lock'. Locked on: line 952 Unlocked on: line 963 line 968 by goto mutex unlock. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-02-27media: venus: vdec: handle 10bit bitstreamsAniket Masule
Handle 10bit video streams in the decoder by using dithering, i.e the decoder output buffers will be in 8bit format. The runtime handling is implemented by sending v4l2 event to userspace application, then the application should stop the streaming on capture queue and initiate format negotiation, and start streaming again. Signed-off-by: Aniket Masule <amasule@codeaurora.org> Co-developed-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-02-27media: venus: introduce core selectionAniket Masule
Presently the core (vcodec pipelines) assignment is static. Here we introduce dynamic load balancing across the cores depending on the current session load. The load on earch core is calculated and core with minimum load is assigned to given instance. This will be applicable on Venus v4 with more than one vcodec cores. Signed-off-by: Aniket Masule <amasule@codeaurora.org> Co-developed-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-02-27media: venus: redesign clocks and pm domains controlStanimir Varbanov
Redesign core (vcodec) clock control to give the venus core more freedom to control them in order to make possible to use core selection feature on Venus IP v4. Move all clock and pmdomain functions in separate file and abstract power control with common operations per Venus IP version. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-02-24media: media/platform: rename VFL_TYPE_GRABBER to _VIDEOHans Verkuil
'GRABBER' is a weird name, all other types map to the /dev device names. Rename to 'VIDEO' to be consistent with the other types. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2019-11-09media: venus: remove invalid compat_ioctl32 handlerArnd Bergmann
v4l2_compat_ioctl32() is the function that calls into v4l2_file_operations->compat_ioctl32(), so setting that back to the same function leads to a trivial endless loop, followed by a kernel stack overrun. Remove the incorrect assignment. Cc: stable@vger.kernel.org Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files") Fixes: aaaa93eda64b ("[media] media: venus: venc: add video encoder files") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2019-10-04media: venus: Update clock scalingAniket Masule
Current clock scaling calculations are same for vpu4 and previous versions. For vpu4, Clock scaling calculations are updated with cycles/mb and bitrate. This helps in getting precise clock required. Signed-off-by: Aniket Masule <amasule@codeaurora.org> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-10-04media: venus: Add codec data tableAniket Masule
Add vpp cycles for different types of codec. It indicates the cycles required by video hardware to process each macroblock. Add vsp cycles, cycles required by stream processor. Initialize the codec data with core resources. Signed-off-by: Aniket Masule <amasule@codeaurora.org> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-08-19media: venus: vdec: flag OUTPUT formats with V4L2_FMT_FLAG_DYN_RESOLUTIONMaxime Jourdan
Tag all the coded formats where the venus vdec supports dynamic resolution switching. Signed-off-by: Maxime Jourdan <mjourdan@baylibre.com> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-08-05media: venus: dec: populate properly timestamps and flags for capture buffersStanimir Varbanov
Cache flags, timestamps and timecode structure of OUTPUT buffers in per-instance structure array and fill correctly the same when the CAPTURE buffers are done. This will make v4l2-compliance decoder streaming test happy. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-08-05media: venus: make decoder compliant with stateful codec APIStanimir Varbanov
This refactors code for start/stop streaming vb2 operations and adds a state machine handling similar to the one in stateful codec API documentation. One major change is that now the HFI session is started on STREAMON(OUTPUT) and stopped on REQBUF(OUTPUT,count=0), during that time STREAMOFF(CAP,OUT) just flush buffers but doesn't stop the session. The other major change is that now the capture and output queues are completely separated. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-08-05media: venus: vdec: allow bigger sizeimage set by clientsStanimir Varbanov
In most of the cases the client will know better what could be the maximum size for compressed data buffers. Change the driver to permit the user to set bigger size for the compressed buffer but make reasonable sanitation. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-06-11Merge tag 'v5.2-rc4' into media/masterMauro Carvalho Chehab
There are some conflicts due to SPDX changes. We also have more patches being merged via media tree touching them. So, let's merge back from upstream and address those. Linux 5.2-rc4 * tag 'v5.2-rc4': (767 commits) Linux 5.2-rc4 MAINTAINERS: Karthikeyan Ramasubramanian is MIA i2c: xiic: Add max_read_len quirk lockref: Limit number of cmpxchg loop retries uaccess: add noop untagged_addr definition x86/insn-eval: Fix use-after-free access to LDT entry kbuild: use more portable 'command -v' for cc-cross-prefix s390/unwind: correct stack switching during unwind block, bfq: add weight symlink to the bfq.weight cgroup parameter cgroup: let a symlink too be created with a cftype file drm/nouveau/secboot/gp10[2467]: support newer FW to fix SEC2 failures on some boards drm/nouveau/secboot: enable loading of versioned LS PMU/SEC2 ACR msgqueue FW drm/nouveau/secboot: split out FW version-specific LS function pointers drm/nouveau/secboot: pass max supported FW version to LS load funcs drm/nouveau/core: support versioned firmware loading drm/nouveau/core: pass subdev into nvkm_firmware_get, rather than device block: free sched's request pool in blk_cleanup_queue pktgen: do not sleep with the thread lock held. net: mvpp2: Use strscpy to handle stat strings net: rds: fix memory leak in rds_ib_flush_mr_pool ... Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284Thomas Gleixner
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 and only version 2 as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 294 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190529141900.825281744@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap, out}_mplaneBoris Brezillon
Support for multiplanar and singleplanar formats is mutually exclusive, at least in practice. In our attempt to unify support for support for mplane and !mplane in v4l, let's get rid of the ->vidioc_enum_fmt_{vid,out}_cap_mplane() hooks and call ->vidioc_enum_fmt_{vid,out}_cap() instead. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> [hverkuil-cisco@xs4all.nl: fix typos: pirv -> priv and prov -> priv] Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-12-03media: venus: fix reported size of 0-length buffersAlexandre Courbot
The last buffer is often signaled by an empty buffer with the V4L2_BUF_FLAG_LAST flag set. Such buffers were returned with the bytesused field set to the full size of the OPB, which leads user-space to believe that the buffer actually contains useful data. Fix this by passing the number of bytes reported used by the firmware. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-09media: venus: vdec: fix decoded data sizeVikash Garodia
Existing code returns the max of the decoded size and buffer size. It turns out that buffer size is always greater due to hardware alignment requirement. As a result, payload size given to client is incorrect. This change ensures that the bytesused is assigned to actual payload size, when available. Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-09-11media: use strscpy() instead of strlcpy()Mauro Carvalho Chehab
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-08-02media: headers: fix linux/mod_devicetable.h inclusionsArnd Bergmann
A couple of drivers produced build errors after the mod_devicetable.h header was split out from the platform_device one, e.g. drivers/media/platform/davinci/vpbe_osd.c:42:40: error: array type has incomplete element type 'struct platform_device_id' drivers/media/platform/davinci/vpbe_venc.c:42:40: error: array type has incomplete element type 'struct platform_device_id' This adds the inclusion where needed. Fixes: ac3167257b9f ("headers: separate linux/mod_devicetable.h from linux/platform_device.h") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: add HEVC codec supportStanimir Varbanov
This add HEVC codec support for venus versions 3xx and 4xx. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: implementing multi-stream supportStanimir Varbanov
This is implementing multi-stream decoder support. The multi-stream will be used to enable/disable the primary/secondary decoder outputs. Depending on formats on both decoder outputs we could implement downscale, dithering and supporting UBWC (universal bandwidth compression) formats. The UBWC compressed raw format is used to optimize interconnect bandwidth for bigger resolutions like 4K and hence we will get some power-saving benefits as well. Both decoder outputs are distinguished by buffer_type field in the HFI packets. For example HFI_BUFFER_OUTPUT is the buffer type for primary decoder output and HFI_BUFFER_OUTPUT2 is for secondary decoder output. Starting from Venus 4xx the DPB buffers format must be UBWC, so the multi-stream becomes mandatory for this Venus version. That means that we need to allocate internally in the driver a set of DPB buffers (with UBWC NV12 format) and give them to the firmware. The other decoder output (we called it OPB) format will be NV12 linear format and with the same resolution (or smaller in case the user wants to downscale). The DPB buffers are used for decoder reference frames and those have to be in a specific format (UBWC). So one decoder output is used to fill those reference buffers while the other output is used to fill the userspace buffers with the user requested format. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: helpers: move frame size calculations on common placeStanimir Varbanov
This move the calculations of raw and compressed buffer sizes on common helper and make it identical for encoder and decoder. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: vdec: a new function for output configurationStanimir Varbanov
Make a new function vdec_output_conf() for decoder output configuration. vdec_output_conf() will set properties via HFI interface related to the output configuration, and keep vdec_set_properties() which will set properties related to decoding parameters. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: vdec: get required input buffers as wellStanimir Varbanov
Rework and rename vdec_cap_num_buffers() to get the number of input buffers too. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: helpers: extend set_num_bufs helper with one more argumentStanimir Varbanov
Extend venus_helper_set_num_bufs() helper function with one more argument to set number of output buffers for the secondary decoder output. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: helpers, vdec, venc: add helpers to set work mode and core usageStanimir Varbanov
These are new properties applicable to Venus version 4xx. Add the helpers and call them from decoder and encoder drivers. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: helpers: add helper function to set actual buffer sizeStanimir Varbanov
Add and use a helper function to set actual buffer size for particular buffer type. This is also preparation to use the second decoder output. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: helpers: add a helper function to set dynamic buffer modeStanimir Varbanov
Adds a new helper function to set dynamic buffer mode if it is supported by current HFI version. The dynamic buffer mode is set unconditionally for both decoder outputs. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: hfi_parser: add common capability parserStanimir Varbanov
This adds common capability parser for all supported Venus versions. Having it will help to enumerate better the supported raw formats and codecs and also the capabilities for every codec like max/min width/height, framerate, bitrate and so on. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: core, helpers: add two more clocks found in Venus 4xxStanimir Varbanov
Add two more clocks for Venus 4xx in core structure and create a new power enable function to handle it for 3xx/4xx versions. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-25media: venus: hfi: preparation to support venus 4xxStanimir Varbanov
This covers the differences between 1xx,3xx and 4xx. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-06-28media: venus: keep resolution when adjusting formatAlexandre Courbot
When checking a format for validity, the resolution is reset to 1280x720 whenever the pixel format is not supported. This behavior can mislead user-space into believing that this is the only resolution supported, and looks strange considering that if we try/set the same format with just the pixel format changed to a valid one, the call will this time succeed without altering the resolution. Resolution is managed independently of the pixel format, so remove this reset. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-04media: venus: vdec: fix format enumerationAlexandre Courbot
find_format_by_index() stops enumerating formats as soon as the index matches, and returns NULL if venus_helper_check_codec() finds out that the format is not supported. This prevents formats to be properly enumerated if a non-supported format is present, as the enumeration will end with it. Fix this by moving the call to venus_helper_check_codec() into the loop, and keep enumerating when it fails. Fixes: 29f0133ec6 media: venus: use helper function to check supported codecs Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-27media: venus: reimplement decoder stop commandStanimir Varbanov
This addresses the wrong behavior of decoder stop command by rewriting it. These new implementation enqueue an empty buffer on the decoder input buffer queue to signal end-of-stream. The client should stop queuing buffers on the V4L2 Output queue and continue queuing/dequeuing buffers on Capture queue. This process will continue until the client receives a buffer with V4L2_BUF_FLAG_LAST flag raised, which means that this is last decoded buffer with data. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: <stable@vger.kernel.org> # for v4.13 and up Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2017-08-26media: venus: use helper function to check supported codecsStanimir Varbanov
Use the helper function in decoder and encoder find_format to runtime check supported codecs. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-26media: venus: fill missing video_device nameStanimir Varbanov
This fills missing (forgotten) video device name with appropriate string so that udev can distinguishes between decoder and encoder devices. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-26media: venus: mark venc and vdec PM functions as __maybe_unusedStanimir Varbanov
Without PM support gcc could warns about unused functions, thus mark runtime_suspend/resume as __maybe_unused. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20[media] media: venus: vdec: add support for min buffers for captureStanimir Varbanov
This adds support for V4L2_CID_MIN_BUFFERS_FOR_CAPTURE get control in venus decoder, it is usable in case when the userspace wants to know minimum capture buffers before calling request_buf for capture queue in mem2mem drivers. Also this will fix an issue found gstreamer v4l2videodec element, i.e. the video decoder element cannot continue because the buffers are insufficient. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20[media] media: venus: vdec: fix compile error in vdec_closeStanimir Varbanov
This fixes the following compile error ocured when building with gcc7: drivers/media/platform/qcom/venus/vdec.c:1022 vdec_close() error: dereferencing freed memory 'inst' by moving kfree as a last call. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20[media] media: venus: vdec: add video decoder filesStanimir Varbanov
This consists of video decoder implementation plus decoder controls. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>