mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 06:41:39 -04:00
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
This commit is contained in:
@@ -31,5 +31,29 @@ int drm_sysfb_get_validated_int0(struct drm_device *dev, const char *name,
|
||||
}
|
||||
EXPORT_SYMBOL(drm_sysfb_get_validated_int0);
|
||||
|
||||
const struct drm_format_info *drm_sysfb_get_format(struct drm_device *dev,
|
||||
const struct drm_sysfb_format *formats,
|
||||
size_t nformats,
|
||||
const struct pixel_format *pixel)
|
||||
{
|
||||
const struct drm_format_info *format = NULL;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < nformats; ++i) {
|
||||
const struct drm_sysfb_format *f = &formats[i];
|
||||
|
||||
if (pixel_format_equal(pixel, &f->pixel)) {
|
||||
format = drm_format_info(f->fourcc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!format)
|
||||
drm_warn(dev, "No compatible color format found\n");
|
||||
|
||||
return format;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_sysfb_get_format);
|
||||
|
||||
MODULE_DESCRIPTION("Helpers for DRM sysfb drivers");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -36,6 +36,10 @@ int drm_sysfb_get_validated_int(struct drm_device *dev, const char *name,
|
||||
u64 value, u32 max);
|
||||
int drm_sysfb_get_validated_int0(struct drm_device *dev, const char *name,
|
||||
u64 value, u32 max);
|
||||
const struct drm_format_info *drm_sysfb_get_format(struct drm_device *dev,
|
||||
const struct drm_sysfb_format *formats,
|
||||
size_t nformats,
|
||||
const struct pixel_format *pixel);
|
||||
|
||||
#if defined(CONFIG_SCREEN_INFO)
|
||||
int drm_sysfb_get_width_si(struct drm_device *dev, const struct screen_info *si);
|
||||
@@ -48,10 +52,6 @@ int drm_sysfb_get_stride_si(struct drm_device *dev, const struct screen_info *si
|
||||
unsigned int width, unsigned int height, u64 size);
|
||||
u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
|
||||
unsigned int height, unsigned int stride, u64 size);
|
||||
const struct drm_format_info *drm_sysfb_get_format_si(struct drm_device *dev,
|
||||
const struct drm_sysfb_format *formats,
|
||||
size_t nformats,
|
||||
const struct screen_info *si);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -72,33 +72,3 @@ u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_in
|
||||
return drm_sysfb_get_validated_size0(dev, "visible size", vsize, size);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_sysfb_get_visible_size_si);
|
||||
|
||||
const struct drm_format_info *drm_sysfb_get_format_si(struct drm_device *dev,
|
||||
const struct drm_sysfb_format *formats,
|
||||
size_t nformats,
|
||||
const struct screen_info *si)
|
||||
{
|
||||
const struct drm_format_info *format = NULL;
|
||||
struct pixel_format pixel;
|
||||
size_t i;
|
||||
int ret;
|
||||
|
||||
ret = screen_info_pixel_format(si, &pixel);
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < nformats; ++i) {
|
||||
const struct drm_sysfb_format *f = &formats[i];
|
||||
|
||||
if (pixel_format_equal(&pixel, &f->pixel)) {
|
||||
format = drm_format_info(f->fourcc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!format)
|
||||
drm_warn(dev, "No compatible color format found\n");
|
||||
|
||||
return format;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_sysfb_get_format_si);
|
||||
|
||||
@@ -45,8 +45,14 @@ static const struct drm_format_info *efidrm_get_format_si(struct drm_device *dev
|
||||
{ PIXEL_FORMAT_XBGR8888, DRM_FORMAT_XBGR8888, },
|
||||
{ PIXEL_FORMAT_XRGB2101010, DRM_FORMAT_XRGB2101010, },
|
||||
};
|
||||
struct pixel_format pixel;
|
||||
int ret;
|
||||
|
||||
return drm_sysfb_get_format_si(dev, formats, ARRAY_SIZE(formats), si);
|
||||
ret = screen_info_pixel_format(si, &pixel);
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
return drm_sysfb_get_format(dev, formats, ARRAY_SIZE(formats), &pixel);
|
||||
}
|
||||
|
||||
static u64 efidrm_get_mem_flags(struct drm_device *dev, resource_size_t start,
|
||||
|
||||
@@ -49,8 +49,14 @@ static const struct drm_format_info *vesadrm_get_format_si(struct drm_device *de
|
||||
{ PIXEL_FORMAT_XBGR8888, DRM_FORMAT_XBGR8888, },
|
||||
{ PIXEL_FORMAT_C8, DRM_FORMAT_C8, },
|
||||
};
|
||||
struct pixel_format pixel;
|
||||
int ret;
|
||||
|
||||
return drm_sysfb_get_format_si(dev, formats, ARRAY_SIZE(formats), si);
|
||||
ret = screen_info_pixel_format(si, &pixel);
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
return drm_sysfb_get_format(dev, formats, ARRAY_SIZE(formats), &pixel);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user