Skip to contentSkip to conversation

drm/ast: report connection status on Display Port.

PATCH In review Jocelyn Falempe 3 participants 6 messages Jul 6, 2023 – Jul 10, 2023

Subsystems (4)
lore
Share & tools
lore

Jocelyn Falempe

author reviewer
#0 lore raw

PATCH v2 1/1 drm/ast: report connection status on Display Port.

Aspeed always report the display port as "connected", because it doesn't set a .detect callback.
Fix this by providing the proper detect callback for astdp and dp501.

This also fixes the following regression:
Since commit fae7d186403e ("drm/probe-helper: Default to 640x480 if no
EDID on DP")
The default resolution is now 640x480 when no monitor is connected. But Aspeed graphics is mostly used in servers, where no monitor is attached. This also affects the remote BMC resolution to 640x480, which is inconvenient, and breaks the anaconda installer.

v2: Add .detect callback to the dp/dp501 connector (Jani Nikula)

---
 drivers/gpu/drm/ast/ast_dp.c    |  9 ++++++++
 drivers/gpu/drm/ast/ast_dp501.c | 37 ++++++++++++++++++++++-----------
 drivers/gpu/drm/ast/ast_drv.h   |  2 ++
 drivers/gpu/drm/ast/ast_mode.c  | 24 +++++++++++++++++++++
 4 files changed, 60 insertions(+), 12 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +9 -0
index 6dc1a09504e1..fbc154930fdf 100644
@@ -7,6 +7,15 @@
 #include <drm/drm_print.h>
 #include "ast_drv.h"
 
+bool ast_astdp_is_connected(struct ast_device *ast)
+{
+	if (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, ASTDP_MCU_FW_EXECUTING) &&
+		ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDC, ASTDP_LINK_SUCCESS) &&
+		ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDF, ASTDP_HPD))
+		return true;
+	return false;
+}
+
 int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
 {
 	struct ast_device *ast = to_ast_device(dev);
drivers/gpu/drm/ast/ast_dp501.c +25 -12
index a5d285850ffb..f10d53b0c94f 100644
@@ -272,11 +272,9 @@ static bool ast_launch_m68k(struct drm_device *dev)
 	return true;
 }
 
-bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+bool ast_dp501_is_connected(struct ast_device *ast)
 {
-	struct ast_device *ast = to_ast_device(dev);
-	u32 i, boot_address, offset, data;
-	u32 *pEDIDidx;
+	u32 boot_address, offset, data;
 
 	if (ast->config_mode == ast_use_p2a) {
 		boot_address = get_fw_base(ast);
@@ -292,14 +290,6 @@ bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
 		data = ast_mindwm(ast, boot_address + offset);
 		if (!(data & AST_DP501_PNP_CONNECTED))
 			return false;
-
-		/* Read EDID */
-		offset = AST_DP501_EDID_DATA;
-		for (i = 0; i < 128; i += 4) {
-			data = ast_mindwm(ast, boot_address + offset + i);
-			pEDIDidx = (u32 *)(ediddata + i);
-			*pEDIDidx = data;
-		}
 	} else {
 		if (!ast->dp501_fw_buf)
 			return false;
@@ -319,7 +309,30 @@ bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
 		data = readl(ast->dp501_fw_buf + offset);
 		if (!(data & AST_DP501_PNP_CONNECTED))
 			return false;
+	}
+	return true;
+}
+
+bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+{
+	struct ast_device *ast = to_ast_device(dev);
+	u32 i, boot_address, offset, data;
+	u32 *pEDIDidx;
+
+	if (!ast_dp501_is_connected(ast))
+		return false;
+
+	if (ast->config_mode == ast_use_p2a) {
+		boot_address = get_fw_base(ast);
 
+		/* Read EDID */
+		offset = AST_DP501_EDID_DATA;
+		for (i = 0; i < 128; i += 4) {
+			data = ast_mindwm(ast, boot_address + offset + i);
+			pEDIDidx = (u32 *)(ediddata + i);
+			*pEDIDidx = data;
+		}
+	} else {
 		/* Read EDID */
 		offset = AST_DP501_EDID_DATA;
 		for (i = 0; i < 128; i += 4) {
drivers/gpu/drm/ast/ast_drv.h +2 -0
index 3f6e0c984523..99a24d779b9c 100644
@@ -510,6 +510,7 @@ void ast_patch_ahb_2500(struct ast_device *ast);
 /* ast dp501 */
 void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
 bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size);
+bool ast_dp501_is_connected(struct ast_device *ast);
 bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata);
 u8 ast_get_dp501_max_clk(struct drm_device *dev);
 void ast_init_3rdtx(struct drm_device *dev);
@@ -518,6 +519,7 @@ void ast_init_3rdtx(struct drm_device *dev);
 struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev);
 
 /* aspeed DP */
+bool ast_astdp_is_connected(struct ast_device *ast);
 int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata);
 void ast_dp_launch(struct drm_device *dev);
 void ast_dp_power_on_off(struct drm_device *dev, bool no);
drivers/gpu/drm/ast/ast_mode.c +24 -0
index f711d592da52..ccf48d57d239 100644
@@ -1586,12 +1586,24 @@ static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs
 	.get_modes = ast_dp501_connector_helper_get_modes,
 };
 
+static enum drm_connector_status ast_dp501_connector_helper_detect(
+	struct drm_connector *connector,
+	bool force)
+{
+	struct ast_device *ast = to_ast_device(connector->dev);
+
+	if (ast_dp501_is_connected(ast))
+		return connector_status_connected;
+	return connector_status_disconnected;
+}
+
 static const struct drm_connector_funcs ast_dp501_connector_funcs = {
 	.reset = drm_atomic_helper_connector_reset,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = drm_connector_cleanup,
 	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+	.detect = ast_dp501_connector_helper_detect,
 };
 
 static int ast_dp501_connector_init(struct drm_device *dev, struct drm_connector *connector)
@@ -1684,12 +1696,24 @@ static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs
 	.get_modes = ast_astdp_connector_helper_get_modes,
 };
 
+static enum drm_connector_status ast_astdp_connector_helper_detect(
+	struct drm_connector *connector,
+	bool force)
+{
+	struct ast_device *ast = to_ast_device(connector->dev);
+
+	if (ast_astdp_is_connected(ast))
+		return connector_status_connected;
+	return connector_status_disconnected;
+}
+
 static const struct drm_connector_funcs ast_astdp_connector_funcs = {
 	.reset = drm_atomic_helper_connector_reset,
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.destroy = drm_connector_cleanup,
 	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+	.detect = ast_astdp_connector_helper_detect,
 };
 
 static int ast_astdp_connector_init(struct drm_device *dev, struct drm_connector *connector)

base-commit: b32d5a51f3c21843011d68a58e6ac0b897bce9f2

Signature · 1 line
2.41.0
#1 lore raw
Quoted 12 lines · Jocelyn Falempe

Aspeed always report the display port as "connected", because it doesn't set a .detect callback.
Fix this by providing the proper detect callback for astdp and dp501.

This also fixes the following regression:
Since commit fae7d186403e ("drm/probe-helper: Default to 640x480 if no
EDID on DP")
The default resolution is now 640x480 when no monitor is connected. But Aspeed graphics is mostly used in servers, where no monitor is attached. This also affects the remote BMC resolution to 640x480, which is inconvenient, and breaks the anaconda installer.

Quoted 3 lines

v2: Add .detect callback to the dp/dp501 connector (Jani Nikula)

So if this "also fixes a regression" how about a Fixes: tag and a CC:
<stable tag to ensure this is not only fixed in latest mainline, but also in all affected stable and longterm kernels?

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) --
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
If I did something stupid, please tell me, as explained on that page.

author reviewer
#2 lore raw
Quoted 13 lines · Linux regression tracking (Thorsten Leemhuis)
Quoted 12 lines · Jocelyn Falempe

Aspeed always report the display port as "connected", because it doesn't set a .detect callback.
Fix this by providing the proper detect callback for astdp and dp501.

This also fixes the following regression:
Since commit fae7d186403e ("drm/probe-helper: Default to 640x480 if no
EDID on DP")
The default resolution is now 640x480 when no monitor is connected. But Aspeed graphics is mostly used in servers, where no monitor is attached. This also affects the remote BMC resolution to 640x480, which is inconvenient, and breaks the anaconda installer.

Quoted 7 lines
Quoted 3 lines

v2: Add .detect callback to the dp/dp501 connector (Jani Nikula)

So if this "also fixes a regression" how about a Fixes: tag and a CC:
<stable tag to ensure this is not only fixed in latest mainline, but also in all affected stable and longterm kernels?

In this case, the regression only affect one userspace program (anaconda), and the fix looks too risky to backport to all stable kernels. I've to prepare a v3, as this one breaks on hardware were there is only one Display Port connector and no VGA connector.

Quoted 7 lines

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) --
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
If I did something stupid, please tell me, as explained on that page.

Best regards,

Signature · 1 line
Jocelyn
#3 lore raw
Quoted 16 lines · Jocelyn Falempe
Quoted 15 lines · Linux regression tracking (Thorsten Leemhuis)
Quoted 14 lines · Jocelyn Falempe

Aspeed always report the display port as "connected", because it doesn't set a .detect callback.
Fix this by providing the proper detect callback for astdp and dp501.

This also fixes the following regression:
Since commit fae7d186403e ("drm/probe-helper: Default to 640x480 if no EDID on DP")
The default resolution is now 640x480 when no monitor is connected. But Aspeed graphics is mostly used in servers, where no monitor is attached. This also affects the remote BMC resolution to 640x480, which is inconvenient, and breaks the anaconda installer.

v2: Add .detect callback to the dp/dp501 connector (Jani Nikula)

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

So if this "also fixes a regression" how about a Fixes: tag and a CC:
<stable tag to ensure this is not only fixed in latest mainline, but also in all affected stable and longterm kernels?

In this case, the regression only affect one userspace program (anaconda),

That is (mostly) irrelevant when it comes to regressions.

Quoted 1 line

and the fix looks too risky to backport to all stable kernels.

Not sure, but I tend to thing that decision would better be left to the stable team. Each developer will have a different opinion about what's too risky or not and they might be in the better position to judge what they want for their trees. A "Fixes:" tag thus still seems appropriate here; will also tell downstream distros that might want to pick this up.

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) --
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
If I did something stupid, please tell me, as explained on that page.

#4 lore raw
In reply to Jocelyn Falempe

Hi Jocelyn

Am 06.07.23 um 11:58 schrieb Jocelyn Falempe:

Quoted 11 lines

Aspeed always report the display port as "connected", because it doesn't set a .detect callback.
Fix this by providing the proper detect callback for astdp and dp501.

This also fixes the following regression:
Since commit fae7d186403e ("drm/probe-helper: Default to 640x480 if no
EDID on DP")
The default resolution is now 640x480 when no monitor is connected. But Aspeed graphics is mostly used in servers, where no monitor is attached. This also affects the remote BMC resolution to 640x480, which is inconvenient, and breaks the anaconda installer.

The formating of these paraghraphs looks off.

Quoted 4 lines

v2: Add .detect callback to the dp/dp501 connector (Jani Nikula)

Maybe add Fixes with the patch that added the DP default resolution. It's not really correct, but at least tells people to consider your patch.

I assume that you'll send another patch with the BMC connector?

Quoted 12 lines
---
  drivers/gpu/drm/ast/ast_dp.c    |  9 ++++++++
  drivers/gpu/drm/ast/ast_dp501.c | 37 ++++++++++++++++++++++-----------
  drivers/gpu/drm/ast/ast_drv.h   |  2 ++
  drivers/gpu/drm/ast/ast_mode.c  | 24 +++++++++++++++++++++
  4 files changed, 60 insertions(+), 12 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +0 -0
index 6dc1a09504e1..fbc154930fdf 100644

drivers/gpu/drm/ast/ast_dp.c line 14

Quoted 8 lines
drivers/gpu/drm/ast/ast_dp.c +5 -0
@@ -7,6 +7,15 @@
  #include <drm/drm_print.h>
  #include "ast_drv.h"
 
+bool ast_astdp_is_connected(struct ast_device *ast)
+{
+	if (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, ASTDP_MCU_FW_EXECUTING) &&
+		ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDC, ASTDP_LINK_SUCCESS) &&
+		ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDF, ASTDP_HPD))

The indention of those two lines is off.

You could also rewrite this as

if (!a)
return false;
if (!b)
return false;
if (!c)
return false;
return true;

Quoted 99 lines
drivers/gpu/drm/ast/ast_dp.c +4 -0
+		return true;
+	return false;
+}
+
  int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
  {
  	struct ast_device *ast = to_ast_device(dev);
drivers/gpu/drm/ast/ast_dp501.c +25 -12
index a5d285850ffb..f10d53b0c94f 100644
@@ -272,11 +272,9 @@ static bool ast_launch_m68k(struct drm_device *dev)
  	return true;
  }
 
-bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+bool ast_dp501_is_connected(struct ast_device *ast)
  {
-	struct ast_device *ast = to_ast_device(dev);
-	u32 i, boot_address, offset, data;
-	u32 *pEDIDidx;
+	u32 boot_address, offset, data;
 
  	if (ast->config_mode == ast_use_p2a) {
  		boot_address = get_fw_base(ast);
@@ -292,14 +290,6 @@ bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
  		data = ast_mindwm(ast, boot_address + offset);
  		if (!(data & AST_DP501_PNP_CONNECTED))
  			return false;
-
-		/* Read EDID */
-		offset = AST_DP501_EDID_DATA;
-		for (i = 0; i < 128; i += 4) {
-			data = ast_mindwm(ast, boot_address + offset + i);
-			pEDIDidx = (u32 *)(ediddata + i);
-			*pEDIDidx = data;
-		}
  	} else {
  		if (!ast->dp501_fw_buf)
  			return false;
@@ -319,7 +309,30 @@ bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
  		data = readl(ast->dp501_fw_buf + offset);
  		if (!(data & AST_DP501_PNP_CONNECTED))
  			return false;
+	}
+	return true;
+}
+
+bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+{
+	struct ast_device *ast = to_ast_device(dev);
+	u32 i, boot_address, offset, data;
+	u32 *pEDIDidx;
+
+	if (!ast_dp501_is_connected(ast))
+		return false;
+
+	if (ast->config_mode == ast_use_p2a) {
+		boot_address = get_fw_base(ast);
 
+		/* Read EDID */
+		offset = AST_DP501_EDID_DATA;
+		for (i = 0; i < 128; i += 4) {
+			data = ast_mindwm(ast, boot_address + offset + i);
+			pEDIDidx = (u32 *)(ediddata + i);
+			*pEDIDidx = data;
+		}
+	} else {
  		/* Read EDID */
  		offset = AST_DP501_EDID_DATA;
  		for (i = 0; i < 128; i += 4) {
drivers/gpu/drm/ast/ast_drv.h +2 -0
index 3f6e0c984523..99a24d779b9c 100644
@@ -510,6 +510,7 @@ void ast_patch_ahb_2500(struct ast_device *ast);
  /* ast dp501 */
  void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
  bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size);
+bool ast_dp501_is_connected(struct ast_device *ast);
  bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata);
  u8 ast_get_dp501_max_clk(struct drm_device *dev);
  void ast_init_3rdtx(struct drm_device *dev);
@@ -518,6 +519,7 @@ void ast_init_3rdtx(struct drm_device *dev);
  struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev);
 
  /* aspeed DP */
+bool ast_astdp_is_connected(struct ast_device *ast);
  int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata);
  void ast_dp_launch(struct drm_device *dev);
  void ast_dp_power_on_off(struct drm_device *dev, bool no);
drivers/gpu/drm/ast/ast_mode.c +0 -0
index f711d592da52..ccf48d57d239 100644
@@ -1586,12 +1586,24 @@ static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs
  	.get_modes = ast_dp501_connector_helper_get_modes,
  };
 

drivers/gpu/drm/ast/ast_mode.c static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs · line 1598

Quoted 10 lines
drivers/gpu/drm/ast/ast_mode.c +10 -0
+static enum drm_connector_status ast_dp501_connector_helper_detect(
+	struct drm_connector *connector,
+	bool force)
+{
+	struct ast_device *ast = to_ast_device(connector->dev);
+
+	if (ast_dp501_is_connected(ast))
+		return connector_status_connected;
+	return connector_status_disconnected;
+}

It seems more appropriate to implement this as connector helper func detect_ctx. It does the same in practice, but the detect funtionality is rather part of the helpers.

drivers/gpu/drm/ast/ast_mode.c static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs · line 1606

Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c +2 -0
+
  static const struct drm_connector_funcs ast_dp501_connector_funcs = {
  	.reset = drm_atomic_helper_connector_reset,
  	.fill_modes = drm_helper_probe_single_connector_modes,
  	.destroy = drm_connector_cleanup,
  	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+	.detect = ast_dp501_connector_helper_detect,

That might sound pedantic, but I'd prefer to have the assignments sorted as in the struct's definiation. :) So .detect would be set just below .reset.

Quoted 15 lines
drivers/gpu/drm/ast/ast_mode.c +8 -0
  };
 
  static int ast_dp501_connector_init(struct drm_device *dev, struct drm_connector *connector)
@@ -1684,12 +1696,24 @@ static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs
  	.get_modes = ast_astdp_connector_helper_get_modes,
  };
 
+static enum drm_connector_status ast_astdp_connector_helper_detect(
+	struct drm_connector *connector,
+	bool force)
+{
+	struct ast_device *ast = to_ast_device(connector->dev);
+
+	if (ast_astdp_is_connected(ast))
+		return connector_status_connected;

drivers/gpu/drm/ast/ast_mode.c static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs · line 1716

Quoted 10 lines
drivers/gpu/drm/ast/ast_mode.c +4 -0
+	return connector_status_disconnected;
+}
+
  static const struct drm_connector_funcs ast_astdp_connector_funcs = {
  	.reset = drm_atomic_helper_connector_reset,
  	.fill_modes = drm_helper_probe_single_connector_modes,
  	.destroy = drm_connector_cleanup,
  	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+	.detect = ast_astdp_connector_helper_detect,

Same here.

Best regards
Thomas

Quoted 5 lines
drivers/gpu/drm/ast/ast_mode.c +0 -0
  };
 
  static int ast_astdp_connector_init(struct drm_device *dev, struct drm_connector *connector)

base-commit: b32d5a51f3c21843011d68a58e6ac0b897bce9f2

Signature · 6 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 reviewer
#5 lore raw
Quoted 15 lines · Thomas Zimmermann

Hi Jocelyn

Am 06.07.23 um 11:58 schrieb Jocelyn Falempe:

Quoted 11 lines

Aspeed always report the display port as "connected", because it doesn't set a .detect callback.
Fix this by providing the proper detect callback for astdp and dp501.

This also fixes the following regression:
Since commit fae7d186403e ("drm/probe-helper: Default to 640x480 if no EDID on DP")
The default resolution is now 640x480 when no monitor is connected. But Aspeed graphics is mostly used in servers, where no monitor is attached. This also affects the remote BMC resolution to 640x480, which is inconvenient, and breaks the anaconda installer.

Quoted 1 line

The formating of these paraghraphs looks off.

Ok

Quoted 9 lines
Quoted 5 lines

v2: Add .detect callback to the dp/dp501 connector (Jani Nikula)

Maybe add Fixes with the patch that added the DP default resolution. It's not really correct, but at least tells people to consider your patch.

I assume that you'll send another patch with the BMC connector?

Yes, this patch alone will break more systems than what it tries to fix.

Quoted 27 lines
Quoted 18 lines

---
  drivers/gpu/drm/ast/ast_dp.c    |  9 ++++++++ drivers/gpu/drm/ast/ast_dp501.c | 37 ++++++++++++++++++++++----------- drivers/gpu/drm/ast/ast_drv.h   |  2 ++ drivers/gpu/drm/ast/ast_mode.c  | 24 +++++++++++++++++++++

  4 files changed, 60 insertions(+), 12 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +3 -0
index 6dc1a09504e1..fbc154930fdf 100644
@@ -7,6 +7,15 @@
   #include <drm/drm_print.h>
   #include "ast_drv.h"
+bool ast_astdp_is_connected(struct ast_device *ast)
+{
+    if (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, 
Quoted 4 lines

ASTDP_MCU_FW_EXECUTING) &&
+        ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDC, ASTDP_LINK_SUCCESS) &&
+        ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xDF, ASTDP_HPD))

The indention of those two lines is off.

You could also rewrite this as

Quoted 7 lines

 if (!a)
   return false;
 if (!b)
   return false;
 if (!c)
   return false;
 return true;

ok

Quoted 102 lines
Quoted 102 lines

+        return true;
+    return false;

drivers/gpu/drm/ast/ast_dp.c +2 -0
+}
+

  int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata) {
      struct ast_device *ast = to_ast_device(dev);

drivers/gpu/drm/ast/ast_dp501.c +2 -12
index a5d285850ffb..f10d53b0c94f 100644
@@ -272,11 +272,9 @@ static bool ast_launch_m68k(struct drm_device *dev)
       return true;
   }
-bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+bool ast_dp501_is_connected(struct ast_device *ast)
   {
-    struct ast_device *ast = to_ast_device(dev);
-    u32 i, boot_address, offset, data;
-    u32 *pEDIDidx;
+    u32 boot_address, offset, data;
       if (ast->config_mode == ast_use_p2a) {
           boot_address = get_fw_base(ast);
@@ -292,14 +290,6 @@ bool ast_dp501_read_edid(struct drm_device *dev, 
 u8 *ediddata)
           data = ast_mindwm(ast, boot_address + offset);
           if (!(data & AST_DP501_PNP_CONNECTED))
               return false;
-
-        /* Read EDID */
-        offset = AST_DP501_EDID_DATA;
-        for (i = 0; i < 128; i += 4) {
-            data = ast_mindwm(ast, boot_address + offset + i);
-            pEDIDidx = (u32 *)(ediddata + i);
-            *pEDIDidx = data;
-        }
       } else {
           if (!ast->dp501_fw_buf)

              return false;

drivers/gpu/drm/ast/ast_dp501.c +23 -0
@@ -319,7 +309,30 @@ bool ast_dp501_read_edid(struct drm_device *dev, 
 u8 *ediddata)
           data = readl(ast->dp501_fw_buf + offset);
           if (!(data & AST_DP501_PNP_CONNECTED))
               return false;
+    }
+    return true;
+}
+
+bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+{
+    struct ast_device *ast = to_ast_device(dev);
+    u32 i, boot_address, offset, data;
+    u32 *pEDIDidx;
+
+    if (!ast_dp501_is_connected(ast))
+        return false;
+
+    if (ast->config_mode == ast_use_p2a) {
+        boot_address = get_fw_base(ast);
+        /* Read EDID */
+        offset = AST_DP501_EDID_DATA;
+        for (i = 0; i < 128; i += 4) {
+            data = ast_mindwm(ast, boot_address + offset + i);
+            pEDIDidx = (u32 *)(ediddata + i);
+            *pEDIDidx = data;
+        }
+    } else {
           /* Read EDID */
           offset = AST_DP501_EDID_DATA;
           for (i = 0; i < 128; i += 4) {
drivers/gpu/drm/ast/ast_drv.h +2 -0
index 3f6e0c984523..99a24d779b9c 100644
@@ -510,6 +510,7 @@ void ast_patch_ahb_2500(struct ast_device *ast);
   /* ast dp501 */
   void ast_set_dp501_video_output(struct drm_device *dev, u8 mode);
   bool ast_backup_fw(struct drm_device *dev, u8 *addr, u32 size);
+bool ast_dp501_is_connected(struct ast_device *ast);
   bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata);
   u8 ast_get_dp501_max_clk(struct drm_device *dev);
   void ast_init_3rdtx(struct drm_device *dev);
@@ -518,6 +519,7 @@ void ast_init_3rdtx(struct drm_device *dev);
   struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev);
   /* aspeed DP */
+bool ast_astdp_is_connected(struct ast_device *ast);
   int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata);
   void ast_dp_launch(struct drm_device *dev);
   void ast_dp_power_on_off(struct drm_device *dev, bool no);
drivers/gpu/drm/ast/ast_mode.c +0 -0
index f711d592da52..ccf48d57d239 100644
@@ -1586,12 +1586,24 @@ static const struct drm_connector_helper_funcs 

ast_dp501_connector_helper_funcs
      .get_modes = ast_dp501_connector_helper_get_modes, };

drivers/gpu/drm/ast/ast_mode.c +4 -0
+static enum drm_connector_status ast_dp501_connector_helper_detect(
+    struct drm_connector *connector,
+    bool force)
+{
Quoted 8 lines

drivers/gpu/drm/ast/ast_mode.c static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs · line 1598

Quoted 6 lines

+    struct ast_device *ast = to_ast_device(connector->dev);

drivers/gpu/drm/ast/ast_mode.c +5 -0
+
+    if (ast_dp501_is_connected(ast))
+        return connector_status_connected;
+    return connector_status_disconnected;
+}

It seems more appropriate to implement this as connector helper func detect_ctx. It does the same in practice, but the detect funtionality is rather part of the helpers.

ok, it looks easy to switch to detect_ctx().

Quoted 11 lines
Quoted 9 lines

+
  static const struct drm_connector_funcs ast_dp501_connector_funcs = { .reset = drm_atomic_helper_connector_reset,
      .fill_modes = drm_helper_probe_single_connector_modes, .destroy = drm_connector_cleanup,
      .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +    .detect = ast_dp501_connector_helper_detect,

That might sound pedantic, but I'd prefer to have the assignments sorted as in the struct's definiation. :) So .detect would be set just below .reset.

ok, I was wondering what the order was, as it was not alphabetically.

Quoted 28 lines
Quoted 18 lines

  };
  static int ast_dp501_connector_init(struct drm_device *dev, struct drm_connector *connector)

drivers/gpu/drm/ast/ast_mode.c +0 -0
@@ -1684,12 +1696,24 @@ static const struct drm_connector_helper_funcs 

ast_astdp_connector_helper_funcs
      .get_modes = ast_astdp_connector_helper_get_modes, };

drivers/gpu/drm/ast/ast_mode.c +11 -0
+static enum drm_connector_status ast_astdp_connector_helper_detect(
+    struct drm_connector *connector,
+    bool force)
+{
+    struct ast_device *ast = to_ast_device(connector->dev);
+
+    if (ast_astdp_is_connected(ast))
+        return connector_status_connected;
+    return connector_status_disconnected;
+}
+
Quoted 7 lines

  static const struct drm_connector_funcs ast_astdp_connector_funcs = { .reset = drm_atomic_helper_connector_reset,
      .fill_modes = drm_helper_probe_single_connector_modes, .destroy = drm_connector_cleanup,
      .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +    .detect = ast_astdp_connector_helper_detect,

Same here.

Quoted 8 lines

Best regards
Thomas

Quoted 4 lines

  };
  static int ast_astdp_connector_init(struct drm_device *dev, struct drm_connector *connector)

base-commit: b32d5a51f3c21843011d68a58e6ac0b897bce9f2

Thanks for your review.
I will try to add a virtual BMC connector, and send a v3.

Signature · 1 line
Jocelyn