Skip to contentSkip to conversation

media: mediatek: support mdp3 on mt8183 platform

PATCH Superseded Moudy Ho 4 participants 16 messages Dec 1, 2021 – Dec 2, 2021

Subsystems (3)

v9 of 28 Superseded Latest is v28 →

lore
Share & tools
lore

Moudy Ho

author
#0 lore raw

v9 cover media: mediatek: support mdp3 on mt8183 platform

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 (7):
soc: mediatek: mmsys: add support for MDP
soc: mediatek: mmsys: add support for ISP control
soc: mediatek: mutex: add support for MDP
soc: mediatek: mutex: add functions that operate registers by CMDQ
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-rsz.yaml     |   65 +
 .../bindings/media/mediatek,mdp3-wrot.yaml    |   67 +
 .../bindings/soc/mediatek/mediatek,ccorr.yaml |   57 +
 .../bindings/soc/mediatek/mediatek,rdma.yaml  |  216 +++
 .../bindings/soc/mediatek/mediatek,wdma.yaml  |   68 +
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      |  115 +-
 drivers/media/platform/Kconfig                |   19 +
 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   |  514 +++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
 .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1264 +++++++++++++++++
 .../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 +
 drivers/soc/mediatek/Kconfig                  |    1 +
 drivers/soc/mediatek/mt8183-mmsys.h           |  294 ++++
 drivers/soc/mediatek/mtk-mmsys.c              |  173 +++
 drivers/soc/mediatek/mtk-mmsys.h              |    3 +
 drivers/soc/mediatek/mtk-mutex.c              |   98 +-
 include/linux/soc/mediatek/mtk-mmsys.h        |   86 ++
 include/linux/soc/mediatek/mtk-mutex.h        |    8 +
 35 files changed, 6530 insertions(+), 2 deletions(-)
 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,rdma.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 v9 1/7 soc: mediatek: mmsys: add support for MDP

For the purpose of module independence, related settings should be moved from MDP to the corresponding driver.
This patch adds more 8183 MDP settings and interface. and MDP related settings must be set via CMDQ to avoid frame unsynchronized.

---
 drivers/soc/mediatek/Kconfig           |   1 +
 drivers/soc/mediatek/mt8183-mmsys.h    | 268 +++++++++++++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.c       |  56 ++++++
 drivers/soc/mediatek/mtk-mmsys.h       |   2 +
 include/linux/soc/mediatek/mtk-mmsys.h |  56 ++++++
 5 files changed, 383 insertions(+)
drivers/soc/mediatek/Kconfig +1 -0
index fdd8bc08569e..172bc7828aca 100644
@@ -69,6 +69,7 @@ config MTK_MMSYS
 	bool "MediaTek MMSYS Support"
 	default ARCH_MEDIATEK
 	depends on HAS_IOMEM
+	select MTK_CMDQ
 	help
 	  Say yes here to add support for the MediaTek Multimedia
 	  Subsystem (MMSYS).
drivers/soc/mediatek/mt8183-mmsys.h +268 -0

285 lines not on this page · raw message

drivers/soc/mediatek/mtk-mmsys.c +56 -0

95 lines not on this page · raw message

drivers/soc/mediatek/mtk-mmsys.h +2 -0
index 8b0ed05117ea..7ec2107b9823 100644
@@ -92,6 +92,8 @@ struct mtk_mmsys_driver_data {
 	const char *clk_driver;
 	const struct mtk_mmsys_routes *routes;
 	const unsigned int num_routes;
+	const struct mtk_mmsys_routes *mdp_routes;
+	const unsigned int mdp_num_routes;
 };
 
 /*
include/linux/soc/mediatek/mtk-mmsys.h +56 -0

74 lines not on this page · raw message

Signature · 1 line
2.18.0
author
#2 lore raw

PATCH v9 2/7 soc: mediatek: mmsys: add support for ISP control

In reply to Moudy Ho

This patch adds 8183 ISP settings in MMSYS domain and interface.

---
 drivers/soc/mediatek/mt8183-mmsys.h    |  26 ++++++
 drivers/soc/mediatek/mtk-mmsys.c       | 117 +++++++++++++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.h       |   1 +
 include/linux/soc/mediatek/mtk-mmsys.h |  30 +++++++
 4 files changed, 174 insertions(+)
drivers/soc/mediatek/mt8183-mmsys.h +26 -0
index 48865973314d..afc98c4dac95 100644
@@ -32,6 +32,18 @@
 #define MT8183_MDP_CCORR_SEL_IN			0xff0
 #define MT8183_MDP_CCORR_SOUT_SEL		0xff4
 
+#define MT8183_ISP_REG_MMSYS_SW0_RST_B		0x140
+#define MT8183_ISP_REG_MMSYS_SW1_RST_B		0x144
+#define MT8183_ISP_REG_MDP_ASYNC_CFG_WD		0x934
+#define MT8183_ISP_REG_MDP_ASYNC_IPU_CFG_WD	0x93C
+#define MT8183_ISP_REG_ISP_RELAY_CFG_WD		0x994
+#define MT8183_ISP_REG_IPU_RELAY_CFG_WD		0x9a0
+#define MT8183_ISP_BIT_MDP_DL_ASYNC_TX		BIT(3)
+#define MT8183_ISP_BIT_MDP_DL_ASYNC_TX2		BIT(4)
+#define MT8183_ISP_BIT_MDP_DL_ASYNC_RX		BIT(10)
+#define MT8183_ISP_BIT_MDP_DL_ASYNC_RX2		BIT(11)
+#define MT8183_ISP_BIT_NO_SOF_MODE		BIT(31)
+
 #define MT8183_OVL0_MOUT_EN_OVL0_2L		BIT(4)
 #define MT8183_OVL0_2L_MOUT_EN_DISP_PATH0	BIT(0)
 #define MT8183_OVL1_2L_MOUT_EN_RDMA1		BIT(4)
@@ -325,5 +337,19 @@ static const struct mtk_mmsys_routes mmsys_mt8183_mdp_routing_table[] = {
 	}
 };
 
+static const unsigned int mmsys_mt8183_mdp_isp_ctrl_table[ISP_CTRL_MAX] = {
+	[ISP_REG_MMSYS_SW0_RST_B] = MT8183_ISP_REG_MMSYS_SW0_RST_B,
+	[ISP_REG_MMSYS_SW1_RST_B] = MT8183_ISP_REG_MMSYS_SW1_RST_B,
+	[ISP_REG_MDP_ASYNC_CFG_WD] = MT8183_ISP_REG_MDP_ASYNC_CFG_WD,
+	[ISP_REG_MDP_ASYNC_IPU_CFG_WD] = MT8183_ISP_REG_MDP_ASYNC_IPU_CFG_WD,
+	[ISP_REG_ISP_RELAY_CFG_WD] = MT8183_ISP_REG_ISP_RELAY_CFG_WD,
+	[ISP_REG_IPU_RELAY_CFG_WD] = MT8183_ISP_REG_IPU_RELAY_CFG_WD,
+	[ISP_BIT_MDP_DL_ASYNC_TX] = MT8183_ISP_BIT_MDP_DL_ASYNC_TX,
+	[ISP_BIT_MDP_DL_ASYNC_TX2] = MT8183_ISP_BIT_MDP_DL_ASYNC_TX2,
+	[ISP_BIT_MDP_DL_ASYNC_RX] = MT8183_ISP_BIT_MDP_DL_ASYNC_RX,
+	[ISP_BIT_MDP_DL_ASYNC_RX2] = MT8183_ISP_BIT_MDP_DL_ASYNC_RX2,
+	[ISP_BIT_NO_SOF_MODE] = MT8183_ISP_BIT_NO_SOF_MODE,
+};
+
 #endif /* __SOC_MEDIATEK_MT8183_MMSYS_H */
 
drivers/soc/mediatek/mtk-mmsys.c +117 -0

129 lines not on this page · raw message

drivers/soc/mediatek/mtk-mmsys.h +1 -0
index 7ec2107b9823..61baec9409de 100644
@@ -94,6 +94,7 @@ struct mtk_mmsys_driver_data {
 	const unsigned int num_routes;
 	const struct mtk_mmsys_routes *mdp_routes;
 	const unsigned int mdp_num_routes;
+	const unsigned int *mdp_isp_ctrl;
 };
 
 /*
include/linux/soc/mediatek/mtk-mmsys.h +30 -0
index c5a4d6b181ce..1938428369f2 100644
@@ -91,6 +91,29 @@ enum mtk_mdp_comp_id {
 	MDP_MAX_COMP_COUNT	/* ALWAYS keep at the end */
 };
 
+enum mtk_mdp_pipe_id {
+	MDP_PIPE_RDMA0,
+	MDP_PIPE_IMGI,
+	MDP_PIPE_WPEI,
+	MDP_PIPE_WPEI2,
+	MDP_PIPE_MAX
+};
+
+enum mtk_isp_ctrl {
+	ISP_REG_MMSYS_SW0_RST_B,
+	ISP_REG_MMSYS_SW1_RST_B,
+	ISP_REG_MDP_ASYNC_CFG_WD,
+	ISP_REG_MDP_ASYNC_IPU_CFG_WD,
+	ISP_REG_ISP_RELAY_CFG_WD,
+	ISP_REG_IPU_RELAY_CFG_WD,
+	ISP_BIT_MDP_DL_ASYNC_TX,
+	ISP_BIT_MDP_DL_ASYNC_TX2,
+	ISP_BIT_MDP_DL_ASYNC_RX,
+	ISP_BIT_MDP_DL_ASYNC_RX2,
+	ISP_BIT_NO_SOF_MODE,
+	ISP_CTRL_MAX
+};
+
 void mtk_mmsys_ddp_connect(struct device *dev,
 			   enum mtk_ddp_comp_id cur,
 			   enum mtk_ddp_comp_id next);
@@ -109,4 +132,11 @@ void mtk_mmsys_mdp_disconnect(struct device *dev,
 			      enum mtk_mdp_comp_id cur,
 			      enum mtk_mdp_comp_id next);
 
+void mtk_mmsys_mdp_isp_ctrl(struct device *dev, struct mmsys_cmdq_cmd *cmd,
+			    enum mtk_mdp_comp_id id);
+
+void mtk_mmsys_mdp_camin_ctrl(struct device *dev, struct mmsys_cmdq_cmd *cmd,
+			      enum mtk_mdp_comp_id id,
+			      u32 camin_w, u32 camin_h);
+
 #endif /* __MTK_MMSYS_H */
Signature · 1 line
2.18.0
maintainer Acked-by on v9 2/7
#3 lore raw

Re: [PATCH v9 2/7] soc: mediatek: mmsys: add support for ISP control

Il 01/12/21 10:50, Moudy Ho ha scritto:

Quoted 10 lines

This patch adds 8183 ISP settings in MMSYS domain and interface.

---
  drivers/soc/mediatek/mt8183-mmsys.h    |  26 ++++++
  drivers/soc/mediatek/mtk-mmsys.c       | 117 +++++++++++++++++++++++++
  drivers/soc/mediatek/mtk-mmsys.h       |   1 +
  include/linux/soc/mediatek/mtk-mmsys.h |  30 +++++++
  4 files changed, 174 insertions(+)
author
#4 lore raw

PATCH v9 3/7 soc: mediatek: mutex: add support for MDP

In reply to Moudy Ho

For the purpose of module independence, related settings should be moved from MDP to the corresponding driver.
This patch adds more 8183 MDP settings and interface.

---
 drivers/soc/mediatek/mtk-mutex.c       | 33 ++++++++++++++++++++++++++
 include/linux/soc/mediatek/mtk-mutex.h |  2 ++
 2 files changed, 35 insertions(+)
drivers/soc/mediatek/mtk-mutex.c +33 -0
index 2ca55bb5a8be..e5e6255f5b84 100644
@@ -119,6 +119,10 @@
 #define MT8183_MUTEX_EOF_DSI0			(MT8183_MUTEX_SOF_DSI0 << 6)
 #define MT8183_MUTEX_EOF_DPI0			(MT8183_MUTEX_SOF_DPI0 << 6)
 
+#define MT8183_MUTEX_MDP_START			5
+#define MT8183_MUTEX_MDP_MOD_MASK		0x07FFFFFF
+#define MT8183_MUTEX_MDP_SOF_MASK		0x00000007
+
 struct mtk_mutex {
 	int id;
 	bool claimed;
@@ -139,6 +143,9 @@ struct mtk_mutex_data {
 	const unsigned int *mutex_sof;
 	const unsigned int mutex_mod_reg;
 	const unsigned int mutex_sof_reg;
+	const unsigned int *mutex_mdp_offset;
+	const unsigned int mutex_mdp_mod_mask;
+	const unsigned int mutex_mdp_sof_mask;
 	const bool no_clk;
 };
 
@@ -264,6 +271,14 @@ static const unsigned int mt8183_mutex_sof[MUTEX_SOF_DSI3 + 1] = {
 	[MUTEX_SOF_DPI0] = MT8183_MUTEX_SOF_DPI0 | MT8183_MUTEX_EOF_DPI0,
 };
 
+/* indicate which mutex is used by each pipepline */
+static const unsigned int mt8183_mutex_mdp_offset[MDP_PIPE_MAX] = {
+	[MDP_PIPE_IMGI] = MT8183_MUTEX_MDP_START,
+	[MDP_PIPE_RDMA0] = MT8183_MUTEX_MDP_START + 1,
+	[MDP_PIPE_WPEI] = MT8183_MUTEX_MDP_START + 2,
+	[MDP_PIPE_WPEI2] = MT8183_MUTEX_MDP_START + 3
+};
+
 static const struct mtk_mutex_data mt2701_mutex_driver_data = {
 	.mutex_mod = mt2701_mutex_mod,
 	.mutex_sof = mt2712_mutex_sof,
@@ -298,6 +313,9 @@ static const struct mtk_mutex_data mt8183_mutex_driver_data = {
 	.mutex_sof = mt8183_mutex_sof,
 	.mutex_mod_reg = MT8183_MUTEX0_MOD0,
 	.mutex_sof_reg = MT8183_MUTEX0_SOF0,
+	.mutex_mdp_offset = mt8183_mutex_mdp_offset,
+	.mutex_mdp_mod_mask = MT8183_MUTEX_MDP_MOD_MASK,
+	.mutex_mdp_sof_mask = MT8183_MUTEX_MDP_SOF_MASK,
 	.no_clk = true,
 };
 
@@ -323,6 +341,21 @@ struct mtk_mutex *mtk_mutex_get(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(mtk_mutex_get);
 
+struct mtk_mutex *mtk_mutex_mdp_get(struct device *dev,
+				    enum mtk_mdp_pipe_id id)
+{
+	struct mtk_mutex_ctx *mtx = dev_get_drvdata(dev);
+	int i = mtx->data->mutex_mdp_offset[id];
+
+	if (!mtx->mutex[i].claimed) {
+		mtx->mutex[i].claimed = true;
+		return &mtx->mutex[i];
+	}
+
+	return ERR_PTR(-EBUSY);
+}
+EXPORT_SYMBOL_GPL(mtk_mutex_mdp_get);
+
 void mtk_mutex_put(struct mtk_mutex *mutex)
 {
 	struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
include/linux/soc/mediatek/mtk-mutex.h +2 -0
index 6fe4ffbde290..099ddb025d79 100644
@@ -11,6 +11,8 @@ struct device;
 struct mtk_mutex;
 
 struct mtk_mutex *mtk_mutex_get(struct device *dev);
+struct mtk_mutex *mtk_mutex_mdp_get(struct device *dev,
+				    enum mtk_mdp_pipe_id id);
 int mtk_mutex_prepare(struct mtk_mutex *mutex);
 void mtk_mutex_add_comp(struct mtk_mutex *mutex,
 			enum mtk_ddp_comp_id id);
Signature · 1 line
2.18.0
author
#5 lore raw

PATCH v9 4/7 soc: mediatek: mutex: add functions that operate registers by CMDQ

In reply to Moudy Ho

Considering that some functions have timing requirements in specific situation, this patch adds several interface that operate registers by CMDQ.

---
 drivers/soc/mediatek/mtk-mutex.c       | 65 +++++++++++++++++++++++++-
 include/linux/soc/mediatek/mtk-mutex.h |  6 +++
 2 files changed, 70 insertions(+), 1 deletion(-)
drivers/soc/mediatek/mtk-mutex.c +64 -1
index e5e6255f5b84..320d0b72c78d 100644
@@ -7,10 +7,14 @@
 #include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/soc/mediatek/mtk-mmsys.h>
 #include <linux/soc/mediatek/mtk-mutex.h>
+#include <linux/soc/mediatek/mtk-cmdq.h>
+
+#define MTK_MUTEX_ENABLE			BIT(0)
 
 #define MT2701_MUTEX0_MOD0			0x2c
 #define MT2701_MUTEX0_SOF0			0x30
@@ -155,6 +159,8 @@ struct mtk_mutex_ctx {
 	void __iomem			*regs;
 	struct mtk_mutex		mutex[10];
 	const struct mtk_mutex_data	*data;
+	phys_addr_t			addr;
+	u8				subsys_id;
 };
 
 static const unsigned int mt2701_mutex_mod[DDP_COMPONENT_ID_MAX] = {
@@ -475,6 +481,25 @@ void mtk_mutex_remove_comp(struct mtk_mutex *mutex,
 }
 EXPORT_SYMBOL_GPL(mtk_mutex_remove_comp);
 
+void mtk_mutex_add_mod_by_cmdq(struct mtk_mutex *mutex, u32 mod,
+			       struct mmsys_cmdq_cmd *cmd)
+{
+	struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
+						 mutex[mutex->id]);
+	unsigned int offset;
+
+	WARN_ON(&mtx->mutex[mutex->id] != mutex);
+
+	offset = DISP_REG_MUTEX_MOD(mtx->data->mutex_mod_reg, mutex->id);
+	cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id, mtx->addr + offset,
+			    mod, mtx->data->mutex_mdp_mod_mask);
+
+	offset = DISP_REG_MUTEX_SOF(mtx->data->mutex_sof_reg, mutex->id);
+	cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id, mtx->addr + offset,
+			    0, mtx->data->mutex_mdp_sof_mask);
+}
+EXPORT_SYMBOL_GPL(mtk_mutex_add_mod_by_cmdq);
+
 void mtk_mutex_enable(struct mtk_mutex *mutex)
 {
 	struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
@@ -486,6 +511,20 @@ void mtk_mutex_enable(struct mtk_mutex *mutex)
 }
 EXPORT_SYMBOL_GPL(mtk_mutex_enable);
 
+void mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex,
+			      struct mmsys_cmdq_cmd *cmd)
+{
+	struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
+						 mutex[mutex->id]);
+
+	WARN_ON(&mtx->mutex[mutex->id] != mutex);
+
+	cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id,
+			    mtx->addr + DISP_REG_MUTEX_EN(mutex->id),
+			    MTK_MUTEX_ENABLE, MTK_MUTEX_ENABLE);
+}
+EXPORT_SYMBOL_GPL(mtk_mutex_enable_by_cmdq);
+
 void mtk_mutex_disable(struct mtk_mutex *mutex)
 {
 	struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
@@ -497,6 +536,20 @@ void mtk_mutex_disable(struct mtk_mutex *mutex)
 }
 EXPORT_SYMBOL_GPL(mtk_mutex_disable);
 
+void mtk_mutex_disable_by_cmdq(struct mtk_mutex *mutex,
+			       struct mmsys_cmdq_cmd *cmd)
+{
+	struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
+						 mutex[mutex->id]);
+
+	WARN_ON(&mtx->mutex[mutex->id] != mutex);
+
+	cmdq_pkt_write_mask(cmd->pkt, mtx->subsys_id,
+			    mtx->addr + DISP_REG_MUTEX_EN(mutex->id),
+			    0x0, MTK_MUTEX_ENABLE);
+}
+EXPORT_SYMBOL_GPL(mtk_mutex_disable_by_cmdq);
+
 void mtk_mutex_acquire(struct mtk_mutex *mutex)
 {
 	struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
@@ -524,7 +577,8 @@ static int mtk_mutex_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_mutex_ctx *mtx;
-	struct resource *regs;
+	struct cmdq_client_reg cmdq_reg;
+	struct resource *regs, addr;
 	int i;
 
 	mtx = devm_kzalloc(dev, sizeof(*mtx), GFP_KERNEL);
@@ -545,6 +599,15 @@ static int mtk_mutex_probe(struct platform_device *pdev)
 		}
 	}
 
+	if (of_address_to_resource(dev->of_node, 0, &addr) < 0)
+		mtx->addr = 0L;
+	else
+		mtx->addr = addr.start;
+
+	if (cmdq_dev_get_client_reg(dev, &cmdq_reg, 0) != 0)
+		dev_info(dev, "cmdq subsys id has not been set\n");
+	mtx->subsys_id = cmdq_reg.subsys;
+
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	mtx->regs = devm_ioremap_resource(dev, regs);
 	if (IS_ERR(mtx->regs)) {
include/linux/soc/mediatek/mtk-mutex.h +6 -0
index 099ddb025d79..86c17c024d83 100644
@@ -16,8 +16,14 @@ struct mtk_mutex *mtk_mutex_mdp_get(struct device *dev,
 int mtk_mutex_prepare(struct mtk_mutex *mutex);
 void mtk_mutex_add_comp(struct mtk_mutex *mutex,
 			enum mtk_ddp_comp_id id);
+void mtk_mutex_add_mod_by_cmdq(struct mtk_mutex *mutex, u32 mod,
+			       struct mmsys_cmdq_cmd *cmd);
 void mtk_mutex_enable(struct mtk_mutex *mutex);
+void mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex,
+			      struct mmsys_cmdq_cmd *cmd);
 void mtk_mutex_disable(struct mtk_mutex *mutex);
+void mtk_mutex_disable_by_cmdq(struct mtk_mutex *mutex,
+			       struct mmsys_cmdq_cmd *cmd);
 void mtk_mutex_remove_comp(struct mtk_mutex *mutex,
 			   enum mtk_ddp_comp_id id);
 void mtk_mutex_unprepare(struct mtk_mutex *mutex);
Signature · 1 line
2.18.0
maintainer Reviewed-by on v9 4/7
#6 lore raw

Re: [PATCH v9 4/7] soc: mediatek: mutex: add functions that operate registers by CMDQ

Il 01/12/21 10:50, Moudy Ho ha scritto:

Quoted 10 lines

Considering that some functions have timing requirements in specific situation, this patch adds several interface that operate registers by CMDQ.

---
  drivers/soc/mediatek/mtk-mutex.c       | 65 +++++++++++++++++++++++++-
  include/linux/soc/mediatek/mtk-mutex.h |  6 +++
  2 files changed, 70 insertions(+), 1 deletion(-)
author
#7 lore raw

PATCH v9 5/7 dt-binding: mt8183: add Mediatek MDP3 dt-bindings

In reply to 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-rsz.yaml     |  65 ++++++
 .../bindings/media/mediatek,mdp3-wrot.yaml    |  67 ++++++
 .../bindings/soc/mediatek/mediatek,ccorr.yaml |  57 +++++
 .../bindings/soc/mediatek/mediatek,rdma.yaml  | 216 ++++++++++++++++++
 .../bindings/soc/mediatek/mediatek,wdma.yaml  |  68 ++++++
 5 files changed, 473 insertions(+)
 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,rdma.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,wdma.yaml
Documentation/devicetree/bindings/media/mediatek,mdp3-rsz.yaml new file +65 -0
new file mode 100644
index 000000000000..d7f104a0f165
@@ -0,0 +1,65 @@
+# 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]>
+
+description: |
+  One of Media Data Path 3 (MDP3) components used to do frame resizing.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - mediatek,mt8183-mdp3-rsz
+
+  mediatek,mdp3-id:
+    description: There may be multiple components with the same function but
+      different addresses in MDP3. The MDP3 driver can select one or zero of
+      them and connect other components in series according to the current
+      application to form one or more data paths. This property indicate the
+      selection order of the same components.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1, 2, 3]
+
+  reg:
+    maxItems: 1
+
+  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
+    maxItems: 1
+
+  clocks:
+    minItems: 1
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/mt8183-clk.h>
+    #include <dt-bindings/gce/mt8183-gce.h>
+
+    mdp3_rsz0: mdp3_rsz0@14003000 {
+      compatible = "mediatek,mt8183-mdp3-rsz";
+      mediatek,mdp3-id = <0>;
+      reg = <0x14003000 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-rsz";
+      mediatek,mdp3-id = <1>;
+      reg = <0x14004000 0x1000>;
+      mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x4000 0x1000>;
+      clocks = <&mmsys CLK_MM_MDP_RSZ1>;
+    };
Documentation/devicetree/bindings/media/mediatek,mdp3-wrot.yaml new file +67 -0

67 lines not on this page · raw message

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

57 lines not on this page · raw message

Documentation/devicetree/bindings/soc/mediatek/mediatek,rdma.yaml new file +216 -0

216 lines not on this page · raw message

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

68 lines not on this page · raw message

Signature · 1 line
2.18.0
author
#8 lore raw

PATCH v9 6/7 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 | 115 ++++++++++++++++++++++-
 1 file changed, 114 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8183.dtsi +114 -1
index ba4584faca5a..e4dc76b04438 100644
@@ -1325,6 +1325,85 @@
 			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0 0x1000>;
 		};
 
+		mdp3_rdma0: mdp3_rdma0@14001000 {
+			compatible = "mediatek,mt8183-mdp3",
+				     "mediatek,mt8183-mdp3-rdma";
+			mediatek,scp = <&scp>;
+			mediatek,mdp3-id = <0>;
+			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";
+			mediatek,mdp3-comp-ids = <0 1 0 1 0 1>;
+			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 0>,
+				 <&gce 22 CMDQ_THR_PRIO_LOWEST 0>,
+				 <&gce 23 CMDQ_THR_PRIO_LOWEST 0>;
+			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-rsz";
+			mediatek,mdp3-id = <0>;
+			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-rsz";
+			mediatek,mdp3-id = <1>;
+			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-wrot";
+			mediatek,mdp3-id = <0>;
+			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";
+			mediatek,mdp3-id = <0>;
+			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 +1528,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 +1578,14 @@
 			power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
 		};
 
+		mdp3_ccorr: mdp3_ccorr@1401c000 {
+			compatible = "mediatek,mt8183-mdp3-ccorr";
+			mediatek,mdp3-id = <0>;
+			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
author
#9 lore raw

PATCH v9 7/7 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

---
 drivers/media/platform/Kconfig                |   19 +
 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   |  514 +++++++
 .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
 .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1264 +++++++++++++++++
 .../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, 5281 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 +19 -0
index cf4adc64c953..e6c1e8892154 100644
@@ -315,6 +315,25 @@ 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 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 +514 -0

514 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 +1264 -0

1,264 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

43 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.

#10 lore raw

Re: [PATCH v9 7/7] media: platform: mtk-mdp3: add Mediatek MDP3 driver

Il 01/12/21 10:50, Moudy Ho ha scritto:

Quoted 67 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

---
  drivers/media/platform/Kconfig                |   19 +
  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   |  514 +++++++
  .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
  .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1264 +++++++++++++++++
  .../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, 5281 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

snip...

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

Quoted 6 lines
drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c new file +0 -0
new file mode 100644
index 000000000000..a643f3ee928b
@@ -0,0 +1,514 @@

Looks like you forgot to check my review comments to this entire file. Can you please send a new version after applying the changes to this file suggested in my review of series v8?

Thanks.

author
#11 lore raw

Re: [PATCH v9 7/7] media: platform: mtk-mdp3: add Mediatek MDP3 driver

Quoted 82 lines · AngeloGioacchino Del Regno

Il 01/12/21 10:50, Moudy Ho ha scritto:

Quoted 78 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

---
  drivers/media/platform/Kconfig                |   19 +
  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   |  514 +++++++
  .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
  .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1264
+++++++++++++++++
  .../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, 5281 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

snip...

Quoted 13 lines

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

Quoted 7 lines
drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c new file +0 -0
new file mode 100644
index 000000000000..a643f3ee928b
@@ -0,0 +1,514 @@

Looks like you forgot to check my review comments to this entire file.
Can you please send a new version after applying the changes to this file
suggested in my review of series v8?

Hi Angelo,

Thanks for the reminder and sorry for my carelessness. Considering the compatibility of subsequent chips and function independence, I plan to move those mutex mod definition to the corresponding driver, and release next version ASAP.

Thanks & Regards,
Moudy Ho

Quoted 1 line

Thanks.

#12 lore raw

Re: [PATCH v9 7/7] media: platform: mtk-mdp3: add Mediatek MDP3 driver

Il 02/12/21 04:35, moudy ho ha scritto:

Quoted 98 lines · AngeloGioacchino Del Regno
Quoted 82 lines

Il 01/12/21 10:50, Moudy Ho ha scritto:

Quoted 78 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

---
   drivers/media/platform/Kconfig                |   19 +
   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   |  514 +++++++
   .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
   .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1264
+++++++++++++++++
   .../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, 5281 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

snip...

Quoted 13 lines

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

Quoted 7 lines
drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c new file +0 -0
new file mode 100644
index 000000000000..a643f3ee928b
@@ -0,0 +1,514 @@

Looks like you forgot to check my review comments to this entire file.
Can you please send a new version after applying the changes to this file
suggested in my review of series v8?

Hi Angelo,

Quoted 9 lines

Thanks for the reminder and sorry for my carelessness. Considering the compatibility of subsequent chips and function independence, I plan to move those mutex mod definition to the corresponding driver, and release next version ASAP.

Thanks & Regards,
Moudy Ho

Quoted 1 line

Thanks.

Hi Moudy,

Don't worry, we're humans, it happens to the best. We're always here to improve! Thank you for sending the v10 by the way, I will review it as soon as I can.

Regards,
- Angelo

#13 lore raw

Re: [PATCH v9 7/7] media: platform: mtk-mdp3: add Mediatek MDP3 driver

In reply to Moudy Ho
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 linus/master v5.16-rc3 next-20211201] [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/20211201-175258
base:   git://linuxtv.org/media_tree.git master
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20211202/202112020126.zBCAihfa-lkp(a)intel.com/config)
compiler: arceb-elf-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/f6f2b079ebc64ba1d7f0f73b0cfcfe8b98124ec3
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/20211201-175258
git checkout f6f2b079ebc64ba1d7f0f73b0cfcfe8b98124ec3
# 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=arc SHELL=/bin/bash drivers/media/platform/mtk-mdp3/

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

All warnings (new ones prefixed by >>):

In file included from include/linux/device.h:15,
from include/linux/platform_device.h:13,
from drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:7:
drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c: In function 'mdp_cmdq_send':

>> drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:435:30: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     435 |                 dev_err(dev, "%s mdp_path_ctx_init error\n");
         |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:435:17: note: in expansion of macro 'dev_err'
     435 |                 dev_err(dev, "%s mdp_path_ctx_init error\n");
         |                 ^~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:435:32: note: format string is defined here
     435 |                 dev_err(dev, "%s mdp_path_ctx_init error\n");
         |                               ~^
         |                                |
         |                                char *
   In file included from include/linux/device.h:15,
                    from include/linux/platform_device.h:13,
                    from drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:7:
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:445:30: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
     445 |                 dev_err(dev, "%s mdp_path_config error\n");
         |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:445:17: note: in expansion of macro 'dev_err'
     445 |                 dev_err(dev, "%s mdp_path_config error\n");
         |                 ^~~~~~~
   drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c:445:32: note: format string is defined here
     445 |                 dev_err(dev, "%s mdp_path_config error\n");
         |                               ~^
         |                                |
         |                                char *

vim +435 drivers/media/platform/mtk-mdp3/mtk-mdp3-cmdq.c

390
391 int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)
392 {
393 struct mmsys_cmdq_cmd cmd;
394 struct mdp_path *path = NULL;
395 struct mdp_cmdq_cb_param *cb_param = NULL;
396 struct mdp_comp *comps = NULL;
397 struct device *dev = &mdp->pdev->dev;
398 int i, ret;
399
400 if (atomic_read(&mdp->suspended))
401 return -ECANCELED;
402
403 atomic_inc(&mdp->job_count);
404
405 cmd.pkt = cmdq_pkt_create(mdp->cmdq_clt, SZ_16K);
406 if (IS_ERR(cmd.pkt)) {
407 atomic_dec(&mdp->job_count);
408 wake_up(&mdp->callback_wq);
409 return PTR_ERR(cmd.pkt);
410 }
411 cmd.event = &mdp->event[0];
412
413 path = kzalloc(sizeof(*path), GFP_KERNEL);
414 if (!path) {
415 ret = -ENOMEM;
416 goto err_destroy_pkt;
417 }
418
419 path->mdp_dev = mdp;
420 path->config = param->config;
421 path->param = param->param;
422 for (i = 0; i < param->param->num_outputs; i++) {
423 path->bounds[i].left = 0;
424 path->bounds[i].top = 0;
425 path->bounds[i].width =
426 param->param->outputs[i].buffer.format.width;
427 path->bounds[i].height =
428 param->param->outputs[i].buffer.format.height;
429 path->composes[i] = param->composes[i] ?
430 param->composes[i] : &path->bounds[i];
431 }
432
433 ret = mdp_path_ctx_init(mdp, path);
434 if (ret) {

 > 435			dev_err(dev, "%s mdp_path_ctx_init error\n");

436 goto err_destroy_pkt;
437 }
438
439 mtk_mutex_prepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]);
440 for (i = 0; i < param->config->num_components; i++)
441 mdp_comp_clock_on(&mdp->pdev->dev, path->comps[i].comp);
442
443 ret = mdp_path_config(mdp, &cmd, path);
444 if (ret) {
445 dev_err(dev, "%s mdp_path_config error\n");
446 goto err_destroy_pkt;
447 }
448
449 cb_param = kzalloc(sizeof(*cb_param), GFP_KERNEL);
450 if (!cb_param) {
451 ret = -ENOMEM;
452 goto err_destroy_pkt;
453 }
454
455 comps = kcalloc(param->config->num_components, sizeof(*comps),
456 GFP_KERNEL);
457 if (!comps) {
458 ret = -ENOMEM;
459 goto err_destroy_pkt;
460 }
461
462 for (i = 0; i < param->config->num_components; i++)
463 memcpy(&comps[i], path->comps[i].comp,
464 sizeof(struct mdp_comp));
465 cb_param->mdp = mdp;
466 cb_param->user_cmdq_cb = param->cmdq_cb;
467 cb_param->user_cb_data = param->cb_data;
468 cb_param->pkt = cmd.pkt;
469 cb_param->comps = comps;
470 cb_param->num_comps = param->config->num_components;
471 cb_param->mdp_ctx = param->mdp_ctx;
472
473 cmdq_pkt_finalize(cmd.pkt);
474 ret = cmdq_pkt_flush_async(cmd.pkt,
475 mdp_handle_cmdq_callback,
476 (void *)cb_param);
477 if (ret) {
478 dev_err(dev, "cmdq_pkt_flush_async fail!\n");
479 goto err_clock_off;
480 }
481 return 0;
482
483 err_clock_off:
484 mtk_mutex_unprepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]);
485 mdp_comp_clocks_off(&mdp->pdev->dev, cb_param->comps,
486 cb_param->num_comps);
487 err_destroy_pkt:
488 cmdq_pkt_destroy(cmd.pkt);
489 atomic_dec(&mdp->job_count);
490 wake_up(&mdp->callback_wq);
491 kfree(comps);
492 kfree(cb_param);
493 kfree(path);
494
495 return ret;
496 }
497

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

#14 lore raw
In reply to Moudy Ho

Il 01/12/21 10:50, Moudy Ho ha scritto:

Quoted 85 lines

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 9 lines

Moudy Ho (7):
soc: mediatek: mmsys: add support for MDP
soc: mediatek: mmsys: add support for ISP control
soc: mediatek: mutex: add support for MDP
soc: mediatek: mutex: add functions that operate registers by CMDQ
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,

I agree with your vision of mmsys and mutex patches being somewhat tied to the MDP3 driver being present but, still, can you please split this series?

The reason for this is that the four patches related to mmsys and mutex are ok, ready to be merged, and unlikely to get any other change during the development of the MDP3 driver specifically.
Like that, we could at least start getting all the required base support upstream and reduce the strain on you (and on reviewers) when releasing/rebasing any new version of this series; this will consequently help raising the quality of this work.

Regards,
- Angelo

#15 lore raw
In reply to Moudy Ho

Le 01/12/2021 à 10:50, Moudy Ho a écrit :

Quoted 75 lines

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
Quoted 8 lines

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.

Hi,

I think it would be good to add v4l2-compliance test result here.

Regards,
Benjamin

Quoted 64 lines

Moudy Ho (7):
soc: mediatek: mmsys: add support for MDP
soc: mediatek: mmsys: add support for ISP control
soc: mediatek: mutex: add support for MDP
soc: mediatek: mutex: add functions that operate registers by CMDQ
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-rsz.yaml     |   65 +
  .../bindings/media/mediatek,mdp3-wrot.yaml    |   67 +
  .../bindings/soc/mediatek/mediatek,ccorr.yaml |   57 +
  .../bindings/soc/mediatek/mediatek,rdma.yaml  |  216 +++
  .../bindings/soc/mediatek/mediatek,wdma.yaml  |   68 +
  arch/arm64/boot/dts/mediatek/mt8183.dtsi      |  115 +-
  drivers/media/platform/Kconfig                |   19 +
  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   |  514 +++++++
  .../media/platform/mtk-mdp3/mtk-mdp3-cmdq.h   |   46 +
  .../media/platform/mtk-mdp3/mtk-mdp3-comp.c   | 1264 +++++++++++++++++
  .../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 +
  drivers/soc/mediatek/Kconfig                  |    1 +
  drivers/soc/mediatek/mt8183-mmsys.h           |  294 ++++
  drivers/soc/mediatek/mtk-mmsys.c              |  173 +++
  drivers/soc/mediatek/mtk-mmsys.h              |    3 +
  drivers/soc/mediatek/mtk-mutex.c              |   98 +-
  include/linux/soc/mediatek/mtk-mmsys.h        |   86 ++
  include/linux/soc/mediatek/mtk-mutex.h        |    8 +
  35 files changed, 6530 insertions(+), 2 deletions(-)

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,rdma.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

Quoted 9 lines

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

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