From: Sowmiya S <sowmiya.s@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: swati2.sharma@intel.com, suraj.kandpal@intel.com,
Sowmiya S <sowmiya.s@intel.com>
Subject: [PATCH i-g-t v8 4/9] lib/igt_fb: Add helper to get bpc from DRM fourcc
Date: Wed, 4 Feb 2026 22:48:13 +0530 [thread overview]
Message-ID: <20260204171819.292327-5-sowmiya.s@intel.com> (raw)
In-Reply-To: <20260204171819.292327-1-sowmiya.s@intel.com>
Introduce igt_drm_format_get_bpc, which returns
the nominal bits per color channel (BPC) for
common RGB DRM fourcc formats.
Signed-off-by: Sowmiya S <sowmiya.s@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
lib/igt_fb.c | 33 +++++++++++++++++++++++++++++++++
lib/igt_fb.h | 1 +
2 files changed, 34 insertions(+)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 3a1553d48..b3575d266 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -5083,6 +5083,39 @@ int igt_fb_get_fnv1a_crc(struct igt_fb *fb, igt_crc_t *crc)
return 0;
}
+/**
+ * igt_drm_format_get_bpc: Return bits-per-channel for a DRM fourcc format
+ * @drm_format: drm fourcc code
+ *
+ * Returns the nominal bits-per-color-channel (BPC) for the given @drm_format.
+ * This helper is intended for RGB formats and currently covers common packed
+ * and planar RGB(A/X) variants. Non-RGB formats are not yet handled.
+ * Extend as needed to cover additional FOURCCs (including YUV) by
+ * adding explicit cases.
+ */
+int igt_drm_format_get_bpc(uint32_t drm_format)
+{
+ switch (drm_format) {
+ case DRM_FORMAT_XRGB8888:
+ case DRM_FORMAT_ARGB8888:
+ case DRM_FORMAT_XBGR8888:
+ case DRM_FORMAT_ABGR8888:
+ return 8;
+ case DRM_FORMAT_XRGB2101010:
+ case DRM_FORMAT_ARGB2101010:
+ case DRM_FORMAT_XBGR2101010:
+ case DRM_FORMAT_ABGR2101010:
+ return 10;
+ case DRM_FORMAT_XRGB16161616F:
+ case DRM_FORMAT_XBGR16161616F:
+ case DRM_FORMAT_ARGB16161616F:
+ case DRM_FORMAT_ABGR16161616F:
+ return 16;
+ default:
+ return -1;
+ }
+}
+
/**
* igt_format_is_yuv:
* @drm_format: drm fourcc
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 8e5907dab..844b27ff2 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -222,6 +222,7 @@ int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align,
/* helpers to handle drm fourcc codes */
uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth);
uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
+int igt_drm_format_get_bpc(uint32_t drm_format);
const char *igt_format_str(uint32_t drm_format);
bool igt_fb_supported_format(uint32_t drm_format);
bool igt_format_is_yuv(uint32_t drm_format);
--
2.43.0
next prev parent reply other threads:[~2026-02-04 16:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 17:18 [PATCH i-g-t v8 0/9] Add writeback changes for intel-supported formats Sowmiya S
2026-02-04 17:18 ` [PATCH i-g-t v8 1/9] tests/kms_writeback: Add support for intel-specific formats Sowmiya S
2026-02-04 17:18 ` [PATCH i-g-t v8 2/9] lib/igt_fb: Validate supported formats for crc calculation Sowmiya S
2026-02-04 17:18 ` [PATCH i-g-t v8 3/9] tests/kms_writeback: Update checks for zero FB ID and empty writeback commit Sowmiya S
2026-02-04 17:18 ` Sowmiya S [this message]
2026-02-04 17:18 ` [PATCH i-g-t v8 5/9] tests/kms_writeback: Refactor format handling in commit_and_dump_fb Sowmiya S
2026-02-04 17:18 ` [PATCH i-g-t v8 6/9] tests/kms_writeback: Remove unused invalid_fb parameter Sowmiya S
2026-02-05 2:55 ` Kandpal, Suraj
2026-02-04 17:18 ` [PATCH i-g-t v8 7/9] tests/kms_writeback: Refactor writeback-fb-id subtest Sowmiya S
2026-02-04 17:18 ` [PATCH i-g-t v8 8/9] tests/kms_writeback: Refactor writeback-check-output subtest Sowmiya S
2026-02-12 16:04 ` Bilal, Mohammed
2026-02-04 17:18 ` [PATCH i-g-t v8 9/9] tests/kms_writeback: Use helper to fetch default FB format Sowmiya S
2026-02-04 19:07 ` ✓ Xe.CI.BAT: success for Add writeback changes for intel-supported formats (rev8) Patchwork
2026-02-04 19:13 ` ✓ i915.CI.BAT: " Patchwork
2026-02-05 6:13 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-02-05 9:27 ` ✓ i915.CI.Full: success " Patchwork
2026-02-09 8:14 ` [PATCH i-g-t v8 0/9] Add writeback changes for intel-supported formats Karthik B S
2026-02-09 8:34 ` Kandpal, Suraj
2026-02-13 7:08 ` Karthik B S
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=20260204171819.292327-5-sowmiya.s@intel.com \
--to=sowmiya.s@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=suraj.kandpal@intel.com \
--cc=swati2.sharma@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