summaryrefslogtreecommitdiff
path: root/drivers/media/platform/mtk-vcodec
AgeCommit message (Collapse)Author
2022-03-18media: platform: rename mtk-vcodec/ to mediatek/mtk-vcodec/Mauro Carvalho Chehab
As the end goal is to have platform drivers split by vendor, rename mtk-vcodec/ to mediatek/mtk-vcodec/. Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-03-15media: platform: mtk-vcodec: move config to its own fileMauro Carvalho Chehab
In order to better organize the platform/Kconfig, place mtk-vcodec-specific config stuff on a separate Kconfig file. Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-03-07Merge tag 'br-v5.18l' of git://linuxtv.org/hverkuil/media_tree into media_stageMauro Carvalho Chehab
Tag branch * tag 'br-v5.18l' of git://linuxtv.org/hverkuil/media_tree: (39 commits) media: imx-jpeg: Set V4L2_BUF_FLAG_LAST at eos media: meson-ir-tx: remove incorrect doc comment media: vivid: use time_is_after_jiffies() instead of open coding it media: wl128x: use time_is_before_jiffies() instead of open coding it media: tda8083: use time_is_after_jiffies() instead of open coding it media: stv0299: use time_is_before_jiffies() instead of open coding it media: si21xx: use time_is_before_jiffies() instead of open coding it media: cedrus: h264: Fix neighbour info buffer size media: cx88-mpeg: clear interrupt status register before streaming video media: cedrus: H265: Fix neighbour info buffer size media: fsl-viu: use GFP_KERNEL media: cx18: use GFP_KERNEL drivers: meson: vdec: add VP9 support to GXM stkwebcam: add new Asus laptop to upside_down table media: imx-jpeg: fix a bug of accessing array out of bounds media: sun6i-csi: fix colorspace in sun6i_video_try_fmt() media: usb: go7007: s2250-board: fix leak in probe() media: cedrus: Add watchdog for job completion pixfmt-yuv-planar.rst: fix typo: 'Cr, Cr' -> 'Cr, Cb' media: imx-jpeg: Remove unnecessary print function dev_err() ... Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-03-07media: mtk-vcodec: Remove duplicated include in mtk_vcodec_enc_drv.cYang Li
Fix following includecheck warning: ./drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c: linux/pm_runtime.h is included more than once. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-02-22media: platform: mtk-vcodec: Do not force /dev/videoX node numberBenjamin Gaignard
Let's v4l2 framework use a free /dev/videoX node for decode and encoder. For the decoder call video_register_device() before register the media controller device so the mapping between ins correctly done. Since the registering sequence has changed rework exiting errors case too. Fixes: 590577a4e525 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver") Fixes: 4e855a6efa54 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver") Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2022-01-28media: mtk-vcodec: Get rid of mtk_smi_larb_get/putYong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the vcodec devices call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Irui Wang <irui.wang@mediatek.com> Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: Evan Green <evgreen@chromium.org> Acked-by: Tiffany Lin <tiffany.lin@mediatek.com> Reviewed-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Remove mtk_vcodec_release_enc_pmYunfei Dong
There are only two lines in mtk_vcodec_release_enc_pm, using pm_runtime_disable and put_device instead directly. Move pm_runtime_enable outside mtk_vcodec_release_enc_pm to symmetry with pm_runtime_disable, after that, rename mtk_vcodec_init_enc_pm to *_clk since it only has clock operations now. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Remove mtk_vcodec_release_dec_pmYunfei Dong
There are only two lines in mtk_vcodec_release_dec_pm, using pm_runtime_disable and put_device instead directly. Move pm_runtime_enable outside mtk_vcodec_init_dec_pm to symmetry with pm_runtime_disable, after that, rename mtk_vcodec_init_dec_pm to *_clk since it only has clock operations now. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Use codec type to separate different hardwareYunfei Dong
There is just one core thread, in order to separate different hardware, using codec type to separeate it in scp driver. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Add core dec and dec end ipi msgYunfei Dong
Add core dec and dec end ipi msg: AP_IPIMSG_DEC_CORE/AP_IPIMSG_DEC_CORE_END. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Support 34bits dma address for vdecYunfei Dong
Use the dma_set_mask_and_coherent helper to set vdec DMA bit mask to support 34bits iova space(16GB) that the mt8192 iommu HW support. Whole the iova range separate to 0~4G/4G~8G/8G~12G/12G~16G, regarding which iova range VDEC actually locate, it depends on the dma-ranges property of vdec dtsi node. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Add work queue for core hardware decodeYunfei Dong
Add work queue to process core hardware information. First, get lat_buf from message queue, then call core hardware of each codec(H264/VP9/AV1) to decode, finally puts lat_buf back to the message. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: Steve Cho <stevecho@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Add new interface to lock different hardwareYunfei Dong
For add new hardware, not only need to lock lat hardware, also need to lock core hardware in case of different instance start to decoder at the same time. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Generalize power and clock on/off interfacesYunfei Dong
Generalizes power and clock on/off interfaces to support different hardware. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Add msg queue feature for lat and core architectureYunfei Dong
For lat and core architecture, lat thread will send message to core thread when lat decode done. Core hardware will use the message from lat to decode, then free message to lat thread when decode done. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Add irq interface for multi hardwareYunfei Dong
Adds irq interface for multi hardware. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Use pure single core for MT8183Yunfei Dong
Separates different architecture for hardware: pure_sin_core and lat_sin_core. MT8183 is pure single core. Uses .hw_arch to distinguish. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Add to support multi hardware decodeYunfei Dong
There are more than two hardwares for decoder: LAT0, LAT1 and CORE. In order to manage these hardwares, register each hardware as independent platform device for the larbs are different. Each hardware module controls its own information which includes interrupt/power/clocks/registers. Calling of_platform_populate in parent device, and use subdev_bitmap to record whether the hardwares are registered. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: Steve Cho <stevecho@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Support MT8192Yunfei Dong
Adds MT8192's compatible "mediatek,mt8192-vcodec-dec". Adds MT8192's device private data mtk_lat_sig_core_pdata. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: export decoder pm functionsYunfei Dong
When mtk vcodec decoder is build as a module, we need to export mtk-vcodec-dec pm functions to make them visible by the other components. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Refactor vcodec pm interfaceYunfei Dong
Using the needed params for pm init/release function and remove unused param mtkdev in 'struct mtk_vcodec_pm'. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: Tzung-Bi Shih <tzungbi@google.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Steve Cho <stevecho@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Align vcodec wake up interrupt interfaceYunfei Dong
Vdec and venc can use the same function to wake up interrupt event. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: Tzung-Bi Shih <tzungbi@google.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Steve Cho <stevecho@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: Get numbers of register bases from DTYunfei Dong
Different platforms may have different numbers of register bases. Gets the numbers of register bases from dts (sizeof(u32) * 4 bytes for each). Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2022-01-23media: mtk-vcodec: potential dereference of null pointerJiasheng Jiang
The return value of devm_kzalloc() needs to be checked. To avoid use of null pointer in case of thefailure of alloc. Fixes: 46233e91fa24 ("media: mtk-vcodec: move firmware implementations into their own files") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Reviewed-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2021-12-07media: replace setting of bytesused with vb2_set_plane_payloadDafna Hirschfeld
In many places the bytesused field of struct vb2_buffer is set directly. Replace that with the function call vb2_set_plane_payload Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@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>
2021-11-30media: mtk-vcodec: don't check return val of mtk_venc_get_q_dataDafna Hirschfeld
The function mtk_venc_get_q_data always returns a reference so there is no need to check if the return value is null. In addition move the q_data initialization to the declaration 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>
2021-11-30media: mtk-vcodec: replace func vidioc_try_fmt with two funcs for out/capDafna Hirschfeld
The function vidioc_try_fmt has a big 'if-else' for the capture and output cases. There is hardly any code outside of that condition. It is therefore better to split that functions into two different functions, one for each case. 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>
2021-11-30media: mtk-vcodec: fix debugging definesDafna Hirschfeld
The mtk-vcodec uses some internal defined debug formats for printing. This patch fixes some things in those defines: 1. use the 'pr_fmt' define to print function name and line. 2. remove 'if(DEBUG)' condition for the defines. This condition prevents the debugs from being shown in case of dynamic debugs. Instead replace 'pr_info' with 'pr_debug' 3. remove module parameters that enable/disable debug. There is no reason for the driver to have those params. Having those params require the user to explicitly set them when user wants to see debug prints instead of using the global debugs setting as expected by drivers to conform. In addition to that, fix some warnings about debug formatting [hverkuil: used %zu instead of %lu for sizeof() arguments] Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-11-30media: mtk-vcodec: call v4l2_m2m_ctx_release first when file is releasedDafna Hirschfeld
The func v4l2_m2m_ctx_release waits for currently running jobs to finish and then stop streaming both queues and frees the buffers. All this should be done before the call to mtk_vcodec_enc_release which frees the encoder handler. This fixes null-pointer dereference bug: [ 638.028076] Mem abort info: [ 638.030932] ESR = 0x96000004 [ 638.033978] EC = 0x25: DABT (current EL), IL = 32 bits [ 638.039293] SET = 0, FnV = 0 [ 638.042338] EA = 0, S1PTW = 0 [ 638.045474] FSC = 0x04: level 0 translation fault [ 638.050349] Data abort info: [ 638.053224] ISV = 0, ISS = 0x00000004 [ 638.057055] CM = 0, WnR = 0 [ 638.060018] user pgtable: 4k pages, 48-bit VAs, pgdp=000000012b6db000 [ 638.066485] [00000000000001a0] pgd=0000000000000000, p4d=0000000000000000 [ 638.073277] Internal error: Oops: 96000004 [#1] SMP [ 638.078145] Modules linked in: rfkill mtk_vcodec_dec mtk_vcodec_enc uvcvideo mtk_mdp mtk_vcodec_common videobuf2_dma_contig v4l2_h264 cdc_ether v4l2_mem2mem videobuf2_vmalloc usbnet videobuf2_memops videobuf2_v4l2 r8152 videobuf2_common videodev cros_ec_sensors cros_ec_sensors_core industrialio_triggered_buffer kfifo_buf elan_i2c elants_i2c sbs_battery mc cros_usbpd_charger cros_ec_chardev cros_usbpd_logger crct10dif_ce mtk_vpu fuse ip_tables x_tables ipv6 [ 638.118583] CPU: 0 PID: 212 Comm: kworker/u8:5 Not tainted 5.15.0-06427-g58a1d4dcfc74-dirty #109 [ 638.127357] Hardware name: Google Elm (DT) [ 638.131444] Workqueue: mtk-vcodec-enc mtk_venc_worker [mtk_vcodec_enc] [ 638.137974] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 638.144925] pc : vp8_enc_encode+0x34/0x2b0 [mtk_vcodec_enc] [ 638.150493] lr : venc_if_encode+0xac/0x1b0 [mtk_vcodec_enc] [ 638.156060] sp : ffff8000124d3c40 [ 638.159364] x29: ffff8000124d3c40 x28: 0000000000000000 x27: 0000000000000000 [ 638.166493] x26: 0000000000000000 x25: ffff0000e7f252d0 x24: ffff8000124d3d58 [ 638.173621] x23: ffff8000124d3d58 x22: ffff8000124d3d60 x21: 0000000000000001 [ 638.180750] x20: ffff80001137e000 x19: 0000000000000000 x18: 0000000000000001 [ 638.187878] x17: 000000040044ffff x16: 00400032b5503510 x15: 0000000000000000 [ 638.195006] x14: ffff8000118536c0 x13: ffff8000ee1da000 x12: 0000000030d4d91d [ 638.202134] x11: 0000000000000000 x10: 0000000000000980 x9 : ffff8000124d3b20 [ 638.209262] x8 : ffff0000c18d4ea0 x7 : ffff0000c18d44c0 x6 : ffff0000c18d44c0 [ 638.216391] x5 : ffff80000904a3b0 x4 : ffff8000124d3d58 x3 : ffff8000124d3d60 [ 638.223519] x2 : ffff8000124d3d78 x1 : 0000000000000001 x0 : ffff80001137efb8 [ 638.230648] Call trace: [ 638.233084] vp8_enc_encode+0x34/0x2b0 [mtk_vcodec_enc] [ 638.238304] venc_if_encode+0xac/0x1b0 [mtk_vcodec_enc] [ 638.243525] mtk_venc_worker+0x110/0x250 [mtk_vcodec_enc] [ 638.248918] process_one_work+0x1f8/0x498 [ 638.252923] worker_thread+0x140/0x538 [ 638.256664] kthread+0x148/0x158 [ 638.259884] ret_from_fork+0x10/0x20 [ 638.263455] Code: f90023f9 2a0103f5 aa0303f6 aa0403f8 (f940d277) [ 638.269538] ---[ end trace e374fc10f8e181f5 ]--- [gst-master] root@debian:~/gst-build# [ 638.019193] Unable to handle kernel NULL pointer dereference at virtual address 00000000000001a0 Fixes: 4e855a6efa547 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver") 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>
2021-11-30media: mtk-vcodec: Fix an error handling path in 'mtk_vcodec_probe()'Christophe JAILLET
In case of error the 'media_device_init()' call is not balanced by a corresponding 'media_device_cleanup()' call. Add it, when needed, as already done in the remove function. Fixes: 118add98f80e ("media: mtk-vcodec: vdec: add media device if using stateless api") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-11-19media: mtk-vcodec: remove unused func parameterDafna Hirschfeld
The prarameter bs_size to function vpu_enc_encode is not used. Remove 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>
2021-11-19media: mtk-vcodec: enc: add vp8 profile ctrlDafna Hirschfeld
In order for the encoder to work with gstreamer it needs to have the V4L2_CID_MPEG_VIDEO_VP8_PROFILE ctrl. This patch adds that ctrl with only profile 0 supported. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-11-15media: mtk-vcodec: Remove redundant 'flush_workqueue()' callsChristophe JAILLET
'destroy_workqueue()' already drains the queue before destroying it, so there is no need to flush it explicitly. Remove the redundant 'flush_workqueue()' calls. This was generated with coccinelle: @@ expression E; @@ - flush_workqueue(E); destroy_workqueue(E); Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-11-15media: mtk-vcodec: vdec: remove redundant 'pfb' assignmentTzung-Bi Shih
A clang-analyzer warning was reported. >> drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c:133:18: warning: Value stored to 'pfb' during its initialization is never read [clang-analyzer-deadcode.DeadStores] struct vdec_fb *pfb = &framebuf->frame_buffer; ^~~ ~~~~~~~~~~~~~~~~~~~~~~~ Removes the redundant 'pfb' assignment to fix. Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-11-15media: mtk-vcodec: Align width and height to 64 bytesYunfei Dong
Width and height need to 64 bytes aligned when setting the format. Need to make sure all is 64 bytes align when use width and height to calculate buffer size. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Tested-by: Steve Cho <stevecho@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-10-05media: mtk-vcodec: MT8173 h264/vp8 encoder min/max bitrate settingsIrui Wang
Set recommend min/max bitrate range for MT8173 h264/vp8 encoder. Signed-off-by: Irui Wang <irui.wang@mediatek.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: venc: fix return value when start_streaming failsDafna Hirschfeld
In case vb2ops_venc_start_streaming fails, the error value is overwritten by the ret value of pm_runtime_put which might be 0. Fix it. Fixes: 985c73693fe5a (" media: mtk-vcodec: Separating mtk encoder driver") 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>
2021-09-30media: mtk-vcodec: fix warnings: symbol XXX was not declaredTzung-Bi Shih
Fixes sparse warnings: - warning: symbol 'mtk_vdec_8173_pdata' was not declared. Should it be static? - warning: symbol 'mtk_vdec_8183_pdata' was not declared. Should it be static? Link: https://lore.kernel.org/linux-media/20210809131940.2890108-1-tzungbi@google.com Cc: linux-mediatek@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tzungbi@google.com # X-LSpam-Score: -10.7 (----------) Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: enable MT8183 decoderYunfei Dong
Now that all the supporting blocks are present, enable decoder for MT8183. [acourbot: refactor, cleanup and split] Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Co-developed-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: vdec: add media device if using stateless apiYunfei Dong
The stateless API requires a media device for issuing requests. Add one if we are being instantiated as a stateless decoder. [acourbot: refactor, cleanup and split] [tzungbi: fix wrong device minor number reference] Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Co-developed-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: vdec: support stateless H.264 decodingYunfei Dong
Add support for H.264 decoding using the stateless API, as supported by MT8183. This support takes advantage of the V4L2 H.264 reference list builders. [acourbot: refactor, cleanup and split] [tzungbi: fix missing kerneldoc issue] [hverkuil: fix trivial kerneldoc typo] Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Co-developed-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: vdec: support stateless APIYunfei Dong
Support the stateless codec API that will be used by MT8183. [acourbot: refactor, cleanup and split] Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Co-developed-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: support version 2 of decoder firmware ABIAlexandre Courbot
Add support for decoder firmware version 2, which makes the kernel responsible for managing the VSI context and is used for stateless codecs. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: vdec: handle firmware version fieldAlexandre Courbot
Firmwares for decoders newer than MT8173 will include an ABI version number in their initialization ack message. Add the capacity to manage it and make initialization fail if the firmware ABI is of a version that we don't support. For MT8173, this ABI version field does not exist ; thus ignore it on this chip. There should only be one firmware version available for it anyway. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: vdec: move stateful ops into their own fileYunfei Dong
We are planning to add support for stateless decoders to this driver. Part of the driver will be shared between stateful and stateless codecs, but a few ops need to be specialized for both. Extract the stateful part of the driver and move it into its own file, accessible through ops that the common driver parts can call. This patch only moves code around and introduces a set of abstractions ; the behavior of the driver should not be changed in any way. Changes to code styling has been done to accommodate 'checkpatch.pl --strict'. [acourbot: refactor, cleanup and split] [tzungbi: fix errors from 'checkpatch.pl --strict'] Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Co-developed-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: venc: support START and STOP commandsAlexandre Courbot
The V4L2 encoder specification requires encoders to support the V4L2_ENC_CMD_START and V4L2_ENC_CMD_STOP commands. Add support for these to the mtk-vcodec encoder by reusing the same flush buffer as used by the decoder driver. [hsinyi: fix double-free issue if flush buffer was not dequeued by the time streamoff is called] Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: make flush buffer reusable by encoderAlexandre Courbot
The flush buffer is a special buffer that tells the decoder driver to send an empty CAPTURE frame to the client with V4L2_BUF_FLAG_LAST set. We need similar functionality for the encoder ; however currently the flush buffer depends on decoder-specific structures and thus cannot be reused with the encoder. Fix this by testing for this buffer by its VB2 address, and not through a dedicated flag stored in a higher-level decoder structure. This also allows us to remove said flag and simplify the code a bit. Since the flush buffer should never be used in the stateless decoder, also add safeguards to check against it. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: vdec: clamp OUTPUT resolution to hardware limitsAlexandre Courbot
Calling S_FMT or TRY_FMT on the OUTPUT queue should adjust the resolution to the limits supported by the hardware. Until now this was only done on the CAPTURE queue, which could make clients believe that unsupported resolutions can be used when they set the coded size on the OUTPUT queue. In the case of the stateless decoder, the problem was even bigger since subsequently calling G_FMT on the CAPTURE queue would result in the unclamped resolution being returned, further inducing the client into error. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: vdec: use helpers in VIDIOC_(TRY_)DECODER_CMDAlexandre Courbot
Let's use the dedicated helpers to make sure we get the expected behavior and remove redundant code. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-09-30media: mtk-vcodec: vdec: Support H264 profile controlHirokazu Honda
Add H264 profiles supported by the MediaTek 8173 decoder. [acourbot: fix commit log a bit, move to mtk_vcodec_dec.c] Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Signed-off-by: Alexandre Courbot <acourbot@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>