Skip to contentSkip to conversation

drm/mgag200: Handle VIDRST from BMC helpers

PATCH Superseded Thomas Zimmermann 2 participants 12 messages Jul 3, 2024 – Jul 4, 2024

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover drm/mgag200: Handle VIDRST from BMC helpers

The VIDRST pin controls CRTC synchronization with an external clock chip, such as a BMC or TV encoder. This patchset separates the CRTC state from the BMC state and streamlines the driver code.

Patch one moves the VIDRST programming logic into the CRTC modesetting code. The status of the rsp flag bits is fully controlled by an active BMC encoder. Without BMC, the CRTC ignores VIDRST by default.

During a modeset operation on the CRTC, the BMC has to stop scanning out the display signal. Patch 2 integrates the logic controlling the BMC scanout with the BMC encoder helpers.

Patches 3 and 4 then remove and rename obsolete and unused artifacts within the mgag200 driver.

Thomas Zimmermann (4):
drm/mgag200: Only set VIDRST bits in CRTC modesetting drm/mgag200: Start/stop BMC scanout in BMC encoder helpers drm/mgag200: Remove vidrst callbacks from struct mgag200_device_funcs drm/mgag200: Rename BMC vidrst names

 drivers/gpu/drm/mgag200/mgag200_bmc.c     | 50 +++++++++++++++++++----
 drivers/gpu/drm/mgag200/mgag200_drv.h     | 29 ++++---------
 drivers/gpu/drm/mgag200/mgag200_g200er.c  |  8 +---
 drivers/gpu/drm/mgag200/mgag200_g200ev.c  |  8 +---
 drivers/gpu/drm/mgag200/mgag200_g200ew3.c |  2 -
 drivers/gpu/drm/mgag200/mgag200_g200se.c  |  8 +---
 drivers/gpu/drm/mgag200/mgag200_g200wb.c  |  2 -
 drivers/gpu/drm/mgag200/mgag200_mode.c    | 24 ++++-------
 8 files changed, 62 insertions(+), 69 deletions(-)
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH 1/4 drm/mgag200: Only set VIDRST bits in CRTC modesetting

The VRSTEN and HRSTEN bits control whether a CRTC synchronizes its display signal with an external source on the VIDRST pin. The G200WB and G200EW3 models synchronize with a BMC chip, but different external video encoders, such as the Matrox Maven, can also be attached to the pin.

Only set VRSTEN and HRSTEN bits in the CRTC mode-setting code, so the driver maintains the bits independently from the BMC. Add the field set_vidrst to the CRTC state for this purpose. Off by default, control the CRTC VIDRST setting from the BMC's atomic_check helper. So if a BMC (or another external clock) requires synchronization, it instructs the CRTC to synchronize.

---
 drivers/gpu/drm/mgag200/mgag200_bmc.c    | 26 +++++++++++++++++++-----
 drivers/gpu/drm/mgag200/mgag200_drv.h    |  5 ++++-
 drivers/gpu/drm/mgag200/mgag200_g200er.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_g200ev.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_g200se.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_mode.c   | 11 ++++++----
 6 files changed, 35 insertions(+), 13 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +21 -5
index 23ef85aa7e37..cb5400333862 100644
@@ -77,11 +77,6 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
 {
 	u8 tmp;
 
-	/* Ensure that the vrsten and hrsten are set */
-	WREG8(MGAREG_CRTCEXT_INDEX, 1);
-	tmp = RREG8(MGAREG_CRTCEXT_DATA);
-	WREG8(MGAREG_CRTCEXT_DATA, tmp | 0x88);
-
 	/* Assert rstlvl2 */
 	WREG8(DAC_INDEX, MGA1064_REMHEADCTL2);
 	tmp = RREG8(DAC_DATA);
@@ -108,6 +103,25 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
 	WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
 }
 
+static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
+						   struct drm_crtc_state *crtc_state,
+						   struct drm_connector_state *conn_state)
+{
+	struct mga_device *mdev = to_mga_device(encoder->dev);
+	struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
+
+	if (mdev->info->has_vidrst)
+		mgag200_crtc_state->set_vidrst = true;
+	else
+		mgag200_crtc_state->set_vidrst = false;
+
+	return 0;
+}
+
+static const struct drm_encoder_helper_funcs mgag200_bmc_encoder_helper_funcs = {
+	.atomic_check = mgag200_bmc_encoder_helper_atomic_check,
+};
+
 static const struct drm_encoder_funcs mgag200_bmc_encoder_funcs = {
 	.destroy = drm_encoder_cleanup,
 };
@@ -190,6 +204,8 @@ int mgag200_bmc_output_init(struct mga_device *mdev, struct drm_connector *physi
 			       DRM_MODE_ENCODER_VIRTUAL, NULL);
 	if (ret)
 		return ret;
+	drm_encoder_helper_add(encoder, &mgag200_bmc_encoder_helper_funcs);
+
 	encoder->possible_crtcs = drm_crtc_mask(crtc);
 
 	bmc_connector = &mdev->output.bmc.bmc_connector;
drivers/gpu/drm/mgag200/mgag200_drv.h +4 -1
index 7f7dfbd0f013..4b75613de882 100644
@@ -179,6 +179,8 @@ struct mgag200_crtc_state {
 	const struct drm_format_info *format;
 
 	struct mgag200_pll_values pixpllc;
+
+	bool set_vidrst;
 };
 
 static inline struct mgag200_crtc_state *to_mgag200_crtc_state(struct drm_crtc_state *base)
@@ -430,7 +432,8 @@ void mgag200_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_st
 	.atomic_duplicate_state = mgag200_crtc_atomic_duplicate_state, \
 	.atomic_destroy_state = mgag200_crtc_atomic_destroy_state
 
-void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode);
+void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode,
+			   bool set_vidrst);
 void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_info *format);
 void mgag200_enable_display(struct mga_device *mdev);
 void mgag200_init_registers(struct mga_device *mdev);
drivers/gpu/drm/mgag200/mgag200_g200er.c +1 -1
index 4e8a1756138d..abfbed6ec390 100644
@@ -195,7 +195,7 @@ static void mgag200_g200er_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 		funcs->disable_vidrst(mdev);
 
 	mgag200_set_format_regs(mdev, format);
-	mgag200_set_mode_regs(mdev, adjusted_mode);
+	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
 	if (funcs->pixpllc_atomic_update)
 		funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_g200ev.c +1 -1
index d884f3cb0ec7..acc99999e2b5 100644
@@ -196,7 +196,7 @@ static void mgag200_g200ev_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 		funcs->disable_vidrst(mdev);
 
 	mgag200_set_format_regs(mdev, format);
-	mgag200_set_mode_regs(mdev, adjusted_mode);
+	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
 	if (funcs->pixpllc_atomic_update)
 		funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_g200se.c +1 -1
index a824bb8ad579..be4e124102c6 100644
@@ -327,7 +327,7 @@ static void mgag200_g200se_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 		funcs->disable_vidrst(mdev);
 
 	mgag200_set_format_regs(mdev, format);
-	mgag200_set_mode_regs(mdev, adjusted_mode);
+	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
 	if (funcs->pixpllc_atomic_update)
 		funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_mode.c +7 -4
index bb6204002cb3..4f4612192e30 100644
@@ -201,9 +201,9 @@ void mgag200_init_registers(struct mga_device *mdev)
 	WREG8(MGA_MISC_OUT, misc);
 }
 
-void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode)
+void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode,
+			   bool set_vidrst)
 {
-	const struct mgag200_device_info *info = mdev->info;
 	unsigned int hdisplay, hsyncstart, hsyncend, htotal;
 	unsigned int vdisplay, vsyncstart, vsyncend, vtotal;
 	u8 misc, crtcext1, crtcext2, crtcext5;
@@ -238,9 +238,11 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod
 		   ((hdisplay & 0x100) >> 7) |
 		   ((hsyncstart & 0x100) >> 6) |
 		    (htotal & 0x40);
-	if (info->has_vidrst)
+	if (set_vidrst)
 		crtcext1 |= MGAREG_CRTCEXT1_VRSTEN |
 			    MGAREG_CRTCEXT1_HRSTEN;
+	else
+		crtcext1 &= ~(MGAREG_CRTCEXT1_VRSTEN | MGAREG_CRTCEXT1_HRSTEN);
 
 	crtcext2 = ((vtotal & 0xc00) >> 10) |
 		   ((vdisplay & 0x400) >> 8) |
@@ -656,7 +658,7 @@ void mgag200_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_
 		funcs->disable_vidrst(mdev);
 
 	mgag200_set_format_regs(mdev, format);
-	mgag200_set_mode_regs(mdev, adjusted_mode);
+	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
 	if (funcs->pixpllc_atomic_update)
 		funcs->pixpllc_atomic_update(crtc, old_state);
@@ -717,6 +719,7 @@ struct drm_crtc_state *mgag200_crtc_atomic_duplicate_state(struct drm_crtc *crtc
 	new_mgag200_crtc_state->format = mgag200_crtc_state->format;
 	memcpy(&new_mgag200_crtc_state->pixpllc, &mgag200_crtc_state->pixpllc,
 	       sizeof(new_mgag200_crtc_state->pixpllc));
+	new_mgag200_crtc_state->set_vidrst = mgag200_crtc_state->set_vidrst;
 
 	return &new_mgag200_crtc_state->base;
 }
Signature · 1 line
2.45.2
reviewer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] drm/mgag200: Only set VIDRST bits in CRTC modesetting

Quoted 5 lines · Thomas Zimmermann

The VRSTEN and HRSTEN bits control whether a CRTC synchronizes its display signal with an external source on the VIDRST pin. The G200WB and G200EW3 models synchronize with a BMC chip, but different external video encoders, such as the Matrox Maven, can also be attached to the pin.

If I understand correctly, it's a kind of VSYNC with the BMC, to avoid tearing when using the remote console ?

Quoted 39 lines

Only set VRSTEN and HRSTEN bits in the CRTC mode-setting code, so the driver maintains the bits independently from the BMC. Add the field set_vidrst to the CRTC state for this purpose. Off by default, control the CRTC VIDRST setting from the BMC's atomic_check helper. So if a BMC (or another external clock) requires synchronization, it instructs the CRTC to synchronize. >

---
  drivers/gpu/drm/mgag200/mgag200_bmc.c    | 26 +++++++++++++++++++-----
  drivers/gpu/drm/mgag200/mgag200_drv.h    |  5 ++++-
  drivers/gpu/drm/mgag200/mgag200_g200er.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_g200ev.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_g200se.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_mode.c   | 11 ++++++----
  6 files changed, 35 insertions(+), 13 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +2 -5
index 23ef85aa7e37..cb5400333862 100644
@@ -77,11 +77,6 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
  {
  	u8 tmp;
 
-	/* Ensure that the vrsten and hrsten are set */
-	WREG8(MGAREG_CRTCEXT_INDEX, 1);
-	tmp = RREG8(MGAREG_CRTCEXT_DATA);
-	WREG8(MGAREG_CRTCEXT_DATA, tmp | 0x88);
-
  	/* Assert rstlvl2 */
  	WREG8(DAC_INDEX, MGA1064_REMHEADCTL2);
  	tmp = RREG8(DAC_DATA);
@@ -108,6 +103,25 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
  	WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
  }
 
+static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
+						   struct drm_crtc_state *crtc_state,

drivers/gpu/drm/mgag200/mgag200_bmc.c void mgag200_bmc_enable_vidrst(struct mga_device *mdev) · line 117

Quoted 10 lines
drivers/gpu/drm/mgag200/mgag200_bmc.c +10 -0
+						   struct drm_connector_state *conn_state)
+{
+	struct mga_device *mdev = to_mga_device(encoder->dev);
+	struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
+
+	if (mdev->info->has_vidrst)
+		mgag200_crtc_state->set_vidrst = true;
+	else
+		mgag200_crtc_state->set_vidrst = false;
+

I think you can simplify it with:

mgag200_crtc_state->set_vidrst = mdev->info->has_vidrst;

Quoted 120 lines
drivers/gpu/drm/mgag200/mgag200_bmc.c +9 -0
+	return 0;
+}
+
+static const struct drm_encoder_helper_funcs mgag200_bmc_encoder_helper_funcs = {
+	.atomic_check = mgag200_bmc_encoder_helper_atomic_check,
+};
+
  static const struct drm_encoder_funcs mgag200_bmc_encoder_funcs = {
  	.destroy = drm_encoder_cleanup,
  };
@@ -190,6 +204,8 @@ int mgag200_bmc_output_init(struct mga_device *mdev, struct drm_connector *physi
  			       DRM_MODE_ENCODER_VIRTUAL, NULL);
  	if (ret)
  		return ret;
+	drm_encoder_helper_add(encoder, &mgag200_bmc_encoder_helper_funcs);
+
  	encoder->possible_crtcs = drm_crtc_mask(crtc);
 
  	bmc_connector = &mdev->output.bmc.bmc_connector;
drivers/gpu/drm/mgag200/mgag200_drv.h +4 -1
index 7f7dfbd0f013..4b75613de882 100644
@@ -179,6 +179,8 @@ struct mgag200_crtc_state {
  	const struct drm_format_info *format;
 
  	struct mgag200_pll_values pixpllc;
+
+	bool set_vidrst;
  };
 
  static inline struct mgag200_crtc_state *to_mgag200_crtc_state(struct drm_crtc_state *base)
@@ -430,7 +432,8 @@ void mgag200_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_st
  	.atomic_duplicate_state = mgag200_crtc_atomic_duplicate_state, \
  	.atomic_destroy_state = mgag200_crtc_atomic_destroy_state
 
-void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode);
+void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode,
+			   bool set_vidrst);
  void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_info *format);
  void mgag200_enable_display(struct mga_device *mdev);
  void mgag200_init_registers(struct mga_device *mdev);
drivers/gpu/drm/mgag200/mgag200_g200er.c +1 -1
index 4e8a1756138d..abfbed6ec390 100644
@@ -195,7 +195,7 @@ static void mgag200_g200er_crtc_helper_atomic_enable(struct drm_crtc *crtc,
  		funcs->disable_vidrst(mdev);
 
  	mgag200_set_format_regs(mdev, format);
-	mgag200_set_mode_regs(mdev, adjusted_mode);
+	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
  	if (funcs->pixpllc_atomic_update)
  		funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_g200ev.c +1 -1
index d884f3cb0ec7..acc99999e2b5 100644
@@ -196,7 +196,7 @@ static void mgag200_g200ev_crtc_helper_atomic_enable(struct drm_crtc *crtc,
  		funcs->disable_vidrst(mdev);
 
  	mgag200_set_format_regs(mdev, format);
-	mgag200_set_mode_regs(mdev, adjusted_mode);
+	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
  	if (funcs->pixpllc_atomic_update)
  		funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_g200se.c +1 -1
index a824bb8ad579..be4e124102c6 100644
@@ -327,7 +327,7 @@ static void mgag200_g200se_crtc_helper_atomic_enable(struct drm_crtc *crtc,
  		funcs->disable_vidrst(mdev);
 
  	mgag200_set_format_regs(mdev, format);
-	mgag200_set_mode_regs(mdev, adjusted_mode);
+	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
  	if (funcs->pixpllc_atomic_update)
  		funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_mode.c +6 -4
index bb6204002cb3..4f4612192e30 100644
@@ -201,9 +201,9 @@ void mgag200_init_registers(struct mga_device *mdev)
  	WREG8(MGA_MISC_OUT, misc);
  }
 
-void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode)
+void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode,
+			   bool set_vidrst)
  {
-	const struct mgag200_device_info *info = mdev->info;
  	unsigned int hdisplay, hsyncstart, hsyncend, htotal;
  	unsigned int vdisplay, vsyncstart, vsyncend, vtotal;
  	u8 misc, crtcext1, crtcext2, crtcext5;
@@ -238,9 +238,11 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod
  		   ((hdisplay & 0x100) >> 7) |
  		   ((hsyncstart & 0x100) >> 6) |
  		    (htotal & 0x40);
-	if (info->has_vidrst)
+	if (set_vidrst)
  		crtcext1 |= MGAREG_CRTCEXT1_VRSTEN |
  			    MGAREG_CRTCEXT1_HRSTEN;
+	else
+		crtcext1 &= ~(MGAREG_CRTCEXT1_VRSTEN | MGAREG_CRTCEXT1_HRSTEN);
 
  	crtcext2 = ((vtotal & 0xc00) >> 10) |
  		   ((vdisplay & 0x400) >> 8) |
@@ -656,7 +658,7 @@ void mgag200_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_
  		funcs->disable_vidrst(mdev);
 
  	mgag200_set_format_regs(mdev, format);
-	mgag200_set_mode_regs(mdev, adjusted_mode);
+	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
  	if (funcs->pixpllc_atomic_update)
  		funcs->pixpllc_atomic_update(crtc, old_state);

drivers/gpu/drm/mgag200/mgag200_mode.c struct drm_crtc_state *mgag200_crtc_atomic_duplicate_state(struct drm_crtc *crtc · line 725

Quoted 7 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -0
@@ -717,6 +719,7 @@ struct drm_crtc_state *mgag200_crtc_atomic_duplicate_state(struct drm_crtc *crtc
  	new_mgag200_crtc_state->format = mgag200_crtc_state->format;
  	memcpy(&new_mgag200_crtc_state->pixpllc, &mgag200_crtc_state->pixpllc,
  	       sizeof(new_mgag200_crtc_state->pixpllc));
+	new_mgag200_crtc_state->set_vidrst = mgag200_crtc_state->set_vidrst;
 
  	return &new_mgag200_crtc_state->base;
  }

With the small nitpick.

Signature · 1 line
Jocelyn
author maintainer
#3 lore raw

Re: [PATCH 1/4] drm/mgag200: Only set VIDRST bits in CRTC modesetting

Hi

Am 04.07.24 um 14:03 schrieb Jocelyn Falempe:

Quoted 11 lines · Thomas Zimmermann
Quoted 5 lines

The VRSTEN and HRSTEN bits control whether a CRTC synchronizes its display signal with an external source on the VIDRST pin. The G200WB and G200EW3 models synchronize with a BMC chip, but different external video encoders, such as the Matrox Maven, can also be attached to the pin.

If I understand correctly, it's a kind of VSYNC with the BMC, to avoid tearing when using the remote console ?

I closely looked through the code behind enable_vidrst and disable_vidrst. The involved registers are mostly undocumented, but from the comments I assume that the BMC has to stop scanning out the display signal. It's likely that it only picks up mode changes after the scanout has been re-enabled.

BTW we've seen various models with BMC attached, but only G200EW3 and G200WB use this code for synchronization. Do you think we could enable it for all models and BMCs?

Quoted 54 lines
Quoted 41 lines

Only set VRSTEN and HRSTEN bits in the CRTC mode-setting code, so the driver maintains the bits independently from the BMC. Add the field set_vidrst to the CRTC state for this purpose. Off by default, control the CRTC VIDRST setting from the BMC's atomic_check helper. So if a BMC (or another external clock) requires synchronization, it instructs the CRTC to synchronize. >

---
  drivers/gpu/drm/mgag200/mgag200_bmc.c    | 26 +++++++++++++++++++----- drivers/gpu/drm/mgag200/mgag200_drv.h    |  5 ++++-

  drivers/gpu/drm/mgag200/mgag200_g200er.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_g200ev.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_g200se.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_mode.c   | 11 ++++++----
  6 files changed, 35 insertions(+), 13 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +0 -0
index 23ef85aa7e37..cb5400333862 100644
@@ -77,11 +77,6 @@ void mgag200_bmc_enable_vidrst(struct mga_device 
 *mdev)
   {
       u8 tmp;

  -    /* Ensure that the vrsten and hrsten are set */ -    WREG8(MGAREG_CRTCEXT_INDEX, 1);
-    tmp = RREG8(MGAREG_CRTCEXT_DATA);
-    WREG8(MGAREG_CRTCEXT_DATA, tmp | 0x88); -
      /* Assert rstlvl2 */
      WREG8(DAC_INDEX, MGA1064_REMHEADCTL2); tmp = RREG8(DAC_DATA);

drivers/gpu/drm/mgag200/mgag200_bmc.c +2 -0
@@ -108,6 +103,25 @@ void mgag200_bmc_enable_vidrst(struct mga_device 
 *mdev)
       WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
   }
   +static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
+                           struct drm_crtc_state *crtc_state,
+                           struct drm_connector_state *conn_state)

drivers/gpu/drm/mgag200/mgag200_bmc.c void mgag200_bmc_enable_vidrst(struct mga_device · line 118

Quoted 10 lines
drivers/gpu/drm/mgag200/mgag200_bmc.c +9 -0
+{
+    struct mga_device *mdev = to_mga_device(encoder->dev);
+    struct mgag200_crtc_state *mgag200_crtc_state = 
 to_mgag200_crtc_state(crtc_state);
+
+    if (mdev->info->has_vidrst)
+        mgag200_crtc_state->set_vidrst = true;
+    else
+        mgag200_crtc_state->set_vidrst = false;
+

I think you can simplify it with:

Quoted 1 line

mgag200_crtc_state->set_vidrst = mdev->info->has_vidrst;

Ok.

Best regards
Thomas

Quoted 135 lines
Quoted 128 lines
drivers/gpu/drm/mgag200/mgag200_bmc.c +7 -0
+    return 0;
+}
+
+static const struct drm_encoder_helper_funcs 
 mgag200_bmc_encoder_helper_funcs = {
+    .atomic_check = mgag200_bmc_encoder_helper_atomic_check,
+};
+

  static const struct drm_encoder_funcs mgag200_bmc_encoder_funcs = { .destroy = drm_encoder_cleanup,
  };

drivers/gpu/drm/mgag200/mgag200_bmc.c +2 -0
@@ -190,6 +204,8 @@ int mgag200_bmc_output_init(struct mga_device 
 *mdev, struct drm_connector *physi
                      DRM_MODE_ENCODER_VIRTUAL, NULL);
       if (ret)
           return ret;
+    drm_encoder_helper_add(encoder, &mgag200_bmc_encoder_helper_funcs);
+
       encoder->possible_crtcs = drm_crtc_mask(crtc);
         bmc_connector = &mdev->output.bmc.bmc_connector;
drivers/gpu/drm/mgag200/mgag200_drv.h +2 -0
index 7f7dfbd0f013..4b75613de882 100644
@@ -179,6 +179,8 @@ struct mgag200_crtc_state {
       const struct drm_format_info *format;
         struct mgag200_pll_values pixpllc;
+
+    bool set_vidrst;
   };
     static inline struct mgag200_crtc_state *to_mgag200_crtc_state(struct drm_crtc_state *base)
@@ -430,7 +432,8 @@ void mgag200_crtc_atomic_destroy_state(struct 

drm_crtc *crtc, struct drm_crtc_st
      .atomic_duplicate_state = mgag200_crtc_atomic_duplicate_state, \
      .atomic_destroy_state = mgag200_crtc_atomic_destroy_state
  -void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode); +void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode,
+               bool set_vidrst);
  void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_info *format); void mgag200_enable_display(struct mga_device *mdev);
  void mgag200_init_registers(struct mga_device *mdev);

drivers/gpu/drm/mgag200/mgag200_g200er.c +1 -1
index 4e8a1756138d..abfbed6ec390 100644
@@ -195,7 +195,7 @@ static void 
 mgag200_g200er_crtc_helper_atomic_enable(struct drm_crtc *crtc,
           funcs->disable_vidrst(mdev);
         mgag200_set_format_regs(mdev, format);
-    mgag200_set_mode_regs(mdev, adjusted_mode);
+    mgag200_set_mode_regs(mdev, adjusted_mode, 
 mgag200_crtc_state->set_vidrst);
         if (funcs->pixpllc_atomic_update)
           funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_g200ev.c +1 -1
index d884f3cb0ec7..acc99999e2b5 100644
@@ -196,7 +196,7 @@ static void 
 mgag200_g200ev_crtc_helper_atomic_enable(struct drm_crtc *crtc,
           funcs->disable_vidrst(mdev);
         mgag200_set_format_regs(mdev, format);
-    mgag200_set_mode_regs(mdev, adjusted_mode);
+    mgag200_set_mode_regs(mdev, adjusted_mode, 
 mgag200_crtc_state->set_vidrst);
         if (funcs->pixpllc_atomic_update)
           funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_g200se.c +1 -1
index a824bb8ad579..be4e124102c6 100644
@@ -327,7 +327,7 @@ static void 
 mgag200_g200se_crtc_helper_atomic_enable(struct drm_crtc *crtc,
           funcs->disable_vidrst(mdev);
         mgag200_set_format_regs(mdev, format);
-    mgag200_set_mode_regs(mdev, adjusted_mode);
+    mgag200_set_mode_regs(mdev, adjusted_mode, 
 mgag200_crtc_state->set_vidrst);
         if (funcs->pixpllc_atomic_update)
           funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_mode.c +2 -1
index bb6204002cb3..4f4612192e30 100644
@@ -201,9 +201,9 @@ void mgag200_init_registers(struct mga_device *mdev)
       WREG8(MGA_MISC_OUT, misc);
   }
   -void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode)
+void mgag200_set_mode_regs(struct mga_device *mdev, const struct 
 drm_display_mode *mode,
+               bool set_vidrst)
   {
-    const struct mgag200_device_info *info = mdev->info;
       unsigned int hdisplay, hsyncstart, hsyncend, htotal;
       unsigned int vdisplay, vsyncstart, vsyncend, vtotal;

      u8 misc, crtcext1, crtcext2, crtcext5;

drivers/gpu/drm/mgag200/mgag200_mode.c +0 -0
@@ -238,9 +238,11 @@ void mgag200_set_mode_regs(struct mga_device 
 *mdev, const struct drm_display_mod

             ((hdisplay & 0x100) >> 7) |
             ((hsyncstart & 0x100) >> 6) |
              (htotal & 0x40);
-    if (info->has_vidrst)
+    if (set_vidrst)
          crtcext1 |= MGAREG_CRTCEXT1_VRSTEN | MGAREG_CRTCEXT1_HRSTEN;
+    else
+        crtcext1 &= ~(MGAREG_CRTCEXT1_VRSTEN | MGAREG_CRTCEXT1_HRSTEN); crtcext2 = ((vtotal & 0xc00) >> 10) |
             ((vdisplay & 0x400) >> 8) |

drivers/gpu/drm/mgag200/mgag200_mode.c +0 -0
@@ -656,7 +658,7 @@ void mgag200_crtc_helper_atomic_enable(struct 

drm_crtc *crtc, struct drm_atomic_ funcs->disable_vidrst(mdev); mgag200_set_format_regs(mdev, format); -    mgag200_set_mode_regs(mdev, adjusted_mode); +    mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
        if (funcs->pixpllc_atomic_update) funcs->pixpllc_atomic_update(crtc, old_state);

drivers/gpu/drm/mgag200/mgag200_mode.c +1 -0
@@ -717,6 +719,7 @@ struct drm_crtc_state 
 *mgag200_crtc_atomic_duplicate_state(struct drm_crtc *crtc
       new_mgag200_crtc_state->format = mgag200_crtc_state->format;
       memcpy(&new_mgag200_crtc_state->pixpllc, &mgag200_crtc_state->pixpllc,
              sizeof(new_mgag200_crtc_state->pixpllc));
+    new_mgag200_crtc_state->set_vidrst = 
 mgag200_crtc_state->set_vidrst;
         return &new_mgag200_crtc_state->base;
Quoted 1 line

  }

With the small nitpick.

Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#4 lore raw

Re: [PATCH 1/4] drm/mgag200: Only set VIDRST bits in CRTC modesetting

Quoted 12 lines · Thomas Zimmermann

Hi

Am 04.07.24 um 14:03 schrieb Jocelyn Falempe:

Quoted 9 lines · Thomas Zimmermann
Quoted 5 lines

The VRSTEN and HRSTEN bits control whether a CRTC synchronizes its display signal with an external source on the VIDRST pin. The G200WB and G200EW3 models synchronize with a BMC chip, but different external video encoders, such as the Matrox Maven, can also be attached to the pin.

Quoted 7 lines
Quoted 2 lines

If I understand correctly, it's a kind of VSYNC with the BMC, to avoid tearing when using the remote console ?

I closely looked through the code behind enable_vidrst and disable_vidrst. The involved registers are mostly undocumented, but from the comments I assume that the BMC has to stop scanning out the display signal. It's likely that it only picks up mode changes after the scanout has been re-enabled.

BTW we've seen various models with BMC attached, but only G200EW3 and G200WB use this code for synchronization. Do you think we could enable it for all models and BMCs?

From one side it makes sense because all those chips are made for BMC. On the other hand, it may break, and we don't know what the other BMC firmwares are doing, and we even don't know if those pins are connected.

So I prefer to stay on the safe side, and keep it like this.

Quoted 198 lines
Quoted 54 lines
Quoted 41 lines

Only set VRSTEN and HRSTEN bits in the CRTC mode-setting code, so the driver maintains the bits independently from the BMC. Add the field set_vidrst to the CRTC state for this purpose. Off by default, control the CRTC VIDRST setting from the BMC's atomic_check helper. So if a BMC (or another external clock) requires synchronization, it instructs the CRTC to synchronize. >

---
  drivers/gpu/drm/mgag200/mgag200_bmc.c    | 26 +++++++++++++++++++----- drivers/gpu/drm/mgag200/mgag200_drv.h    |  5 ++++-

  drivers/gpu/drm/mgag200/mgag200_g200er.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_g200ev.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_g200se.c |  2 +-
  drivers/gpu/drm/mgag200/mgag200_mode.c   | 11 ++++++----
  6 files changed, 35 insertions(+), 13 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +0 -0
index 23ef85aa7e37..cb5400333862 100644
@@ -77,11 +77,6 @@ void mgag200_bmc_enable_vidrst(struct mga_device 
 *mdev)
   {
       u8 tmp;

  -    /* Ensure that the vrsten and hrsten are set */ -    WREG8(MGAREG_CRTCEXT_INDEX, 1);
-    tmp = RREG8(MGAREG_CRTCEXT_DATA);
-    WREG8(MGAREG_CRTCEXT_DATA, tmp | 0x88); -
      /* Assert rstlvl2 */
      WREG8(DAC_INDEX, MGA1064_REMHEADCTL2); tmp = RREG8(DAC_DATA);

drivers/gpu/drm/mgag200/mgag200_bmc.c +2 -0
@@ -108,6 +103,25 @@ void mgag200_bmc_enable_vidrst(struct mga_device 
 *mdev)
       WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
   }
   +static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
+                           struct drm_crtc_state *crtc_state,
+                           struct drm_connector_state *conn_state)

drivers/gpu/drm/mgag200/mgag200_bmc.c void mgag200_bmc_enable_vidrst(struct mga_device · line 118

Quoted 10 lines
drivers/gpu/drm/mgag200/mgag200_bmc.c +9 -0
+{
+    struct mga_device *mdev = to_mga_device(encoder->dev);
+    struct mgag200_crtc_state *mgag200_crtc_state = 
 to_mgag200_crtc_state(crtc_state);
+
+    if (mdev->info->has_vidrst)
+        mgag200_crtc_state->set_vidrst = true;
+    else
+        mgag200_crtc_state->set_vidrst = false;
+

I think you can simplify it with:

Quoted 1 line

mgag200_crtc_state->set_vidrst = mdev->info->has_vidrst;

Ok.

Best regards
Thomas

Quoted 135 lines
Quoted 128 lines
drivers/gpu/drm/mgag200/mgag200_bmc.c +7 -0
+    return 0;
+}
+
+static const struct drm_encoder_helper_funcs 
 mgag200_bmc_encoder_helper_funcs = {
+    .atomic_check = mgag200_bmc_encoder_helper_atomic_check,
+};
+

  static const struct drm_encoder_funcs mgag200_bmc_encoder_funcs = { .destroy = drm_encoder_cleanup,
  };

drivers/gpu/drm/mgag200/mgag200_bmc.c +2 -0
@@ -190,6 +204,8 @@ int mgag200_bmc_output_init(struct mga_device 
 *mdev, struct drm_connector *physi
                      DRM_MODE_ENCODER_VIRTUAL, NULL);
       if (ret)
           return ret;
+    drm_encoder_helper_add(encoder, &mgag200_bmc_encoder_helper_funcs);
+
       encoder->possible_crtcs = drm_crtc_mask(crtc);
         bmc_connector = &mdev->output.bmc.bmc_connector;
drivers/gpu/drm/mgag200/mgag200_drv.h +2 -0
index 7f7dfbd0f013..4b75613de882 100644
@@ -179,6 +179,8 @@ struct mgag200_crtc_state {
       const struct drm_format_info *format;
         struct mgag200_pll_values pixpllc;
+
+    bool set_vidrst;
   };
     static inline struct mgag200_crtc_state *to_mgag200_crtc_state(struct drm_crtc_state *base)
@@ -430,7 +432,8 @@ void mgag200_crtc_atomic_destroy_state(struct 

drm_crtc *crtc, struct drm_crtc_st
      .atomic_duplicate_state = mgag200_crtc_atomic_duplicate_state, \
      .atomic_destroy_state = mgag200_crtc_atomic_destroy_state
  -void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode); +void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode,
+               bool set_vidrst);
  void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_info *format); void mgag200_enable_display(struct mga_device *mdev);
  void mgag200_init_registers(struct mga_device *mdev);

drivers/gpu/drm/mgag200/mgag200_g200er.c +1 -1
index 4e8a1756138d..abfbed6ec390 100644
@@ -195,7 +195,7 @@ static void 
 mgag200_g200er_crtc_helper_atomic_enable(struct drm_crtc *crtc,
           funcs->disable_vidrst(mdev);
         mgag200_set_format_regs(mdev, format);
-    mgag200_set_mode_regs(mdev, adjusted_mode);
+    mgag200_set_mode_regs(mdev, adjusted_mode, 
 mgag200_crtc_state->set_vidrst);
         if (funcs->pixpllc_atomic_update)
           funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_g200ev.c +1 -1
index d884f3cb0ec7..acc99999e2b5 100644
@@ -196,7 +196,7 @@ static void 
 mgag200_g200ev_crtc_helper_atomic_enable(struct drm_crtc *crtc,
           funcs->disable_vidrst(mdev);
         mgag200_set_format_regs(mdev, format);
-    mgag200_set_mode_regs(mdev, adjusted_mode);
+    mgag200_set_mode_regs(mdev, adjusted_mode, 
 mgag200_crtc_state->set_vidrst);
         if (funcs->pixpllc_atomic_update)
           funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_g200se.c +1 -1
index a824bb8ad579..be4e124102c6 100644
@@ -327,7 +327,7 @@ static void 
 mgag200_g200se_crtc_helper_atomic_enable(struct drm_crtc *crtc,
           funcs->disable_vidrst(mdev);
         mgag200_set_format_regs(mdev, format);
-    mgag200_set_mode_regs(mdev, adjusted_mode);
+    mgag200_set_mode_regs(mdev, adjusted_mode, 
 mgag200_crtc_state->set_vidrst);
         if (funcs->pixpllc_atomic_update)
           funcs->pixpllc_atomic_update(crtc, old_state);
drivers/gpu/drm/mgag200/mgag200_mode.c +2 -1
index bb6204002cb3..4f4612192e30 100644
@@ -201,9 +201,9 @@ void mgag200_init_registers(struct mga_device *mdev)
       WREG8(MGA_MISC_OUT, misc);
   }
   -void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode)
+void mgag200_set_mode_regs(struct mga_device *mdev, const struct 
 drm_display_mode *mode,
+               bool set_vidrst)
   {
-    const struct mgag200_device_info *info = mdev->info;
       unsigned int hdisplay, hsyncstart, hsyncend, htotal;
       unsigned int vdisplay, vsyncstart, vsyncend, vtotal;

      u8 misc, crtcext1, crtcext2, crtcext5;

drivers/gpu/drm/mgag200/mgag200_mode.c +0 -0
@@ -238,9 +238,11 @@ void mgag200_set_mode_regs(struct mga_device 
 *mdev, const struct drm_display_mod

             ((hdisplay & 0x100) >> 7) |
             ((hsyncstart & 0x100) >> 6) |
              (htotal & 0x40);
-    if (info->has_vidrst)
+    if (set_vidrst)
          crtcext1 |= MGAREG_CRTCEXT1_VRSTEN | MGAREG_CRTCEXT1_HRSTEN;
+    else
+        crtcext1 &= ~(MGAREG_CRTCEXT1_VRSTEN | MGAREG_CRTCEXT1_HRSTEN); crtcext2 = ((vtotal & 0xc00) >> 10) |
             ((vdisplay & 0x400) >> 8) |

drivers/gpu/drm/mgag200/mgag200_mode.c +0 -0
@@ -656,7 +658,7 @@ void mgag200_crtc_helper_atomic_enable(struct 

drm_crtc *crtc, struct drm_atomic_ funcs->disable_vidrst(mdev); mgag200_set_format_regs(mdev, format); -    mgag200_set_mode_regs(mdev, adjusted_mode); +    mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
        if (funcs->pixpllc_atomic_update) funcs->pixpllc_atomic_update(crtc, old_state);

drivers/gpu/drm/mgag200/mgag200_mode.c +1 -0
@@ -717,6 +719,7 @@ struct drm_crtc_state 
 *mgag200_crtc_atomic_duplicate_state(struct drm_crtc *crtc
       new_mgag200_crtc_state->format = mgag200_crtc_state->format;
       memcpy(&new_mgag200_crtc_state->pixpllc, &mgag200_crtc_state->pixpllc,
              sizeof(new_mgag200_crtc_state->pixpllc));
+    new_mgag200_crtc_state->set_vidrst = 
 mgag200_crtc_state->set_vidrst;
         return &new_mgag200_crtc_state->base;
Quoted 1 line

  }

With the small nitpick.

author maintainer
#5 lore raw

PATCH 2/4 drm/mgag200: Start/stop BMC scanout in BMC encoder helpers

In reply to Thomas Zimmermann

Start and stop the BMC scanout from the BMC encoder's atomic_enable and atomic_disable helpers. The BMC stops scanning out at the beginning of a modeset operation and restarts the scanout at the end of the modeset.

Only G200EW3 and G200WB require this procedure. Drop the original vidrst callbacks for these model's support, as they are now obsolete.

---
 drivers/gpu/drm/mgag200/mgag200_bmc.c     | 24 +++++++++++++++++++++--
 drivers/gpu/drm/mgag200/mgag200_drv.h     |  4 +---
 drivers/gpu/drm/mgag200/mgag200_g200ew3.c |  2 --
 drivers/gpu/drm/mgag200/mgag200_g200wb.c  |  2 --
 4 files changed, 23 insertions(+), 9 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +22 -2
index cb5400333862..74feb6d8db45 100644
@@ -14,7 +14,7 @@ static struct mgag200_bmc_connector *to_mgag200_bmc_connector(struct drm_connect
 	return container_of(connector, struct mgag200_bmc_connector, base);
 }
 
-void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
 {
 	u8 tmp;
 	int iter_max;
@@ -73,7 +73,16 @@ void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
 	}
 }
 
-void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_encoder_helper_atomic_disable(struct drm_encoder *encoder,
+						      struct drm_atomic_state *state)
+{
+	struct mga_device *mdev = to_mga_device(encoder->dev);
+
+	if (mdev->info->has_vidrst)
+		mgag200_bmc_disable_vidrst(mdev);
+}
+
+static void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
 {
 	u8 tmp;
 
@@ -103,6 +112,15 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
 	WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
 }
 
+static void mgag200_bmc_encoder_helper_atomic_enable(struct drm_encoder *encoder,
+						     struct drm_atomic_state *state)
+{
+	struct mga_device *mdev = to_mga_device(encoder->dev);
+
+	if (mdev->info->has_vidrst)
+		mgag200_bmc_enable_vidrst(mdev);
+}
+
 static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
 						   struct drm_crtc_state *crtc_state,
 						   struct drm_connector_state *conn_state)
@@ -119,6 +137,8 @@ static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
 }
 
 static const struct drm_encoder_helper_funcs mgag200_bmc_encoder_helper_funcs = {
+	.atomic_disable = mgag200_bmc_encoder_helper_atomic_disable,
+	.atomic_enable = mgag200_bmc_encoder_helper_atomic_enable,
 	.atomic_check = mgag200_bmc_encoder_helper_atomic_check,
 };
 
drivers/gpu/drm/mgag200/mgag200_drv.h +1 -3
index 4b75613de882..b1365795234b 100644
@@ -442,9 +442,7 @@ int mgag200_mode_config_init(struct mga_device *mdev, resource_size_t vram_avail
 /* mgag200_vga.c */
 int mgag200_vga_output_init(struct mga_device *mdev);
 
-				/* mgag200_bmc.c */
-void mgag200_bmc_disable_vidrst(struct mga_device *mdev);
-void mgag200_bmc_enable_vidrst(struct mga_device *mdev);
+/* mgag200_bmc.c */
 int mgag200_bmc_output_init(struct mga_device *mdev, struct drm_connector *physical_connector);
 
 #endif				/* __MGAG200_DRV_H__ */
drivers/gpu/drm/mgag200/mgag200_g200ew3.c +0 -2
index 839401e8b465..265f3e95830a 100644
@@ -146,8 +146,6 @@ static const struct mgag200_device_info mgag200_g200ew3_device_info =
 	MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, true, 0, 1, false);
 
 static const struct mgag200_device_funcs mgag200_g200ew3_device_funcs = {
-	.disable_vidrst = mgag200_bmc_disable_vidrst,
-	.enable_vidrst = mgag200_bmc_enable_vidrst,
 	.pixpllc_atomic_check = mgag200_g200ew3_pixpllc_atomic_check,
 	.pixpllc_atomic_update = mgag200_g200wb_pixpllc_atomic_update, // same as G200WB
 };
drivers/gpu/drm/mgag200/mgag200_g200wb.c +0 -2
index 835df0f4fc13..e25477347c3e 100644
@@ -280,8 +280,6 @@ static const struct mgag200_device_info mgag200_g200wb_device_info =
 	MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, true, 0, 1, false);
 
 static const struct mgag200_device_funcs mgag200_g200wb_device_funcs = {
-	.disable_vidrst = mgag200_bmc_disable_vidrst,
-	.enable_vidrst = mgag200_bmc_enable_vidrst,
 	.pixpllc_atomic_check = mgag200_g200wb_pixpllc_atomic_check,
 	.pixpllc_atomic_update = mgag200_g200wb_pixpllc_atomic_update,
 };
Signature · 1 line
2.45.2
#6 lore raw

Re: [PATCH 2/4] drm/mgag200: Start/stop BMC scanout in BMC encoder helpers

Quoted 7 lines · Thomas Zimmermann

Start and stop the BMC scanout from the BMC encoder's atomic_enable and atomic_disable helpers. The BMC stops scanning out at the beginning of a modeset operation and restarts the scanout at the end of the modeset.

Only G200EW3 and G200WB require this procedure. Drop the original vidrst callbacks for these model's support, as they are now obsolete.

Thanks, that makes the BMC connector more useful.

I'm just wondering, in case you use both a VGA output and the BMC, before this patch, vidrst would be enabled, and after, as the BMC connector is "unconnected" it should be disabled ?

Will that have a visible impact for users ?

Quoted 106 lines
---
  drivers/gpu/drm/mgag200/mgag200_bmc.c     | 24 +++++++++++++++++++++--
  drivers/gpu/drm/mgag200/mgag200_drv.h     |  4 +---
  drivers/gpu/drm/mgag200/mgag200_g200ew3.c |  2 --
  drivers/gpu/drm/mgag200/mgag200_g200wb.c  |  2 --
  4 files changed, 23 insertions(+), 9 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +22 -2
index cb5400333862..74feb6d8db45 100644
@@ -14,7 +14,7 @@ static struct mgag200_bmc_connector *to_mgag200_bmc_connector(struct drm_connect
  	return container_of(connector, struct mgag200_bmc_connector, base);
  }
 
-void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
  {
  	u8 tmp;
  	int iter_max;
@@ -73,7 +73,16 @@ void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
  	}
  }
 
-void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_encoder_helper_atomic_disable(struct drm_encoder *encoder,
+						      struct drm_atomic_state *state)
+{
+	struct mga_device *mdev = to_mga_device(encoder->dev);
+
+	if (mdev->info->has_vidrst)
+		mgag200_bmc_disable_vidrst(mdev);
+}
+
+static void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
  {
  	u8 tmp;
 
@@ -103,6 +112,15 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
  	WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
  }
 
+static void mgag200_bmc_encoder_helper_atomic_enable(struct drm_encoder *encoder,
+						     struct drm_atomic_state *state)
+{
+	struct mga_device *mdev = to_mga_device(encoder->dev);
+
+	if (mdev->info->has_vidrst)
+		mgag200_bmc_enable_vidrst(mdev);
+}
+
  static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
  						   struct drm_crtc_state *crtc_state,
  						   struct drm_connector_state *conn_state)
@@ -119,6 +137,8 @@ static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
  }
 
  static const struct drm_encoder_helper_funcs mgag200_bmc_encoder_helper_funcs = {
+	.atomic_disable = mgag200_bmc_encoder_helper_atomic_disable,
+	.atomic_enable = mgag200_bmc_encoder_helper_atomic_enable,
  	.atomic_check = mgag200_bmc_encoder_helper_atomic_check,
  };
 
drivers/gpu/drm/mgag200/mgag200_drv.h +1 -3
index 4b75613de882..b1365795234b 100644
@@ -442,9 +442,7 @@ int mgag200_mode_config_init(struct mga_device *mdev, resource_size_t vram_avail
  /* mgag200_vga.c */
  int mgag200_vga_output_init(struct mga_device *mdev);
 
-				/* mgag200_bmc.c */
-void mgag200_bmc_disable_vidrst(struct mga_device *mdev);
-void mgag200_bmc_enable_vidrst(struct mga_device *mdev);
+/* mgag200_bmc.c */
  int mgag200_bmc_output_init(struct mga_device *mdev, struct drm_connector *physical_connector);
 
  #endif				/* __MGAG200_DRV_H__ */
drivers/gpu/drm/mgag200/mgag200_g200ew3.c +0 -2
index 839401e8b465..265f3e95830a 100644
@@ -146,8 +146,6 @@ static const struct mgag200_device_info mgag200_g200ew3_device_info =
  	MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, true, 0, 1, false);
 
  static const struct mgag200_device_funcs mgag200_g200ew3_device_funcs = {
-	.disable_vidrst = mgag200_bmc_disable_vidrst,
-	.enable_vidrst = mgag200_bmc_enable_vidrst,
  	.pixpllc_atomic_check = mgag200_g200ew3_pixpllc_atomic_check,
  	.pixpllc_atomic_update = mgag200_g200wb_pixpllc_atomic_update, // same as G200WB
  };
drivers/gpu/drm/mgag200/mgag200_g200wb.c +0 -2
index 835df0f4fc13..e25477347c3e 100644
@@ -280,8 +280,6 @@ static const struct mgag200_device_info mgag200_g200wb_device_info =
  	MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, true, 0, 1, false);
 
  static const struct mgag200_device_funcs mgag200_g200wb_device_funcs = {
-	.disable_vidrst = mgag200_bmc_disable_vidrst,
-	.enable_vidrst = mgag200_bmc_enable_vidrst,
  	.pixpllc_atomic_check = mgag200_g200wb_pixpllc_atomic_check,
  	.pixpllc_atomic_update = mgag200_g200wb_pixpllc_atomic_update,
  };
author maintainer
#7 lore raw

Re: [PATCH 2/4] drm/mgag200: Start/stop BMC scanout in BMC encoder helpers

Hi

Am 04.07.24 um 14:13 schrieb Jocelyn Falempe:

Quoted 8 lines · Thomas Zimmermann
Quoted 5 lines

Start and stop the BMC scanout from the BMC encoder's atomic_enable and atomic_disable helpers. The BMC stops scanning out at the beginning of a modeset operation and restarts the scanout at the end of the modeset.

Quoted 8 lines
Quoted 2 lines

Only G200EW3 and G200WB require this procedure. Drop the original vidrst callbacks for these model's support, as they are now obsolete.

Thanks, that makes the BMC connector more useful.

I'm just wondering, in case you use both a VGA output and the BMC, before this patch, vidrst would be enabled, and after, as the BMC connector is "unconnected" it should be disabled ?

Will that have a visible impact for users ?

Oh, I didn't think of this case. That could likely be a problem. Thanks for pointing this out.

Let's drop patches 2 to 4 for now. I'd still like to take patch 1, as it works on it own and makes sense.

Best regards
Thomas

Quoted 106 lines
Quoted 105 lines

---
  drivers/gpu/drm/mgag200/mgag200_bmc.c     | 24 +++++++++++++++++++++-- drivers/gpu/drm/mgag200/mgag200_drv.h     |  4 +--- drivers/gpu/drm/mgag200/mgag200_g200ew3.c |  2 -- drivers/gpu/drm/mgag200/mgag200_g200wb.c  |  2 --

  4 files changed, 23 insertions(+), 9 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +1 -0
index cb5400333862..74feb6d8db45 100644
@@ -14,7 +14,7 @@ static struct mgag200_bmc_connector 
 *to_mgag200_bmc_connector(struct drm_connect
       return container_of(connector, struct mgag200_bmc_connector, base);
   }
   -void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
   {
       u8 tmp;

      int iter_max;

drivers/gpu/drm/mgag200/mgag200_bmc.c +10 -0
@@ -73,7 +73,16 @@ void mgag200_bmc_disable_vidrst(struct mga_device 
 *mdev)
       }
   }
   -void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_encoder_helper_atomic_disable(struct 
 drm_encoder *encoder,
+                              struct drm_atomic_state *state)
+{
+    struct mga_device *mdev = to_mga_device(encoder->dev);
+
+    if (mdev->info->has_vidrst)
+        mgag200_bmc_disable_vidrst(mdev);
+}
+
+static void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
   {

      u8 tmp;
  @@ -103,6 +112,15 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev) WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
  }
  +static void mgag200_bmc_encoder_helper_atomic_enable(struct drm_encoder *encoder, +                             struct drm_atomic_state *state)

drivers/gpu/drm/mgag200/mgag200_bmc.c +7 -0
+{
+    struct mga_device *mdev = to_mga_device(encoder->dev);
+
+    if (mdev->info->has_vidrst)
+        mgag200_bmc_enable_vidrst(mdev);
+}
+

  static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state)

drivers/gpu/drm/mgag200/mgag200_bmc.c +2 -0
@@ -119,6 +137,8 @@ static int 
 mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
   }
     static const struct drm_encoder_helper_funcs mgag200_bmc_encoder_helper_funcs = {
+    .atomic_disable = mgag200_bmc_encoder_helper_atomic_disable,
+    .atomic_enable = mgag200_bmc_encoder_helper_atomic_enable,
       .atomic_check = mgag200_bmc_encoder_helper_atomic_check,
   };

  diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 4b75613de882..b1365795234b 100644

drivers/gpu/drm/mgag200/mgag200_drv.h +0 -0
@@ -442,9 +442,7 @@ int mgag200_mode_config_init(struct mga_device 
 *mdev, resource_size_t vram_avail
   /* mgag200_vga.c */
   int mgag200_vga_output_init(struct mga_device *mdev);

  -                /* mgag200_bmc.c */

drivers/gpu/drm/mgag200/mgag200_drv.h +1 -2
-void mgag200_bmc_disable_vidrst(struct mga_device *mdev);
-void mgag200_bmc_enable_vidrst(struct mga_device *mdev);
+/* mgag200_bmc.c */

  int mgag200_bmc_output_init(struct mga_device *mdev, struct drm_connector *physical_connector); #endif                /* __MGAG200_DRV_H__ */

drivers/gpu/drm/mgag200/mgag200_g200ew3.c +0 -0
index 839401e8b465..265f3e95830a 100644
@@ -146,8 +146,6 @@ static const struct mgag200_device_info 

mgag200_g200ew3_device_info =
      MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, true, 0, 1, false);
    static const struct mgag200_device_funcs mgag200_g200ew3_device_funcs = { -    .disable_vidrst = mgag200_bmc_disable_vidrst,
-    .enable_vidrst = mgag200_bmc_enable_vidrst,
      .pixpllc_atomic_check = mgag200_g200ew3_pixpllc_atomic_check, .pixpllc_atomic_update = mgag200_g200wb_pixpllc_atomic_update, // same as G200WB };

drivers/gpu/drm/mgag200/mgag200_g200wb.c +0 -0
index 835df0f4fc13..e25477347c3e 100644
@@ -280,8 +280,6 @@ static const struct mgag200_device_info 

mgag200_g200wb_device_info =
      MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, true, 0, 1, false); static const struct mgag200_device_funcs mgag200_g200wb_device_funcs = { -    .disable_vidrst = mgag200_bmc_disable_vidrst,
-    .enable_vidrst = mgag200_bmc_enable_vidrst, .pixpllc_atomic_check = mgag200_g200wb_pixpllc_atomic_check, .pixpllc_atomic_update = mgag200_g200wb_pixpllc_atomic_update, };

Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
author maintainer
#8 lore raw

Re: [PATCH 2/4] drm/mgag200: Start/stop BMC scanout in BMC encoder helpers

Am 04.07.24 um 14:23 schrieb Thomas Zimmermann:

Quoted 16 lines

Hi

Am 04.07.24 um 14:13 schrieb Jocelyn Falempe:

Quoted 13 lines · Thomas Zimmermann
Quoted 7 lines

Start and stop the BMC scanout from the BMC encoder's atomic_enable and atomic_disable helpers. The BMC stops scanning out at the beginning of a modeset operation and restarts the scanout at the end of the modeset.

Only G200EW3 and G200WB require this procedure. Drop the original vidrst callbacks for these model's support, as they are now obsolete.

Thanks, that makes the BMC connector more useful.

Quoted 7 lines
Quoted 3 lines

I'm just wondering, in case you use both a VGA output and the BMC, before this patch, vidrst would be enabled, and after, as the BMC connector is "unconnected" it should be disabled ?

Will that have a visible impact for users ?

Oh, I didn't think of this case. That could likely be a problem. Thanks for pointing this out.

Let's drop patches 2 to 4 for now. I'd still like to take patch 1, as it works on it own and makes sense.

Or maybe I'll send out something different. I'd like the BMC and CRTC to be more independent from each other. But apparently the CRTC really has to do all the work here.

Best regards
Thomas

Quoted 112 lines

Best regards
Thomas

Quoted 107 lines
Quoted 106 lines

---
  drivers/gpu/drm/mgag200/mgag200_bmc.c     | 24
+++++++++++++++++++++--
  drivers/gpu/drm/mgag200/mgag200_drv.h     |  4 +--- drivers/gpu/drm/mgag200/mgag200_g200ew3.c |  2 -- drivers/gpu/drm/mgag200/mgag200_g200wb.c  |  2 --

  4 files changed, 23 insertions(+), 9 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +1 -0
index cb5400333862..74feb6d8db45 100644
@@ -14,7 +14,7 @@ static struct mgag200_bmc_connector 
 *to_mgag200_bmc_connector(struct drm_connect
       return container_of(connector, struct mgag200_bmc_connector, base);
   }
   -void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
   {
       u8 tmp;

      int iter_max;

drivers/gpu/drm/mgag200/mgag200_bmc.c +10 -0
@@ -73,7 +73,16 @@ void mgag200_bmc_disable_vidrst(struct mga_device 
 *mdev)
       }
   }
   -void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_encoder_helper_atomic_disable(struct 
 drm_encoder *encoder,
+                              struct drm_atomic_state *state)
+{
+    struct mga_device *mdev = to_mga_device(encoder->dev);
+
+    if (mdev->info->has_vidrst)
+        mgag200_bmc_disable_vidrst(mdev);
+}
+
+static void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
   {

      u8 tmp;
  @@ -103,6 +112,15 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev) WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
  }
  +static void mgag200_bmc_encoder_helper_atomic_enable(struct drm_encoder *encoder, +                             struct drm_atomic_state *state)

drivers/gpu/drm/mgag200/mgag200_bmc.c +7 -0
+{
+    struct mga_device *mdev = to_mga_device(encoder->dev);
+
+    if (mdev->info->has_vidrst)
+        mgag200_bmc_enable_vidrst(mdev);
+}
+

  static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state)

drivers/gpu/drm/mgag200/mgag200_bmc.c +2 -0
@@ -119,6 +137,8 @@ static int 
 mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
   }
     static const struct drm_encoder_helper_funcs mgag200_bmc_encoder_helper_funcs = {
+    .atomic_disable = mgag200_bmc_encoder_helper_atomic_disable,
+    .atomic_enable = mgag200_bmc_encoder_helper_atomic_enable,
       .atomic_check = mgag200_bmc_encoder_helper_atomic_check,
   };

  diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 4b75613de882..b1365795234b 100644

drivers/gpu/drm/mgag200/mgag200_drv.h +0 -0
@@ -442,9 +442,7 @@ int mgag200_mode_config_init(struct mga_device 
 *mdev, resource_size_t vram_avail
   /* mgag200_vga.c */
   int mgag200_vga_output_init(struct mga_device *mdev);

  -                /* mgag200_bmc.c */

drivers/gpu/drm/mgag200/mgag200_drv.h +1 -2
-void mgag200_bmc_disable_vidrst(struct mga_device *mdev);
-void mgag200_bmc_enable_vidrst(struct mga_device *mdev);
+/* mgag200_bmc.c */

  int mgag200_bmc_output_init(struct mga_device *mdev, struct drm_connector *physical_connector); #endif                /* __MGAG200_DRV_H__ */

drivers/gpu/drm/mgag200/mgag200_g200ew3.c +0 -0
index 839401e8b465..265f3e95830a 100644
@@ -146,8 +146,6 @@ static const struct mgag200_device_info 

mgag200_g200ew3_device_info =
      MGAG200_DEVICE_INFO_INIT(2048, 2048, 0, true, 0, 1, false);
    static const struct mgag200_device_funcs mgag200_g200ew3_device_funcs = { -    .disable_vidrst = mgag200_bmc_disable_vidrst,
-    .enable_vidrst = mgag200_bmc_enable_vidrst,
      .pixpllc_atomic_check = mgag200_g200ew3_pixpllc_atomic_check, .pixpllc_atomic_update = mgag200_g200wb_pixpllc_atomic_update, // same as G200WB };

drivers/gpu/drm/mgag200/mgag200_g200wb.c +0 -0
index 835df0f4fc13..e25477347c3e 100644
@@ -280,8 +280,6 @@ static const struct mgag200_device_info 

mgag200_g200wb_device_info =
      MGAG200_DEVICE_INFO_INIT(1280, 1024, 31877, true, 0, 1, false); static const struct mgag200_device_funcs mgag200_g200wb_device_funcs = { -    .disable_vidrst = mgag200_bmc_disable_vidrst,
-    .enable_vidrst = mgag200_bmc_enable_vidrst, .pixpllc_atomic_check = mgag200_g200wb_pixpllc_atomic_check, .pixpllc_atomic_update = mgag200_g200wb_pixpllc_atomic_update, };

Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
author maintainer
#9 lore raw

PATCH 3/4 drm/mgag200: Remove vidrst callbacks from struct mgag200_device_funcs

In reply to Thomas Zimmermann

The callbacks disable_vidrst and enable_vidrst are obsolete and unused. Their functionality has been integrated into the BMC's encoder. Remove the fields from struct mgag200_device_funcs.

---
 drivers/gpu/drm/mgag200/mgag200_drv.h    | 12 ------------
 drivers/gpu/drm/mgag200/mgag200_g200er.c |  6 ------
 drivers/gpu/drm/mgag200/mgag200_g200ev.c |  6 ------
 drivers/gpu/drm/mgag200/mgag200_g200se.c |  6 ------
 drivers/gpu/drm/mgag200/mgag200_mode.c   | 13 -------------
 5 files changed, 43 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.h +0 -12
index b1365795234b..64ba8a7118dc 100644
@@ -247,18 +247,6 @@ struct mgag200_device_info {
 	}
 
 struct mgag200_device_funcs {
-	/*
-	 * Disables an external reset source (i.e., BMC) before programming
-	 * a new display mode.
-	 */
-	void (*disable_vidrst)(struct mga_device *mdev);
-
-	/*
-	 * Enables an external reset source (i.e., BMC) after programming
-	 * a new display mode.
-	 */
-	void (*enable_vidrst)(struct mga_device *mdev);
-
 	/*
 	 * Validate that the given state can be programmed into PIXPLLC. On
 	 * success, the calculated parameters should be stored in the CRTC's
drivers/gpu/drm/mgag200/mgag200_g200er.c +0 -6
index abfbed6ec390..3ab3efe74d69 100644
@@ -191,9 +191,6 @@ static void mgag200_g200er_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 	struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
 	const struct drm_format_info *format = mgag200_crtc_state->format;
 
-	if (funcs->disable_vidrst)
-		funcs->disable_vidrst(mdev);
-
 	mgag200_set_format_regs(mdev, format);
 	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
@@ -208,9 +205,6 @@ static void mgag200_g200er_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 		mgag200_crtc_set_gamma_linear(mdev, format);
 
 	mgag200_enable_display(mdev);
-
-	if (funcs->enable_vidrst)
-		funcs->enable_vidrst(mdev);
 }
 
 static const struct drm_crtc_helper_funcs mgag200_g200er_crtc_helper_funcs = {
drivers/gpu/drm/mgag200/mgag200_g200ev.c +0 -6
index acc99999e2b5..703aff7e7dc1 100644
@@ -192,9 +192,6 @@ static void mgag200_g200ev_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 	struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
 	const struct drm_format_info *format = mgag200_crtc_state->format;
 
-	if (funcs->disable_vidrst)
-		funcs->disable_vidrst(mdev);
-
 	mgag200_set_format_regs(mdev, format);
 	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
@@ -209,9 +206,6 @@ static void mgag200_g200ev_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 		mgag200_crtc_set_gamma_linear(mdev, format);
 
 	mgag200_enable_display(mdev);
-
-	if (funcs->enable_vidrst)
-		funcs->enable_vidrst(mdev);
 }
 
 static const struct drm_crtc_helper_funcs mgag200_g200ev_crtc_helper_funcs = {
drivers/gpu/drm/mgag200/mgag200_g200se.c +0 -6
index be4e124102c6..9a26c02c4c79 100644
@@ -323,9 +323,6 @@ static void mgag200_g200se_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 	struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
 	const struct drm_format_info *format = mgag200_crtc_state->format;
 
-	if (funcs->disable_vidrst)
-		funcs->disable_vidrst(mdev);
-
 	mgag200_set_format_regs(mdev, format);
 	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
@@ -340,9 +337,6 @@ static void mgag200_g200se_crtc_helper_atomic_enable(struct drm_crtc *crtc,
 		mgag200_crtc_set_gamma_linear(mdev, format);
 
 	mgag200_enable_display(mdev);
-
-	if (funcs->enable_vidrst)
-		funcs->enable_vidrst(mdev);
 }
 
 static const struct drm_crtc_helper_funcs mgag200_g200se_crtc_helper_funcs = {
drivers/gpu/drm/mgag200/mgag200_mode.c +0 -13
index 4f4612192e30..abf64ffe2158 100644
@@ -654,9 +654,6 @@ void mgag200_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_
 	struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
 	const struct drm_format_info *format = mgag200_crtc_state->format;
 
-	if (funcs->disable_vidrst)
-		funcs->disable_vidrst(mdev);
-
 	mgag200_set_format_regs(mdev, format);
 	mgag200_set_mode_regs(mdev, adjusted_mode, mgag200_crtc_state->set_vidrst);
 
@@ -669,23 +666,13 @@ void mgag200_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_
 		mgag200_crtc_set_gamma_linear(mdev, format);
 
 	mgag200_enable_display(mdev);
-
-	if (funcs->enable_vidrst)
-		funcs->enable_vidrst(mdev);
 }
 
 void mgag200_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_atomic_state *old_state)
 {
 	struct mga_device *mdev = to_mga_device(crtc->dev);
-	const struct mgag200_device_funcs *funcs = mdev->funcs;
-
-	if (funcs->disable_vidrst)
-		funcs->disable_vidrst(mdev);
 
 	mgag200_disable_display(mdev);
-
-	if (funcs->enable_vidrst)
-		funcs->enable_vidrst(mdev);
 }
 
 void mgag200_crtc_reset(struct drm_crtc *crtc)
Signature · 1 line
2.45.2
author maintainer
#10 lore raw

PATCH 4/4 drm/mgag200: Rename BMC vidrst names

In reply to Thomas Zimmermann

The BMC's scanout synchronization is only indirectly related to the VIDRST functionality. Do some renaming.

---
 drivers/gpu/drm/mgag200/mgag200_bmc.c | 14 +++++++-------
 drivers/gpu/drm/mgag200/mgag200_drv.h |  8 ++++----
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/mgag200/mgag200_bmc.c +7 -7
index 74feb6d8db45..a590f564573f 100644
@@ -14,7 +14,7 @@ static struct mgag200_bmc_connector *to_mgag200_bmc_connector(struct drm_connect
 	return container_of(connector, struct mgag200_bmc_connector, base);
 }
 
-static void mgag200_bmc_disable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_stop_scanout(struct mga_device *mdev)
 {
 	u8 tmp;
 	int iter_max;
@@ -78,11 +78,11 @@ static void mgag200_bmc_encoder_helper_atomic_disable(struct drm_encoder *encode
 {
 	struct mga_device *mdev = to_mga_device(encoder->dev);
 
-	if (mdev->info->has_vidrst)
-		mgag200_bmc_disable_vidrst(mdev);
+	if (mdev->info->sync_bmc)
+		mgag200_bmc_stop_scanout(mdev);
 }
 
-static void mgag200_bmc_enable_vidrst(struct mga_device *mdev)
+static void mgag200_bmc_start_scanout(struct mga_device *mdev)
 {
 	u8 tmp;
 
@@ -117,8 +117,8 @@ static void mgag200_bmc_encoder_helper_atomic_enable(struct drm_encoder *encoder
 {
 	struct mga_device *mdev = to_mga_device(encoder->dev);
 
-	if (mdev->info->has_vidrst)
-		mgag200_bmc_enable_vidrst(mdev);
+	if (mdev->info->sync_bmc)
+		mgag200_bmc_start_scanout(mdev);
 }
 
 static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
@@ -128,7 +128,7 @@ static int mgag200_bmc_encoder_helper_atomic_check(struct drm_encoder *encoder,
 	struct mga_device *mdev = to_mga_device(encoder->dev);
 	struct mgag200_crtc_state *mgag200_crtc_state = to_mgag200_crtc_state(crtc_state);
 
-	if (mdev->info->has_vidrst)
+	if (mdev->info->sync_bmc)
 		mgag200_crtc_state->set_vidrst = true;
 	else
 		mgag200_crtc_state->set_vidrst = false;
drivers/gpu/drm/mgag200/mgag200_drv.h +4 -4
index 64ba8a7118dc..cc7bd5f2ed6f 100644
@@ -216,8 +216,8 @@ struct mgag200_device_info {
 	 */
 	unsigned long max_mem_bandwidth;
 
-	/* HW has external source (e.g., BMC) to synchronize with */
-	bool has_vidrst:1;
+	/* Synchronize scanout with BMC */
+	bool sync_bmc:1;
 
 	struct {
 		unsigned data_bit:3;
@@ -232,13 +232,13 @@ struct mgag200_device_info {
 };
 
 #define MGAG200_DEVICE_INFO_INIT(_max_hdisplay, _max_vdisplay, _max_mem_bandwidth, \
-				 _has_vidrst, _i2c_data_bit, _i2c_clock_bit, \
+				 _sync_bmc, _i2c_data_bit, _i2c_clock_bit, \
 				 _bug_no_startadd) \
 	{ \
 		.max_hdisplay = (_max_hdisplay), \
 		.max_vdisplay = (_max_vdisplay), \
 		.max_mem_bandwidth = (_max_mem_bandwidth), \
-		.has_vidrst = (_has_vidrst), \
+		.sync_bmc = (_sync_bmc), \
 		.i2c = { \
 			.data_bit = (_i2c_data_bit), \
 			.clock_bit = (_i2c_clock_bit), \
Signature · 1 line
2.45.2
author maintainer
#11 lore raw
In reply to Thomas Zimmermann

Am 03.07.24 um 15:40 schrieb Thomas Zimmermann:

Quoted 1 line

The VIDRST pin controls CRTC synchronization with an external clock

Jocelyn, see sec 5.6 of the G200 programming manual for details on this.

Quoted 30 lines

chip, such as a BMC or TV encoder. This patchset separates the CRTC state from the BMC state and streamlines the driver code.

Patch one moves the VIDRST programming logic into the CRTC modesetting code. The status of the rsp flag bits is fully controlled by an active BMC encoder. Without BMC, the CRTC ignores VIDRST by default.

During a modeset operation on the CRTC, the BMC has to stop scanning out the display signal. Patch 2 integrates the logic controlling the BMC scanout with the BMC encoder helpers.

Patches 3 and 4 then remove and rename obsolete and unused artifacts within the mgag200 driver.

Thomas Zimmermann (4):
drm/mgag200: Only set VIDRST bits in CRTC modesetting drm/mgag200: Start/stop BMC scanout in BMC encoder helpers drm/mgag200: Remove vidrst callbacks from struct mgag200_device_funcs drm/mgag200: Rename BMC vidrst names

  drivers/gpu/drm/mgag200/mgag200_bmc.c     | 50 +++++++++++++++++++----
  drivers/gpu/drm/mgag200/mgag200_drv.h     | 29 ++++---------
  drivers/gpu/drm/mgag200/mgag200_g200er.c  |  8 +---
  drivers/gpu/drm/mgag200/mgag200_g200ev.c  |  8 +---
  drivers/gpu/drm/mgag200/mgag200_g200ew3.c |  2 -
  drivers/gpu/drm/mgag200/mgag200_g200se.c  |  8 +---
  drivers/gpu/drm/mgag200/mgag200_g200wb.c  |  2 -
  drivers/gpu/drm/mgag200/mgag200_mode.c    | 24 ++++-------
  8 files changed, 62 insertions(+), 69 deletions(-)
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)