From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Subject: [PATCH i-g-t v2 1/4] lib/kms: Introduce struct igt_forced_connector
Date: Thu, 11 Apr 2024 21:34:47 +0300 [thread overview]
Message-ID: <20240411183450.6417-1-ville.syrjala@linux.intel.com> (raw)
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Give the forced_connector[] struct a proper type name,
and utilize it in various places to make the code
less messy.
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
lib/igt_kms.c | 50 +++++++++++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 60339565a192..d20a93372540 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -91,12 +91,14 @@
#define MAX_EDID 2
#define DISPLAY_TILE_BLOCK 0x12
-static struct {
+struct igt_forced_connector {
uint32_t connector_type;
uint32_t connector_type_id;
int idx;
int dir;
-} forced_connectors[MAX_CONNECTORS + 1];
+};
+
+static struct igt_forced_connector forced_connectors[MAX_CONNECTORS + 1];
/**
* igt_kms_get_base_edid:
@@ -1498,31 +1500,37 @@ static bool connector_is_forced(int idx, drmModeConnector *connector)
igt_assert(connector->connector_type != 0);
for (int i = 0; forced_connectors[i].connector_type; i++) {
- if (forced_connectors[i].idx == idx &&
- forced_connectors[i].connector_type == connector->connector_type &&
- forced_connectors[i].connector_type_id == connector->connector_type_id)
+ struct igt_forced_connector *c = &forced_connectors[i];
+
+ if (c->idx == idx &&
+ c->connector_type == connector->connector_type &&
+ c->connector_type_id == connector->connector_type_id)
return true;
}
return false;
}
-static int forced_connector_free_index(void)
+static struct igt_forced_connector *forced_connector_alloc(void)
{
int i;
for (i = 0; forced_connectors[i].connector_type; i++)
;
- return i < ARRAY_SIZE(forced_connectors) ? i : -1;
+ if (i >= ARRAY_SIZE(forced_connectors))
+ return NULL;
+
+ return &forced_connectors[i];
}
static bool force_connector(int drm_fd,
drmModeConnector *connector,
const char *value)
{
+ struct igt_forced_connector *c;
char name[80];
- int i, idx, dir;
+ int idx, dir;
idx = igt_device_get_card_index(drm_fd);
if (idx < 0 || idx > 63)
@@ -1549,17 +1557,17 @@ static bool force_connector(int drm_fd,
return true;
}
- i = forced_connector_free_index();
- if (i < 0) {
+ c = forced_connector_alloc();
+ if (!c) {
igt_warn("Connector limit reached, %s will not be reset\n", name);
close(dir);
return true;
}
- forced_connectors[i].idx = idx;
- forced_connectors[i].connector_type = connector->connector_type;
- forced_connectors[i].connector_type_id = connector->connector_type_id;
- forced_connectors[i].dir = dir;
+ c->idx = idx;
+ c->connector_type = connector->connector_type;
+ c->connector_type_id = connector->connector_type_id;
+ c->dir = dir;
return true;
}
@@ -1571,9 +1579,10 @@ static void dump_forced_connectors(void)
igt_debug("Current forced connectors:\n");
for (int i = 0; forced_connectors[i].connector_type; i++) {
- kmstest_connector_dirname(forced_connectors[i].idx,
- forced_connectors[i].connector_type,
- forced_connectors[i].connector_type_id,
+ struct igt_forced_connector *c = &forced_connectors[i];
+
+ kmstest_connector_dirname(c->idx, c->connector_type,
+ c->connector_type_id,
name, sizeof(name));
igt_debug("\t%s\n", name);
}
@@ -5302,8 +5311,11 @@ void igt_reset_connectors(void)
{
/* reset the connectors stored in forced_connectors, avoiding any
* functions that are not safe to call in signal handlers */
- for (int i = 0; i < forced_connectors[i].connector_type; i++)
- igt_sysfs_set(forced_connectors[i].dir, "status", "detect");
+ for (int i = 0; i < forced_connectors[i].connector_type; i++) {
+ struct igt_forced_connector *c = &forced_connectors[i];
+
+ igt_sysfs_set(c->dir, "status", "detect");
+ }
}
/**
--
2.43.2
next reply other threads:[~2024-04-11 18:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 18:34 Ville Syrjala [this message]
2024-04-11 18:34 ` [PATCH i-g-t v2 2/4] lib/kms: Adjust forced_connectors[] traversal Ville Syrjala
2024-04-14 5:56 ` Joshi, Kunal1
2024-04-11 18:34 ` [PATCH i-g-t v2 3/4] lib/kms: Generalize forced_connectors[] to handle arbitrary attributes Ville Syrjala
2024-04-14 5:57 ` Joshi, Kunal1
2024-04-11 18:34 ` [PATCH i-g-t v2 4/4] lib/kms: Clear connector_attrs[] upon setting the reset value Ville Syrjala
2024-04-14 5:59 ` Joshi, Kunal1
2024-04-16 12:33 ` Ville Syrjälä
2024-04-11 19:17 ` ✓ CI.xeBAT: success for series starting with [i-g-t,v2,1/4] lib/kms: Introduce struct igt_forced_connector Patchwork
2024-04-11 19:26 ` ✓ Fi.CI.BAT: " Patchwork
2024-04-12 1:49 ` ✗ CI.xeFULL: failure " Patchwork
2024-04-12 5:17 ` ✗ Fi.CI.IGT: " Patchwork
2024-04-14 5:55 ` [PATCH i-g-t v2 1/4] " Joshi, Kunal1
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=20240411183450.6417-1-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kunal1.joshi@intel.com \
/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