From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 1/4] lib/igt_fb: Rework igt_fb_modifier_name()
Date: Thu, 16 Nov 2023 15:24:49 +0200 [thread overview]
Message-ID: <20231116132452.2671-1-ville.syrjala@linux.intel.com> (raw)
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Replace the switch statement in igt_fb_modifier_name() with
a table so that we'll be able to also do the reverse mapping.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
lib/igt_fb.c | 59 ++++++++++++++++++++++++----------------------------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index e531a041e567..5670bc06c778 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -4913,39 +4913,34 @@ void igt_format_array_fill(uint32_t **formats_array, unsigned int *count,
}
}
+static const struct {
+ uint64_t modifier;
+ const char *name;
+} modifiers[] = {
+ { .modifier = DRM_FORMAT_MOD_LINEAR, .name = "linear", },
+ { .modifier = I915_FORMAT_MOD_X_TILED, .name = "x", },
+ { .modifier = I915_FORMAT_MOD_Y_TILED, .name = "y", },
+ { .modifier = I915_FORMAT_MOD_Yf_TILED, .name = "yf", },
+ { .modifier = I915_FORMAT_MOD_Y_TILED_CCS, .name = "y-ccs", },
+ { .modifier = I915_FORMAT_MOD_Yf_TILED_CCS, .name = "yf-ccs", },
+ { .modifier = I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS, .name = "y-rc-ccs", },
+ { .modifier = I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC, .name = "y-rc-ccs-cc", },
+ { .modifier = I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS, .name = "y-mc-ccs", },
+ { .modifier = I915_FORMAT_MOD_4_TILED, .name = "4", },
+ { .modifier = I915_FORMAT_MOD_4_TILED_DG2_RC_CCS, .name = "4-rc-ccs", },
+ { .modifier = I915_FORMAT_MOD_4_TILED_DG2_MC_CCS, .name = "4-mc-ccs", },
+ { .modifier = I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC, .name = "4-rc-ccs-cc", },
+ { .modifier = I915_FORMAT_MOD_4_TILED_MTL_RC_CCS, .name = "4-rc-ccs", },
+ { .modifier = I915_FORMAT_MOD_4_TILED_MTL_MC_CCS, .name = "4-rc-ccs", },
+ { .modifier = I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC, .name = "4-rc-ccs-cc", },
+};
+
const char *igt_fb_modifier_name(uint64_t modifier)
{
- switch (modifier) {
- case DRM_FORMAT_MOD_LINEAR:
- return "linear";
- case I915_FORMAT_MOD_X_TILED:
- return "x";
- case I915_FORMAT_MOD_Y_TILED:
- return "y";
- case I915_FORMAT_MOD_Yf_TILED:
- return "yf";
- case I915_FORMAT_MOD_Y_TILED_CCS:
- return "y-ccs";
- case I915_FORMAT_MOD_Yf_TILED_CCS:
- return "yf-ccs";
- case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
- return "y-rc-ccs";
- case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC:
- return "y-rc-ccs-cc";
- case I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS:
- return "y-mc-ccs";
- case I915_FORMAT_MOD_4_TILED:
- return "4";
- case I915_FORMAT_MOD_4_TILED_MTL_RC_CCS:
- case I915_FORMAT_MOD_4_TILED_DG2_RC_CCS:
- return "4-rc-ccs";
- case I915_FORMAT_MOD_4_TILED_MTL_MC_CCS:
- case I915_FORMAT_MOD_4_TILED_DG2_MC_CCS:
- return "4-mc-ccs";
- case I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC:
- case I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC:
- return "4-rc-ccs-cc";
- default:
- return "?";
+ for (int i = 0; i < ARRAY_SIZE(modifiers); i++) {
+ if (modifier == modifiers[i].modifier)
+ return modifiers[i].name;
}
+
+ return "?";
}
--
2.41.0
next 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 Ville Syrjala [this message]
2023-11-16 13:24 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Provide igt_fb_modifier_for_name() Ville Syrjala
2023-11-17 13:24 ` 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-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