Skip to contentSkip to conversation

drm/ast: Transparently handle BMC in outputs

PATCH In review Thomas Zimmermann 2 participants 14 messages Aug 15, 2024 – Aug 19, 2024

Subsystems (3)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

v3 cover drm/ast: Transparently handle BMC in outputs

Add transparent BMC support to all outputs. If the user disconnects the physical display, each output will now return display modes for the BMC. Makes the BMC connector obsolete, so remove it.

The benefit of the new approach is that is works with any userspace. Most userspace compositors have problems configuring the current BMC connector. The BMC connector is now gone and only a physical connector is present.

Also clean up some of the EDID handling in preparation. Switching to struct drm_edid and its helpers simplifies the code for inclusion of the BMC support.

A similar approach has been taken for mgag200. [1] Here a server's display hardware also contains an internal BMC that needs to display even without the presence of a physical display.

v3:
- track physical connector status in struct ast_connector v2:
- fix reading EDID data on ASTDP and DP501 chips (Jocelyn)

[1] https://patchwork.freedesktop.org/series/136885/

Thomas Zimmermann (11):
drm/ast: Move code for physical outputs into separate files drm/ast: Add struct ast_connector
drm/ast: astdp: Move locking into EDID helper drm/ast: astdp: Use struct drm_edid and helpers drm/ast: astdp: Simplify power management when detecting display drm/ast: astdp: Transparently handle BMC support drm/ast: dp501: Use struct drm_edid and helpers drm/ast: dp501: Transparently handle BMC support drm/ast: sil164: Transparently handle BMC support drm/ast: vga: Transparently handle BMC support drm/ast: Remove BMC output

 drivers/gpu/drm/ast/Makefile     |   4 +-
 drivers/gpu/drm/ast/ast_dp.c     | 242 ++++++++++++-
 drivers/gpu/drm/ast/ast_dp501.c  | 184 ++++++++--
 drivers/gpu/drm/ast/ast_drv.h    |  42 +--
 drivers/gpu/drm/ast/ast_mode.c   | 578 -------------------------------
 drivers/gpu/drm/ast/ast_sil164.c | 127 +++++++
 drivers/gpu/drm/ast/ast_vga.c    | 127 +++++++
 7 files changed, 667 insertions(+), 637 deletions(-)
 create mode 100644 drivers/gpu/drm/ast/ast_sil164.c
 create mode 100644 drivers/gpu/drm/ast/ast_vga.c
Signature · 1 line
2.46.0
author maintainer
#1 lore raw

PATCH v3 1/11 drm/ast: Move code for physical outputs into separate files

Move the modesetting code for the various transmitter chips into their own source files before adding BMC support. No functional changes.

---
 drivers/gpu/drm/ast/Makefile     |   4 +-
 drivers/gpu/drm/ast/ast_dp.c     | 214 +++++++++++++-
 drivers/gpu/drm/ast/ast_dp501.c  | 141 ++++++++-
 drivers/gpu/drm/ast/ast_drv.h    |  17 +-
 drivers/gpu/drm/ast/ast_mode.c   | 471 -------------------------------
 drivers/gpu/drm/ast/ast_sil164.c |  88 ++++++
 drivers/gpu/drm/ast/ast_vga.c    |  88 ++++++
 7 files changed, 530 insertions(+), 493 deletions(-)
 create mode 100644 drivers/gpu/drm/ast/ast_sil164.c
 create mode 100644 drivers/gpu/drm/ast/ast_vga.c
drivers/gpu/drm/ast/Makefile +3 -1
index d794c076bc24..47da848fa3fc 100644
@@ -11,6 +11,8 @@ ast-y := \
 	ast_main.o \
 	ast_mm.o \
 	ast_mode.o \
-	ast_post.o
+	ast_post.o \
+	ast_sil164.o \
+	ast_vga.o
 
 obj-$(CONFIG_DRM_AST) := ast.o
drivers/gpu/drm/ast/ast_dp.c +207 -7

262 lines not on this page · raw message

drivers/gpu/drm/ast/ast_dp501.c +138 -3

168 lines not on this page · raw message

drivers/gpu/drm/ast/ast_drv.h +6 -11
index d23b98ce4359..3a4f80cb5c0f 100644
@@ -460,22 +460,17 @@ void ast_post_gpu(struct drm_device *dev);
 u32 ast_mindwm(struct ast_device *ast, u32 r);
 void ast_moutdwm(struct ast_device *ast, u32 r, u32 v);
 void ast_patch_ahb_2500(void __iomem *regs);
+
+int ast_vga_output_init(struct ast_device *ast);
+int ast_sil164_output_init(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);
+int ast_dp501_output_init(struct ast_device *ast);
 
 /* aspeed DP */
-bool ast_astdp_is_connected(struct ast_device *ast);
-int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata);
 int ast_dp_launch(struct ast_device *ast);
-bool ast_dp_power_is_on(struct ast_device *ast);
-void ast_dp_power_on_off(struct drm_device *dev, bool no);
-void ast_dp_link_training(struct ast_device *ast);
-void ast_dp_set_on_off(struct drm_device *dev, bool no);
-void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *vbios_mode);
+int ast_astdp_output_init(struct ast_device *ast);
 
 #endif
drivers/gpu/drm/ast/ast_mode.c +0 -471

483 lines not on this page · raw message

drivers/gpu/drm/ast/ast_sil164.c new file +88 -0

88 lines not on this page · raw message

drivers/gpu/drm/ast/ast_vga.c new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
2.46.0
author maintainer
#2 lore raw

PATCH v3 2/11 drm/ast: Add struct ast_connector

In reply to Thomas Zimmermann

Add struct ast_connector to track a connector's physical status. With the upcoming BMC support, the physical status can be different from the reported status.

---
 drivers/gpu/drm/ast/ast_dp.c     |  7 ++++++-
 drivers/gpu/drm/ast/ast_dp501.c  | 11 +++++++++--
 drivers/gpu/drm/ast/ast_drv.h    | 24 ++++++++++++++++++++----
 drivers/gpu/drm/ast/ast_mode.c   |  8 ++++----
 drivers/gpu/drm/ast/ast_sil164.c | 20 ++++++++++++++++++--
 drivers/gpu/drm/ast/ast_vga.c    | 20 ++++++++++++++++++--
 6 files changed, 75 insertions(+), 15 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +6 -1
index 549c823c9529..c7f0f9b5dc3a 100644
@@ -364,6 +364,7 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
 						 struct drm_modeset_acquire_ctx *ctx,
 						 bool force)
 {
+	struct ast_connector *ast_connector = to_ast_connector(connector);
 	struct drm_device *dev = connector->dev;
 	struct ast_device *ast = to_ast_device(connector->dev);
 	enum drm_connector_status status = connector_status_disconnected;
@@ -392,6 +393,8 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
 
 	mutex_unlock(&ast->modeset_lock);
 
+	ast_connector->physical_status = status;
+
 	return status;
 }
 
@@ -432,7 +435,8 @@ int ast_astdp_output_init(struct ast_device *ast)
 	struct drm_device *dev = &ast->base;
 	struct drm_crtc *crtc = &ast->crtc;
 	struct drm_encoder *encoder = &ast->output.astdp.encoder;
-	struct drm_connector *connector = &ast->output.astdp.connector;
+	struct ast_connector *ast_connector = &ast->output.astdp.connector;
+	struct drm_connector *connector = &ast_connector->base;
 	int ret;
 
 	ret = drm_encoder_init(dev, encoder, &ast_astdp_encoder_funcs,
@@ -446,6 +450,7 @@ int ast_astdp_output_init(struct ast_device *ast)
 	ret = ast_astdp_connector_init(dev, connector);
 	if (ret)
 		return ret;
+	ast_connector->physical_status = connector->status;
 
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret)
drivers/gpu/drm/ast/ast_dp501.c +9 -2
index 478efa226170..3904f98ef846 100644
@@ -540,11 +540,16 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector
 						 struct drm_modeset_acquire_ctx *ctx,
 						 bool force)
 {
+	struct ast_connector *ast_connector = to_ast_connector(connector);
 	struct ast_device *ast = to_ast_device(connector->dev);
+	enum drm_connector_status status = connector_status_disconnected;
 
 	if (ast_dp501_is_connected(ast))
 		return connector_status_connected;
-	return connector_status_disconnected;
+
+	ast_connector->physical_status = status;
+
+	return status;
 }
 
 static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = {
@@ -584,7 +589,8 @@ int ast_dp501_output_init(struct ast_device *ast)
 	struct drm_device *dev = &ast->base;
 	struct drm_crtc *crtc = &ast->crtc;
 	struct drm_encoder *encoder = &ast->output.dp501.encoder;
-	struct drm_connector *connector = &ast->output.dp501.connector;
+	struct ast_connector *ast_connector = &ast->output.dp501.connector;
+	struct drm_connector *connector = &ast_connector->base;
 	int ret;
 
 	ret = drm_encoder_init(dev, encoder, &ast_dp501_encoder_funcs,
@@ -598,6 +604,7 @@ int ast_dp501_output_init(struct ast_device *ast)
 	ret = ast_dp501_connector_init(dev, connector);
 	if (ret)
 		return ret;
+	ast_connector->physical_status = connector->status;
 
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret)
drivers/gpu/drm/ast/ast_drv.h +20 -4
index 3a4f80cb5c0f..b29625d45a11 100644
@@ -146,6 +146,22 @@ static inline struct ast_plane *to_ast_plane(struct drm_plane *plane)
 	return container_of(plane, struct ast_plane, base);
 }
 
+/*
+ * Connector
+ */
+
+struct ast_connector {
+	struct drm_connector base;
+
+	enum drm_connector_status physical_status;
+};
+
+static inline struct ast_connector *
+to_ast_connector(struct drm_connector *connector)
+{
+	return container_of(connector, struct ast_connector, base);
+}
+
 /*
  * BMC
  */
@@ -192,19 +208,19 @@ struct ast_device {
 	struct {
 		struct {
 			struct drm_encoder encoder;
-			struct drm_connector connector;
+			struct ast_connector connector;
 		} vga;
 		struct {
 			struct drm_encoder encoder;
-			struct drm_connector connector;
+			struct ast_connector connector;
 		} sil164;
 		struct {
 			struct drm_encoder encoder;
-			struct drm_connector connector;
+			struct ast_connector connector;
 		} dp501;
 		struct {
 			struct drm_encoder encoder;
-			struct drm_connector connector;
+			struct ast_connector connector;
 		} astdp;
 		struct {
 			struct drm_encoder encoder;
drivers/gpu/drm/ast/ast_mode.c +4 -4
index d823e9d85b04..8ce1637268e1 100644
@@ -1502,25 +1502,25 @@ int ast_mode_config_init(struct ast_device *ast)
 		ret = ast_vga_output_init(ast);
 		if (ret)
 			return ret;
-		physical_connector = &ast->output.vga.connector;
+		physical_connector = &ast->output.vga.connector.base;
 	}
 	if (ast->tx_chip_types & AST_TX_SIL164_BIT) {
 		ret = ast_sil164_output_init(ast);
 		if (ret)
 			return ret;
-		physical_connector = &ast->output.sil164.connector;
+		physical_connector = &ast->output.sil164.connector.base;
 	}
 	if (ast->tx_chip_types & AST_TX_DP501_BIT) {
 		ret = ast_dp501_output_init(ast);
 		if (ret)
 			return ret;
-		physical_connector = &ast->output.dp501.connector;
+		physical_connector = &ast->output.dp501.connector.base;
 	}
 	if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
 		ret = ast_astdp_output_init(ast);
 		if (ret)
 			return ret;
-		physical_connector = &ast->output.astdp.connector;
+		physical_connector = &ast->output.astdp.connector.base;
 	}
 	ret = ast_bmc_output_init(ast, physical_connector);
 	if (ret)
drivers/gpu/drm/ast/ast_sil164.c +18 -2
index 6e17d84f994e..05f991aa34ca 100644
@@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = {
  * Connector
  */
 
+static int ast_sil164_connector_helper_detect_ctx(struct drm_connector *connector,
+						  struct drm_modeset_acquire_ctx *ctx,
+						  bool force)
+{
+	struct ast_connector *ast_connector = to_ast_connector(connector);
+	enum drm_connector_status status;
+
+	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
+
+	ast_connector->physical_status = status;
+
+	return status;
+}
+
 static const struct drm_connector_helper_funcs ast_sil164_connector_helper_funcs = {
 	.get_modes = drm_connector_helper_get_modes,
-	.detect_ctx = drm_connector_helper_detect_from_ddc,
+	.detect_ctx = ast_sil164_connector_helper_detect_ctx,
 };
 
 static const struct drm_connector_funcs ast_sil164_connector_funcs = {
@@ -67,7 +81,8 @@ int ast_sil164_output_init(struct ast_device *ast)
 	struct drm_device *dev = &ast->base;
 	struct drm_crtc *crtc = &ast->crtc;
 	struct drm_encoder *encoder = &ast->output.sil164.encoder;
-	struct drm_connector *connector = &ast->output.sil164.connector;
+	struct ast_connector *ast_connector = &ast->output.sil164.connector;
+	struct drm_connector *connector = &ast_connector->base;
 	int ret;
 
 	ret = drm_encoder_init(dev, encoder, &ast_sil164_encoder_funcs,
@@ -79,6 +94,7 @@ int ast_sil164_output_init(struct ast_device *ast)
 	ret = ast_sil164_connector_init(dev, connector);
 	if (ret)
 		return ret;
+	ast_connector->physical_status = connector->status;
 
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret)
drivers/gpu/drm/ast/ast_vga.c +18 -2
index 2ea0763844f3..fdbd0daca7dc 100644
@@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = {
  * Connector
  */
 
+static int ast_vga_connector_helper_detect_ctx(struct drm_connector *connector,
+					       struct drm_modeset_acquire_ctx *ctx,
+					       bool force)
+{
+	struct ast_connector *ast_connector = to_ast_connector(connector);
+	enum drm_connector_status status;
+
+	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
+
+	ast_connector->physical_status = status;
+
+	return status;
+}
+
 static const struct drm_connector_helper_funcs ast_vga_connector_helper_funcs = {
 	.get_modes = drm_connector_helper_get_modes,
-	.detect_ctx = drm_connector_helper_detect_from_ddc,
+	.detect_ctx = ast_vga_connector_helper_detect_ctx,
 };
 
 static const struct drm_connector_funcs ast_vga_connector_funcs = {
@@ -67,7 +81,8 @@ int ast_vga_output_init(struct ast_device *ast)
 	struct drm_device *dev = &ast->base;
 	struct drm_crtc *crtc = &ast->crtc;
 	struct drm_encoder *encoder = &ast->output.vga.encoder;
-	struct drm_connector *connector = &ast->output.vga.connector;
+	struct ast_connector *ast_connector = &ast->output.vga.connector;
+	struct drm_connector *connector = &ast_connector->base;
 	int ret;
 
 	ret = drm_encoder_init(dev, encoder, &ast_vga_encoder_funcs,
@@ -79,6 +94,7 @@ int ast_vga_output_init(struct ast_device *ast)
 	ret = ast_vga_connector_init(dev, connector);
 	if (ret)
 		return ret;
+	ast_connector->physical_status = connector->status;
 
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret)
Signature · 1 line
2.46.0
reviewer Reviewed-by on v3 2/11
#3 lore raw

Re: [PATCH v3 02/11] drm/ast: Add struct ast_connector

Quoted 3 lines · Thomas Zimmermann

Add struct ast_connector to track a connector's physical status. With the upcoming BMC support, the physical status can be different from the reported status.

Thanks for this, as we fake the connector to be always connected with BMC, it has to know internally if there is something plugged.

Quoted 269 lines
---
  drivers/gpu/drm/ast/ast_dp.c     |  7 ++++++-
  drivers/gpu/drm/ast/ast_dp501.c  | 11 +++++++++--
  drivers/gpu/drm/ast/ast_drv.h    | 24 ++++++++++++++++++++----
  drivers/gpu/drm/ast/ast_mode.c   |  8 ++++----
  drivers/gpu/drm/ast/ast_sil164.c | 20 ++++++++++++++++++--
  drivers/gpu/drm/ast/ast_vga.c    | 20 ++++++++++++++++++--
  6 files changed, 75 insertions(+), 15 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +6 -1
index 549c823c9529..c7f0f9b5dc3a 100644
@@ -364,6 +364,7 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
  						 struct drm_modeset_acquire_ctx *ctx,
  						 bool force)
  {
+	struct ast_connector *ast_connector = to_ast_connector(connector);
  	struct drm_device *dev = connector->dev;
  	struct ast_device *ast = to_ast_device(connector->dev);
  	enum drm_connector_status status = connector_status_disconnected;
@@ -392,6 +393,8 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
 
  	mutex_unlock(&ast->modeset_lock);
 
+	ast_connector->physical_status = status;
+
  	return status;
  }
 
@@ -432,7 +435,8 @@ int ast_astdp_output_init(struct ast_device *ast)
  	struct drm_device *dev = &ast->base;
  	struct drm_crtc *crtc = &ast->crtc;
  	struct drm_encoder *encoder = &ast->output.astdp.encoder;
-	struct drm_connector *connector = &ast->output.astdp.connector;
+	struct ast_connector *ast_connector = &ast->output.astdp.connector;
+	struct drm_connector *connector = &ast_connector->base;
  	int ret;
 
  	ret = drm_encoder_init(dev, encoder, &ast_astdp_encoder_funcs,
@@ -446,6 +450,7 @@ int ast_astdp_output_init(struct ast_device *ast)
  	ret = ast_astdp_connector_init(dev, connector);
  	if (ret)
  		return ret;
+	ast_connector->physical_status = connector->status;
 
  	ret = drm_connector_attach_encoder(connector, encoder);
  	if (ret)
drivers/gpu/drm/ast/ast_dp501.c +9 -2
index 478efa226170..3904f98ef846 100644
@@ -540,11 +540,16 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector
  						 struct drm_modeset_acquire_ctx *ctx,
  						 bool force)
  {
+	struct ast_connector *ast_connector = to_ast_connector(connector);
  	struct ast_device *ast = to_ast_device(connector->dev);
+	enum drm_connector_status status = connector_status_disconnected;
 
  	if (ast_dp501_is_connected(ast))
  		return connector_status_connected;
-	return connector_status_disconnected;
+
+	ast_connector->physical_status = status;
+
+	return status;
  }
 
  static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = {
@@ -584,7 +589,8 @@ int ast_dp501_output_init(struct ast_device *ast)
  	struct drm_device *dev = &ast->base;
  	struct drm_crtc *crtc = &ast->crtc;
  	struct drm_encoder *encoder = &ast->output.dp501.encoder;
-	struct drm_connector *connector = &ast->output.dp501.connector;
+	struct ast_connector *ast_connector = &ast->output.dp501.connector;
+	struct drm_connector *connector = &ast_connector->base;
  	int ret;
 
  	ret = drm_encoder_init(dev, encoder, &ast_dp501_encoder_funcs,
@@ -598,6 +604,7 @@ int ast_dp501_output_init(struct ast_device *ast)
  	ret = ast_dp501_connector_init(dev, connector);
  	if (ret)
  		return ret;
+	ast_connector->physical_status = connector->status;
 
  	ret = drm_connector_attach_encoder(connector, encoder);
  	if (ret)
drivers/gpu/drm/ast/ast_drv.h +20 -4
index 3a4f80cb5c0f..b29625d45a11 100644
@@ -146,6 +146,22 @@ static inline struct ast_plane *to_ast_plane(struct drm_plane *plane)
  	return container_of(plane, struct ast_plane, base);
  }
 
+/*
+ * Connector
+ */
+
+struct ast_connector {
+	struct drm_connector base;
+
+	enum drm_connector_status physical_status;
+};
+
+static inline struct ast_connector *
+to_ast_connector(struct drm_connector *connector)
+{
+	return container_of(connector, struct ast_connector, base);
+}
+
  /*
   * BMC
   */
@@ -192,19 +208,19 @@ struct ast_device {
  	struct {
  		struct {
  			struct drm_encoder encoder;
-			struct drm_connector connector;
+			struct ast_connector connector;
  		} vga;
  		struct {
  			struct drm_encoder encoder;
-			struct drm_connector connector;
+			struct ast_connector connector;
  		} sil164;
  		struct {
  			struct drm_encoder encoder;
-			struct drm_connector connector;
+			struct ast_connector connector;
  		} dp501;
  		struct {
  			struct drm_encoder encoder;
-			struct drm_connector connector;
+			struct ast_connector connector;
  		} astdp;
  		struct {
  			struct drm_encoder encoder;
drivers/gpu/drm/ast/ast_mode.c +4 -4
index d823e9d85b04..8ce1637268e1 100644
@@ -1502,25 +1502,25 @@ int ast_mode_config_init(struct ast_device *ast)
  		ret = ast_vga_output_init(ast);
  		if (ret)
  			return ret;
-		physical_connector = &ast->output.vga.connector;
+		physical_connector = &ast->output.vga.connector.base;
  	}
  	if (ast->tx_chip_types & AST_TX_SIL164_BIT) {
  		ret = ast_sil164_output_init(ast);
  		if (ret)
  			return ret;
-		physical_connector = &ast->output.sil164.connector;
+		physical_connector = &ast->output.sil164.connector.base;
  	}
  	if (ast->tx_chip_types & AST_TX_DP501_BIT) {
  		ret = ast_dp501_output_init(ast);
  		if (ret)
  			return ret;
-		physical_connector = &ast->output.dp501.connector;
+		physical_connector = &ast->output.dp501.connector.base;
  	}
  	if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
  		ret = ast_astdp_output_init(ast);
  		if (ret)
  			return ret;
-		physical_connector = &ast->output.astdp.connector;
+		physical_connector = &ast->output.astdp.connector.base;
  	}
  	ret = ast_bmc_output_init(ast, physical_connector);
  	if (ret)
drivers/gpu/drm/ast/ast_sil164.c +18 -2
index 6e17d84f994e..05f991aa34ca 100644
@@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = {
   * Connector
   */
 
+static int ast_sil164_connector_helper_detect_ctx(struct drm_connector *connector,
+						  struct drm_modeset_acquire_ctx *ctx,
+						  bool force)
+{
+	struct ast_connector *ast_connector = to_ast_connector(connector);
+	enum drm_connector_status status;
+
+	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
+
+	ast_connector->physical_status = status;
+
+	return status;
+}
+
  static const struct drm_connector_helper_funcs ast_sil164_connector_helper_funcs = {
  	.get_modes = drm_connector_helper_get_modes,
-	.detect_ctx = drm_connector_helper_detect_from_ddc,
+	.detect_ctx = ast_sil164_connector_helper_detect_ctx,
  };
 
  static const struct drm_connector_funcs ast_sil164_connector_funcs = {
@@ -67,7 +81,8 @@ int ast_sil164_output_init(struct ast_device *ast)
  	struct drm_device *dev = &ast->base;
  	struct drm_crtc *crtc = &ast->crtc;
  	struct drm_encoder *encoder = &ast->output.sil164.encoder;
-	struct drm_connector *connector = &ast->output.sil164.connector;
+	struct ast_connector *ast_connector = &ast->output.sil164.connector;
+	struct drm_connector *connector = &ast_connector->base;
  	int ret;
 
  	ret = drm_encoder_init(dev, encoder, &ast_sil164_encoder_funcs,
@@ -79,6 +94,7 @@ int ast_sil164_output_init(struct ast_device *ast)
  	ret = ast_sil164_connector_init(dev, connector);
  	if (ret)
  		return ret;
+	ast_connector->physical_status = connector->status;
 
  	ret = drm_connector_attach_encoder(connector, encoder);
  	if (ret)
drivers/gpu/drm/ast/ast_vga.c +18 -2
index 2ea0763844f3..fdbd0daca7dc 100644
@@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = {
   * Connector
   */
 
+static int ast_vga_connector_helper_detect_ctx(struct drm_connector *connector,
+					       struct drm_modeset_acquire_ctx *ctx,
+					       bool force)
+{
+	struct ast_connector *ast_connector = to_ast_connector(connector);
+	enum drm_connector_status status;
+
+	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
+
+	ast_connector->physical_status = status;
+
+	return status;
+}
+
  static const struct drm_connector_helper_funcs ast_vga_connector_helper_funcs = {
  	.get_modes = drm_connector_helper_get_modes,
-	.detect_ctx = drm_connector_helper_detect_from_ddc,
+	.detect_ctx = ast_vga_connector_helper_detect_ctx,
  };
 
  static const struct drm_connector_funcs ast_vga_connector_funcs = {
@@ -67,7 +81,8 @@ int ast_vga_output_init(struct ast_device *ast)
  	struct drm_device *dev = &ast->base;
  	struct drm_crtc *crtc = &ast->crtc;
  	struct drm_encoder *encoder = &ast->output.vga.encoder;
-	struct drm_connector *connector = &ast->output.vga.connector;
+	struct ast_connector *ast_connector = &ast->output.vga.connector;
+	struct drm_connector *connector = &ast_connector->base;
  	int ret;
 
  	ret = drm_encoder_init(dev, encoder, &ast_vga_encoder_funcs,
@@ -79,6 +94,7 @@ int ast_vga_output_init(struct ast_device *ast)
  	ret = ast_vga_connector_init(dev, connector);
  	if (ret)
  		return ret;
+	ast_connector->physical_status = connector->status;
 
  	ret = drm_connector_attach_encoder(connector, encoder);
  	if (ret)
author maintainer
#4 lore raw

PATCH v3 3/11 drm/ast: astdp: Move locking into EDID helper

In reply to Thomas Zimmermann

The modeset mutex protects EDID retrival from concurrent modeset operations. Acquire the lock in ast_astdp_read_edid(). Prepares the code for conversion to struct drm_edid.

---
 drivers/gpu/drm/ast/ast_dp.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +10 -14
index c7f0f9b5dc3a..c2b08a414ae4 100644
@@ -26,6 +26,12 @@ static int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
 	int ret = 0;
 	u8 i;
 
+	/*
+	 * Protect access to I/O registers from concurrent modesetting
+	 * by acquiring the I/O-register lock.
+	 */
+	mutex_lock(&ast->modeset_lock);
+
 	/* Start reading EDID data */
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xe5, (u8)~AST_IO_VGACRE5_EDID_READ_DONE, 0x00);
 
@@ -95,6 +101,8 @@ static int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xe5, (u8)~AST_IO_VGACRE5_EDID_READ_DONE,
 			       AST_IO_VGACRE5_EDID_READ_DONE);
 
+	mutex_unlock(&ast->modeset_lock);
+
 	return ret;
 }
 
@@ -324,9 +332,6 @@ static const struct drm_encoder_helper_funcs ast_astdp_encoder_helper_funcs = {
 static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 {
 	void *edid;
-	struct drm_device *dev = connector->dev;
-	struct ast_device *ast = to_ast_device(dev);
-
 	int succ;
 	int count;
 
@@ -334,17 +339,9 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 	if (!edid)
 		goto err_drm_connector_update_edid_property;
 
-	/*
-	 * Protect access to I/O registers from concurrent modesetting
-	 * by acquiring the I/O-register lock.
-	 */
-	mutex_lock(&ast->modeset_lock);
-
 	succ = ast_astdp_read_edid(connector->dev, edid);
 	if (succ < 0)
-		goto err_mutex_unlock;
-
-	mutex_unlock(&ast->modeset_lock);
+		goto err_kfree;
 
 	drm_connector_update_edid_property(connector, edid);
 	count = drm_add_edid_modes(connector, edid);
@@ -352,8 +349,7 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 
 	return count;
 
-err_mutex_unlock:
-	mutex_unlock(&ast->modeset_lock);
+err_kfree:
 	kfree(edid);
 err_drm_connector_update_edid_property:
 	drm_connector_update_edid_property(connector, NULL);
Signature · 1 line
2.46.0
author maintainer
#5 lore raw

PATCH v3 4/11 drm/ast: astdp: Use struct drm_edid and helpers

In reply to Thomas Zimmermann

Convert ASTDP support to struct drm_edid and its helpers. Simplifies and modernizes the EDID handling.

The driver reads 4 bytes at once, but the overall read length is now variable. Therefore update the EDID read loop to never return more than the requested bytes.

The device does not seem to support EDID extensions, as the driver actively clears any such information from the main EDID header. As the new interface allows for reading extension blocks for EDID, make sure that the block is always 0 (i.e., the main header). A later update might fix that.

v2:
- fix reading if len is not a multiple of 4

---
 drivers/gpu/drm/ast/ast_dp.c | 55 +++++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 26 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +29 -26
index c2b08a414ae4..45e5c92d19c2 100644
@@ -20,11 +20,15 @@ static bool ast_astdp_is_connected(struct ast_device *ast)
 	return true;
 }
 
-static int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
+static int ast_astdp_read_edid_block(void *data, u8 *buf, unsigned int block, size_t len)
 {
-	struct ast_device *ast = to_ast_device(dev);
+	struct ast_device *ast = data;
+	size_t rdlen = round_up(len, 4);
 	int ret = 0;
-	u8 i;
+	unsigned int i;
+
+	if (block > 0)
+		return -EIO; /* extension headers not supported */
 
 	/*
 	 * Protect access to I/O registers from concurrent modesetting
@@ -35,13 +39,23 @@ static int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
 	/* Start reading EDID data */
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xe5, (u8)~AST_IO_VGACRE5_EDID_READ_DONE, 0x00);
 
-	for (i = 0; i < 32; i++) {
+	for (i = 0; i < rdlen; i += 4) {
+		unsigned int offset;
 		unsigned int j;
+		u8 ediddata[4];
+		u8 vgacre4;
+
+		offset = (i + block * EDID_LENGTH) / 4;
+		if (offset >= 64) {
+			ret = -EIO;
+			goto out;
+		}
+		vgacre4 = offset;
 
 		/*
 		 * CRE4[7:0]: Read-Pointer for EDID (Unit: 4bytes); valid range: 0~64
 		 */
-		ast_set_index_reg(ast, AST_IO_VGACRI, 0xe4, i);
+		ast_set_index_reg(ast, AST_IO_VGACRI, 0xe4, vgacre4);
 
 		/*
 		 * CRD7[b0]: valid flag for EDID
@@ -65,7 +79,7 @@ static int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
 			vgacrd7 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd7);
 			if (vgacrd7 & AST_IO_VGACRD7_EDID_VALID_FLAG) {
 				vgacrd6 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd6);
-				if (vgacrd6 == i)
+				if (vgacrd6 == offset)
 					break;
 			}
 		}
@@ -93,7 +107,8 @@ static int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
 			ediddata[2] = 0;
 		}
 
-		ediddata += 4;
+		memcpy(buf, ediddata, min((len - i), 4));
+		buf += 4;
 	}
 
 out:
@@ -331,29 +346,17 @@ static const struct drm_encoder_helper_funcs ast_astdp_encoder_helper_funcs = {
 
 static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 {
-	void *edid;
-	int succ;
+	struct drm_device *dev = connector->dev;
+	struct ast_device *ast = to_ast_device(dev);
+	const struct drm_edid *drm_edid;
 	int count;
 
-	edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-	if (!edid)
-		goto err_drm_connector_update_edid_property;
-
-	succ = ast_astdp_read_edid(connector->dev, edid);
-	if (succ < 0)
-		goto err_kfree;
-
-	drm_connector_update_edid_property(connector, edid);
-	count = drm_add_edid_modes(connector, edid);
-	kfree(edid);
+	drm_edid = drm_edid_read_custom(connector, ast_astdp_read_edid_block, ast);
+	drm_edid_connector_update(connector, drm_edid);
+	count = drm_edid_connector_add_modes(connector);
+	drm_edid_free(drm_edid);
 
 	return count;
-
-err_kfree:
-	kfree(edid);
-err_drm_connector_update_edid_property:
-	drm_connector_update_edid_property(connector, NULL);
-	return 0;
 }
 
 static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector,
Signature · 1 line
2.46.0
author maintainer
#6 lore raw

PATCH v3 5/11 drm/ast: astdp: Simplify power management when detecting display

In reply to Thomas Zimmermann

Remove the CRTC handling in the ASTDP detect_ctx helper and enable power while the detecting the display. Unconditionally wait a few milliseconds after switching power. Simplifies the code and makes it more robust.

---
 drivers/gpu/drm/ast/ast_dp.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +6 -13
index 45e5c92d19c2..ffbcc397ee6b 100644
@@ -170,6 +170,8 @@ static void ast_dp_power_on_off(struct drm_device *dev, bool on)
 
 	// DP Power on/off
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_PHY_SLEEP, bE3);
+
+	msleep(50);
 }
 
 static void ast_dp_link_training(struct ast_device *ast)
@@ -367,27 +369,18 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
 	struct drm_device *dev = connector->dev;
 	struct ast_device *ast = to_ast_device(connector->dev);
 	enum drm_connector_status status = connector_status_disconnected;
-	struct drm_connector_state *connector_state = connector->state;
-	bool is_active = false;
+	bool power_is_on;
 
 	mutex_lock(&ast->modeset_lock);
 
-	if (connector_state && connector_state->crtc) {
-		struct drm_crtc_state *crtc_state = connector_state->crtc->state;
-
-		if (crtc_state && crtc_state->active)
-			is_active = true;
-	}
-
-	if (!is_active && !ast_dp_power_is_on(ast)) {
+	power_is_on = ast_dp_power_is_on(ast);
+	if (!power_is_on)
 		ast_dp_power_on_off(dev, true);
-		msleep(50);
-	}
 
 	if (ast_astdp_is_connected(ast))
 		status = connector_status_connected;
 
-	if (!is_active && status == connector_status_disconnected)
+	if (!power_is_on && status == connector_status_disconnected)
 		ast_dp_power_on_off(dev, false);
 
 	mutex_unlock(&ast->modeset_lock);
Signature · 1 line
2.46.0
reviewer Reviewed-by on v3 5/11
#7 lore raw

Re: [PATCH v3 05/11] drm/ast: astdp: Simplify power management when detecting display

Quoted 5 lines · Thomas Zimmermann

Remove the CRTC handling in the ASTDP detect_ctx helper and enable power while the detecting the display. Unconditionally wait a few milliseconds after switching power. Simplifies the code and makes it more robust.

Thanks, it looks good to me.

Quoted 50 lines
---
  drivers/gpu/drm/ast/ast_dp.c | 19 ++++++-------------
  1 file changed, 6 insertions(+), 13 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +6 -13
index 45e5c92d19c2..ffbcc397ee6b 100644
@@ -170,6 +170,8 @@ static void ast_dp_power_on_off(struct drm_device *dev, bool on)
 
  	// DP Power on/off
  	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_PHY_SLEEP, bE3);
+
+	msleep(50);
  }
 
  static void ast_dp_link_training(struct ast_device *ast)
@@ -367,27 +369,18 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
  	struct drm_device *dev = connector->dev;
  	struct ast_device *ast = to_ast_device(connector->dev);
  	enum drm_connector_status status = connector_status_disconnected;
-	struct drm_connector_state *connector_state = connector->state;
-	bool is_active = false;
+	bool power_is_on;
 
  	mutex_lock(&ast->modeset_lock);
 
-	if (connector_state && connector_state->crtc) {
-		struct drm_crtc_state *crtc_state = connector_state->crtc->state;
-
-		if (crtc_state && crtc_state->active)
-			is_active = true;
-	}
-
-	if (!is_active && !ast_dp_power_is_on(ast)) {
+	power_is_on = ast_dp_power_is_on(ast);
+	if (!power_is_on)
  		ast_dp_power_on_off(dev, true);
-		msleep(50);
-	}
 
  	if (ast_astdp_is_connected(ast))
  		status = connector_status_connected;
 
-	if (!is_active && status == connector_status_disconnected)
+	if (!power_is_on && status == connector_status_disconnected)
  		ast_dp_power_on_off(dev, false);
 
  	mutex_unlock(&ast->modeset_lock);
author maintainer
#8 lore raw

PATCH v3 6/11 drm/ast: astdp: Transparently handle BMC support

In reply to Thomas Zimmermann

Permanently set the connector status to 'connected'. Return BMC modes for connector if no display is attached to the physical DP connector. Otherwise use EDID modes as before.

If the status of the physical connector changes, the driver still generates a hotplug event. DRM clients will then reconfigure their output to a mode appropriate for either physical display or BMC.

v3:
- use struct ast_connector.physical_status to handle BMC

---
 drivers/gpu/drm/ast/ast_dp.c | 43 ++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 12 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +31 -12
index ffbcc397ee6b..00b364f9a71e 100644
@@ -319,12 +319,15 @@ static void ast_astdp_encoder_helper_atomic_enable(struct drm_encoder *encoder,
 {
 	struct drm_device *dev = encoder->dev;
 	struct ast_device *ast = to_ast_device(dev);
+	struct ast_connector *ast_connector = &ast->output.astdp.connector;
 
-	ast_dp_power_on_off(dev, AST_DP_POWER_ON);
-	ast_dp_link_training(ast);
+	if (ast_connector->physical_status == connector_status_connected) {
+		ast_dp_power_on_off(dev, AST_DP_POWER_ON);
+		ast_dp_link_training(ast);
 
-	ast_wait_for_vretrace(ast);
-	ast_dp_set_on_off(dev, 1);
+		ast_wait_for_vretrace(ast);
+		ast_dp_set_on_off(dev, 1);
+	}
 }
 
 static void ast_astdp_encoder_helper_atomic_disable(struct drm_encoder *encoder,
@@ -348,15 +351,29 @@ static const struct drm_encoder_helper_funcs ast_astdp_encoder_helper_funcs = {
 
 static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 {
-	struct drm_device *dev = connector->dev;
-	struct ast_device *ast = to_ast_device(dev);
-	const struct drm_edid *drm_edid;
+	struct ast_connector *ast_connector = to_ast_connector(connector);
 	int count;
 
-	drm_edid = drm_edid_read_custom(connector, ast_astdp_read_edid_block, ast);
-	drm_edid_connector_update(connector, drm_edid);
-	count = drm_edid_connector_add_modes(connector);
-	drm_edid_free(drm_edid);
+	if (ast_connector->physical_status == connector_status_connected) {
+		struct ast_device *ast = to_ast_device(connector->dev);
+		const struct drm_edid *drm_edid;
+
+		drm_edid = drm_edid_read_custom(connector, ast_astdp_read_edid_block, ast);
+		drm_edid_connector_update(connector, drm_edid);
+		count = drm_edid_connector_add_modes(connector);
+		drm_edid_free(drm_edid);
+	} else {
+		drm_edid_connector_update(connector, NULL);
+
+		/*
+		 * There's no EDID data without a connected monitor. Set BMC-
+		 * compatible modes in this case. The XGA default resolution
+		 * should work well for all BMCs.
+		 */
+		count = drm_add_modes_noedid(connector, 4096, 4096);
+		if (count)
+			drm_set_preferred_mode(connector, 1024, 768);
+	}
 
 	return count;
 }
@@ -385,9 +402,11 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
 
 	mutex_unlock(&ast->modeset_lock);
 
+	if (status != ast_connector->physical_status)
+		++connector->epoch_counter;
 	ast_connector->physical_status = status;
 
-	return status;
+	return connector_status_connected;
 }
 
 static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs = {
Signature · 1 line
2.46.0
author maintainer
#9 lore raw

PATCH v3 7/11 drm/ast: dp501: Use struct drm_edid and helpers

In reply to Thomas Zimmermann

Convert DP501 support to struct drm_edid and its helpers. Simplifies and modernizes the EDID handling.

The driver reads 4 bytes at once, but the overall read length is now variable. Therefore update the EDID read loop to never return more than the requested bytes.

v2:
- fix reading EDID data

---
 drivers/gpu/drm/ast/ast_dp501.c | 59 ++++++++++++---------------------
 1 file changed, 22 insertions(+), 37 deletions(-)
drivers/gpu/drm/ast/ast_dp501.c +22 -37
index 3904f98ef846..8cc7d20a8999 100644
@@ -318,32 +318,30 @@ static bool ast_dp501_is_connected(struct ast_device *ast)
 	return true;
 }
 
-static bool ast_dp501_read_edid(struct drm_device *dev, u8 *ediddata)
+static int ast_dp512_read_edid_block(void *data, u8 *buf, unsigned int block, size_t len)
 {
-	struct ast_device *ast = to_ast_device(dev);
-	u32 i, boot_address, offset, data;
-	u32 *pEDIDidx;
+	struct ast_device *ast = data;
+	size_t rdlen = round_up(len, 4);
+	u32 i, boot_address, offset, ediddata;
 
-	if (!ast_dp501_is_connected(ast))
-		return false;
+	if (block > (512 / EDID_LENGTH))
+		return -EIO;
+
+	offset = AST_DP501_EDID_DATA + block * EDID_LENGTH;
 
 	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;
+		for (i = 0; i < rdlen; i += 4) {
+			ediddata = ast_mindwm(ast, boot_address + offset + i);
+			memcpy(buf, &ediddata, min((len - i), 4));
+			buf += 4;
 		}
 	} else {
-		/* Read EDID */
-		offset = AST_DP501_EDID_DATA;
-		for (i = 0; i < 128; i += 4) {
-			data = readl(ast->dp501_fw_buf + offset + i);
-			pEDIDidx = (u32 *)(ediddata + i);
-			*pEDIDidx = data;
+		for (i = 0; i < rdlen; i += 4) {
+			ediddata = readl(ast->dp501_fw_buf + offset + i);
+			memcpy(buf, &ediddata, min((len - i), 4));
+			buf += 4;
 		}
 	}
 
@@ -511,29 +509,16 @@ static const struct drm_encoder_helper_funcs ast_dp501_encoder_helper_funcs = {
 
 static int ast_dp501_connector_helper_get_modes(struct drm_connector *connector)
 {
-	void *edid;
-	bool succ;
+	struct ast_device *ast = to_ast_device(connector->dev);
+	const struct drm_edid *drm_edid;
 	int count;
 
-	edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-	if (!edid)
-		goto err_drm_connector_update_edid_property;
-
-	succ = ast_dp501_read_edid(connector->dev, edid);
-	if (!succ)
-		goto err_kfree;
-
-	drm_connector_update_edid_property(connector, edid);
-	count = drm_add_edid_modes(connector, edid);
-	kfree(edid);
+	drm_edid = drm_edid_read_custom(connector, ast_dp512_read_edid_block, ast);
+	drm_edid_connector_update(connector, drm_edid);
+	count = drm_edid_connector_add_modes(connector);
+	drm_edid_free(drm_edid);
 
 	return count;
-
-err_kfree:
-	kfree(edid);
-err_drm_connector_update_edid_property:
-	drm_connector_update_edid_property(connector, NULL);
-	return 0;
 }
 
 static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector,
Signature · 1 line
2.46.0
author maintainer
#10 lore raw

PATCH v3 8/11 drm/ast: dp501: Transparently handle BMC support

In reply to Thomas Zimmermann

Permanently set the connector status to 'connected'. Return BMC modes for connector if no display is attached to the physical DP connector. Otherwise use EDID modes as before.

If the status of the physical connector changes, the driver still generates a hotplug event. DRM clients will then reconfigure their output to a mode appropriate for either physical display or BMC.

v3:
- use struct ast_connector.physical_status to handle BMC

---
 drivers/gpu/drm/ast/ast_dp501.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)
drivers/gpu/drm/ast/ast_dp501.c +25 -8
index 8cc7d20a8999..e4c636f45082 100644
@@ -509,14 +509,29 @@ static const struct drm_encoder_helper_funcs ast_dp501_encoder_helper_funcs = {
 
 static int ast_dp501_connector_helper_get_modes(struct drm_connector *connector)
 {
-	struct ast_device *ast = to_ast_device(connector->dev);
-	const struct drm_edid *drm_edid;
+	struct ast_connector *ast_connector = to_ast_connector(connector);
 	int count;
 
-	drm_edid = drm_edid_read_custom(connector, ast_dp512_read_edid_block, ast);
-	drm_edid_connector_update(connector, drm_edid);
-	count = drm_edid_connector_add_modes(connector);
-	drm_edid_free(drm_edid);
+	if (ast_connector->physical_status == connector_status_connected) {
+		struct ast_device *ast = to_ast_device(connector->dev);
+		const struct drm_edid *drm_edid;
+
+		drm_edid = drm_edid_read_custom(connector, ast_dp512_read_edid_block, ast);
+		drm_edid_connector_update(connector, drm_edid);
+		count = drm_edid_connector_add_modes(connector);
+		drm_edid_free(drm_edid);
+	} else {
+		drm_edid_connector_update(connector, NULL);
+
+		/*
+		 * There's no EDID data without a connected monitor. Set BMC-
+		 * compatible modes in this case. The XGA default resolution
+		 * should work well for all BMCs.
+		 */
+		count = drm_add_modes_noedid(connector, 4096, 4096);
+		if (count)
+			drm_set_preferred_mode(connector, 1024, 768);
+	}
 
 	return count;
 }
@@ -530,11 +545,13 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector
 	enum drm_connector_status status = connector_status_disconnected;
 
 	if (ast_dp501_is_connected(ast))
-		return connector_status_connected;
+		status = connector_status_connected;
 
+	if (status != ast_connector->physical_status)
+		++connector->epoch_counter;
 	ast_connector->physical_status = status;
 
-	return status;
+	return connector_status_connected;
 }
 
 static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = {
Signature · 1 line
2.46.0
author maintainer
#11 lore raw

PATCH v3 9/11 drm/ast: sil164: Transparently handle BMC support

In reply to Thomas Zimmermann

Permanently set the connector status to 'connected'. Return BMC modes for connector if no display is attached to the physical DP connector. Otherwise use EDID modes as before.

If the status of the physical connector changes, the driver still generates a hotplug event. DRM clients will then reconfigure their output to a mode appropriate for either physical display or BMC.

v3:
- use struct ast_connector.physical_status to handle BMC

---
 drivers/gpu/drm/ast/ast_sil164.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_sil164.c +25 -2
index 05f991aa34ca..496c7120e515 100644
@@ -21,6 +21,27 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = {
  * Connector
  */
 
+static int ast_sil164_connector_helper_get_modes(struct drm_connector *connector)
+{
+	struct ast_connector *ast_connector = to_ast_connector(connector);
+	int count;
+
+	if (ast_connector->physical_status == connector_status_connected) {
+		count = drm_connector_helper_get_modes(connector);
+	} else {
+		/*
+		 * There's no EDID data without a connected monitor. Set BMC-
+		 * compatible modes in this case. The XGA default resolution
+		 * should work well for all BMCs.
+		 */
+		count = drm_add_modes_noedid(connector, 4096, 4096);
+		if (count)
+			drm_set_preferred_mode(connector, 1024, 768);
+	}
+
+	return count;
+}
+
 static int ast_sil164_connector_helper_detect_ctx(struct drm_connector *connector,
 						  struct drm_modeset_acquire_ctx *ctx,
 						  bool force)
@@ -30,13 +51,15 @@ static int ast_sil164_connector_helper_detect_ctx(struct drm_connector *connecto
 
 	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
 
+	if (status != ast_connector->physical_status)
+		++connector->epoch_counter;
 	ast_connector->physical_status = status;
 
-	return status;
+	return connector_status_connected;
 }
 
 static const struct drm_connector_helper_funcs ast_sil164_connector_helper_funcs = {
-	.get_modes = drm_connector_helper_get_modes,
+	.get_modes = ast_sil164_connector_helper_get_modes,
 	.detect_ctx = ast_sil164_connector_helper_detect_ctx,
 };
 
Signature · 1 line
2.46.0
author maintainer
#12 lore raw

PATCH v3 10/11 drm/ast: vga: Transparently handle BMC support

In reply to Thomas Zimmermann

Permanently set the connector status to 'connected'. Return BMC modes for connector if no display is attached to the physical DP connector. Otherwise use EDID modes as before.

If the status of the physical connector changes, the driver still generates a hotplug event. DRM clients will then reconfigure their output to a mode appropriate for either physical display or BMC.

v3:
- use struct ast_connector.physical_status to handle BMC

---
 drivers/gpu/drm/ast/ast_vga.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_vga.c +25 -2
index fdbd0daca7dc..3e815da43fbd 100644
@@ -21,6 +21,27 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = {
  * Connector
  */
 
+static int ast_vga_connector_helper_get_modes(struct drm_connector *connector)
+{
+	struct ast_connector *ast_connector = to_ast_connector(connector);
+	int count;
+
+	if (ast_connector->physical_status == connector_status_connected) {
+		count = drm_connector_helper_get_modes(connector);
+	} else {
+		/*
+		 * There's no EDID data without a connected monitor. Set BMC-
+		 * compatible modes in this case. The XGA default resolution
+		 * should work well for all BMCs.
+		 */
+		count = drm_add_modes_noedid(connector, 4096, 4096);
+		if (count)
+			drm_set_preferred_mode(connector, 1024, 768);
+	}
+
+	return count;
+}
+
 static int ast_vga_connector_helper_detect_ctx(struct drm_connector *connector,
 					       struct drm_modeset_acquire_ctx *ctx,
 					       bool force)
@@ -30,13 +51,15 @@ static int ast_vga_connector_helper_detect_ctx(struct drm_connector *connector,
 
 	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
 
+	if (status != ast_connector->physical_status)
+		++connector->epoch_counter;
 	ast_connector->physical_status = status;
 
-	return status;
+	return connector_status_connected;
 }
 
 static const struct drm_connector_helper_funcs ast_vga_connector_helper_funcs = {
-	.get_modes = drm_connector_helper_get_modes,
+	.get_modes = ast_vga_connector_helper_get_modes,
 	.detect_ctx = ast_vga_connector_helper_detect_ctx,
 };
 
Signature · 1 line
2.46.0
author maintainer
#13 lore raw

PATCH v3 11/11 drm/ast: Remove BMC output

In reply to Thomas Zimmermann

Ast's BMC connector tracks the status of an underlying physical connector and updates the BMC status accordingly. This functionality works around GNOME's settings app, which cannot handle multiple outputs on the same CRTC.

The workaround is now obsolete as all code for physical outputs handle BMC support internally. Hence, remove the driver's code and the BMC output entirely.

v3:
- remove struct ast_bmc_connector

---
 drivers/gpu/drm/ast/ast_drv.h  |  19 ------
 drivers/gpu/drm/ast/ast_mode.c | 107 ---------------------------------
 2 files changed, 126 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +0 -19
index b29625d45a11..91fe07cf7b07 100644
@@ -162,21 +162,6 @@ to_ast_connector(struct drm_connector *connector)
 	return container_of(connector, struct ast_connector, base);
 }
 
-/*
- * BMC
- */
-
-struct ast_bmc_connector {
-	struct drm_connector base;
-	struct drm_connector *physical_connector;
-};
-
-static inline struct ast_bmc_connector *
-to_ast_bmc_connector(struct drm_connector *connector)
-{
-	return container_of(connector, struct ast_bmc_connector, base);
-}
-
 /*
  * Device
  */
@@ -222,10 +207,6 @@ struct ast_device {
 			struct drm_encoder encoder;
 			struct ast_connector connector;
 		} astdp;
-		struct {
-			struct drm_encoder encoder;
-			struct ast_bmc_connector bmc_connector;
-		} bmc;
 	} output;
 
 	bool support_wide_screen;
drivers/gpu/drm/ast/ast_mode.c +0 -107

149 lines not on this page · raw message

Signature · 1 line
2.46.0