From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] tests/i915_pm_rpm: Try the standard "ddc" symlink for i2c read
Date: Wed, 5 Jul 2023 22:34:54 +0300 [thread overview]
Message-ID: <20230705193454.14033-1-ville.syrjala@linux.intel.com> (raw)
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
The driver may provide the standard "ddc" symlink in sysfs,
try that first for the i2c read, then fall back to the old
i915 specific stuff.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
tests/i915/i915_pm_rpm.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index 4ce83f27f86a..17413ffe5e0f 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -861,13 +861,15 @@ static void assert_drm_infos_equal(struct compare_data *d1,
assert_drm_crtcs_equal(d1->crtcs[i], d2->crtcs[i]);
}
-static bool find_i2c_path(const char *connector_name, char *i2c_path)
+static bool find_i2c_path(const char *connector_name,
+ char *i2c_path, size_t i2c_path_size)
{
struct dirent *dirent;
DIR *dir;
int sysfs_card_fd = igt_sysfs_open(drm_fd);
int connector_fd = -1;
bool found_i2c_file = false;
+ ssize_t r;
dir = fdopendir(sysfs_card_fd);
igt_assert(dir);
@@ -889,9 +891,24 @@ static bool find_i2c_path(const char *connector_name, char *i2c_path)
if (connector_fd < 0)
return false;
+ /* try the standard "ddc" symlink first */
+ r = readlinkat(connector_fd, "ddc", i2c_path, i2c_path_size);
+ if (r > 0 && r != i2c_path_size) {
+ int num;
+
+ i2c_path[r] = '\0';
+
+ if (sscanf(basename(i2c_path), "i2c-%d", &num) == 1) {
+ snprintf(i2c_path, i2c_path_size, "/dev/i2c-%d", num);
+ return true;
+ }
+ }
+
dir = fdopendir(connector_fd);
igt_assert(dir);
+ /* fall back to old "i2c-?" symlink */
+ /* FIXME nuke this at some point */
while ((dirent = readdir(dir))) {
if (strncmp(dirent->d_name, "i2c-", 4) == 0) {
sprintf(i2c_path, "/dev/%s", dirent->d_name);
@@ -926,10 +943,12 @@ static bool i2c_read_edid(const char *connector_name, unsigned char *edid)
.nmsgs = 2,
};
- result = find_i2c_path(connector_name, i2c_path);
+ result = find_i2c_path(connector_name, i2c_path, sizeof(i2c_path));
if (!result)
return false;
+ igt_info("Testing %s %s\n", connector_name, i2c_path);
+
fd = open(i2c_path, O_RDWR);
igt_assert_neq(fd, -1);
--
2.39.3
next reply other threads:[~2023-07-05 19:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-05 19:34 Ville Syrjala [this message]
2023-07-05 20:29 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/i915_pm_rpm: Try the standard "ddc" symlink for i2c read Patchwork
2023-07-05 23:14 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-07-14 7:34 ` Kamil Konieczny
2023-07-14 9:10 ` Yedireswarapu, SaiX Nandan
2023-07-14 7:33 ` [igt-dev] [PATCH i-g-t] " Kamil Konieczny
2023-07-14 8:35 ` [igt-dev] ✓ Fi.CI.IGT: success for " Patchwork
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=20230705193454.14033-1-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/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