diff --git a/drivers/gpu/drm/sysfb/Makefile b/drivers/gpu/drm/sysfb/Makefile
index 861b4026f4a6e..a156c496413d3 100644
--- a/drivers/gpu/drm/sysfb/Makefile
+++ b/drivers/gpu/drm/sysfb/Makefile
@@ -3,6 +3,7 @@
 drm_sysfb_helper-y := \
 	drm_sysfb.o \
 	drm_sysfb_modeset.o
+drm_sysfb_helper-$(CONFIG_SCREEN_INFO) += drm_sysfb_screen_info.o
 obj-$(CONFIG_DRM_SYSFB_HELPER)	+= drm_sysfb_helper.o
 
 obj-$(CONFIG_DRM_EFIDRM)	+= efidrm.o
diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h
index 1697cf7ace973..cb08a88242cc1 100644
--- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h
+++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h
@@ -6,12 +6,46 @@
 #include <linux/container_of.h>
 #include <linux/iosys-map.h>
 
+#include <video/pixel_format.h>
+
 #include <drm/drm_crtc.h>
 #include <drm/drm_device.h>
 #include <drm/drm_modes.h>
 
 struct drm_format_info;
 struct drm_scanout_buffer;
+struct screen_info;
+
+/*
+ * Input parsing
+ */
+
+struct drm_sysfb_format {
+	struct pixel_format pixel;
+	u32 fourcc;
+};
+
+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);
+
+#if defined(CONFIG_SCREEN_INFO)
+int drm_sysfb_get_width_si(struct drm_device *dev, const struct screen_info *si);
+int drm_sysfb_get_height_si(struct drm_device *dev, const struct screen_info *si);
+struct resource *drm_sysfb_get_memory_si(struct drm_device *dev,
+					 const struct screen_info *si,
+					 struct resource *res);
+int drm_sysfb_get_stride_si(struct drm_device *dev, const struct screen_info *si,
+			    const struct drm_format_info *format,
+			    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
 
 /*
  * Input parsing
diff --git a/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c b/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c
new file mode 100644
index 0000000000000..0b3fb874a51f2
--- /dev/null
+++ b/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/export.h>
+#include <linux/limits.h>
+#include <linux/minmax.h>
+#include <linux/screen_info.h>
+
+#include <drm/drm_fourcc.h>
+#include <drm/drm_print.h>
+
+#include "drm_sysfb_helper.h"
+
+static s64 drm_sysfb_get_validated_size0(struct drm_device *dev, const char *name,
+					 u64 value, u64 max)
+{
+	if (!value) {
+		drm_warn(dev, "%s of 0 not allowed\n", name);
+		return -EINVAL;
+	} else if (value > min(max, S64_MAX)) {
+		drm_warn(dev, "%s of %llu exceeds maximum of %llu\n", name, value, max);
+		return -EINVAL;
+	}
+	return value;
+}
+
+int drm_sysfb_get_width_si(struct drm_device *dev, const struct screen_info *si)
+{
+	return drm_sysfb_get_validated_int0(dev, "width", si->lfb_width, U16_MAX);
+}
+EXPORT_SYMBOL(drm_sysfb_get_width_si);
+
+int drm_sysfb_get_height_si(struct drm_device *dev, const struct screen_info *si)
+{
+	return drm_sysfb_get_validated_int0(dev, "height", si->lfb_height, U16_MAX);
+}
+EXPORT_SYMBOL(drm_sysfb_get_height_si);
+
+struct resource *drm_sysfb_get_memory_si(struct drm_device *dev,
+					 const struct screen_info *si,
+					 struct resource *res)
+{
+	ssize_t	num;
+
+	num = screen_info_resources(si, res, 1);
+	if (!num) {
+		drm_warn(dev, "memory resource not found\n");
+		return NULL;
+	}
+
+	return res;
+}
+EXPORT_SYMBOL(drm_sysfb_get_memory_si);
+
+int drm_sysfb_get_stride_si(struct drm_device *dev, const struct screen_info *si,
+			    const struct drm_format_info *format,
+			    unsigned int width, unsigned int height, u64 size)
+{
+	u64 lfb_linelength = si->lfb_linelength;
+
+	if (!lfb_linelength)
+		lfb_linelength = drm_format_info_min_pitch(format, 0, width);
+
+	return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength, div64_u64(size, height));
+}
+EXPORT_SYMBOL(drm_sysfb_get_stride_si);
+
+u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
+				  unsigned int height, unsigned int stride, u64 size)
+{
+	u64 vsize = PAGE_ALIGN(height * stride);
+
+	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;
+	u32 bits_per_pixel;
+	size_t i;
+
+	bits_per_pixel = __screen_info_lfb_bits_per_pixel(si);
+
+	for (i = 0; i < nformats; ++i) {
+		const struct pixel_format *f = &formats[i].pixel;
+
+		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);
+			break;
+		}
+	}
+
+	if (!format)
+		drm_warn(dev, "No compatible color format found\n");
+
+	return format;
+}
+EXPORT_SYMBOL(drm_sysfb_get_format_si);
diff --git a/drivers/gpu/drm/sysfb/efidrm.c b/drivers/gpu/drm/sysfb/efidrm.c
index a77ea5285cc1d..07eb494203a25 100644
--- a/drivers/gpu/drm/sysfb/efidrm.c
+++ b/drivers/gpu/drm/sysfb/efidrm.c
@@ -33,72 +33,10 @@
 #define DRIVER_MAJOR	1
 #define DRIVER_MINOR	0
 
-static s64 efidrm_get_validated_size0(struct drm_device *dev, const char *name,
-				      u64 value, u64 max)
-{
-	if (!value) {
-		drm_err(dev, "%s of 0 not allowed\n", name);
-		return -EINVAL;
-	} else if (value > max) {
-		drm_err(dev, "%s of %llu exceeds maximum of %llu\n", name, value, max);
-		return -EINVAL;
-	}
-	return value;
-}
-
-static int efidrm_get_width_si(struct drm_device *dev, const struct screen_info *si)
-{
-	return drm_sysfb_get_validated_int0(dev, "width", si->lfb_width, U16_MAX);
-}
-
-static int efidrm_get_height_si(struct drm_device *dev, const struct screen_info *si)
-{
-	return drm_sysfb_get_validated_int0(dev, "height", si->lfb_height, U16_MAX);
-}
-
-static struct resource *efidrm_get_memory_si(struct drm_device *dev,
-					     const struct screen_info *si,
-					     struct resource *res)
-{
-	ssize_t	num;
-
-	num = screen_info_resources(si, res, 1);
-	if (!num) {
-		drm_err(dev, "memory resource not found\n");
-		return NULL;
-	}
-
-	return res;
-}
-
-static int efidrm_get_stride_si(struct drm_device *dev, const struct screen_info *si,
-				const struct drm_format_info *format,
-				unsigned int width, unsigned int height, u64 size)
-{
-	u64 lfb_linelength = si->lfb_linelength;
-
-	if (!lfb_linelength)
-		lfb_linelength = drm_format_info_min_pitch(format, 0, width);
-
-	return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength,
-					    div64_u64(size, height));
-}
-
-static u64 efidrm_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
-				      unsigned int height, unsigned int stride, u64 size)
-{
-	u64 vsize = PAGE_ALIGN(height * stride);
-
-	return efidrm_get_validated_size0(dev, "visible size", vsize, size);
-}
-
 static const struct drm_format_info *efidrm_get_format_si(struct drm_device *dev,
 							  const struct screen_info *si)
 {
-	static const struct {
-		struct pixel_format pixel;
-		u32 fourcc;
-	} efi_formats[] = {
+	static const struct drm_sysfb_format formats[] = {
 		{ PIXEL_FORMAT_XRGB1555, DRM_FORMAT_XRGB1555, },
 		{ PIXEL_FORMAT_RGB565, DRM_FORMAT_RGB565, },
 		{ PIXEL_FORMAT_RGB888, DRM_FORMAT_RGB888, },
@@ -106,33 +44,8 @@ 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, },
 	};
-	const struct drm_format_info *format = NULL;
-	u32 bits_per_pixel;
-	size_t i;
-
-	bits_per_pixel = __screen_info_lfb_bits_per_pixel(si);
-
-	for (i = 0; i < ARRAY_SIZE(efi_formats); ++i) {
-		const struct pixel_format *f = &efi_formats[i].pixel;
-
-		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(efi_formats[i].fourcc);
-			break;
-		}
-	}
-
-	if (!format)
-		return ERR_PTR(-EINVAL);
-	if (format->is_color_indexed)
-		return ERR_PTR(-EINVAL);
 
-	return format;
+	return drm_sysfb_get_format_si(dev, formats, ARRAY_SIZE(formats), si);
 }
 
 static u64 efidrm_get_mem_flags(struct drm_device *dev, resource_size_t start,
@@ -268,21 +181,21 @@ static struct efidrm_device *efidrm_device_create(struct drm_driver *drv,
 	 */
 
 	format = efidrm_get_format_si(dev, si);
-	if (IS_ERR(format))
-		return ERR_CAST(format);
-	width = efidrm_get_width_si(dev, si);
+	if (!format)
+		return ERR_PTR(-EINVAL);
+	width = drm_sysfb_get_width_si(dev, si);
 	if (width < 0)
 		return ERR_PTR(width);
-	height = efidrm_get_height_si(dev, si);
+	height = drm_sysfb_get_height_si(dev, si);
 	if (height < 0)
 		return ERR_PTR(height);
-	res = efidrm_get_memory_si(dev, si, &resbuf);
+	res = drm_sysfb_get_memory_si(dev, si, &resbuf);
 	if (!res)
 		return ERR_PTR(-EINVAL);
-	stride = efidrm_get_stride_si(dev, si, format, width, height, resource_size(res));
+	stride = drm_sysfb_get_stride_si(dev, si, format, width, height, resource_size(res));
 	if (stride < 0)
 		return ERR_PTR(stride);
-	vsize = efidrm_get_visible_size_si(dev, si, height, stride, resource_size(res));
+	vsize = drm_sysfb_get_visible_size_si(dev, si, height, stride, resource_size(res));
 	if (!vsize)
 		return ERR_PTR(-EINVAL);
 
diff --git a/drivers/gpu/drm/sysfb/vesadrm.c b/drivers/gpu/drm/sysfb/vesadrm.c
index d87ff77be20de..4d62c78e7d1e0 100644
--- a/drivers/gpu/drm/sysfb/vesadrm.c
+++ b/drivers/gpu/drm/sysfb/vesadrm.c
@@ -36,105 +36,18 @@
 
 #define VESADRM_GAMMA_LUT_SIZE 256
 
-static s64 vesadrm_get_validated_size0(struct drm_device *dev, const char *name,
-				       u64 value, u64 max)
-{
-	if (!value) {
-		drm_err(dev, "vesadrm: %s of 0 not allowed\n", name);
-		return -EINVAL;
-	} else if (value > max) {
-		drm_err(dev, "vesadrm: %s of %llu exceeds maximum of %llu\n", name, value, max);
-		return -EINVAL;
-	}
-	return value;
-}
-
-static int vesadrm_get_width_si(struct drm_device *dev, const struct screen_info *si)
-{
-	return drm_sysfb_get_validated_int0(dev, "width", si->lfb_width, U16_MAX);
-}
-
-static int vesadrm_get_height_si(struct drm_device *dev, const struct screen_info *si)
-{
-	return drm_sysfb_get_validated_int0(dev, "height", si->lfb_height, U16_MAX);
-}
-
-static struct resource *vesadrm_get_memory_si(struct drm_device *dev,
-					      const struct screen_info *si,
-					      struct resource *res)
-{
-	ssize_t	num;
-
-	num = screen_info_resources(si, res, 1);
-	if (!num) {
-		drm_err(dev, "vesadrm: memory resource not found\n");
-		return NULL;
-	}
-
-	return res;
-}
-
-static int vesadrm_get_stride_si(struct drm_device *dev, const struct screen_info *si,
-				 const struct drm_format_info *format,
-				 unsigned int width, unsigned int height, u64 size)
-{
-	u64 lfb_linelength = si->lfb_linelength;
-
-	if (!lfb_linelength)
-		lfb_linelength = drm_format_info_min_pitch(format, 0, width);
-
-	return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength,
-					    div64_u64(size, height));
-}
-
-static u64 vesadrm_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
-				       unsigned int height, unsigned int stride, u64 size)
-{
-	u64 vsize = PAGE_ALIGN(height * stride);
-
-	return vesadrm_get_validated_size0(dev, "visible size", vsize, size);
-}
-
 static const struct drm_format_info *vesadrm_get_format_si(struct drm_device *dev,
 							   const struct screen_info *si)
 {
-	static const struct {
-		struct pixel_format pixel;
-		u32 fourcc;
-	} vesa_formats[] = {
+	static const struct drm_sysfb_format formats[] = {
 		{ PIXEL_FORMAT_XRGB1555, DRM_FORMAT_XRGB1555, },
 		{ PIXEL_FORMAT_RGB565, DRM_FORMAT_RGB565, },
 		{ PIXEL_FORMAT_RGB888, DRM_FORMAT_RGB888, },
 		{ PIXEL_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888, },
 		{ PIXEL_FORMAT_XBGR8888, DRM_FORMAT_XBGR8888, },
 	};
-	const struct drm_format_info *format = NULL;
-	u32 bits_per_pixel;
-	size_t i;
-
-	bits_per_pixel = __screen_info_lfb_bits_per_pixel(si);
-
-	for (i = 0; i < ARRAY_SIZE(vesa_formats); ++i) {
-		const struct pixel_format *f = &vesa_formats[i].pixel;
 
-		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(vesa_formats[i].fourcc);
-			break;
-		}
-	}
-
-	if (!format)
-		return ERR_PTR(-EINVAL);
-	if (format->is_color_indexed)
-		return ERR_PTR(-EINVAL);
-
-	return format;
+	return drm_sysfb_get_format_si(dev, formats, ARRAY_SIZE(formats), si);
 }
 
 /*
@@ -426,21 +339,21 @@ static struct vesadrm_device *vesadrm_device_create(struct drm_driver *drv,
 	 */
 
 	format = vesadrm_get_format_si(dev, si);
-	if (IS_ERR(format))
-		return ERR_CAST(format);
-	width = vesadrm_get_width_si(dev, si);
+	if (!format)
+		return ERR_PTR(-EINVAL);
+	width = drm_sysfb_get_width_si(dev, si);
 	if (width < 0)
 		return ERR_PTR(width);
-	height = vesadrm_get_height_si(dev, si);
+	height = drm_sysfb_get_height_si(dev, si);
 	if (height < 0)
 		return ERR_PTR(height);
-	res = vesadrm_get_memory_si(dev, si, &resbuf);
+	res = drm_sysfb_get_memory_si(dev, si, &resbuf);
 	if (!res)
 		return ERR_PTR(-EINVAL);
-	stride = vesadrm_get_stride_si(dev, si, format, width, height, resource_size(res));
+	stride = drm_sysfb_get_stride_si(dev, si, format, width, height, resource_size(res));
 	if (stride < 0)
 		return ERR_PTR(stride);
-	vsize = vesadrm_get_visible_size_si(dev, si, height, stride, resource_size(res));
+	vsize = drm_sysfb_get_visible_size_si(dev, si, height, stride, resource_size(res));
 	if (!vsize)
 		return ERR_PTR(-EINVAL);
 
