Skip to contentSkip to conversation

drm/ast: Transparently handle BMC in outputs

PATCH Superseded Thomas Zimmermann 2 participants 18 messages Aug 12, 2024 – Aug 13, 2024

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

v2 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.

v2:
- fix reading EDID data on ASTDP and DP501 chips (Jocelyn)

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

Thomas Zimmermann (9):
drm/ast: Move code for physical outputs into separate files drm/ast: astdp: Move locking into EDID helper drm/ast: astdp: Use struct drm_edid and helpers 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  | 179 ++++++++--
 drivers/gpu/drm/ast/ast_drv.h    |  21 +-
 drivers/gpu/drm/ast/ast_mode.c   | 578 -------------------------------
 drivers/gpu/drm/ast/ast_sil164.c | 124 +++++++
 drivers/gpu/drm/ast/ast_vga.c    | 124 +++++++
 7 files changed, 645 insertions(+), 627 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 v2 1/9 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 v2 2/9 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 ef2dd9d82de9..217c155f0874 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;
 }
 
@@ -323,9 +331,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;
 
@@ -333,17 +338,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);
@@ -351,8 +348,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
#3 lore raw

PATCH v2 3/9 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 217c155f0874..22c4f2a126e9 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:
@@ -330,29 +345,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
reviewer Reviewed-by on v2 3/9
#4 lore raw

Re: [PATCH v2 3/9] drm/ast: astdp: Use struct drm_edid and helpers

Quoted 7 lines · 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.

Quoted 8 lines

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

Thanks, it looks good to me.

Quoted 111 lines
---
  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 217c155f0874..22c4f2a126e9 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:
@@ -330,29 +345,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,
author maintainer
#5 lore raw

PATCH v2 4/9 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.

---
 drivers/gpu/drm/ast/ast_dp.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +18 -1
index 22c4f2a126e9..121a76a85554 100644
@@ -355,6 +355,17 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 	count = drm_edid_connector_add_modes(connector);
 	drm_edid_free(drm_edid);
 
+	if (!count) {
+		/*
+		 * 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;
 }
 
@@ -364,10 +375,14 @@ 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 old_status = connector_status_disconnected;
 	enum drm_connector_status status = connector_status_disconnected;
 	struct drm_connector_state *connector_state = connector->state;
 	bool is_active = false;
 
+	if (connector->edid_blob_ptr)
+		old_status = connector_status_connected;
+
 	mutex_lock(&ast->modeset_lock);
 
 	if (connector_state && connector_state->crtc) {
@@ -390,7 +405,9 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
 
 	mutex_unlock(&ast->modeset_lock);
 
-	return status;
+	if (status != old_status)
+		++connector->epoch_counter;
+	return connector_status_connected;
 }
 
 static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs = {
Signature · 1 line
2.46.0
reviewer Reviewed-by on v2 4/9
#6 lore raw

Re: [PATCH v2 4/9] drm/ast: astdp: Transparently handle BMC support

Quoted 8 lines · 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.

Thanks, it looks good to me.

Quoted 53 lines
---
  drivers/gpu/drm/ast/ast_dp.c | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +18 -1
index 22c4f2a126e9..121a76a85554 100644
@@ -355,6 +355,17 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
  	count = drm_edid_connector_add_modes(connector);
  	drm_edid_free(drm_edid);
 
+	if (!count) {
+		/*
+		 * 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;
  }
 
@@ -364,10 +375,14 @@ 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 old_status = connector_status_disconnected;
  	enum drm_connector_status status = connector_status_disconnected;
  	struct drm_connector_state *connector_state = connector->state;
  	bool is_active = false;
 
+	if (connector->edid_blob_ptr)
+		old_status = connector_status_connected;
+
  	mutex_lock(&ast->modeset_lock);
 
  	if (connector_state && connector_state->crtc) {
@@ -390,7 +405,9 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
 
  	mutex_unlock(&ast->modeset_lock);
 
-	return status;
+	if (status != old_status)
+		++connector->epoch_counter;
+	return connector_status_connected;
  }
 
  static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs = {
author maintainer
#7 lore raw

PATCH v2 5/9 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 478efa226170..0dc37b65e1d7 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
reviewer Reviewed-by on v2 5/9
#8 lore raw

Re: [PATCH v2 5/9] drm/ast: dp501: Use struct drm_edid and helpers

Quoted 9 lines · 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

Thanks, it looks good to me.

Quoted 95 lines
---
  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 478efa226170..0dc37b65e1d7 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,
author maintainer
#9 lore raw

PATCH v2 6/9 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.

---
 drivers/gpu/drm/ast/ast_dp501.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_dp501.c +21 -2
index 0dc37b65e1d7..755cbf931b38 100644
@@ -518,6 +518,17 @@ static int ast_dp501_connector_helper_get_modes(struct drm_connector *connector)
 	count = drm_edid_connector_add_modes(connector);
 	drm_edid_free(drm_edid);
 
+	if (!count) {
+		/*
+		 * 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;
 }
 
@@ -526,10 +537,18 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector
 						 bool force)
 {
 	struct ast_device *ast = to_ast_device(connector->dev);
+	enum drm_connector_status status = connector_status_disconnected;
+	enum drm_connector_status old_status = connector_status_disconnected;
+
+	if (connector->edid_blob_ptr)
+		old_status = connector_status_connected;
 
 	if (ast_dp501_is_connected(ast))
-		return connector_status_connected;
-	return connector_status_disconnected;
+		status = connector_status_connected;
+
+	if (status != old_status)
+		++connector->epoch_counter;
+	return connector_status_connected;
 }
 
 static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = {
Signature · 1 line
2.46.0
reviewer Reviewed-by on v2 6/9
#10 lore raw

Re: [PATCH v2 6/9] drm/ast: dp501: Transparently handle BMC support

Quoted 7 lines · 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.

Thanks, it looks good to me.

Quoted 49 lines
---
  drivers/gpu/drm/ast/ast_dp501.c | 23 +++++++++++++++++++++--
  1 file changed, 21 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_dp501.c +21 -2
index 0dc37b65e1d7..755cbf931b38 100644
@@ -518,6 +518,17 @@ static int ast_dp501_connector_helper_get_modes(struct drm_connector *connector)
  	count = drm_edid_connector_add_modes(connector);
  	drm_edid_free(drm_edid);
 
+	if (!count) {
+		/*
+		 * 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;
  }
 
@@ -526,10 +537,18 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector
  						 bool force)
  {
  	struct ast_device *ast = to_ast_device(connector->dev);
+	enum drm_connector_status status = connector_status_disconnected;
+	enum drm_connector_status old_status = connector_status_disconnected;
+
+	if (connector->edid_blob_ptr)
+		old_status = connector_status_connected;
 
  	if (ast_dp501_is_connected(ast))
-		return connector_status_connected;
-	return connector_status_disconnected;
+		status = connector_status_connected;
+
+	if (status != old_status)
+		++connector->epoch_counter;
+	return connector_status_connected;
  }
 
  static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = {
author maintainer
#11 lore raw

PATCH v2 7/9 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.

---
 drivers/gpu/drm/ast/ast_sil164.c | 40 ++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_sil164.c +38 -2
index 6e17d84f994e..940118544fae 100644
@@ -21,9 +21,45 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = {
  * Connector
  */
 
+static int ast_sil164_connector_helper_get_modes(struct drm_connector *connector)
+{
+	int count = drm_connector_helper_get_modes(connector);
+
+	if (!count) {
+		/*
+		 * 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)
+{
+	enum drm_connector_status old_status, status;
+
+	if (connector->edid_blob_ptr)
+		old_status = connector_status_connected;
+	else
+		old_status = connector_status_disconnected;
+
+	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
+
+	if (status != old_status)
+		++connector->epoch_counter;
+	return connector_status_connected;
+}
+
 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,
+	.get_modes = ast_sil164_connector_helper_get_modes,
+	.detect_ctx = ast_sil164_connector_helper_detect_ctx,
 };
 
 static const struct drm_connector_funcs ast_sil164_connector_funcs = {
Signature · 1 line
2.46.0
reviewer Reviewed-by on v2 7/9
#12 lore raw

Re: [PATCH v2 7/9] drm/ast: sil164: Transparently handle BMC support

Quoted 8 lines · 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.

Thanks, it looks good to me.

Quoted 57 lines
---
  drivers/gpu/drm/ast/ast_sil164.c | 40 ++++++++++++++++++++++++++++++--
  1 file changed, 38 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_sil164.c +38 -2
index 6e17d84f994e..940118544fae 100644
@@ -21,9 +21,45 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = {
   * Connector
   */
 
+static int ast_sil164_connector_helper_get_modes(struct drm_connector *connector)
+{
+	int count = drm_connector_helper_get_modes(connector);
+
+	if (!count) {
+		/*
+		 * 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)
+{
+	enum drm_connector_status old_status, status;
+
+	if (connector->edid_blob_ptr)
+		old_status = connector_status_connected;
+	else
+		old_status = connector_status_disconnected;
+
+	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
+
+	if (status != old_status)
+		++connector->epoch_counter;
+	return connector_status_connected;
+}
+
  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,
+	.get_modes = ast_sil164_connector_helper_get_modes,
+	.detect_ctx = ast_sil164_connector_helper_detect_ctx,
  };
 
  static const struct drm_connector_funcs ast_sil164_connector_funcs = {
author maintainer
#13 lore raw

PATCH v2 8/9 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.

---
 drivers/gpu/drm/ast/ast_vga.c | 40 +++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_vga.c +38 -2
index 2ea0763844f3..8f080af0b61b 100644
@@ -21,9 +21,45 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = {
  * Connector
  */
 
+static int ast_vga_connector_helper_get_modes(struct drm_connector *connector)
+{
+	int count = drm_connector_helper_get_modes(connector);
+
+	if (!count) {
+		/*
+		 * 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)
+{
+	enum drm_connector_status old_status, status;
+
+	if (connector->edid_blob_ptr)
+		old_status = connector_status_connected;
+	else
+		old_status = connector_status_disconnected;
+
+	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
+
+	if (status != old_status)
+		++connector->epoch_counter;
+	return connector_status_connected;
+}
+
 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,
+	.get_modes = ast_vga_connector_helper_get_modes,
+	.detect_ctx = ast_vga_connector_helper_detect_ctx,
 };
 
 static const struct drm_connector_funcs ast_vga_connector_funcs = {
Signature · 1 line
2.46.0
reviewer Reviewed-by on v2 8/9
#14 lore raw

Re: [PATCH v2 8/9] drm/ast: vga: Transparently handle BMC support

Quoted 8 lines · 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.

Thanks, it looks good to me.

Quoted 57 lines
---
  drivers/gpu/drm/ast/ast_vga.c | 40 +++++++++++++++++++++++++++++++++--
  1 file changed, 38 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_vga.c +38 -2
index 2ea0763844f3..8f080af0b61b 100644
@@ -21,9 +21,45 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = {
   * Connector
   */
 
+static int ast_vga_connector_helper_get_modes(struct drm_connector *connector)
+{
+	int count = drm_connector_helper_get_modes(connector);
+
+	if (!count) {
+		/*
+		 * 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)
+{
+	enum drm_connector_status old_status, status;
+
+	if (connector->edid_blob_ptr)
+		old_status = connector_status_connected;
+	else
+		old_status = connector_status_disconnected;
+
+	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
+
+	if (status != old_status)
+		++connector->epoch_counter;
+	return connector_status_connected;
+}
+
  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,
+	.get_modes = ast_vga_connector_helper_get_modes,
+	.detect_ctx = ast_vga_connector_helper_detect_ctx,
  };
 
  static const struct drm_connector_funcs ast_vga_connector_funcs = {
author maintainer
#15 lore raw

PATCH v2 9/9 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.

---
 drivers/gpu/drm/ast/ast_drv.h  |   4 --
 drivers/gpu/drm/ast/ast_mode.c | 107 ---------------------------------
 2 files changed, 111 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +0 -4
index 3a4f80cb5c0f..a4cde495fde4 100644
@@ -206,10 +206,6 @@ struct ast_device {
 			struct drm_encoder encoder;
 			struct drm_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
reviewer Reviewed-by on v2 9/9
#16 lore raw

Re: [PATCH v2 9/9] drm/ast: Remove BMC output

Quoted 9 lines · 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.

Thanks, it looks good to me.

Quoted 178 lines
---
  drivers/gpu/drm/ast/ast_drv.h  |   4 --
  drivers/gpu/drm/ast/ast_mode.c | 107 ---------------------------------
  2 files changed, 111 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +0 -4
index 3a4f80cb5c0f..a4cde495fde4 100644
@@ -206,10 +206,6 @@ struct ast_device {
  			struct drm_encoder encoder;
  			struct drm_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
index d823e9d85b04..ed496fb32bf3 100644
@@ -34,10 +34,8 @@
 
  #include <drm/drm_atomic.h>
  #include <drm/drm_atomic_helper.h>
-#include <drm/drm_atomic_state_helper.h>
  #include <drm/drm_crtc.h>
  #include <drm/drm_damage_helper.h>
-#include <drm/drm_edid.h>
  #include <drm/drm_format_helper.h>
  #include <drm/drm_fourcc.h>
  #include <drm/drm_gem_atomic_helper.h>
@@ -1309,103 +1307,6 @@ static int ast_crtc_init(struct drm_device *dev)
  	return 0;
  }
 
-/*
- * BMC virtual Connector
- */
-
-static const struct drm_encoder_funcs ast_bmc_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
-static int ast_bmc_connector_helper_detect_ctx(struct drm_connector *connector,
-					       struct drm_modeset_acquire_ctx *ctx,
-					       bool force)
-{
-	struct ast_bmc_connector *bmc_connector = to_ast_bmc_connector(connector);
-	struct drm_connector *physical_connector = bmc_connector->physical_connector;
-
-	/*
-	 * Most user-space compositors cannot handle more than one connected
-	 * connector per CRTC. Hence, we only mark the BMC as connected if the
-	 * physical connector is disconnected. If the physical connector's status
-	 * is connected or unknown, the BMC remains disconnected. This has no
-	 * effect on the output of the BMC.
-	 *
-	 * FIXME: Remove this logic once user-space compositors can handle more
-	 *        than one connector per CRTC. The BMC should always be connected.
-	 */
-
-	if (physical_connector && physical_connector->status == connector_status_disconnected)
-		return connector_status_connected;
-
-	return connector_status_disconnected;
-}
-
-static int ast_bmc_connector_helper_get_modes(struct drm_connector *connector)
-{
-	return drm_add_modes_noedid(connector, 4096, 4096);
-}
-
-static const struct drm_connector_helper_funcs ast_bmc_connector_helper_funcs = {
-	.get_modes = ast_bmc_connector_helper_get_modes,
-	.detect_ctx = ast_bmc_connector_helper_detect_ctx,
-};
-
-static const struct drm_connector_funcs ast_bmc_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,
-};
-
-static int ast_bmc_connector_init(struct drm_device *dev,
-				  struct ast_bmc_connector *bmc_connector,
-				  struct drm_connector *physical_connector)
-{
-	struct drm_connector *connector = &bmc_connector->base;
-	int ret;
-
-	ret = drm_connector_init(dev, connector, &ast_bmc_connector_funcs,
-				 DRM_MODE_CONNECTOR_VIRTUAL);
-	if (ret)
-		return ret;
-
-	drm_connector_helper_add(connector, &ast_bmc_connector_helper_funcs);
-
-	bmc_connector->physical_connector = physical_connector;
-
-	return 0;
-}
-
-static int ast_bmc_output_init(struct ast_device *ast,
-			       struct drm_connector *physical_connector)
-{
-	struct drm_device *dev = &ast->base;
-	struct drm_crtc *crtc = &ast->crtc;
-	struct drm_encoder *encoder = &ast->output.bmc.encoder;
-	struct ast_bmc_connector *bmc_connector = &ast->output.bmc.bmc_connector;
-	struct drm_connector *connector = &bmc_connector->base;
-	int ret;
-
-	ret = drm_encoder_init(dev, encoder,
-			       &ast_bmc_encoder_funcs,
-			       DRM_MODE_ENCODER_VIRTUAL, "ast_bmc");
-	if (ret)
-		return ret;
-	encoder->possible_crtcs = drm_crtc_mask(crtc);
-
-	ret = ast_bmc_connector_init(dev, bmc_connector, physical_connector);
-	if (ret)
-		return ret;
-
-	ret = drm_connector_attach_encoder(connector, encoder);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
  /*
   * Mode config
   */
@@ -1457,7 +1358,6 @@ static const struct drm_mode_config_funcs ast_mode_config_funcs = {
  int ast_mode_config_init(struct ast_device *ast)
  {
  	struct drm_device *dev = &ast->base;
-	struct drm_connector *physical_connector = NULL;
  	int ret;
 
  	ret = drmm_mutex_init(dev, &ast->modeset_lock);
@@ -1502,29 +1402,22 @@ 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;
  	}
  	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;
  	}
  	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;
  	}
  	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;
  	}
-	ret = ast_bmc_output_init(ast, physical_connector);
-	if (ret)
-		return ret;
 
  	drm_mode_config_reset(dev);
 
author maintainer
#17 lore raw

Re: [PATCH v2 9/9] drm/ast: Remove BMC output

Hi

Am 13.08.24 um 15:20 schrieb Jocelyn Falempe:

Quoted 8 lines · Thomas Zimmermann
Quoted 5 lines

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.

Quoted 7 lines
Quoted 4 lines

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.

Thanks, it looks good to me.

Thanks for reviewing. If no further comments come in, I'll merge the patchset later this week.

Best regards
Thomas

Quoted 191 lines
Quoted 190 lines

---
  drivers/gpu/drm/ast/ast_drv.h  |   4 -- drivers/gpu/drm/ast/ast_mode.c | 107 ---------------------------------

  2 files changed, 111 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +0 -4
index 3a4f80cb5c0f..a4cde495fde4 100644
@@ -206,10 +206,6 @@ struct ast_device {
               struct drm_encoder encoder;
               struct drm_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 -2
index d823e9d85b04..ed496fb32bf3 100644
@@ -34,10 +34,8 @@
     #include <drm/drm_atomic.h>
   #include <drm/drm_atomic_helper.h>
-#include <drm/drm_atomic_state_helper.h>
   #include <drm/drm_crtc.h>
   #include <drm/drm_damage_helper.h>
-#include <drm/drm_edid.h>
   #include <drm/drm_format_helper.h>
   #include <drm/drm_fourcc.h>
   #include <drm/drm_gem_atomic_helper.h>
@@ -1309,103 +1307,6 @@ static int ast_crtc_init(struct drm_device *dev)
       return 0;
   }

  -/*
- * BMC virtual Connector
- */

drivers/gpu/drm/ast/ast_mode.c +0 -6
-
-static const struct drm_encoder_funcs ast_bmc_encoder_funcs = {
-    .destroy = drm_encoder_cleanup,
-};
-
-static int ast_bmc_connector_helper_detect_ctx(struct drm_connector 

*connector,
-                           struct drm_modeset_acquire_ctx *ctx, -                           bool force)
-{
-    struct ast_bmc_connector *bmc_connector = to_ast_bmc_connector(connector);
-    struct drm_connector *physical_connector = bmc_connector->physical_connector;
-
-    /*
-     * Most user-space compositors cannot handle more than one connected
-     * connector per CRTC. Hence, we only mark the BMC as connected if the
-     * physical connector is disconnected. If the physical connector's status
-     * is connected or unknown, the BMC remains disconnected. This has no
-     * effect on the output of the BMC.
-     *
-     * FIXME: Remove this logic once user-space compositors can handle more
-     *        than one connector per CRTC. The BMC should always be connected.
-     */
-
-    if (physical_connector && physical_connector->status == connector_status_disconnected)
-        return connector_status_connected;

drivers/gpu/drm/ast/ast_mode.c +0 -5
-
-    return connector_status_disconnected;
-}
-
-static int ast_bmc_connector_helper_get_modes(struct drm_connector 

*connector)

drivers/gpu/drm/ast/ast_mode.c +0 -5
-{
-    return drm_add_modes_noedid(connector, 4096, 4096);
-}
-
-static const struct drm_connector_helper_funcs 

ast_bmc_connector_helper_funcs = {
-    .get_modes = ast_bmc_connector_helper_get_modes, -    .detect_ctx = ast_bmc_connector_helper_detect_ctx,

drivers/gpu/drm/ast/ast_mode.c +0 -7
-};
-
-static const struct drm_connector_funcs ast_bmc_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,

drivers/gpu/drm/ast/ast_mode.c +0 -15
-};
-
-static int ast_bmc_connector_init(struct drm_device *dev,
-                  struct ast_bmc_connector *bmc_connector,
-                  struct drm_connector *physical_connector)
-{
-    struct drm_connector *connector = &bmc_connector->base;
-    int ret;
-
-    ret = drm_connector_init(dev, connector, &ast_bmc_connector_funcs,
-                 DRM_MODE_CONNECTOR_VIRTUAL);
-    if (ret)
-        return ret;
-
-    drm_connector_helper_add(connector, 

&ast_bmc_connector_helper_funcs);

drivers/gpu/drm/ast/ast_mode.c +0 -13
-
-    bmc_connector->physical_connector = physical_connector;
-
-    return 0;
-}
-
-static int ast_bmc_output_init(struct ast_device *ast,
-                   struct drm_connector *physical_connector)
-{
-    struct drm_device *dev = &ast->base;
-    struct drm_crtc *crtc = &ast->crtc;
-    struct drm_encoder *encoder = &ast->output.bmc.encoder;
-    struct ast_bmc_connector *bmc_connector = 

&ast->output.bmc.bmc_connector;
-    struct drm_connector *connector = &bmc_connector->base; -    int ret;

drivers/gpu/drm/ast/ast_mode.c +0 -9
-
-    ret = drm_encoder_init(dev, encoder,
-                   &ast_bmc_encoder_funcs,
-                   DRM_MODE_ENCODER_VIRTUAL, "ast_bmc");
-    if (ret)
-        return ret;
-    encoder->possible_crtcs = drm_crtc_mask(crtc);
-
-    ret = ast_bmc_connector_init(dev, bmc_connector, 

physical_connector);
-    if (ret)
-        return ret;

drivers/gpu/drm/ast/ast_mode.c +0 -8
-
-    ret = drm_connector_attach_encoder(connector, encoder);
-    if (ret)
-        return ret;
-
-    return 0;
-}
-

  /*
   * Mode config
   */

drivers/gpu/drm/ast/ast_mode.c +0 -8
@@ -1457,7 +1358,6 @@ static const struct drm_mode_config_funcs 
 ast_mode_config_funcs = {
   int ast_mode_config_init(struct ast_device *ast)
   {
       struct drm_device *dev = &ast->base;
-    struct drm_connector *physical_connector = NULL;
       int ret;
         ret = drmm_mutex_init(dev, &ast->modeset_lock);
@@ -1502,29 +1402,22 @@ 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;
       }
       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;
       }
       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;
       }
       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;
       }
-    ret = ast_bmc_output_init(ast, physical_connector);
-    if (ret)
-        return ret;
         drm_mode_config_reset(dev);
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)