[PATCH v3 15/21] drm: Add helper to extract a LUT entry from either 16-bit or 32-bit LUT
Ariel D'Alessandro
ariel.dalessandro at collabora.com
Tue Dec 23 10:01:35 PST 2025
Add a common helper to ease extracting a 32-bit LUT entry from either
16-bit or 32-bit LUT entry. This is handy for code that needs to handle
both bit widths.
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro at collabora.com>
Co-developed-by: Nícolas F. R. A. Prado <nfraprado at collabora.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado at collabora.com>
---
include/drm/drm_color_mgmt.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 51279267ed3fd..3d0117aae342d 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -66,6 +66,33 @@ static inline u32 drm_color_lut32_extract(u32 user_input, int bit_precision)
(1ULL << 32) - 1);
}
+/**
+ * drm_color_lut_to_lut32 - Copy LUT entry contents to 32-bit channel color LUT
+ *
+ * @dest: The destination 32-bit per channel color LUT entry
+ * @src: The source array of LUT entries (16-bit or 32-bit depending on @bits32)
+ * @index: LUT entry array index
+ * @bits32: Boolean indicating the source LUT entry bit-witdh
+ *
+ * Copy the contents of a LUT entry from the source array, to a 32-bit channel
+ * color LUT. The source array of LUT entries can be 16-bit or 32-bit width
+ * depending on the @bits32 boolean argument.
+ */
+static inline void drm_color_lut_to_lut32(struct drm_color_lut32 *dest,
+ void *src, int index, bool bits32)
+{
+ if (bits32) {
+ *dest = ((struct drm_color_lut32 *)src)[index];
+ } else {
+ struct drm_color_lut *lut =
+ &((struct drm_color_lut *)src)[index];
+ dest->red = lut->red;
+ dest->green = lut->green;
+ dest->blue = lut->blue;
+ dest->reserved = lut->reserved;
+ }
+}
+
/**
* drm_color_ctm_to_ctm_3x4 - Copy CTM matrix contents to 3x4 dimensions matrix
*
--
2.51.0
More information about the Linux-mediatek
mailing list