mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-15 19:01:45 -04:00
drm/sysfb: Find screen_info format with helpers
Convert drm_sysfb_get_format_si() to lookup the screen_info color format as struct pixel_format with screen_info_pixel_format(). Then search the list of given formats for the screen_info format with pixel_format_equal(). Replaces custom code with helpers. The pixel-compare helper pixel_format_equal() also handles indexed color formats. Prepares for sysfb drivers to support color palettes. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250714151513.309475-4-tzimmermann@suse.de
This commit is contained in:
@@ -79,22 +79,19 @@ const struct drm_format_info *drm_sysfb_get_format_si(struct drm_device *dev,
|
||||
const struct screen_info *si)
|
||||
{
|
||||
const struct drm_format_info *format = NULL;
|
||||
u32 bits_per_pixel;
|
||||
struct pixel_format pixel;
|
||||
size_t i;
|
||||
int ret;
|
||||
|
||||
bits_per_pixel = __screen_info_lfb_bits_per_pixel(si);
|
||||
ret = screen_info_pixel_format(si, &pixel);
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < nformats; ++i) {
|
||||
const struct pixel_format *f = &formats[i].pixel;
|
||||
const struct drm_sysfb_format *f = &formats[i];
|
||||
|
||||
if (bits_per_pixel == f->bits_per_pixel &&
|
||||
si->red_size == f->red.length &&
|
||||
si->red_pos == f->red.offset &&
|
||||
si->green_size == f->green.length &&
|
||||
si->green_pos == f->green.offset &&
|
||||
si->blue_size == f->blue.length &&
|
||||
si->blue_pos == f->blue.offset) {
|
||||
format = drm_format_info(formats[i].fourcc);
|
||||
if (pixel_format_equal(&pixel, &f->pixel)) {
|
||||
format = drm_format_info(f->fourcc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user