Skip to contentSkip to conversation

media: mediatek: support mdp3 on mt8183 platform

PATCH Superseded Moudy Ho 5 participants 16 messages Jan 5, 2022 – Mar 16, 2022

Subsystems (3)

v11 of 28 Superseded Latest is v28 →

lore
Share & tools
lore
author
#7 lore raw

PATCH v11 2/3 dts: arm64: mt8183: add Mediatek MDP3 nodes

In reply to Moudy Ho

Add device nodes for Media Data Path 3 (MDP3) modules.

---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 108 ++++++++++++++++++++++-
 1 file changed, 107 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +107 -1
index ba4584faca5a..b872ef1ff6b3 100644
@@ -1325,6 +1325,79 @@
 			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0 0x1000>;
 		};
 
+		mdp3_rdma0: mdp3_rdma0@14001000 {
+			compatible = "mediatek,mt8183-mdp3",
+				     "mediatek,mt8183-mdp3-rdma0";
+			mediatek,scp = <&scp>;
+			mediatek,mdp3-comps = "mediatek,mt8183-mdp3-dl1",
+					      "mediatek,mt8183-mdp3-dl2",
+					      "mediatek,mt8183-mdp3-path1",
+					      "mediatek,mt8183-mdp3-path2",
+					      "mediatek,mt8183-mdp3-imgi",
+					      "mediatek,mt8183-mdp3-exto";
+			reg = <0 0x14001000 0 0x1000>,
+			      <0 0x14000000 0 0x1000>,
+			      <0 0x14005000 0 0x1000>,
+			      <0 0x14006000 0 0x1000>,
+			      <0 0x15020000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x1000 0x1000>,
+						  <&gce SUBSYS_1400XXXX 0 0x1000>,
+						  <&gce SUBSYS_1400XXXX 0x5000 0x1000>,
+						  <&gce SUBSYS_1400XXXX 0x6000 0x1000>,
+						  <&gce SUBSYS_1502XXXX 0 0x1000>;
+			power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+			clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+				 <&mmsys CLK_MM_MDP_RSZ1>,
+				 <&mmsys CLK_MM_MDP_DL_TXCK>,
+				 <&mmsys CLK_MM_MDP_DL_RX>,
+				 <&mmsys CLK_MM_IPU_DL_TXCK>,
+				 <&mmsys CLK_MM_IPU_DL_RX>;
+			iommus = <&iommu M4U_PORT_MDP_RDMA0>;
+			mediatek,mmsys = <&mmsys>;
+			mediatek,mm-mutex = <&mutex>;
+			mediatek,mailbox-gce = <&gce>;
+			mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST 0>,
+				 <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+				 <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+				 <&gce 23 CMDQ_THR_PRIO_LOWEST>;
+			gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+				     <&gce 0x14010000 SUBSYS_1401XXXX>,
+				     <&gce 0x14020000 SUBSYS_1402XXXX>,
+				     <&gce 0x15020000 SUBSYS_1502XXXX>;
+		};
+
+		mdp3_rsz0: mdp3_rsz0@14003000 {
+			compatible = "mediatek,mt8183-mdp3-rsz0";
+			reg = <0 0x14003000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x3000 0x1000>;
+			clocks = <&mmsys CLK_MM_MDP_RSZ0>;
+		};
+
+		mdp3_rsz1: mdp3_rsz1@14004000 {
+			compatible = "mediatek,mt8183-mdp3-rsz1";
+			reg = <0 0x14004000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x4000 0x1000>;
+			clocks = <&mmsys CLK_MM_MDP_RSZ1>;
+		};
+
+		mdp3_wrot0: mdp3_wrot0@14005000 {
+			compatible = "mediatek,mt8183-mdp3-wrot0";
+			reg = <0 0x14005000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x5000 0x1000>;
+			power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+			clocks = <&mmsys CLK_MM_MDP_WROT0>;
+			iommus = <&iommu M4U_PORT_MDP_WROT0>;
+		};
+
+		mdp3_wdma: mdp3_wdma@14006000 {
+			compatible = "mediatek,mt8183-mdp3-wdma";
+			reg = <0 0x14006000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x6000 0x1000>;
+			power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+			clocks = <&mmsys CLK_MM_MDP_WDMA0>;
+			iommus = <&iommu M4U_PORT_MDP_WDMA0>;
+		};
+
 		ovl0: ovl@14008000 {
 			compatible = "mediatek,mt8183-disp-ovl";
 			reg = <0 0x14008000 0 0x1000>;
@@ -1449,7 +1522,33 @@
 			interrupts = <GIC_SPI 217 IRQ_TYPE_LEVEL_LOW>;
 			power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
 			mediatek,gce-events = <CMDQ_EVENT_MUTEX_STREAM_DONE0>,
-					      <CMDQ_EVENT_MUTEX_STREAM_DONE1>;
+					      <CMDQ_EVENT_MUTEX_STREAM_DONE1>,
+					      <CMDQ_EVENT_MDP_RDMA0_SOF>,
+					      <CMDQ_EVENT_MDP_RDMA0_EOF>,
+					      <CMDQ_EVENT_MDP_RSZ0_SOF>,
+					      <CMDQ_EVENT_MDP_RSZ1_SOF>,
+					      <CMDQ_EVENT_MDP_TDSHP_SOF>,
+					      <CMDQ_EVENT_MDP_WROT0_SOF>,
+					      <CMDQ_EVENT_MDP_WROT0_EOF>,
+					      <CMDQ_EVENT_MDP_WDMA0_SOF>,
+					      <CMDQ_EVENT_MDP_WDMA0_EOF>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_0>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_1>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_2>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_3>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_4>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_5>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_6>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_7>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_8>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_9>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_10>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_11>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_12>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_13>,
+					      <CMDQ_EVENT_ISP_FRAME_DONE_P2_14>,
+					      <CMDQ_EVENT_WPE_A_DONE>,
+					      <CMDQ_EVENT_SPE_B_DONE>;
 		};
 
 		larb0: larb@14017000 {
@@ -1473,6 +1572,13 @@
 			power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
 		};
 
+		mdp3_ccorr: mdp3_ccorr@1401c000 {
+			compatible = "mediatek,mt8183-mdp3-ccorr";
+			reg = <0 0x1401c000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1401XXXX 0xc000 0x1000>;
+			clocks = <&mmsys CLK_MM_MDP_CCORR>;
+		};
+
 		imgsys: syscon@15020000 {
 			compatible = "mediatek,mt8183-imgsys", "syscon";
 			reg = <0 0x15020000 0 0x1000>;
Signature · 1 line
2.18.0

Moudy Ho

author
#0 lore raw

v11 cover media: mediatek: support mdp3 on mt8183 platform

Change since v10:
- The routing table needs to be discarded, and the calculation result on the SCP side is used to write a suitable mux setting for
1 input port and 2 output ports.
- Adjust dts parsing flow to remove redundant HW IDs.
- Fix memory leak caused by no free path information in function "mdp_cmdq_send".

Change since v9:
- Keep only the MDP3 driver patches and split the remaining mmsys and mutex patches into another mail.
- Move mutex mod settings to corresponding driver and make relevant adjustments for this in MDP3 driver.
- Fix compile warning reported by kernel test robot.

Change since v8:
- Rebase on v5.16-rc2.
- Refer to Angelo's suggestion, adjust the register writing format to increase readability and significance.
- Refer to Angelo's suggestion, adjust or reduce inappropriate debugging messages.
- Refer to Rob Herring's suggestion to correct the the binding file to make it with the specification.
- Fix compile warning reported by kernel test robot.

Change since v7:
- Rebase on v5.15-rc6.
- Revise several V4L2 M2M settings to pass v4l2-compliance test.
- Integrate those same component dt-binding documents of DRM and MDP, and move them under the MMSYS domain.
- Split MMSYS and MUTEX into two different files according to their functional properties.

Changes since v6:
- Refactor GCE event to corresponding node.
- Fix dt_binding_check fail.
- Fix compilation errors.

Changes since v5:
- Rebase on v5.14-rc6.
- Move MMSYS/Mutex settings to corresponding driver.
- Revise the software license description and copyright.
- Remove unnecessary enum. or definitions.
- Optimize platform/chip definition conditions.
- Use general printing functions instead of MDP3 private ones.
- Fix compile warning.

Changes since v4:
- Rebase on v5.13-rc1.
- Remove the CMDQ flush flow to match the CMDQ API change.
- Integrate four of MDP's direct-link subcomponents into MDP controller node from syscon node to avoid illegal clock usage.
- Rewrite dt-binding in a JSON compatible subset of YAML
- Fix a bit of macro argument precedence.

Changes since v3:
- Rebase on v5.9-rc1.
- modify code for review comment from Rob Herring, cancel multiple nodes using same register base situation.
- control IOMMU port through pm runtime get/put to DMA components' device.
- SCP(VPU) driver revision.
- stop queuing jobs(remove flush_workqueue()) after mdp_m2m_release().
- add computation of plane address with data_offset.
- fix scale ratio check issue.
- add default v4l2_format setting.

Changes since v2:
- modify code for review comment from Tomasz Figa & Alexandre Courbot
- review comment from Rob Herring will offer code revision in v4, due to it's related to device node modification, will need to modify code architecture

Changes since v1:
- modify code for CMDQ v3 API support
- EC ipi cmd migration
- fix compliance test fail item (m2m cmd with -f) due to there is two problem in runing all format(-f) cmd:
1. out of memory before test complete
Due to capture buffer mmap (refcount + 1) after reqbuf but seems
no corresponding munmap called before device close.
There are total 12XX items(formats) in format test and each format
alloc 8 capture/output buffers.
2. unceasingly captureBufs() (randomly)

        Seems the break statement didn't catch the count == 0 situation:
        In v4l2-test-buffers.cpp, function: captureBufs()
                        ...
                        count--;
                        if (!node->is_m2m && !count)
                                break;
        Log is as attachment

I will paste the test result with problem part in another e-mail

Hi,

This is the first version of RFC patch for Media Data Path 3 (MDP3), MDP3 is used for scaling and color format conversion. support using GCE to write register in critical time limitation. support V4L2 m2m device control.

Moudy Ho (3):
dt-binding: mt8183: add Mediatek MDP3 dt-bindings
dts: arm64: mt8183: add Mediatek MDP3 nodes
media: platform: mtk-mdp3: add Mediatek MDP3 driver

 .../bindings/media/mediatek,mdp3-rdma.yaml    |  193 +++
 .../bindings/media/mediatek,mdp3-rsz.yaml     |   55 +
 .../bindings/media/mediatek,mdp3-wrot.yaml    |   57 +
 .../bindings/soc/mediatek/mediatek,ccorr.yaml |   47 +
 .../bindings/soc/mediatek/mediatek,wdma.yaml  |   58 +
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      |  108 +-
 drivers/media/platform/Kconfig                |   20 +
 drivers/media/platform/Makefile               |    2 +
 drivers/media/platform/mtk-mdp3/Makefile      |    6 +
 .../media/platform/mtk-mdp3/mdp_reg_ccorr.h   |   19 +
 drivers/media/platform/mtk-mdp3/mdp_reg_isp.h |   27 +
 .../media/platform/mtk-mdp3/mdp_reg_rdma.h    |   65 +
 drivers/media/platform/mtk-mdp3/mdp_reg_rsz.h |   39 +
 .../media/platform/mtk-mdp3/mdp_reg_wdma.h    |   47 +
 .../media/platform/mtk-mdp3/mdp_reg_wrot.h    |   55 +
 drivers/media/platform/mtk-mdp3/mtk-img-ipi.h |  280 ++++
 .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.c   |  515 +++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
 .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1228 +++++++++++++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-comp.h   |  147 ++
 .../media/platform/mtk-mdp3/mtk-mdp3-core.c   |  338 +++++
 .../media/platform/mtk-mdp3/mtk-mdp3-core.h   |   76 +
 .../media/platform/mtk-mdp3/mtk-mdp3-m2m.c    |  789 +++++++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-m2m.h    |   49 +
 .../media/platform/mtk-mdp3/mtk-mdp3-regs.c   |  737 ++++++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-regs.h   |  372 +++++
 .../media/platform/mtk-mdp3/mtk-mdp3-vpu.c    |  312 +++++
 .../media/platform/mtk-mdp3/mtk-mdp3-vpu.h    |   78 ++
 28 files changed, 5764 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-wrot.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,ccorr.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma.yaml
 create mode 100644 drivers/media/platform/mtk-mdp3/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_ccorr.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_isp.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_rdma.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_rsz.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_wdma.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_wrot.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-img-ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.h
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH v11 1/3 dt-binding: mt8183: add Mediatek MDP3 dt-bindings

This patch adds DT binding document for Media Data Path 3 (MDP3) a unit in multimedia system used for scaling and color format convert.

---
 .../bindings/media/mediatek,mdp3-rdma.yaml    | 193 ++++++++++++++++++
 .../bindings/media/mediatek,mdp3-rsz.yaml     |  55 +++++
 .../bindings/media/mediatek,mdp3-wrot.yaml    |  57 ++++++
 .../bindings/soc/mediatek/mediatek,ccorr.yaml |  47 +++++
 .../bindings/soc/mediatek/mediatek,wdma.yaml  |  58 ++++++
 5 files changed, 410 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-wrot.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,ccorr.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma.yaml
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +193 -0
new file mode 100644
index 000000000000..002503383934
@@ -0,0 +1,193 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/mediatek,mdp3-rdma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek Read Direct Memory Access
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  Mediatek Read Direct Memory Access(RDMA) component used to do read DMA.
+  It contains one line buffer to store the sufficient pixel data, and
+  must be siblings to the central MMSYS_CONFIG node.
+  For a description of the MMSYS_CONFIG binding, see
+  Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml
+  for details.
+  The 1st RDMA is also used to be a controller node in Media Data Path 3(MDP3)
+  that containing MMSYS, MUTEX, GCE and SCP settings.
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          # MDP3 controller node
+          - const: mediatek,mt8183-mdp3
+          - const: mediatek,mt8183-mdp3-rdma0
+      - items:
+          # normal RDMA conponent
+          - const: mediatek,mt8183-mdp3-rdma0
+
+  mediatek,scp:
+    description: The node of system control processor (SCP), using
+      the remoteproc & rpmsg framework.
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mdp3-comps:
+    description: MTK sub-system of direct-link or DIP
+    $ref: /schemas/types.yaml#/definitions/string-array
+    items:
+      - enum:
+          # MDP direct-link input path selection, create a
+          # component for path connectedness of HW pipe control
+          - mediatek,mt8183-mdp3-dl1
+      - enum:
+          - mediatek,mt8183-mdp3-dl2
+      - enum:
+          # MDP direct-link output path selection, create a
+          # component for path connectedness of HW pipe control
+          - mediatek,mt8183-mdp3-path1
+      - enum:
+          - mediatek,mt8183-mdp3-path2
+      - enum:
+          # Input DMA of ISP PASS2 (DIP) module for raw image input
+          - mediatek,mt8183-mdp3-imgi
+      - enum:
+          # Output DMA of ISP PASS2 (DIP) module for YUV image output
+          - mediatek,mt8183-mdp3-exto
+
+  reg:
+    items:
+      - description: basic RDMA HW address
+      - description: MDP direct-link 1st and 2nd input
+      - description: MDP direct-link 1st output
+      - description: MDP direct-link 2nd output
+      - description: ISP input and output
+
+  mediatek,gce-client-reg:
+    description: The register of client driver can be configured by gce with
+      4 arguments defined in this property, such as phandle of gce, subsys id,
+      register offset and size. Each GCE subsys id is mapping to a client
+      defined in the header include/dt-bindings/gce/<chip>-gce.h.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - description: GCE client for RDMA
+      - description: GCR client for MDP direct-link 1st and 2nd input
+      - description: GCR client for MDP direct-link 1st output
+      - description: GCR client for MDP direct-link 2nd output
+      - description: GCR client for ISP input and output
+
+  power-domains:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: RDMA clock
+      - description: RSZ clock
+      - description: direck-link TX clock in MDP side
+      - description: direck-link RX clock in MDP side
+      - description: direck-link TX clock in ISP side
+      - description: direck-link RX clock in ISP side
+
+  iommus:
+    maxItems: 1
+
+  mediatek,mmsys:
+    description: The node of mux(multiplexer) controller for HW connections.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mediatek,mm-mutex:
+    description: The node of sof(start of frame) signal controller.
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mailbox-gce:
+    description: The node of global command engine (GCE), used to read/write
+      registers with critical time limitation.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mboxes:
+    items:
+      - description: used for 1st data pipe from RDMA
+      - description: used for 2nd data pipe from RDMA
+      - description: used for 3rd data pipe from Direct-Link
+      - description: used for 4th data pipe from Direct-Link
+
+  gce-subsys:
+    description: sub-system id corresponding to the global command engine (GCE)
+      register address.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+if:
+  properties:
+    compatible:
+      contains:
+        const: mediatek,mt8183-mdp3
+
+then:
+  required:
+    - mediatek,scp
+    - mediatek,mmsys
+    - mediatek,mm-mutex
+    - mediatek,mailbox-gce
+    - mboxes
+    - gce-subsys
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - mediatek,gce-client-reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8183-clk.h>
+    #include <dt-bindings/gce/mt8183-gce.h>
+    #include <dt-bindings/power/mt8183-power.h>
+    #include <dt-bindings/memory/mt8183-larb-port.h>
+
+    mdp3_rdma0: mdp3_rdma0@14001000 {
+      compatible = "mediatek,mt8183-mdp3",
+                   "mediatek,mt8183-mdp3-rdma0";
+      mediatek,scp = <&scp>;
+      mediatek,mdp3-comps = "mediatek,mt8183-mdp3-dl1",
+                            "mediatek,mt8183-mdp3-dl2",
+                            "mediatek,mt8183-mdp3-path1",
+                            "mediatek,mt8183-mdp3-path2",
+                            "mediatek,mt8183-mdp3-imgi",
+                            "mediatek,mt8183-mdp3-exto";
+      reg = <0x14001000 0x1000>,
+            <0x14000000 0x1000>,
+            <0x14005000 0x1000>,
+            <0x14006000 0x1000>,
+            <0x15020000 0x1000>;
+      mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x1000 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0x5000 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0x6000 0x1000>,
+                                <&gce SUBSYS_1502XXXX 0 0x1000>;
+      power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+      clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+               <&mmsys CLK_MM_MDP_RSZ1>,
+               <&mmsys CLK_MM_MDP_DL_TXCK>,
+               <&mmsys CLK_MM_MDP_DL_RX>,
+               <&mmsys CLK_MM_IPU_DL_TXCK>,
+               <&mmsys CLK_MM_IPU_DL_RX>;
+      iommus = <&iommu>;
+      mediatek,mmsys = <&mmsys>;
+      mediatek,mm-mutex = <&mutex>;
+      mediatek,mailbox-gce = <&gce>;
+      mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 23 CMDQ_THR_PRIO_LOWEST>;
+      gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+                   <&gce 0x14010000 SUBSYS_1401XXXX>,
+                   <&gce 0x14020000 SUBSYS_1402XXXX>,
+                   <&gce 0x15020000 SUBSYS_1502XXXX>;
+    };
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +55 -0

55 lines not on this page · raw message

Documentation/devicetree/bindings/media/mediatek,mdp3-wrot.yaml new file +57 -0

57 lines not on this page · raw message

Documentation/devicetree/bindings/soc/mediatek/mediatek,ccorr.yaml new file +47 -0

47 lines not on this page · raw message

Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma.yaml new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
2.18.0
author
#11 lore raw

PATCH v11 3/3 media: platform: mtk-mdp3: add Mediatek MDP3 driver

In reply to Moudy Ho

This patch adds driver for Mediatek's Media Data Path ver.3 (MDP3). It provides the following functions:
color transform, format conversion, resize, crop, rotate, flip and additional image quality enhancement.

The MDP3 driver is mainly used for Google Chromebook products to import the new architecture to set the HW settings as shown below:
User -> V4L2 framework

    -> MDP3 driver -> SCP (setting calculations)
      -> MDP3 driver -> CMDQ (GCE driver) -> HW

Each modules' related operation control is sited in mtk-mdp3-comp.c Each modules' register table is defined in file with "mdp_reg_" prefix GCE related API, operation control sited in mtk-mdp3-cmdq.c V4L2 m2m device functions are implemented in mtk-mdp3-m2m.c Probe, power, suspend/resume, system level functions are defined in mtk-mdp3-core.c

---
Depend on:
[1]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ [2]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ [3]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ [4]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

---
 drivers/media/platform/Kconfig                |   20 +
 drivers/media/platform/Makefile               |    2 +
 drivers/media/platform/mtk-mdp3/Makefile      |    6 +
 .../media/platform/mtk-mdp3/mdp_reg_ccorr.h   |   19 +
 drivers/media/platform/mtk-mdp3/mdp_reg_isp.h |   27 +
 .../media/platform/mtk-mdp3/mdp_reg_rdma.h    |   65 +
 drivers/media/platform/mtk-mdp3/mdp_reg_rsz.h |   39 +
 .../media/platform/mtk-mdp3/mdp_reg_wdma.h    |   47 +
 .../media/platform/mtk-mdp3/mdp_reg_wrot.h    |   55 +
 drivers/media/platform/mtk-mdp3/mtk-img-ipi.h |  280 ++++
 .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.c   |  515 +++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
 .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1228 +++++++++++++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-comp.h   |  147 ++
 .../media/platform/mtk-mdp3/mtk-mdp3-core.c   |  338 +++++
 .../media/platform/mtk-mdp3/mtk-mdp3-core.h   |   76 +
 .../media/platform/mtk-mdp3/mtk-mdp3-m2m.c    |  789 +++++++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-m2m.h    |   49 +
 .../media/platform/mtk-mdp3/mtk-mdp3-regs.c   |  737 ++++++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-regs.h   |  372 +++++
 .../media/platform/mtk-mdp3/mtk-mdp3-vpu.c    |  312 +++++
 .../media/platform/mtk-mdp3/mtk-mdp3-vpu.h    |   78 ++
 22 files changed, 5247 insertions(+)
 create mode 100644 drivers/media/platform/mtk-mdp3/Makefile
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_ccorr.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_isp.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_rdma.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_rsz.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_wdma.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_wrot.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-img-ipi.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.h
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c
 create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.h
drivers/media/platform/Kconfig +20 -0
index cf4adc64c953..f879b93a623b 100644
@@ -315,6 +315,26 @@ config VIDEO_MEDIATEK_MDP
 	    To compile this driver as a module, choose M here: the
 	    module will be called mtk-mdp.
 
+config VIDEO_MEDIATEK_MDP3
+	tristate "Mediatek MDP v3 driver"
+	depends on MTK_IOMMU || COMPLIE_TEST
+	depends on VIDEO_DEV && VIDEO_V4L2
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	depends on MTK_MMSYS
+	depends on HAS_DMA
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_MEM2MEM_DEV
+	select VIDEO_MEDIATEK_VPU
+	select MTK_CMDQ
+	select MTK_SCP
+	default n
+	help
+	    It is a v4l2 driver and present in Mediatek MT8183 SoC.
+	    The driver supports for scaling and color space conversion.
+
+	    To compile this driver as a module, choose M here: the
+	    module will be called mtk-mdp3.
+
 config VIDEO_MEDIATEK_VCODEC
 	tristate "Mediatek Video Codec driver"
 	depends on MTK_IOMMU || COMPILE_TEST
drivers/media/platform/Makefile +2 -0
index a148553babfc..29bdfa92a09a 100644
@@ -78,6 +78,8 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)	+= mtk-vcodec/
 
 obj-$(CONFIG_VIDEO_MEDIATEK_MDP)	+= mtk-mdp/
 
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP3)	+= mtk-mdp3/
+
 obj-$(CONFIG_VIDEO_MEDIATEK_JPEG)	+= mtk-jpeg/
 
 obj-$(CONFIG_VIDEO_QCOM_CAMSS)		+= qcom/camss/
drivers/media/platform/mtk-mdp3/Makefile new file +6 -0
new file mode 100644
index 000000000000..8772f5ac2867
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+mtk-mdp3-y += mtk-mdp3-core.o mtk-mdp3-vpu.o mtk-mdp3-regs.o
+mtk-mdp3-y += mtk-mdp3-m2m.o
+mtk-mdp3-y += mtk-mdp3-comp.o mtk-mdp3-cmdq.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP3) += mtk-mdp3.o
\ No newline at end of file
drivers/media/platform/mtk-mdp3/mdp_reg_ccorr.h new file +19 -0
new file mode 100644
index 000000000000..46804d97db1f
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MDP_REG_CCORR_H__
+#define __MDP_REG_CCORR_H__
+
+#define MDP_CCORR_EN                0x000
+#define MDP_CCORR_CFG               0x020
+#define MDP_CCORR_SIZE              0x030
+
+/* MASK */
+#define MDP_CCORR_EN_MASK           0x00000001
+#define MDP_CCORR_CFG_MASK          0x70001317
+#define MDP_CCORR_SIZE_MASK         0x1fff1fff
+
+#endif  // __MDP_REG_CCORR_H__
drivers/media/platform/mtk-mdp3/mdp_reg_isp.h new file +27 -0
new file mode 100644
index 000000000000..5334cd932b55
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __ISP_REG_H__
+#define __ISP_REG_H__
+
+enum isp_dip_cq {
+	ISP_DRV_DIP_CQ_THRE0 = 0,
+	ISP_DRV_DIP_CQ_THRE1,
+	ISP_DRV_DIP_CQ_THRE2,
+	ISP_DRV_DIP_CQ_THRE3,
+	ISP_DRV_DIP_CQ_THRE4,
+	ISP_DRV_DIP_CQ_THRE5,
+	ISP_DRV_DIP_CQ_THRE6,
+	ISP_DRV_DIP_CQ_THRE7,
+	ISP_DRV_DIP_CQ_THRE8,
+	ISP_DRV_DIP_CQ_THRE9,
+	ISP_DRV_DIP_CQ_THRE10,
+	ISP_DRV_DIP_CQ_THRE11,
+	ISP_DRV_DIP_CQ_NUM,
+	ISP_DRV_DIP_CQ_NONE,
+};
+
+#endif  // __ISP_REG_H__
drivers/media/platform/mtk-mdp3/mdp_reg_rdma.h new file +65 -0

65 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mdp_reg_rsz.h new file +39 -0
new file mode 100644
index 000000000000..051fdb020741
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MDP_REG_RSZ_H__
+#define __MDP_REG_RSZ_H__
+
+#define PRZ_ENABLE                                        0x000
+#define PRZ_CONTROL_1                                     0x004
+#define PRZ_CONTROL_2                                     0x008
+#define PRZ_INPUT_IMAGE                                   0x010
+#define PRZ_OUTPUT_IMAGE                                  0x014
+#define PRZ_HORIZONTAL_COEFF_STEP                         0x018
+#define PRZ_VERTICAL_COEFF_STEP                           0x01c
+#define PRZ_LUMA_HORIZONTAL_INTEGER_OFFSET                0x020
+#define PRZ_LUMA_HORIZONTAL_SUBPIXEL_OFFSET               0x024
+#define PRZ_LUMA_VERTICAL_INTEGER_OFFSET                  0x028
+#define PRZ_LUMA_VERTICAL_SUBPIXEL_OFFSET                 0x02c
+#define PRZ_CHROMA_HORIZONTAL_INTEGER_OFFSET              0x030
+#define PRZ_CHROMA_HORIZONTAL_SUBPIXEL_OFFSET             0x034
+
+/* MASK */
+#define PRZ_ENABLE_MASK                                   0x00010001
+#define PRZ_CONTROL_1_MASK                                0xfffffff3
+#define PRZ_CONTROL_2_MASK                                0x0ffffaff
+#define PRZ_INPUT_IMAGE_MASK                              0xffffffff
+#define PRZ_OUTPUT_IMAGE_MASK                             0xffffffff
+#define PRZ_HORIZONTAL_COEFF_STEP_MASK                    0x007fffff
+#define PRZ_VERTICAL_COEFF_STEP_MASK                      0x007fffff
+#define PRZ_LUMA_HORIZONTAL_INTEGER_OFFSET_MASK           0x0000ffff
+#define PRZ_LUMA_HORIZONTAL_SUBPIXEL_OFFSET_MASK          0x001fffff
+#define PRZ_LUMA_VERTICAL_INTEGER_OFFSET_MASK             0x0000ffff
+#define PRZ_LUMA_VERTICAL_SUBPIXEL_OFFSET_MASK            0x001fffff
+#define PRZ_CHROMA_HORIZONTAL_INTEGER_OFFSET_MASK         0x0000ffff
+#define PRZ_CHROMA_HORIZONTAL_SUBPIXEL_OFFSET_MASK        0x001fffff
+
+#endif // __MDP_REG_RSZ_H__
drivers/media/platform/mtk-mdp3/mdp_reg_wdma.h new file +47 -0

47 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mdp_reg_wrot.h new file +55 -0

55 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-img-ipi.h new file +280 -0

280 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c new file +515 -0

515 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h new file +46 -0

46 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c new file +1228 -0

1,228 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h new file +147 -0

147 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c new file +338 -0

338 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h new file +76 -0

76 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c new file +789 -0

77 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.h new file +49 -0

49 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c new file +737 -0

737 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.h new file +372 -0

372 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c new file +312 -0

312 lines not on this page · raw message

drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.h new file +78 -0

78 lines not on this page · raw message

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

Signature · 1 line
2.18.0

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

#12 lore raw

Re: [PATCH v11 3/3] media: platform: mtk-mdp3: add Mediatek MDP3 driver

Thank you for the patch! Perhaps something to improve:

Hi Moudy,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on media-tree/master]
[also build test WARNING on robh/for-next v5.16-rc8 next-20220105] [cannot apply to mbgg-mediatek/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Moudy-Ho/media-mediatek-support-mdp3-on-mt8183-platform/20220105-173918
base:   git://linuxtv.org/media_tree.git master
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20220106/202201060241.t95Ra9LM-lkp(a)intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/696f7ac402f9778a21202f2b889c3c30a6923b3d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Moudy-Ho/media-mediatek-support-mdp3-on-mt8183-platform/20220105-173918 git checkout 696f7ac402f9778a21202f2b889c3c30a6923b3d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/media/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:14,
from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c:15:
drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type

     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c:15:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function); did you mean 'SCP_IPI_MAX'?
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
         |                                                            SCP_IPI_MAX
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c: In function 'mdp_probe':
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c:192:37: error: implicit declaration of function 'mtk_mutex_mdp_get'; did you mean 'mtk_mutex_get'? [-Werror=implicit-function-declaration]
     192 |                 mdp->mdp_mutex[i] = mtk_mutex_mdp_get(&mm_pdev->dev, i);
         |                                     ^~~~~~~~~~~~~~~~~
         |                                     mtk_mutex_get
   cc1: some warnings being treated as errors
--
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:14,
                    from drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c:10:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type
     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c:10:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function); did you mean 'SCP_IPI_MAX'?
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
         |                                                            SCP_IPI_MAX
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT

--
In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:14,
from drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c:10:
drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type

     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c:10:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function)
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT
--
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:11:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type
     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:12:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function)
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: In function 'get_comp_flag':
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:35:38: error: 'MDP_COMP_RDMA0' undeclared (first use in this function)
      35 |                 if (ctx->comp->id == MDP_COMP_RDMA0)
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:35:38: note: each undeclared identifier is reported only once for each function it appears in
   In file included from include/linux/bits.h:6,
                    from include/linux/bitops.h:6,
                    from include/linux/kernel.h:13,
                    from include/linux/clk.h:13,
                    from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:7:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:36:58: error: 'MDP_COMP_RSZ1' undeclared (first use in this function)
      36 |                         return BIT(MDP_COMP_RDMA0) | BIT(MDP_COMP_RSZ1);
         |                                                          ^~~~~~~~~~~~~
   include/vdso/bits.h:7:44: note: in definition of macro 'BIT'
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                            ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: At top level:
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:41:55: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
      41 | static int init_rdma(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
         |                                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: In function 'init_rdma':
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:48:66: error: 'MDP_COMP_RSZ1' undeclared (first use in this function)
      48 |                 struct mdp_comp *prz1 = ctx->comp->mdp_dev->comp[MDP_COMP_RSZ1];
         |                                                                  ^~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:51:38: error: 'MDP_COMP_RDMA0' undeclared (first use in this function)
      51 |                 if (ctx->comp->id == MDP_COMP_RDMA0 && prz1)
         |                                      ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:11:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:52:25: note: in expansion of macro 'MM_REG_WRITE'
      52 |                         MM_REG_WRITE(cmd, subsys_id, prz1->reg_base, PRZ_ENABLE,
         |                         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:57:9: note: in expansion of macro 'MM_REG_WRITE'
      57 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_RESET, BIT(0), BIT(0));
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:34:33: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      34 |         cmdq_pkt_poll_mask((cmd)->pkt, id, \
         |                                 ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:37:9: note: in expansion of macro 'MM_REG_POLL_MASK'
      37 |         MM_REG_POLL_MASK((cmd), id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:58:9: note: in expansion of macro 'MM_REG_POLL'
      58 |         MM_REG_POLL(cmd, subsys_id, base, MDP_RDMA_MON_STA_1, BIT(8), BIT(8));
         |         ^~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:59:9: note: in expansion of macro 'MM_REG_WRITE'
      59 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_RESET, 0x0, BIT(0));
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: At top level:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:64:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
      64 |                              struct mmsys_cmdq_cmd *cmd,
         |                                     ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:11:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: In function 'config_rdma_frame':
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:77:25: note: in expansion of macro 'MM_REG_WRITE'
      77 |                         MM_REG_WRITE(cmd, subsys_id, base,
         |                         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:80:25: note: in expansion of macro 'MM_REG_WRITE'
      80 |                         MM_REG_WRITE(cmd, subsys_id, base,
         |                         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:85:9: note: in expansion of macro 'MM_REG_WRITE'
      85 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_GMCIF_CON,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:91:9: note: in expansion of macro 'MM_REG_WRITE'
      91 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_CON, rdma->src_ctrl,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:97:25: note: in expansion of macro 'MM_REG_WRITE'
      97 |                         MM_REG_WRITE(cmd, subsys_id,
         |                         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
--
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:9:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type
     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:10:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function)
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:47:43: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
      47 |                                    struct mmsys_cmdq_cmd *cmd, u32 count)
         |                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c: In function 'mdp_path_subfrm_require':
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:62:14: error: 'MDP_COMP_RDMA0' undeclared (first use in this function)
      62 |         case MDP_COMP_RDMA0:
         |              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:62:14: note: each undeclared identifier is reported only once for each function it appears in
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:63:28: error: 'MDP_PIPE_RDMA0' undeclared (first use in this function)
      63 |                 mutex_id = MDP_PIPE_RDMA0;
         |                            ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:65:14: error: 'MDP_COMP_ISP_IMGI' undeclared (first use in this function); did you mean 'MDP_COMP_TYPE_IMGI'?
      65 |         case MDP_COMP_ISP_IMGI:
         |              ^~~~~~~~~~~~~~~~~
         |              MDP_COMP_TYPE_IMGI
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:66:28: error: 'MDP_PIPE_IMGI' undeclared (first use in this function)
      66 |                 mutex_id = MDP_PIPE_IMGI;
         |                            ^~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:68:14: error: 'MDP_COMP_WPEI' undeclared (first use in this function); did you mean 'MDP_COMP_TYPE_WPEI'?
      68 |         case MDP_COMP_WPEI:
         |              ^~~~~~~~~~~~~
         |              MDP_COMP_TYPE_WPEI
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:69:28: error: 'MDP_PIPE_WPEI' undeclared (first use in this function)
      69 |                 mutex_id = MDP_PIPE_WPEI;
         |                            ^~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:71:14: error: 'MDP_COMP_WPEI2' undeclared (first use in this function); did you mean 'MDP_COMP_TYPE_WPEI'?
      71 |         case MDP_COMP_WPEI2:
         |              ^~~~~~~~~~~~~~
         |              MDP_COMP_TYPE_WPEI
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:72:28: error: 'MDP_PIPE_WPEI2' undeclared (first use in this function)
      72 |                 mutex_id = MDP_PIPE_WPEI2;
         |                            ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:87:22: error: 'MDP_COMP_AAL0' undeclared (first use in this function)
      87 |                 case MDP_COMP_AAL0:
         |                      ^~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:88:22: error: 'MDP_COMP_CCORR0' undeclared (first use in this function); did you mean 'MDP_COMP_TYPE_CCORR'?
      88 |                 case MDP_COMP_CCORR0:
         |                      ^~~~~~~~~~~~~~~
         |                      MDP_COMP_TYPE_CCORR
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:89:22: error: 'MDP_COMP_WDMA' undeclared (first use in this function); did you mean 'MDP_COMP_TYPE_WDMA'?
      89 |                 case MDP_COMP_WDMA:
         |                      ^~~~~~~~~~~~~
         |                      MDP_COMP_TYPE_WDMA
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:90:22: error: 'MDP_COMP_WROT0' undeclared (first use in this function)
      90 |                 case MDP_COMP_WROT0:
         |                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:91:22: error: 'MDP_COMP_TDSHP0' undeclared (first use in this function); did you mean 'MDP_COMP_TYPE_HDR'?
      91 |                 case MDP_COMP_TDSHP0:
         |                      ^~~~~~~~~~~~~~~
         |                      MDP_COMP_TYPE_HDR
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:92:22: error: 'MDP_COMP_RSZ1' undeclared (first use in this function)
      92 |                 case MDP_COMP_RSZ1:
         |                      ^~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:93:22: error: 'MDP_COMP_RSZ0' undeclared (first use in this function)
      93 |                 case MDP_COMP_RSZ0:
         |                      ^~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:95:37: error: implicit declaration of function 'mtk_mutex_get_mdp_mod' [-Werror=implicit-function-declaration]
      95 |                         mutex_bit = mtk_mutex_get_mdp_mod(mutex[mutex_id], id);
         |                                     ^~~~~~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:104:17: error: implicit declaration of function 'mtk_mutex_add_mod_by_cmdq'; did you mean 'mtk_mutex_add_comp'? [-Werror=implicit-function-declaration]
     104 |                 mtk_mutex_add_mod_by_cmdq(mutex[mutex_id], subfrm->mutex_mod, cmd);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~
         |                 mtk_mutex_add_comp
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c: At top level:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:131:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                                struct mmsys_cmdq_cmd *cmd)
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c: In function 'mdp_path_subfrm_run':
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:149:30: error: 'MDP_COMP_RDMA0' undeclared (first use in this function)
     149 |                         case MDP_COMP_RDMA0:
         |                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:9:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:28:35: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      28 |         cmdq_pkt_clear_event((cmd)->pkt, (cmd)->event[(evt)])
         |                                   ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:150:33: note: in expansion of macro 'MM_REG_CLEAR'
     150 |                                 MM_REG_CLEAR(cmd, RDMA0_SOF);
         |                                 ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:28:47: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      28 |         cmdq_pkt_clear_event((cmd)->pkt, (cmd)->event[(evt)])
         |                                               ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:150:33: note: in expansion of macro 'MM_REG_CLEAR'
     150 |                                 MM_REG_CLEAR(cmd, RDMA0_SOF);
         |                                 ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:152:30: error: 'MDP_COMP_TDSHP0' undeclared (first use in this function); did you mean 'MDP_COMP_TYPE_HDR'?
     152 |                         case MDP_COMP_TDSHP0:
         |                              ^~~~~~~~~~~~~~~
         |                              MDP_COMP_TYPE_HDR
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:9:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:28:35: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      28 |         cmdq_pkt_clear_event((cmd)->pkt, (cmd)->event[(evt)])
         |                                   ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:153:33: note: in expansion of macro 'MM_REG_CLEAR'
     153 |                                 MM_REG_CLEAR(cmd, TDSHP0_SOF);
         |                                 ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:28:47: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      28 |         cmdq_pkt_clear_event((cmd)->pkt, (cmd)->event[(evt)])
         |                                               ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:153:33: note: in expansion of macro 'MM_REG_CLEAR'
     153 |                                 MM_REG_CLEAR(cmd, TDSHP0_SOF);
         |                                 ^~~~~~~~~~~~

vim +123 drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h

100
101 struct mdp_comp {
102 struct mdp_dev *mdp_dev;
103 void __iomem *regs;
104 phys_addr_t reg_base;
105 u8 subsys_id;
106 struct clk *clks[6];
107 struct device *comp_dev;
108 enum mdp_comp_type type;

 > 109		enum mtk_mdp_comp_id		id;
   110		u32				alias_id;
   111		const struct mdp_comp_ops	*ops;
   112	};
   113	
   114	struct mdp_comp_ctx {
   115		struct mdp_comp			*comp;
   116		const struct img_compparam	*param;
   117		const struct img_input		*input;
   118		const struct img_output		*outputs[IMG_MAX_HW_OUTPUTS];
   119	};
   120	
   121	struct mdp_comp_ops {
   122		s64 (*get_comp_flag)(const struct mdp_comp_ctx *ctx);
 > 123		int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);

124 int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
125 const struct v4l2_rect *compose);
126 int (*config_subfrm)(struct mdp_comp_ctx *ctx,
127 struct mmsys_cmdq_cmd *cmd, u32 index);
128 int (*wait_comp_event)(struct mdp_comp_ctx *ctx,
129 struct mmsys_cmdq_cmd *cmd);
130 int (*advance_subfrm)(struct mdp_comp_ctx *ctx,
131 struct mmsys_cmdq_cmd *cmd, u32 index);
132 int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
133 };
134

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#13 lore raw

Re: [PATCH v11 3/3] media: platform: mtk-mdp3: add Mediatek MDP3 driver

In reply to Moudy Ho
Thank you for the patch! Yet something to improve:

Hi Moudy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on media-tree/master]
[also build test ERROR on robh/for-next v5.16-rc8 next-20220105] [cannot apply to mbgg-mediatek/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Moudy-Ho/media-mediatek-support-mdp3-on-mt8183-platform/20220105-173918
base:   git://linuxtv.org/media_tree.git master
config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20220106/202201062041.Yo7iIAXn-lkp(a)intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/696f7ac402f9778a21202f2b889c3c30a6923b3d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Moudy-Ho/media-mediatek-support-mdp3-on-mt8183-platform/20220105-173918 git checkout 696f7ac402f9778a21202f2b889c3c30a6923b3d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=ia64 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:14,
from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c:15:

>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type
     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c:15:
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function); did you mean 'SCP_IPI_MAX'?
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
         |                                                            SCP_IPI_MAX
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c: In function 'mdp_probe':
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c:192:37: error: implicit declaration of function 'mtk_mutex_mdp_get'; did you mean 'mtk_mutex_get'? [-Werror=implicit-function-declaration]
     192 |                 mdp->mdp_mutex[i] = mtk_mutex_mdp_get(&mm_pdev->dev, i);
         |                                     ^~~~~~~~~~~~~~~~~
         |                                     mtk_mutex_get
   cc1: some warnings being treated as errors
--
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:14,
                    from drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c:10:
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type
     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c:10:
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function); did you mean 'SCP_IPI_MAX'?
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
         |                                                            SCP_IPI_MAX
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT
--
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:14,
                    from drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c:10:
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type
     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c:10:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function)
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT
--
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:11:
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:109:41: error: field 'id' has incomplete type
     109 |         enum mtk_mdp_comp_id            id;
         |                                         ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:123:59: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     123 |         int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                           ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:124:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     124 |         int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
         |                                                              ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:127:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     127 |                              struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                     ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:129:39: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     129 |                                struct mmsys_cmdq_cmd *cmd);
         |                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:131:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     131 |                               struct mmsys_cmdq_cmd *cmd, u32 index);
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:132:62: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     132 |         int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
         |                                                              ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:12:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:43:60: error: 'MDP_PIPE_MAX' undeclared here (not in a function)
      43 |         struct mtk_mutex                        *mdp_mutex[MDP_PIPE_MAX];
         |                                                            ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h:44:55: error: 'MDP_MAX_COMP_COUNT' undeclared here (not in a function); did you mean 'MDP_MAX_EVENT_COUNT'?
      44 |         struct mdp_comp                         *comp[MDP_MAX_COMP_COUNT];
         |                                                       ^~~~~~~~~~~~~~~~~~
         |                                                       MDP_MAX_EVENT_COUNT
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: In function 'get_comp_flag':
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:35:38: error: 'MDP_COMP_RDMA0' undeclared (first use in this function)
      35 |                 if (ctx->comp->id == MDP_COMP_RDMA0)
         |                                      ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:35:38: note: each undeclared identifier is reported only once for each function it appears in
   In file included from include/linux/bits.h:6,
                    from include/linux/bitops.h:6,
                    from include/linux/kernel.h:13,
                    from include/linux/clk.h:13,
                    from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:7:
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:36:58: error: 'MDP_COMP_RSZ1' undeclared (first use in this function)
      36 |                         return BIT(MDP_COMP_RDMA0) | BIT(MDP_COMP_RSZ1);
         |                                                          ^~~~~~~~~~~~~
   include/vdso/bits.h:7:44: note: in definition of macro 'BIT'
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                            ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: At top level:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:41:55: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
      41 | static int init_rdma(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
         |                                                       ^~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: In function 'init_rdma':
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:48:66: error: 'MDP_COMP_RSZ1' undeclared (first use in this function)
      48 |                 struct mdp_comp *prz1 = ctx->comp->mdp_dev->comp[MDP_COMP_RSZ1];
         |                                                                  ^~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:51:38: error: 'MDP_COMP_RDMA0' undeclared (first use in this function)
      51 |                 if (ctx->comp->id == MDP_COMP_RDMA0 && prz1)
         |                                      ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:11:
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:52:25: note: in expansion of macro 'MM_REG_WRITE'
      52 |                         MM_REG_WRITE(cmd, subsys_id, prz1->reg_base, PRZ_ENABLE,
         |                         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:57:9: note: in expansion of macro 'MM_REG_WRITE'
      57 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_RESET, BIT(0), BIT(0));
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:34:33: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      34 |         cmdq_pkt_poll_mask((cmd)->pkt, id, \
         |                                 ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:37:9: note: in expansion of macro 'MM_REG_POLL_MASK'
      37 |         MM_REG_POLL_MASK((cmd), id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:58:9: note: in expansion of macro 'MM_REG_POLL'
      58 |         MM_REG_POLL(cmd, subsys_id, base, MDP_RDMA_MON_STA_1, BIT(8), BIT(8));
         |         ^~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:59:9: note: in expansion of macro 'MM_REG_WRITE'
      59 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_RESET, 0x0, BIT(0));
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: At top level:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:64:37: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
      64 |                              struct mmsys_cmdq_cmd *cmd,
         |                                     ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:11:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: In function 'config_rdma_frame':
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:77:25: note: in expansion of macro 'MM_REG_WRITE'
      77 |                         MM_REG_WRITE(cmd, subsys_id, base,
         |                         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:80:25: note: in expansion of macro 'MM_REG_WRITE'
      80 |                         MM_REG_WRITE(cmd, subsys_id, base,
         |                         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:85:9: note: in expansion of macro 'MM_REG_WRITE'
      85 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_GMCIF_CON,
         |         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:91:9: note: in expansion of macro 'MM_REG_WRITE'
      91 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_CON, rdma->src_ctrl,
         |         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:97:25: note: in expansion of macro 'MM_REG_WRITE'
      97 |                         MM_REG_WRITE(cmd, subsys_id,
         |                         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:100:25: note: in expansion of macro 'MM_REG_WRITE'
     100 |                         MM_REG_WRITE(cmd, subsys_id,
         |                         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:105:33: note: in expansion of macro 'MM_REG_WRITE'
     105 |                                 MM_REG_WRITE(cmd, subsys_id,
         |                                 ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:110:9: note: in expansion of macro 'MM_REG_WRITE'
     110 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_CON, rdma->control,
         |         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:113:9: note: in expansion of macro 'MM_REG_WRITE'
     113 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_BASE_0, rdma->iova[0],
         |         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:115:9: note: in expansion of macro 'MM_REG_WRITE'
     115 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_BASE_1, rdma->iova[1],
         |         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:117:9: note: in expansion of macro 'MM_REG_WRITE'
     117 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_BASE_2, rdma->iova[2],
         |         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:120:9: note: in expansion of macro 'MM_REG_WRITE'
     120 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_END_0,
         |         ^~~~~~~~~~~~
>> drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:122:9: note: in expansion of macro 'MM_REG_WRITE'
     122 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_END_1,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:124:9: note: in expansion of macro 'MM_REG_WRITE'
     124 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_END_2,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:127:9: note: in expansion of macro 'MM_REG_WRITE'
     127 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_MF_BKGD_SIZE_IN_BYTE,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:129:9: note: in expansion of macro 'MM_REG_WRITE'
     129 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SF_BKGD_SIZE_IN_BYTE,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:132:9: note: in expansion of macro 'MM_REG_WRITE'
     132 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_TRANSFORM_0,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: At top level:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:139:38: warning: 'struct mmsys_cmdq_cmd' declared inside parameter list will not be visible outside of this definition or declaration
     139 |                               struct mmsys_cmdq_cmd *cmd, u32 index)
         |                                      ^~~~~~~~~~~~~~
   In file included from drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:11:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c: In function 'config_rdma_subfrm':
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:151:9: note: in expansion of macro 'MM_REG_WRITE'
     151 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_EN, BIT(0), BIT(0));
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:154:9: note: in expansion of macro 'MM_REG_WRITE'
     154 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_OFFSET_0,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:160:25: note: in expansion of macro 'MM_REG_WRITE'
     160 |                         MM_REG_WRITE(cmd, subsys_id, base,
         |                         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:165:9: note: in expansion of macro 'MM_REG_WRITE'
     165 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_OFFSET_1,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
         |         ^~~~~~~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c:168:9: note: in expansion of macro 'MM_REG_WRITE'
     168 |         MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_OFFSET_2,
         |         ^~~~~~~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:14:34: error: invalid use of undefined type 'struct mmsys_cmdq_cmd'
      14 |         cmdq_pkt_write_mask((cmd)->pkt, id, \
         |                                  ^~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h:17:9: note: in expansion of macro 'MM_REG_WRITE_MASK'
      17 |         MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \

..

vim +/id +109 drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h

    12	
    13	#define MM_REG_WRITE_MASK(cmd, id, base, ofst, val, mask, ...) \
  > 14		cmdq_pkt_write_mask((cmd)->pkt, id, \
    15			(base) + (ofst), (val), (mask), ##__VA_ARGS__)
    16	#define MM_REG_WRITE(cmd, id, base, ofst, val, mask, ...) \
    17		MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
    18			(((mask) & (ofst##_MASK)) == (ofst##_MASK)) ? \
    19				(0xffffffff) : (mask), ##__VA_ARGS__)
    20	
    21	#define MM_REG_WAIT(cmd, evt) \
    22		cmdq_pkt_wfe((cmd)->pkt, (cmd)->event[(evt)], true)
    23	
    24	#define MM_REG_WAIT_NO_CLEAR(cmd, evt) \
    25		cmdq_pkt_wfe((cmd)->pkt, (cmd)->event[(evt)], false)
    26	
    27	#define MM_REG_CLEAR(cmd, evt) \
    28		cmdq_pkt_clear_event((cmd)->pkt, (cmd)->event[(evt)])
    29	
    30	#define MM_REG_SET_EVENT(cmd, evt) \
    31		cmdq_pkt_set_event((cmd)->pkt, (cmd)->event[(evt)])
    32	
    33	#define MM_REG_POLL_MASK(cmd, id, base, ofst, val, mask, ...) \
    34		cmdq_pkt_poll_mask((cmd)->pkt, id, \
    35			(base) + (ofst), (val), (mask), ##__VA_ARGS__)
    36	#define MM_REG_POLL(cmd, id, base, ofst, val, mask, ...) \
    37		MM_REG_POLL_MASK((cmd), id, base, ofst, val, \
    38			(((mask) & (ofst##_MASK)) == (ofst##_MASK)) ? \
    39				(0xffffffff) : (mask), ##__VA_ARGS__)
    40	
    41	enum mdp_comp_type {
    42		MDP_COMP_TYPE_INVALID = 0,
    43	
    44		MDP_COMP_TYPE_RDMA,
    45		MDP_COMP_TYPE_RSZ,
    46		MDP_COMP_TYPE_WROT,
    47		MDP_COMP_TYPE_WDMA,
    48		MDP_COMP_TYPE_PATH1,
    49		MDP_COMP_TYPE_PATH2,
    50	
    51		MDP_COMP_TYPE_TDSHP,
    52		MDP_COMP_TYPE_COLOR,
    53		MDP_COMP_TYPE_DRE,
    54		MDP_COMP_TYPE_CCORR,
    55		MDP_COMP_TYPE_HDR,
    56	
    57		MDP_COMP_TYPE_IMGI,
    58		MDP_COMP_TYPE_WPEI,
    59		MDP_COMP_TYPE_EXTO,	/* External path */
    60		MDP_COMP_TYPE_DL_PATH1, /* Direct-link path1 */
    61		MDP_COMP_TYPE_DL_PATH2, /* Direct-link path2 */
    62	
    63		MDP_COMP_TYPE_COUNT	/* ALWAYS keep at the end */
    64	};
    65	
    66	enum mdp_comp_event {
    67		RDMA0_SOF,
    68		RDMA0_DONE,
    69		RSZ0_SOF,
    70		RSZ1_SOF,
    71		TDSHP0_SOF,
    72		WROT0_SOF,
    73		WROT0_DONE,
    74		WDMA0_SOF,
    75		WDMA0_DONE,
    76	
    77		ISP_P2_0_DONE,
    78		ISP_P2_1_DONE,
    79		ISP_P2_2_DONE,
    80		ISP_P2_3_DONE,
    81		ISP_P2_4_DONE,
    82		ISP_P2_5_DONE,
    83		ISP_P2_6_DONE,
    84		ISP_P2_7_DONE,
    85		ISP_P2_8_DONE,
    86		ISP_P2_9_DONE,
    87		ISP_P2_10_DONE,
    88		ISP_P2_11_DONE,
    89		ISP_P2_12_DONE,
    90		ISP_P2_13_DONE,
    91		ISP_P2_14_DONE,
    92	
    93		WPE_DONE,
    94		WPE_B_DONE,
    95	
    96		MDP_MAX_EVENT_COUNT	/* ALWAYS keep at the end */
    97	};
    98	
    99	struct mdp_comp_ops;
   100	
   101	struct mdp_comp {
   102		struct mdp_dev			*mdp_dev;
   103		void __iomem			*regs;
   104		phys_addr_t			reg_base;
   105		u8				subsys_id;
   106		struct clk			*clks[6];
   107		struct device			*comp_dev;
   108		enum mdp_comp_type		type;
 > 109		enum mtk_mdp_comp_id		id;

110 u32 alias_id;
111 const struct mdp_comp_ops *ops;
112 };
113

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#8 lore raw

Re: [PATCH v11 2/3] dts: arm64: mt8183: add Mediatek MDP3 nodes

In reply to Moudy Ho

Il 05/01/22 10:37, Moudy Ho ha scritto:

Quoted 40 lines

Add device nodes for Media Data Path 3 (MDP3) modules.

---
  arch/arm64/boot/dts/mediatek/mt8183.dtsi | 108 ++++++++++++++++++++++-
  1 file changed, 107 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +25 -0
index ba4584faca5a..b872ef1ff6b3 100644
@@ -1325,6 +1325,79 @@
  			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0 0x1000>;
  		};
 
+		mdp3_rdma0: mdp3_rdma0@14001000 {
+			compatible = "mediatek,mt8183-mdp3",
+				     "mediatek,mt8183-mdp3-rdma0";
+			mediatek,scp = <&scp>;
+			mediatek,mdp3-comps = "mediatek,mt8183-mdp3-dl1",
+					      "mediatek,mt8183-mdp3-dl2",
+					      "mediatek,mt8183-mdp3-path1",
+					      "mediatek,mt8183-mdp3-path2",
+					      "mediatek,mt8183-mdp3-imgi",
+					      "mediatek,mt8183-mdp3-exto";
+			reg = <0 0x14001000 0 0x1000>,
+			      <0 0x14000000 0 0x1000>,
+			      <0 0x14005000 0 0x1000>,
+			      <0 0x14006000 0 0x1000>,
+			      <0 0x15020000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x1000 0x1000>,
+						  <&gce SUBSYS_1400XXXX 0 0x1000>,
+						  <&gce SUBSYS_1400XXXX 0x5000 0x1000>,
+						  <&gce SUBSYS_1400XXXX 0x6000 0x1000>,
+						  <&gce SUBSYS_1502XXXX 0 0x1000>;
+			power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+			clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+				 <&mmsys CLK_MM_MDP_RSZ1>,
+				 <&mmsys CLK_MM_MDP_DL_TXCK>,
+				 <&mmsys CLK_MM_MDP_DL_RX>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi line 1362

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8183.dtsi +10 -0
+				 <&mmsys CLK_MM_IPU_DL_TXCK>,
+				 <&mmsys CLK_MM_IPU_DL_RX>;
+			iommus = <&iommu M4U_PORT_MDP_RDMA0>;
+			mediatek,mmsys = <&mmsys>;
+			mediatek,mm-mutex = <&mutex>;
+			mediatek,mailbox-gce = <&gce>;
+			mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST 0>,
+				 <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+				 <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+				 <&gce 23 CMDQ_THR_PRIO_LOWEST>;

Hello Moudy,
the mboxes for gce 21, 22, 23 are missing the third cell. Please fix.

Regards,
Angelo

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8183.dtsi +6 -0
+			gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+				     <&gce 0x14010000 SUBSYS_1401XXXX>,
+				     <&gce 0x14020000 SUBSYS_1402XXXX>,
+				     <&gce 0x15020000 SUBSYS_1502XXXX>;
+		};
+
maintainer
#2 lore raw

Re: [PATCH v11 1/3] dt-binding: mt8183: add Mediatek MDP3 dt-bindings

In reply to Moudy Ho
Quoted 40 lines · Moudy Ho

This patch adds DT binding document for Media Data Path 3 (MDP3) a unit in multimedia system used for scaling and color format convert.

---
 .../bindings/media/mediatek,mdp3-rdma.yaml    | 193 ++++++++++++++++++
 .../bindings/media/mediatek,mdp3-rsz.yaml     |  55 +++++
 .../bindings/media/mediatek,mdp3-wrot.yaml    |  57 ++++++
 .../bindings/soc/mediatek/mediatek,ccorr.yaml |  47 +++++
 .../bindings/soc/mediatek/mediatek,wdma.yaml  |  58 ++++++
 5 files changed, 410 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml
 create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-wrot.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,ccorr.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma.yaml
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +17 -0
new file mode 100644
index 000000000000..002503383934
@@ -0,0 +1,193 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/mediatek,mdp3-rdma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek Read Direct Memory Access
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  Mediatek Read Direct Memory Access(RDMA) component used to do read DMA.
+  It contains one line buffer to store the sufficient pixel data, and
+  must be siblings to the central MMSYS_CONFIG node.
+  For a description of the MMSYS_CONFIG binding, see
+  Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 27

Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +10 -0
+  for details.
+  The 1st RDMA is also used to be a controller node in Media Data Path 3(MDP3)
+  that containing MMSYS, MUTEX, GCE and SCP settings.
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          # MDP3 controller node
+          - const: mediatek,mt8183-mdp3

How is this more specific than this:

Quoted 4 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +3 -0
+          - const: mediatek,mt8183-mdp3-rdma0
 
+      - items:
+          # normal RDMA conponent

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 40

Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +10 -0
+          - const: mediatek,mt8183-mdp3-rdma0
+
+  mediatek,scp:
+    description: The node of system control processor (SCP), using
+      the remoteproc & rpmsg framework.
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mdp3-comps:
+    description: MTK sub-system of direct-link or DIP

This needs a better description. What is DIP? What is direct-link?

Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +10 -0
+    $ref: /schemas/types.yaml#/definitions/string-array
+    items:
+      - enum:
+          # MDP direct-link input path selection, create a
+          # component for path connectedness of HW pipe control
+          - mediatek,mt8183-mdp3-dl1
+      - enum:
+          - mediatek,mt8183-mdp3-dl2
+      - enum:
+          # MDP direct-link output path selection, create a

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 60

Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +10 -0
+          # component for path connectedness of HW pipe control
+          - mediatek,mt8183-mdp3-path1
+      - enum:
+          - mediatek,mt8183-mdp3-path2
+      - enum:
+          # Input DMA of ISP PASS2 (DIP) module for raw image input
+          - mediatek,mt8183-mdp3-imgi
+      - enum:
+          # Output DMA of ISP PASS2 (DIP) module for YUV image output
+          - mediatek,mt8183-mdp3-exto

There's only 1 possible value for mediatek,mdp3-comps, so why does it need to be in DT?

Quoted 32 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +32 -0
+
+  reg:
+    items:
+      - description: basic RDMA HW address
+      - description: MDP direct-link 1st and 2nd input
+      - description: MDP direct-link 1st output
+      - description: MDP direct-link 2nd output
+      - description: ISP input and output
+
+  mediatek,gce-client-reg:
+    description: The register of client driver can be configured by gce with
+      4 arguments defined in this property, such as phandle of gce, subsys id,
+      register offset and size. Each GCE subsys id is mapping to a client
+      defined in the header include/dt-bindings/gce/<chip>-gce.h.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - description: GCE client for RDMA
+      - description: GCR client for MDP direct-link 1st and 2nd input
+      - description: GCR client for MDP direct-link 1st output
+      - description: GCR client for MDP direct-link 2nd output
+      - description: GCR client for ISP input and output
+
+  power-domains:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: RDMA clock
+      - description: RSZ clock
+      - description: direck-link TX clock in MDP side
+      - description: direck-link RX clock in MDP side
+      - description: direck-link TX clock in ISP side

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 102

Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +10 -0
+      - description: direck-link RX clock in ISP side
+
+  iommus:
+    maxItems: 1
+
+  mediatek,mmsys:
+    description: The node of mux(multiplexer) controller for HW connections.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mediatek,mm-mutex:

Is this some sort of h/w lock? We have a standard binding for that.

Quoted 107 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +91 -0
+    description: The node of sof(start of frame) signal controller.
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mailbox-gce:
+    description: The node of global command engine (GCE), used to read/write
+      registers with critical time limitation.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mboxes:
+    items:
+      - description: used for 1st data pipe from RDMA
+      - description: used for 2nd data pipe from RDMA
+      - description: used for 3rd data pipe from Direct-Link
+      - description: used for 4th data pipe from Direct-Link
+
+  gce-subsys:
+    description: sub-system id corresponding to the global command engine (GCE)
+      register address.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+if:
+  properties:
+    compatible:
+      contains:
+        const: mediatek,mt8183-mdp3
+
+then:
+  required:
+    - mediatek,scp
+    - mediatek,mmsys
+    - mediatek,mm-mutex
+    - mediatek,mailbox-gce
+    - mboxes
+    - gce-subsys
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - mediatek,gce-client-reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8183-clk.h>
+    #include <dt-bindings/gce/mt8183-gce.h>
+    #include <dt-bindings/power/mt8183-power.h>
+    #include <dt-bindings/memory/mt8183-larb-port.h>
+
+    mdp3_rdma0: mdp3_rdma0@14001000 {
+      compatible = "mediatek,mt8183-mdp3",
+                   "mediatek,mt8183-mdp3-rdma0";
+      mediatek,scp = <&scp>;
+      mediatek,mdp3-comps = "mediatek,mt8183-mdp3-dl1",
+                            "mediatek,mt8183-mdp3-dl2",
+                            "mediatek,mt8183-mdp3-path1",
+                            "mediatek,mt8183-mdp3-path2",
+                            "mediatek,mt8183-mdp3-imgi",
+                            "mediatek,mt8183-mdp3-exto";
+      reg = <0x14001000 0x1000>,
+            <0x14000000 0x1000>,
+            <0x14005000 0x1000>,
+            <0x14006000 0x1000>,
+            <0x15020000 0x1000>;
+      mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x1000 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0x5000 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0x6000 0x1000>,
+                                <&gce SUBSYS_1502XXXX 0 0x1000>;
+      power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+      clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+               <&mmsys CLK_MM_MDP_RSZ1>,
+               <&mmsys CLK_MM_MDP_DL_TXCK>,
+               <&mmsys CLK_MM_MDP_DL_RX>,
+               <&mmsys CLK_MM_IPU_DL_TXCK>,
+               <&mmsys CLK_MM_IPU_DL_RX>;
+      iommus = <&iommu>;
+      mediatek,mmsys = <&mmsys>;
+      mediatek,mm-mutex = <&mutex>;
+      mediatek,mailbox-gce = <&gce>;
+      mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 23 CMDQ_THR_PRIO_LOWEST>;
+      gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+                   <&gce 0x14010000 SUBSYS_1401XXXX>,
+                   <&gce 0x14020000 SUBSYS_1402XXXX>,
+                   <&gce 0x15020000 SUBSYS_1502XXXX>;
+    };
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +10 -0
new file mode 100644
index 000000000000..cd4cf1531535
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/mediatek,mdp3-rsz.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek Resizer
+
+maintainers:
+  - Matthias Brugger <[email protected]>

Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml line 20

Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +10 -0
+
+description: |
+  One of Media Data Path 3 (MDP3) components used to do frame resizing.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - mediatek,mt8183-mdp3-rsz0
+          - mediatek,mt8183-mdp3-rsz1

Again, what's the difference between 0 and 1?

I've probably asked that before, but without a sufficient reasoning here in the schema I'm just going to keep asking the same question.

Rob

#3 lore raw

Re: [PATCH v11 1/3] dt-binding: mt8183: add Mediatek MDP3 dt-bindings

Il 21/01/22 22:16, Rob Herring ha scritto:

Quoted 1 line · Moudy Ho

Hello Rob,

since I'm not the best at reviewing dt-bindings, I always try to leave that to

other reviewers; in which case, thank you for your awesome review activity on

all of these (and helping me a lot on some of my attempts to write yaml..!!)

In this case, though, since I do have knowledge about the platform, it's probably worth for me to try to address some of your questions, on at least this one.

Quoted 44 lines
Quoted 44 lines

This patch adds DT binding document for Media Data Path 3 (MDP3) a unit in multimedia system used for scaling and color format convert.

---
  .../bindings/media/mediatek,mdp3-rdma.yaml    | 193 ++++++++++++++++++
  .../bindings/media/mediatek,mdp3-rsz.yaml     |  55 +++++
  .../bindings/media/mediatek,mdp3-wrot.yaml    |  57 ++++++
  .../bindings/soc/mediatek/mediatek,ccorr.yaml |  47 +++++
  .../bindings/soc/mediatek/mediatek,wdma.yaml  |  58 ++++++
  5 files changed, 410 insertions(+)

create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml create mode 100644 Documentation/devicetree/bindings/media/mediatek,mdp3-wrot.yaml create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,ccorr.yaml create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma.yaml

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +21 -0
new file mode 100644
index 000000000000..002503383934
@@ -0,0 +1,193 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/mediatek,mdp3-rdma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek Read Direct Memory Access
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  Mediatek Read Direct Memory Access(RDMA) component used to do read DMA.
+  It contains one line buffer to store the sufficient pixel data, and
+  must be siblings to the central MMSYS_CONFIG node.
+  For a description of the MMSYS_CONFIG binding, see
+  Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml
+  for details.
+  The 1st RDMA is also used to be a controller node in Media Data Path 3(MDP3)
+  that containing MMSYS, MUTEX, GCE and SCP settings.
+
Quoted 11 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 27

Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+properties:
+  compatible:
+    oneOf:
+      - items:
+          # MDP3 controller node
+          - const: mediatek,mt8183-mdp3

How is this more specific than this:

Quoted 1 line
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +1 -0
+          - const: mediatek,mt8183-mdp3-rdma0

Probably, oneOf is not the right choice here... "mediatek,mt8183-mdp3" is needed to probe the "main" mdp3 core pdev, while RDMA0 is a necessary component (as in this driver uses the component framework, and rdma0 is required for functionality, as far as I understand).

This shouldn't be a choice, meaning that defining mdp3-rdma0 without mdp3 is completely useless, as there wouldn't be anything else initializing that component, nor sub-components of that.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+      - items:
+          # normal RDMA conponent
+          - const: mediatek,mt8183-mdp3-rdma0
+
+  mediatek,scp:
+    description: The node of system control processor (SCP), using
Quoted 8 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 40

Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+      the remoteproc & rpmsg framework.
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mdp3-comps:
+    description: MTK sub-system of direct-link or DIP

This needs a better description. What is DIP? What is direct-link?

I agree, this needs a better description.

Quoted 22 lines
Quoted 11 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +10 -0
+    $ref: /schemas/types.yaml#/definitions/string-array
+    items:
+      - enum:
+          # MDP direct-link input path selection, create a
+          # component for path connectedness of HW pipe control
+          - mediatek,mt8183-mdp3-dl1
+      - enum:
+          - mediatek,mt8183-mdp3-dl2
+      - enum:
+          # MDP direct-link output path selection, create a

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 60

Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +10 -0
+          # component for path connectedness of HW pipe control
+          - mediatek,mt8183-mdp3-path1
+      - enum:
+          - mediatek,mt8183-mdp3-path2
+      - enum:
+          # Input DMA of ISP PASS2 (DIP) module for raw image input
+          - mediatek,mt8183-mdp3-imgi
+      - enum:
+          # Output DMA of ISP PASS2 (DIP) module for YUV image output
+          - mediatek,mt8183-mdp3-exto
Quoted 3 lines

There's only 1 possible value for mediatek,mdp3-comps, so why does it need to be in DT?

The wanted logic here (I believe) is that, depending on firmware capabilities and/or platform/board capabilities, you may miss some subcomponents like IMGI and/or EXTO.
As for DL1/2 and PATH1/2... DL1+PATH1 is surely critically necessary for the functionality of the MDP3 RDMA... I don't know whether it's possible that we get any fw/platform/device that's not using DL2/PATH2 at all.

Moudy, can you please explain?

Quoted 36 lines
Quoted 36 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +36 -0
+
+  reg:
+    items:
+      - description: basic RDMA HW address
+      - description: MDP direct-link 1st and 2nd input
+      - description: MDP direct-link 1st output
+      - description: MDP direct-link 2nd output
+      - description: ISP input and output
+
+  mediatek,gce-client-reg:
+    description: The register of client driver can be configured by gce with
+      4 arguments defined in this property, such as phandle of gce, subsys id,
+      register offset and size. Each GCE subsys id is mapping to a client
+      defined in the header include/dt-bindings/gce/<chip>-gce.h.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - description: GCE client for RDMA
+      - description: GCR client for MDP direct-link 1st and 2nd input
+      - description: GCR client for MDP direct-link 1st output
+      - description: GCR client for MDP direct-link 2nd output
+      - description: GCR client for ISP input and output
+
+  power-domains:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: RDMA clock
+      - description: RSZ clock
+      - description: direck-link TX clock in MDP side
+      - description: direck-link RX clock in MDP side
+      - description: direck-link TX clock in ISP side
+      - description: direck-link RX clock in ISP side
+
+  iommus:
+    maxItems: 1
Quoted 9 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 102

Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+
+  mediatek,mmsys:
+    description: The node of mux(multiplexer) controller for HW connections.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mediatek,mm-mutex:

Is this some sort of h/w lock? We have a standard binding for that.

There's a story behind that one: this was part of mtk (display) DRM drivers, then it was moved to soc/mediatek/mtk-mutex.c as it started being shared.

I wonder if the mm-mutex can be rewritten and moved to hwspinlock... this driver is growing and now, with the introduction of MDP3, we're seeing some more.

Though, it's definitely worth mentioning that the usage of MediaTek's mm-mutex is varying a bit between the drm case and the mdp3 case as, here, we have a "command queue" mechanism that is used for commands ordering in HW.
This is a very complex architecture that has very specific requirements. For how I see it, migrating that to hwspinlock would require an almost complete reimplementation of soc/mediatek/*, which would take a considerable amount of time and efforts.
I'm mostly sure that I can help with that, but for how things are looking right

now, between refactoring, getting code solid, going through sane reviews and a final merge, I'd say that this will take 8-12 months from now.

For this reason, I would propose to perform a slow and steady migration of the MediaTek mmsys, scpsys, mutex over time, but only after getting in the support for the new SoCs and functionality for the older ones, provided in this series and some others that were already sent by MTK, half (or more) of which have already been merged.

Quoted 120 lines
Quoted 107 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +91 -0
+    description: The node of sof(start of frame) signal controller.
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mailbox-gce:
+    description: The node of global command engine (GCE), used to read/write
+      registers with critical time limitation.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mboxes:
+    items:
+      - description: used for 1st data pipe from RDMA
+      - description: used for 2nd data pipe from RDMA
+      - description: used for 3rd data pipe from Direct-Link
+      - description: used for 4th data pipe from Direct-Link
+
+  gce-subsys:
+    description: sub-system id corresponding to the global command engine (GCE)
+      register address.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+if:
+  properties:
+    compatible:
+      contains:
+        const: mediatek,mt8183-mdp3
+
+then:
+  required:
+    - mediatek,scp
+    - mediatek,mmsys
+    - mediatek,mm-mutex
+    - mediatek,mailbox-gce
+    - mboxes
+    - gce-subsys
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - mediatek,gce-client-reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8183-clk.h>
+    #include <dt-bindings/gce/mt8183-gce.h>
+    #include <dt-bindings/power/mt8183-power.h>
+    #include <dt-bindings/memory/mt8183-larb-port.h>
+
+    mdp3_rdma0: mdp3_rdma0@14001000 {
+      compatible = "mediatek,mt8183-mdp3",
+                   "mediatek,mt8183-mdp3-rdma0";
+      mediatek,scp = <&scp>;
+      mediatek,mdp3-comps = "mediatek,mt8183-mdp3-dl1",
+                            "mediatek,mt8183-mdp3-dl2",
+                            "mediatek,mt8183-mdp3-path1",
+                            "mediatek,mt8183-mdp3-path2",
+                            "mediatek,mt8183-mdp3-imgi",
+                            "mediatek,mt8183-mdp3-exto";
+      reg = <0x14001000 0x1000>,
+            <0x14000000 0x1000>,
+            <0x14005000 0x1000>,
+            <0x14006000 0x1000>,
+            <0x15020000 0x1000>;
+      mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x1000 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0x5000 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0x6000 0x1000>,
+                                <&gce SUBSYS_1502XXXX 0 0x1000>;
+      power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+      clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+               <&mmsys CLK_MM_MDP_RSZ1>,
+               <&mmsys CLK_MM_MDP_DL_TXCK>,
+               <&mmsys CLK_MM_MDP_DL_RX>,
+               <&mmsys CLK_MM_IPU_DL_TXCK>,
+               <&mmsys CLK_MM_IPU_DL_RX>;
+      iommus = <&iommu>;
+      mediatek,mmsys = <&mmsys>;
+      mediatek,mm-mutex = <&mutex>;
+      mediatek,mailbox-gce = <&gce>;
+      mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 23 CMDQ_THR_PRIO_LOWEST>;
+      gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+                   <&gce 0x14010000 SUBSYS_1401XXXX>,
+                   <&gce 0x14020000 SUBSYS_1402XXXX>,
+                   <&gce 0x15020000 SUBSYS_1502XXXX>;
+    };
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +10 -0
new file mode 100644
index 000000000000..cd4cf1531535
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/mediatek,mdp3-rsz.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek Resizer
+
+maintainers:
+  - Matthias Brugger <[email protected]>

Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml line 20

Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +10 -0
+
+description: |
+  One of Media Data Path 3 (MDP3) components used to do frame resizing.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - mediatek,mt8183-mdp3-rsz0
+          - mediatek,mt8183-mdp3-rsz1

Again, what's the difference between 0 and 1?

Quoted 2 lines

I've probably asked that before, but without a sufficient reasoning here in the schema I'm just going to keep asking the same question.

This can probably be, instead, something like

compatible = "mediatek,mt8183-mdp3-rsz";
reg = < .... >;
mediatek,instance-id = <0>;
gce reg, clocks, blah...

or

compatible = "mediatek,mt8183-mdp3-rsz";
reg = < ...rsz0... >, < ...rsz1... >;
reg-names = "rsz0", "rsz1";
gce reg, clocks, blah...

...In any case, if MediaTek chose to separate these like that, I guess that there will be differences in newer SoCs that would make that kind of binding much necessary.

Please Moudy, can you explain why you didn't write that like the examples that I provided there?

Quoted 3 lines

Rob

author
#9 lore raw

Re: [PATCH v11 2/3] dts: arm64: mt8183: add Mediatek MDP3 nodes

In reply to AngeloGioacchino Del Regno
Quoted 70 lines · AngeloGioacchino Del Regno

Il 05/01/22 10:37, Moudy Ho ha scritto:

Quoted 55 lines

Add device nodes for Media Data Path 3 (MDP3) modules.

---
  arch/arm64/boot/dts/mediatek/mt8183.dtsi | 108
++++++++++++++++++++++-
  1 file changed, 107 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +7 -0
index ba4584faca5a..b872ef1ff6b3 100644
@@ -1325,6 +1325,79 @@
  			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX
 0 0x1000>;
  		};
 
+		mdp3_rdma0: mdp3_rdma0@14001000 {
+			compatible = "mediatek,mt8183-mdp3",
+				     "mediatek,mt8183-mdp3-rdma0";
+			mediatek,scp = <&scp>;
+			mediatek,mdp3-comps = "mediatek,mt8183-mdp3-
 dl1",
+					      "mediatek,mt8183-mdp3-
 dl2",
+					      "mediatek,mt8183-mdp3-

path1",

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+					      "mediatek,mt8183-mdp3-

path2",

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+					      "mediatek,mt8183-mdp3-

imgi",

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+					      "mediatek,mt8183-mdp3-

exto";

arch/arm64/boot/dts/mediatek/mt8183.dtsi +6 -0
+			reg = <0 0x14001000 0 0x1000>,
+			      <0 0x14000000 0 0x1000>,
+			      <0 0x14005000 0 0x1000>,
+			      <0 0x14006000 0 0x1000>,
+			      <0 0x15020000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX

0x1000 0x1000>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+						  <&gce SUBSYS_1400XXXX

0 0x1000>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+						  <&gce SUBSYS_1400XXXX

0x5000 0x1000>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+						  <&gce SUBSYS_1400XXXX

0x6000 0x1000>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+						  <&gce SUBSYS_1502XXXX

0 0x1000>;

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+			power-domains = <&spm

MT8183_POWER_DOMAIN_DISP>;

arch/arm64/boot/dts/mediatek/mt8183.dtsi +4 -0
+			clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+				 <&mmsys CLK_MM_MDP_RSZ1>,
+				 <&mmsys CLK_MM_MDP_DL_TXCK>,
+				 <&mmsys CLK_MM_MDP_DL_RX>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi line 1362

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8183.dtsi +10 -0
+				 <&mmsys CLK_MM_IPU_DL_TXCK>,
+				 <&mmsys CLK_MM_IPU_DL_RX>;
+			iommus = <&iommu M4U_PORT_MDP_RDMA0>;
+			mediatek,mmsys = <&mmsys>;
+			mediatek,mm-mutex = <&mutex>;
+			mediatek,mailbox-gce = <&gce>;
+			mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST 0>,
+				 <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+				 <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+				 <&gce 23 CMDQ_THR_PRIO_LOWEST>;

Hello Moudy,
the mboxes for gce 21, 22, 23 are missing the third cell. Please fix.

Quoted 2 lines

Regards,
Angelo

Hi Angelo,
Thanks for the reminder, but I'm a bit confused, the previous version(v10) mentioned that the current upstream mbox has only 2 cells.
So I should follow this rule to remove the extra 0 in the first item as follows:
+ mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST>,
+ <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+ <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+ <&gce 23 CMDQ_THR_PRIO_LOWEST>;

Thanks,
Moudy Ho

Quoted 9 lines

arch/arm64/boot/dts/mediatek/mt8183.dtsi line 1368

Quoted 7 lines
arch/arm64/boot/dts/mediatek/mt8183.dtsi +6 -0
+			gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+				     <&gce 0x14010000 SUBSYS_1401XXXX>,
+				     <&gce 0x14020000 SUBSYS_1402XXXX>,
+				     <&gce 0x15020000 SUBSYS_1502XXXX>;
+		};
+

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

author
#4 lore raw

Re: [PATCH v11 1/3] dt-binding: mt8183: add Mediatek MDP3 dt-bindings

In reply to AngeloGioacchino Del Regno
Quoted 103 lines · AngeloGioacchino Del Regno

Il 21/01/22 22:16, Rob Herring ha scritto:

Quoted 1 line · Moudy Ho

Hello Rob,

since I'm not the best at reviewing dt-bindings, I always try to leave that to

other reviewers; in which case, thank you for your awesome review activity on

all of these (and helping me a lot on some of my attempts to write yaml..!!)

In this case, though, since I do have knowledge about the platform, it's probably
worth for me to try to address some of your questions, on at least this one.

Quoted 63 lines
Quoted 63 lines

This patch adds DT binding document for Media Data Path 3 (MDP3) a unit in multimedia system used for scaling and color format convert.

---
  .../bindings/media/mediatek,mdp3-rdma.yaml    | 193
++++++++++++++++++
  .../bindings/media/mediatek,mdp3-rsz.yaml     |  55 +++++
  .../bindings/media/mediatek,mdp3-wrot.yaml    |  57 ++++++
  .../bindings/soc/mediatek/mediatek,ccorr.yaml |  47 +++++
  .../bindings/soc/mediatek/mediatek,wdma.yaml  |  58 ++++++
  5 files changed, 410 insertions(+)

create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml
create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml
create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3-wrot.yaml
create mode 100644
Documentation/devicetree/bindings/soc/mediatek/mediatek,ccorr.yam l
create mode 100644
Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma.yaml

diff --git a/Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml b/Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file mode 100644
index 000000000000..002503383934

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +0 -0

rdma.yaml

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +4 -0
@@ -0,0 +1,193 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/media/mediatek,mdp3-rdma.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtt5fpkQb$

+$schema:
https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtk8-fzFI$

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +8 -0
+
+title: Mediatek Read Direct Memory Access
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  Mediatek Read Direct Memory Access(RDMA) component used to do

read DMA.
+ It contains one line buffer to store the sufficient pixel data, and

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +3 -0
+  must be siblings to the central MMSYS_CONFIG node.
+  For a description of the MMSYS_CONFIG binding, see
+  Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.

yaml

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +2 -0
+  for details.
+  The 1st RDMA is also used to be a controller node in Media

Data Path 3(MDP3)

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +2 -0
+  that containing MMSYS, MUTEX, GCE and SCP settings.
+
Quoted 10 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-

Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3- new file +6 -0
+properties:
+  compatible:
+    oneOf:
+      - items:
+          # MDP3 controller node
+          - const: mediatek,mt8183-mdp3

How is this more specific than this:

Quoted 1 line

+ - const: mediatek,mt8183-mdp3-rdma0

Probably, oneOf is not the right choice here... "mediatek,mt8183- mdp3" is needed
to probe the "main" mdp3 core pdev, while RDMA0 is a necessary component (as in
this driver uses the component framework, and rdma0 is required for functionality,
as far as I understand).

Quoted 6 lines

This shouldn't be a choice, meaning that defining mdp3-rdma0 without mdp3 is
completely useless, as there wouldn't be anything else initializing that component,
nor sub-components of that.

Hi Rob and Angelo,
Sorry for the incomplete description here, I originally planned to add a compatible name here in the future when the chip has multiple RDMAs. Since 8183 currently has only one RDMA, the above design expression is incorrect and should be rewritten as follows:

[8183]
properties:
compatible:
items:
# MDP3 controller node
- const: mediatek,mt8183-mdp3
- const: mediatek,mt8195-mdp3-rdma0

[8195]
properties:
compatible:
oneOf:
- items:
# MDP3 controller node
- const: mediatek,mt8183-mdp3
- const: mediatek,mt8195-mdp3-rdma0
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma1
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma2
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma3

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/media/mediatek,mdp3- new file +6 -0
+      - items:
+          # normal RDMA conponent
+          - const: mediatek,mt8183-mdp3-rdma0
+
+  mediatek,scp:
+    description: The node of system control processor (SCP),

using

Quoted 8 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-

Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3- new file +6 -0
+      the remoteproc & rpmsg framework.
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mdp3-comps:
+    description: MTK sub-system of direct-link or DIP

This needs a better description. What is DIP? What is direct-link?

Quoted 2 lines

I agree, this needs a better description.

I tried to modify the description as follows, could you help to see if there is anything confusing:

mediatek,mdp3-comps:
description:
MDP subsystem which has direct-link from Image Signal
Processor(ISP).
When using the camera, the DMA of ISP PASS (DIP) module will
directly trigger MDP3 without other control (such as V4L2 M2M) to create corresponding HW path.
The MDP3 controller must set up a series of registers at the
beginning of path creation which covering MMSYS, IMGSYS, and MDP3's components, so that data flow can pass through MDP3.

      The entire path is briefly described as follows:
      DIP   : ISP ->
      MDP3  :       IMGI -> DL -> CCORR(optional) -> RSZ -> PATH_OUT ->

WDMA/WROT

Quoted 40 lines
Quoted 24 lines
Quoted 21 lines
Documentation/devicetree/bindings/media/mediatek,mdp3- new file +16 -0
+    $ref: /schemas/types.yaml#/definitions/string-array
+    items:
+      - enum:
+          # MDP direct-link input path selection, create a
+          # component for path connectedness of HW pipe control
+          - mediatek,mt8183-mdp3-dl1
+      - enum:
+          - mediatek,mt8183-mdp3-dl2
+      - enum:
+          # MDP direct-link output path selection, create a
+          # component for path connectedness of HW pipe control
+          - mediatek,mt8183-mdp3-path1
+      - enum:
+          - mediatek,mt8183-mdp3-path2
+      - enum:
+          # Input DMA of ISP PASS2 (DIP) module for raw image

input

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +3 -0
+          - mediatek,mt8183-mdp3-imgi
+      - enum:
+          # Output DMA of ISP PASS2 (DIP) module for YUV image
Quoted 2 lines

output
+ - mediatek,mt8183-mdp3-exto

Quoted 4 lines

There's only 1 possible value for mediatek,mdp3-comps, so why does it
need to be in DT?

The wanted logic here (I believe) is that, depending on firmware capabilities
and/or platform/board capabilities, you may miss some subcomponents like IMGI
and/or EXTO.
As for DL1/2 and PATH1/2... DL1+PATH1 is surely critically necessary for the
functionality of the MDP3 RDMA... I don't know whether it's possible that we
get any fw/platform/device that's not using DL2/PATH2 at all.

Quoted 2 lines

Moudy, can you please explain?

Hi Angelo,
Thanks for your help and your assumptions are correct.
In further chips(such as 8195), IMGI will be replaced by WPE, and
PATH_OUT will be removed, and DL will be expanded to 6 (implicit number of direct-link from ISP paths).
For this variable hardware design, not sure how to flexibly describe
in dt-bindings to meet futher requirements.
It should be that I got wrong with the definition of "enum", should
it be rewritten as follows in 8183?
items:
- enum:
# MDP direct-link input path selection, create a
# component for path connectedness of HW pipe control
- mediatek,mt8183-mdp3-dl1
- mediatek,mt8183-mdp3-dl2
# MDP direct-link output path selection, create a # component for path connectedness of HW pipe control
- mediatek,mt8183-mdp3-path1
- mediatek,mt8183-mdp3-path2
# Input DMA of ISP PASS2 (DIP) module for raw image input
- mediatek,mt8183-mdp3-imgi
# Output DMA of ISP PASS2 (DIP) module for YUV image output
- mediatek,mt8183-mdp3-exto
items: (8195)
snip....
items: (8192)
snip...

Quoted 80 lines
Quoted 42 lines
Quoted 42 lines
Documentation/devicetree/bindings/media/mediatek,mdp3- new file +11 -0
+
+  reg:
+    items:
+      - description: basic RDMA HW address
+      - description: MDP direct-link 1st and 2nd input
+      - description: MDP direct-link 1st output
+      - description: MDP direct-link 2nd output
+      - description: ISP input and output
+
+  mediatek,gce-client-reg:
+    description: The register of client driver can be configured

by gce with
+ 4 arguments defined in this property, such as phandle of
gce, subsys id,
+ register offset and size. Each GCE subsys id is mapping to
a client
+ defined in the header include/dt-bindings/gce/<chip>-
gce.h.

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +4 -0
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - description: GCE client for RDMA
+      - description: GCR client for MDP direct-link 1st and 2nd

input

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +19 -0
+      - description: GCR client for MDP direct-link 1st output
+      - description: GCR client for MDP direct-link 2nd output
+      - description: GCR client for ISP input and output
+
+  power-domains:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: RDMA clock
+      - description: RSZ clock
+      - description: direck-link TX clock in MDP side
+      - description: direck-link RX clock in MDP side
+      - description: direck-link TX clock in ISP side
+      - description: direck-link RX clock in ISP side
+
+  iommus:
+    maxItems: 1
+
Quoted 9 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-

Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3- new file +2 -0
+  mediatek,mmsys:
+    description: The node of mux(multiplexer) controller for HW

connections.

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +3 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mediatek,mm-mutex:

Is this some sort of h/w lock? We have a standard binding for that.

There's a story behind that one: this was part of mtk (display) DRM drivers, then
it was moved to soc/mediatek/mtk-mutex.c as it started being shared.

I wonder if the mm-mutex can be rewritten and moved to hwspinlock... this driver
is growing and now, with the introduction of MDP3, we're seeing some more.

Though, it's definitely worth mentioning that the usage of MediaTek's mm-mutex is
varying a bit between the drm case and the mdp3 case as, here, we have a "command
queue" mechanism that is used for commands ordering in HW. This is a very complex architecture that has very specific requirements.
For how I see it, migrating that to hwspinlock would require an almost complete
reimplementation of soc/mediatek/*, which would take a considerable amount of
time and efforts.
I'm mostly sure that I can help with that, but for how things are looking right

now, between refactoring, getting code solid, going through sane reviews and a
final merge, I'd say that this will take 8-12 months from now.

Quoted 9 lines

For this reason, I would propose to perform a slow and steady migration of the
MediaTek mmsys, scpsys, mutex over time, but only after getting in the support
for the new SoCs and functionality for the older ones, provided in this series
and some others that were already sent by MTK, half (or more) of which have
already been merged.

Sorry for the misunderstanding caused by the name, the original mtk-
mutex design did have the ability to lock registers, but that has since been removed but the name continues.
It's not one of those h/w locks like spinlock, semaphore, or mutex
but is just designed to send signals to trigger h/w components to get or send data.

Quoted 158 lines
Quoted 134 lines
Quoted 124 lines

+ description: The node of sof(start of frame) signal
controller.

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +5 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mailbox-gce:
+    description: The node of global command engine (GCE), used

to read/write

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +12 -0
+      registers with critical time limitation.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mboxes:
+    items:
+      - description: used for 1st data pipe from RDMA
+      - description: used for 2nd data pipe from RDMA
+      - description: used for 3rd data pipe from Direct-Link
+      - description: used for 4th data pipe from Direct-Link
+
+  gce-subsys:
+    description: sub-system id corresponding to the global

command engine (GCE)

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +49 -0
+      register address.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+if:
+  properties:
+    compatible:
+      contains:
+        const: mediatek,mt8183-mdp3
+
+then:
+  required:
+    - mediatek,scp
+    - mediatek,mmsys
+    - mediatek,mm-mutex
+    - mediatek,mailbox-gce
+    - mboxes
+    - gce-subsys
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - mediatek,gce-client-reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8183-clk.h>
+    #include <dt-bindings/gce/mt8183-gce.h>
+    #include <dt-bindings/power/mt8183-power.h>
+    #include <dt-bindings/memory/mt8183-larb-port.h>
+
+    mdp3_rdma0: mdp3_rdma0@14001000 {
+      compatible = "mediatek,mt8183-mdp3",
+                   "mediatek,mt8183-mdp3-rdma0";
+      mediatek,scp = <&scp>;
+      mediatek,mdp3-comps = "mediatek,mt8183-mdp3-dl1",
+                            "mediatek,mt8183-mdp3-dl2",
+                            "mediatek,mt8183-mdp3-path1",
+                            "mediatek,mt8183-mdp3-path2",
+                            "mediatek,mt8183-mdp3-imgi",
+                            "mediatek,mt8183-mdp3-exto";
+      reg = <0x14001000 0x1000>,
+            <0x14000000 0x1000>,
+            <0x14005000 0x1000>,
+            <0x14006000 0x1000>,
+            <0x15020000 0x1000>;
+      mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x1000

0x1000>,

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +2 -0
+                                <&gce SUBSYS_1400XXXX 0 0x1000>,
+                                <&gce SUBSYS_1400XXXX 0x5000

0x1000>,
+ <&gce SUBSYS_1400XXXX 0x6000
0x1000>,

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +21 -0
+                                <&gce SUBSYS_1502XXXX 0 0x1000>;
+      power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+      clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+               <&mmsys CLK_MM_MDP_RSZ1>,
+               <&mmsys CLK_MM_MDP_DL_TXCK>,
+               <&mmsys CLK_MM_MDP_DL_RX>,
+               <&mmsys CLK_MM_IPU_DL_TXCK>,
+               <&mmsys CLK_MM_IPU_DL_RX>;
+      iommus = <&iommu>;
+      mediatek,mmsys = <&mmsys>;
+      mediatek,mm-mutex = <&mutex>;
+      mediatek,mailbox-gce = <&gce>;
+      mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 23 CMDQ_THR_PRIO_LOWEST>;
+      gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+                   <&gce 0x14010000 SUBSYS_1401XXXX>,
+                   <&gce 0x14020000 SUBSYS_1402XXXX>,
+                   <&gce 0x15020000 SUBSYS_1502XXXX>;
+    };

diff --git a/Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml b/Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file mode 100644
index 000000000000..cd4cf1531535

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +0 -0

rsz.yaml

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +4 -0
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/media/mediatek,mdp3-rsz.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtoNRPuZQ$

+$schema:
https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtk8-fzFI$

Documentation/devicetree/bindings/media/mediatek,mdp3- new file +8 -0
+
+title: Mediatek Resizer
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  One of Media Data Path 3 (MDP3) components used to do frame

resizing.

Documentation/devicetree/bindings/media/mediatek,mdp3-

Quoted 7 lines
Documentation/devicetree/bindings/media/mediatek,mdp3- new file +7 -0
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - mediatek,mt8183-mdp3-rsz0
+          - mediatek,mt8183-mdp3-rsz1

Again, what's the difference between 0 and 1?

Quoted 2 lines

I've probably asked that before, but without a sufficient reasoning here in the schema I'm just going to keep asking the same question.

This can probably be, instead, something like

compatible = "mediatek,mt8183-mdp3-rsz";
reg = < .... >;
mediatek,instance-id = <0>;
gce reg, clocks, blah...

or

compatible = "mediatek,mt8183-mdp3-rsz";
reg = < ...rsz0... >, < ...rsz1... >;
reg-names = "rsz0", "rsz1";
gce reg, clocks, blah...

...In any case, if MediaTek chose to separate these like that, I guess that
there will be differences in newer SoCs that would make that kind of binding
much necessary.

Quoted 3 lines

Please Moudy, can you explain why you didn't write that like the examples
that I provided there?

Before version 10 it was written the same way as the first form Angelo mentioned - with h/w indexed properties, but Rob thinks it's bad idea. At that time I asked Rob if it could be rewritten into its current V11 form, but I updated before I got a suggestion.
Apologize for the inconvenience casued by my careless handling.

In the 8183 MDP3, only RSZ is configured with 2 sets. The 1st set upstream can have quality adjustment components (like AAL or CCORR or both) connected, but the 2nd set does not.
Although those two RSZ components have the same hardware function but register address. The MDP paths with different functions will be created due to the different upstream and downstream connections. In addition to the various upstream/downstream connection methods caused by chip design, the above conditions are also dynamically determined according to the current usage scenario(with or without PQ, rotation...etc).
Also, considering that multiple paths are used at the same time, MDP3 will need to know which components are currently available for dispatch.
At present, I can't find a better description form, let me know if you have any thoughts with this.

Quoted 3 lines
Quoted 3 lines

Rob

Thanks,
Moudy

Quoted 1 line

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#10 lore raw

Re: [PATCH v11 2/3] dts: arm64: mt8183: add Mediatek MDP3 nodes

In reply to moudy ho

Il 25/01/22 09:20, moudy ho ha scritto:

Quoted 85 lines · AngeloGioacchino Del Regno
Quoted 70 lines

Il 05/01/22 10:37, Moudy Ho ha scritto:

Quoted 55 lines

Add device nodes for Media Data Path 3 (MDP3) modules.

---
   arch/arm64/boot/dts/mediatek/mt8183.dtsi | 108
++++++++++++++++++++++-
   1 file changed, 107 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +7 -0
index ba4584faca5a..b872ef1ff6b3 100644
@@ -1325,6 +1325,79 @@
   			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX
 0 0x1000>;
   		};
 
+		mdp3_rdma0: mdp3_rdma0@14001000 {
+			compatible = "mediatek,mt8183-mdp3",
+				     "mediatek,mt8183-mdp3-rdma0";
+			mediatek,scp = <&scp>;
+			mediatek,mdp3-comps = "mediatek,mt8183-mdp3-
 dl1",
+					      "mediatek,mt8183-mdp3-
 dl2",
+					      "mediatek,mt8183-mdp3-

path1",

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+					      "mediatek,mt8183-mdp3-

path2",

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+					      "mediatek,mt8183-mdp3-

imgi",

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+					      "mediatek,mt8183-mdp3-

exto";

arch/arm64/boot/dts/mediatek/mt8183.dtsi +6 -0
+			reg = <0 0x14001000 0 0x1000>,
+			      <0 0x14000000 0 0x1000>,
+			      <0 0x14005000 0 0x1000>,
+			      <0 0x14006000 0 0x1000>,
+			      <0 0x15020000 0 0x1000>;
+			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX

0x1000 0x1000>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+						  <&gce SUBSYS_1400XXXX

0 0x1000>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+						  <&gce SUBSYS_1400XXXX

0x5000 0x1000>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+						  <&gce SUBSYS_1400XXXX

0x6000 0x1000>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+						  <&gce SUBSYS_1502XXXX

0 0x1000>;

arch/arm64/boot/dts/mediatek/mt8183.dtsi +1 -0
+			power-domains = <&spm

MT8183_POWER_DOMAIN_DISP>;

arch/arm64/boot/dts/mediatek/mt8183.dtsi +4 -0
+			clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+				 <&mmsys CLK_MM_MDP_RSZ1>,
+				 <&mmsys CLK_MM_MDP_DL_TXCK>,
+				 <&mmsys CLK_MM_MDP_DL_RX>,

arch/arm64/boot/dts/mediatek/mt8183.dtsi line 1362

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8183.dtsi +10 -0
+				 <&mmsys CLK_MM_IPU_DL_TXCK>,
+				 <&mmsys CLK_MM_IPU_DL_RX>;
+			iommus = <&iommu M4U_PORT_MDP_RDMA0>;
+			mediatek,mmsys = <&mmsys>;
+			mediatek,mm-mutex = <&mutex>;
+			mediatek,mailbox-gce = <&gce>;
+			mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST 0>,
+				 <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+				 <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+				 <&gce 23 CMDQ_THR_PRIO_LOWEST>;

Hello Moudy,
the mboxes for gce 21, 22, 23 are missing the third cell. Please fix.

Quoted 2 lines

Regards,
Angelo

Hi Angelo,
Thanks for the reminder, but I'm a bit confused, the previous version(v10) mentioned that the current upstream mbox has only 2 cells.
So I should follow this rule to remove the extra 0 in the first item as follows:
+ mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST>,
+ <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+ <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+ <&gce 23 CMDQ_THR_PRIO_LOWEST>;

Quoted 2 lines

Thanks,
Moudy Ho

Hello Moudy,
I'm sorry for this confusion and you are totally right in the proposed solution, which is the exact opposite of what I said.

Thanks for understanding,
Angelo

Quoted 10 lines
Quoted 9 lines
Quoted 7 lines
arch/arm64/boot/dts/mediatek/mt8183.dtsi +6 -0
+			gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+				     <&gce 0x14010000 SUBSYS_1401XXXX>,
+				     <&gce 0x14020000 SUBSYS_1402XXXX>,
+				     <&gce 0x15020000 SUBSYS_1502XXXX>;
+		};
+
#14 lore raw

Re: [PATCH v11 3/3] media: platform: mtk-mdp3: add Mediatek MDP3 driver

In reply to Moudy Ho

Le 05/01/2022 à 10:37, Moudy Ho a écrit :

drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c

Quoted 3,977 lines

This patch adds driver for Mediatek's Media Data Path ver.3 (MDP3). It provides the following functions:
color transform, format conversion, resize, crop, rotate, flip and additional image quality enhancement.

The MDP3 driver is mainly used for Google Chromebook products to import the new architecture to set the HW settings as shown below:

   User -> V4L2 framework
     -> MDP3 driver -> SCP (setting calculations)
       -> MDP3 driver -> CMDQ (GCE driver) -> HW

Each modules' related operation control is sited in mtk-mdp3-comp.c Each modules' register table is defined in file with "mdp_reg_" prefix GCE related API, operation control sited in mtk-mdp3-cmdq.c V4L2 m2m device functions are implemented in mtk-mdp3-m2m.c Probe, power, suspend/resume, system level functions are defined in mtk-mdp3-core.c

---
Depend on:
[1]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ [2]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ [3]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ [4]https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

---
  drivers/media/platform/Kconfig                |   20 +
  drivers/media/platform/Makefile               |    2 +
  drivers/media/platform/mtk-mdp3/Makefile      |    6 +
  .../media/platform/mtk-mdp3/mdp_reg_ccorr.h   |   19 +
  drivers/media/platform/mtk-mdp3/mdp_reg_isp.h |   27 +
  .../media/platform/mtk-mdp3/mdp_reg_rdma.h    |   65 +
  drivers/media/platform/mtk-mdp3/mdp_reg_rsz.h |   39 +
  .../media/platform/mtk-mdp3/mdp_reg_wdma.h    |   47 +
  .../media/platform/mtk-mdp3/mdp_reg_wrot.h    |   55 +
  drivers/media/platform/mtk-mdp3/mtk-img-ipi.h |  280 ++++
  .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.c   |  515 +++++++
  .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
  .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1228 +++++++++++++++++
  .../media/platform/mtk-mdp3/mtk-mdp3-comp.h   |  147 ++
  .../media/platform/mtk-mdp3/mtk-mdp3-core.c   |  338 +++++
  .../media/platform/mtk-mdp3/mtk-mdp3-core.h   |   76 +
  .../media/platform/mtk-mdp3/mtk-mdp3-m2m.c    |  789 +++++++++++
  .../media/platform/mtk-mdp3/mtk-mdp3-m2m.h    |   49 +
  .../media/platform/mtk-mdp3/mtk-mdp3-regs.c   |  737 ++++++++++
  .../media/platform/mtk-mdp3/mtk-mdp3-regs.h   |  372 +++++
  .../media/platform/mtk-mdp3/mtk-mdp3-vpu.c    |  312 +++++
  .../media/platform/mtk-mdp3/mtk-mdp3-vpu.h    |   78 ++
  22 files changed, 5247 insertions(+)

create mode 100644 drivers/media/platform/mtk-mdp3/Makefile create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_ccorr.h create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_isp.h create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_rdma.h create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_rsz.h create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_wdma.h create mode 100644 drivers/media/platform/mtk-mdp3/mdp_reg_wrot.h create mode 100644 drivers/media/platform/mtk-mdp3/mtk-img-ipi.h create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.h create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.h create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c create mode 100644 drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.h

drivers/media/platform/Kconfig +20 -0
index cf4adc64c953..f879b93a623b 100644
@@ -315,6 +315,26 @@ config VIDEO_MEDIATEK_MDP
  	    To compile this driver as a module, choose M here: the
  	    module will be called mtk-mdp.
 
+config VIDEO_MEDIATEK_MDP3
+	tristate "Mediatek MDP v3 driver"
+	depends on MTK_IOMMU || COMPLIE_TEST
+	depends on VIDEO_DEV && VIDEO_V4L2
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	depends on MTK_MMSYS
+	depends on HAS_DMA
+	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_MEM2MEM_DEV
+	select VIDEO_MEDIATEK_VPU
+	select MTK_CMDQ
+	select MTK_SCP
+	default n
+	help
+	    It is a v4l2 driver and present in Mediatek MT8183 SoC.
+	    The driver supports for scaling and color space conversion.
+
+	    To compile this driver as a module, choose M here: the
+	    module will be called mtk-mdp3.
+
  config VIDEO_MEDIATEK_VCODEC
  	tristate "Mediatek Video Codec driver"
  	depends on MTK_IOMMU || COMPILE_TEST
drivers/media/platform/Makefile +2 -0
index a148553babfc..29bdfa92a09a 100644
@@ -78,6 +78,8 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC)	+= mtk-vcodec/
 
  obj-$(CONFIG_VIDEO_MEDIATEK_MDP)	+= mtk-mdp/
 
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP3)	+= mtk-mdp3/
+
  obj-$(CONFIG_VIDEO_MEDIATEK_JPEG)	+= mtk-jpeg/
 
  obj-$(CONFIG_VIDEO_QCOM_CAMSS)		+= qcom/camss/
drivers/media/platform/mtk-mdp3/Makefile new file +6 -0
new file mode 100644
index 000000000000..8772f5ac2867
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+mtk-mdp3-y += mtk-mdp3-core.o mtk-mdp3-vpu.o mtk-mdp3-regs.o
+mtk-mdp3-y += mtk-mdp3-m2m.o
+mtk-mdp3-y += mtk-mdp3-comp.o mtk-mdp3-cmdq.o
+
+obj-$(CONFIG_VIDEO_MEDIATEK_MDP3) += mtk-mdp3.o
\ No newline at end of file
drivers/media/platform/mtk-mdp3/mdp_reg_ccorr.h new file +19 -0
new file mode 100644
index 000000000000..46804d97db1f
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MDP_REG_CCORR_H__
+#define __MDP_REG_CCORR_H__
+
+#define MDP_CCORR_EN                0x000
+#define MDP_CCORR_CFG               0x020
+#define MDP_CCORR_SIZE              0x030
+
+/* MASK */
+#define MDP_CCORR_EN_MASK           0x00000001
+#define MDP_CCORR_CFG_MASK          0x70001317
+#define MDP_CCORR_SIZE_MASK         0x1fff1fff
+
+#endif  // __MDP_REG_CCORR_H__
drivers/media/platform/mtk-mdp3/mdp_reg_isp.h new file +27 -0
new file mode 100644
index 000000000000..5334cd932b55
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __ISP_REG_H__
+#define __ISP_REG_H__
+
+enum isp_dip_cq {
+	ISP_DRV_DIP_CQ_THRE0 = 0,
+	ISP_DRV_DIP_CQ_THRE1,
+	ISP_DRV_DIP_CQ_THRE2,
+	ISP_DRV_DIP_CQ_THRE3,
+	ISP_DRV_DIP_CQ_THRE4,
+	ISP_DRV_DIP_CQ_THRE5,
+	ISP_DRV_DIP_CQ_THRE6,
+	ISP_DRV_DIP_CQ_THRE7,
+	ISP_DRV_DIP_CQ_THRE8,
+	ISP_DRV_DIP_CQ_THRE9,
+	ISP_DRV_DIP_CQ_THRE10,
+	ISP_DRV_DIP_CQ_THRE11,
+	ISP_DRV_DIP_CQ_NUM,
+	ISP_DRV_DIP_CQ_NONE,
+};
+
+#endif  // __ISP_REG_H__
drivers/media/platform/mtk-mdp3/mdp_reg_rdma.h new file +65 -0
new file mode 100644
index 000000000000..59d9aae40be6
@@ -0,0 +1,65 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MDP_REG_RDMA_H__
+#define __MDP_REG_RDMA_H__
+
+#define MDP_RDMA_EN                     0x000
+#define MDP_RDMA_RESET                  0x008
+#define MDP_RDMA_CON                    0x020
+#define MDP_RDMA_GMCIF_CON              0x028
+#define MDP_RDMA_SRC_CON                0x030
+#define MDP_RDMA_MF_BKGD_SIZE_IN_BYTE   0x060
+#define MDP_RDMA_MF_BKGD_SIZE_IN_PXL    0x068
+#define MDP_RDMA_MF_SRC_SIZE            0x070
+#define MDP_RDMA_MF_CLIP_SIZE           0x078
+#define MDP_RDMA_MF_OFFSET_1            0x080
+#define MDP_RDMA_SF_BKGD_SIZE_IN_BYTE   0x090
+#define MDP_RDMA_SRC_END_0              0x100
+#define MDP_RDMA_SRC_END_1              0x108
+#define MDP_RDMA_SRC_END_2              0x110
+#define MDP_RDMA_SRC_OFFSET_0           0x118
+#define MDP_RDMA_SRC_OFFSET_1           0x120
+#define MDP_RDMA_SRC_OFFSET_2           0x128
+#define MDP_RDMA_SRC_OFFSET_0_P         0x148
+#define MDP_RDMA_TRANSFORM_0            0x200
+#define MDP_RDMA_RESV_DUMMY_0           0x2a0
+#define MDP_RDMA_MON_STA_1              0x408
+#define MDP_RDMA_SRC_BASE_0             0xf00
+#define MDP_RDMA_SRC_BASE_1             0xf08
+#define MDP_RDMA_SRC_BASE_2             0xf10
+#define MDP_RDMA_UFO_DEC_LENGTH_BASE_Y  0xf20
+#define MDP_RDMA_UFO_DEC_LENGTH_BASE_C  0xf28
+
+/* MASK */
+#define MDP_RDMA_EN_MASK                    0x00000001
+#define MDP_RDMA_RESET_MASK                 0x00000001
+#define MDP_RDMA_CON_MASK                   0x00001110
+#define MDP_RDMA_GMCIF_CON_MASK             0xfffb3771
+#define MDP_RDMA_SRC_CON_MASK               0xf3ffffff
+#define MDP_RDMA_MF_BKGD_SIZE_IN_BYTE_MASK  0x001fffff
+#define MDP_RDMA_MF_BKGD_SIZE_IN_PXL_MASK   0x001fffff
+#define MDP_RDMA_MF_SRC_SIZE_MASK           0x1fff1fff
+#define MDP_RDMA_MF_CLIP_SIZE_MASK          0x1fff1fff
+#define MDP_RDMA_MF_OFFSET_1_MASK           0x003f001f
+#define MDP_RDMA_SF_BKGD_SIZE_IN_BYTE_MASK  0x001fffff
+#define MDP_RDMA_SRC_END_0_MASK             0xffffffff
+#define MDP_RDMA_SRC_END_1_MASK             0xffffffff
+#define MDP_RDMA_SRC_END_2_MASK             0xffffffff
+#define MDP_RDMA_SRC_OFFSET_0_MASK          0xffffffff
+#define MDP_RDMA_SRC_OFFSET_1_MASK          0xffffffff
+#define MDP_RDMA_SRC_OFFSET_2_MASK          0xffffffff
+#define MDP_RDMA_SRC_OFFSET_0_P_MASK        0xffffffff
+#define MDP_RDMA_TRANSFORM_0_MASK           0xff110777
+#define MDP_RDMA_RESV_DUMMY_0_MASK          0xffffffff
+#define MDP_RDMA_MON_STA_1_MASK             0xffffffff
+#define MDP_RDMA_SRC_BASE_0_MASK            0xffffffff
+#define MDP_RDMA_SRC_BASE_1_MASK            0xffffffff
+#define MDP_RDMA_SRC_BASE_2_MASK            0xffffffff
+#define MDP_RDMA_UFO_DEC_LENGTH_BASE_Y_MASK 0xffffffff
+#define MDP_RDMA_UFO_DEC_LENGTH_BASE_C_MASK 0xffffffff
+
+#endif  // __MDP_REG_RDMA_H__
drivers/media/platform/mtk-mdp3/mdp_reg_rsz.h new file +39 -0
new file mode 100644
index 000000000000..051fdb020741
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MDP_REG_RSZ_H__
+#define __MDP_REG_RSZ_H__
+
+#define PRZ_ENABLE                                        0x000
+#define PRZ_CONTROL_1                                     0x004
+#define PRZ_CONTROL_2                                     0x008
+#define PRZ_INPUT_IMAGE                                   0x010
+#define PRZ_OUTPUT_IMAGE                                  0x014
+#define PRZ_HORIZONTAL_COEFF_STEP                         0x018
+#define PRZ_VERTICAL_COEFF_STEP                           0x01c
+#define PRZ_LUMA_HORIZONTAL_INTEGER_OFFSET                0x020
+#define PRZ_LUMA_HORIZONTAL_SUBPIXEL_OFFSET               0x024
+#define PRZ_LUMA_VERTICAL_INTEGER_OFFSET                  0x028
+#define PRZ_LUMA_VERTICAL_SUBPIXEL_OFFSET                 0x02c
+#define PRZ_CHROMA_HORIZONTAL_INTEGER_OFFSET              0x030
+#define PRZ_CHROMA_HORIZONTAL_SUBPIXEL_OFFSET             0x034
+
+/* MASK */
+#define PRZ_ENABLE_MASK                                   0x00010001
+#define PRZ_CONTROL_1_MASK                                0xfffffff3
+#define PRZ_CONTROL_2_MASK                                0x0ffffaff
+#define PRZ_INPUT_IMAGE_MASK                              0xffffffff
+#define PRZ_OUTPUT_IMAGE_MASK                             0xffffffff
+#define PRZ_HORIZONTAL_COEFF_STEP_MASK                    0x007fffff
+#define PRZ_VERTICAL_COEFF_STEP_MASK                      0x007fffff
+#define PRZ_LUMA_HORIZONTAL_INTEGER_OFFSET_MASK           0x0000ffff
+#define PRZ_LUMA_HORIZONTAL_SUBPIXEL_OFFSET_MASK          0x001fffff
+#define PRZ_LUMA_VERTICAL_INTEGER_OFFSET_MASK             0x0000ffff
+#define PRZ_LUMA_VERTICAL_SUBPIXEL_OFFSET_MASK            0x001fffff
+#define PRZ_CHROMA_HORIZONTAL_INTEGER_OFFSET_MASK         0x0000ffff
+#define PRZ_CHROMA_HORIZONTAL_SUBPIXEL_OFFSET_MASK        0x001fffff
+
+#endif // __MDP_REG_RSZ_H__
drivers/media/platform/mtk-mdp3/mdp_reg_wdma.h new file +47 -0
new file mode 100644
index 000000000000..4dc540f1fb5f
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MDP_REG_WDMA_H__
+#define __MDP_REG_WDMA_H__
+
+#define WDMA_EN                 0x008
+#define WDMA_RST                0x00c
+#define WDMA_CFG                0x014
+#define WDMA_SRC_SIZE           0x018
+#define WDMA_CLIP_SIZE          0x01c
+#define WDMA_CLIP_COORD         0x020
+#define WDMA_DST_W_IN_BYTE      0x028
+#define WDMA_ALPHA              0x02c
+#define WDMA_BUF_CON2           0x03c
+#define WDMA_DST_UV_PITCH       0x078
+#define WDMA_DST_ADDR_OFFSET    0x080
+#define WDMA_DST_U_ADDR_OFFSET  0x084
+#define WDMA_DST_V_ADDR_OFFSET  0x088
+#define WDMA_FLOW_CTRL_DBG      0x0a0
+#define WDMA_DST_ADDR           0xf00
+#define WDMA_DST_U_ADDR         0xf04
+#define WDMA_DST_V_ADDR         0xf08
+
+/* MASK */
+#define WDMA_EN_MASK                0x00000001
+#define WDMA_RST_MASK               0x00000001
+#define WDMA_CFG_MASK               0xff03bff0
+#define WDMA_SRC_SIZE_MASK          0x3fff3fff
+#define WDMA_CLIP_SIZE_MASK         0x3fff3fff
+#define WDMA_CLIP_COORD_MASK        0x3fff3fff
+#define WDMA_DST_W_IN_BYTE_MASK     0x0000ffff
+#define WDMA_ALPHA_MASK             0x800000ff
+#define WDMA_BUF_CON2_MASK          0xffffffff
+#define WDMA_DST_UV_PITCH_MASK      0x0000ffff
+#define WDMA_DST_ADDR_OFFSET_MASK   0x0fffffff
+#define WDMA_DST_U_ADDR_OFFSET_MASK 0x0fffffff
+#define WDMA_DST_V_ADDR_OFFSET_MASK 0x0fffffff
+#define WDMA_FLOW_CTRL_DBG_MASK     0x0000f3ff
+#define WDMA_DST_ADDR_MASK          0xffffffff
+#define WDMA_DST_U_ADDR_MASK        0xffffffff
+#define WDMA_DST_V_ADDR_MASK        0xffffffff
+
+#endif  // __MDP_REG_WDMA_H__
drivers/media/platform/mtk-mdp3/mdp_reg_wrot.h new file +55 -0
new file mode 100644
index 000000000000..39b8785f89eb
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MDP_REG_WROT_H__
+#define __MDP_REG_WROT_H__
+
+#define VIDO_CTRL                   0x000
+#define VIDO_MAIN_BUF_SIZE          0x008
+#define VIDO_SOFT_RST               0x010
+#define VIDO_SOFT_RST_STAT          0x014
+#define VIDO_CROP_OFST              0x020
+#define VIDO_TAR_SIZE               0x024
+#define VIDO_OFST_ADDR              0x02c
+#define VIDO_STRIDE                 0x030
+#define VIDO_OFST_ADDR_C            0x038
+#define VIDO_STRIDE_C               0x03c
+#define VIDO_DITHER                 0x054
+#define VIDO_STRIDE_V               0x06c
+#define VIDO_OFST_ADDR_V            0x068
+#define VIDO_RSV_1                  0x070
+#define VIDO_IN_SIZE                0x078
+#define VIDO_ROT_EN                 0x07c
+#define VIDO_FIFO_TEST              0x080
+#define VIDO_MAT_CTRL               0x084
+#define VIDO_BASE_ADDR              0xf00
+#define VIDO_BASE_ADDR_C            0xf04
+#define VIDO_BASE_ADDR_V            0xf08
+
+/* MASK */
+#define VIDO_CTRL_MASK                  0xf530711f
+#define VIDO_MAIN_BUF_SIZE_MASK         0x1fff7f77
+#define VIDO_SOFT_RST_MASK              0x00000001
+#define VIDO_SOFT_RST_STAT_MASK         0x00000001
+#define VIDO_TAR_SIZE_MASK              0x1fff1fff
+#define VIDO_CROP_OFST_MASK             0x1fff1fff
+#define VIDO_OFST_ADDR_MASK             0x0fffffff
+#define VIDO_STRIDE_MASK                0x0000ffff
+#define VIDO_OFST_ADDR_C_MASK           0x0fffffff
+#define VIDO_STRIDE_C_MASK              0x0000ffff
+#define VIDO_DITHER_MASK                0xff000001
+#define VIDO_STRIDE_V_MASK              0x0000ffff
+#define VIDO_OFST_ADDR_V_MASK           0x0fffffff
+#define VIDO_RSV_1_MASK                 0xffffffff
+#define VIDO_IN_SIZE_MASK               0x1fff1fff
+#define VIDO_ROT_EN_MASK                0x00000001
+#define VIDO_FIFO_TEST_MASK             0x00000fff
+#define VIDO_MAT_CTRL_MASK              0x000000f3
+#define VIDO_BASE_ADDR_MASK             0xffffffff
+#define VIDO_BASE_ADDR_C_MASK           0xffffffff
+#define VIDO_BASE_ADDR_V_MASK           0xffffffff
+
+#endif  // __MDP_REG_WROT_H__
drivers/media/platform/mtk-mdp3/mtk-img-ipi.h new file +280 -0
new file mode 100644
index 000000000000..f8560dad87da
@@ -0,0 +1,280 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Holmes Chiou <[email protected]>
+ *         Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MTK_IMG_IPI_H__
+#define __MTK_IMG_IPI_H__
+
+#include <linux/types.h>
+
+/* ISP-MDP generic input information */
+
+#define IMG_MAX_HW_INPUTS	3
+
+#define IMG_MAX_HW_OUTPUTS	4
+
+#define IMG_MAX_PLANES		3
+
+#define IMG_IPI_INIT    1
+#define IMG_IPI_DEINIT  2
+#define IMG_IPI_FRAME   3
+#define IMG_IPI_DEBUG   4
+
+struct img_addr {
+	u64 va; /* Used for Linux OS access */
+	u32 pa; /* Used for CM4 access */
+	u32 iova; /* Used for IOMMU HW access */
+} __packed;
+
+struct tuning_addr {
+	u64	present;
+	u32	pa;	/* Used for CM4 access */
+	u32	iova;	/* Used for IOMMU HW access */
+} __packed;
+
+struct img_sw_addr {
+	u64 va; /* Used for APMCU access */
+	u32 pa; /* Used for CM4 access */
+} __packed;
+
+struct img_plane_format {
+	u32 size;
+	u16 stride;
+} __packed;
+
+struct img_pix_format {
+	u16 width;
+	u16 height;
+	u32 colorformat; /* enum mdp_color */
+	u16 ycbcr_prof; /* enum mdp_ycbcr_profile */
+	struct img_plane_format plane_fmt[IMG_MAX_PLANES];
+} __packed;
+
+struct img_image_buffer {
+	struct img_pix_format format;
+	u32 iova[IMG_MAX_PLANES];
+	/* enum mdp_buffer_usage, FD or advanced ISP usages */
+	u32 usage;
+} __packed;
+
+#define IMG_SUBPIXEL_SHIFT	20
+
+struct img_crop {
+	s16 left;
+	s16 top;
+	u16 width;
+	u16 height;
+	u32 left_subpix;
+	u32 top_subpix;
+	u32 width_subpix;
+	u32 height_subpix;
+} __packed;
+
+#define IMG_CTRL_FLAG_HFLIP	BIT(0)
+#define IMG_CTRL_FLAG_DITHER	BIT(1)
+#define IMG_CTRL_FLAG_SHARPNESS	BIT(4)
+#define IMG_CTRL_FLAG_HDR	BIT(5)
+#define IMG_CTRL_FLAG_DRE	BIT(6)
+
+struct img_input {
+	struct img_image_buffer buffer;
+	u16 flags; /* HDR, DRE, dither */
+} __packed;
+
+struct img_output {
+	struct img_image_buffer buffer;
+	struct img_crop crop;
+	s16 rotation;
+	u16 flags; /* H-flip, sharpness, dither */
+} __packed;
+
+struct img_ipi_frameparam {
+	u32 index;
+	u32 frame_no;
+	u64 timestamp;
+	u8 type; /* enum mdp_stream_type */
+	u8 state;
+	u8 num_inputs;
+	u8 num_outputs;
+	u64 drv_data;
+	struct img_input inputs[IMG_MAX_HW_INPUTS];
+	struct img_output outputs[IMG_MAX_HW_OUTPUTS];
+	struct tuning_addr tuning_data;
+	struct img_addr subfrm_data;
+	struct img_sw_addr config_data;
+	struct img_sw_addr self_data;
+} __packed;
+
+struct img_sw_buffer {
+	u64	handle;		/* Used for APMCU access */
+	u32	scp_addr;	/* Used for CM4 access */
+} __packed;
+
+struct img_ipi_param {
+	u8 usage;
+	struct img_sw_buffer frm_param;
+} __packed;
+
+struct img_frameparam {
+	struct list_head list_entry;
+	struct img_ipi_frameparam frameparam;
+};
+
+/* ISP-MDP generic output information */
+
+struct img_comp_frame {
+	u32 output_disable:1;
+	u32 bypass:1;
+	u16 in_width;
+	u16 in_height;
+	u16 out_width;
+	u16 out_height;
+	struct img_crop crop;
+	u16 in_total_width;
+	u16 out_total_width;
+} __packed;
+
+struct img_region {
+	s16 left;
+	s16 right;
+	s16 top;
+	s16 bottom;
+} __packed;
+
+struct img_offset {
+	s16 left;
+	s16 top;
+	u32 left_subpix;
+	u32 top_subpix;
+} __packed;
+
+struct img_comp_subfrm {
+	u32 tile_disable:1;
+	struct img_region in;
+	struct img_region out;
+	struct img_offset luma;
+	struct img_offset chroma;
+	s16 out_vertical; /* Output vertical index */
+	s16 out_horizontal; /* Output horizontal index */
+} __packed;
+
+#define IMG_MAX_SUBFRAMES	14
+
+struct mdp_rdma_subfrm {
+	u32 offset[IMG_MAX_PLANES];
+	u32 offset_0_p;
+	u32 src;
+	u32 clip;
+	u32 clip_ofst;
+} __packed;
+
+struct mdp_rdma_data {
+	u32 src_ctrl;
+	u32 control;
+	u32 iova[IMG_MAX_PLANES];
+	u32 iova_end[IMG_MAX_PLANES];
+	u32 mf_bkgd;
+	u32 mf_bkgd_in_pxl;
+	u32 sf_bkgd;
+	u32 ufo_dec_y;
+	u32 ufo_dec_c;
+	u32 transform;
+	struct mdp_rdma_subfrm subfrms[IMG_MAX_SUBFRAMES];
+} __packed;
+
+struct mdp_rsz_subfrm {
+	u32 control2;
+	u32 src;
+	u32 clip;
+} __packed;
+
+struct mdp_rsz_data {
+	u32 coeff_step_x;
+	u32 coeff_step_y;
+	u32 control1;
+	u32 control2;
+	struct mdp_rsz_subfrm subfrms[IMG_MAX_SUBFRAMES];
+} __packed;
+
+struct mdp_wrot_subfrm {
+	u32 offset[IMG_MAX_PLANES];
+	u32 src;
+	u32 clip;
+	u32 clip_ofst;
+	u32 main_buf;
+} __packed;
+
+struct mdp_wrot_data {
+	u32 iova[IMG_MAX_PLANES];
+	u32 control;
+	u32 stride[IMG_MAX_PLANES];
+	u32 mat_ctrl;
+	u32 fifo_test;
+	u32 filter;
+	struct mdp_wrot_subfrm subfrms[IMG_MAX_SUBFRAMES];
+} __packed;
+
+struct mdp_wdma_subfrm {
+	u32 offset[IMG_MAX_PLANES];
+	u32 src;
+	u32 clip;
+	u32 clip_ofst;
+} __packed;
+
+struct mdp_wdma_data {
+	u32 wdma_cfg;
+	u32 iova[IMG_MAX_PLANES];
+	u32 w_in_byte;
+	u32 uv_stride;
+	struct mdp_wdma_subfrm subfrms[IMG_MAX_SUBFRAMES];
+} __packed;
+
+struct isp_data {
+	u64 dl_flags; /* 1 << (enum mdp_comp_type) */
+	u32 smxi_iova[4];
+	u32 cq_idx;
+	u32 cq_iova;
+	u32 tpipe_iova[IMG_MAX_SUBFRAMES];
+} __packed;
+
+struct img_compparam {
+	u16 type; /* enum mdp_comp_type */
+	u16 id; /* enum mtk_mdp_comp_id */
+	u32 input;
+	u32 outputs[IMG_MAX_HW_OUTPUTS];
+	u32 num_outputs;
+	struct img_comp_frame frame;
+	struct img_comp_subfrm subfrms[IMG_MAX_SUBFRAMES];
+	u32 num_subfrms;
+	union {
+		struct mdp_rdma_data rdma;
+		struct mdp_rsz_data rsz;
+		struct mdp_wrot_data wrot;
+		struct mdp_wdma_data wdma;
+		struct isp_data isp;
+	};
+} __packed;
+
+#define IMG_MAX_COMPONENTS	20
+
+struct img_mux {
+	u32 reg;
+	u32 value;
+};
+
+struct img_mmsys_ctrl {
+	struct img_mux sets[IMG_MAX_COMPONENTS * 2];
+	u32 num_sets;
+};
+
+struct img_config {
+	struct img_compparam components[IMG_MAX_COMPONENTS];
+	u32 num_components;
+	struct img_mmsys_ctrl ctrls[IMG_MAX_SUBFRAMES];
+	u32 num_subfrms;
+} __packed;
+
+#endif  /* __MTK_IMG_IPI_H__ */
drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c new file +515 -0
new file mode 100644
index 000000000000..4a08502952d6
@@ -0,0 +1,515 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#include <linux/platform_device.h>
+#include "mtk-mdp3-cmdq.h"
+#include "mtk-mdp3-comp.h"
+#include "mtk-mdp3-core.h"
+#include "mtk-mdp3-m2m.h"
+
+#define MDP_PATH_MAX_COMPS	IMG_MAX_COMPONENTS
+
+struct mdp_path {
+	struct mdp_dev		*mdp_dev;
+	struct mdp_comp_ctx	comps[MDP_PATH_MAX_COMPS];
+	u32			num_comps;
+	const struct img_config	*config;
+	const struct img_ipi_frameparam *param;
+	const struct v4l2_rect	*composes[IMG_MAX_HW_OUTPUTS];
+	struct v4l2_rect	bounds[IMG_MAX_HW_OUTPUTS];
+};
+
+#define has_op(ctx, op) \
+	((ctx)->comp->ops && (ctx)->comp->ops->op)
+#define call_op(ctx, op, ...) \
+	(has_op(ctx, op) ? (ctx)->comp->ops->op(ctx, ##__VA_ARGS__) : 0)
+
+struct mdp_path_subfrm {
+	s32	mutex_id;
+	u32	mutex_mod;
+	s32	sofs[MDP_PATH_MAX_COMPS];
+	u32	num_sofs;
+};
+
+static bool is_output_disable(const struct img_compparam *param, u32 count)
+{
+	return (count < param->num_subfrms) ?
+		(param->frame.output_disable ||
+		param->subfrms[count].tile_disable) :
+		true;
+}
+
+static int mdp_path_subfrm_require(struct mdp_path_subfrm *subfrm,
+				   const struct mdp_path *path,
+				   struct mmsys_cmdq_cmd *cmd, u32 count)
+{
+	const struct img_config *config = path->config;
+	const struct mdp_comp_ctx *ctx;
+	struct device *dev = &path->mdp_dev->pdev->dev;
+	struct mtk_mutex **mutex = path->mdp_dev->mdp_mutex;
+	s32 mutex_id = -1;
+	u32 mutex_bit = 0;
+	int index, id;
+
+	/* Default value */
+	memset(subfrm, 0, sizeof(*subfrm));
+
+	/* Decide which mutex to use based on the current pipeline */
+	switch (path->comps[0].comp->id) {
+	case MDP_COMP_RDMA0:
+		mutex_id = MDP_PIPE_RDMA0;
+		break;
+	case MDP_COMP_ISP_IMGI:
+		mutex_id = MDP_PIPE_IMGI;
+		break;
+	case MDP_COMP_WPEI:
+		mutex_id = MDP_PIPE_WPEI;
+		break;
+	case MDP_COMP_WPEI2:
+		mutex_id = MDP_PIPE_WPEI2;
+		break;
+	default:
+		dev_err(dev, "Unknown pipeline and no mutex is assigned");
+		return -EINVAL;
+	}
+	subfrm->mutex_id = mutex_id;
+
+	/* Set mutex mod */
+	for (index = 0; index < config->num_components; index++) {
+		ctx = &path->comps[index];
+		if (is_output_disable(ctx->param, count))
+			continue;
+		id = ctx->comp->id;
+		switch (id) {
+		case MDP_COMP_AAL0:
+		case MDP_COMP_CCORR0:
+		case MDP_COMP_WDMA:
+		case MDP_COMP_WROT0:
+		case MDP_COMP_TDSHP0:
+		case MDP_COMP_RSZ1:
+		case MDP_COMP_RSZ0:
+		case MDP_COMP_RDMA0:
+			mutex_bit = mtk_mutex_get_mdp_mod(mutex[mutex_id], id);
+			subfrm->mutex_mod |= mutex_bit;
+			break;
+		default:
+			break;
+		}
+	}
+
+	if (subfrm->mutex_mod)
+		mtk_mutex_add_mod_by_cmdq(mutex[mutex_id], subfrm->mutex_mod, cmd);
+
+	/* Set SOF */
+	for (index = 0; index < config->num_components; index++) {
+		ctx = &path->comps[index];
+		if (is_output_disable(ctx->param, count))
+			continue;
+		id = ctx->comp->id;
+		switch (id) {
+		case MDP_COMP_WDMA:
+		case MDP_COMP_WROT0:
+		case MDP_COMP_TDSHP0:
+		case MDP_COMP_RSZ1:
+		case MDP_COMP_RSZ0:
+		case MDP_COMP_RDMA0:
+			subfrm->sofs[subfrm->num_sofs++] = id;
+			break;
+		default:
+			break;
+		}
+	}
+
+	return 0;
+}
+
+static int mdp_path_subfrm_run(const struct mdp_path_subfrm *subfrm,
+			       const struct mdp_path *path,
+			       struct mmsys_cmdq_cmd *cmd)
+{
+	struct device *dev = &path->mdp_dev->pdev->dev;
+	struct mtk_mutex **mutex = path->mdp_dev->mdp_mutex;
+	s32 mutex_id = subfrm->mutex_id;
+
+	if (-1 == mutex_id) {
+		dev_err(dev, "Incorrect mutex id");
+		return -EINVAL;
+	}
+
+	if (subfrm->mutex_mod) {
+		int index;
+
+		/* Wait WROT SRAM shared to DISP RDMA */
+		/* Clear SOF event for each engine */
+		for (index = 0; index < subfrm->num_sofs; index++) {
+			switch (subfrm->sofs[index]) {
+			case MDP_COMP_RDMA0:
+				MM_REG_CLEAR(cmd, RDMA0_SOF);
+				break;
+			case MDP_COMP_TDSHP0:
+				MM_REG_CLEAR(cmd, TDSHP0_SOF);
+				break;
+			case MDP_COMP_RSZ0:
+				MM_REG_CLEAR(cmd, RSZ0_SOF);
+				break;
+			case MDP_COMP_RSZ1:
+				MM_REG_CLEAR(cmd, RSZ1_SOF);
+				break;
+			case MDP_COMP_WDMA:
+				MM_REG_CLEAR(cmd, WDMA0_SOF);
+				break;
+			case MDP_COMP_WROT0:
+				MM_REG_CLEAR(cmd, WROT0_SOF);
+				break;
+			default:
+				break;
+			}
+		}
+
+		/* Enable the mutex */
+		mtk_mutex_enable_by_cmdq(mutex[mutex_id], cmd);
+
+		/* Wait SOF events and clear mutex modules (optional) */
+		for (index = 0; index < subfrm->num_sofs; index++) {
+			switch (subfrm->sofs[index]) {
+			case MDP_COMP_RDMA0:
+				MM_REG_WAIT(cmd, RDMA0_SOF);
+				break;
+			case MDP_COMP_TDSHP0:
+				MM_REG_WAIT(cmd, TDSHP0_SOF);
+				break;
+			case MDP_COMP_RSZ0:
+				MM_REG_WAIT(cmd, RSZ0_SOF);
+				break;
+			case MDP_COMP_RSZ1:
+				MM_REG_WAIT(cmd, RSZ1_SOF);
+				break;
+			case MDP_COMP_WDMA:
+				MM_REG_WAIT(cmd, WDMA0_SOF);
+				break;
+			case MDP_COMP_WROT0:
+				MM_REG_WAIT(cmd, WROT0_SOF);
+				break;
+			default:
+				break;
+			}
+		}
+	}
+	return 0;
+}
+
+static int mdp_path_ctx_init(struct mdp_dev *mdp, struct mdp_path *path)
+{
+	const struct img_config *config = path->config;
+	int index, ret;
+
+	if (config->num_components < 1)
+		return -EINVAL;
+
+	for (index = 0; index < config->num_components; index++) {
+		ret = mdp_comp_ctx_init(mdp, &path->comps[index],
+					&config->components[index],
+					path->param);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int mdp_path_config_subfrm(struct mmsys_cmdq_cmd *cmd,
+				  struct mdp_path *path, u32 count)
+{
+	struct mdp_path_subfrm subfrm;
+	const struct img_config *config = path->config;
+	const struct img_mmsys_ctrl *ctrl = &config->ctrls[count];
+	const struct img_mux *set;
+	struct device *mmsys_dev = path->mdp_dev->mdp_mmsys;
+	struct mdp_comp_ctx *ctx;
+	int index, ret;
+
+	/* Acquire components */
+	ret = mdp_path_subfrm_require(&subfrm, path, cmd, count);
+	if (ret)
+		return ret;
+	/* Enable mux settings */
+	for (index = 0; index < ctrl->num_sets; index++) {
+		set = &ctrl->sets[index];
+		mmsys_dev = path->mdp_dev->mdp_mmsys;
+
+		mtk_mmsys_write_reg_by_cmdq(mmsys_dev, cmd,
+					    set->reg, set->value, 0xFFFFFFFF);
+	}
+	/* Config sub-frame information */
+	for (index = (config->num_components - 1); index >= 0; index--) {
+		ctx = &path->comps[index];
+		if (is_output_disable(ctx->param, count))
+			continue;
+		ret = call_op(ctx, config_subfrm, cmd, count);
+		if (ret)
+			return ret;
+	}
+	/* Run components */
+	ret = mdp_path_subfrm_run(&subfrm, path, cmd);
+	if (ret)
+		return ret;
+	/* Wait components done */
+	for (index = 0; index < config->num_components; index++) {
+		ctx = &path->comps[index];
+		if (is_output_disable(ctx->param, count))
+			continue;
+		ret = call_op(ctx, wait_comp_event, cmd);
+		if (ret)
+			return ret;
+	}
+	/* Advance to the next sub-frame */
+	for (index = 0; index < config->num_components; index++) {
+		ctx = &path->comps[index];
+		ret = call_op(ctx, advance_subfrm, cmd, count);
+		if (ret)
+			return ret;
+	}
+	/* Disable mux settings */
+	for (index = 0; index < ctrl->num_sets; index++) {
+		set = &ctrl->sets[index];
+		mmsys_dev = path->mdp_dev->mdp_mmsys;
+
+		mtk_mmsys_write_reg_by_cmdq(mmsys_dev, cmd,
+					    set->reg, 0, 0xFFFFFFFF);
+	}
+
+	return 0;
+}
+
+static int mdp_path_config(struct mdp_dev *mdp, struct mmsys_cmdq_cmd *cmd,
+			   struct mdp_path *path)
+{
+	const struct img_config *config = path->config;
+	struct mdp_comp_ctx *ctx;
+	int index, count, ret;
+
+	/* Config path frame */
+	/* Reset components */
+	for (index = 0; index < config->num_components; index++) {
+		ctx = &path->comps[index];
+		ret = call_op(ctx, init_comp, cmd);
+		if (ret)
+			return ret;
+	}
+	/* Config frame mode */
+	for (index = 0; index < config->num_components; index++) {
+		const struct v4l2_rect *compose =
+			path->composes[ctx->param->outputs[0]];
+
+		ctx = &path->comps[index];
+		ret = call_op(ctx, config_frame, cmd, compose);
+		if (ret)
+			return ret;
+	}
+
+	/* Config path sub-frames */
+	for (count = 0; count < config->num_subfrms; count++) {
+		ret = mdp_path_config_subfrm(cmd, path, count);
+		if (ret)
+			return ret;
+	}
+	/* Post processing information */
+	for (index = 0; index < config->num_components; index++) {
+		ctx = &path->comps[index];
+		ret = call_op(ctx, post_process, cmd);
+		if (ret)
+			return ret;
+	}
+	return 0;
+}
+
+static void mdp_auto_release_work(struct work_struct *work)
+{
+	struct mdp_cmdq_cb_param *cb_param;
+	struct mdp_dev *mdp;
+
+	cb_param = container_of(work, struct mdp_cmdq_cb_param,
+				auto_release_work);
+	mdp = cb_param->mdp;
+
+	mtk_mutex_unprepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]);
+	mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps,
+			    cb_param->num_comps);
+
+	kfree(cb_param->comps);
+	kfree(cb_param);
+
+	atomic_dec(&mdp->job_count);
+	wake_up(&mdp->callback_wq);
+}
+
+static void mdp_handle_cmdq_callback(struct cmdq_cb_data data)
+{
+	struct mdp_cmdq_cb_param *cb_param;
+	struct mdp_dev *mdp;
+	struct device *dev;
+
+	if (!data.data) {
+		pr_info("%s:no callback data\n", __func__);
+		return;
+	}
+
+	cb_param = (struct mdp_cmdq_cb_param *)data.data;
+	mdp = cb_param->mdp;
+	dev = &mdp->pdev->dev;
+
+	if (cb_param->mdp_ctx)
+		mdp_m2m_job_finish(cb_param->mdp_ctx);
+
+	if (cb_param->user_cmdq_cb) {
+		struct cmdq_cb_data user_cb_data;
+
+		user_cb_data.sta = data.sta;
+		user_cb_data.data = cb_param->user_cb_data;
+		cb_param->user_cmdq_cb(user_cb_data);
+	}
+
+	cmdq_pkt_destroy(cb_param->pkt);
+	INIT_WORK(&cb_param->auto_release_work, mdp_auto_release_work);
+	if (!queue_work(mdp->clock_wq, &cb_param->auto_release_work)) {
+		dev_err(dev, "%s:queue_work fail!\n", __func__);
+		mtk_mutex_unprepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]);
+		mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps,
+				    cb_param->num_comps);
+
+		kfree(cb_param->comps);
+		kfree(cb_param);
+
+		atomic_dec(&mdp->job_count);
+		wake_up(&mdp->callback_wq);
+	}
+}
+
+int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)
+{
+	struct mmsys_cmdq_cmd cmd;
+	struct mdp_path *path = NULL;
+	struct mdp_cmdq_cb_param *cb_param = NULL;
+	struct mdp_comp *comps = NULL;
+	struct device *dev = &mdp->pdev->dev;
+	int i, ret;
+
+	if (atomic_read(&mdp->suspended))
+		return -ECANCELED;
+
+	atomic_inc(&mdp->job_count);
+
+	cmd.pkt = cmdq_pkt_create(mdp->cmdq_clt, SZ_16K);
+	if (IS_ERR(cmd.pkt)) {
+		atomic_dec(&mdp->job_count);
+		wake_up(&mdp->callback_wq);
+		return PTR_ERR(cmd.pkt);
+	}
+	cmd.event = &mdp->event[0];
+
+	path = kzalloc(sizeof(*path), GFP_KERNEL);
+	if (!path) {
+		ret = -ENOMEM;
+		goto err_destroy_pkt;
+	}
+
+	path->mdp_dev = mdp;
+	path->config = param->config;
+	path->param = param->param;
+	for (i = 0; i < param->param->num_outputs; i++) {
+		path->bounds[i].left = 0;
+		path->bounds[i].top = 0;
+		path->bounds[i].width =
+			param->param->outputs[i].buffer.format.width;
+		path->bounds[i].height =
+			param->param->outputs[i].buffer.format.height;
+		path->composes[i] = param->composes[i] ?
+			param->composes[i] : &path->bounds[i];
+	}
+
+	ret = mdp_path_ctx_init(mdp, path);
+	if (ret) {
+		dev_err(dev, "mdp_path_ctx_init error\n");
+		goto err_destroy_pkt;
+	}
+
+	mtk_mutex_prepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]);
+	for (i = 0; i < param->config->num_components; i++)
+		mdp_comp_clock_on(&mdp->pdev->dev, path->comps[i].comp);
+
+	ret = mdp_path_config(mdp, &cmd, path);
+	if (ret) {
+		dev_err(dev, "mdp_path_config error\n");
+		goto err_destroy_pkt;
+	}
+
+	cb_param = kzalloc(sizeof(*cb_param), GFP_KERNEL);
+	if (!cb_param) {
+		ret = -ENOMEM;
+		goto err_destroy_pkt;
+	}
+
+	comps = kcalloc(param->config->num_components, sizeof(*comps),
+			GFP_KERNEL);
+	if (!comps) {
+		ret = -ENOMEM;
+		goto err_destroy_pkt;
+	}
+
+	for (i = 0; i < param->config->num_components; i++)
+		memcpy(&comps[i], path->comps[i].comp,
+		       sizeof(struct mdp_comp));
+	cb_param->mdp = mdp;
+	cb_param->user_cmdq_cb = param->cmdq_cb;
+	cb_param->user_cb_data = param->cb_data;
+	cb_param->pkt = cmd.pkt;
+	cb_param->comps = comps;
+	cb_param->num_comps = param->config->num_components;
+	cb_param->mdp_ctx = param->mdp_ctx;
+
+	cmdq_pkt_finalize(cmd.pkt);
+	ret = cmdq_pkt_flush_async(cmd.pkt,
+				   mdp_handle_cmdq_callback,
+				   (void *)cb_param);
+	if (ret) {
+		dev_err(dev, "cmdq_pkt_flush_async fail!\n");
+		goto err_clock_off;
+	}
+	kfree(path);
+	return 0;
+
+err_clock_off:
+	mtk_mutex_unprepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]);
+	mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps,
+			    cb_param->num_comps);
+err_destroy_pkt:
+	cmdq_pkt_destroy(cmd.pkt);
+	atomic_dec(&mdp->job_count);
+	wake_up(&mdp->callback_wq);
+	kfree(comps);
+	kfree(cb_param);
+	kfree(path);
+
+	return ret;
+}
+
+int mdp_cmdq_sendtask(struct platform_device *pdev, struct img_config *config,
+		      struct img_ipi_frameparam *param,
+		      struct v4l2_rect *compose,
+		      void (*cmdq_cb)(struct cmdq_cb_data data), void *cb_data)
+{
+	struct mdp_dev *mdp = platform_get_drvdata(pdev);
+	struct mdp_cmdq_param task = {
+		.config = config,
+		.param = param,
+		.composes[0] = compose,
+		.cmdq_cb = cmdq_cb,
+		.cb_data = cb_data,
+	};
+
+	return mdp_cmdq_send(mdp, &task);
+}
+EXPORT_SYMBOL_GPL(mdp_cmdq_sendtask);
drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.h new file +46 -0
new file mode 100644
index 000000000000..16933507333b
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MTK_MDP3_CMDQ_H__
+#define __MTK_MDP3_CMDQ_H__
+
+#include <linux/platform_device.h>
+#include <linux/videodev2.h>
+#include <linux/soc/mediatek/mtk-cmdq.h>
+#include "mtk-img-ipi.h"
+
+struct platform_device *mdp_get_plat_device(struct platform_device *pdev);
+
+int mdp_cmdq_sendtask(struct platform_device *pdev, struct img_config *config,
+		      struct img_ipi_frameparam *param, struct v4l2_rect *compose,
+		      void (*cmdq_cb)(struct cmdq_cb_data data), void *cb_data);
+
+struct mdp_cmdq_param {
+	struct img_config *config;
+	struct img_ipi_frameparam *param;
+	const struct v4l2_rect *composes[IMG_MAX_HW_OUTPUTS];
+
+	void (*cmdq_cb)(struct cmdq_cb_data data);
+	void *cb_data;
+	void *mdp_ctx;
+};
+
+struct mdp_cmdq_cb_param {
+	struct work_struct auto_release_work;
+	struct mdp_dev *mdp;
+	void (*user_cmdq_cb)(struct cmdq_cb_data data);
+	void *user_cb_data;
+	struct cmdq_pkt *pkt;
+	struct mdp_comp *comps;
+	u8 num_comps;
+	void *mdp_ctx;
+};
+
+struct mdp_dev;
+
+int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param);
+
+#endif  /* __MTK_MDP3_CMDQ_H__ */
drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c new file +1228 -0
new file mode 100644
index 000000000000..622900d2152c
@@ -0,0 +1,1228 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#include <linux/clk.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/pm_runtime.h>
+#include "mtk-mdp3-comp.h"
+#include "mtk-mdp3-core.h"
+#include "mtk-mdp3-regs.h"
+
+#include "mdp_reg_rdma.h"
+#include "mdp_reg_ccorr.h"
+#include "mdp_reg_rsz.h"
+#include "mdp_reg_wrot.h"
+#include "mdp_reg_wdma.h"
+#include "mdp_reg_isp.h"
+
+static const struct mdp_platform_config *__get_plat_cfg(const struct mdp_comp_ctx *ctx)
+{
+	if (!ctx)
+		return NULL;
+
+	return ctx->comp->mdp_dev->mdp_data->mdp_cfg;
+}
+
+static s64 get_comp_flag(const struct mdp_comp_ctx *ctx)
+{
+	const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
+
+	if (mdp_cfg && mdp_cfg->rdma_rsz1_sram_sharing)
+		if (ctx->comp->id == MDP_COMP_RDMA0)
+			return BIT(MDP_COMP_RDMA0) | BIT(MDP_COMP_RSZ1);
+
+	return BIT(ctx->comp->id);
+}
+
+static int init_rdma(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	if (mdp_cfg && mdp_cfg->rdma_support_10bit) {
+		struct mdp_comp *prz1 = ctx->comp->mdp_dev->comp[MDP_COMP_RSZ1];
+
+		/* Disable RSZ1 */
+		if (ctx->comp->id == MDP_COMP_RDMA0 && prz1)
+			MM_REG_WRITE(cmd, subsys_id, prz1->reg_base, PRZ_ENABLE,
+				     0x0, BIT(0));
+	}
+
+	/* Reset RDMA */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_RESET, BIT(0), BIT(0));
+	MM_REG_POLL(cmd, subsys_id, base, MDP_RDMA_MON_STA_1, BIT(8), BIT(8));
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_RESET, 0x0, BIT(0));
+	return 0;
+}
+
+static int config_rdma_frame(struct mdp_comp_ctx *ctx,
+			     struct mmsys_cmdq_cmd *cmd,
+			     const struct v4l2_rect *compose)
+{
+	const struct mdp_rdma_data *rdma = &ctx->param->rdma;
+	const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
+	u32 colorformat = ctx->input->buffer.format.colorformat;
+	bool block10bit = MDP_COLOR_IS_10BIT_PACKED(colorformat);
+	bool en_ufo = MDP_COLOR_IS_UFP(colorformat);
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	if (mdp_cfg && mdp_cfg->rdma_support_10bit) {
+		if (block10bit)
+			MM_REG_WRITE(cmd, subsys_id, base,
+				     MDP_RDMA_RESV_DUMMY_0, 0x7, 0x7);
+		else
+			MM_REG_WRITE(cmd, subsys_id, base,
+				     MDP_RDMA_RESV_DUMMY_0, 0x0, 0x7);
+	}
+
+	/* Setup smi control */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_GMCIF_CON,
+		     (7 <<  4) + //burst type to 8
+		     (1 << 16),  //enable pre-ultra
+		     0x00030071);
+
+	/* Setup source frame info */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_CON, rdma->src_ctrl,
+		     0x03C8FE0F);
+
+	if (mdp_cfg)
+		if (mdp_cfg->rdma_support_10bit && en_ufo) {
+			/* Setup source buffer base */
+			MM_REG_WRITE(cmd, subsys_id,
+				     base, MDP_RDMA_UFO_DEC_LENGTH_BASE_Y,
+				     rdma->ufo_dec_y, 0xFFFFFFFF);
+			MM_REG_WRITE(cmd, subsys_id,
+				     base, MDP_RDMA_UFO_DEC_LENGTH_BASE_C,
+				     rdma->ufo_dec_c, 0xFFFFFFFF);
+			/* Set 10bit source frame pitch */
+			if (block10bit)
+				MM_REG_WRITE(cmd, subsys_id,
+					     base, MDP_RDMA_MF_BKGD_SIZE_IN_PXL,
+					     rdma->mf_bkgd_in_pxl, 0x001FFFFF);
+		}
+
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_CON, rdma->control,
+		     0x1110);
+	/* Setup source buffer base */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_BASE_0, rdma->iova[0],
+		     0xFFFFFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_BASE_1, rdma->iova[1],
+		     0xFFFFFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_BASE_2, rdma->iova[2],
+		     0xFFFFFFFF);
+	/* Setup source buffer end */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_END_0,
+		     rdma->iova_end[0], 0xFFFFFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_END_1,
+		     rdma->iova_end[1], 0xFFFFFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_END_2,
+		     rdma->iova_end[2], 0xFFFFFFFF);
+	/* Setup source frame pitch */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_MF_BKGD_SIZE_IN_BYTE,
+		     rdma->mf_bkgd, 0x001FFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SF_BKGD_SIZE_IN_BYTE,
+		     rdma->sf_bkgd, 0x001FFFFF);
+	/* Setup color transform */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_TRANSFORM_0,
+		     rdma->transform, 0x0F110000);
+
+	return 0;
+}
+
+static int config_rdma_subfrm(struct mdp_comp_ctx *ctx,
+			      struct mmsys_cmdq_cmd *cmd, u32 index)
+{
+	const struct mdp_rdma_subfrm *subfrm = &ctx->param->rdma.subfrms[index];
+	const struct img_comp_subfrm *csf = &ctx->param->subfrms[index];
+	const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
+	u32 colorformat = ctx->input->buffer.format.colorformat;
+	bool block10bit = MDP_COLOR_IS_10BIT_PACKED(colorformat);
+	bool en_ufo = MDP_COLOR_IS_UFP(colorformat);
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* Enable RDMA */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_EN, BIT(0), BIT(0));
+
+	/* Set Y pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_OFFSET_0,
+		     subfrm->offset[0], 0xFFFFFFFF);
+
+	/* Set 10bit UFO mode */
+	if (mdp_cfg)
+		if (mdp_cfg->rdma_support_10bit && block10bit && en_ufo)
+			MM_REG_WRITE(cmd, subsys_id, base,
+				     MDP_RDMA_SRC_OFFSET_0_P,
+				     subfrm->offset_0_p, 0xFFFFFFFF);
+
+	/* Set U pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_OFFSET_1,
+		     subfrm->offset[1], 0xFFFFFFFF);
+	/* Set V pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_SRC_OFFSET_2,
+		     subfrm->offset[2], 0xFFFFFFFF);
+	/* Set source size */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_MF_SRC_SIZE, subfrm->src,
+		     0x1FFF1FFF);
+	/* Set target size */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_MF_CLIP_SIZE,
+		     subfrm->clip, 0x1FFF1FFF);
+	/* Set crop offset */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_MF_OFFSET_1,
+		     subfrm->clip_ofst, 0x003F001F);
+
+	if (mdp_cfg && mdp_cfg->rdma_upsample_repeat_only)
+		if ((csf->in.right - csf->in.left + 1) > 320)
+			MM_REG_WRITE(cmd, subsys_id, base,
+				     MDP_RDMA_RESV_DUMMY_0, BIT(2), BIT(2));
+
+	return 0;
+}
+
+static int wait_rdma_event(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	struct device *dev = &ctx->comp->mdp_dev->pdev->dev;
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	if (ctx->comp->alias_id == 0)
+		MM_REG_WAIT(cmd, RDMA0_DONE);
+	else
+		dev_err(dev, "Do not support RDMA1_DONE event\n");
+
+	/* Disable RDMA */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_RDMA_EN, 0x0, BIT(0));
+	return 0;
+}
+
+static const struct mdp_comp_ops rdma_ops = {
+	.get_comp_flag = get_comp_flag,
+	.init_comp = init_rdma,
+	.config_frame = config_rdma_frame,
+	.config_subfrm = config_rdma_subfrm,
+	.wait_comp_event = wait_rdma_event,
+	.advance_subfrm = NULL,
+	.post_process = NULL,
+};
+
+static int init_rsz(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* Reset RSZ */
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_ENABLE, 0x10000, BIT(16));
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_ENABLE, 0x0, BIT(16));
+	/* Enable RSZ */
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_ENABLE, BIT(0), BIT(0));
+	return 0;
+}
+
+static int config_rsz_frame(struct mdp_comp_ctx *ctx,
+			    struct mmsys_cmdq_cmd *cmd,
+			    const struct v4l2_rect *compose)
+{
+	const struct mdp_rsz_data *rsz = &ctx->param->rsz;
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	if (ctx->param->frame.bypass) {
+		/* Disable RSZ */
+		MM_REG_WRITE(cmd, subsys_id, base, PRZ_ENABLE, 0x0, BIT(0));
+		return 0;
+	}
+
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_CONTROL_1, rsz->control1,
+		     0x03FFFDF3);
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_CONTROL_2, rsz->control2,
+		     0x0FFFC290);
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_HORIZONTAL_COEFF_STEP,
+		     rsz->coeff_step_x, 0x007FFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_VERTICAL_COEFF_STEP,
+		     rsz->coeff_step_y, 0x007FFFFF);
+	return 0;
+}
+
+static int config_rsz_subfrm(struct mdp_comp_ctx *ctx,
+			     struct mmsys_cmdq_cmd *cmd, u32 index)
+{
+	const struct mdp_rsz_subfrm *subfrm = &ctx->param->rsz.subfrms[index];
+	const struct img_comp_subfrm *csf = &ctx->param->subfrms[index];
+	const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_CONTROL_2, subfrm->control2,
+		     0x00003800);
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_INPUT_IMAGE, subfrm->src,
+		     0xFFFFFFFF);
+
+	if (mdp_cfg && mdp_cfg->rsz_disable_dcm_small_sample)
+		if ((csf->in.right - csf->in.left + 1) <= 16)
+			MM_REG_WRITE(cmd, subsys_id, base, PRZ_CONTROL_1,
+				     BIT(27), BIT(27));
+
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_LUMA_HORIZONTAL_INTEGER_OFFSET,
+		     csf->luma.left, 0xFFFF);
+	MM_REG_WRITE(cmd, subsys_id,
+		     base, PRZ_LUMA_HORIZONTAL_SUBPIXEL_OFFSET,
+		     csf->luma.left_subpix, 0x1FFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_LUMA_VERTICAL_INTEGER_OFFSET,
+		     csf->luma.top, 0xFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_LUMA_VERTICAL_SUBPIXEL_OFFSET,
+		     csf->luma.top_subpix, 0x1FFFFF);
+	MM_REG_WRITE(cmd, subsys_id,
+		     base, PRZ_CHROMA_HORIZONTAL_INTEGER_OFFSET,
+		     csf->chroma.left, 0xFFFF);
+	MM_REG_WRITE(cmd, subsys_id,
+		     base, PRZ_CHROMA_HORIZONTAL_SUBPIXEL_OFFSET,
+		     csf->chroma.left_subpix, 0x1FFFFF);
+
+	MM_REG_WRITE(cmd, subsys_id, base, PRZ_OUTPUT_IMAGE, subfrm->clip,
+		     0xFFFFFFFF);
+
+	return 0;
+}
+
+static int advance_rsz_subfrm(struct mdp_comp_ctx *ctx,
+			      struct mmsys_cmdq_cmd *cmd, u32 index)
+{
+	const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
+
+	if (mdp_cfg && mdp_cfg->rsz_disable_dcm_small_sample) {
+		const struct img_comp_subfrm *csf = &ctx->param->subfrms[index];
+		phys_addr_t base = ctx->comp->reg_base;
+		u8 subsys_id = ctx->comp->subsys_id;
+
+		if ((csf->in.right - csf->in.left + 1) <= 16)
+			MM_REG_WRITE(cmd, subsys_id, base, PRZ_CONTROL_1, 0x0,
+				     BIT(27));
+	}
+
+	return 0;
+}
+
+static const struct mdp_comp_ops rsz_ops = {
+	.get_comp_flag = get_comp_flag,
+	.init_comp = init_rsz,
+	.config_frame = config_rsz_frame,
+	.config_subfrm = config_rsz_subfrm,
+	.wait_comp_event = NULL,
+	.advance_subfrm = advance_rsz_subfrm,
+	.post_process = NULL,
+};
+
+static int init_wrot(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* Reset WROT */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_SOFT_RST, BIT(0), BIT(0));
+	MM_REG_POLL(cmd, subsys_id, base, VIDO_SOFT_RST_STAT, BIT(0), BIT(0));
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_SOFT_RST, 0x0, BIT(0));
+	MM_REG_POLL(cmd, subsys_id, base, VIDO_SOFT_RST_STAT, 0x0, BIT(0));
+	return 0;
+}
+
+static int config_wrot_frame(struct mdp_comp_ctx *ctx,
+			     struct mmsys_cmdq_cmd *cmd,
+			     const struct v4l2_rect *compose)
+{
+	const struct mdp_wrot_data *wrot = &ctx->param->wrot;
+	const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* Write frame base address */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_BASE_ADDR, wrot->iova[0],
+		     0xFFFFFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_BASE_ADDR_C, wrot->iova[1],
+		     0xFFFFFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_BASE_ADDR_V, wrot->iova[2],
+		     0xFFFFFFFF);
+	/* Write frame related registers */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_CTRL, wrot->control,
+		     0xF131510F);
+	/* Write frame Y pitch */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_STRIDE, wrot->stride[0],
+		     0x0000FFFF);
+	/* Write frame UV pitch */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_STRIDE_C, wrot->stride[1],
+		     0xFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_STRIDE_V, wrot->stride[2],
+		     0xFFFF);
+	/* Write matrix control */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_MAT_CTRL, wrot->mat_ctrl, 0xF3);
+
+	/* Set the fixed ALPHA as 0xFF */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_DITHER, 0xFF000000,
+		     0xFF000000);
+	/* Set VIDO_EOL_SEL */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_RSV_1, BIT(31), BIT(31));
+	/* Set VIDO_FIFO_TEST */
+	if (wrot->fifo_test != 0)
+		MM_REG_WRITE(cmd, subsys_id, base, VIDO_FIFO_TEST,
+			     wrot->fifo_test, 0xFFF);
+	/* Filter enable */
+	if (mdp_cfg && mdp_cfg->wrot_filter_constraint)
+		MM_REG_WRITE(cmd, subsys_id, base, VIDO_MAIN_BUF_SIZE,
+			     wrot->filter, 0x77);
+
+	return 0;
+}
+
+static int config_wrot_subfrm(struct mdp_comp_ctx *ctx,
+			      struct mmsys_cmdq_cmd *cmd, u32 index)
+{
+	const struct mdp_wrot_subfrm *subfrm = &ctx->param->wrot.subfrms[index];
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* Write Y pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_OFST_ADDR,
+		     subfrm->offset[0], 0x0FFFFFFF);
+	/* Write U pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_OFST_ADDR_C,
+		     subfrm->offset[1], 0x0FFFFFFF);
+	/* Write V pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_OFST_ADDR_V,
+		     subfrm->offset[2], 0x0FFFFFFF);
+	/* Write source size */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_IN_SIZE, subfrm->src,
+		     0x1FFF1FFF);
+	/* Write target size */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_TAR_SIZE, subfrm->clip,
+		     0x1FFF1FFF);
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_CROP_OFST, subfrm->clip_ofst,
+		     0x1FFF1FFF);
+
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_MAIN_BUF_SIZE,
+		     subfrm->main_buf, 0x1FFF7F00);
+
+	/* Enable WROT */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_ROT_EN, BIT(0), BIT(0));
+
+	return 0;
+}
+
+static int wait_wrot_event(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	const struct mdp_platform_config *mdp_cfg = __get_plat_cfg(ctx);
+	struct device *dev = &ctx->comp->mdp_dev->pdev->dev;
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	if (ctx->comp->alias_id == 0)
+		MM_REG_WAIT(cmd, WROT0_DONE);
+	else
+		dev_err(dev, "Do not support WROT1_DONE event\n");
+
+	if (mdp_cfg && mdp_cfg->wrot_filter_constraint)
+		MM_REG_WRITE(cmd, subsys_id, base, VIDO_MAIN_BUF_SIZE, 0x0,
+			     0x77);
+
+	/* Disable WROT */
+	MM_REG_WRITE(cmd, subsys_id, base, VIDO_ROT_EN, 0x0, BIT(0));
+
+	return 0;
+}
+
+static const struct mdp_comp_ops wrot_ops = {
+	.get_comp_flag = get_comp_flag,
+	.init_comp = init_wrot,
+	.config_frame = config_wrot_frame,
+	.config_subfrm = config_wrot_subfrm,
+	.wait_comp_event = wait_wrot_event,
+	.advance_subfrm = NULL,
+	.post_process = NULL,
+};
+
+static int init_wdma(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* Reset WDMA */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_RST, BIT(0), BIT(0));
+	MM_REG_POLL(cmd, subsys_id, base, WDMA_FLOW_CTRL_DBG, BIT(0), BIT(0));
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_RST, 0x0, BIT(0));
+	return 0;
+}
+
+static int config_wdma_frame(struct mdp_comp_ctx *ctx,
+			     struct mmsys_cmdq_cmd *cmd,
+			     const struct v4l2_rect *compose)
+{
+	const struct mdp_wdma_data *wdma = &ctx->param->wdma;
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_BUF_CON2, 0x10101050,
+		     0xFFFFFFFF);
+
+	/* Setup frame information */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_CFG, wdma->wdma_cfg,
+		     0x0F01B8F0);
+	/* Setup frame base address */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_DST_ADDR,   wdma->iova[0],
+		     0xFFFFFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_DST_U_ADDR, wdma->iova[1],
+		     0xFFFFFFFF);
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_DST_V_ADDR, wdma->iova[2],
+		     0xFFFFFFFF);
+	/* Setup Y pitch */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_DST_W_IN_BYTE,
+		     wdma->w_in_byte, 0x0000FFFF);
+	/* Setup UV pitch */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_DST_UV_PITCH,
+		     wdma->uv_stride, 0x0000FFFF);
+	/* Set the fixed ALPHA as 0xFF */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_ALPHA, 0x800000FF,
+		     0x800000FF);
+
+	return 0;
+}
+
+static int config_wdma_subfrm(struct mdp_comp_ctx *ctx,
+			      struct mmsys_cmdq_cmd *cmd, u32 index)
+{
+	const struct mdp_wdma_subfrm *subfrm = &ctx->param->wdma.subfrms[index];
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* Write Y pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_DST_ADDR_OFFSET,
+		     subfrm->offset[0], 0x0FFFFFFF);
+	/* Write U pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_DST_U_ADDR_OFFSET,
+		     subfrm->offset[1], 0x0FFFFFFF);
+	/* Write V pixel offset */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_DST_V_ADDR_OFFSET,
+		     subfrm->offset[2], 0x0FFFFFFF);
+	/* Write source size */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_SRC_SIZE, subfrm->src,
+		     0x3FFF3FFF);
+	/* Write target size */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_CLIP_SIZE, subfrm->clip,
+		     0x3FFF3FFF);
+	/* Write clip offset */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_CLIP_COORD, subfrm->clip_ofst,
+		     0x3FFF3FFF);
+
+	/* Enable WDMA */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_EN, BIT(0), BIT(0));
+
+	return 0;
+}
+
+static int wait_wdma_event(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	MM_REG_WAIT(cmd, WDMA0_DONE);
+	/* Disable WDMA */
+	MM_REG_WRITE(cmd, subsys_id, base, WDMA_EN, 0x0, BIT(0));
+	return 0;
+}
+
+static const struct mdp_comp_ops wdma_ops = {
+	.get_comp_flag = get_comp_flag,
+	.init_comp = init_wdma,
+	.config_frame = config_wdma_frame,
+	.config_subfrm = config_wdma_subfrm,
+	.wait_comp_event = wait_wdma_event,
+	.advance_subfrm = NULL,
+	.post_process = NULL,
+};
+
+static int init_ccorr(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* CCORR enable */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_CCORR_EN, BIT(0), BIT(0));
+	/* Relay mode */
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_CCORR_CFG, BIT(0), BIT(0));
+	return 0;
+}
+
+static int config_ccorr_frame(struct mdp_comp_ctx *ctx,
+			      struct mmsys_cmdq_cmd *cmd,
+			      const struct v4l2_rect *compose)
+{
+	/* Disabled function */
+	return 0;
+}
+
+static int config_ccorr_subfrm(struct mdp_comp_ctx *ctx,
+			       struct mmsys_cmdq_cmd *cmd, u32 index)
+{
+	const struct img_comp_subfrm *csf = &ctx->param->subfrms[index];
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+	u32 hsize, vsize;
+
+	hsize = csf->in.right - csf->in.left + 1;
+	vsize = csf->in.bottom - csf->in.top + 1;
+	MM_REG_WRITE(cmd, subsys_id, base, MDP_CCORR_SIZE,
+		     (hsize << 16) + (vsize <<  0), 0x1FFF1FFF);
+	return 0;
+}
+
+static const struct mdp_comp_ops ccorr_ops = {
+	.get_comp_flag = get_comp_flag,
+	.init_comp = init_ccorr,
+	.config_frame = config_ccorr_frame,
+	.config_subfrm = config_ccorr_subfrm,
+	.wait_comp_event = NULL,
+	.advance_subfrm = NULL,
+	.post_process = NULL,
+};
+
+static int init_isp(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	struct device *dev = ctx->comp->mdp_dev->mdp_mmsys;
+	const struct isp_data *isp = &ctx->param->isp;
+
+	/* Direct link */
+	if (isp->dl_flags & BIT(MDP_COMP_CAMIN)) {
+		dev_dbg(dev, "SW_RST ASYNC");
+		mtk_mmsys_mdp_isp_ctrl(dev, cmd, MDP_COMP_CAMIN);
+	}
+
+	if (isp->dl_flags & BIT(MDP_COMP_CAMIN2)) {
+		dev_dbg(dev, "SW_RST ASYNC2");
+		mtk_mmsys_mdp_isp_ctrl(dev, cmd, MDP_COMP_CAMIN2);
+	}
+
+	return 0;
+}
+
+static int config_isp_frame(struct mdp_comp_ctx *ctx,
+			    struct mmsys_cmdq_cmd *cmd,
+			    const struct v4l2_rect *compose)
+{
+	struct device *dev = &ctx->comp->mdp_dev->pdev->dev;
+	const struct isp_data *isp = &ctx->param->isp;
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* DIP_X_SMX1I_BASE_ADDR, DIP_X_SMX1O_BASE_ADDR */
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2890, isp->smxi_iova[0],
+			  0xFFFFFFFF);
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x27D0, isp->smxi_iova[0],
+			  0xFFFFFFFF);
+	/* DIP_X_SMX2I_BASE_ADDR, DIP_X_SMX2O_BASE_ADDR */
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x28C0, isp->smxi_iova[1],
+			  0xFFFFFFFF);
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2800, isp->smxi_iova[1],
+			  0xFFFFFFFF);
+	/* DIP_X_SMX3I_BASE_ADDR, DIP_X_SMX3O_BASE_ADDR */
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x28F0, isp->smxi_iova[2],
+			  0xFFFFFFFF);
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2830, isp->smxi_iova[2],
+			  0xFFFFFFFF);
+	/* DIP_X_SMX4I_BASE_ADDR, DIP_X_SMX4O_BASE_ADDR */
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2920, isp->smxi_iova[3],
+			  0xFFFFFFFF);
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2860, isp->smxi_iova[3],
+			  0xFFFFFFFF);
+
+	switch (isp->cq_idx) {
+	case ISP_DRV_DIP_CQ_THRE0:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2208,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE1:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2214,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE2:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2220,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE3:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x222C,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE4:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2238,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE5:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2244,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE6:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2250,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE7:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x225C,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE8:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2268,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE9:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2274,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE10:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2280,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	case ISP_DRV_DIP_CQ_THRE11:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x228C,
+				  isp->cq_iova, 0xFFFFFFFF);
+		break;
+	default:
+		dev_err(dev, "Do not support this cq (%d)", isp->cq_idx);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int config_isp_subfrm(struct mdp_comp_ctx *ctx,
+			     struct mmsys_cmdq_cmd *cmd, u32 index)
+{
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2304,
+			  ctx->param->isp.tpipe_iova[index], 0xFFFFFFFF);
+	return 0;
+}
+
+static int wait_isp_event(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd)
+{
+	const struct isp_data *isp = &ctx->param->isp;
+	struct device *dev = &ctx->comp->mdp_dev->pdev->dev;
+	phys_addr_t base = ctx->comp->reg_base;
+	u8 subsys_id = ctx->comp->subsys_id;
+
+	/* MDP_DL_SEL: select MDP_CROP */
+	if (isp->dl_flags & BIT(MDP_COMP_CAMIN))
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x30, 0x0, BIT(9));
+	/* MDP2_DL_SEL: select MDP_CROP2 */
+	if (isp->dl_flags & BIT(MDP_COMP_CAMIN2))
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x30, 0x0,
+				  BIT(10) | BIT(11));
+
+	switch (isp->cq_idx) {
+	case ISP_DRV_DIP_CQ_THRE0:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(0), BIT(0));
+		MM_REG_WAIT(cmd, ISP_P2_0_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE1:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(1), BIT(1));
+		MM_REG_WAIT(cmd, ISP_P2_1_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE2:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(2), BIT(2));
+		MM_REG_WAIT(cmd, ISP_P2_2_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE3:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(3), BIT(3));
+		MM_REG_WAIT(cmd, ISP_P2_3_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE4:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(4), BIT(4));
+		MM_REG_WAIT(cmd, ISP_P2_4_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE5:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(5), BIT(5));
+		MM_REG_WAIT(cmd, ISP_P2_5_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE6:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(6), BIT(6));
+		MM_REG_WAIT(cmd, ISP_P2_6_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE7:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(7), BIT(7));
+		MM_REG_WAIT(cmd, ISP_P2_7_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE8:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(8), BIT(8));
+		MM_REG_WAIT(cmd, ISP_P2_8_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE9:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(9), BIT(9));
+		MM_REG_WAIT(cmd, ISP_P2_9_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE10:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(10), BIT(10));
+		MM_REG_WAIT(cmd, ISP_P2_10_DONE);
+		break;
+	case ISP_DRV_DIP_CQ_THRE11:
+		MM_REG_WRITE_MASK(cmd, subsys_id, base, 0x2000, BIT(11), BIT(11));
+		MM_REG_WAIT(cmd, ISP_P2_11_DONE);
+		break;
+	default:
+		dev_err(dev, "Do not support this cq (%d)", isp->cq_idx);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static const struct mdp_comp_ops imgi_ops = {
+	.get_comp_flag = get_comp_flag,
+	.init_comp = init_isp,
+	.config_frame = config_isp_frame,
+	.config_subfrm = config_isp_subfrm,
+	.wait_comp_event = wait_isp_event,
+	.advance_subfrm = NULL,
+	.post_process = NULL,
+};
+
+static int config_camin_subfrm(struct mdp_comp_ctx *ctx,
+			       struct mmsys_cmdq_cmd *cmd, u32 index)
+{
+	const struct img_comp_subfrm *csf = &ctx->param->subfrms[index];
+	struct device *dev = ctx->comp->mdp_dev->mdp_mmsys;
+	u32 camin_w, camin_h;
+
+	camin_w = csf->in.right - csf->in.left + 1;
+	camin_h = csf->in.bottom - csf->in.top + 1;
+
+	/* Config for direct link */
+	if (ctx->comp->alias_id == 0)
+		mtk_mmsys_mdp_camin_ctrl(dev, cmd, MDP_COMP_CAMIN,
+					 camin_w, camin_h);
+	if (ctx->comp->alias_id == 1)
+		mtk_mmsys_mdp_camin_ctrl(dev, cmd, MDP_COMP_CAMIN2,
+					 camin_w, camin_h);
+
+	return 0;
+}
+
+static const struct mdp_comp_ops camin_ops = {
+	.get_comp_flag = get_comp_flag,
+	.init_comp = NULL,
+	.config_frame = NULL,
+	.config_subfrm = config_camin_subfrm,
+	.wait_comp_event = NULL,
+	.advance_subfrm = NULL,
+	.post_process = NULL,
+};
+
+static const struct mdp_comp_ops *mdp_comp_ops[MDP_COMP_TYPE_COUNT] = {
+	[MDP_COMP_TYPE_RDMA] =		&rdma_ops,
+	[MDP_COMP_TYPE_RSZ] =		&rsz_ops,
+	[MDP_COMP_TYPE_WROT] =		&wrot_ops,
+	[MDP_COMP_TYPE_WDMA] =		&wdma_ops,
+	[MDP_COMP_TYPE_PATH1] =		NULL,
+	[MDP_COMP_TYPE_PATH2] =		NULL,
+	[MDP_COMP_TYPE_CCORR] =		&ccorr_ops,
+	[MDP_COMP_TYPE_IMGI] =		&imgi_ops,
+	[MDP_COMP_TYPE_EXTO] =		NULL,
+	[MDP_COMP_TYPE_DL_PATH1] =	&camin_ops,
+	[MDP_COMP_TYPE_DL_PATH2] =	&camin_ops,
+};
+
+struct mdp_comp_match {
+	enum mtk_mdp_comp_id id;
+	enum mdp_comp_type	type;
+	u32			alias_id;
+};
+
+static const struct mdp_comp_match mdp_comp_matches[MDP_MAX_COMP_COUNT] = {
+	[MDP_COMP_WPEI] =	{ MDP_COMP_WPEI, MDP_COMP_TYPE_WPEI, 0 },
+	[MDP_COMP_WPEO] =	{ MDP_COMP_WPEO, MDP_COMP_TYPE_EXTO, 2 },
+	[MDP_COMP_WPEI2] =	{ MDP_COMP_WPEI2, MDP_COMP_TYPE_WPEI, 1 },
+	[MDP_COMP_WPEO2] =	{ MDP_COMP_WPEO2, MDP_COMP_TYPE_EXTO, 3 },
+	[MDP_COMP_ISP_IMGI] =	{ MDP_COMP_ISP_IMGI, MDP_COMP_TYPE_IMGI, 0 },
+	[MDP_COMP_ISP_IMGO] =	{ MDP_COMP_ISP_IMGO, MDP_COMP_TYPE_EXTO, 0 },
+	[MDP_COMP_ISP_IMG2O] =	{ MDP_COMP_ISP_IMG2O, MDP_COMP_TYPE_EXTO, 1 },
+
+	[MDP_COMP_CAMIN] =	{ MDP_COMP_CAMIN, MDP_COMP_TYPE_DL_PATH1, 0 },
+	[MDP_COMP_CAMIN2] =	{ MDP_COMP_CAMIN2, MDP_COMP_TYPE_DL_PATH2, 1 },
+	[MDP_COMP_RDMA0] =	{ MDP_COMP_RDMA0, MDP_COMP_TYPE_RDMA, 0 },
+	[MDP_COMP_CCORR0] =	{ MDP_COMP_CCORR0, MDP_COMP_TYPE_CCORR, 0 },
+	[MDP_COMP_RSZ0] =	{ MDP_COMP_RSZ0, MDP_COMP_TYPE_RSZ, 0 },
+	[MDP_COMP_RSZ1] =	{ MDP_COMP_RSZ1, MDP_COMP_TYPE_RSZ, 1 },
+	[MDP_COMP_PATH0_SOUT] =	{ MDP_COMP_PATH0_SOUT, MDP_COMP_TYPE_PATH1, 0 },
+	[MDP_COMP_PATH1_SOUT] =	{ MDP_COMP_PATH1_SOUT, MDP_COMP_TYPE_PATH2, 1 },
+	[MDP_COMP_WROT0] =	{ MDP_COMP_WROT0, MDP_COMP_TYPE_WROT, 0 },
+	[MDP_COMP_WDMA] =	{ MDP_COMP_WDMA, MDP_COMP_TYPE_WDMA, 0 },
+};
+
+static const struct of_device_id mdp_comp_dt_ids[] = {
+	{
+		.compatible = "mediatek,mt8183-mdp3-rdma0",
+		.data = &mdp_comp_matches[MDP_COMP_RDMA0],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-ccorr",
+		.data = &mdp_comp_matches[MDP_COMP_CCORR0],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-rsz0",
+		.data = &mdp_comp_matches[MDP_COMP_RSZ0],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-rsz1",
+		.data = &mdp_comp_matches[MDP_COMP_RSZ1],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-wrot0",
+		.data = &mdp_comp_matches[MDP_COMP_WROT0],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-wdma",
+		.data = &mdp_comp_matches[MDP_COMP_WDMA],
+	},
+	{}
+};
+
+static const struct of_device_id mdp_sub_comp_dt_ids[] = {
+	{
+		.compatible = "mediatek,mt8183-mdp3-path1",
+		.data = &mdp_comp_matches[MDP_COMP_PATH0_SOUT],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-path2",
+		.data = &mdp_comp_matches[MDP_COMP_PATH1_SOUT],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-imgi",
+		.data = &mdp_comp_matches[MDP_COMP_ISP_IMGI],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-exto",
+		.data = &mdp_comp_matches[MDP_COMP_ISP_IMGO],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-dl1",
+		.data = &mdp_comp_matches[MDP_COMP_CAMIN],
+	}, {
+		.compatible = "mediatek,mt8183-mdp3-dl2",
+		.data = &mdp_comp_matches[MDP_COMP_CAMIN2],
+	},
+	{}
+};
+
+/* Used to describe the item order in MDP property */
+struct mdp_comp_info {
+	u32	clk_num;
+	u32	clk_ofst;
+	u32	dts_reg_ofst;
+};
+
+static const struct mdp_comp_info mdp_comp_dt_info[MDP_COMP_TYPE_COUNT] = {
+	[MDP_COMP_TYPE_RDMA]		= {2, 0, 0},
+	[MDP_COMP_TYPE_RSZ]		= {1, 0, 0},
+	[MDP_COMP_TYPE_WROT]		= {1, 0, 0},
+	[MDP_COMP_TYPE_WDMA]		= {1, 0, 0},
+	[MDP_COMP_TYPE_PATH1]		= {0, 0, 2},
+	[MDP_COMP_TYPE_PATH2]		= {0, 0, 3},
+	[MDP_COMP_TYPE_CCORR]		= {1, 0, 0},
+	[MDP_COMP_TYPE_IMGI]		= {0, 0, 4},
+	[MDP_COMP_TYPE_EXTO]		= {0, 0, 4},
+	[MDP_COMP_TYPE_DL_PATH1]	= {2, 2, 1},
+	[MDP_COMP_TYPE_DL_PATH2]	= {2, 4, 1},
+};
+
+void mdp_comp_clock_on(struct device *dev, struct mdp_comp *comp)
+{
+	int i, err;
+
+	if (comp->comp_dev) {
+		err = pm_runtime_get_sync(comp->comp_dev);
+		if (err < 0)
+			dev_err(dev,
+				"Failed to get power, err %d. type:%d id:%d\n",
+				err, comp->type, comp->id);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(comp->clks); i++) {
+		if (IS_ERR(comp->clks[i]))
+			break;
+		err = clk_prepare_enable(comp->clks[i]);
+		if (err)
+			dev_err(dev,
+				"Failed to enable clk %d. type:%d id:%d\n",
+				i, comp->type, comp->id);
+	}
+}
+
+void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(comp->clks); i++) {
+		if (IS_ERR(comp->clks[i]))
+			break;
+		clk_disable_unprepare(comp->clks[i]);
+	}
+
+	if (comp->comp_dev)
+		pm_runtime_put(comp->comp_dev);
+}
+
+void mdp_comp_clocks_on(struct device *dev, struct mdp_comp *comps, int num)
+{
+	int i;
+
+	for (i = 0; i < num; i++)
+		mdp_comp_clock_on(dev, &comps[i]);
+}
+
+void mdp_comp_clocks_off(struct device *dev, struct mdp_comp *comps, int num)
+{
+	int i;
+
+	for (i = 0; i < num; i++)
+		mdp_comp_clock_off(dev, &comps[i]);
+}
+
+static int mdp_get_subsys_id(struct device *dev, struct device_node *node,
+			     struct mdp_comp *comp)
+{
+	struct platform_device *comp_pdev;
+	struct cmdq_client_reg  cmdq_reg;
+	int ret = 0;
+	int index = 0;
+
+	if (!dev || !node || !comp)
+		return -EINVAL;
+
+	comp_pdev = of_find_device_by_node(node);
+
+	if (!comp_pdev) {
+		dev_err(dev, "get comp_pdev fail! comp id=%d type=%d\n",
+			comp->id, comp->type);
+		return -ENODEV;
+	}
+
+	index = mdp_comp_dt_info[comp->type].dts_reg_ofst;
+	ret = cmdq_dev_get_client_reg(&comp_pdev->dev, &cmdq_reg, index);
+	if (ret != 0) {
+		dev_err(&comp_pdev->dev, "cmdq_dev_get_subsys fail!\n");
+		return -EINVAL;
+	}
+
+	comp->subsys_id = cmdq_reg.subsys;
+	dev_dbg(&comp_pdev->dev, "subsys id=%d\n", cmdq_reg.subsys);
+
+	return 0;
+}
+
+static void __mdp_comp_init(struct mdp_dev *mdp, struct device_node *node,
+			    struct mdp_comp *comp)
+{
+	struct resource res;
+	phys_addr_t base;
+	int index = mdp_comp_dt_info[comp->type].dts_reg_ofst;
+
+	if (of_address_to_resource(node, index, &res) < 0)
+		base = 0L;
+	else
+		base = res.start;
+
+	comp->mdp_dev = mdp;
+	comp->regs = of_iomap(node, 0);
+	comp->reg_base = base;
+}
+
+static int mdp_comp_init(struct mdp_dev *mdp, struct device_node *node,
+			 struct mdp_comp *comp, enum mtk_mdp_comp_id id)
+{
+	struct device *dev = &mdp->pdev->dev;
+	int clk_num;
+	int clk_ofst;
+	int i;
+
+	if (id < 0 || id >= MDP_MAX_COMP_COUNT) {
+		dev_err(dev, "Invalid component id %d\n", id);
+		return -EINVAL;
+	}
+
+	comp->type = mdp_comp_matches[id].type;
+	comp->id = mdp_comp_matches[id].id;
+	comp->alias_id = mdp_comp_matches[id].alias_id;
+	comp->ops = mdp_comp_ops[comp->type];
+	__mdp_comp_init(mdp, node, comp);
+
+	clk_num = mdp_comp_dt_info[comp->type].clk_num;
+	clk_ofst = mdp_comp_dt_info[comp->type].clk_ofst;
+
+	for (i = 0; i < clk_num; i++) {
+		comp->clks[i] = of_clk_get(node, i + clk_ofst);
+		if (IS_ERR(comp->clks[i]))
+			break;
+	}
+
+	mdp_get_subsys_id(dev, node, comp);
+
+	return 0;
+}
+
+static struct mdp_comp *mdp_comp_create(struct mdp_dev *mdp,
+					struct device_node *node,
+					enum mtk_mdp_comp_id id)
+{
+	struct device *dev = &mdp->pdev->dev;
+	struct mdp_comp *comp;
+	int ret;
+
+	if (mdp->comp[id])
+		return ERR_PTR(-EEXIST);
+
+	comp = devm_kzalloc(dev, sizeof(*comp), GFP_KERNEL);
+	if (!comp)
+		return ERR_PTR(-ENOMEM);
+
+	ret = mdp_comp_init(mdp, node, comp, id);
+	if (ret) {
+		kfree(comp);
+		return ERR_PTR(ret);
+	}
+	mdp->comp[id] = comp;
+	mdp->comp[id]->mdp_dev = mdp;
+
+	dev_info(dev, "%s type:%d alias:%d id:%d base:%#x regs:%p\n",
+		 dev->of_node->name, comp->type, comp->alias_id, id,
+		 (u32)comp->reg_base, comp->regs);
+	return comp;
+}
+
+static int mdp_sub_comps_create(struct mdp_dev *mdp, struct device_node *node)
+{
+	struct property *prop;
+	const char *name;
+	int index = 0;
+
+	of_property_for_each_string(node, "mediatek,mdp3-comps", prop, name) {
+		const struct of_device_id *list = mdp_sub_comp_dt_ids;
+		struct mdp_comp_match *match = NULL;
+		struct mdp_comp *comp;
+
+		for (; list->compatible[0]; list++) {
+			if (of_compat_cmp(name, list->compatible,
+					  strlen(list->compatible)) == 0) {
+				match = (struct mdp_comp_match *)list->data;
+				break;
+			}
+		}
+
+		if (match)
+			comp = mdp_comp_create(mdp, node, match->id);
+
+		if (IS_ERR(comp))
+			return PTR_ERR(comp);
+
+		index++;
+	}
+	return 0;
+}
+
+static void mdp_comp_deinit(struct mdp_comp *comp)
+{
+	if (!comp)
+		return;
+
+	if (comp->regs)
+		iounmap(comp->regs);
+}
+
+void mdp_component_deinit(struct mdp_dev *mdp)
+{
+	int i;
+
+	for (i = 0; i < MDP_PIPE_MAX; i++)
+		mtk_mutex_put(mdp->mdp_mutex[i]);
+
+	for (i = 0; i < ARRAY_SIZE(mdp->comp); i++) {
+		if (mdp->comp[i]) {
+			pm_runtime_disable(mdp->comp[i]->comp_dev);
+			mdp_comp_deinit(mdp->comp[i]);
+			kfree(mdp->comp[i]);
+		}
+	}
+}
+
+int mdp_component_init(struct mdp_dev *mdp)
+{
+	struct device *dev = &mdp->pdev->dev;
+	struct device_node *node, *parent;
+	struct platform_device *pdev;
+	int ret;
+
+	parent = dev->of_node->parent;
+	/* Iterate over sibling MDP function blocks */
+	for_each_child_of_node(parent, node) {
+		const struct of_device_id *of_id;
+		struct mdp_comp_match *match;
+		struct mdp_comp *comp;
+
+		of_id = of_match_node(mdp_comp_dt_ids, node);
+		if (!of_id)
+			continue;
+
+		if (!of_device_is_available(node)) {
+			dev_info(dev, "Skipping disabled component %pOF\n", node);
+			continue;
+		}
+
+		match = (struct mdp_comp_match *)of_id->data;
+
+		comp = mdp_comp_create(mdp, node, match->id);
+		if (IS_ERR(comp))
+			goto err_init_comps;
+
+		ret = mdp_sub_comps_create(mdp, node);
+		if (ret)
+			goto err_init_comps;
+
+		/* Only DMA capable components need the pm control */
+		comp->comp_dev = NULL;
+		if (comp->type != MDP_COMP_TYPE_RDMA &&
+		    comp->type != MDP_COMP_TYPE_WROT &&
+		    comp->type != MDP_COMP_TYPE_WDMA)
+			continue;
+
+		pdev = of_find_device_by_node(node);
+		if (!pdev) {
+			dev_warn(dev, "can't find platform device of node:%s\n",
+				 node->name);
+			return -ENODEV;
+		}
+
+		comp->comp_dev = &pdev->dev;
+		pm_runtime_enable(comp->comp_dev);
+	}
+	return 0;
+
+err_init_comps:
+	mdp_component_deinit(mdp);
+	return ret;
+}
+
+int mdp_comp_ctx_init(struct mdp_dev *mdp, struct mdp_comp_ctx *ctx,
+		      const struct img_compparam *param,
+	const struct img_ipi_frameparam *frame)
+{
+	struct device *dev = &mdp->pdev->dev;
+	int i;
+
+	if (param->type < 0 || param->type >= MDP_MAX_COMP_COUNT) {
+		dev_err(dev, "Invalid component id %d", param->type);
+		return -EINVAL;
+	}
+
+	ctx->comp = mdp->comp[param->type];
+	if (!ctx->comp) {
+		dev_err(dev, "Uninit component id %d", param->type);
+		return -EINVAL;
+	}
+
+	ctx->param = param;
+	ctx->input = &frame->inputs[param->input];
+	for (i = 0; i < param->num_outputs; i++)
+		ctx->outputs[i] = &frame->outputs[param->outputs[i]];
+	return 0;
+}
drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h new file +147 -0
new file mode 100644
index 000000000000..7b34f9c42410
@@ -0,0 +1,147 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MTK_MDP3_COMP_H__
+#define __MTK_MDP3_COMP_H__
+
+#include <linux/soc/mediatek/mtk-mmsys.h>
+#include "mtk-mdp3-cmdq.h"
+
+#define MM_REG_WRITE_MASK(cmd, id, base, ofst, val, mask, ...) \
+	cmdq_pkt_write_mask((cmd)->pkt, id, \
+		(base) + (ofst), (val), (mask), ##__VA_ARGS__)
+#define MM_REG_WRITE(cmd, id, base, ofst, val, mask, ...) \
+	MM_REG_WRITE_MASK(cmd, id, base, ofst, val, \
+		(((mask) & (ofst##_MASK)) == (ofst##_MASK)) ? \
+			(0xffffffff) : (mask), ##__VA_ARGS__)
+
+#define MM_REG_WAIT(cmd, evt) \
+	cmdq_pkt_wfe((cmd)->pkt, (cmd)->event[(evt)], true)
+
+#define MM_REG_WAIT_NO_CLEAR(cmd, evt) \
+	cmdq_pkt_wfe((cmd)->pkt, (cmd)->event[(evt)], false)
+
+#define MM_REG_CLEAR(cmd, evt) \
+	cmdq_pkt_clear_event((cmd)->pkt, (cmd)->event[(evt)])
+
+#define MM_REG_SET_EVENT(cmd, evt) \
+	cmdq_pkt_set_event((cmd)->pkt, (cmd)->event[(evt)])
+
+#define MM_REG_POLL_MASK(cmd, id, base, ofst, val, mask, ...) \
+	cmdq_pkt_poll_mask((cmd)->pkt, id, \
+		(base) + (ofst), (val), (mask), ##__VA_ARGS__)
+#define MM_REG_POLL(cmd, id, base, ofst, val, mask, ...) \
+	MM_REG_POLL_MASK((cmd), id, base, ofst, val, \
+		(((mask) & (ofst##_MASK)) == (ofst##_MASK)) ? \
+			(0xffffffff) : (mask), ##__VA_ARGS__)
+
+enum mdp_comp_type {
+	MDP_COMP_TYPE_INVALID = 0,
+
+	MDP_COMP_TYPE_RDMA,
+	MDP_COMP_TYPE_RSZ,
+	MDP_COMP_TYPE_WROT,
+	MDP_COMP_TYPE_WDMA,
+	MDP_COMP_TYPE_PATH1,
+	MDP_COMP_TYPE_PATH2,
+
+	MDP_COMP_TYPE_TDSHP,
+	MDP_COMP_TYPE_COLOR,
+	MDP_COMP_TYPE_DRE,
+	MDP_COMP_TYPE_CCORR,
+	MDP_COMP_TYPE_HDR,
+
+	MDP_COMP_TYPE_IMGI,
+	MDP_COMP_TYPE_WPEI,
+	MDP_COMP_TYPE_EXTO,	/* External path */
+	MDP_COMP_TYPE_DL_PATH1, /* Direct-link path1 */
+	MDP_COMP_TYPE_DL_PATH2, /* Direct-link path2 */
+
+	MDP_COMP_TYPE_COUNT	/* ALWAYS keep at the end */
+};
+
+enum mdp_comp_event {
+	RDMA0_SOF,
+	RDMA0_DONE,
+	RSZ0_SOF,
+	RSZ1_SOF,
+	TDSHP0_SOF,
+	WROT0_SOF,
+	WROT0_DONE,
+	WDMA0_SOF,
+	WDMA0_DONE,
+
+	ISP_P2_0_DONE,
+	ISP_P2_1_DONE,
+	ISP_P2_2_DONE,
+	ISP_P2_3_DONE,
+	ISP_P2_4_DONE,
+	ISP_P2_5_DONE,
+	ISP_P2_6_DONE,
+	ISP_P2_7_DONE,
+	ISP_P2_8_DONE,
+	ISP_P2_9_DONE,
+	ISP_P2_10_DONE,
+	ISP_P2_11_DONE,
+	ISP_P2_12_DONE,
+	ISP_P2_13_DONE,
+	ISP_P2_14_DONE,
+
+	WPE_DONE,
+	WPE_B_DONE,
+
+	MDP_MAX_EVENT_COUNT	/* ALWAYS keep at the end */
+};
+
+struct mdp_comp_ops;
+
+struct mdp_comp {
+	struct mdp_dev			*mdp_dev;
+	void __iomem			*regs;
+	phys_addr_t			reg_base;
+	u8				subsys_id;
+	struct clk			*clks[6];
+	struct device			*comp_dev;
+	enum mdp_comp_type		type;
+	enum mtk_mdp_comp_id		id;
+	u32				alias_id;
+	const struct mdp_comp_ops	*ops;
+};
+
+struct mdp_comp_ctx {
+	struct mdp_comp			*comp;
+	const struct img_compparam	*param;
+	const struct img_input		*input;
+	const struct img_output		*outputs[IMG_MAX_HW_OUTPUTS];
+};
+
+struct mdp_comp_ops {
+	s64 (*get_comp_flag)(const struct mdp_comp_ctx *ctx);
+	int (*init_comp)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
+	int (*config_frame)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd,
+			    const struct v4l2_rect *compose);
+	int (*config_subfrm)(struct mdp_comp_ctx *ctx,
+			     struct mmsys_cmdq_cmd *cmd, u32 index);
+	int (*wait_comp_event)(struct mdp_comp_ctx *ctx,
+			       struct mmsys_cmdq_cmd *cmd);
+	int (*advance_subfrm)(struct mdp_comp_ctx *ctx,
+			      struct mmsys_cmdq_cmd *cmd, u32 index);
+	int (*post_process)(struct mdp_comp_ctx *ctx, struct mmsys_cmdq_cmd *cmd);
+};
+
+struct mdp_dev;
+
+int mdp_component_init(struct mdp_dev *mdp);
+void mdp_component_deinit(struct mdp_dev *mdp);
+void mdp_comp_clock_on(struct device *dev, struct mdp_comp *comp);
+void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp);
+void mdp_comp_clocks_on(struct device *dev, struct mdp_comp *comps, int num);
+void mdp_comp_clocks_off(struct device *dev, struct mdp_comp *comps, int num);
+int mdp_comp_ctx_init(struct mdp_dev *mdp, struct mdp_comp_ctx *ctx,
+		      const struct img_compparam *param,
+	const struct img_ipi_frameparam *frame);
+
+#endif  /* __MTK_MDP3_COMP_H__ */
drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c new file +338 -0
new file mode 100644
index 000000000000..535a9b51ee88
@@ -0,0 +1,338 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#include <linux/clk.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/remoteproc.h>
+#include <linux/remoteproc/mtk_scp.h>
+#include <media/videobuf2-dma-contig.h>
+#include "mtk-mdp3-core.h"
+#include "mtk-mdp3-m2m.h"
+
+static const struct mdp_platform_config mt8183_plat_cfg = {
+	.rdma_support_10bit		= true,
+	.rdma_rsz1_sram_sharing		= true,
+	.rdma_upsample_repeat_only	= true,
+	.rsz_disable_dcm_small_sample	= false,
+	.wrot_filter_constraint		= false,
+	.gce_event_offset		= 2,
+};
+
+static const struct mtk_mdp_driver_data mt8183_mdp_driver_data = {
+	.mdp_cfg = &mt8183_plat_cfg,
+};
+
+static const struct of_device_id mdp_of_ids[] = {
+	{ .compatible = "mediatek,mt8183-mdp3",
+	  .data = &mt8183_mdp_driver_data,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, mdp_of_ids);
+
+static struct platform_device *__get_pdev_by_name(struct platform_device *pdev,
+						  char *ref_name)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *mdp_node;
+	struct platform_device *mdp_pdev;
+
+	mdp_node = of_parse_phandle(dev->of_node, ref_name, 0);
+	if (!mdp_node) {
+		dev_err(dev, "can't get node %s\n", ref_name);
+		return NULL;
+	}
+
+	mdp_pdev = of_find_device_by_node(mdp_node);
+	of_node_put(mdp_node);
+	if (WARN_ON(!mdp_pdev)) {
+		dev_err(dev, "find %s pdev failed\n", ref_name);
+		return NULL;
+	}
+
+	return mdp_pdev;
+}
+
+struct platform_device *mdp_get_plat_device(struct platform_device *pdev)
+{
+	if (!pdev)
+		return NULL;
+
+	return __get_pdev_by_name(pdev, "mediatek,mdp3");
+}
+EXPORT_SYMBOL_GPL(mdp_get_plat_device);
+
+int mdp_vpu_get_locked(struct mdp_dev *mdp)
+{
+	int ret = 0;
+
+	if (mdp->vpu_count++ == 0) {
+		ret = rproc_boot(mdp->rproc_handle);
+		if (ret) {
+			dev_err(&mdp->pdev->dev,
+				"vpu_load_firmware failed %d\n", ret);
+			goto err_load_vpu;
+		}
+		ret = mdp_vpu_register(mdp);
+		if (ret) {
+			dev_err(&mdp->pdev->dev,
+				"mdp_vpu register failed %d\n", ret);
+			goto err_reg_vpu;
+		}
+		ret = mdp_vpu_dev_init(&mdp->vpu, mdp->scp, &mdp->vpu_lock);
+		if (ret) {
+			dev_err(&mdp->pdev->dev,
+				"mdp_vpu device init failed %d\n", ret);
+			goto err_init_vpu;
+		}
+	}
+	return 0;
+
+err_init_vpu:
+	mdp_vpu_unregister(mdp);
+err_reg_vpu:
+err_load_vpu:
+	mdp->vpu_count--;
+	return ret;
+}
+
+void mdp_vpu_put_locked(struct mdp_dev *mdp)
+{
+	if (--mdp->vpu_count == 0) {
+		mdp_vpu_dev_deinit(&mdp->vpu);
+		mdp_vpu_unregister(mdp);
+	}
+}
+
+void mdp_video_device_release(struct video_device *vdev)
+{
+	struct mdp_dev *mdp = (struct mdp_dev *)video_get_drvdata(vdev);
+
+	scp_put(mdp->scp);
+
+	destroy_workqueue(mdp->job_wq);
+	destroy_workqueue(mdp->clock_wq);
+
+	pm_runtime_disable(&mdp->pdev->dev);
+
+	vb2_dma_contig_clear_max_seg_size(&mdp->pdev->dev);
+	mdp_component_deinit(mdp);
+
+#ifdef MDP_DEBUG
+	mdp_debug_deinit();
+#endif
+
+	mdp_vpu_shared_mem_free(&mdp->vpu);
+	v4l2_m2m_release(mdp->m2m_dev);
+	kfree(mdp);
+}
+
+static int mdp_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct mdp_dev *mdp;
+	struct device_node *mdp_node;
+	struct platform_device *mm_pdev;
+	u32 event_ofst;
+	int ret, i;
+
+	mdp = kzalloc(sizeof(*mdp), GFP_KERNEL);
+	if (!mdp) {
+		ret = -ENOMEM;
+		goto err_return;
+	}
+
+	mdp->pdev = pdev;
+	mdp->mdp_data = of_device_get_match_data(&pdev->dev);
+	mm_pdev = __get_pdev_by_name(pdev, "mediatek,mmsys");
+	if (!mm_pdev) {
+		ret = -ENODEV;
+		goto err_return;
+	}
+	mdp->mdp_mmsys = &mm_pdev->dev;
+
+	mdp_node = of_parse_phandle(pdev->dev.of_node, "mediatek,mm-mutex", 0);
+	if (!mdp_node) {
+		ret = -ENODEV;
+		goto err_return;
+	}
+
+	event_ofst = mdp->mdp_data->mdp_cfg->gce_event_offset;
+	for (i = RDMA0_SOF; i < MDP_MAX_EVENT_COUNT; i++) {
+		s32 event_id;
+
+		if (!dev)
+			return -EINVAL;
+
+		if (of_property_read_u32_index(mdp_node,
+					       "mediatek,gce-events",
+					       i + event_ofst, &event_id)) {
+			dev_err(dev, "can't parse gce-events property");
+
+			return -ENODEV;
+		}
+		mdp->event[i] = (event_id < 0) ? -i : event_id;
+		dev_dbg(dev, "Get event id:%d\n", mdp->event[i]);
+	}
+
+	mm_pdev = of_find_device_by_node(mdp_node);
+	of_node_put(mdp_node);
+	if (WARN_ON(!mm_pdev)) {
+		ret = -ENODEV;
+		goto err_return;
+	}
+
+	for (i = 0; i < MDP_PIPE_MAX; i++) {
+		mdp->mdp_mutex[i] = mtk_mutex_mdp_get(&mm_pdev->dev, i);
+		if (!mdp->mdp_mutex[i]) {
+			ret = -ENODEV;
+			goto err_return;
+		}
+	}
+
+	ret = mdp_component_init(mdp);
+	if (ret) {
+		dev_err(dev, "Failed to initialize mdp components\n");
+		goto err_return;
+	}
+
+	mdp->job_wq = alloc_workqueue(MDP_MODULE_NAME, WQ_FREEZABLE, 0);
+	if (!mdp->job_wq) {
+		dev_err(dev, "Unable to create job workqueue\n");
+		ret = -ENOMEM;
+		goto err_deinit_comp;
+	}
+
+	mdp->clock_wq = alloc_workqueue(MDP_MODULE_NAME "-clock", WQ_FREEZABLE,
+					0);
+	if (!mdp->clock_wq) {
+		dev_err(dev, "Unable to create clock workqueue\n");
+		ret = -ENOMEM;
+		goto err_destroy_job_wq;
+	}
+
+	mdp->scp = scp_get(pdev);
+	if (!mdp->scp) {
+		dev_err(&pdev->dev, "Could not get scp device\n");
+		ret = -ENODEV;
+		goto err_destroy_clock_wq;
+	}
+
+	mdp->rproc_handle = scp_get_rproc(mdp->scp);
+	dev_dbg(&pdev->dev, "MDP rproc_handle: %pK", mdp->rproc_handle);
+
+	mutex_init(&mdp->vpu_lock);
+	mutex_init(&mdp->m2m_lock);
+
+	mdp->cmdq_clt = cmdq_mbox_create(dev, 0);
+	if (IS_ERR(mdp->cmdq_clt)) {
+		ret = PTR_ERR(mdp->cmdq_clt);
+		goto err_put_scp;
+	}
+
+	init_waitqueue_head(&mdp->callback_wq);
+	ida_init(&mdp->mdp_ida);
+	platform_set_drvdata(pdev, mdp);
+
+	vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
+
+	ret = v4l2_device_register(dev, &mdp->v4l2_dev);
+	if (ret) {
+		dev_err(dev, "Failed to register v4l2 device\n");
+		ret = -EINVAL;
+		goto err_mbox_destroy;
+	}
+
+	ret = mdp_m2m_device_register(mdp);
+	if (ret) {
+		v4l2_err(&mdp->v4l2_dev, "Failed to register m2m device\n");
+		goto err_unregister_device;
+	}
+
+	dev_dbg(dev, "mdp-%d registered successfully\n", pdev->id);
+	return 0;
+
+err_unregister_device:
+	v4l2_device_unregister(&mdp->v4l2_dev);
+err_mbox_destroy:
+	cmdq_mbox_destroy(mdp->cmdq_clt);
+err_put_scp:
+	scp_put(mdp->scp);
+err_destroy_clock_wq:
+	destroy_workqueue(mdp->clock_wq);
+err_destroy_job_wq:
+	destroy_workqueue(mdp->job_wq);
+err_deinit_comp:
+	mdp_component_deinit(mdp);
+err_return:
+	kfree(mdp);
+	dev_dbg(dev, "Errno %d\n", ret);
+	return ret;
+}
+
+static int mdp_remove(struct platform_device *pdev)
+{
+	struct mdp_dev *mdp = platform_get_drvdata(pdev);
+
+	v4l2_device_unregister(&mdp->v4l2_dev);
+
+	dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name);
+	return 0;
+}
+
+static int __maybe_unused mdp_suspend(struct device *dev)
+{
+	struct mdp_dev *mdp = dev_get_drvdata(dev);
+	int ret;
+
+	atomic_set(&mdp->suspended, 1);
+
+	if (atomic_read(&mdp->job_count)) {
+		ret = wait_event_timeout(mdp->callback_wq,
+					 !atomic_read(&mdp->job_count),
+					 2 * HZ);
+		if (ret == 0) {
+			dev_err(dev,
+				"%s:flushed cmdq task incomplete, count=%d\n",
+				__func__, atomic_read(&mdp->job_count));
+			return -EBUSY;
+		}
+	}
+
+	return 0;
+}
+
+static int __maybe_unused mdp_resume(struct device *dev)
+{
+	struct mdp_dev *mdp = dev_get_drvdata(dev);
+
+	atomic_set(&mdp->suspended, 0);
+
+	return 0;
+}
+
+static const struct dev_pm_ops mdp_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(mdp_suspend, mdp_resume)
+};
+
+static struct platform_driver mdp_driver = {
+	.probe		= mdp_probe,
+	.remove		= mdp_remove,
+	.driver = {
+		.name	= MDP_MODULE_NAME,
+		.pm	= &mdp_pm_ops,
+		.of_match_table = of_match_ptr(mdp_of_ids),
+	},
+};
+
+module_platform_driver(mdp_driver);
+
+MODULE_AUTHOR("Ping-Hsun Wu <[email protected]>");
+MODULE_DESCRIPTION("Mediatek image processor 3 driver");
+MODULE_LICENSE("GPL v2");
drivers/media/platform/mtk-mdp3/mtk-mdp3-core.h new file +76 -0
new file mode 100644
index 000000000000..d688071b0bf1
@@ -0,0 +1,76 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#ifndef __MTK_MDP3_CORE_H__
+#define __MTK_MDP3_CORE_H__
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-mem2mem.h>
+#include <linux/soc/mediatek/mtk-mmsys.h>
+#include <linux/soc/mediatek/mtk-mutex.h>
+#include "mtk-mdp3-comp.h"
+#include "mtk-mdp3-vpu.h"
+
+#define MDP_MODULE_NAME	"mtk-mdp3"
+
+enum mdp_buffer_usage {
+	MDP_BUFFER_USAGE_HW_READ,
+	MDP_BUFFER_USAGE_MDP,
+	MDP_BUFFER_USAGE_MDP2,
+	MDP_BUFFER_USAGE_ISP,
+	MDP_BUFFER_USAGE_WPE,
+};
+
+struct mdp_platform_config {
+	bool	rdma_support_10bit;
+	bool	rdma_rsz1_sram_sharing;
+	bool	rdma_upsample_repeat_only;
+	bool	rsz_disable_dcm_small_sample;
+	bool	wrot_filter_constraint;
+	u32	gce_event_offset;
+};
+
+struct mtk_mdp_driver_data {
+	const struct mdp_platform_config *mdp_cfg;
+};
+
+struct mdp_dev {
+	struct platform_device			*pdev;
+	struct device				*mdp_mmsys;
+	struct mtk_mutex			*mdp_mutex[MDP_PIPE_MAX];
+	struct mdp_comp				*comp[MDP_MAX_COMP_COUNT];
+	const struct mtk_mdp_driver_data	*mdp_data;
+	s32					event[MDP_MAX_EVENT_COUNT];
+
+	struct workqueue_struct			*job_wq;
+	struct workqueue_struct			*clock_wq;
+	struct mdp_vpu_dev			vpu;
+	struct mtk_scp				*scp;
+	struct rproc				*rproc_handle;
+	/* synchronization protect for accessing vpu working buffer info */
+	struct mutex				vpu_lock;
+	s32					vpu_count;
+	u32					id_count;
+	struct ida				mdp_ida;
+	struct cmdq_client			*cmdq_clt;
+	wait_queue_head_t			callback_wq;
+
+	struct v4l2_device			v4l2_dev;
+	struct video_device			*m2m_vdev;
+	struct v4l2_m2m_dev			*m2m_dev;
+	/* synchronization protect for m2m device operation */
+	struct mutex				m2m_lock;
+	atomic_t				suspended;
+	atomic_t				job_count;
+};
+
+int mdp_vpu_get_locked(struct mdp_dev *mdp);
+void mdp_vpu_put_locked(struct mdp_dev *mdp);
+int mdp_vpu_register(struct mdp_dev *mdp);
+void mdp_vpu_unregister(struct mdp_dev *mdp);
+void mdp_video_device_release(struct video_device *vdev);
+
+#endif  /* __MTK_MDP3_CORE_H__ */
drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.c new file +789 -0
new file mode 100644
index 000000000000..9b3d9a59ae48
@@ -0,0 +1,789 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Ping-Hsun Wu <[email protected]>
+ */
+
+#include <linux/platform_device.h>
+#include <media/v4l2-ioctl.h>
+#include <media/v4l2-event.h>
+#include <media/videobuf2-dma-contig.h>
+#include "mtk-mdp3-m2m.h"
+
+static inline struct mdp_m2m_ctx *fh_to_ctx(struct v4l2_fh *fh)
+{
+	return container_of(fh, struct mdp_m2m_ctx, fh);
+}
+
+static inline struct mdp_m2m_ctx *ctrl_to_ctx(struct v4l2_ctrl *ctrl)
+{
+	return container_of(ctrl->handler, struct mdp_m2m_ctx, ctrl_handler);
+}
+
+static inline struct mdp_frame *ctx_get_frame(struct mdp_m2m_ctx *ctx,
+					      enum v4l2_buf_type type)
+{
+	if (V4L2_TYPE_IS_OUTPUT(type))
+		return &ctx->curr_param.output;
+	else
+		return &ctx->curr_param.captures[0];
+}
+
+static void mdp_m2m_ctx_set_state(struct mdp_m2m_ctx *ctx, u32 state)
+{
+	mutex_lock(&ctx->curr_param.state_lock);
+	ctx->curr_param.state |= state;
+	mutex_unlock(&ctx->curr_param.state_lock);
+}
+
+static bool mdp_m2m_ctx_is_state_set(struct mdp_m2m_ctx *ctx, u32 mask)
+{
+	bool ret;
+
+	mutex_lock(&ctx->curr_param.state_lock);
+	ret = (ctx->curr_param.state & mask) == mask;
+	mutex_unlock(&ctx->curr_param.state_lock);
+	return ret;
+}
+
+static void mdp_m2m_job_abort(void *priv)
+{
+}
+
+static void mdp_m2m_process_done(void *priv, int vb_state)
+{
+	struct mdp_m2m_ctx *ctx = priv;
+	struct vb2_v4l2_buffer *src_vbuf, *dst_vbuf;
+
+	src_vbuf = (struct vb2_v4l2_buffer *)
+			v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
+	dst_vbuf = (struct vb2_v4l2_buffer *)
+			v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
+	src_vbuf->sequence = ctx->frame_count[MDP_M2M_SRC]++;
+	dst_vbuf->sequence = ctx->frame_count[MDP_M2M_DST]++;
+	v4l2_m2m_buf_copy_metadata(src_vbuf, dst_vbuf, true);
+
+	v4l2_m2m_buf_done(src_vbuf, vb_state);
+	v4l2_m2m_buf_done(dst_vbuf, vb_state);
+	v4l2_m2m_job_finish(ctx->mdp_dev->m2m_dev, ctx->m2m_ctx);
+
+	ctx->curr_param.frame_no = ctx->frame_count[MDP_M2M_SRC];
+}
+
+static void mdp_m2m_worker(struct work_struct *work)
+{
+	struct mdp_m2m_ctx *ctx = container_of(work, struct mdp_m2m_ctx, work);
+	struct mdp_frame *frame;
+	struct vb2_v4l2_buffer *src_vb, *dst_vb;
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/media/platform/mtk-mdp3/mtk-mdp3-m2m.h new file +49 -0
new file mode 100644
index 000000000000..ffab59ac9dc7

Lines of this file are not shown. View the raw message.

drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c new file +31 -0
new file mode 100644
index 000000000000..439711298867

Lines of this file are not shown. View the raw message.

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

Hello Moudy,

When testing MDP3 with GStreamer pipeline I notice R and B component swap when using RGB16 pixel format.
V4L2_PIX_FMT_RGB565 should be mapped on MDP_COLOR_RGB565 to avoid this problem.

Regards,
Benjamin

Quoted 1,486 lines
drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.c new file +706 -0

Lines of this file are not shown. View the raw message.

drivers/media/platform/mtk-mdp3/mtk-mdp3-regs.h new file +372 -0
new file mode 100644
index 000000000000..3ff784aa372b

Lines of this file are not shown. View the raw message.

drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.c new file +312 -0
new file mode 100644
index 000000000000..fc008d96c7c0

Lines of this file are not shown. View the raw message.

drivers/media/platform/mtk-mdp3/mtk-mdp3-vpu.h new file +78 -0
new file mode 100644
index 000000000000..e831070b44d0

Lines of this file are not shown. View the raw message.

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

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

author
#5 lore raw

Re: [PATCH v11 1/3] dt-binding: mt8183: add Mediatek MDP3 dt-bindings

In reply to moudy.ho
Quoted 50 lines · moudy.ho
Quoted 49 lines · AngeloGioacchino Del Regno

Il 21/01/22 22:16, Rob Herring ha scritto:

Quoted 1 line · Moudy Ho

Hello Rob,

since I'm not the best at reviewing dt-bindings, I always try to leave that to

other reviewers; in which case, thank you for your awesome review activity on

all of these (and helping me a lot on some of my attempts to write yaml..!!)

In this case, though, since I do have knowledge about the platform, it's probably
worth for me to try to address some of your questions, on at least this one.

Quoted 28 lines
Quoted 28 lines

This patch adds DT binding document for Media Data Path 3 (MDP3)
a unit in multimedia system used for scaling and color format convert.

---
  .../bindings/media/mediatek,mdp3-rdma.yaml    | 193
++++++++++++++++++
  .../bindings/media/mediatek,mdp3-rsz.yaml     |  55 +++++
  .../bindings/media/mediatek,mdp3-wrot.yaml    |  57 ++++++
  .../bindings/soc/mediatek/mediatek,ccorr.yaml |  47 +++++
  .../bindings/soc/mediatek/mediatek,wdma.yaml  |  58 ++++++
  5 files changed, 410 insertions(+)

create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml
create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml
create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3-wrot.yaml
create mode 100644
Documentation/devicetree/bindings/soc/mediatek/mediatek,ccorr.y am
l
create mode 100644
Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma.ya ml

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

diff --git a/Documentation/devicetree/bindings/media/mediatek,mdp3- rdma.yaml b/Documentation/devicetree/bindings/media/mediatek,mdp3- rdma.yaml
new file mode 100644
index 000000000000..002503383934
--- /dev/null

Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 4

Quoted 8 lines

+++ b/Documentation/devicetree/bindings/media/mediatek,mdp3- rdma.yaml

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +4 -0
@@ -0,0 +1,193 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/media/mediatek,mdp3-rdma.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtt5fpkQb$

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review line 5

Quoted 3 lines
(quoted diff) +1 -0
+$schema: 

https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtk8-fzFI$

Quoted 59 lines
Quoted 42 lines
Quoted 23 lines
Quoted 23 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +8 -0
+
+title: Mediatek Read Direct Memory Access
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  Mediatek Read Direct Memory Access(RDMA) component used to

do
read DMA.
+ It contains one line buffer to store the sufficient pixel data, and

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +3 -0
+  must be siblings to the central MMSYS_CONFIG node.
+  For a description of the MMSYS_CONFIG binding, see
+  Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsy

s.
yaml

(quoted diff) +2 -0
+  for details.
+  The 1st RDMA is also used to be a controller node in Media

Data Path 3(MDP3)

(quoted diff) +2 -0
+  that containing MMSYS, MUTEX, GCE and SCP settings.
+
Quoted 10 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 27

Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+properties:
+  compatible:
+    oneOf:
+      - items:
+          # MDP3 controller node
+          - const: mediatek,mt8183-mdp3

How is this more specific than this:

Quoted 1 line

+ - const: mediatek,mt8183-mdp3-rdma0

Probably, oneOf is not the right choice here... "mediatek,mt8183- mdp3" is needed
to probe the "main" mdp3 core pdev, while RDMA0 is a necessary component (as in
this driver uses the component framework, and rdma0 is required for functionality,
as far as I understand).

Quoted 7 lines

This shouldn't be a choice, meaning that defining mdp3-rdma0 without
mdp3 is
completely useless, as there wouldn't be anything else initializing that component,
nor sub-components of that.

Hi Rob and Angelo,
Sorry for the incomplete description here, I originally planned to add
a compatible name here in the future when the chip has multiple RDMAs.
Since 8183 currently has only one RDMA, the above design expression is
incorrect and should be rewritten as follows:

Quoted 7 lines

[8183]
properties:
compatible:
items:
# MDP3 controller node
- const: mediatek,mt8183-mdp3
- const: mediatek,mt8195-mdp3-rdma0

fix typo
- const: mediatek,mt8183-mdp3-rdma0

Quoted 350 lines

[8195]
properties:
compatible:
oneOf:
- items:
# MDP3 controller node
- const: mediatek,mt8183-mdp3
- const: mediatek,mt8195-mdp3-rdma0
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma1
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma2
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma3

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+      - items:
+          # normal RDMA conponent
+          - const: mediatek,mt8183-mdp3-rdma0
+
+  mediatek,scp:
+    description: The node of system control processor (SCP),

using
+ the remoteproc & rpmsg framework.

Quoted 8 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 40

Quoted 5 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +5 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mdp3-comps:
+    description: MTK sub-system of direct-link or DIP

This needs a better description. What is DIP? What is direct- link?

Quoted 2 lines

I agree, this needs a better description.

I tried to modify the description as follows, could you help to see if
there is anything confusing:

mediatek,mdp3-comps:
description:
MDP subsystem which has direct-link from Image Signal
Processor(ISP).
When using the camera, the DMA of ISP PASS (DIP) module will
directly trigger MDP3 without other control (such as V4L2 M2M) to create corresponding HW path.
The MDP3 controller must set up a series of registers at the
beginning of path creation which covering MMSYS, IMGSYS, and MDP3's components, so that data flow can pass through MDP3.

      The entire path is briefly described as follows:
      DIP   : ISP ->
      MDP3  :       IMGI -> DL -> CCORR(optional) -> RSZ -> PATH_OUT

->
WDMA/WROT

Quoted 45 lines
Quoted 26 lines
Quoted 23 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +5 -0
+    $ref: /schemas/types.yaml#/definitions/string-array
+    items:
+      - enum:
+          # MDP direct-link input path selection, create a
+          # component for path connectedness of HW pipe

control

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+          - mediatek,mt8183-mdp3-dl1
+      - enum:
+          - mediatek,mt8183-mdp3-dl2
+      - enum:
+          # MDP direct-link output path selection, create a
+          # component for path connectedness of HW pipe

control

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +5 -0
+          - mediatek,mt8183-mdp3-path1
+      - enum:
+          - mediatek,mt8183-mdp3-path2
+      - enum:
+          # Input DMA of ISP PASS2 (DIP) module for raw image

input

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +3 -0
+          - mediatek,mt8183-mdp3-imgi
+      - enum:
+          # Output DMA of ISP PASS2 (DIP) module for YUV image
Quoted 2 lines

output
+ - mediatek,mt8183-mdp3-exto

Quoted 5 lines

There's only 1 possible value for mediatek,mdp3-comps, so why does
it
need to be in DT?

The wanted logic here (I believe) is that, depending on firmware capabilities
and/or platform/board capabilities, you may miss some subcomponents like IMGI
and/or EXTO.
As for DL1/2 and PATH1/2... DL1+PATH1 is surely critically necessary
for the
functionality of the MDP3 RDMA... I don't know whether it's possible
that we
get any fw/platform/device that's not using DL2/PATH2 at all.

Quoted 2 lines

Moudy, can you please explain?

Hi Angelo,
Thanks for your help and your assumptions are correct. In further chips(such as 8195), IMGI will be replaced by WPE, and
PATH_OUT will be removed, and DL will be expanded to 6 (implicit number
of direct-link from ISP paths).
For this variable hardware design, not sure how to flexibly
describe
in dt-bindings to meet futher requirements.
It should be that I got wrong with the definition of "enum", should
it be rewritten as follows in 8183?
items:
- enum:
# MDP direct-link input path selection, create a # component for path connectedness of HW pipe control
- mediatek,mt8183-mdp3-dl1
- mediatek,mt8183-mdp3-dl2
# MDP direct-link output path selection, create a # component for path connectedness of HW pipe control
- mediatek,mt8183-mdp3-path1
- mediatek,mt8183-mdp3-path2
# Input DMA of ISP PASS2 (DIP) module for raw image input
- mediatek,mt8183-mdp3-imgi
# Output DMA of ISP PASS2 (DIP) module for YUV image output
- mediatek,mt8183-mdp3-exto
items: (8195)
snip....
items: (8192)
snip...

Quoted 89 lines
Quoted 47 lines
Quoted 47 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +11 -0
+
+  reg:
+    items:
+      - description: basic RDMA HW address
+      - description: MDP direct-link 1st and 2nd input
+      - description: MDP direct-link 1st output
+      - description: MDP direct-link 2nd output
+      - description: ISP input and output
+
+  mediatek,gce-client-reg:
+    description: The register of client driver can be

configured
by gce with
+ 4 arguments defined in this property, such as phandle of
gce, subsys id,
+ register offset and size. Each GCE subsys id is mapping
to
a client
+ defined in the header include/dt-bindings/gce/<chip>-
gce.h.

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +4 -0
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - description: GCE client for RDMA
+      - description: GCR client for MDP direct-link 1st and

2nd
input

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +21 -0
+      - description: GCR client for MDP direct-link 1st output
+      - description: GCR client for MDP direct-link 2nd output
+      - description: GCR client for ISP input and output
+
+  power-domains:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: RDMA clock
+      - description: RSZ clock
+      - description: direck-link TX clock in MDP side
+      - description: direck-link RX clock in MDP side
+      - description: direck-link TX clock in ISP side
+      - description: direck-link RX clock in ISP side
+
+  iommus:
+    maxItems: 1
+
+  mediatek,mmsys:
+    description: The node of mux(multiplexer) controller for
Quoted 9 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 102

Quoted 5 lines

HW
connections.

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +3 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mediatek,mm-mutex:

Is this some sort of h/w lock? We have a standard binding for that.

There's a story behind that one: this was part of mtk (display) DRM drivers, then
it was moved to soc/mediatek/mtk-mutex.c as it started being shared.

I wonder if the mm-mutex can be rewritten and moved to hwspinlock...
this driver
is growing and now, with the introduction of MDP3, we're seeing some
more.

Though, it's definitely worth mentioning that the usage of MediaTek's
mm-mutex is
varying a bit between the drm case and the mdp3 case as, here, we have a "command
queue" mechanism that is used for commands ordering in HW. This is a very complex architecture that has very specific requirements.
For how I see it, migrating that to hwspinlock would require an almost complete
reimplementation of soc/mediatek/*, which would take a considerable amount of
time and efforts.
I'm mostly sure that I can help with that, but for how things are looking right

now, between refactoring, getting code solid, going through sane reviews and a
final merge, I'd say that this will take 8-12 months from now.

Quoted 9 lines

For this reason, I would propose to perform a slow and steady migration of the
MediaTek mmsys, scpsys, mutex over time, but only after getting in the support
for the new SoCs and functionality for the older ones, provided in this series
and some others that were already sent by MTK, half (or more) of which have
already been merged.

Sorry for the misunderstanding caused by the name, the original
mtk-
mutex design did have the ability to lock registers, but that has since
been removed but the name continues.
It's not one of those h/w locks like spinlock, semaphore, or mutex
but is just designed to send signals to trigger h/w components to get or send data.

Quoted 107 lines
Quoted 107 lines
Quoted 107 lines

+ description: The node of sof(start of frame) signal
controller.

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +5 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mailbox-gce:
+    description: The node of global command engine (GCE), used

to read/write

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +12 -0
+      registers with critical time limitation.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mboxes:
+    items:
+      - description: used for 1st data pipe from RDMA
+      - description: used for 2nd data pipe from RDMA
+      - description: used for 3rd data pipe from Direct-Link
+      - description: used for 4th data pipe from Direct-Link
+
+  gce-subsys:
+    description: sub-system id corresponding to the global

command engine (GCE)

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +49 -0
+      register address.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+if:
+  properties:
+    compatible:
+      contains:
+        const: mediatek,mt8183-mdp3
+
+then:
+  required:
+    - mediatek,scp
+    - mediatek,mmsys
+    - mediatek,mm-mutex
+    - mediatek,mailbox-gce
+    - mboxes
+    - gce-subsys
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - mediatek,gce-client-reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8183-clk.h>
+    #include <dt-bindings/gce/mt8183-gce.h>
+    #include <dt-bindings/power/mt8183-power.h>
+    #include <dt-bindings/memory/mt8183-larb-port.h>
+
+    mdp3_rdma0: mdp3_rdma0@14001000 {
+      compatible = "mediatek,mt8183-mdp3",
+                   "mediatek,mt8183-mdp3-rdma0";
+      mediatek,scp = <&scp>;
+      mediatek,mdp3-comps = "mediatek,mt8183-mdp3-dl1",
+                            "mediatek,mt8183-mdp3-dl2",
+                            "mediatek,mt8183-mdp3-path1",
+                            "mediatek,mt8183-mdp3-path2",
+                            "mediatek,mt8183-mdp3-imgi",
+                            "mediatek,mt8183-mdp3-exto";
+      reg = <0x14001000 0x1000>,
+            <0x14000000 0x1000>,
+            <0x14005000 0x1000>,
+            <0x14006000 0x1000>,
+            <0x15020000 0x1000>;
+      mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x1000

0x1000>,
+ <&gce SUBSYS_1400XXXX 0
0x1000>,
+ <&gce SUBSYS_1400XXXX 0x5000
0x1000>,
+ <&gce SUBSYS_1400XXXX 0x6000
0x1000>,
+ <&gce SUBSYS_1502XXXX 0
0x1000>;

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +20 -0
+      power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+      clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+               <&mmsys CLK_MM_MDP_RSZ1>,
+               <&mmsys CLK_MM_MDP_DL_TXCK>,
+               <&mmsys CLK_MM_MDP_DL_RX>,
+               <&mmsys CLK_MM_IPU_DL_TXCK>,
+               <&mmsys CLK_MM_IPU_DL_RX>;
+      iommus = <&iommu>;
+      mediatek,mmsys = <&mmsys>;
+      mediatek,mm-mutex = <&mutex>;
+      mediatek,mailbox-gce = <&gce>;
+      mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 23 CMDQ_THR_PRIO_LOWEST>;
+      gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+                   <&gce 0x14010000 SUBSYS_1401XXXX>,
+                   <&gce 0x14020000 SUBSYS_1402XXXX>,
+                   <&gce 0x15020000 SUBSYS_1502XXXX>;
+    };

diff --git a/Documentation/devicetree/bindings/media/mediatek,mdp3- rsz.yaml b/Documentation/devicetree/bindings/media/mediatek,mdp3- rsz.yaml
new file mode 100644
index 000000000000..cd4cf1531535
--- /dev/null

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 4

Quoted 8 lines

+++ b/Documentation/devicetree/bindings/media/mediatek,mdp3- rsz.yaml

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +4 -0
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/media/mediatek,mdp3-rsz.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtoNRPuZQ$

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review line 5

Quoted 3 lines
(quoted diff) +1 -0
+$schema: 

https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtk8-fzFI$

Quoted 79 lines
Quoted 47 lines
Quoted 20 lines
Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +8 -0
+
+title: Mediatek Resizer
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  One of Media Data Path 3 (MDP3) components used to do frame

resizing.

Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml line 20

Quoted 7 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +7 -0
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - mediatek,mt8183-mdp3-rsz0
+          - mediatek,mt8183-mdp3-rsz1

Again, what's the difference between 0 and 1?

Quoted 4 lines

I've probably asked that before, but without a sufficient reasoning
here in the schema I'm just going to keep asking the same question.

This can probably be, instead, something like

compatible = "mediatek,mt8183-mdp3-rsz";
reg = < .... >;
mediatek,instance-id = <0>;
gce reg, clocks, blah...

or

compatible = "mediatek,mt8183-mdp3-rsz";
reg = < ...rsz0... >, < ...rsz1... >;
reg-names = "rsz0", "rsz1";
gce reg, clocks, blah...

...In any case, if MediaTek chose to separate these like that, I guess that
there will be differences in newer SoCs that would make that kind of
binding
much necessary.

Quoted 3 lines

Please Moudy, can you explain why you didn't write that like the examples
that I provided there?

Before version 10 it was written the same way as the first form Angelo
mentioned - with h/w indexed properties, but Rob thinks it's bad idea.
At that time I asked Rob if it could be rewritten into its current V11
form, but I updated before I got a suggestion. Apologize for the inconvenience casued by my careless handling.

In the 8183 MDP3, only RSZ is configured with 2 sets. The 1st set upstream can have quality adjustment components (like AAL or CCORR or both) connected, but the 2nd set does not.
Although those two RSZ components have the same hardware function but register address. The MDP paths with different functions will be created due to the different upstream and downstream connections. In addition to the various upstream/downstream connection methods caused by chip design, the above conditions are also dynamically determined according to the current usage scenario(with or without PQ,
rotation...etc).
Also, considering that multiple paths are used at the same time, MDP3 will need to know which components are currently available for dispatch.
At present, I can't find a better description form, let me know if you
have any thoughts with this.

Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Rob

Thanks,
Moudy

Hi Rob and Angelo,

I tried to draw the flow to illustrate that there will be different selections of component (RSZ0 or RSZ1) because of the different target paths created.
+------------+ +------------+

|    RDMA0   |          |   ISP[*1]  |
  +------------+          +----
--------+
      A  B  C                   2  1
      v  v  v             
      v  v
      |  |  |                   |  |
      |  |  +---------
+         |  |
      |  |            |         |  |
      |  +-------
+    |         |  |
      |          |    |         |  |
      |  +----
---+----+---------+  |
      |  |       |    |            |
      |  |   
    |    +---------+  |
      v  v       |              |  |
      A  2  
     |              |  |
    ********     |              |  |

** ** | | |
* PQ[*2] * | | |

** ** | | |
******** | | |

| | | | |
v v | v v
A 2 | C 1
+---+------+ | +------
-----+

  |   RSZ0   |   |        |   RSZ1    |
  +---+----
--+   |        +-----------+
      D          |              3  4

v
| v v
| | | |

|  +-------+              |  |
      |  |                      |  |
 |  |  +-------------------+  |
      |  |  |                      |

v v v v
D B 3 4

+------------+ +------------+

|    WROT0   |         |    WDMA    |
  +------------+         +------

------+

[*1] Direct-link path for camera input
[*2] A series of
picture quality adjustment
engines, composed of AAL, CCORR, TDSHP
and COLOR

Although components RSZ0 and RSZ1 have the same HW function, considering that the components corresponding to their upstream and downstream are different, paths with different functions can be created as approprate.
There are 3 paths from RDMA0, which are
A. Path with full PQ(picture quality) adjustments, resize and rotation. B. rotation only.
C. Path with resize and rotation.

For direct-link input, there has 2 possible path, which are
1. Main path: write buffer with resize function
2. Secondary path: can only be used when the picked components are free.

Combining the above features, it can create one of the 5 paths, or dual paths at the same time such as: A+1, B+1 or C(4)+2. In further chips, the number of multi-components and paths will increase.
Is there a more appropriate way to replace the HW index for this design?

Thanks,
Moudy

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

author
#6 lore raw

Re: [PATCH v11 1/3] dt-binding: mt8183: add Mediatek MDP3 dt-bindings

Quoted 60 lines · moudy.ho
Quoted 59 lines · moudy.ho
Quoted 57 lines · AngeloGioacchino Del Regno

Il 21/01/22 22:16, Rob Herring ha scritto:

Quoted 1 line · Moudy Ho

Hello Rob,

since I'm not the best at reviewing dt-bindings, I always try to leave that to

other reviewers; in which case, thank you for your awesome review activity on

all of these (and helping me a lot on some of my attempts to write
yaml..!!)

In this case, though, since I do have knowledge about the platform,
it's probably
worth for me to try to address some of your questions, on at least
this one.

Quoted 33 lines
Quoted 33 lines

This patch adds DT binding document for Media Data Path 3 (MDP3)
a unit in multimedia system used for scaling and color format convert.

---
  .../bindings/media/mediatek,mdp3-rdma.yaml    | 193
++++++++++++++++++
  .../bindings/media/mediatek,mdp3-rsz.yaml     |  55 +++++
  .../bindings/media/mediatek,mdp3-wrot.yaml    |  57 ++++++
  .../bindings/soc/mediatek/mediatek,ccorr.yaml |  47 +++++
  .../bindings/soc/mediatek/mediatek,wdma.yaml  |  58 ++++++
  5 files changed, 410 insertions(+)

create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3- rdma.yaml
create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3- rsz.yaml
create mode 100644
Documentation/devicetree/bindings/media/mediatek,mdp3- wrot.yaml
create mode 100644
Documentation/devicetree/bindings/soc/mediatek/mediatek,ccorr .y
am
l
create mode 100644
Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma. ya
ml

Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

diff --git a/Documentation/devicetree/bindings/media/mediatek,mdp3- rdma.yaml b/Documentation/devicetree/bindings/media/mediatek,mdp3- rdma.yaml
new file mode 100644
index 000000000000..002503383934
--- /dev/null

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 4

Quoted 8 lines

+++ b/Documentation/devicetree/bindings/media/mediatek,mdp3- rdma.yaml

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +4 -0
@@ -0,0 +1,193 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/media/mediatek,mdp3-rdma.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtt5fpkQb$

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review line 5

Quoted 3 lines
(quoted diff) +1 -0
+$schema: 

https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtk8-fzFI$

Quoted 439 lines
Quoted 62 lines
Quoted 44 lines
Quoted 24 lines
Quoted 24 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +8 -0
+
+title: Mediatek Read Direct Memory Access
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  Mediatek Read Direct Memory Access(RDMA) component used to

do
read DMA.
+ It contains one line buffer to store the sufficient pixel data, and

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +3 -0
+  must be siblings to the central MMSYS_CONFIG node.
+  For a description of the MMSYS_CONFIG binding, see
+  Documentation/devicetree/bindings/arm/mediatek/mediatek,mm

sy
s.
yaml

(quoted diff) +2 -0
+  for details.
+  The 1st RDMA is also used to be a controller node in Media

Data Path 3(MDP3)

(quoted diff) +2 -0
+  that containing MMSYS, MUTEX, GCE and SCP settings.
+
Quoted 10 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 27

Quoted 6 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+properties:
+  compatible:
+    oneOf:
+      - items:
+          # MDP3 controller node
+          - const: mediatek,mt8183-mdp3

How is this more specific than this:

Quoted 1 line

+ - const: mediatek,mt8183-mdp3-rdma0

Probably, oneOf is not the right choice here... "mediatek,mt8183- mdp3" is needed
to probe the "main" mdp3 core pdev, while RDMA0 is a necessary component (as in
this driver uses the component framework, and rdma0 is required for
functionality,
as far as I understand).

Quoted 8 lines

This shouldn't be a choice, meaning that defining mdp3-rdma0 without
mdp3 is
completely useless, as there wouldn't be anything else initializing
that component,
nor sub-components of that.

Hi Rob and Angelo,
Sorry for the incomplete description here, I originally planned to add
a compatible name here in the future when the chip has multiple RDMAs.
Since 8183 currently has only one RDMA, the above design expression is
incorrect and should be rewritten as follows:

Quoted 7 lines

[8183]
properties:
compatible:
items:
# MDP3 controller node
- const: mediatek,mt8183-mdp3
- const: mediatek,mt8195-mdp3-rdma0

fix typo
- const: mediatek,mt8183-mdp3-rdma0

Quoted 367 lines

[8195]
properties:
compatible:
oneOf:
- items:
# MDP3 controller node
- const: mediatek,mt8183-mdp3
- const: mediatek,mt8195-mdp3-rdma0
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma1
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma2
- items:
# normal RDMA conponent
- const: mediatek,mt8195-mdp3-rdma3

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+      - items:
+          # normal RDMA conponent
+          - const: mediatek,mt8183-mdp3-rdma0
+
+  mediatek,scp:
+    description: The node of system control processor (SCP),

using
+ the remoteproc & rpmsg framework.

Quoted 8 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 40

Quoted 5 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +5 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mdp3-comps:
+    description: MTK sub-system of direct-link or DIP

This needs a better description. What is DIP? What is direct- link?

Quoted 2 lines

I agree, this needs a better description.

I tried to modify the description as follows, could you help to see if
there is anything confusing:

mediatek,mdp3-comps:
description:
MDP subsystem which has direct-link from Image Signal
Processor(ISP).
When using the camera, the DMA of ISP PASS (DIP) module will
directly trigger MDP3 without other control (such as V4L2 M2M) to create corresponding HW path.
The MDP3 controller must set up a series of registers at the
beginning of path creation which covering MMSYS, IMGSYS, and MDP3's components, so that data flow can pass through MDP3.

      The entire path is briefly described as follows:
      DIP   : ISP ->
      MDP3  :       IMGI -> DL -> CCORR(optional) -> RSZ ->

PATH_OUT
->
WDMA/WROT

Quoted 48 lines
Quoted 28 lines
Quoted 24 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +5 -0
+    $ref: /schemas/types.yaml#/definitions/string-array
+    items:
+      - enum:
+          # MDP direct-link input path selection, create a
+          # component for path connectedness of HW pipe

control

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +6 -0
+          - mediatek,mt8183-mdp3-dl1
+      - enum:
+          - mediatek,mt8183-mdp3-dl2
+      - enum:
+          # MDP direct-link output path selection, create a
+          # component for path connectedness of HW pipe

control

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +5 -0
+          - mediatek,mt8183-mdp3-path1
+      - enum:
+          - mediatek,mt8183-mdp3-path2
+      - enum:
+          # Input DMA of ISP PASS2 (DIP) module for raw

image
input

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +3 -0
+          - mediatek,mt8183-mdp3-imgi
+      - enum:
+          # Output DMA of ISP PASS2 (DIP) module for YUV
Quoted 3 lines

image
output
+ - mediatek,mt8183-mdp3-exto

Quoted 5 lines

There's only 1 possible value for mediatek,mdp3-comps, so why does
it
need to be in DT?

The wanted logic here (I believe) is that, depending on firmware capabilities
and/or platform/board capabilities, you may miss some subcomponents
like IMGI
and/or EXTO.
As for DL1/2 and PATH1/2... DL1+PATH1 is surely critically necessary
for the
functionality of the MDP3 RDMA... I don't know whether it's possible
that we
get any fw/platform/device that's not using DL2/PATH2 at all.

Quoted 2 lines

Moudy, can you please explain?

Hi Angelo,
Thanks for your help and your assumptions are correct. In further chips(such as 8195), IMGI will be replaced by WPE, and
PATH_OUT will be removed, and DL will be expanded to 6 (implicit number
of direct-link from ISP paths).
For this variable hardware design, not sure how to flexibly
describe
in dt-bindings to meet futher requirements.
It should be that I got wrong with the definition of "enum",
should
it be rewritten as follows in 8183?
items:
- enum:
# MDP direct-link input path selection, create a # component for path connectedness of HW pipe control
- mediatek,mt8183-mdp3-dl1
- mediatek,mt8183-mdp3-dl2
# MDP direct-link output path selection, create a # component for path connectedness of HW pipe control
- mediatek,mt8183-mdp3-path1
- mediatek,mt8183-mdp3-path2
# Input DMA of ISP PASS2 (DIP) module for raw image input
- mediatek,mt8183-mdp3-imgi
# Output DMA of ISP PASS2 (DIP) module for YUV image
output

          - mediatek,mt8183-mdp3-exto
      items: (8195)
          snip....
      items: (8192)
          snip...
Quoted 95 lines
Quoted 51 lines
Quoted 51 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +11 -0
+
+  reg:
+    items:
+      - description: basic RDMA HW address
+      - description: MDP direct-link 1st and 2nd input
+      - description: MDP direct-link 1st output
+      - description: MDP direct-link 2nd output
+      - description: ISP input and output
+
+  mediatek,gce-client-reg:
+    description: The register of client driver can be

configured
by gce with
+ 4 arguments defined in this property, such as phandle
of
gce, subsys id,
+ register offset and size. Each GCE subsys id is
mapping
to
a client
+ defined in the header include/dt-bindings/gce/<chip>-
gce.h.

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +4 -0
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - description: GCE client for RDMA
+      - description: GCR client for MDP direct-link 1st and

2nd
input
+ - description: GCR client for MDP direct-link 1st
output
+ - description: GCR client for MDP direct-link 2nd
output

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +19 -0
+      - description: GCR client for ISP input and output
+
+  power-domains:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: RDMA clock
+      - description: RSZ clock
+      - description: direck-link TX clock in MDP side
+      - description: direck-link RX clock in MDP side
+      - description: direck-link TX clock in ISP side
+      - description: direck-link RX clock in ISP side
+
+  iommus:
+    maxItems: 1
+
+  mediatek,mmsys:
+    description: The node of mux(multiplexer) controller for
Quoted 9 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 102

Quoted 5 lines

HW
connections.

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +3 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mediatek,mm-mutex:

Is this some sort of h/w lock? We have a standard binding for that.

There's a story behind that one: this was part of mtk (display) DRM
drivers, then
it was moved to soc/mediatek/mtk-mutex.c as it started being shared.

I wonder if the mm-mutex can be rewritten and moved to hwspinlock...
this driver
is growing and now, with the introduction of MDP3, we're seeing some
more.

Though, it's definitely worth mentioning that the usage of MediaTek's
mm-mutex is
varying a bit between the drm case and the mdp3 case as, here, we have a "command
queue" mechanism that is used for commands ordering in HW. This is a very complex architecture that has very specific requirements.
For how I see it, migrating that to hwspinlock would require an almost complete
reimplementation of soc/mediatek/*, which would take a considerable
amount of
time and efforts.
I'm mostly sure that I can help with that, but for how things are looking right

now, between refactoring, getting code solid, going through sane reviews and a
final merge, I'd say that this will take 8-12 months from now.

Quoted 11 lines

For this reason, I would propose to perform a slow and steady migration of the
MediaTek mmsys, scpsys, mutex over time, but only after getting in
the support
for the new SoCs and functionality for the older ones, provided in
this series
and some others that were already sent by MTK, half (or more) of which have
already been merged.

Sorry for the misunderstanding caused by the name, the original
mtk-
mutex design did have the ability to lock registers, but that has since
been removed but the name continues.
It's not one of those h/w locks like spinlock, semaphore, or
mutex
but is just designed to send signals to trigger h/w components to get
or send data.

Quoted 108 lines
Quoted 108 lines
Quoted 108 lines

+ description: The node of sof(start of frame) signal
controller.

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +5 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+    maxItems: 1
+
+  mediatek,mailbox-gce:
+    description: The node of global command engine (GCE),

used
to read/write

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +12 -0
+      registers with critical time limitation.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  mboxes:
+    items:
+      - description: used for 1st data pipe from RDMA
+      - description: used for 2nd data pipe from RDMA
+      - description: used for 3rd data pipe from Direct-Link
+      - description: used for 4th data pipe from Direct-Link
+
+  gce-subsys:
+    description: sub-system id corresponding to the global

command engine (GCE)

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +49 -0
+      register address.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+
+if:
+  properties:
+    compatible:
+      contains:
+        const: mediatek,mt8183-mdp3
+
+then:
+  required:
+    - mediatek,scp
+    - mediatek,mmsys
+    - mediatek,mm-mutex
+    - mediatek,mailbox-gce
+    - mboxes
+    - gce-subsys
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - mediatek,gce-client-reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8183-clk.h>
+    #include <dt-bindings/gce/mt8183-gce.h>
+    #include <dt-bindings/power/mt8183-power.h>
+    #include <dt-bindings/memory/mt8183-larb-port.h>
+
+    mdp3_rdma0: mdp3_rdma0@14001000 {
+      compatible = "mediatek,mt8183-mdp3",
+                   "mediatek,mt8183-mdp3-rdma0";
+      mediatek,scp = <&scp>;
+      mediatek,mdp3-comps = "mediatek,mt8183-mdp3-dl1",
+                            "mediatek,mt8183-mdp3-dl2",
+                            "mediatek,mt8183-mdp3-path1",
+                            "mediatek,mt8183-mdp3-path2",
+                            "mediatek,mt8183-mdp3-imgi",
+                            "mediatek,mt8183-mdp3-exto";
+      reg = <0x14001000 0x1000>,
+            <0x14000000 0x1000>,
+            <0x14005000 0x1000>,
+            <0x14006000 0x1000>,
+            <0x15020000 0x1000>;
+      mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x1000

0x1000>,
+ <&gce SUBSYS_1400XXXX 0
0x1000>,
+ <&gce SUBSYS_1400XXXX 0x5000
0x1000>,
+ <&gce SUBSYS_1400XXXX 0x6000
0x1000>,
+ <&gce SUBSYS_1502XXXX 0
0x1000>;

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +20 -0
+      power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
+      clocks = <&mmsys CLK_MM_MDP_RDMA0>,
+               <&mmsys CLK_MM_MDP_RSZ1>,
+               <&mmsys CLK_MM_MDP_DL_TXCK>,
+               <&mmsys CLK_MM_MDP_DL_RX>,
+               <&mmsys CLK_MM_IPU_DL_TXCK>,
+               <&mmsys CLK_MM_IPU_DL_RX>;
+      iommus = <&iommu>;
+      mediatek,mmsys = <&mmsys>;
+      mediatek,mm-mutex = <&mutex>;
+      mediatek,mailbox-gce = <&gce>;
+      mboxes = <&gce 20 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 21 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 22 CMDQ_THR_PRIO_LOWEST>,
+               <&gce 23 CMDQ_THR_PRIO_LOWEST>;
+      gce-subsys = <&gce 0x14000000 SUBSYS_1400XXXX>,
+                   <&gce 0x14010000 SUBSYS_1401XXXX>,
+                   <&gce 0x14020000 SUBSYS_1402XXXX>,
+                   <&gce 0x15020000 SUBSYS_1502XXXX>;
+    };

diff --git a/Documentation/devicetree/bindings/media/mediatek,mdp3- rsz.yaml b/Documentation/devicetree/bindings/media/mediatek,mdp3- rsz.yaml
new file mode 100644
index 000000000000..cd4cf1531535
--- /dev/null

Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml line 4

Quoted 8 lines

+++ b/Documentation/devicetree/bindings/media/mediatek,mdp3- rsz.yaml

Documentation/devicetree/bindings/media/mediatek,mdp3-rdma.yaml new file +4 -0
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 

https://urldefense.com/v3/__http://devicetree.org/schemas/media/mediatek,mdp3-rsz.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtoNRPuZQ$

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review line 5

Quoted 3 lines
(quoted diff) +1 -0
+$schema: 

https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!CTRNKA9wMg0ARbw!zgc4tZBqeOyinIM3DFy7YlTTFM9LtRFRUOLmIB6Go6xpTeaPQaFg_ekOtk8-fzFI$

Quoted 89 lines
Quoted 83 lines
Quoted 48 lines
Quoted 21 lines
Quoted 11 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +8 -0
+
+title: Mediatek Resizer
+
+maintainers:
+  - Matthias Brugger <[email protected]>
+
+description: |
+  One of Media Data Path 3 (MDP3) components used to do

frame
resizing.

Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml line 20

Quoted 7 lines
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +7 -0
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - mediatek,mt8183-mdp3-rsz0
+          - mediatek,mt8183-mdp3-rsz1

Again, what's the difference between 0 and 1?

Quoted 4 lines

I've probably asked that before, but without a sufficient reasoning
here in the schema I'm just going to keep asking the same question.

This can probably be, instead, something like

compatible = "mediatek,mt8183-mdp3-rsz";
reg = < .... >;
mediatek,instance-id = <0>;
gce reg, clocks, blah...

or

compatible = "mediatek,mt8183-mdp3-rsz";
reg = < ...rsz0... >, < ...rsz1... >;
reg-names = "rsz0", "rsz1";
gce reg, clocks, blah...

...In any case, if MediaTek chose to separate these like that, I guess that
there will be differences in newer SoCs that would make that kind of
binding
much necessary.

Quoted 3 lines

Please Moudy, can you explain why you didn't write that like the examples
that I provided there?

Before version 10 it was written the same way as the first form Angelo
mentioned - with h/w indexed properties, but Rob thinks it's bad idea.
At that time I asked Rob if it could be rewritten into its current V11
form, but I updated before I got a suggestion. Apologize for the inconvenience casued by my careless handling.

In the 8183 MDP3, only RSZ is configured with 2 sets. The 1st set upstream can have quality adjustment components (like AAL or CCORR or
both) connected, but the 2nd set does not.
Although those two RSZ components have the same hardware function but
register address. The MDP paths with different functions will be created due to the different upstream and downstream connections. In addition to the various upstream/downstream connection methods caused by chip design, the above conditions are also dynamically determined according to the current usage scenario(with or without PQ,
rotation...etc).
Also, considering that multiple paths are used at the same time, MDP3
will need to know which components are currently available for dispatch.
At present, I can't find a better description form, let me know if you
have any thoughts with this.

Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Rob

Thanks,
Moudy

Quoted 6 lines

Hi Rob and Angelo,

I tried to draw the flow to illustrate that there will be different selections of component (RSZ0 or RSZ1) because of the different target
paths created.

  +------------+          +------------+
  |   RDMA0    |          |   ISP[*1]  |
  +---+--+--+--+          +-----+--+---+
      A  B  C                   2  1
      v  v  v                   v  v
      |  |  |                   |  |
      |  |  +---------+         |  |
      |  |            |         |  |
      |  +-------+    |         |  |
      |          |    |         |  |
      |  +-------+----+---------+  |
      |  |       |    |            |
      |  |       |    +---------+  |
      v  v       |              |  |
      A  2       |              |  |
    ********     |              |  |
  **        **   |              |  |
 *   PQ[*2]   *  |              |  |
  **        **   |              |  |
    ********     |              |  |
      |  |       |              |  |
      v  v       |              v  v
      A  2       |              C  1
  +---+--+---+   |        +-----+--+--+
  |   RSZ0   |   |        |   RSZ1    |
  +---+------+   |        +-----+--+--+
      D          |              3  4
      v          |              v  v
      |          |              |  |
      |  +-------+              |  |
      |  |                      |  |
      |  |  +-------------------+  |
      |  |  |                      |
      v  v  v                      v
      D  B  3                      4
  +---+--+--+--+         +---------+--+
  |   WROT0    |         |    WDMA    |
  +------------+         +------------+

update diagram for typesetting

Quoted 29 lines

[*1] Direct-link path for camera input
[*2] A series of
picture quality adjustment
engines, composed of AAL, CCORR, TDSHP
and COLOR

Although components RSZ0 and RSZ1 have the same HW function, considering that the components corresponding to their upstream and downstream are different, paths with different functions can be created
as approprate.
There are 3 paths from RDMA0, which are
A. Path with full PQ(picture quality) adjustments, resize and rotation.
B. rotation only.
C. Path with resize and rotation.

For direct-link input, there has 2 possible path, which are
1. Main path: write buffer with resize function
2. Secondary path: can only be used when the picked components are free.

Combining the above features, it can create one of the 5 paths, or dual
paths at the same time such as: A+1, B+1 or C(4)+2. In further chips, the number of multi-components and paths will increase.
Is there a more appropriate way to replace the HW index for this design?

Quoted 2 lines

Thanks,
Moudy

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#15 lore raw
In reply to Moudy Ho

Il 05/01/22 10:37, Moudy Ho ha scritto:

Quoted 98 lines

Change since v10:
- The routing table needs to be discarded, and the calculation result on the SCP side is used to write a suitable mux setting for
1 input port and 2 output ports.
- Adjust dts parsing flow to remove redundant HW IDs.
- Fix memory leak caused by no free path information in function "mdp_cmdq_send".

Change since v9:
- Keep only the MDP3 driver patches and split the remaining mmsys and mutex patches into another mail.
- Move mutex mod settings to corresponding driver and make relevant adjustments for this in MDP3 driver.
- Fix compile warning reported by kernel test robot.

Change since v8:
- Rebase on v5.16-rc2.
- Refer to Angelo's suggestion, adjust the register writing format to increase readability and significance.
- Refer to Angelo's suggestion, adjust or reduce inappropriate debugging messages.
- Refer to Rob Herring's suggestion to correct the the binding file to make it with the specification.
- Fix compile warning reported by kernel test robot.

Change since v7:
- Rebase on v5.15-rc6.
- Revise several V4L2 M2M settings to pass v4l2-compliance test.
- Integrate those same component dt-binding documents of DRM and MDP, and move them under the MMSYS domain.
- Split MMSYS and MUTEX into two different files according to their functional properties.

Changes since v6:
- Refactor GCE event to corresponding node.
- Fix dt_binding_check fail.
- Fix compilation errors.

Changes since v5:
- Rebase on v5.14-rc6.
- Move MMSYS/Mutex settings to corresponding driver.
- Revise the software license description and copyright.
- Remove unnecessary enum. or definitions.
- Optimize platform/chip definition conditions.
- Use general printing functions instead of MDP3 private ones.
- Fix compile warning.

Changes since v4:
- Rebase on v5.13-rc1.
- Remove the CMDQ flush flow to match the CMDQ API change.
- Integrate four of MDP's direct-link subcomponents into MDP controller node from syscon node to avoid illegal clock usage.
- Rewrite dt-binding in a JSON compatible subset of YAML
- Fix a bit of macro argument precedence.

Changes since v3:
- Rebase on v5.9-rc1.
- modify code for review comment from Rob Herring, cancel multiple nodes using same register base situation.
- control IOMMU port through pm runtime get/put to DMA components' device.
- SCP(VPU) driver revision.
- stop queuing jobs(remove flush_workqueue()) after mdp_m2m_release().
- add computation of plane address with data_offset.
- fix scale ratio check issue.
- add default v4l2_format setting.

Changes since v2:
- modify code for review comment from Tomasz Figa & Alexandre Courbot
- review comment from Rob Herring will offer code revision in v4, due to it's related to device node modification, will need to modify code architecture

Changes since v1:
- modify code for CMDQ v3 API support
- EC ipi cmd migration
- fix compliance test fail item (m2m cmd with -f) due to there is two problem in runing all format(-f) cmd:
1. out of memory before test complete
Due to capture buffer mmap (refcount + 1) after reqbuf but seems
no corresponding munmap called before device close.
There are total 12XX items(formats) in format test and each format
alloc 8 capture/output buffers.
2. unceasingly captureBufs() (randomly)

         Seems the break statement didn't catch the count == 0 situation:
         In v4l2-test-buffers.cpp, function: captureBufs()
                         ...
                         count--;
                         if (!node->is_m2m && !count)
                                 break;
         Log is as attachment

I will paste the test result with problem part in another e-mail

Hi,

This is the first version of RFC patch for Media Data Path 3 (MDP3), MDP3 is used for scaling and color format conversion. support using GCE to write register in critical time limitation. support V4L2 m2m device control.

Quoted 5 lines

Moudy Ho (3):
dt-binding: mt8183: add Mediatek MDP3 dt-bindings
dts: arm64: mt8183: add Mediatek MDP3 nodes
media: platform: mtk-mdp3: add Mediatek MDP3 driver

Hello Moudy,

In next-20220315, all MediaTek media drivers have been moved in a different subdirectory. Now they are all in drivers/media/platform/mediatek/.

Can you please rebase this series, placing the MDP3 driver in drivers/media/platform/mediatek/mdp3 ?

While at it, also please include the additional documentation and address the rdma/rsz (etc) suggestions about using one compatible and a instance-id property to express the multiple instances (remember: "mediatek,mt8183-mdp3-rdma", mediatek,instance-id = <0>).... and all the other constructive suggestions that were given during the extensive review of patch 1/3 of this series.

Looking forward to see a new version!

Regards,
Angelo