Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/sysfb: Generalize pixel-format matching

Provide drm_sysfb_get_format(), a helper that finds a specific DRM
format from a list of pixel formats. The new function builds upon
drm_sysfb_get_format_si(), which finds the DRM format from a given
instance of struct screen_info. Now get the screen_info's pixel format
in the caller. Allows for matching pixel formats in drivers without
screen_info.

Convert the callers in efidrm and vesadrm to the new interface.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Julius Werner <jwerner@chromium.org>
Link: https://patch.msgid.link/20260217155836.96267-11-tzimmermann@suse.de

+42 -36
+24
drivers/gpu/drm/sysfb/drm_sysfb.c
··· 31 31 } 32 32 EXPORT_SYMBOL(drm_sysfb_get_validated_int0); 33 33 34 + const struct drm_format_info *drm_sysfb_get_format(struct drm_device *dev, 35 + const struct drm_sysfb_format *formats, 36 + size_t nformats, 37 + const struct pixel_format *pixel) 38 + { 39 + const struct drm_format_info *format = NULL; 40 + size_t i; 41 + 42 + for (i = 0; i < nformats; ++i) { 43 + const struct drm_sysfb_format *f = &formats[i]; 44 + 45 + if (pixel_format_equal(pixel, &f->pixel)) { 46 + format = drm_format_info(f->fourcc); 47 + break; 48 + } 49 + } 50 + 51 + if (!format) 52 + drm_warn(dev, "No compatible color format found\n"); 53 + 54 + return format; 55 + } 56 + EXPORT_SYMBOL(drm_sysfb_get_format); 57 + 34 58 MODULE_DESCRIPTION("Helpers for DRM sysfb drivers"); 35 59 MODULE_LICENSE("GPL");
+4 -4
drivers/gpu/drm/sysfb/drm_sysfb_helper.h
··· 36 36 u64 value, u32 max); 37 37 int drm_sysfb_get_validated_int0(struct drm_device *dev, const char *name, 38 38 u64 value, u32 max); 39 + const struct drm_format_info *drm_sysfb_get_format(struct drm_device *dev, 40 + const struct drm_sysfb_format *formats, 41 + size_t nformats, 42 + const struct pixel_format *pixel); 39 43 40 44 #if defined(CONFIG_SCREEN_INFO) 41 45 int drm_sysfb_get_width_si(struct drm_device *dev, const struct screen_info *si); ··· 52 48 unsigned int width, unsigned int height, u64 size); 53 49 u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, 54 50 unsigned int height, unsigned int stride, u64 size); 55 - const struct drm_format_info *drm_sysfb_get_format_si(struct drm_device *dev, 56 - const struct drm_sysfb_format *formats, 57 - size_t nformats, 58 - const struct screen_info *si); 59 51 #endif 60 52 61 53 /*
-30
drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c
··· 72 72 return drm_sysfb_get_validated_size0(dev, "visible size", vsize, size); 73 73 } 74 74 EXPORT_SYMBOL(drm_sysfb_get_visible_size_si); 75 - 76 - const struct drm_format_info *drm_sysfb_get_format_si(struct drm_device *dev, 77 - const struct drm_sysfb_format *formats, 78 - size_t nformats, 79 - const struct screen_info *si) 80 - { 81 - const struct drm_format_info *format = NULL; 82 - struct pixel_format pixel; 83 - size_t i; 84 - int ret; 85 - 86 - ret = screen_info_pixel_format(si, &pixel); 87 - if (ret) 88 - return NULL; 89 - 90 - for (i = 0; i < nformats; ++i) { 91 - const struct drm_sysfb_format *f = &formats[i]; 92 - 93 - if (pixel_format_equal(&pixel, &f->pixel)) { 94 - format = drm_format_info(f->fourcc); 95 - break; 96 - } 97 - } 98 - 99 - if (!format) 100 - drm_warn(dev, "No compatible color format found\n"); 101 - 102 - return format; 103 - } 104 - EXPORT_SYMBOL(drm_sysfb_get_format_si);
+7 -1
drivers/gpu/drm/sysfb/efidrm.c
··· 45 45 { PIXEL_FORMAT_XBGR8888, DRM_FORMAT_XBGR8888, }, 46 46 { PIXEL_FORMAT_XRGB2101010, DRM_FORMAT_XRGB2101010, }, 47 47 }; 48 + struct pixel_format pixel; 49 + int ret; 48 50 49 - return drm_sysfb_get_format_si(dev, formats, ARRAY_SIZE(formats), si); 51 + ret = screen_info_pixel_format(si, &pixel); 52 + if (ret) 53 + return NULL; 54 + 55 + return drm_sysfb_get_format(dev, formats, ARRAY_SIZE(formats), &pixel); 50 56 } 51 57 52 58 static u64 efidrm_get_mem_flags(struct drm_device *dev, resource_size_t start,
+7 -1
drivers/gpu/drm/sysfb/vesadrm.c
··· 49 49 { PIXEL_FORMAT_XBGR8888, DRM_FORMAT_XBGR8888, }, 50 50 { PIXEL_FORMAT_C8, DRM_FORMAT_C8, }, 51 51 }; 52 + struct pixel_format pixel; 53 + int ret; 52 54 53 - return drm_sysfb_get_format_si(dev, formats, ARRAY_SIZE(formats), si); 55 + ret = screen_info_pixel_format(si, &pixel); 56 + if (ret) 57 + return NULL; 58 + 59 + return drm_sysfb_get_format(dev, formats, ARRAY_SIZE(formats), &pixel); 54 60 } 55 61 56 62 /*