forked from Minki/linux
a3f781a9d6
Add a config option CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION to enable bitblt and fillrect hardware acceleration in the framebuffer console. If disabled, such acceleration will not be used, even if it is supported by the graphics hardware driver. If you plan to use DRM as your main graphics output system, you should disable this option since it will prevent compiling in code which isn't used later on when DRM takes over. For all other configurations, e.g. if none of your graphic cards support DRM (yet), DRM isn't available for your architecture, or you can't be sure that the graphic card in the target system will support DRM, you most likely want to enable this option. In the non-accelerated case (e.g. when DRM is used), the inlined fb_scrollmode() function is hardcoded to return SCROLL_REDRAW and as such the compiler is able to optimize much unneccesary code away. In this v3 patch version I additionally changed the GETVYRES() and GETVXRES() macros to take a pointer to the fbcon_display struct. This fixes the build when console rotation is enabled and helps the compiler again to optimize out code. Signed-off-by: Helge Deller <deller@gmx.de> Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-4-deller@gmx.de
97 lines
2.4 KiB
C
97 lines
2.4 KiB
C
/*
|
|
* linux/drivers/video/console/fbcon_rotate.h -- Software Display Rotation
|
|
*
|
|
* Copyright (C) 2005 Antonino Daplas <adaplas@pol.net>
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file COPYING in the main directory of this archive
|
|
* for more details.
|
|
*/
|
|
|
|
#ifndef _FBCON_ROTATE_H
|
|
#define _FBCON_ROTATE_H
|
|
|
|
#define GETVYRES(s,i) ({ \
|
|
(fb_scrollmode(s) == SCROLL_REDRAW || fb_scrollmode(s) == SCROLL_MOVE) ? \
|
|
(i)->var.yres : (i)->var.yres_virtual; })
|
|
|
|
#define GETVXRES(s,i) ({ \
|
|
(fb_scrollmode(s) == SCROLL_REDRAW || fb_scrollmode(s) == SCROLL_MOVE || !(i)->fix.xpanstep) ? \
|
|
(i)->var.xres : (i)->var.xres_virtual; })
|
|
|
|
|
|
static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat)
|
|
{
|
|
u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
|
|
|
|
pat +=index;
|
|
return (*pat) & (0x80 >> bit);
|
|
}
|
|
|
|
static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat)
|
|
{
|
|
u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
|
|
|
|
pat += index;
|
|
|
|
(*pat) |= 0x80 >> bit;
|
|
}
|
|
|
|
static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)
|
|
{
|
|
int i, j;
|
|
int shift = (8 - (width % 8)) & 7;
|
|
|
|
width = (width + 7) & ~7;
|
|
|
|
for (i = 0; i < height; i++) {
|
|
for (j = 0; j < width - shift; j++) {
|
|
if (pattern_test_bit(j, i, width, in))
|
|
pattern_set_bit(width - (1 + j + shift),
|
|
height - (1 + i),
|
|
width, out);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
static inline void rotate_cw(const char *in, char *out, u32 width, u32 height)
|
|
{
|
|
int i, j, h = height, w = width;
|
|
int shift = (8 - (height % 8)) & 7;
|
|
|
|
width = (width + 7) & ~7;
|
|
height = (height + 7) & ~7;
|
|
|
|
for (i = 0; i < h; i++) {
|
|
for (j = 0; j < w; j++) {
|
|
if (pattern_test_bit(j, i, width, in))
|
|
pattern_set_bit(height - 1 - i - shift, j,
|
|
height, out);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height)
|
|
{
|
|
int i, j, h = height, w = width;
|
|
int shift = (8 - (width % 8)) & 7;
|
|
|
|
width = (width + 7) & ~7;
|
|
height = (height + 7) & ~7;
|
|
|
|
for (i = 0; i < h; i++) {
|
|
for (j = 0; j < w; j++) {
|
|
if (pattern_test_bit(j, i, width, in))
|
|
pattern_set_bit(i, width - 1 - j - shift,
|
|
height, out);
|
|
}
|
|
}
|
|
}
|
|
|
|
extern void fbcon_rotate_cw(struct fbcon_ops *ops);
|
|
extern void fbcon_rotate_ud(struct fbcon_ops *ops);
|
|
extern void fbcon_rotate_ccw(struct fbcon_ops *ops);
|
|
#endif
|