Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Provide igt_fb_modifier_for_name()
Date: Thu, 16 Nov 2023 15:24:50 +0200	[thread overview]
Message-ID: <20231116132452.2671-2-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20231116132452.2671-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a function that given a modifier's human readable
name returns the actual modifier magic number.

TODO: figure out what to do about the "same" modifier with
      multiple platform variants...

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_fb.c | 10 ++++++++++
 lib/igt_fb.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 5670bc06c778..24275c06354b 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -4944,3 +4944,13 @@ const char *igt_fb_modifier_name(uint64_t modifier)
 
 	return "?";
 }
+
+uint64_t igt_fb_modifier_for_name(const char *name)
+{
+	for (int i = 0; i < ARRAY_SIZE(modifiers); i++) {
+		if (!strcasecmp(name, modifiers[i].name))
+			return modifiers[i].modifier;
+	}
+
+	return DRM_FORMAT_MOD_INVALID;
+}
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 834aaef54dea..3bb577c02cd9 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -230,6 +230,7 @@ int igt_fill_cts_color_square_framebuffer(uint32_t *pixmap,
 
 int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc);
 const char *igt_fb_modifier_name(uint64_t modifier);
+uint64_t igt_fb_modifier_for_name(const char *name);
 
 #endif /* __IGT_FB_H__ */
 
-- 
2.41.0

  reply	other threads:[~2023-11-16 13:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 13:24 [igt-dev] [PATCH i-g-t 1/4] lib/igt_fb: Rework igt_fb_modifier_name() Ville Syrjala
2023-11-16 13:24 ` Ville Syrjala [this message]
2023-11-17 13:24   ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Provide igt_fb_modifier_for_name() Juha-Pekka Heikkila
2023-11-16 13:24 ` [igt-dev] [PATCH i-g-t 3/4] lib/igt_power: Add power_supply/BAT based measurement Ville Syrjala
2023-11-16 13:24 ` [igt-dev] [PATCH i-g-t 4/4] tests/kms_power_basic: Add basic power measurement test Ville Syrjala
2023-11-16 14:46 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/4] lib/igt_fb: Rework igt_fb_modifier_name() Patchwork
2023-11-17 11:48 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-11-17 12:17 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
2023-11-17 13:23 ` [igt-dev] [PATCH i-g-t 1/4] " Juha-Pekka Heikkila

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=20231116132452.2671-2-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