summaryrefslogtreecommitdiff
path: root/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
AgeCommit message (Collapse)Author
2020-01-09media: mtk-vcodec: use v4l2_m2m_buffer where appropriateAlexandre Courbot
Despite using M2M in both the decoder and encoder, this driver used vb2_v4l2_buffer as its base buffer structure, and placed a list_head right after the buffer declaration in order to match the layout of a v4l2_m2m_buffer. This is very dangerous as it means the driver will break should the layout of v4l2_m2m_buffer change. Fix this by directly using v4l2_m2m_buffer and updating the sites that accessed the buffer accordingly. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil-cisco@xs4all.nl: fix checkpatch warning] Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2019-10-01media: mtk-vcodec: vdec: clean up vidioc_vdec_s_fmt a bitAlexandre Courbot
Check for a potentially NULL pointer that was overlooked and use shorter accessors to the same data. While we are at it, sprinkle a few comments. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-10-01media: mtk-vcodec: vdec: fix incorrect pointer dereferenceYunfei Dong
mtk_q_data::fmt is actually a pointer and must be dereferenced as such. This went under the radar because mtk_v4l2_debug() evaluates to nothing unless DEBUG is defined. [acourbot: split into its own commit] Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-08-19media: mtk-vcodec: flag OUTPUT formats with V4L2_FMT_FLAG_DYN_RESOLUTIONMaxime Jourdan
Tag all the coded formats where the mtk-vcodec decoder supports dynamic resolution switching. Signed-off-by: Maxime Jourdan <mjourdan@baylibre.com> Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> 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-05media: mtk-vcodec: support single-buffer framesYunfei Dong
MT8183 will use a multi-planar format backed by a single buffer. Adapt the existing code to be able to handle such frames instead of assuming each frame is backed by two buffers. Co-developed-by: Alexandre Courbot <acourbot@chromium.org> [acourbot: refactor, cleanup and split] Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil-cisco@xs4all.nl: fix checkpatch alignment warning] Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-06-05media: mtk-vcodec: constify formatsAlexandre Courbot
Formats are read-only internal memory structures, so make them const. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-06-05media: mtk-vcodec: replace GPLv2 with SPDXAlexandre Courbot
Replace the GPLv2 boilerplate with the corresponding SPDX reference. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.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>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174Thomas 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 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 655 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-22media: mtk-vcodec: enlarge struct vdec_pic_info fieldsYunfei Dong
Enlarge the plane number to support more complex case and add the support for fmt change case. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-03-29media: mtk-vcodec: remove ready_to_displayAlexandre Courbot
This member is never read throughout the code, so remove it. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-03-29media: mtk-vcodec: fix access to incorrect planes memberAlexandre Courbot
Commit 0650a91499e0 ("media: mtk-vcodec: Correct return type for mem2mem buffer helpers") fixed the return types for mem2mem buffer helper functions by changing a few local variables from vb2_buffer to vb2_v4l2_buffer. However, it left a few accesses to vb2_buffer::planes as-is, accidentally turning them into accesses to vb2_v4l2_buffer::planes and resulting in values being read from/written to the wrong place. Fix this by inserting vb2_buf into these accesses so they mimic their original behavior. Fixes: 0650a91499e0 ("media: mtk-vcodec: Correct return type for mem2mem buffer helpers") Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-03-19media: mtk-vcodec: fix access to vb2_v4l2_buffer structAlexandre Courbot
Commit 0650a91499e0 ("media: mtk-vcodec: Correct return type for mem2mem buffer helpers") fixed the return types for mem2mem buffer helper functions, but omitted two occurrences that are accessed in the mtk_v4l2_debug() macro. These only trigger compiler errors when DEBUG is defined. Fixes: 0650a91499e0 ("media: mtk-vcodec: Correct return type for mem2mem buffer helpers") Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-03-01media: platform: fix several typosMauro Carvalho Chehab
Use codespell to fix lots of typos over frontends. Manually verified to avoid false-positives. Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Acked-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Reviewed-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Houlong Wei <houlong.wei@mediatek.com> Reviewed-by: Yong Deng <yong.deng@magewell.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-02-18media: mtk-vcodec: Correct return type for mem2mem buffer helpersEzequiel Garcia
Fix the assigned type of mem2mem buffer handling API. Namely, these functions: v4l2_m2m_next_buf v4l2_m2m_last_buf v4l2_m2m_buf_remove v4l2_m2m_next_src_buf v4l2_m2m_next_dst_buf v4l2_m2m_last_src_buf v4l2_m2m_last_dst_buf v4l2_m2m_src_buf_remove v4l2_m2m_dst_buf_remove return a struct vb2_v4l2_buffer, and not a struct vb2_buffer. Fixing this is necessary to fix the mem2mem buffer handling API, changing the return to the correct struct vb2_v4l2_buffer instead of a void pointer. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@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-07-04media: mtk-vcodec: Support VP9 profile in decoderKeiichi Watanabe
Add V4L2_CID_MPEG_VIDEO_VP9_PROFILE control in MediaTek decoder's driver. MediaTek decoder only supports profile 0 for now. Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-06-28media: mem2mem: Remove unused v4l2_m2m_ops .lock/.unlockEzequiel Garcia
Commit f1a81afc98e3 ("[media] m2m: fix bad unlock balance") removed the last use of v4l2_m2m_ops.lock and v4l2_m2m_ops.unlock hooks. They are not actually used anymore. Remove them. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-02-26media: mtk-vcodec: Always signal source change event on format changeTomasz Figa
Currently the driver signals the source change event only in case of a midstream resolution change, however the initial format detection is also defined as a source change by the V4L2 codec API specification. Fix this by signaling the event after the initial header is parsed as well. Signed-off-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Wu-Cheng Li <wuchengli@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-05-19[media] mtk_vcodec_dec: return error at mtk_vdec_pic_info_update()Mauro Carvalho Chehab
Gcc 7.1 complains that: drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: In function 'mtk_vdec_pic_info_update': drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c:284:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable] int ret; ^~~ Indeed, if debug is disabled, "ret" is never used. The best fix for it seems to make the fuction to return an error code. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-22[media] mtk-vcodec: check the vp9 decoder buffer index from VPUWu-Cheng Li
VPU firmware has a bug and may return invalid buffer index for some vp9 videos. Check the buffer indexes before accessing the buffer. Signed-off-by: Wu-Cheng Li <wuchengli@chromium.org> Acked-by: Tiffany Lin <Tiffany.lin@mediatek.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-08[media] mtk-vcodec: fix build warnings without DEBUGMinghsiu Tsai
After removing DEBUG from mtk_vcodec_util.h, some build warnings are generated as the following: .../drivers/media/platform/mtk-vcodec/vdec_vpu_if.c: In function 'vcodec_vpu_send_msg': .../drivers/media/platform/mtk-vcodec/vdec_vpu_if.c:73:11: warning: unused variable 'msg_id' [-Wunused-variable] uint32_t msg_id = *(uint32_t *)msg; ^ .../drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c: In function 'vb2ops_vdec_buf_queue': .../drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c:1129:7: warning: unused variable 'log_level' [-Wunused-variable] int log_level = ret ? 0 : 1; ^ .../drivers/media/platform/mtk-vcodec/venc_vpu_if.c: In function 'vpu_enc_send_msg': .../drivers/media/platform/mtk-vcodec/venc_vpu_if.c:82:12: warning: unused variable 'msg_id' [-Wunused-variable] uint32_t msg_id = *(uint32_t *)msg; ^ It is because mtk_vcodec_debug() and mtk_vcodec_err() are defined as empty macros. Without DEBUG definition, the variable for debugging is not used anymore. Fixing build warnings by moving the assignment of the variable to the argument of mtk_vcodec_debug() and mtk_vcodec_err(). Within the patch, build pass with/without DEBUG definition, and functions still work fine. Signed-off-by: Minghsiu Tsai <minghsiu.tsai@mediatek.com> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03[media] mtk-vcodec: use V4L2_DEC_CMD_STOP to implement flushTiffany Lin
Also remove the code using size-0 OUTPUT buffer to flush. Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com> Signed-off-by: Wu-Cheng Li <wuchengli@chromium.org> Reviewed-by: Kuang-che Wu <kcwu@chromium.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-16[media] mtk-vcodec: add index check in decoder vidioc_qbufWu-Cheng Li
vb2_qbuf will check the buffer index. If a driver overrides vidioc_qbuf and use the buffer index, the driver needs to check the index. Signed-off-by: Wu-Cheng Li <wuchengli@chromium.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21[media] vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoderTiffany Lin
Add V4L2_PIX_FMT_MT21C support Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21[media] vcodec: mediatek: Add Mediatek VP9 Video Decoder DriverTiffany Lin
Add vp9 decoder driver for MT8173 [mchehab@s-opensource.org: make checkpatch.pl happy] Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21[media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder DriverTiffany Lin
Add v4l2 layer decoder driver for MT8173 [mchehab@s-opensource.com: make checkpatch.pl happy] Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>