Hi all,
A long outstanding issue with the DRM subsystem has been the lack of
support for low-color displays, as used typically on older desktop
systems and small embedded displays.
This patch series adds support for color-indexed frame buffer formats
with 2, 4, and 16 colors. It has been tested on ARAnyM using a
work-in-progress Atari DRM driver, with text console operation and
fbtest.
Overview:
- Patches 1 and 2 give a working system, albeit with a too large pitch
(line length),
- Patches 3 and 4 reduce memory consumption by correcting the pitch
in case bpp < 8,
- Patches 5 and 6 are untested, but may become useful with DRM
userspace,
- Patches 7 and 8 add more fourcc codes for grayscale and monochrome
frame buffer formats, which may be useful for e.g. the ssd130x and
repaper drivers.
Notes:
- I haven't looked yet into making modetest draw a correct image.
- As this was used on emulated hardware only, and I do not have Atari
hardware, I do not have performance figures to compare with fbdev.
I hope to do proper measuring with an Amiga DRM driver, eventually.
Thanks for your comments!
Geert Uytterhoeven (8):
drm/fourcc: Add DRM_FORMAT_C[124]
drm/fb-helper: Add support for DRM_FORMAT_C[124]
drm/fourcc: Add drm_format_info_bpp() helper
drm/client: Use actual bpp when allocating frame buffers
drm/framebuffer: Use actual bpp for DRM_IOCTL_MODE_GETFB
drm/gem-fb-helper: Use actual bpp for size calculations
drm/fourcc: Add DRM_FORMAT_R[124]
drm/fourcc: Add DRM_FORMAT_D1
drivers/gpu/drm/drm_client.c | 4 +-
drivers/gpu/drm/drm_fb_helper.c | 120 ++++++++++++++-----
drivers/gpu/drm/drm_fourcc.c | 45 +++++++
drivers/gpu/drm/drm_framebuffer.c | 2 +-
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 12 +-
include/drm/drm_fourcc.h | 1 +
include/uapi/drm/drm_fourcc.h | 15 +++
7 files changed, 160 insertions(+), 39 deletions(-)
--
2.25.1
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Introduce fourcc codes for single-channel frame buffer formats with two,
four, and sixteen intensity levels. Traditionally, the first channel
has been called the "red" channel, but the fourcc can also be used for
other light-on-dark displays.
As the number of bits per pixel is less than eight, these rely on proper
block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_fourcc.c | 6 ++++++
include/uapi/drm/drm_fourcc.h | 9 +++++++++
2 files changed, 15 insertions(+)
Introduce a fourcc code for a single-channel frame buffer format with two
darkness levels. This can be used for two-level dark-on-light displays.
As the number of bits per pixel is less than eight, this relies on
proper block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_fourcc.c | 2 ++
include/uapi/drm/drm_fourcc.h | 3 +++
2 files changed, 5 insertions(+)
The AFBC helpers derive the number of bits per pixel from the deprecated
drm_format_info.cpp[] field, which does not take into account block
sizes.
Fix this by using the actual number of bits per pixel instead.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Untested.
After adding the missing block info, probably the whole function can
just be dropped, in favor of drm_format_info_bpp()?
---
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
@@ -499,11 +499,8 @@ static __u32 drm_gem_afbc_get_bpp(struct drm_device *dev,info=drm_get_format_info(dev,mode_cmd);-/* use whatever a driver has set */-if(info->cpp[0])-returninfo->cpp[0]*8;--/* guess otherwise */+// FIXME DRM_FORMAT_* should provide proper block info in+// FIXME drivers/gpu/drm/drm_fourcc.cswitch(info->format){caseDRM_FORMAT_YUV420_8BIT:return12;
Introduce fourcc codes for color-indexed frame buffer formats with two,
four, and sixteen color, and provide a suitable mapping from bit per
pixel and depth to fourcc codes.
As the number of bits per pixel is less than eight, these rely on proper
block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Do we want to keep the rounding down if depth < bpp, or insist on depth
== bpp? I don't think the rounding down will still be needed after
"[PATCH 4/8] drm/client: Use actual bpp when allocating frame buffers".
---
drivers/gpu/drm/drm_fourcc.c | 18 ++++++++++++++++++
include/uapi/drm/drm_fourcc.h | 3 +++
2 files changed, 21 insertions(+)
When allocating a frame buffer, the number of bits per pixel needed is
derived from the deprecated drm_format_info.cpp[] field. While this
works for formats using less than 8 bits per pixel, it does lead to a
large overallocation.
Reduce memory consumption by using the actual number of bits per pixel
instead.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_client.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Add a helper to retrieve the actual number of bits per pixel for a
plane, taking into account the number of characters and pixels per
block for tiled formats.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_fourcc.c | 19 +++++++++++++++++++
include/drm/drm_fourcc.h | 1 +
2 files changed, 20 insertions(+)
When userspace queries the properties of a frame buffer, the number of
bits per pixel is derived from the deprecated drm_format_info.cpp[]
field, which does not take into account block sizes.
Fix this by using the actual number of bits per pixel instead.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Untested.
---
drivers/gpu/drm/drm_framebuffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -530,7 +530,7 @@ int drm_mode_getfb(struct drm_device *dev,r->height=fb->height;r->width=fb->width;r->depth=fb->format->depth;-r->bpp=fb->format->cpp[0]*8;+r->bpp=drm_format_info_bpp(fb->format,0);r->pitch=fb->pitches[0];/* GET_FB() is an unprivileged ioctl so we must not return a
Add support for color-indexed frame buffer formats with two, four, and
sixteen colors to the DRM framebuffer helper functions:
1. Add support for depths 1/2/4 to the damage helper,
2. For color-indexed modes, the length of the color bitfields must be
set to the color depth, else the logo code may pick a logo with too
many colors. Drop the incorrect DAC width comment, which
originates from the i915 driver.
3. Accept C[124] modes when validating or filling in struct
fb_var_screeninfo, and use the correct number of bits per pixel.
4. Set the visual to FB_VISUAL_PSEUDOCOLOR for all supported
color-indexed modes.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_fb_helper.c | 120 +++++++++++++++++++++++++-------
1 file changed, 93 insertions(+), 27 deletions(-)
@@ -376,12 +376,34 @@ static void drm_fb_helper_damage_blit_real(struct drm_fb_helper *fb_helper,structiosys_map*dst){structdrm_framebuffer*fb=fb_helper->fb;-unsignedintcpp=fb->format->cpp[0];-size_toffset=clip->y1*fb->pitches[0]+clip->x1*cpp;-void*src=fb_helper->fbdev->screen_buffer+offset;-size_tlen=(clip->x2-clip->x1)*cpp;+size_toffset=clip->y1*fb->pitches[0];+size_tlen=clip->x2-clip->x1;unsignedinty;+void*src;+switch(fb->format->depth){+case1:+offset+=clip->x1/8;+len=DIV_ROUND_UP(len+clip->x1%8,8);+break;++case2:+offset+=clip->x1/4;+len=DIV_ROUND_UP(len+clip->x1%4,4);+break;++case4:+offset+=clip->x1/2;+len=DIV_ROUND_UP(len+clip->x1%2,2);+break;++default:+offset+=clip->x1*fb->format->cpp[0];+len*=fb->format->cpp[0];+break;+}++src=fb_helper->fbdev->screen_buffer+offset;iosys_map_incr(dst,offset);/* go to first pixel within clip rect */for(y=clip->y1;y<clip->y2;y++){
From: Pekka Paalanen <ppaalanen@gmail.com> Date: 2022-02-17 09:46:40
On Tue, 15 Feb 2022 17:52:19 +0100
Geert Uytterhoeven [off-list ref] wrote:
quoted hunk
Introduce fourcc codes for color-indexed frame buffer formats with two,
four, and sixteen color, and provide a suitable mapping from bit per
pixel and depth to fourcc codes.
As the number of bits per pixel is less than eight, these rely on proper
block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Do we want to keep the rounding down if depth < bpp, or insist on depth
== bpp? I don't think the rounding down will still be needed after
"[PATCH 4/8] drm/client: Use actual bpp when allocating frame buffers".
---
drivers/gpu/drm/drm_fourcc.c | 18 ++++++++++++++++++
include/uapi/drm/drm_fourcc.h | 3 +++
2 files changed, 21 insertions(+)
@@ -99,6 +99,9 @@ extern "C" {#define DRM_FORMAT_INVALID 0/* color index */+#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [0] C */+#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [1:0] C */+#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [3:0] C */
Hi Geert,
generally this looks fine to me though I'm not familiar with the
code. The thing I'm missing here is a more precise description of the
new pixel formats.
This description of C8 is a little vague maybe, but presumably one
pixel being one byte, the address of pixel x is just &bytes[x].
C4, C2 and C1 should also specify the pixel order within the byte.
There is some precedent of that in with some YUV formats in this file.
Maybe something like:
C2 /* [7:0] c0:c1:c2:c3 2:2:2:2 four pixels per byte */
or the other way around, which ever your ordering is?
Thanks,
pq
From: Pekka Paalanen <ppaalanen@gmail.com> Date: 2022-02-17 10:03:08
On Tue, 15 Feb 2022 17:52:25 +0100
Geert Uytterhoeven [off-list ref] wrote:
quoted hunk
Introduce fourcc codes for single-channel frame buffer formats with two,
four, and sixteen intensity levels. Traditionally, the first channel
has been called the "red" channel, but the fourcc can also be used for
other light-on-dark displays.
As the number of bits per pixel is less than eight, these rely on proper
block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_fourcc.c | 6 ++++++
include/uapi/drm/drm_fourcc.h | 9 +++++++++
2 files changed, 15 insertions(+)
@@ -104,6 +104,15 @@ extern "C" {#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [3:0] C */#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */+/* 1 bpp Red */+#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [0] R */++/* 2 bpp Red */+#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [1:0] R */++/* 4 bpp Red */+#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [3:0] R */+/* 8 bpp Red */#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
Hi Geert,
I have the same comment here as for C1/C2/C4: these need to specify the
ordering inside a byte. Otherwise this reads as one byte of storage per
pixel, but using only 1/2/4 bits of each byte.
The idea of having Cx and Rx formats separately sounds good to me.
Thanks,
pq
From: Pekka Paalanen <ppaalanen@gmail.com> Date: 2022-02-17 10:10:43
On Tue, 15 Feb 2022 17:52:26 +0100
Geert Uytterhoeven [off-list ref] wrote:
quoted hunk
Introduce a fourcc code for a single-channel frame buffer format with two
darkness levels. This can be used for two-level dark-on-light displays.
As the number of bits per pixel is less than eight, this relies on
proper block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_fourcc.c | 2 ++
include/uapi/drm/drm_fourcc.h | 3 +++
2 files changed, 5 insertions(+)
Hi Geert,
the same comment here as for C1 and R1 formats, need to specify pixel
ordering inside a byte.
I think it would also be good to explain the rationale why C1 and R1
are not suitable for this case and we need yet another 1-bit format in
the commit message.
For posterity, of course. I roughly remember the discussions.
I also wonder if anyone would actually use D1. Should it be added
anyway? There is no rule that a pixel format must be used inside the
kernel AFAIK, but is there even a prospective userspace wanting this?
Exposing R1 and inverting bits while copying to hardware might be
enough?
Thanks,
pq
/* 1 bpp Red */
#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [0] R */
Hi Pekka,
On Thu, Feb 17, 2022 at 11:10 AM Pekka Paalanen [off-list ref] wrote:
On Tue, 15 Feb 2022 17:52:26 +0100
Geert Uytterhoeven [off-list ref] wrote:
quoted
Introduce a fourcc code for a single-channel frame buffer format with two
darkness levels. This can be used for two-level dark-on-light displays.
As the number of bits per pixel is less than eight, this relies on
proper block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
the same comment here as for C1 and R1 formats, need to specify pixel
ordering inside a byte.
Right, will do.
I think it would also be good to explain the rationale why C1 and R1
are not suitable for this case and we need yet another 1-bit format in
the commit message.
For posterity, of course. I roughly remember the discussions.
C1 is color-indexed, which can be any two colors.
R1 is light-on-dark.
D1 is dark-on-light.
I also wonder if anyone would actually use D1. Should it be added
anyway? There is no rule that a pixel format must be used inside the
kernel AFAIK, but is there even a prospective userspace wanting this?
Exposing R1 and inverting bits while copying to hardware might be
enough?
That's an option. The repaper driver does that:
drm_fb_xrgb8888_to_gray8(buf, 0, cma_obj->vaddr, fb, &clip);
repaper_gray8_to_mono_reversed(buf, fb->width, fb->height);
Can drm_framebuffer objects be backed by graphics memory, i.e.
can they be displayed without copying?
quoted
/* 1 bpp Red */
#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [0] R */
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
From: Pekka Paalanen <ppaalanen@gmail.com> Date: 2022-02-17 14:28:46
On Thu, 17 Feb 2022 11:42:29 +0100
Geert Uytterhoeven [off-list ref] wrote:
Hi Pekka,
On Thu, Feb 17, 2022 at 11:10 AM Pekka Paalanen [off-list ref] wrote:
quoted
On Tue, 15 Feb 2022 17:52:26 +0100
Geert Uytterhoeven [off-list ref] wrote:
quoted
Introduce a fourcc code for a single-channel frame buffer format with two
darkness levels. This can be used for two-level dark-on-light displays.
As the number of bits per pixel is less than eight, this relies on
proper block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
the same comment here as for C1 and R1 formats, need to specify pixel
ordering inside a byte.
Right, will do.
Btw. does endianess of anything have any effect on these pixel formats?
That's probably a weird question, but I recall Pixman (the pixel
handling library of the X server nowadays known as Xorg) having pixel
formats where CPU endianess affects whether the first pixel in a byte
is found at the MSB or LSB.
quoted
I think it would also be good to explain the rationale why C1 and R1
are not suitable for this case and we need yet another 1-bit format in
the commit message.
For posterity, of course. I roughly remember the discussions.
C1 is color-indexed, which can be any two colors.
R1 is light-on-dark.
D1 is dark-on-light.
quoted
I also wonder if anyone would actually use D1. Should it be added
anyway? There is no rule that a pixel format must be used inside the
kernel AFAIK, but is there even a prospective userspace wanting this?
Exposing R1 and inverting bits while copying to hardware might be
enough?
That's an option. The repaper driver does that:
drm_fb_xrgb8888_to_gray8(buf, 0, cma_obj->vaddr, fb, &clip);
repaper_gray8_to_mono_reversed(buf, fb->width, fb->height);
Can drm_framebuffer objects be backed by graphics memory, i.e.
can they be displayed without copying?
Yes, they can. That is actually their primary purpose. So the invert
bits approach only works with drivers that need to manually shovel the
data, but not with direct hardware scanout.
D1 might be useful on hardware that:
- can scanout the buffer directly, and
- does not have an optional inverter in its hardware pipeline, and
- does not benefit from a shadow buffer.
Do you happen to know any that fits the description?
Thanks,
pq
From: Michel Dänzer <hidden> Date: 2022-02-17 14:35:25
On 2022-02-17 15:28, Pekka Paalanen wrote:
On Thu, 17 Feb 2022 11:42:29 +0100
Geert Uytterhoeven [off-list ref] wrote:
quoted
Hi Pekka,
On Thu, Feb 17, 2022 at 11:10 AM Pekka Paalanen [off-list ref] wrote:
quoted
On Tue, 15 Feb 2022 17:52:26 +0100
Geert Uytterhoeven [off-list ref] wrote:
quoted
Introduce a fourcc code for a single-channel frame buffer format with two
darkness levels. This can be used for two-level dark-on-light displays.
As the number of bits per pixel is less than eight, this relies on
proper block handling for the calculation of bits per pixel and pitch.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
the same comment here as for C1 and R1 formats, need to specify pixel
ordering inside a byte.
Right, will do.
Btw. does endianess of anything have any effect on these pixel formats?
That's probably a weird question, but I recall Pixman (the pixel
handling library of the X server nowadays known as Xorg) having pixel
formats where CPU endianess affects whether the first pixel in a byte
is found at the MSB or LSB.
Pixman probably has that for hysterical raisins inherited from the X code base. Conceptually, endianness is purely about the order of bytes in words, and is orthogonal to the order in which the bits of a byte/word are numbered.
--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and Xwayland developer
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2022-02-17 14:57:16
Hi Geert
Am 15.02.22 um 17:52 schrieb Geert Uytterhoeven:
quoted hunk
Add support for color-indexed frame buffer formats with two, four, and
sixteen colors to the DRM framebuffer helper functions:
1. Add support for depths 1/2/4 to the damage helper,
2. For color-indexed modes, the length of the color bitfields must be
set to the color depth, else the logo code may pick a logo with too
many colors. Drop the incorrect DAC width comment, which
originates from the i915 driver.
3. Accept C[124] modes when validating or filling in struct
fb_var_screeninfo, and use the correct number of bits per pixel.
4. Set the visual to FB_VISUAL_PSEUDOCOLOR for all supported
color-indexed modes.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/gpu/drm/drm_fb_helper.c | 120 +++++++++++++++++++++++++-------
1 file changed, 93 insertions(+), 27 deletions(-)
C8.
The fbdev helpers look correct to me. I'm not so sure about the usage
of the format info; especially the depth field. The docs say that the
field is deprecated and should be 0. Maybe depth can be handled within
fbdev?
Best regards
Thomas
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2022-02-17 14:58:48
Am 15.02.22 um 17:52 schrieb Geert Uytterhoeven:
When allocating a frame buffer, the number of bits per pixel needed is
derived from the deprecated drm_format_info.cpp[] field. While this
works for formats using less than 8 bits per pixel, it does lead to a
large overallocation.
Reduce memory consumption by using the actual number of bits per pixel
instead.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Hi Thomas,
Thanks for your review!
On Thu, Feb 17, 2022 at 3:57 PM Thomas Zimmermann [off-list ref] wrote:
Am 15.02.22 um 17:52 schrieb Geert Uytterhoeven:
quoted
Add support for color-indexed frame buffer formats with two, four, and
sixteen colors to the DRM framebuffer helper functions:
1. Add support for depths 1/2/4 to the damage helper,
2. For color-indexed modes, the length of the color bitfields must be
set to the color depth, else the logo code may pick a logo with too
many colors. Drop the incorrect DAC width comment, which
originates from the i915 driver.
3. Accept C[124] modes when validating or filling in struct
fb_var_screeninfo, and use the correct number of bits per pixel.
4. Set the visual to FB_VISUAL_PSEUDOCOLOR for all supported
color-indexed modes.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
The depth field is deprecated. It's probably better to use
fb->format->format and test against 4CC codes.
The reason I checked for depth instead of a 4CC code is that the only
thing that matters here is the number of bits per pixel. Hence this
function won't need any changes to support R1, R2, R4, and D1 later.
When we get here, we already know that we are using a format that
is supported by the fbdev helper code, and thus passed the 4CC
checks elsewhere.
Alternatively, we could introduce drm_format_info_bpp() earlier in
the series, and use that?
A non-existing color-indexed mode with zero colors ;-)
Introduced purely to make a check like in the comment below work.
What we really want to check here is if the mode is color-indexed
or not...
Again, this is not about color-indexed vs. truecolor, but about bpp.
Here I do check the 4CC codes, as this controls which modes can be
handled by the fbdev emulation, and we do not want to let random
modes with depth or bpp < 8 pass.
The fbdev helpers look correct to me. I'm not so sure about the usage
of the format info; especially the depth field. The docs say that the
field is deprecated and should be 0. Maybe depth can be handled within
fbdev?
Perhaps. I don't know enough about DRM to know what the depth field
is used for.
Note that true fbdev supports all values of depth < bpp (e.g. a
32-color mode (depth = 5) where each pixel is stored in one byte).
I do not suggest adding support for that, though ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
From: Simon Ser <hidden> Date: 2022-02-17 16:18:47
On Thursday, February 17th, 2022 at 17:12, Geert Uytterhoeven [off-list ref] wrote:
quoted
What is C0?
A non-existing color-indexed mode with zero colors ;-)
Introduced purely to make a check like in the comment below work.
What we really want to check here is if the mode is color-indexed
or not...
Maybe it would be worth introducing a drm_format_info_is_color_indexed
function? Would be self-describing when used, and would avoid to miss
some places to update when adding new color-indexed formats.
Hi Simon,
On Thu, Feb 17, 2022 at 5:18 PM Simon Ser [off-list ref] wrote:
On Thursday, February 17th, 2022 at 17:12, Geert Uytterhoeven [off-list ref] wrote:
quoted
quoted
What is C0?
A non-existing color-indexed mode with zero colors ;-)
Introduced purely to make a check like in the comment below work.
What we really want to check here is if the mode is color-indexed
or not...
Maybe it would be worth introducing a drm_format_info_is_color_indexed
function? Would be self-describing when used, and would avoid to miss
some places to update when adding new color-indexed formats.
Yep, and a .is_color_indexed flag, cfr. the existing .is_yuv flag.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
From: Sam Ravnborg <hidden> Date: 2022-02-17 20:34:47
Hi Geert,
quoted
quoted
+ switch (fb->format->depth) {
The depth field is deprecated. It's probably better to use
fb->format->format and test against 4CC codes.
The reason I checked for depth instead of a 4CC code is that the only
thing that matters here is the number of bits per pixel. Hence this
function won't need any changes to support R1, R2, R4, and D1 later.
When we get here, we already know that we are using a format that
is supported by the fbdev helper code, and thus passed the 4CC
checks elsewhere.
Alternatively, we could introduce drm_format_info_bpp() earlier in
the series, and use that?
The drm_format_info_bpp() is very descriptive, so yes it would be good to use
it here also.
Sam
From: Sam Ravnborg <hidden> Date: 2022-02-17 20:37:33
Hi Geert,
On Tue, Feb 15, 2022 at 05:52:18PM +0100, Geert Uytterhoeven wrote:
Hi all,
A long outstanding issue with the DRM subsystem has been the lack of
support for low-color displays, as used typically on older desktop
systems and small embedded displays.
This is one of the pieces missing for a long time - great to see
something done here. Thanks Geert!
Sam
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2022-02-18 08:14:43
Hi
Am 17.02.22 um 17:12 schrieb Geert Uytterhoeven:
Hi Thomas,
Thanks for your review!
On Thu, Feb 17, 2022 at 3:57 PM Thomas Zimmermann [off-list ref] wrote:
quoted
Am 15.02.22 um 17:52 schrieb Geert Uytterhoeven:
quoted
Add support for color-indexed frame buffer formats with two, four, and
sixteen colors to the DRM framebuffer helper functions:
1. Add support for depths 1/2/4 to the damage helper,
2. For color-indexed modes, the length of the color bitfields must be
set to the color depth, else the logo code may pick a logo with too
many colors. Drop the incorrect DAC width comment, which
originates from the i915 driver.
3. Accept C[124] modes when validating or filling in struct
fb_var_screeninfo, and use the correct number of bits per pixel.
4. Set the visual to FB_VISUAL_PSEUDOCOLOR for all supported
color-indexed modes.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
The depth field is deprecated. It's probably better to use
fb->format->format and test against 4CC codes.
The reason I checked for depth instead of a 4CC code is that the only
thing that matters here is the number of bits per pixel. Hence this
function won't need any changes to support R1, R2, R4, and D1 later.
When we get here, we already know that we are using a format that
is supported by the fbdev helper code, and thus passed the 4CC
checks elsewhere.
At some point, we will probably have to change several of these tests to
4cc. C8 and RGB332 both have 8-bit depth/bpp; same for C4 and RGB121; or
whatever low-color formats we also want to add.
It's not a blocker now, but maybe something to keep in mind.
Alternatively, we could introduce drm_format_info_bpp() earlier in
the series, and use that?
Having a helper for this might indeed be useful. We use depth for the
number of color bits and bpp for the number of bits in he pixel. That's
important for XRGB8888, where depth is 24, or XRGB555 where depth is 15.
If that makes sense, maybe have a helper for depth and one for bpp, even
if they return the same value in most of the cases.
A non-existing color-indexed mode with zero colors ;-)
Introduced purely to make a check like in the comment below work.
What we really want to check here is if the mode is color-indexed
or not...
I think I'd rather keep that switch.
Best regards
Thomas
Again, this is not about color-indexed vs. truecolor, but about bpp.
Here I do check the 4CC codes, as this controls which modes can be
handled by the fbdev emulation, and we do not want to let random
modes with depth or bpp < 8 pass.
quoted
The fbdev helpers look correct to me. I'm not so sure about the usage
of the format info; especially the depth field. The docs say that the
field is deprecated and should be 0. Maybe depth can be handled within
fbdev?
Perhaps. I don't know enough about DRM to know what the depth field
is used for.
Note that true fbdev supports all values of depth < bpp (e.g. a
32-color mode (depth = 5) where each pixel is stored in one byte).
I do not suggest adding support for that, though ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
Hi Thomas,
On Fri, Feb 18, 2022 at 9:14 AM Thomas Zimmermann [off-list ref] wrote:
Am 17.02.22 um 17:12 schrieb Geert Uytterhoeven:
quoted
On Thu, Feb 17, 2022 at 3:57 PM Thomas Zimmermann [off-list ref] wrote:
quoted
Am 15.02.22 um 17:52 schrieb Geert Uytterhoeven:
quoted
Add support for color-indexed frame buffer formats with two, four, and
sixteen colors to the DRM framebuffer helper functions:
1. Add support for depths 1/2/4 to the damage helper,
2. For color-indexed modes, the length of the color bitfields must be
set to the color depth, else the logo code may pick a logo with too
many colors. Drop the incorrect DAC width comment, which
originates from the i915 driver.
3. Accept C[124] modes when validating or filling in struct
fb_var_screeninfo, and use the correct number of bits per pixel.
4. Set the visual to FB_VISUAL_PSEUDOCOLOR for all supported
color-indexed modes.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
The depth field is deprecated. It's probably better to use
fb->format->format and test against 4CC codes.
The reason I checked for depth instead of a 4CC code is that the only
thing that matters here is the number of bits per pixel. Hence this
function won't need any changes to support R1, R2, R4, and D1 later.
When we get here, we already know that we are using a format that
is supported by the fbdev helper code, and thus passed the 4CC
checks elsewhere.
At some point, we will probably have to change several of these tests to
4cc. C8 and RGB332 both have 8-bit depth/bpp; same for C4 and RGB121; or
whatever low-color formats we also want to add.
It's not a blocker now, but maybe something to keep in mind.
quoted
Alternatively, we could introduce drm_format_info_bpp() earlier in
the series, and use that?
Having a helper for this might indeed be useful. We use depth for the
number of color bits and bpp for the number of bits in he pixel. That's
important for XRGB8888, where depth is 24, or XRGB555 where depth is 15.
If that makes sense, maybe have a helper for depth and one for bpp, even
if they return the same value in most of the cases.
The helper for bpp is introduced in "[PATCH 3/8] drm/fourcc: Add
drm_format_info_bpp() helper".
I don't think we need a helper for depth, there's already the .depth
field. It might be deprecated, but it's still used?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2022-02-18 08:56:17
Am 17.02.22 um 21:37 schrieb Sam Ravnborg:
Hi Geert,
On Tue, Feb 15, 2022 at 05:52:18PM +0100, Geert Uytterhoeven wrote:
quoted
Hi all,
A long outstanding issue with the DRM subsystem has been the lack of
support for low-color displays, as used typically on older desktop
systems and small embedded displays.
This is one of the pieces missing for a long time - great to see
something done here. Thanks Geert!
Absolutely! I'm looking forward to see these patches being merged.
Best regards
Thomas
Sam
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev