Skip to contentSkip to conversation

drm/msm/dpu: fix/enable 6bpc dither with split-lm

PATCH In review Rob Clark 3 participants 5 messages Jul 15, 2020 – Jul 21, 2020

Subsystems (3)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm/msm/dpu: fix/enable 6bpc dither with split-lm

From: Rob Clark <[email protected]>

If split-lm is used (for ex, on sdm845), we can have multiple ping- pongs, but only a single phys encoder. We need to configure dithering on each of them.

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c   | 22 ++++++++++---------
 .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c   |  3 +--
 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +12 -10
index 46df0ff75b85..9b98b63c77fb 100644
@@ -212,14 +212,14 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
 	15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
 };
 
-static void _dpu_encoder_setup_dither(struct dpu_encoder_phys *phys)
+static void _dpu_encoder_setup_dither(struct dpu_hw_pingpong *hw_pp, unsigned bpc)
 {
 	struct dpu_hw_dither_cfg dither_cfg = { 0 };
 
-	if (!phys->hw_pp || !phys->hw_pp->ops.setup_dither)
+	if (!hw_pp->ops.setup_dither)
 		return;
 
-	switch (phys->connector->display_info.bpc) {
+	switch (bpc) {
 	case 6:
 		dither_cfg.c0_bitdepth = 6;
 		dither_cfg.c1_bitdepth = 6;
@@ -228,14 +228,14 @@ static void _dpu_encoder_setup_dither(struct dpu_encoder_phys *phys)
 		dither_cfg.temporal_en = 0;
 		break;
 	default:
-		phys->hw_pp->ops.setup_dither(phys->hw_pp, NULL);
+		hw_pp->ops.setup_dither(hw_pp, NULL);
 		return;
 	}
 
 	memcpy(&dither_cfg.matrix, dither_matrix,
 			sizeof(u32) * DITHER_MATRIX_SZ);
 
-	phys->hw_pp->ops.setup_dither(phys->hw_pp, &dither_cfg);
+	hw_pp->ops.setup_dither(hw_pp, &dither_cfg);
 }
 
 void dpu_encoder_helper_report_irq_timeout(struct dpu_encoder_phys *phys_enc,
@@ -1132,11 +1132,13 @@ static void _dpu_encoder_virt_enable_helper(struct drm_encoder *drm_enc)
 
 	_dpu_encoder_update_vsync_source(dpu_enc, &dpu_enc->disp_info);
 
-	if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) {
-		for (i = 0; i < dpu_enc->num_phys_encs; i++) {
-			struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
-
-			_dpu_encoder_setup_dither(phys);
+	if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI &&
+			!WARN_ON(dpu_enc->num_phys_encs == 0)) {
+		unsigned bpc = dpu_enc->phys_encs[0]->connector->display_info.bpc;
+		for (i = 0; i < MAX_CHANNELS_PER_ENC; i++) {
+			if (!dpu_enc->hw_pp[i])
+				continue;
+			_dpu_encoder_setup_dither(dpu_enc->hw_pp[i], bpc);
 		}
 	}
 }
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +1 -2
index 7411ab6bf6af..bea4ab5c58c5 100644
@@ -231,8 +231,7 @@ static void _setup_pingpong_ops(struct dpu_hw_pingpong *c,
 	c->ops.poll_timeout_wr_ptr = dpu_hw_pp_poll_timeout_wr_ptr;
 	c->ops.get_line_count = dpu_hw_pp_get_line_count;
 
-	if (test_bit(DPU_PINGPONG_DITHER, &features) &&
-		IS_SC7180_TARGET(c->hw.hwversion))
+	if (test_bit(DPU_PINGPONG_DITHER, &features))
 		c->ops.setup_dither = dpu_hw_pp_setup_dither;
 };
 
Signature · 1 line
2.26.2
Tested-by on v1 1/1
#1 lore raw

Hi,

Quoted 75 lines · Rob Clark

From: Rob Clark <[email protected]>

If split-lm is used (for ex, on sdm845), we can have multiple ping- pongs, but only a single phys encoder. We need to configure dithering on each of them.

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c   | 22 ++++++++++---------
 .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c   |  3 +--
 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +12 -10
index 46df0ff75b85..9b98b63c77fb 100644
@@ -212,14 +212,14 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
 	15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
 };
 
-static void _dpu_encoder_setup_dither(struct dpu_encoder_phys *phys)
+static void _dpu_encoder_setup_dither(struct dpu_hw_pingpong *hw_pp, unsigned bpc)
 {
 	struct dpu_hw_dither_cfg dither_cfg = { 0 };
 
-	if (!phys->hw_pp || !phys->hw_pp->ops.setup_dither)
+	if (!hw_pp->ops.setup_dither)
 		return;
 
-	switch (phys->connector->display_info.bpc) {
+	switch (bpc) {
 	case 6:
 		dither_cfg.c0_bitdepth = 6;
 		dither_cfg.c1_bitdepth = 6;
@@ -228,14 +228,14 @@ static void _dpu_encoder_setup_dither(struct dpu_encoder_phys *phys)
 		dither_cfg.temporal_en = 0;
 		break;
 	default:
-		phys->hw_pp->ops.setup_dither(phys->hw_pp, NULL);
+		hw_pp->ops.setup_dither(hw_pp, NULL);
 		return;
 	}
 
 	memcpy(&dither_cfg.matrix, dither_matrix,
 			sizeof(u32) * DITHER_MATRIX_SZ);
 
-	phys->hw_pp->ops.setup_dither(phys->hw_pp, &dither_cfg);
+	hw_pp->ops.setup_dither(hw_pp, &dither_cfg);
 }
 
 void dpu_encoder_helper_report_irq_timeout(struct dpu_encoder_phys *phys_enc,
@@ -1132,11 +1132,13 @@ static void _dpu_encoder_virt_enable_helper(struct drm_encoder *drm_enc)
 
 	_dpu_encoder_update_vsync_source(dpu_enc, &dpu_enc->disp_info);
 
-	if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) {
-		for (i = 0; i < dpu_enc->num_phys_encs; i++) {
-			struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
-
-			_dpu_encoder_setup_dither(phys);
+	if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI &&
+			!WARN_ON(dpu_enc->num_phys_encs == 0)) {
+		unsigned bpc = dpu_enc->phys_encs[0]->connector->display_info.bpc;
+		for (i = 0; i < MAX_CHANNELS_PER_ENC; i++) {
+			if (!dpu_enc->hw_pp[i])
+				continue;
+			_dpu_encoder_setup_dither(dpu_enc->hw_pp[i], bpc);
 		}
 	}
 }
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +0 -0
index 7411ab6bf6af..bea4ab5c58c5 100644

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c static void _setup_pingpong_ops(struct dpu_hw_pingpong *c, · line 236

Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +1 -2
@@ -231,8 +231,7 @@ static void _setup_pingpong_ops(struct dpu_hw_pingpong *c,
 	c->ops.poll_timeout_wr_ptr = dpu_hw_pp_poll_timeout_wr_ptr;
 	c->ops.get_line_count = dpu_hw_pp_get_line_count;
 
-	if (test_bit(DPU_PINGPONG_DITHER, &features) &&
-		IS_SC7180_TARGET(c->hw.hwversion))
+	if (test_bit(DPU_PINGPONG_DITHER, &features))
 		c->ops.setup_dither = dpu_hw_pp_setup_dither;
 };

Sorry for taking so long to get around to testing this.  I was able to today, and it does reduce the banding to be less noticeable.

Thanks!

-- steev

#2 lore raw
In reply to Rob Clark
Quoted 81 lines · Rob Clark

From: Rob Clark <[email protected]>

If split-lm is used (for ex, on sdm845), we can have multiple ping- pongs, but only a single phys encoder. We need to configure dithering on each of them.

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c   | 22 ++++++++++---------
 .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c   |  3 +--
 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +3 -3
index 46df0ff75b85..9b98b63c77fb 100644
@@ -212,14 +212,14 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
 	15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
 };
 
-static void _dpu_encoder_setup_dither(struct dpu_encoder_phys *phys)
+static void _dpu_encoder_setup_dither(struct dpu_hw_pingpong *hw_pp,
 unsigned bpc)
 {
 	struct dpu_hw_dither_cfg dither_cfg = { 0 };
 
-	if (!phys->hw_pp || !phys->hw_pp->ops.setup_dither)
+	if (!hw_pp->ops.setup_dither)
 		return;
 
-	switch (phys->connector->display_info.bpc) {
+	switch (bpc) {
 	case 6:
 		dither_cfg.c0_bitdepth = 6;
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -2
 		dither_cfg.c1_bitdepth = 6;
@@ -228,14 +228,14 @@ static void _dpu_encoder_setup_dither(struct
 dpu_encoder_phys *phys)
 		dither_cfg.temporal_en = 0;
 		break;
 	default:
-		phys->hw_pp->ops.setup_dither(phys->hw_pp, NULL);
+		hw_pp->ops.setup_dither(hw_pp, NULL);
 		return;
 	}
 
 	memcpy(&dither_cfg.matrix, dither_matrix,
 			sizeof(u32) * DITHER_MATRIX_SZ);
 
-	phys->hw_pp->ops.setup_dither(phys->hw_pp, &dither_cfg);
+	hw_pp->ops.setup_dither(hw_pp, &dither_cfg);
 }
 

void dpu_encoder_helper_report_irq_timeout(struct dpu_encoder_phys
*phys_enc,

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +7 -5
@@ -1132,11 +1132,13 @@ static void
 _dpu_encoder_virt_enable_helper(struct drm_encoder *drm_enc)
 
 	_dpu_encoder_update_vsync_source(dpu_enc, &dpu_enc->disp_info);
 
-	if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) {
-		for (i = 0; i < dpu_enc->num_phys_encs; i++) {
-			struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
-
-			_dpu_encoder_setup_dither(phys);
+	if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI &&
+			!WARN_ON(dpu_enc->num_phys_encs == 0)) {
+		unsigned bpc = dpu_enc->phys_encs[0]->connector->display_info.bpc;
+		for (i = 0; i < MAX_CHANNELS_PER_ENC; i++) {
+			if (!dpu_enc->hw_pp[i])
+				continue;
+			_dpu_encoder_setup_dither(dpu_enc->hw_pp[i], bpc);
 		}
 	}

}

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +0 -0
index 7411ab6bf6af..bea4ab5c58c5 100644

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c static void _setup_pingpong_ops(struct · line 237

Quoted 9 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +1 -2
@@ -231,8 +231,7 @@ static void _setup_pingpong_ops(struct 
 dpu_hw_pingpong *c,
 	c->ops.poll_timeout_wr_ptr = dpu_hw_pp_poll_timeout_wr_ptr;
 	c->ops.get_line_count = dpu_hw_pp_get_line_count;
 
-	if (test_bit(DPU_PINGPONG_DITHER, &features) &&
-		IS_SC7180_TARGET(c->hw.hwversion))
+	if (test_bit(DPU_PINGPONG_DITHER, &features))
 		c->ops.setup_dither = dpu_hw_pp_setup_dither;
 };

Change looks good to me

- Kalyan

author
#3 lore raw
Quoted 87 lines · On Mon, Jul 20, 2020 at 5:53 AM <[email protected]> wrote:
Quoted 85 lines · Rob Clark

From: Rob Clark <[email protected]>

If split-lm is used (for ex, on sdm845), we can have multiple ping- pongs, but only a single phys encoder. We need to configure dithering on each of them.

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c   | 22 ++++++++++---------
 .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c   |  3 +--
 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +3 -3
index 46df0ff75b85..9b98b63c77fb 100644
@@ -212,14 +212,14 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
      15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
 };
 
-static void _dpu_encoder_setup_dither(struct dpu_encoder_phys *phys)
+static void _dpu_encoder_setup_dither(struct dpu_hw_pingpong *hw_pp,
 unsigned bpc)
 {
      struct dpu_hw_dither_cfg dither_cfg = { 0 };
 
-     if (!phys->hw_pp || !phys->hw_pp->ops.setup_dither)
+     if (!hw_pp->ops.setup_dither)
              return;
 
-     switch (phys->connector->display_info.bpc) {
+     switch (bpc) {
      case 6:
              dither_cfg.c0_bitdepth = 6;
              dither_cfg.c1_bitdepth = 6;
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -2
@@ -228,14 +228,14 @@ static void _dpu_encoder_setup_dither(struct
 dpu_encoder_phys *phys)
              dither_cfg.temporal_en = 0;
              break;
      default:
-             phys->hw_pp->ops.setup_dither(phys->hw_pp, NULL);
+             hw_pp->ops.setup_dither(hw_pp, NULL);
              return;
      }
 
      memcpy(&dither_cfg.matrix, dither_matrix,
                      sizeof(u32) * DITHER_MATRIX_SZ);
 
-     phys->hw_pp->ops.setup_dither(phys->hw_pp, &dither_cfg);
+     hw_pp->ops.setup_dither(hw_pp, &dither_cfg);
 }
 

void dpu_encoder_helper_report_irq_timeout(struct dpu_encoder_phys
*phys_enc,

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +7 -5
@@ -1132,11 +1132,13 @@ static void
 _dpu_encoder_virt_enable_helper(struct drm_encoder *drm_enc)
 
      _dpu_encoder_update_vsync_source(dpu_enc, &dpu_enc->disp_info);
 
-     if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) {
-             for (i = 0; i < dpu_enc->num_phys_encs; i++) {
-                     struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
-
-                     _dpu_encoder_setup_dither(phys);
+     if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI &&
+                     !WARN_ON(dpu_enc->num_phys_encs == 0)) {
+             unsigned bpc = dpu_enc->phys_encs[0]->connector->display_info.bpc;
+             for (i = 0; i < MAX_CHANNELS_PER_ENC; i++) {
+                     if (!dpu_enc->hw_pp[i])
+                             continue;
+                     _dpu_encoder_setup_dither(dpu_enc->hw_pp[i], bpc);
              }
      }

}

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +0 -0
index 7411ab6bf6af..bea4ab5c58c5 100644
@@ -231,8 +231,7 @@ static void _setup_pingpong_ops(struct
 dpu_hw_pingpong *c,
      c->ops.poll_timeout_wr_ptr = dpu_hw_pp_poll_timeout_wr_ptr;
      c->ops.get_line_count = dpu_hw_pp_get_line_count;
 
Quoted 7 lines

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c static void _setup_pingpong_ops(struct dpu_hw_pingpong *c, · line 236

Quoted 5 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +1 -2
-     if (test_bit(DPU_PINGPONG_DITHER, &features) &&
-             IS_SC7180_TARGET(c->hw.hwversion))
+     if (test_bit(DPU_PINGPONG_DITHER, &features))
              c->ops.setup_dither = dpu_hw_pp_setup_dither;
 };

Change looks good to me

Does that count as a Reviewed-by?

BR,
-R

Quoted 2 lines

- Kalyan

Reviewed-by
#4 lore raw
Quoted 10 lines · Rob Clark
Quoted 9 lines · On Mon, Jul 20, 2020 at 5:53 AM <[email protected]> wrote:
Quoted 7 lines · Rob Clark

From: Rob Clark <[email protected]>

If split-lm is used (for ex, on sdm845), we can have multiple ping- pongs, but only a single phys encoder. We need to configure dithering on each of them.

Quoted 86 lines
Quoted 78 lines
Quoted 78 lines
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c   | 22 ++++++++++---------
 .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c   |  3 +--
 2 files changed, 13 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +3 -3
index 46df0ff75b85..9b98b63c77fb 100644
@@ -212,14 +212,14 @@ static u32 dither_matrix[DITHER_MATRIX_SZ] = {
      15, 7, 13, 5, 3, 11, 1, 9, 12, 4, 14, 6, 0, 8, 2, 10
 };
 
-static void _dpu_encoder_setup_dither(struct dpu_encoder_phys *phys)
+static void _dpu_encoder_setup_dither(struct dpu_hw_pingpong *hw_pp,
 unsigned bpc)
 {
      struct dpu_hw_dither_cfg dither_cfg = { 0 };
 
-     if (!phys->hw_pp || !phys->hw_pp->ops.setup_dither)
+     if (!hw_pp->ops.setup_dither)
              return;
 
-     switch (phys->connector->display_info.bpc) {
+     switch (bpc) {
      case 6:
              dither_cfg.c0_bitdepth = 6;
              dither_cfg.c1_bitdepth = 6;
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -2
@@ -228,14 +228,14 @@ static void _dpu_encoder_setup_dither(struct
 dpu_encoder_phys *phys)
              dither_cfg.temporal_en = 0;
              break;
      default:
-             phys->hw_pp->ops.setup_dither(phys->hw_pp, NULL);
+             hw_pp->ops.setup_dither(hw_pp, NULL);
              return;
      }
 
      memcpy(&dither_cfg.matrix, dither_matrix,
                      sizeof(u32) * DITHER_MATRIX_SZ);
 
-     phys->hw_pp->ops.setup_dither(phys->hw_pp, &dither_cfg);
+     hw_pp->ops.setup_dither(hw_pp, &dither_cfg);
 }
 

void dpu_encoder_helper_report_irq_timeout(struct dpu_encoder_phys
*phys_enc,

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +7 -5
@@ -1132,11 +1132,13 @@ static void
 _dpu_encoder_virt_enable_helper(struct drm_encoder *drm_enc)
 
      _dpu_encoder_update_vsync_source(dpu_enc, &dpu_enc->disp_info);
 
-     if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) {
-             for (i = 0; i < dpu_enc->num_phys_encs; i++) {
-                     struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
-
-                     _dpu_encoder_setup_dither(phys);
+     if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI &&
+                     !WARN_ON(dpu_enc->num_phys_encs == 0)) {
+             unsigned bpc = dpu_enc->phys_encs[0]->connector->display_info.bpc;
+             for (i = 0; i < MAX_CHANNELS_PER_ENC; i++) {
+                     if (!dpu_enc->hw_pp[i])
+                             continue;
+                     _dpu_encoder_setup_dither(dpu_enc->hw_pp[i], bpc);
              }
      }

}

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +0 -0
index 7411ab6bf6af..bea4ab5c58c5 100644
@@ -231,8 +231,7 @@ static void _setup_pingpong_ops(struct
 dpu_hw_pingpong *c,
      c->ops.poll_timeout_wr_ptr = dpu_hw_pp_poll_timeout_wr_ptr;
      c->ops.get_line_count = dpu_hw_pp_get_line_count;
 
Quoted 7 lines

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c static void _setup_pingpong_ops(struct dpu_hw_pingpong *c, · line 236

Quoted 5 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +1 -2
-     if (test_bit(DPU_PINGPONG_DITHER, &features) &&
-             IS_SC7180_TARGET(c->hw.hwversion))
+     if (test_bit(DPU_PINGPONG_DITHER, &features))
              c->ops.setup_dither = dpu_hw_pp_setup_dither;
 };

Change looks good to me

Quoted 2 lines

Does that count as a Reviewed-by?

Sure i have added the tag.

Quoted 9 lines

BR,
-R

Quoted 2 lines

- Kalyan

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno