Skip to contentSkip to conversation

Add MT8173 Video Decoder Driver

PATCH In review Tiffany Lin 4 participants 23 messages Sep 2, 2016 – Oct 24, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v5 cover Add MT8173 Video Decoder Driver

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

==================
Device interface
==================

In principle the driver bases on v4l2 memory-to-memory framework:
it provides a single video node and each opened file handle gets its own private context with separate buffer queues. Each context consist of 2 buffer
queues: OUTPUT (for source buffers, i.e. bitstream) and CAPTURE (for destination buffers, i.e. decoded video frames).
OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.

Change in v5:
1. Merge wucheng's V4L2_PIX_FMT_VP9 series to this series
V4L: add VP9 format documentation
v4l2-ioctl: add VP9 format description. videodev2.h: add V4L2_PIX_FMT_VP9 format.
2. Remove V4L2_PIX_FMT_MT21C to another series

Change in v4:
1.Change V4L2_PIX_FMT_MT21 to v4l2_PIX_FMT_MT21C
2.Fix g/s_selection implementation
3.Refine code according to review comments and pass V4l2-compliance test

-/bin/sh: v4l2: not found

# v4l2-compliance -d /dev/video0
v4l2-compliance SHA   : fc45cdc502065bc1dfb4ef9ceb9a822bb9877bce

Driver Info:

        Driver name   : mtk-vcodec-dec
        Card type     : platform:mt8173
        Bus info      : platform:mt8173

Driver version: 4.8.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 2 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK
test Scaling: OK

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK

Test input 0:

Total: 43, Succeeded: 43, Failed: 0, Warnings: 0

Change in v3:
1. Refine vdec hw clock setting
2. Refine vp9 codec driver
3. Refine v4l2 codec driver

Change in v2:
1. Add documentation for V4L2_PIX_FMT_MT21 2. Remove DRM_FORMAT_MT21 2. Refine code according to review comments

Andrew-CT Chen (1):
VPU: mediatek: Add decode support

Tiffany Lin (10):
dt-bindings: Add a binding for Mediatek Video Decoder
vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver
vcodec: mediatek: Add Mediatek H264 Video Decoder Drive
vcodec: mediatek: Add Mediatek VP8 Video Decoder Driver Add documentation for V4L2_PIX_FMT_VP9.
vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver
v4l: add Mediatek compressed video block format
docs-rst: Add compressed video formats used on MT8173 codec driver
vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
arm64: dts: mediatek: Add Video Decoder for MT8173

Wu-Cheng Li (2):
videodev2.h: add V4L2_PIX_FMT_VP9 format.
v4l2-ioctl: add VP9 format description.

 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 +-
 Documentation/media/uapi/v4l/pixfmt-013.rst        |    8 +
 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |    6 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi           |   44 +
 drivers/media/platform/mtk-vcodec/Makefile         |   15 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1448 ++++++++++++++++++++
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  394 ++++++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  205 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   62 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |    8 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c    |    3 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c    |   33 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h    |    5 +
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |  506 +++++++
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |  633 +++++++++
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |  967 +++++++++++++
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c    |  122 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h    |  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c    |  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h    |   96 ++
 drivers/media/platform/mtk-vpu/mtk_vpu.c           |   12 +
 drivers/media/platform/mtk-vpu/mtk_vpu.h           |   27 +
 drivers/media/v4l2-core/v4l2-ioctl.c               |    2 +
 include/uapi/linux/videodev2.h                     |    2 +
 28 files changed, 5173 insertions(+), 26 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v5 1/9 VPU: mediatek: Add decode support

From: Andrew-CT Chen <[email protected]>

VPU driver add decode support

---
 drivers/media/platform/mtk-vpu/mtk_vpu.c |   12 ++++++++++++
 drivers/media/platform/mtk-vpu/mtk_vpu.h |   27 +++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
drivers/media/platform/mtk-vpu/mtk_vpu.c +12 -0
index c9bf58c..63510de 100644
@@ -134,6 +134,8 @@ struct vpu_wdt {
  *
  * @signaled:		the signal of vpu initialization completed
  * @fw_ver:		VPU firmware version
+ * @dec_capability:	decoder capability which is not used for now and
+ *			the value is reserved for future use
  * @enc_capability:	encoder capability which is not used for now and
  *			the value is reserved for future use
  * @wq:			wait queue for VPU initialization status
@@ -141,6 +143,7 @@ struct vpu_wdt {
 struct vpu_run {
 	u32 signaled;
 	char fw_ver[VPU_FW_VER_LEN];
+	unsigned int	dec_capability;
 	unsigned int	enc_capability;
 	wait_queue_head_t wq;
 };
@@ -415,6 +418,14 @@ int vpu_wdt_reg_handler(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(vpu_wdt_reg_handler);
 
+unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev)
+{
+	struct mtk_vpu *vpu = platform_get_drvdata(pdev);
+
+	return vpu->run.dec_capability;
+}
+EXPORT_SYMBOL_GPL(vpu_get_vdec_hw_capa);
+
 unsigned int vpu_get_venc_hw_capa(struct platform_device *pdev)
 {
 	struct mtk_vpu *vpu = platform_get_drvdata(pdev);
@@ -600,6 +611,7 @@ static void vpu_init_ipi_handler(void *data, unsigned int len, void *priv)
 
 	vpu->run.signaled = run->signaled;
 	strncpy(vpu->run.fw_ver, run->fw_ver, VPU_FW_VER_LEN);
+	vpu->run.dec_capability = run->dec_capability;
 	vpu->run.enc_capability = run->enc_capability;
 	wake_up_interruptible(&vpu->run.wq);
 }
drivers/media/platform/mtk-vpu/mtk_vpu.h +27 -0
index 5ab37f0..f457479 100644
@@ -37,6 +37,18 @@ typedef void (*ipi_handler_t) (void *data,
 			 command to VPU.
 			 For other IPI below, AP should send the request
 			 to VPU to trigger the interrupt.
+ * @IPI_VDEC_H264:	 The interrupt from vpu is to notify kernel to
+			 handle H264 vidoe decoder job, and vice versa.
+			 Decode output format is always MT21 no matter what
+			 the input format is.
+ * @IPI_VDEC_VP8:	 The interrupt from is to notify kernel to
+			 handle VP8 video decoder job, and vice versa.
+			 Decode output format is always MT21 no matter what
+			 the input format is.
+ * @IPI_VDEC_VP9:	 The interrupt from vpu is to notify kernel to
+			 handle VP9 video decoder job, and vice versa.
+			 Decode output format is always MT21 no matter what
+			 the input format is.
  * @IPI_VENC_H264:	 The interrupt from vpu is to notify kernel to
 			 handle H264 video encoder job, and vice versa.
  * @IPI_VENC_VP8:	 The interrupt fro vpu is to notify kernel to
@@ -46,6 +58,9 @@ typedef void (*ipi_handler_t) (void *data,
 
 enum ipi_id {
 	IPI_VPU_INIT = 0,
+	IPI_VDEC_H264,
+	IPI_VDEC_VP8,
+	IPI_VDEC_VP9,
 	IPI_VENC_H264,
 	IPI_VENC_VP8,
 	IPI_MAX,
@@ -55,10 +70,12 @@ enum ipi_id {
  * enum rst_id - reset id to register reset function for VPU watchdog timeout
  *
  * @VPU_RST_ENC: encoder reset id
+ * @VPU_RST_DEC: decoder reset id
  * @VPU_RST_MAX: maximum reset id
  */
 enum rst_id {
 	VPU_RST_ENC,
+	VPU_RST_DEC,
 	VPU_RST_MAX,
 };
 
@@ -125,6 +142,16 @@ struct platform_device *vpu_get_plat_device(struct platform_device *pdev);
 int vpu_wdt_reg_handler(struct platform_device *pdev,
 			void vpu_wdt_reset_func(void *),
 			void *priv, enum rst_id id);
+
+/**
+ * vpu_get_vdec_hw_capa - get video decoder hardware capability
+ *
+ * @pdev:	VPU platform device
+ *
+ * Return: video decoder hardware capability
+ **/
+unsigned int vpu_get_vdec_hw_capa(struct platform_device *pdev);
+
 /**
  * vpu_get_venc_hw_capa - get video encoder hardware capability
  *
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v5 2/9 dt-bindings: Add a binding for Mediatek Video Decoder

Add a DT binding documentation of Video Decoder for the MT8173 SoC from Mediatek.

---
 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 ++++++++++++++++++--
 1 file changed, 53 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/media/mediatek-vcodec.txt +53 -4
index 59a47a5..46c15c5 100644
@@ -1,25 +1,74 @@
 Mediatek Video Codec
 
 Mediatek Video Codec is the video codec hw present in Mediatek SoCs which
-supports high resolution encoding functionalities.
+supports high resolution encoding and decoding functionalities.
 
 Required properties:
 - compatible : "mediatek,mt8173-vcodec-enc" for encoder
+  "mediatek,mt8173-vcodec-dec" for decoder.
 - reg : Physical base address of the video codec registers and length of
   memory mapped region.
 - interrupts : interrupt number to the cpu.
 - mediatek,larb : must contain the local arbiters in the current Socs.
 - clocks : list of clock specifiers, corresponding to entries in
   the clock-names property.
-- clock-names: encoder must contain "venc_sel_src", "venc_sel",
-- "venc_lt_sel_src", "venc_lt_sel".
+- clock-names: encoder must contain "venc_sel_src", "venc_sel",,
+  "venc_lt_sel_src", "venc_lt_sel", decoder must contain "vcodecpll",
+  "univpll_d2", "clk_cci400_sel", "vdec_sel", "vdecpll", "vencpll",
+  "venc_lt_sel", "vdec_bus_clk_src".
 - iommus : should point to the respective IOMMU block with master port as
   argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
   for details.
 - mediatek,vpu : the node of video processor unit
 
+
 Example:
-vcodec_enc: vcodec at 0x18002000 {
+
+vcodec_dec: vcodec at 16000000 {
+    compatible = "mediatek,mt8173-vcodec-dec";
+    reg = <0 0x16000000 0 0x100>,   /*VDEC_SYS*/
+          <0 0x16020000 0 0x1000>,  /*VDEC_MISC*/
+          <0 0x16021000 0 0x800>,   /*VDEC_LD*/
+          <0 0x16021800 0 0x800>,   /*VDEC_TOP*/
+          <0 0x16022000 0 0x1000>,  /*VDEC_CM*/
+          <0 0x16023000 0 0x1000>,  /*VDEC_AD*/
+          <0 0x16024000 0 0x1000>,  /*VDEC_AV*/
+          <0 0x16025000 0 0x1000>,  /*VDEC_PP*/
+          <0 0x16026800 0 0x800>,   /*VP8_VD*/
+          <0 0x16027000 0 0x800>,   /*VP6_VD*/
+          <0 0x16027800 0 0x800>,   /*VP8_VL*/
+          <0 0x16028400 0 0x400>;   /*VP9_VD*/
+    interrupts = <GIC_SPI 204 IRQ_TYPE_LEVEL_LOW>;
+    mediatek,larb = <&larb1>;
+    iommus = <&iommu M4U_PORT_HW_VDEC_MC_EXT>,
+             <&iommu M4U_PORT_HW_VDEC_PP_EXT>,
+             <&iommu M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+             <&iommu M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+             <&iommu M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+             <&iommu M4U_PORT_HW_VDEC_UFO_EXT>,
+             <&iommu M4U_PORT_HW_VDEC_VLD_EXT>,
+             <&iommu M4U_PORT_HW_VDEC_VLD2_EXT>;
+    mediatek,vpu = <&vpu>;
+    power-domains = <&scpsys MT8173_POWER_DOMAIN_VDEC>;
+    clocks = <&apmixedsys CLK_APMIXED_VCODECPLL>,
+             <&topckgen CLK_TOP_UNIVPLL_D2>,
+             <&topckgen CLK_TOP_CCI400_SEL>,
+             <&topckgen CLK_TOP_VDEC_SEL>,
+             <&topckgen CLK_TOP_VCODECPLL>,
+             <&apmixedsys CLK_APMIXED_VENCPLL>,
+             <&topckgen CLK_TOP_VENC_LT_SEL>,
+             <&topckgen CLK_TOP_VCODECPLL_370P5>;
+    clock-names = "vcodecpll",
+                  "univpll_d2",
+                  "clk_cci400_sel",
+                  "vdec_sel",
+                  "vdecpll",
+                  "vencpll",
+                  "venc_lt_sel",
+                  "vdec_bus_clk_src";
+  };
+
+  vcodec_enc: vcodec at 0x18002000 {
     compatible = "mediatek,mt8173-vcodec-enc";
     reg = <0 0x18002000 0 0x1000>,    /*VENC_SYS*/
           <0 0x19002000 0 0x1000>;    /*VENC_LT_SYS*/
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v5 3/9 vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

Add v4l2 layer decoder driver for MT8173

---
 drivers/media/platform/mtk-vcodec/Makefile         |   12 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1433 ++++++++++++++++++++
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  394 ++++++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  205 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   62 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |    8 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c    |    3 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c    |   33 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h    |    5 +
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   55 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c    |  112 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h    |  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c    |  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h    |   96 ++
 17 files changed, 2884 insertions(+), 22 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
drivers/media/platform/mtk-vcodec/Makefile +9 -3
index dc5cb00..b54e823 100644
@@ -1,7 +1,13 @@
 
-
-obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-enc.o mtk-vcodec-common.o
-
+obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
+				       mtk-vcodec-enc.o \
+				       mtk-vcodec-common.o
+
+mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
+		vdec_drv_if.o \
+		vdec_vpu_if.o \
+		mtk_vcodec_dec.o \
+		mtk_vcodec_dec_pm.o \
 
 
 mtk-vcodec-enc-y := venc/venc_vp8_if.o \
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c new file +1433 -0

1,433 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h new file +88 -0

88 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c new file +394 -0

394 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c new file +205 -0

205 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h new file +28 -0
new file mode 100644
index 0000000..b8bf56f
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2016 MediaTek Inc.
+* Author: Tiffany Lin <[email protected]>
+*
+* 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.
+*/
+
+#ifndef _MTK_VCODEC_DEC_PM_H_
+#define _MTK_VCODEC_DEC_PM_H_
+
+#include "mtk_vcodec_drv.h"
+
+int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *dev);
+void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev);
+
+void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm);
+void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm);
+void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm);
+void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm);
+
+#endif /* _MTK_VCODEC_DEC_PM_H_ */
drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h +57 -5

173 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c +1 -7
index 5cd2151..aa81f3c 100644
@@ -188,7 +188,6 @@ static int fops_vcodec_open(struct file *file)
 	mtk_v4l2_debug(2, "Create instance [%d]@%p m2m_ctx=%p ",
 			ctx->id, ctx, ctx->m2m_ctx);
 
-	dev->num_instances++;
 	list_add(&ctx->list, &dev->ctx_list);
 
 	mutex_unlock(&dev->dev_mutex);
@@ -218,18 +217,13 @@ static int fops_vcodec_release(struct file *file)
 	mtk_v4l2_debug(1, "[%d] encoder", ctx->id);
 	mutex_lock(&dev->dev_mutex);
 
-	/*
-	 * Call v4l2_m2m_ctx_release to make sure the worker thread is not
-	 * running after venc_if_deinit.
-	 */
-	v4l2_m2m_ctx_release(ctx->m2m_ctx);
 	mtk_vcodec_enc_release(ctx);
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
 	v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
+	v4l2_m2m_ctx_release(ctx->m2m_ctx);
 
 	list_del_init(&ctx->list);
-	dev->num_instances--;
 	kfree(ctx);
 	mutex_unlock(&dev->dev_mutex);
 	return 0;
drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c +1 -2
index 52e7e5c..113b209 100644
@@ -30,8 +30,7 @@ int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx  *ctx, int command,
 	timeout_jiff = msecs_to_jiffies(timeout_ms);
 
 	ret = wait_event_interruptible_timeout(*waitqueue,
-				(ctx->int_cond &&
-				(ctx->int_type == command)),
+				ctx->int_cond,
 				timeout_jiff);
 
 	if (!ret) {
drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c +28 -5
index 5e36513..46768c0 100644
@@ -81,14 +81,37 @@ void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
 		return;
 	}
 
-	dma_free_coherent(dev, size, mem->va, mem->dma_addr);
-	mem->va = NULL;
-	mem->dma_addr = 0;
-	mem->size = 0;
-
 	mtk_v4l2_debug(3, "[%d]  - va      = %p", ctx->id, mem->va);
 	mtk_v4l2_debug(3, "[%d]  - dma     = 0x%lx", ctx->id,
 		       (unsigned long)mem->dma_addr);
 	mtk_v4l2_debug(3, "[%d]    size = 0x%lx", ctx->id, size);
+
+	dma_free_coherent(dev, size, mem->va, mem->dma_addr);
+	mem->va = NULL;
+	mem->dma_addr = 0;
+	mem->size = 0;
 }
 EXPORT_SYMBOL(mtk_vcodec_mem_free);
+
+void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *dev,
+	struct mtk_vcodec_ctx *ctx)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&dev->irqlock, flags);
+	dev->curr_ctx = ctx;
+	spin_unlock_irqrestore(&dev->irqlock, flags);
+}
+EXPORT_SYMBOL(mtk_vcodec_set_curr_ctx);
+
+struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *dev)
+{
+	unsigned long flags;
+	struct mtk_vcodec_ctx *ctx;
+
+	spin_lock_irqsave(&dev->irqlock, flags);
+	ctx = dev->curr_ctx;
+	spin_unlock_irqrestore(&dev->irqlock, flags);
+	return ctx;
+}
+EXPORT_SYMBOL(mtk_vcodec_get_curr_ctx);
drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h +5 -0
index d6345fc..7d55975 100644
@@ -26,6 +26,7 @@ struct mtk_vcodec_mem {
 };
 
 struct mtk_vcodec_ctx;
+struct mtk_vcodec_dev;
 
 extern int mtk_v4l2_dbg_level;
 extern bool mtk_vcodec_dbg;
@@ -84,4 +85,8 @@ int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
 				struct mtk_vcodec_mem *mem);
 void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
 				struct mtk_vcodec_mem *mem);
+void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *dev,
+	struct mtk_vcodec_ctx *ctx);
+struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *dev);
+
 #endif /* _MTK_VCODEC_UTIL_H_ */
drivers/media/platform/mtk-vcodec/vdec_drv_base.h new file +55 -0

55 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/vdec_drv_if.c new file +112 -0

112 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/vdec_drv_if.h new file +101 -0

101 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h new file +103 -0

103 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/vdec_vpu_if.c new file +168 -0

168 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/vdec_vpu_if.h new file +96 -0

32 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.5

Part of the diff is not shown here. View the raw message.

#4 lore raw

PATCH v5 4/9 vcodec: mediatek: Add Mediatek H264 Video Decoder Drive

Add h264 decoder driver for MT8173

---
 drivers/media/platform/mtk-vcodec/Makefile         |    3 +-
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |  506 ++++++++++++++++++++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c    |    3 +
 3 files changed, 511 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
drivers/media/platform/mtk-vcodec/Makefile +2 -1
index b54e823..58243ed 100644
@@ -3,7 +3,8 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
 				       mtk-vcodec-enc.o \
 				       mtk-vcodec-common.o
 
-mtk-vcodec-dec-y := mtk_vcodec_dec_drv.o \
+mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
+		mtk_vcodec_dec_drv.o \
 		vdec_drv_if.o \
 		vdec_vpu_if.o \
 		mtk_vcodec_dec.o \
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c new file +506 -0

506 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/vdec_drv_if.c +3 -0
index 3cb04ef..678b1f7 100644
@@ -23,6 +23,7 @@
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vpu.h"
 
+const struct vdec_common_if *get_h264_dec_comm_if(void);
 
 int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 {
@@ -30,6 +31,8 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 
 	switch (fourcc) {
 	case V4L2_PIX_FMT_H264:
+		ctx->dec_if = get_h264_dec_comm_if();
+		break;
 	case V4L2_PIX_FMT_VP8:
 	default:
 		return -EINVAL;
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v5 5/9 vcodec: mediatek: Add Mediatek VP8 Video Decoder Driver

Add vp8 decoder driver for MT8173

---
 drivers/media/platform/mtk-vcodec/Makefile         |    1 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |  633 ++++++++++++++++++++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c    |    3 +
 3 files changed, 637 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
drivers/media/platform/mtk-vcodec/Makefile +1 -0
index 58243ed..7743c81 100644
@@ -4,6 +4,7 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
 				       mtk-vcodec-common.o
 
 mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
+		vdec/vdec_vp8_if.o \
 		mtk_vcodec_dec_drv.o \
 		vdec_drv_if.o \
 		vdec_vpu_if.o \
drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c new file +633 -0

633 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/vdec_drv_if.c +3 -0
index 678b1f7..25c7cb9 100644
@@ -24,6 +24,7 @@
 #include "mtk_vpu.h"
 
 const struct vdec_common_if *get_h264_dec_comm_if(void);
+const struct vdec_common_if *get_vp8_dec_comm_if(void);
 
 int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 {
@@ -34,6 +35,8 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 		ctx->dec_if = get_h264_dec_comm_if();
 		break;
 	case V4L2_PIX_FMT_VP8:
+		ctx->dec_if = get_vp8_dec_comm_if();
+		break;
 	default:
 		return -EINVAL;
 	}
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v5 6/9 videodev2.h: add V4L2_PIX_FMT_VP9 format.

From: Wu-Cheng Li <[email protected]>

This adds VP9 video coding format, a successor to VP8.

---
 include/uapi/linux/videodev2.h |    1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/videodev2.h +1 -0
index 5529741..43326c3 100644
@@ -603,6 +603,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') /* SMPTE 421M Annex G compliant stream */
 #define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M Annex L compliant stream */
 #define V4L2_PIX_FMT_VP8      v4l2_fourcc('V', 'P', '8', '0') /* VP8 */
+#define V4L2_PIX_FMT_VP9      v4l2_fourcc('V', 'P', '9', '0') /* VP9 */
 
 /*  Vendor-specific formats   */
 #define V4L2_PIX_FMT_CPIA1    v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v5 7/9 v4l2-ioctl: add VP9 format description.

From: Wu-Cheng Li <[email protected]>

VP9 is a video coding format and a successor to VP8.

---
 drivers/media/v4l2-core/v4l2-ioctl.c |    1 +
 1 file changed, 1 insertion(+)
drivers/media/v4l2-core/v4l2-ioctl.c +1 -0
index eb6ccc7..2bd1581 100644
@@ -1269,6 +1269,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 		case V4L2_PIX_FMT_VC1_ANNEX_G:	descr = "VC-1 (SMPTE 412M Annex G)"; break;
 		case V4L2_PIX_FMT_VC1_ANNEX_L:	descr = "VC-1 (SMPTE 412M Annex L)"; break;
 		case V4L2_PIX_FMT_VP8:		descr = "VP8"; break;
+		case V4L2_PIX_FMT_VP9:		descr = "VP9"; break;
 		case V4L2_PIX_FMT_CPIA1:	descr = "GSPCA CPiA YUV"; break;
 		case V4L2_PIX_FMT_WNVA:		descr = "WNVA"; break;
 		case V4L2_PIX_FMT_SN9C10X:	descr = "GSPCA SN9C10X"; break;
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v5 8/9 Add documentation for V4L2_PIX_FMT_VP9.

Add documentation for V4L2_PIX_FMT_VP9.

---
 Documentation/media/uapi/v4l/pixfmt-013.rst |    8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/media/uapi/v4l/pixfmt-013.rst +8 -0
index bfef4f4..58e3ce6 100644
@@ -129,3 +129,11 @@ Compressed Formats
        -  'VP80'
 
        -  VP8 video elementary stream.
+
+    -  .. _V4L2-PIX-FMT-VP9:
+
+       -  ``V4L2_PIX_FMT_VP9``
+
+       -  'VP90'
+
+       -  VP9 video elementary stream.
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v5 9/9 vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver

Add vp9 decoder driver for MT8173

---
 drivers/media/platform/mtk-vcodec/Makefile         |    1 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c |   10 +
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |  967 ++++++++++++++++++++
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |    1 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c    |    4 +
 5 files changed, 983 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
drivers/media/platform/mtk-vcodec/Makefile +1 -0
index 7743c81..852d969 100644
@@ -5,6 +5,7 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
 
 mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
 		vdec/vdec_vp8_if.o \
+		vdec/vdec_vp9_if.o \
 		mtk_vcodec_dec_drv.o \
 		vdec_drv_if.o \
 		vdec_vpu_if.o \
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +10 -0
index d634e61..28a8453 100644
@@ -43,6 +43,11 @@ static struct mtk_video_fmt mtk_video_formats[] = {
 		.type = MTK_FMT_DEC,
 		.num_planes = 1,
 	},
+	{
+		.fourcc = V4L2_PIX_FMT_VP9,
+		.type = MTK_FMT_DEC,
+		.num_planes = 1,
+	},
 };
 
 static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
@@ -56,6 +61,11 @@ static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
 		.stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
 				MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
 	},
+	{
+		.fourcc = V4L2_PIX_FMT_VP9,
+		.stepwise = {  MTK_VDEC_MIN_W, MTK_VDEC_MAX_W, 16,
+				MTK_VDEC_MIN_H, MTK_VDEC_MAX_H, 16 },
+	},
 };
 
 #define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes)
drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c new file +967 -0

967 lines not on this page · raw message

drivers/media/platform/mtk-vcodec/vdec_drv_base.h +1 -0
index ca022e3..7e4c1a9 100644
@@ -17,6 +17,7 @@
 
 #include "mtk_vcodec_drv.h"
 
+#include "vdec_drv_if.h"
 
 struct vdec_common_if {
 	/**
drivers/media/platform/mtk-vcodec/vdec_drv_if.c +4 -0
index 25c7cb9..5ffc468 100644
@@ -25,6 +25,7 @@
 
 const struct vdec_common_if *get_h264_dec_comm_if(void);
 const struct vdec_common_if *get_vp8_dec_comm_if(void);
+const struct vdec_common_if *get_vp9_dec_comm_if(void);
 
 int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 {
@@ -37,6 +38,9 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 	case V4L2_PIX_FMT_VP8:
 		ctx->dec_if = get_vp8_dec_comm_if();
 		break;
+	case V4L2_PIX_FMT_VP9:
+		ctx->dec_if = get_vp9_dec_comm_if();
+		break;
 	default:
 		return -EINVAL;
 	}
Signature · 1 line
1.7.9.5
#10 lore raw

Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

In reply to Tiffany Lin

Em Fri, 2 Sep 2016 20:19:54 +0800
Tiffany Lin <[email protected]> escreveu:

Quoted 4 lines

Add v4l2 layer decoder driver for MT8173

Review

Quoted 10 lines
(quoted diff) +10 -0
+int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
+{
+	int ret = 0;
+
+	switch (fourcc) {
+	case V4L2_PIX_FMT_H264:
+	case V4L2_PIX_FMT_VP8:
+	default:
+		return -EINVAL;
+	}

Did you ever test this driver? The above code will *always* return -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!

I suspect that what you wanted to do, instead, is:

	switch (fourcc) {
	case V4L2_PIX_FMT_H264:
	case V4L2_PIX_FMT_VP8:
		break;
	default:
		return -EINVAL;

Btw, this patch series has also several issues that were pointed by checkpatch. Please *always* run checkpatch when submitting your work.

You should take a look at the Kernel documentation about how to submit patches, at:
https://mchehab.fedorapeople.org/kernel_docs/process/index.html

PS.: this time, I fixed the checkpatch issues for you. So, let me know if the patch below is OK, and I'll merge it at media upstream, assuming that the other patches in this series are ok.

Signature · 18 lines
Thanks,
Mauro

[PATCH] mtk-vcodec: fix some smatch warnings

Fix this bug:
	drivers/media/platform/mtk-vcodec/vdec_drv_if.c:38 vdec_if_init() info: ignoring unreachable code.

With is indeed a real problem that prevents the driver to work!

While here, also remove an used var, as reported by smatch:

	drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c: In function 'mtk_vcodec_init_dec_pm':
	drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c:29:17: warning: variable 'dev' set but not used [-Wunused-but-set-variable]
	  struct device *dev;
	                 ^~~

Signed-off-by: Mauro Carvalho Chehab <[email protected]>
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c +0 -2
index 18182f5676d8..79ca03ac449c 100644
@@ -26,14 +26,12 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
 {
 	struct device_node *node;
 	struct platform_device *pdev;
-	struct device *dev;
 	struct mtk_vcodec_pm *pm;
 	int ret = 0;
 
 	pdev = mtkdev->plat_dev;
 	pm = &mtkdev->pm;
 	pm->mtkdev = mtkdev;
-	dev = &pdev->dev;
 	node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
 	if (!node) {
 		mtk_v4l2_err("of_parse_phandle mediatek,larb fail!");
drivers/media/platform/mtk-vcodec/vdec_drv_if.c +1 -0
index 3cb04ef45144..9813b2ffd5fa 100644
@@ -31,6 +31,7 @@ int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
 	switch (fourcc) {
 	case V4L2_PIX_FMT_H264:
 	case V4L2_PIX_FMT_VP8:
+		break;
 	default:
 		return -EINVAL;
 	}
#11 lore raw

Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

Em Fri, 21 Oct 2016 11:01:04 -0200
Mauro Carvalho Chehab <[email protected]> escreveu:

Quoted 21 lines

Em Fri, 2 Sep 2016 20:19:54 +0800
Tiffany Lin <[email protected]> escreveu:

Quoted 4 lines

Add v4l2 layer decoder driver for MT8173

Review

Quoted 10 lines
(quoted diff) +10 -0
+int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
+{
+	int ret = 0;
+
+	switch (fourcc) {
+	case V4L2_PIX_FMT_H264:
+	case V4L2_PIX_FMT_VP8:
+	default:
+		return -EINVAL;
+	}  

Did you ever test this driver? The above code will *always* return -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!

Quoted 8 lines

I suspect that what you wanted to do, instead, is:

	switch (fourcc) {
	case V4L2_PIX_FMT_H264:
	case V4L2_PIX_FMT_VP8:
		break;
	default:
		return -EINVAL;

Yeah, a latter patch in this series added a break there.

Thanks,
Mauro

#12 lore raw

Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

In reply to Mauro Carvalho Chehab

Hi Mauro,

Quoted 21 lines · Mauro Carvalho Chehab

Em Fri, 2 Sep 2016 20:19:54 +0800
Tiffany Lin <[email protected]> escreveu:

Quoted 4 lines

Add v4l2 layer decoder driver for MT8173

Review

Quoted 10 lines
(quoted diff) +10 -0
+int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
+{
+	int ret = 0;
+
+	switch (fourcc) {
+	case V4L2_PIX_FMT_H264:
+	case V4L2_PIX_FMT_VP8:
+	default:
+		return -EINVAL;
+	}

Did you ever test this driver? The above code will *always* return -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!

Quoted 9 lines

I suspect that what you wanted to do, instead, is:

	switch (fourcc) {
	case V4L2_PIX_FMT_H264:
	case V4L2_PIX_FMT_VP8:
		break;
	default:
		return -EINVAL;

The original idea here is that vp8 and h264 are added in later patches. If get this patch without later patches, it should return -EINVAL.

Quoted 11 lines

Btw, this patch series has also several issues that were pointed by checkpatch. Please *always* run checkpatch when submitting your work.

You should take a look at the Kernel documentation about how to submit patches, at:
https://mchehab.fedorapeople.org/kernel_docs/process/index.html

PS.: this time, I fixed the checkpatch issues for you. So, let me know if the patch below is OK, and I'll merge it at media upstream, assuming that the other patches in this series are ok.

I did run checkpatch, but I don't know why these issues missed. probably I run checkpatch for all files not for patches.
I will take a look at the documentation and keep this in mind for future upstream.
Appreciated for your help.

best regards,
Tiffany

#13 lore raw

Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

Em Mon, 24 Oct 2016 11:22:08 +0800
Tiffany Lin <[email protected]> escreveu:

Quoted 34 lines

Hi Mauro,

Quoted 21 lines · Mauro Carvalho Chehab

Em Fri, 2 Sep 2016 20:19:54 +0800
Tiffany Lin <[email protected]> escreveu:

Quoted 4 lines

Add v4l2 layer decoder driver for MT8173

Review

Quoted 10 lines
(quoted diff) +10 -0
+int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
+{
+	int ret = 0;
+
+	switch (fourcc) {
+	case V4L2_PIX_FMT_H264:
+	case V4L2_PIX_FMT_VP8:
+	default:
+		return -EINVAL;
+	}  

Did you ever test this driver? The above code will *always* return -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!

Quoted 9 lines

I suspect that what you wanted to do, instead, is:

	switch (fourcc) {
	case V4L2_PIX_FMT_H264:
	case V4L2_PIX_FMT_VP8:
		break;
	default:
		return -EINVAL;
Quoted 2 lines

The original idea here is that vp8 and h264 are added in later patches. If get this patch without later patches, it should return -EINVAL.

I noticed your idea, but next time, don't add dead code like that. Reviewers check patch by patch at the order they're present at the patch series.

So, don't add something broken by purpose, assuming that it would be fixed later.

Quoted 14 lines
Quoted 5 lines

Btw, this patch series has also several issues that were pointed by checkpatch. Please *always* run checkpatch when submitting your work.

Quoted 8 lines

You should take a look at the Kernel documentation about how to submit patches, at:
https://mchehab.fedorapeople.org/kernel_docs/process/index.html

PS.: this time, I fixed the checkpatch issues for you. So, let me know if the patch below is OK, and I'll merge it at media upstream, assuming that the other patches in this series are ok.

Quoted 5 lines

I did run checkpatch, but I don't know why these issues missed. probably I run checkpatch for all files not for patches.
I will take a look at the documentation and keep this in mind for future upstream.
Appreciated for your help.

Checkpatch should be run patch by patch, as we expect that all patches will follow the coding style and will compile fine, without introducing warnings.

I do compile the Kernel for every single patch I merge.

Regards,
Mauro

#14 lore raw

Re: [PATCH v5 3/9] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver

Hi Mauro,

Quoted 40 lines · Mauro Carvalho Chehab

Em Mon, 24 Oct 2016 11:22:08 +0800
Tiffany Lin <[email protected]> escreveu:

Quoted 34 lines

Hi Mauro,

Quoted 21 lines · Mauro Carvalho Chehab

Em Fri, 2 Sep 2016 20:19:54 +0800
Tiffany Lin <[email protected]> escreveu:

Quoted 4 lines

Add v4l2 layer decoder driver for MT8173

Review

Quoted 10 lines
(quoted diff) +10 -0
+int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc)
+{
+	int ret = 0;
+
+	switch (fourcc) {
+	case V4L2_PIX_FMT_H264:
+	case V4L2_PIX_FMT_VP8:
+	default:
+		return -EINVAL;
+	}  

Did you ever test this driver? The above code will *always* return -EINVAL, with will cause vidioc_vdec_s_fmt() to always fail!

Quoted 9 lines

I suspect that what you wanted to do, instead, is:

	switch (fourcc) {
	case V4L2_PIX_FMT_H264:
	case V4L2_PIX_FMT_VP8:
		break;
	default:
		return -EINVAL;
Quoted 2 lines

The original idea here is that vp8 and h264 are added in later patches. If get this patch without later patches, it should return -EINVAL.

Quoted 7 lines

I noticed your idea, but next time, don't add dead code like that. Reviewers check patch by patch at the order they're present at the patch series.

So, don't add something broken by purpose, assuming that it would be fixed later.

Got it.

Quoted 20 lines
Quoted 14 lines
Quoted 5 lines

Btw, this patch series has also several issues that were pointed by checkpatch. Please *always* run checkpatch when submitting your work.

Quoted 8 lines

You should take a look at the Kernel documentation about how to submit patches, at:
https://mchehab.fedorapeople.org/kernel_docs/process/index.html

PS.: this time, I fixed the checkpatch issues for you. So, let me know if the patch below is OK, and I'll merge it at media upstream, assuming that the other patches in this series are ok.

Quoted 5 lines

I did run checkpatch, but I don't know why these issues missed. probably I run checkpatch for all files not for patches.
I will take a look at the documentation and keep this in mind for future upstream.
Appreciated for your help.

Quoted 6 lines

Checkpatch should be run patch by patch, as we expect that all patches will follow the coding style and will compile fine, without introducing warnings.

I do compile the Kernel for every single patch I merge.

Got it. I will follow this.

best regards,
Tiffany

Quoted 2 lines

Regards,
Mauro

#15 lore raw
In reply to Tiffany Lin
Quoted 7 lines · Tiffany Lin

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

Quoted 6 lines

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

This patch series fails to apply to the media_tree master (patch 3/9). Can you rebase and repost?

I'm ready to make a pull request for this, so I hope you can fix this soon.

Thanks!

Hans

Quoted 186 lines

==================
Device interface
==================

In principle the driver bases on v4l2 memory-to-memory framework:
it provides a single video node and each opened file handle gets its own private context with separate buffer queues. Each context consist of 2 buffer
queues: OUTPUT (for source buffers, i.e. bitstream) and CAPTURE (for destination buffers, i.e. decoded video frames).
OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.

Change in v5:
1. Merge wucheng's V4L2_PIX_FMT_VP9 series to this series
V4L: add VP9 format documentation
v4l2-ioctl: add VP9 format description. videodev2.h: add V4L2_PIX_FMT_VP9 format.
2. Remove V4L2_PIX_FMT_MT21C to another series

Change in v4:
1.Change V4L2_PIX_FMT_MT21 to v4l2_PIX_FMT_MT21C
2.Fix g/s_selection implementation
3.Refine code according to review comments and pass V4l2-compliance test

-/bin/sh: v4l2: not found

# v4l2-compliance -d /dev/video0
v4l2-compliance SHA   : fc45cdc502065bc1dfb4ef9ceb9a822bb9877bce

Driver Info:

        Driver name   : mtk-vcodec-dec
        Card type     : platform:mt8173
        Bus info      : platform:mt8173

Driver version: 4.8.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 2 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK
test Scaling: OK

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK

Test input 0:

Total: 43, Succeeded: 43, Failed: 0, Warnings: 0

Change in v3:
1. Refine vdec hw clock setting
2. Refine vp9 codec driver
3. Refine v4l2 codec driver

Change in v2:
1. Add documentation for V4L2_PIX_FMT_MT21 2. Remove DRM_FORMAT_MT21 2. Refine code according to review comments

Andrew-CT Chen (1):
VPU: mediatek: Add decode support

Tiffany Lin (10):
dt-bindings: Add a binding for Mediatek Video Decoder
vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver
vcodec: mediatek: Add Mediatek H264 Video Decoder Drive
vcodec: mediatek: Add Mediatek VP8 Video Decoder Driver Add documentation for V4L2_PIX_FMT_VP9.
vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver
v4l: add Mediatek compressed video block format
docs-rst: Add compressed video formats used on MT8173 codec driver
vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
arm64: dts: mediatek: Add Video Decoder for MT8173

Wu-Cheng Li (2):
videodev2.h: add V4L2_PIX_FMT_VP9 format.
v4l2-ioctl: add VP9 format description.

 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 +-
 Documentation/media/uapi/v4l/pixfmt-013.rst        |    8 +
 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |    6 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi           |   44 +
 drivers/media/platform/mtk-vcodec/Makefile         |   15 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1448 ++++++++++++++++++++
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  394 ++++++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  205 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   62 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |    8 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c    |    3 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c    |   33 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h    |    5 +
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |  506 +++++++
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |  633 +++++++++
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |  967 +++++++++++++
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c    |  122 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h    |  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c    |  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h    |   96 ++
 drivers/media/platform/mtk-vpu/mtk_vpu.c           |   12 +
 drivers/media/platform/mtk-vpu/mtk_vpu.h           |   27 +
 drivers/media/v4l2-core/v4l2-ioctl.c               |    2 +
 include/uapi/linux/videodev2.h                     |    2 +
 28 files changed, 5173 insertions(+), 26 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
#16 lore raw

Hi Hans,

Quoted 11 lines · Hans Verkuil
Quoted 10 lines · Tiffany Lin

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Quoted 8 lines
Quoted 3 lines

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

This patch series fails to apply to the media_tree master (patch 3/9). Can you rebase and repost?

I'm ready to make a pull request for this, so I hope you can fix this soon.

I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches.

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder [media] vcodec:mediatek:code refine for v4l2 Encoder driver [media] dvb_frontend: Use memdup_user() rather than duplicating its implementation

If I do not rebase decoder patch series base on Encoder fix pathces. Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?

best regards,
Tiffany

Quoted 190 lines

Thanks!

Hans

Quoted 186 lines

==================
Device interface
==================

In principle the driver bases on v4l2 memory-to-memory framework:
it provides a single video node and each opened file handle gets its own private context with separate buffer queues. Each context consist of 2 buffer
queues: OUTPUT (for source buffers, i.e. bitstream) and CAPTURE (for destination buffers, i.e. decoded video frames).
OUTPUT and CAPTURE buffer could be MMAP or DMABUF memory type.

Change in v5:
1. Merge wucheng's V4L2_PIX_FMT_VP9 series to this series
V4L: add VP9 format documentation
v4l2-ioctl: add VP9 format description. videodev2.h: add V4L2_PIX_FMT_VP9 format.
2. Remove V4L2_PIX_FMT_MT21C to another series

Change in v4:
1.Change V4L2_PIX_FMT_MT21 to v4l2_PIX_FMT_MT21C
2.Fix g/s_selection implementation
3.Refine code according to review comments and pass V4l2-compliance test

-/bin/sh: v4l2: not found

# v4l2-compliance -d /dev/video0
v4l2-compliance SHA   : fc45cdc502065bc1dfb4ef9ceb9a822bb9877bce

Driver Info:

        Driver name   : mtk-vcodec-dec
        Card type     : platform:mt8173
        Bus info      : platform:mt8173

Driver version: 4.8.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 2 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK
test Scaling: OK

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK

Test input 0:

Total: 43, Succeeded: 43, Failed: 0, Warnings: 0

Change in v3:
1. Refine vdec hw clock setting
2. Refine vp9 codec driver
3. Refine v4l2 codec driver

Change in v2:
1. Add documentation for V4L2_PIX_FMT_MT21 2. Remove DRM_FORMAT_MT21 2. Refine code according to review comments

Andrew-CT Chen (1):
VPU: mediatek: Add decode support

Tiffany Lin (10):
dt-bindings: Add a binding for Mediatek Video Decoder
vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver
vcodec: mediatek: Add Mediatek H264 Video Decoder Drive
vcodec: mediatek: Add Mediatek VP8 Video Decoder Driver Add documentation for V4L2_PIX_FMT_VP9.
vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver
v4l: add Mediatek compressed video block format
docs-rst: Add compressed video formats used on MT8173 codec driver
vcodec: mediatek: Add V4L2_PIX_FMT_MT21C support for v4l2 decoder
arm64: dts: mediatek: Add Video Decoder for MT8173

Wu-Cheng Li (2):
videodev2.h: add V4L2_PIX_FMT_VP9 format.
v4l2-ioctl: add VP9 format description.

 .../devicetree/bindings/media/mediatek-vcodec.txt  |   57 +-
 Documentation/media/uapi/v4l/pixfmt-013.rst        |    8 +
 Documentation/media/uapi/v4l/pixfmt-reserved.rst   |    6 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi           |   44 +
 drivers/media/platform/mtk-vcodec/Makefile         |   15 +-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 1448 ++++++++++++++++++++
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h |   88 ++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  394 ++++++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c  |  205 +++
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h  |   28 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h |   62 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c |    8 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_intr.c    |    3 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.c    |   33 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_util.h    |    5 +
 .../media/platform/mtk-vcodec/vdec/vdec_h264_if.c  |  506 +++++++
 .../media/platform/mtk-vcodec/vdec/vdec_vp8_if.c   |  633 +++++++++
 .../media/platform/mtk-vcodec/vdec/vdec_vp9_if.c   |  967 +++++++++++++
 drivers/media/platform/mtk-vcodec/vdec_drv_base.h  |   56 +
 drivers/media/platform/mtk-vcodec/vdec_drv_if.c    |  122 ++
 drivers/media/platform/mtk-vcodec/vdec_drv_if.h    |  101 ++
 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h   |  103 ++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c    |  168 +++
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h    |   96 ++
 drivers/media/platform/mtk-vpu/mtk_vpu.c           |   12 +
 drivers/media/platform/mtk-vpu/mtk_vpu.h           |   27 +
 drivers/media/v4l2-core/v4l2-ioctl.c               |    2 +
 include/uapi/linux/videodev2.h                     |    2 +
 28 files changed, 5173 insertions(+), 26 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_base.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_drv_if.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
#17 lore raw
Quoted 38 lines · Tiffany Lin

Hi Hans,

Quoted 11 lines · Hans Verkuil
Quoted 10 lines · Tiffany Lin

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Quoted 8 lines
Quoted 3 lines

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

This patch series fails to apply to the media_tree master (patch 3/9). Can you rebase and repost?

I'm ready to make a pull request for this, so I hope you can fix this soon.

I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches.

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder [media] vcodec:mediatek:code refine for v4l2 Encoder driver [media] dvb_frontend: Use memdup_user() rather than duplicating its implementation

Quoted 4 lines

If I do not rebase decoder patch series base on Encoder fix pathces. Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?

Ah, OK. I will retest placing this on top of those fixes. I forgot about the pending fixes. I'll handle this.

Regards,

Hans

#18 lore raw
Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Tiffany Lin

Hi Hans,

Quoted 11 lines · Hans Verkuil
Quoted 10 lines · Tiffany Lin

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Quoted 8 lines
Quoted 3 lines

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

This patch series fails to apply to the media_tree master (patch 3/9). Can you rebase and repost?

I'm ready to make a pull request for this, so I hope you can fix this soon.

I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches.

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder [media] vcodec:mediatek:code refine for v4l2 Encoder driver [media] dvb_frontend: Use memdup_user() rather than duplicating its implementation

Quoted 7 lines
Quoted 4 lines

If I do not rebase decoder patch series base on Encoder fix pathces. Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?

Ah, OK. I will retest placing this on top of those fixes. I forgot about the pending fixes. I'll handle this.

OK, that works much better when it is on top of the fixes.

Only one thing is missing: an entry in the MAINTAINERS file. Strange that that wasn't done for the encoder driver, we must have missed that. So can you make a patch adding the en/decoder driver to this file? I'm ready to make the pull request once I have that.

Regards,

Hans

#19 lore raw

Hi Hans,

Quoted 48 lines · Hans Verkuil
Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Tiffany Lin

Hi Hans,

Quoted 11 lines · Hans Verkuil
Quoted 10 lines · Tiffany Lin

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Quoted 8 lines
Quoted 3 lines

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

This patch series fails to apply to the media_tree master (patch 3/9). Can you rebase and repost?

I'm ready to make a pull request for this, so I hope you can fix this soon.

I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches.

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder [media] vcodec:mediatek:code refine for v4l2 Encoder driver [media] dvb_frontend: Use memdup_user() rather than duplicating its implementation

Quoted 7 lines
Quoted 4 lines

If I do not rebase decoder patch series base on Encoder fix pathces. Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?

Ah, OK. I will retest placing this on top of those fixes. I forgot about the pending fixes. I'll handle this.

Quoted 7 lines

OK, that works much better when it is on top of the fixes.

Only one thing is missing: an entry in the MAINTAINERS file. Strange that that wasn't done for the encoder driver, we must have missed that. So can you make a patch adding the en/decoder driver to this file? I'm ready to make the pull request once I have that.

Got it. I will check and update it.

I have a question about decoder device node.
In v5 decoder patch series, I do not add device node patch at end of patch series.
I plain to put it in MT21C format patch series, is it ok?

best regards,
Tiffany

Quoted 3 lines

Regards,

Hans

#20 lore raw
Quoted 58 lines · Tiffany Lin

Hi Hans,

Quoted 48 lines · Hans Verkuil
Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Tiffany Lin

Hi Hans,

Quoted 11 lines · Hans Verkuil
Quoted 10 lines · Tiffany Lin

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Quoted 8 lines
Quoted 3 lines

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

This patch series fails to apply to the media_tree master (patch 3/9). Can you rebase and repost?

I'm ready to make a pull request for this, so I hope you can fix this soon.

I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches.

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder [media] vcodec:mediatek:code refine for v4l2 Encoder driver [media] dvb_frontend: Use memdup_user() rather than duplicating its implementation

Quoted 7 lines
Quoted 4 lines

If I do not rebase decoder patch series base on Encoder fix pathces. Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?

Ah, OK. I will retest placing this on top of those fixes. I forgot about the pending fixes. I'll handle this.

Quoted 7 lines

OK, that works much better when it is on top of the fixes.

Only one thing is missing: an entry in the MAINTAINERS file. Strange that that wasn't done for the encoder driver, we must have missed that. So can you make a patch adding the en/decoder driver to this file? I'm ready to make the pull request once I have that.

Quoted 6 lines

Got it. I will check and update it.

I have a question about decoder device node.
In v5 decoder patch series, I do not add device node patch at end of patch series.
I plain to put it in MT21C format patch series, is it ok?

What is the reason for not adding it in the decoder patch series?

Regards,

Hans

#21 lore raw

Hi Hans,

Quoted 59 lines · Hans Verkuil
Quoted 58 lines · Tiffany Lin

Hi Hans,

Quoted 55 lines · Hans Verkuil
Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Tiffany Lin

Hi Hans,

Quoted 11 lines · Hans Verkuil
Quoted 10 lines · Tiffany Lin

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Quoted 8 lines
Quoted 3 lines

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

This patch series fails to apply to the media_tree master (patch 3/9). Can you rebase and repost?

I'm ready to make a pull request for this, so I hope you can fix this soon.

I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches.

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder [media] vcodec:mediatek:code refine for v4l2 Encoder driver [media] dvb_frontend: Use memdup_user() rather than duplicating its implementation

Quoted 7 lines
Quoted 4 lines

If I do not rebase decoder patch series base on Encoder fix pathces. Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?

Ah, OK. I will retest placing this on top of those fixes. I forgot about the pending fixes. I'll handle this.

OK, that works much better when it is on top of the fixes.

Only one thing is missing: an entry in the MAINTAINERS file. Strange that that wasn't done for the encoder driver, we must have missed that. So can you make a patch adding the en/decoder driver to this file? I'm ready to make the pull request once I have that.

Quoted 9 lines
Quoted 6 lines

Got it. I will check and update it.

I have a question about decoder device node.
In v5 decoder patch series, I do not add device node patch at end of patch series.
I plain to put it in MT21C format patch series, is it ok?

What is the reason for not adding it in the decoder patch series?

It is because our decoder HW only support MT21C format.

best regards,
Tiffany

Quoted 3 lines

Regards,

Hans

#22 lore raw
Quoted 69 lines · Tiffany Lin

Hi Hans,

Quoted 66 lines · Hans Verkuil
Quoted 64 lines · Tiffany Lin

Hi Hans,

Quoted 48 lines · Hans Verkuil
Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Tiffany Lin

Hi Hans,

Quoted 11 lines · Hans Verkuil
Quoted 10 lines · Tiffany Lin

==============
Introduction
==============

The purpose of this series is to add the driver for video codec hw embedded in the Mediatek's MT8173 SoCs. Mediatek Video Codec is able to handle video decoding and encoding of in a range of formats.

This patch series rely on MTK VPU driver that have been merged in v4.8-rc1. Mediatek Video Decoder driver rely on VPU driver to load, communicate with VPU.

Quoted 8 lines
Quoted 3 lines

Internally the driver uses videobuf2 framework, and MTK IOMMU and MTK SMI both have been merged in v4.6-rc1.

[1]https://chromium-review.googlesource.com/#/c/245241/

This patch series fails to apply to the media_tree master (patch 3/9). Can you rebase and repost?

I'm ready to make a pull request for this, so I hope you can fix this soon.

I saw Encoder fix patches in fixes branch.
This patch series is base on Encoder fix patches.

[media] vcodec:mediatek: Refine VP8 encoder driver
[media] vcodec:mediatek: Refine H264 encoder driver
[media] vcodec:mediatek: change H264 profile default to profile high [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder
[media] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out
[media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder [media] vcodec:mediatek:code refine for v4l2 Encoder driver [media] dvb_frontend: Use memdup_user() rather than duplicating its implementation

Quoted 7 lines
Quoted 4 lines

If I do not rebase decoder patch series base on Encoder fix pathces. Then it will fail after Encoder fix patches merged.

May I know what parent patch I need to rebase to to fix this issue?

Ah, OK. I will retest placing this on top of those fixes. I forgot about the pending fixes. I'll handle this.

Quoted 7 lines

OK, that works much better when it is on top of the fixes.

Only one thing is missing: an entry in the MAINTAINERS file. Strange that that wasn't done for the encoder driver, we must have missed that. So can you make a patch adding the en/decoder driver to this file? I'm ready to make the pull request once I have that.

Got it. I will check and update it.

I have a question about decoder device node.
In v5 decoder patch series, I do not add device node patch at end of patch series.
I plain to put it in MT21C format patch series, is it ok?

Quoted 4 lines
Quoted 2 lines

What is the reason for not adding it in the decoder patch series?

It is because our decoder HW only support MT21C format.

Good reason :-)

OK, that's fine.

Regards,

Hans