Skip to content

Commit eabb032

Browse files
soci64hdeller
authored andcommitted
fbdev: Refactoring the fbcon packed pixel drawing routines
The original version duplicated more or less the same algorithms for both system and i/o memory. In this version the drawing algorithms (copy/fill/blit) are separate from the memory access (system and i/o). The two parts are getting combined in the loadable module sources. This also makes it more robust against wrong memory access type or alignment mistakes as there's no direct pointer access or arithmetic in the algorithm sources anymore. Due to liberal use of inlining the compiled result is a single function in all 6 cases, without unnecessary function calls. Unlike earlier the use of macros could be minimized as apparently both gcc and clang is capable now to do the same with inline functions just as well. What wasn't quite the same in the two variants is the support for pixel order reversing. This version is capable to do that for both system and I/O memory, and not only for the latter. As demand for low bits per pixel modes isn't high there's a configuration option to enable this separately for the CFB and SYS modules. The pixel reversing algorithm is different than earlier and was designed so that it can take advantage of bit order reversing instructions on architectures which have them. And even for higher bits per pixel modes like four bpp. One of the shortcomings of the earlier version was the incomplete support for foreign endian framebuffers. Now all three drawing algorithms produce correct output on both endians with native and foreign framebuffers. This is one of the important differences even if otherwise the algorithms don't look too different than before. All three routines work now with aligned native word accesses. As a consequence blitting isn't limited to 32 bits on 64 bit architectures as it was before. The old routines silently assumed that rows are a multiple of the word size. Due to how the new routines function this isn't a requirement any more and access will be done aligned regardless. However if the framebuffer is configured like that then some of the fast paths won't be available. As this code is supposed to be running on all supported architectures it wasn't optimized for a particular one. That doesn't mean I haven't looked at the disassembly. That's where I noticed that it isn't a good idea to use the fallback bitreversing code for example. The low bits per pixel modes should be faster than before as the new routines can blit 4 pixels at a time. On the higher bits per pixel modes I retained the specialized aligned routines so it should be more or less the same, except on 64 bit architectures. There the blitting word size is double now which means 32 BPP isn't done a single pixel a time now. The code was tested on x86, amd64, mips32 and mips64. The latter two in big endian configuration. Originally thought I can get away with the first two, but with such bit twisting code byte ordering is tricky and not really possible to get right without actually verifying it. While writing such routines isn't rocket science a lot of time was spent on making sure that pixel ordering, foreign byte order, various bits per pixels, cpu endianness and word size will give the expected result in all sorts of combinations without making it overly complicated or full with special cases. Signed-off-by: Zsolt Kajtar <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 1a78d9a commit eabb032

File tree

13 files changed

+1464
-2255
lines changed

13 files changed

+1464
-2255
lines changed

drivers/video/fbdev/core/Kconfig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ config FB_CFB_REV_PIXELS_IN_BYTE
6969
bool
7070
depends on FB_CORE
7171
help
72-
Allow generic frame-buffer functions to work on displays with 1, 2
72+
Allow I/O memory frame-buffer functions to work on displays with 1, 2
7373
and 4 bits per pixel depths which has opposite order of pixels in
7474
byte order to bytes in long order.
7575

@@ -97,6 +97,14 @@ config FB_SYS_IMAGEBLIT
9797
blitting. This is used by drivers that don't provide their own
9898
(accelerated) version and the framebuffer is in system RAM.
9999

100+
config FB_SYS_REV_PIXELS_IN_BYTE
101+
bool
102+
depends on FB_CORE
103+
help
104+
Allow virtual memory frame-buffer functions to work on displays with 1, 2
105+
and 4 bits per pixel depths which has opposite order of pixels in
106+
byte order to bytes in long order.
107+
100108
config FB_PROVIDE_GET_FB_UNMAPPED_AREA
101109
bool
102110
depends on FB

0 commit comments

Comments
 (0)