From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Javier Martinez Canillas <javierm@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH 7/8] drm/fb-helper: Add support for DRM_FORMAT_R1
Date: Thu, 13 Jul 2023 15:17:15 +0200 [thread overview]
Message-ID: <ea0d68ef5630fe9748a11e50f6d79f79a768ebdb.1689252746.git.geert@linux-m68k.org> (raw)
In-Reply-To: <cover.1689252746.git.geert@linux-m68k.org>
Add support for the monochrome light-on-dark buffer format (R1) to the
fb helper, so this format can be used for fbdev emulation and for the
text console. This avoids the overhead of using XR24 and the associated
conversions on display hardware that supports only a simple monochrome
format.
R1 is very similar to C1 (monochrome indexed color), and shares the same
depth and bpp. As drm_mode_legacy_fb_format() returns a format based on
only depth and bpp, it cannot distinguish between R1 and C1. Hence
drm_fb_helper_find_format() is modified to try to fall back to R1 if C1
is not supported.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_fb_helper.c | 41 ++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index e870b2ce7a8625e3..1f1bfa764b6b9f00 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1130,7 +1130,7 @@ static void drm_fb_helper_fill_pixel_fmt(struct fb_var_screeninfo *var,
{
u8 depth = format->depth;
- if (format->is_color_indexed) {
+ if (format->format == DRM_FORMAT_R1 || format->is_color_indexed) {
var->red.offset = 0;
var->green.offset = 0;
var->blue.offset = 0;
@@ -1236,6 +1236,7 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
case DRM_FORMAT_C1:
case DRM_FORMAT_C2:
case DRM_FORMAT_C4:
+ case DRM_FORMAT_R1:
/* supported format with sub-byte pixels */
break;
@@ -1439,12 +1440,24 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
}
EXPORT_SYMBOL(drm_fb_helper_pan_display);
+static bool is_supported_format(uint32_t format, const uint32_t *formats,
+ size_t format_count)
+{
+ size_t i;
+
+ for (i = 0; i < format_count; ++i) {
+ if (formats[i] == format)
+ return true;
+ }
+
+ return false;
+}
+
static uint32_t drm_fb_helper_find_format(struct drm_fb_helper *fb_helper, const uint32_t *formats,
size_t format_count, uint32_t bpp, uint32_t depth)
{
struct drm_device *dev = fb_helper->dev;
uint32_t format;
- size_t i;
/*
* Do not consider YUV or other complicated formats
@@ -1457,10 +1470,12 @@ static uint32_t drm_fb_helper_find_format(struct drm_fb_helper *fb_helper, const
if (!format)
goto err;
- for (i = 0; i < format_count; ++i) {
- if (formats[i] == format)
- return format;
- }
+ if (is_supported_format(format, formats, format_count))
+ return format;
+
+ if (format == DRM_FORMAT_C1 &&
+ is_supported_format(DRM_FORMAT_R1, formats, format_count))
+ return DRM_FORMAT_R1;
err:
/* We found nothing. */
@@ -1680,11 +1695,15 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper)
}
static void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
- bool is_color_indexed)
+ const struct drm_format_info *format)
{
info->fix.type = FB_TYPE_PACKED_PIXELS;
- info->fix.visual = is_color_indexed ? FB_VISUAL_PSEUDOCOLOR
- : FB_VISUAL_TRUECOLOR;
+ if (format->format == DRM_FORMAT_R1)
+ info->fix.visual = FB_VISUAL_MONO10;
+ else if (format->is_color_indexed)
+ info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ else
+ info->fix.visual = FB_VISUAL_TRUECOLOR;
info->fix.mmio_start = 0;
info->fix.mmio_len = 0;
info->fix.type_aux = 0;
@@ -1707,6 +1726,7 @@ static void drm_fb_helper_fill_var(struct fb_info *info,
case DRM_FORMAT_C1:
case DRM_FORMAT_C2:
case DRM_FORMAT_C4:
+ case DRM_FORMAT_R1:
/* supported format with sub-byte pixels */
break;
@@ -1747,8 +1767,7 @@ void drm_fb_helper_fill_info(struct fb_info *info,
{
struct drm_framebuffer *fb = fb_helper->fb;
- drm_fb_helper_fill_fix(info, fb->pitches[0],
- fb->format->is_color_indexed);
+ drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format);
drm_fb_helper_fill_var(info, fb_helper,
sizes->fb_width, sizes->fb_height);
--
2.34.1
next prev parent reply other threads:[~2023-07-13 13:17 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 13:17 [PATCH 0/8] drm: fb-helper/ssd130x: " Geert Uytterhoeven
2023-07-13 13:17 ` [PATCH 1/8] drm/ssd130x: Fix pitch calculation in ssd130x_fb_blit_rect() Geert Uytterhoeven
2023-07-14 9:34 ` Javier Martinez Canillas
2023-07-14 9:41 ` Geert Uytterhoeven
2023-07-14 9:48 ` Javier Martinez Canillas
2023-07-21 22:39 ` Javier Martinez Canillas
2023-07-13 13:17 ` [PATCH 2/8] drm/dumb-buffers: Fix drm_mode_create_dumb() for bpp < 8 Geert Uytterhoeven
2023-07-14 9:50 ` Javier Martinez Canillas
2023-07-13 13:17 ` [PATCH/RFC 3/8] drm/ssd130x: Bail out early if data_array is not yet available Geert Uytterhoeven
2023-07-14 9:53 ` Javier Martinez Canillas
2023-07-13 13:17 ` [PATCH 4/8] drm/ssd130x: Add support for DRM_FORMAT_R1 Geert Uytterhoeven
2023-07-14 10:14 ` Javier Martinez Canillas
2023-07-14 11:26 ` Geert Uytterhoeven
2023-07-14 12:35 ` Javier Martinez Canillas
2023-07-14 12:43 ` Geert Uytterhoeven
2023-07-14 13:08 ` Javier Martinez Canillas
2023-07-13 13:17 ` [PATCH 5/8] drm/client: Convert drm_mode_create_dumb() to drm_mode_addfb2() Geert Uytterhoeven
2023-07-14 10:16 ` Javier Martinez Canillas
2023-07-14 11:01 ` Simon Ser
2023-07-14 11:29 ` Geert Uytterhoeven
2023-07-13 13:17 ` [PATCH 6/8] drm/fb-helper: Pass buffer format via drm_fb_helper_surface_size Geert Uytterhoeven
2023-07-14 10:25 ` Javier Martinez Canillas
2023-07-14 11:32 ` Geert Uytterhoeven
2023-07-13 13:17 ` Geert Uytterhoeven [this message]
2023-07-14 10:31 ` [PATCH 7/8] drm/fb-helper: Add support for DRM_FORMAT_R1 Javier Martinez Canillas
2023-07-13 13:17 ` [PATCH 8/8] drm/ssd130x: Switch preferred_bpp/depth to 1 Geert Uytterhoeven
2023-07-14 10:32 ` Javier Martinez Canillas
2023-07-16 13:30 ` [PATCH 0/8] drm: fb-helper/ssd130x: Add support for DRM_FORMAT_R1 Javier Martinez Canillas
2023-07-17 8:07 ` Geert Uytterhoeven
2023-07-17 9:13 ` Javier Martinez Canillas
2023-07-17 9:19 ` Geert Uytterhoeven
2023-07-17 9:33 ` Javier Martinez Canillas
2023-07-17 10:03 ` Geert Uytterhoeven
2023-07-17 10:11 ` Javier Martinez Canillas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea0d68ef5630fe9748a11e50f6d79f79a768ebdb.1689252746.git.geert@linux-m68k.org \
--to=geert@linux-m68k.org \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®