Skip to contentSkip to conversation

drm/msm/dpu: fix blend setup for DMA4 and DMA5 layers

PATCH Applied Dmitry Baryshkov 2 participants 7 messages Jan 16, 2023 – Jan 18, 2023

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

PATCH 1/3 drm/msm/dpu: fix blend setup for DMA4 and DMA5 layers

SM8550 uses new register to map SSPP_DMA4 and SSPP_DMA5 units to blend stages. Add proper support for this register to allow using these two planes for image processing.

Fixes efcd0107727c ("drm/msm/dpu: add support for SM8550")
Cc Neil Armstrong <[email protected]>
---
 .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c    | 15 +++++++++------
 .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h    |  2 ++
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c    | 19 +++++++++++++++++++
 3 files changed, 30 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c +9 -6
index 835d6d2c4115..504a22c76412 100644
@@ -67,6 +67,9 @@
 #define CTL_SC7280_MASK \
 	(BIT(DPU_CTL_ACTIVE_CFG) | BIT(DPU_CTL_FETCH_ACTIVE) | BIT(DPU_CTL_VM_CFG))
 
+#define CTL_SM8550_MASK \
+	(CTL_SC7280_MASK | BIT(DPU_CTL_HAS_LAYER_EXT4))
+
 #define MERGE_3D_SM8150_MASK (0)
 
 #define DSPP_MSM8998_MASK BIT(DPU_DSPP_PCC) | BIT(DPU_DSPP_GC)
@@ -999,37 +1002,37 @@ static const struct dpu_ctl_cfg sm8550_ctl[] = {
 	{
 	.name = "ctl_0", .id = CTL_0,
 	.base = 0x15000, .len = 0x290,
-	.features = CTL_SC7280_MASK | BIT(DPU_CTL_SPLIT_DISPLAY),
+	.features = CTL_SM8550_MASK | BIT(DPU_CTL_SPLIT_DISPLAY),
 	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 9),
 	},
 	{
 	.name = "ctl_1", .id = CTL_1,
 	.base = 0x16000, .len = 0x290,
-	.features = CTL_SC7280_MASK | BIT(DPU_CTL_SPLIT_DISPLAY),
+	.features = CTL_SM8550_MASK | BIT(DPU_CTL_SPLIT_DISPLAY),
 	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 10),
 	},
 	{
 	.name = "ctl_2", .id = CTL_2,
 	.base = 0x17000, .len = 0x290,
-	.features = CTL_SC7280_MASK,
+	.features = CTL_SM8550_MASK,
 	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 11),
 	},
 	{
 	.name = "ctl_3", .id = CTL_3,
 	.base = 0x18000, .len = 0x290,
-	.features = CTL_SC7280_MASK,
+	.features = CTL_SM8550_MASK,
 	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 12),
 	},
 	{
 	.name = "ctl_4", .id = CTL_4,
 	.base = 0x19000, .len = 0x290,
-	.features = CTL_SC7280_MASK,
+	.features = CTL_SM8550_MASK,
 	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 13),
 	},
 	{
 	.name = "ctl_5", .id = CTL_5,
 	.base = 0x1a000, .len = 0x290,
-	.features = CTL_SC7280_MASK,
+	.features = CTL_SM8550_MASK,
 	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 23),
 	},
 };
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h +2 -0
index a1f18d53db6d..d152fef438f9 100644
@@ -199,6 +199,7 @@ enum {
  * @DPU_CTL_SPLIT_DISPLAY:	CTL supports video mode split display
  * @DPU_CTL_FETCH_ACTIVE:	Active CTL for fetch HW (SSPPs)
  * @DPU_CTL_VM_CFG:		CTL config to support multiple VMs
+ * @DPU_CTL_HAS_LAYER_EXT4:	CTL has the CTL_LAYER_EXT4 register
  * @DPU_CTL_MAX
  */
 enum {
@@ -206,6 +207,7 @@ enum {
 	DPU_CTL_ACTIVE_CFG,
 	DPU_CTL_FETCH_ACTIVE,
 	DPU_CTL_VM_CFG,
+	DPU_CTL_HAS_LAYER_EXT4,
 	DPU_CTL_MAX
 };
 
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +19 -0
index a35ecb6676c8..f4fdf537616c 100644
@@ -17,6 +17,8 @@
 	(0x70 + (((lm) - LM_0) * 0x004))
 #define   CTL_LAYER_EXT3(lm)             \
 	(0xA0 + (((lm) - LM_0) * 0x004))
+#define CTL_LAYER_EXT4(lm)             \
+        (0xB8 + (((lm) - LM_0) * 0x004))
 #define   CTL_TOP                       0x014
 #define   CTL_FLUSH                     0x018
 #define   CTL_START                     0x01C
@@ -383,6 +385,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 	struct dpu_hw_blk_reg_map *c = &ctx->hw;
 	u32 mixercfg = 0, mixercfg_ext = 0, mix, ext;
 	u32 mixercfg_ext2 = 0, mixercfg_ext3 = 0;
+	u32 mixercfg_ext4 = 0;
 	int i, j;
 	int stages;
 	int pipes_per_stage;
@@ -492,6 +495,20 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 					mixercfg_ext2 |= mix << 4;
 				}
 				break;
+			case SSPP_DMA4:
+				if (rect_index == DPU_SSPP_RECT_1) {
+					mixercfg_ext4 |= ((i + 1) & 0xF) << 8;
+				} else {
+					mixercfg_ext4 |= ((i + 1) & 0xF) << 0;
+				}
+				break;
+			case SSPP_DMA5:
+				if (rect_index == DPU_SSPP_RECT_1) {
+					mixercfg_ext4 |= ((i + 1) & 0xF) << 12;
+				} else {
+					mixercfg_ext4 |= ((i + 1) & 0xF) << 4;
+				}
+				break;
 			case SSPP_CURSOR0:
 				mixercfg_ext |= ((i + 1) & 0xF) << 20;
 				break;
@@ -509,6 +526,8 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 	DPU_REG_WRITE(c, CTL_LAYER_EXT(lm), mixercfg_ext);
 	DPU_REG_WRITE(c, CTL_LAYER_EXT2(lm), mixercfg_ext2);
 	DPU_REG_WRITE(c, CTL_LAYER_EXT3(lm), mixercfg_ext3);
+	if ((test_bit(DPU_CTL_HAS_LAYER_EXT4, &ctx->caps->features)))
+		DPU_REG_WRITE(c, CTL_LAYER_EXT4(lm), mixercfg_ext4);
 }
 
 
Signature · 1 line
2.39.0
#1 lore raw

PATCH 2/3 drm/msm/dpu: simplify ctl_setup_blendstage calculation

Extract the common expression in the dpu_hw_ctl_setup_blendstage() function.

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 38 +++++++++++-----------
 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +19 -19
index f4fdf537616c..4d70dcd46c9d 100644
@@ -383,7 +383,8 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 	enum dpu_lm lm, struct dpu_hw_stage_cfg *stage_cfg)
 {
 	struct dpu_hw_blk_reg_map *c = &ctx->hw;
-	u32 mixercfg = 0, mixercfg_ext = 0, mix, ext;
+	u32 mix, ext, mix_ext;
+	u32 mixercfg = 0, mixercfg_ext = 0;
 	u32 mixercfg_ext2 = 0, mixercfg_ext3 = 0;
 	u32 mixercfg_ext4 = 0;
 	int i, j;
@@ -409,6 +410,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 		/* overflow to ext register if 'i + 1 > 7' */
 		mix = (i + 1) & 0x7;
 		ext = i >= 7;
+		mix_ext = (i + 1) & 0xf;
 
 		for (j = 0 ; j < pipes_per_stage; j++) {
 			enum dpu_sspp_multirect_index rect_index =
@@ -417,7 +419,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 			switch (stage_cfg->stage[i][j]) {
 			case SSPP_VIG0:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= ((i + 1) & 0xF) << 0;
+					mixercfg_ext3 |= mix_ext << 0;
 				} else {
 					mixercfg |= mix << 0;
 					mixercfg_ext |= ext << 0;
@@ -425,7 +427,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 				break;
 			case SSPP_VIG1:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= ((i + 1) & 0xF) << 4;
+					mixercfg_ext3 |= mix_ext << 4;
 				} else {
 					mixercfg |= mix << 3;
 					mixercfg_ext |= ext << 2;
@@ -433,7 +435,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 				break;
 			case SSPP_VIG2:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= ((i + 1) & 0xF) << 8;
+					mixercfg_ext3 |= mix_ext << 8;
 				} else {
 					mixercfg |= mix << 6;
 					mixercfg_ext |= ext << 4;
@@ -441,7 +443,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 				break;
 			case SSPP_VIG3:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= ((i + 1) & 0xF) << 12;
+					mixercfg_ext3 |= mix_ext << 12;
 				} else {
 					mixercfg |= mix << 26;
 					mixercfg_ext |= ext << 6;
@@ -465,7 +467,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 				break;
 			case SSPP_DMA0:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= ((i + 1) & 0xF) << 8;
+					mixercfg_ext2 |= mix_ext << 8;
 				} else {
 					mixercfg |= mix << 18;
 					mixercfg_ext |= ext << 16;
@@ -473,7 +475,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 				break;
 			case SSPP_DMA1:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= ((i + 1) & 0xF) << 12;
+					mixercfg_ext2 |= mix_ext << 12;
 				} else {
 					mixercfg |= mix << 21;
 					mixercfg_ext |= ext << 18;
@@ -481,39 +483,37 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 				break;
 			case SSPP_DMA2:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= ((i + 1) & 0xF) << 16;
+					mixercfg_ext2 |= mix_ext << 16;
 				} else {
-					mix |= (i + 1) & 0xF;
-					mixercfg_ext2 |= mix << 0;
+					mixercfg_ext2 |= mix_ext << 0;
 				}
 				break;
 			case SSPP_DMA3:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= ((i + 1) & 0xF) << 20;
+					mixercfg_ext2 |= mix_ext << 20;
 				} else {
-					mix |= (i + 1) & 0xF;
-					mixercfg_ext2 |= mix << 4;
+					mixercfg_ext2 |= mix_ext << 4;
 				}
 				break;
 			case SSPP_DMA4:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext4 |= ((i + 1) & 0xF) << 8;
+					mixercfg_ext4 |= mix_ext << 8;
 				} else {
-					mixercfg_ext4 |= ((i + 1) & 0xF) << 0;
+					mixercfg_ext4 |= mix_ext << 0;
 				}
 				break;
 			case SSPP_DMA5:
 				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext4 |= ((i + 1) & 0xF) << 12;
+					mixercfg_ext4 |= mix_ext << 12;
 				} else {
-					mixercfg_ext4 |= ((i + 1) & 0xF) << 4;
+					mixercfg_ext4 |= mix_ext << 4;
 				}
 				break;
 			case SSPP_CURSOR0:
-				mixercfg_ext |= ((i + 1) & 0xF) << 20;
+				mixercfg_ext |= mix_ext << 20;
 				break;
 			case SSPP_CURSOR1:
-				mixercfg_ext |= ((i + 1) & 0xF) << 26;
+				mixercfg_ext |= mix_ext << 26;
 				break;
 			default:
 				break;
Signature · 1 line
2.39.0
Reviewed-by Tested-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] drm/msm/dpu: simplify ctl_setup_blendstage calculation

Quoted 124 lines · Dmitry Baryshkov

Extract the common expression in the dpu_hw_ctl_setup_blendstage() function.

---
  drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 38 +++++++++++-----------
  1 file changed, 19 insertions(+), 19 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +17 -17
index f4fdf537616c..4d70dcd46c9d 100644
@@ -383,7 +383,8 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  	enum dpu_lm lm, struct dpu_hw_stage_cfg *stage_cfg)
  {
  	struct dpu_hw_blk_reg_map *c = &ctx->hw;
-	u32 mixercfg = 0, mixercfg_ext = 0, mix, ext;
+	u32 mix, ext, mix_ext;
+	u32 mixercfg = 0, mixercfg_ext = 0;
  	u32 mixercfg_ext2 = 0, mixercfg_ext3 = 0;
  	u32 mixercfg_ext4 = 0;
  	int i, j;
@@ -409,6 +410,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  		/* overflow to ext register if 'i + 1 > 7' */
  		mix = (i + 1) & 0x7;
  		ext = i >= 7;
+		mix_ext = (i + 1) & 0xf;
 
  		for (j = 0 ; j < pipes_per_stage; j++) {
  			enum dpu_sspp_multirect_index rect_index =
@@ -417,7 +419,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  			switch (stage_cfg->stage[i][j]) {
  			case SSPP_VIG0:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= ((i + 1) & 0xF) << 0;
+					mixercfg_ext3 |= mix_ext << 0;
  				} else {
  					mixercfg |= mix << 0;
  					mixercfg_ext |= ext << 0;
@@ -425,7 +427,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  				break;
  			case SSPP_VIG1:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= ((i + 1) & 0xF) << 4;
+					mixercfg_ext3 |= mix_ext << 4;
  				} else {
  					mixercfg |= mix << 3;
  					mixercfg_ext |= ext << 2;
@@ -433,7 +435,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  				break;
  			case SSPP_VIG2:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= ((i + 1) & 0xF) << 8;
+					mixercfg_ext3 |= mix_ext << 8;
  				} else {
  					mixercfg |= mix << 6;
  					mixercfg_ext |= ext << 4;
@@ -441,7 +443,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  				break;
  			case SSPP_VIG3:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= ((i + 1) & 0xF) << 12;
+					mixercfg_ext3 |= mix_ext << 12;
  				} else {
  					mixercfg |= mix << 26;
  					mixercfg_ext |= ext << 6;
@@ -465,7 +467,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  				break;
  			case SSPP_DMA0:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= ((i + 1) & 0xF) << 8;
+					mixercfg_ext2 |= mix_ext << 8;
  				} else {
  					mixercfg |= mix << 18;
  					mixercfg_ext |= ext << 16;
@@ -473,7 +475,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  				break;
  			case SSPP_DMA1:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= ((i + 1) & 0xF) << 12;
+					mixercfg_ext2 |= mix_ext << 12;
  				} else {
  					mixercfg |= mix << 21;
  					mixercfg_ext |= ext << 18;
@@ -481,39 +483,37 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  				break;
  			case SSPP_DMA2:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= ((i + 1) & 0xF) << 16;
+					mixercfg_ext2 |= mix_ext << 16;
  				} else {
-					mix |= (i + 1) & 0xF;
-					mixercfg_ext2 |= mix << 0;
+					mixercfg_ext2 |= mix_ext << 0;
  				}
  				break;
  			case SSPP_DMA3:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= ((i + 1) & 0xF) << 20;
+					mixercfg_ext2 |= mix_ext << 20;
  				} else {
-					mix |= (i + 1) & 0xF;
-					mixercfg_ext2 |= mix << 4;
+					mixercfg_ext2 |= mix_ext << 4;
  				}
  				break;
  			case SSPP_DMA4:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext4 |= ((i + 1) & 0xF) << 8;
+					mixercfg_ext4 |= mix_ext << 8;
  				} else {
-					mixercfg_ext4 |= ((i + 1) & 0xF) << 0;
+					mixercfg_ext4 |= mix_ext << 0;
  				}
  				break;
  			case SSPP_DMA5:
  				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext4 |= ((i + 1) & 0xF) << 12;
+					mixercfg_ext4 |= mix_ext << 12;
  				} else {
-					mixercfg_ext4 |= ((i + 1) & 0xF) << 4;
+					mixercfg_ext4 |= mix_ext << 4;
  				}
  				break;

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx, · line 519

Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +2 -2
  			case SSPP_CURSOR0:
-				mixercfg_ext |= ((i + 1) & 0xF) << 20;
+				mixercfg_ext |= mix_ext << 20;
  				break;
  			case SSPP_CURSOR1:
-				mixercfg_ext |= ((i + 1) & 0xF) << 26;
+				mixercfg_ext |= mix_ext << 26;
  				break;
  			default:
  				break;
#3 lore raw

PATCH 3/3 drm/msm/dpu: simplify blend configuration

In reply to Dmitry Baryshkov

Rewrite dpu_hw_ctl_setup_blendstage() to use static data configuration rather than using a switch-case. This simplifies adding support for new pipes.

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 156 ++++++---------------
 1 file changed, 45 insertions(+), 111 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +45 -111
index 4d70dcd46c9d..f3c15b5a2099 100644
@@ -379,14 +379,37 @@ static void dpu_hw_ctl_clear_all_blendstages(struct dpu_hw_ctl *ctx)
 	DPU_REG_WRITE(c, CTL_FETCH_PIPE_ACTIVE, 0);
 }
 
+struct ctl_blend_config {
+	int idx, shift, ext_shift;
+};
+
+static const struct ctl_blend_config ctl_blend_config[][2] = {
+	[SSPP_NONE] = { { -1 }, { -1 } },
+	[SSPP_MAX] =  { { -1 }, { -1 } },
+	[SSPP_VIG0] = { { 0, 0,  0  }, { 3, 0 } },
+	[SSPP_VIG1] = { { 0, 3,  2  }, { 3, 4 } },
+	[SSPP_VIG2] = { { 0, 6,  4  }, { 3, 8 } },
+	[SSPP_VIG3] = { { 0, 26, 6  }, { 3, 12 } },
+	[SSPP_RGB0] = { { 0, 9,  8  }, { -1 } },
+	[SSPP_RGB1] = { { 0, 12, 10 }, { -1 } },
+	[SSPP_RGB2] = { { 0, 15, 12 }, { -1 } },
+	[SSPP_RGB3] = { { 0, 29, 14 }, { -1 } },
+	[SSPP_DMA0] = { { 0, 18, 16 }, { 2, 8 } },
+	[SSPP_DMA1] = { { 0, 21, 18 }, { 2, 12 } },
+	[SSPP_DMA2] = { { 2, 0      }, { 2, 16 } },
+	[SSPP_DMA3] = { { 2, 4      }, { 2, 20 } },
+	[SSPP_DMA4] = { { 4, 0      }, { 4, 8 } },
+	[SSPP_DMA5] = { { 4, 4      }, { 4, 12 } },
+	[SSPP_CURSOR0] =  { { 1, 20 }, { -1 } },
+	[SSPP_CURSOR1] =  { { 1, 26 }, { -1 } },
+};
+
 static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 	enum dpu_lm lm, struct dpu_hw_stage_cfg *stage_cfg)
 {
 	struct dpu_hw_blk_reg_map *c = &ctx->hw;
 	u32 mix, ext, mix_ext;
-	u32 mixercfg = 0, mixercfg_ext = 0;
-	u32 mixercfg_ext2 = 0, mixercfg_ext3 = 0;
-	u32 mixercfg_ext4 = 0;
+	u32 mixercfg[5] = { 0 };
 	int i, j;
 	int stages;
 	int pipes_per_stage;
@@ -401,7 +424,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 	else
 		pipes_per_stage = 1;
 
-	mixercfg = CTL_MIXER_BORDER_OUT; /* always set BORDER_OUT */
+	mixercfg[0] = CTL_MIXER_BORDER_OUT; /* always set BORDER_OUT */
 
 	if (!stage_cfg)
 		goto exit;
@@ -415,119 +438,30 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
 		for (j = 0 ; j < pipes_per_stage; j++) {
 			enum dpu_sspp_multirect_index rect_index =
 				stage_cfg->multirect_index[i][j];
-
-			switch (stage_cfg->stage[i][j]) {
-			case SSPP_VIG0:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= mix_ext << 0;
-				} else {
-					mixercfg |= mix << 0;
-					mixercfg_ext |= ext << 0;
-				}
-				break;
-			case SSPP_VIG1:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= mix_ext << 4;
-				} else {
-					mixercfg |= mix << 3;
-					mixercfg_ext |= ext << 2;
-				}
-				break;
-			case SSPP_VIG2:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= mix_ext << 8;
-				} else {
-					mixercfg |= mix << 6;
-					mixercfg_ext |= ext << 4;
-				}
-				break;
-			case SSPP_VIG3:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= mix_ext << 12;
-				} else {
-					mixercfg |= mix << 26;
-					mixercfg_ext |= ext << 6;
-				}
-				break;
-			case SSPP_RGB0:
-				mixercfg |= mix << 9;
-				mixercfg_ext |= ext << 8;
-				break;
-			case SSPP_RGB1:
-				mixercfg |= mix << 12;
-				mixercfg_ext |= ext << 10;
-				break;
-			case SSPP_RGB2:
-				mixercfg |= mix << 15;
-				mixercfg_ext |= ext << 12;
-				break;
-			case SSPP_RGB3:
-				mixercfg |= mix << 29;
-				mixercfg_ext |= ext << 14;
-				break;
-			case SSPP_DMA0:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= mix_ext << 8;
-				} else {
-					mixercfg |= mix << 18;
-					mixercfg_ext |= ext << 16;
-				}
-				break;
-			case SSPP_DMA1:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= mix_ext << 12;
-				} else {
-					mixercfg |= mix << 21;
-					mixercfg_ext |= ext << 18;
-				}
-				break;
-			case SSPP_DMA2:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= mix_ext << 16;
-				} else {
-					mixercfg_ext2 |= mix_ext << 0;
-				}
-				break;
-			case SSPP_DMA3:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= mix_ext << 20;
-				} else {
-					mixercfg_ext2 |= mix_ext << 4;
-				}
-				break;
-			case SSPP_DMA4:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext4 |= mix_ext << 8;
-				} else {
-					mixercfg_ext4 |= mix_ext << 0;
-				}
-				break;
-			case SSPP_DMA5:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext4 |= mix_ext << 12;
-				} else {
-					mixercfg_ext4 |= mix_ext << 4;
-				}
-				break;
-			case SSPP_CURSOR0:
-				mixercfg_ext |= mix_ext << 20;
-				break;
-			case SSPP_CURSOR1:
-				mixercfg_ext |= mix_ext << 26;
-				break;
-			default:
-				break;
+			enum dpu_sspp pipe = stage_cfg->stage[i][j];
+			const struct ctl_blend_config *cfg =
+				&ctl_blend_config[pipe][rect_index == DPU_SSPP_RECT_1];
+
+			/*
+			 * CTL_LAYER has 3-bit field (and extra bits in EXT register),
+			 * all EXT registers has 4-bit fields.
+			 */
+			if (cfg->idx == 0) {
+				mixercfg[0] |= mix << cfg->shift;
+				mixercfg[1] |= ext << cfg->ext_shift;
+			} else {
+				mixercfg[cfg->idx] |= mix_ext << cfg->shift;
 			}
 		}
 	}
 
 exit:
-	DPU_REG_WRITE(c, CTL_LAYER(lm), mixercfg);
-	DPU_REG_WRITE(c, CTL_LAYER_EXT(lm), mixercfg_ext);
-	DPU_REG_WRITE(c, CTL_LAYER_EXT2(lm), mixercfg_ext2);
-	DPU_REG_WRITE(c, CTL_LAYER_EXT3(lm), mixercfg_ext3);
+	DPU_REG_WRITE(c, CTL_LAYER(lm), mixercfg[0]);
+	DPU_REG_WRITE(c, CTL_LAYER_EXT(lm), mixercfg[1]);
+	DPU_REG_WRITE(c, CTL_LAYER_EXT2(lm), mixercfg[2]);
+	DPU_REG_WRITE(c, CTL_LAYER_EXT3(lm), mixercfg[3]);
 	if ((test_bit(DPU_CTL_HAS_LAYER_EXT4, &ctx->caps->features)))
-		DPU_REG_WRITE(c, CTL_LAYER_EXT4(lm), mixercfg_ext4);
+		DPU_REG_WRITE(c, CTL_LAYER_EXT4(lm), mixercfg[4]);
 }
 
 
Signature · 1 line
2.39.0
Reviewed-by Tested-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] drm/msm/dpu: simplify blend configuration

Quoted 191 lines · Dmitry Baryshkov

Rewrite dpu_hw_ctl_setup_blendstage() to use static data configuration rather than using a switch-case. This simplifies adding support for new pipes.

---
  drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 156 ++++++---------------
  1 file changed, 45 insertions(+), 111 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +40 -110
index 4d70dcd46c9d..f3c15b5a2099 100644
@@ -379,14 +379,37 @@ static void dpu_hw_ctl_clear_all_blendstages(struct dpu_hw_ctl *ctx)
  	DPU_REG_WRITE(c, CTL_FETCH_PIPE_ACTIVE, 0);
  }
 
+struct ctl_blend_config {
+	int idx, shift, ext_shift;
+};
+
+static const struct ctl_blend_config ctl_blend_config[][2] = {
+	[SSPP_NONE] = { { -1 }, { -1 } },
+	[SSPP_MAX] =  { { -1 }, { -1 } },
+	[SSPP_VIG0] = { { 0, 0,  0  }, { 3, 0 } },
+	[SSPP_VIG1] = { { 0, 3,  2  }, { 3, 4 } },
+	[SSPP_VIG2] = { { 0, 6,  4  }, { 3, 8 } },
+	[SSPP_VIG3] = { { 0, 26, 6  }, { 3, 12 } },
+	[SSPP_RGB0] = { { 0, 9,  8  }, { -1 } },
+	[SSPP_RGB1] = { { 0, 12, 10 }, { -1 } },
+	[SSPP_RGB2] = { { 0, 15, 12 }, { -1 } },
+	[SSPP_RGB3] = { { 0, 29, 14 }, { -1 } },
+	[SSPP_DMA0] = { { 0, 18, 16 }, { 2, 8 } },
+	[SSPP_DMA1] = { { 0, 21, 18 }, { 2, 12 } },
+	[SSPP_DMA2] = { { 2, 0      }, { 2, 16 } },
+	[SSPP_DMA3] = { { 2, 4      }, { 2, 20 } },
+	[SSPP_DMA4] = { { 4, 0      }, { 4, 8 } },
+	[SSPP_DMA5] = { { 4, 4      }, { 4, 12 } },
+	[SSPP_CURSOR0] =  { { 1, 20 }, { -1 } },
+	[SSPP_CURSOR1] =  { { 1, 26 }, { -1 } },
+};
+
  static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  	enum dpu_lm lm, struct dpu_hw_stage_cfg *stage_cfg)
  {
  	struct dpu_hw_blk_reg_map *c = &ctx->hw;
  	u32 mix, ext, mix_ext;
-	u32 mixercfg = 0, mixercfg_ext = 0;
-	u32 mixercfg_ext2 = 0, mixercfg_ext3 = 0;
-	u32 mixercfg_ext4 = 0;
+	u32 mixercfg[5] = { 0 };
  	int i, j;
  	int stages;
  	int pipes_per_stage;
@@ -401,7 +424,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  	else
  		pipes_per_stage = 1;
 
-	mixercfg = CTL_MIXER_BORDER_OUT; /* always set BORDER_OUT */
+	mixercfg[0] = CTL_MIXER_BORDER_OUT; /* always set BORDER_OUT */
 
  	if (!stage_cfg)
  		goto exit;
@@ -415,119 +438,30 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  		for (j = 0 ; j < pipes_per_stage; j++) {
  			enum dpu_sspp_multirect_index rect_index =
  				stage_cfg->multirect_index[i][j];
-
-			switch (stage_cfg->stage[i][j]) {
-			case SSPP_VIG0:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= mix_ext << 0;
-				} else {
-					mixercfg |= mix << 0;
-					mixercfg_ext |= ext << 0;
-				}
-				break;
-			case SSPP_VIG1:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= mix_ext << 4;
-				} else {
-					mixercfg |= mix << 3;
-					mixercfg_ext |= ext << 2;
-				}
-				break;
-			case SSPP_VIG2:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= mix_ext << 8;
-				} else {
-					mixercfg |= mix << 6;
-					mixercfg_ext |= ext << 4;
-				}
-				break;
-			case SSPP_VIG3:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext3 |= mix_ext << 12;
-				} else {
-					mixercfg |= mix << 26;
-					mixercfg_ext |= ext << 6;
-				}
-				break;
-			case SSPP_RGB0:
-				mixercfg |= mix << 9;
-				mixercfg_ext |= ext << 8;
-				break;
-			case SSPP_RGB1:
-				mixercfg |= mix << 12;
-				mixercfg_ext |= ext << 10;
-				break;
-			case SSPP_RGB2:
-				mixercfg |= mix << 15;
-				mixercfg_ext |= ext << 12;
-				break;
-			case SSPP_RGB3:
-				mixercfg |= mix << 29;
-				mixercfg_ext |= ext << 14;
-				break;
-			case SSPP_DMA0:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= mix_ext << 8;
-				} else {
-					mixercfg |= mix << 18;
-					mixercfg_ext |= ext << 16;
-				}
-				break;
-			case SSPP_DMA1:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= mix_ext << 12;
-				} else {
-					mixercfg |= mix << 21;
-					mixercfg_ext |= ext << 18;
-				}
-				break;
-			case SSPP_DMA2:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= mix_ext << 16;
-				} else {
-					mixercfg_ext2 |= mix_ext << 0;
-				}
-				break;
-			case SSPP_DMA3:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext2 |= mix_ext << 20;
-				} else {
-					mixercfg_ext2 |= mix_ext << 4;
-				}
-				break;
-			case SSPP_DMA4:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext4 |= mix_ext << 8;
-				} else {
-					mixercfg_ext4 |= mix_ext << 0;
-				}
-				break;
-			case SSPP_DMA5:
-				if (rect_index == DPU_SSPP_RECT_1) {
-					mixercfg_ext4 |= mix_ext << 12;
-				} else {
-					mixercfg_ext4 |= mix_ext << 4;
-				}
-				break;
-			case SSPP_CURSOR0:
-				mixercfg_ext |= mix_ext << 20;
-				break;
-			case SSPP_CURSOR1:
-				mixercfg_ext |= mix_ext << 26;
-				break;
-			default:
-				break;
+			enum dpu_sspp pipe = stage_cfg->stage[i][j];
+			const struct ctl_blend_config *cfg =
+				&ctl_blend_config[pipe][rect_index == DPU_SSPP_RECT_1];
+
+			/*
+			 * CTL_LAYER has 3-bit field (and extra bits in EXT register),
+			 * all EXT registers has 4-bit fields.
+			 */
+			if (cfg->idx == 0) {
+				mixercfg[0] |= mix << cfg->shift;
+				mixercfg[1] |= ext << cfg->ext_shift;
+			} else {
+				mixercfg[cfg->idx] |= mix_ext << cfg->shift;
  			}
  		}
  	}
 
  exit:
-	DPU_REG_WRITE(c, CTL_LAYER(lm), mixercfg);
-	DPU_REG_WRITE(c, CTL_LAYER_EXT(lm), mixercfg_ext);
-	DPU_REG_WRITE(c, CTL_LAYER_EXT2(lm), mixercfg_ext2);
-	DPU_REG_WRITE(c, CTL_LAYER_EXT3(lm), mixercfg_ext3);

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx, · line 467

Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +5 -1
+	DPU_REG_WRITE(c, CTL_LAYER(lm), mixercfg[0]);
+	DPU_REG_WRITE(c, CTL_LAYER_EXT(lm), mixercfg[1]);
+	DPU_REG_WRITE(c, CTL_LAYER_EXT2(lm), mixercfg[2]);
+	DPU_REG_WRITE(c, CTL_LAYER_EXT3(lm), mixercfg[3]);
  	if ((test_bit(DPU_CTL_HAS_LAYER_EXT4, &ctx->caps->features)))
-		DPU_REG_WRITE(c, CTL_LAYER_EXT4(lm), mixercfg_ext4);
+		DPU_REG_WRITE(c, CTL_LAYER_EXT4(lm), mixercfg[4]);
  }
 
 
Reviewed-by Tested-by on v1 1/3
#5 lore raw
In reply to Dmitry Baryshkov
Quoted 134 lines · Dmitry Baryshkov

SM8550 uses new register to map SSPP_DMA4 and SSPP_DMA5 units to blend stages. Add proper support for this register to allow using these two planes for image processing.

Fixes efcd0107727c ("drm/msm/dpu: add support for SM8550")
Cc Neil Armstrong <[email protected]>
---
  .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c    | 15 +++++++++------
  .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h    |  2 ++
  drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c    | 19 +++++++++++++++++++
  3 files changed, 30 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c +9 -6
index 835d6d2c4115..504a22c76412 100644
@@ -67,6 +67,9 @@
  #define CTL_SC7280_MASK \
  	(BIT(DPU_CTL_ACTIVE_CFG) | BIT(DPU_CTL_FETCH_ACTIVE) | BIT(DPU_CTL_VM_CFG))
 
+#define CTL_SM8550_MASK \
+	(CTL_SC7280_MASK | BIT(DPU_CTL_HAS_LAYER_EXT4))
+
  #define MERGE_3D_SM8150_MASK (0)
 
  #define DSPP_MSM8998_MASK BIT(DPU_DSPP_PCC) | BIT(DPU_DSPP_GC)
@@ -999,37 +1002,37 @@ static const struct dpu_ctl_cfg sm8550_ctl[] = {
  	{
  	.name = "ctl_0", .id = CTL_0,
  	.base = 0x15000, .len = 0x290,
-	.features = CTL_SC7280_MASK | BIT(DPU_CTL_SPLIT_DISPLAY),
+	.features = CTL_SM8550_MASK | BIT(DPU_CTL_SPLIT_DISPLAY),
  	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 9),
  	},
  	{
  	.name = "ctl_1", .id = CTL_1,
  	.base = 0x16000, .len = 0x290,
-	.features = CTL_SC7280_MASK | BIT(DPU_CTL_SPLIT_DISPLAY),
+	.features = CTL_SM8550_MASK | BIT(DPU_CTL_SPLIT_DISPLAY),
  	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 10),
  	},
  	{
  	.name = "ctl_2", .id = CTL_2,
  	.base = 0x17000, .len = 0x290,
-	.features = CTL_SC7280_MASK,
+	.features = CTL_SM8550_MASK,
  	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 11),
  	},
  	{
  	.name = "ctl_3", .id = CTL_3,
  	.base = 0x18000, .len = 0x290,
-	.features = CTL_SC7280_MASK,
+	.features = CTL_SM8550_MASK,
  	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 12),
  	},
  	{
  	.name = "ctl_4", .id = CTL_4,
  	.base = 0x19000, .len = 0x290,
-	.features = CTL_SC7280_MASK,
+	.features = CTL_SM8550_MASK,
  	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 13),
  	},
  	{
  	.name = "ctl_5", .id = CTL_5,
  	.base = 0x1a000, .len = 0x290,
-	.features = CTL_SC7280_MASK,
+	.features = CTL_SM8550_MASK,
  	.intr_start = DPU_IRQ_IDX(MDP_SSPP_TOP0_INTR2, 23),
  	},
  };
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h +2 -0
index a1f18d53db6d..d152fef438f9 100644
@@ -199,6 +199,7 @@ enum {
   * @DPU_CTL_SPLIT_DISPLAY:	CTL supports video mode split display
   * @DPU_CTL_FETCH_ACTIVE:	Active CTL for fetch HW (SSPPs)
   * @DPU_CTL_VM_CFG:		CTL config to support multiple VMs
+ * @DPU_CTL_HAS_LAYER_EXT4:	CTL has the CTL_LAYER_EXT4 register
   * @DPU_CTL_MAX
   */
  enum {
@@ -206,6 +207,7 @@ enum {
  	DPU_CTL_ACTIVE_CFG,
  	DPU_CTL_FETCH_ACTIVE,
  	DPU_CTL_VM_CFG,
+	DPU_CTL_HAS_LAYER_EXT4,
  	DPU_CTL_MAX
  };
 
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +17 -0
index a35ecb6676c8..f4fdf537616c 100644
@@ -17,6 +17,8 @@
  	(0x70 + (((lm) - LM_0) * 0x004))
  #define   CTL_LAYER_EXT3(lm)             \
  	(0xA0 + (((lm) - LM_0) * 0x004))
+#define CTL_LAYER_EXT4(lm)             \
+        (0xB8 + (((lm) - LM_0) * 0x004))
  #define   CTL_TOP                       0x014
  #define   CTL_FLUSH                     0x018
  #define   CTL_START                     0x01C
@@ -383,6 +385,7 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  	struct dpu_hw_blk_reg_map *c = &ctx->hw;
  	u32 mixercfg = 0, mixercfg_ext = 0, mix, ext;
  	u32 mixercfg_ext2 = 0, mixercfg_ext3 = 0;
+	u32 mixercfg_ext4 = 0;
  	int i, j;
  	int stages;
  	int pipes_per_stage;
@@ -492,6 +495,20 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  					mixercfg_ext2 |= mix << 4;
  				}
  				break;
+			case SSPP_DMA4:
+				if (rect_index == DPU_SSPP_RECT_1) {
+					mixercfg_ext4 |= ((i + 1) & 0xF) << 8;
+				} else {
+					mixercfg_ext4 |= ((i + 1) & 0xF) << 0;
+				}
+				break;
+			case SSPP_DMA5:
+				if (rect_index == DPU_SSPP_RECT_1) {
+					mixercfg_ext4 |= ((i + 1) & 0xF) << 12;
+				} else {
+					mixercfg_ext4 |= ((i + 1) & 0xF) << 4;
+				}
+				break;
  			case SSPP_CURSOR0:
  				mixercfg_ext |= ((i + 1) & 0xF) << 20;
  				break;

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx, · line 533

Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +2 -0
@@ -509,6 +526,8 @@ static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
  	DPU_REG_WRITE(c, CTL_LAYER_EXT(lm), mixercfg_ext);
  	DPU_REG_WRITE(c, CTL_LAYER_EXT2(lm), mixercfg_ext2);
  	DPU_REG_WRITE(c, CTL_LAYER_EXT3(lm), mixercfg_ext3);
+	if ((test_bit(DPU_CTL_HAS_LAYER_EXT4, &ctx->caps->features)))
+		DPU_REG_WRITE(c, CTL_LAYER_EXT4(lm), mixercfg_ext4);
  }
 
 
author Applied
#6 lore raw
In reply to Dmitry Baryshkov
Quoted 5 lines · Dmitry Baryshkov

SM8550 uses new register to map SSPP_DMA4 and SSPP_DMA5 units to blend stages. Add proper support for this register to allow using these two planes for image processing.

Applied, thanks!

[1/3] drm/msm/dpu: fix blend setup for DMA4 and DMA5 layers

      https://gitlab.freedesktop.org/lumag/msm/-/commit/80ca10dc64ff
[2/3] drm/msm/dpu: simplify ctl_setup_blendstage calculation
      https://gitlab.freedesktop.org/lumag/msm/-/commit/644eddf9f166
[3/3] drm/msm/dpu: simplify blend configuration
      https://gitlab.freedesktop.org/lumag/msm/-/commit/63e3386b86d7

Best regards,

Signature · 1 line
Dmitry Baryshkov <[email protected]>