mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-27 03:49:57 -04:00
drm/format-helper: Add generic conversion to 8-bit formats
Add drm_fb_xfrm_line_32to8() to implement conversion from 32-bit pixels to 8-bit pixels. The pixel-conversion is specified by the given callback parameter. Mark the helper as always_inline to avoid overhead from function calls. Then implement all existing line-conversion functions with the new generic call and the respective pixel-conversion helper. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://lore.kernel.org/r/20250328141709.217283-6-tzimmermann@suse.de
This commit is contained in:
@@ -35,6 +35,23 @@
|
||||
* Conversions from XRGB8888
|
||||
*/
|
||||
|
||||
static inline u32 drm_pixel_xrgb8888_to_r8_bt601(u32 pix)
|
||||
{
|
||||
u32 r = (pix & 0x00ff0000) >> 16;
|
||||
u32 g = (pix & 0x0000ff00) >> 8;
|
||||
u32 b = pix & 0x000000ff;
|
||||
|
||||
/* ITU-R BT.601: Y = 0.299 R + 0.587 G + 0.114 B */
|
||||
return (3 * r + 6 * g + b) / 10;
|
||||
}
|
||||
|
||||
static inline u32 drm_pixel_xrgb8888_to_rgb332(u32 pix)
|
||||
{
|
||||
return ((pix & 0x00e00000) >> 16) |
|
||||
((pix & 0x0000e000) >> 11) |
|
||||
((pix & 0x000000c0) >> 6);
|
||||
}
|
||||
|
||||
static inline u32 drm_pixel_xrgb8888_to_rgb565(u32 pix)
|
||||
{
|
||||
return ((pix & 0x00f80000) >> 8) |
|
||||
|
||||
Reference in New Issue
Block a user