Skip to content

Commit 31eea29

Browse files
committed
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
1 parent d6d05e2 commit 31eea29

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,19 @@ const struct drm_format_info *drm_sysfb_get_format_si(struct drm_device *dev,
7979
const struct screen_info *si)
8080
{
8181
const struct drm_format_info *format = NULL;
82-
u32 bits_per_pixel;
82+
struct pixel_format pixel;
8383
size_t i;
84+
int ret;
8485

85-
bits_per_pixel = __screen_info_lfb_bits_per_pixel(si);
86+
ret = screen_info_pixel_format(si, &pixel);
87+
if (ret)
88+
return NULL;
8689

8790
for (i = 0; i < nformats; ++i) {
88-
const struct pixel_format *f = &formats[i].pixel;
89-
90-
if (bits_per_pixel == f->bits_per_pixel &&
91-
si->red_size == f->red.length &&
92-
si->red_pos == f->red.offset &&
93-
si->green_size == f->green.length &&
94-
si->green_pos == f->green.offset &&
95-
si->blue_size == f->blue.length &&
96-
si->blue_pos == f->blue.offset) {
97-
format = drm_format_info(formats[i].fourcc);
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);
9895
break;
9996
}
10097
}

0 commit comments

Comments
 (0)