[PATCH 08/12] drm/client: Extract drm_connector_first_mode()
Ville Syrjala
ville.syrjala at linux.intel.com
Thu Apr 4 20:33:32 UTC 2024
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
Use a consistent method for picking the first mode from the
connnector's mode list.
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
drivers/gpu/drm/drm_client_modeset.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
index 08fc896885dd..1fba6cd8d761 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -159,6 +159,13 @@ drm_connector_preferred_mode(struct drm_connector *connector, int width, int hei
return NULL;
}
+static const struct drm_display_mode *
+drm_connector_first_mode(struct drm_connector *connector)
+{
+ return list_first_entry_or_null(&connector->modes,
+ struct drm_display_mode, head);
+}
+
static const struct drm_display_mode *
drm_connector_pick_cmdline_mode(struct drm_connector *connector)
{
@@ -439,10 +446,8 @@ static bool drm_client_target_preferred(struct drm_connector *connectors[],
modes[i] = drm_connector_preferred_mode(connector, width, height);
}
/* No preferred modes, pick one off the list */
- if (!modes[i] && !list_empty(&connector->modes)) {
- list_for_each_entry(modes[i], &connector->modes, head)
- break;
- }
+ if (!modes[i])
+ modes[i] = drm_connector_first_mode(connector);
/*
* In case of tiled mode if all tiles not present fallback to
* first available non tiled mode.
@@ -684,9 +689,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
if (!modes[i] && !list_empty(&connector->modes)) {
DRM_DEBUG_KMS("using first mode listed on connector %s\n",
connector->name);
- modes[i] = list_first_entry(&connector->modes,
- struct drm_display_mode,
- head);
+ modes[i] = drm_connector_first_mode(connector);
}
/* last resort: use current mode */
--
2.43.2
More information about the Intel-gfx
mailing list