mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Louis Chauvet <louis.chauvet@bootlin.com>
To: "Maíra Canal" <mairacanal@riseup.net>,
	"Haneen Mohammed" <hamohammed.sa@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Melissa Wen" <melissa.srw@gmail.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>
Cc: arthurgrillo@riseup.net, jeremie.dautheribes@bootlin.com,
	 miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com,
	 seanpaul@google.com, nicolejadeyee@google.com,
	linux-kernel@vger.kernel.org,  dri-devel@lists.freedesktop.org,
	Louis Chauvet <louis.chauvet@bootlin.com>
Subject: [PATCH v3 15/16] drm/vkms: Introduce config for connector EDID
Date: Tue, 21 Jan 2025 11:55:39 +0100	[thread overview]
Message-ID: <20250121-google-remove-crtc-index-from-parameter-v3-15-cac00a3c3544@bootlin.com> (raw)
In-Reply-To: <20250121-google-remove-crtc-index-from-parameter-v3-0-cac00a3c3544@bootlin.com>

To properly test the EDID reading without using the DRM override, add an
option to configure the EDID for a connector.

Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
 drivers/gpu/drm/vkms/vkms_config.c |  1 +
 drivers/gpu/drm/vkms/vkms_config.h |  2 ++
 drivers/gpu/drm/vkms/vkms_output.c | 37 ++++++++++++++++++++++++++++++++++---
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 5eba4284269d058f12f78ddba96cb40215e85f72..3e8883298e73e75fb16ac05e449a7ee8fac72935 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -162,6 +162,7 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *v
 	xa_init_flags(&vkms_config_connector->possible_encoders, XA_FLAGS_ALLOC);
 	vkms_config_connector->type = DRM_MODE_CONNECTOR_VIRTUAL;
 	vkms_config_connector->status = connector_status_unknown;
+	vkms_config_connector->edid_blob_len = 0;
 
 	return vkms_config_connector;
 }
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 8e0c9b753821f75f10b3090743905471d0abac36..6844ca8523decd51116fb36f98ed40a09bc2284b 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -104,6 +104,8 @@ struct vkms_config_connector {
 	struct xarray possible_encoders;
 	int type;
 	enum drm_connector_status status;
+	char edid_blob[PAGE_SIZE];
+	int edid_blob_len;
 
 	/* Internal usage */
 	struct drm_connector *connector;
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index 75d90df44da3b6dd3ed3ae104a6bc6d51c9bf089..8f7df59aa2c1517eb78e9b94b8611b15431fd234 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -38,13 +38,44 @@ static const struct drm_connector_funcs vkms_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
+static int vkms_connector_read_block(void *context, u8 *buf, unsigned int block, size_t len)
+{
+	struct vkms_config_connector *config = context;
+
+	if (block * len + len > config->edid_blob_len)
+		return 1;
+	memcpy(buf, &config->edid_blob[block * len], len);
+	return 0;
+}
+
 static int vkms_conn_get_modes(struct drm_connector *connector)
 {
+	const struct drm_edid *drm_edid = NULL;
 	int count;
+	struct vkms_config_connector *connector_cfg;
+	struct vkms_device *vkmsdev = drm_device_to_vkms_device(connector->dev);
+	struct vkms_config_connector *context = NULL;
+
+	list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, link) {
+		if (connector_cfg->connector == connector) {
+			context = connector_cfg;
+			break;
+		}
+	}
+	if (context)
+		drm_edid = drm_edid_read_custom(connector, vkms_connector_read_block, context);
+
+	/*
+	 * Unconditionally update the connector. If the EDID was read
+	 * successfully, fill in the connector information derived from the
+	 * EDID. Otherwise, if the EDID is NULL, clear the connector
+	 * information.
+	 */
+	drm_edid_connector_update(connector, drm_edid);
+
+	count = drm_edid_connector_add_modes(connector);
 
-	/* Use the default modes list from DRM */
-	count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
-	drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
+	drm_edid_free(drm_edid);
 
 	return count;
 }

-- 
2.47.1


  parent reply	other threads:[~2025-01-21 10:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21 10:55 [PATCH v3 00/16] drm/vkms: Introduce detailed configuration Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 01/16] drm/vkms: Extract vkms_config header Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 02/16] drm/vkms: Add a validation function for vkms configuration Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 03/16] drm/vkms: Move default_config creation to its own function Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 04/16] drm/vkms: Introduce config for plane Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 05/16] drm/vkms: Introduce config for plane name Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 06/16] drm/vkms: Introduce config for plane rotation Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 07/16] drm/vkms: Introduce config for CRTCs and encoders Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 08/16] drm/vkms: Introduce config for encoder name Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 09/16] drm/vkms: Introduce config for CRTC name Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 10/16] drm/vkms: Add test for config structure Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 11/16] drm/vkms: Introduce config for connector Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 12/16] drm/vkms: Introduce config for connector type Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 13/16] drm/vkms: Introduce config for plane format Louis Chauvet
2025-01-21 10:55 ` [PATCH v3 14/16] drm/vkms: Introduce config for connector status Louis Chauvet
2025-01-21 10:55 ` Louis Chauvet [this message]
2025-01-21 10:55 ` [PATCH v3 16/16] drm/vkms: Introduce config for encoder type Louis Chauvet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250121-google-remove-crtc-index-from-parameter-v3-15-cac00a3c3544@bootlin.com \
    --to=louis.chauvet@bootlin.com \
    --cc=airlied@gmail.com \
    --cc=arthurgrillo@riseup.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=jeremie.dautheribes@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mairacanal@riseup.net \
    --cc=melissa.srw@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mripard@kernel.org \
    --cc=nicolejadeyee@google.com \
    --cc=seanpaul@google.com \
    --cc=simona@ffwll.ch \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®