Skip to content

Commit 892c788

Browse files
soci64hdeller
authored andcommitted
fbcon: Use correct erase colour for clearing in fbcon
The erase colour calculation for fbcon clearing should use get_color instead of attr_col_ec, like everything else. The latter is similar but is not correct. For example it's missing the depth dependent remapping and doesn't care about blanking. The problem can be reproduced by setting up the background colour to grey (vt.color=0x70) and having an fbcon console set to 2bpp (4 shades of gray). Now the background attribute should be 1 (dark gray) on the console. If the screen is scrolled when pressing enter in a shell prompt at the bottom line then the new line is cleared using colour 7 instead of 1. That's not something fillrect likes (at 2bbp it expect 0-3) so the result is interesting. This patch switches to get_color with vc_video_erase_char to determine the erase colour from attr_col_ec. That makes the latter function redundant as no other users were left. Use correct erase colour for clearing in fbcon Signed-off-by: Zsolt Kajtar <soci@c64.rulez.org> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 76d3ca8 commit 892c788

File tree

7 files changed

+18
-58
lines changed

7 files changed

+18
-58
lines changed

drivers/video/fbdev/core/bitblit.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,
5959
}
6060

6161
static void bit_clear(struct vc_data *vc, struct fb_info *info, int sy,
62-
int sx, int height, int width)
62+
int sx, int height, int width, int fg, int bg)
6363
{
64-
int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
6564
struct fb_fillrect region;
6665

67-
region.color = attr_bgcol_ec(bgshift, vc, info);
66+
region.color = bg;
6867
region.dx = sx * vc->vc_font.width;
6968
region.dy = sy * vc->vc_font.height;
7069
region.width = width * vc->vc_font.width;

drivers/video/fbdev/core/fbcon.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ static void __fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
12581258
{
12591259
struct fb_info *info = fbcon_info_from_console(vc->vc_num);
12601260
struct fbcon_ops *ops = info->fbcon_par;
1261-
1261+
int fg, bg;
12621262
struct fbcon_display *p = &fb_display[vc->vc_num];
12631263
u_int y_break;
12641264

@@ -1279,16 +1279,18 @@ static void __fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
12791279
fbcon_clear_margins(vc, 0);
12801280
}
12811281

1282+
fg = get_color(vc, info, vc->vc_video_erase_char, 1);
1283+
bg = get_color(vc, info, vc->vc_video_erase_char, 0);
12821284
/* Split blits that cross physical y_wrap boundary */
12831285

12841286
y_break = p->vrows - p->yscroll;
12851287
if (sy < y_break && sy + height - 1 >= y_break) {
12861288
u_int b = y_break - sy;
1287-
ops->clear(vc, info, real_y(p, sy), sx, b, width);
1289+
ops->clear(vc, info, real_y(p, sy), sx, b, width, fg, bg);
12881290
ops->clear(vc, info, real_y(p, sy + b), sx, height - b,
1289-
width);
1291+
width, fg, bg);
12901292
} else
1291-
ops->clear(vc, info, real_y(p, sy), sx, height, width);
1293+
ops->clear(vc, info, real_y(p, sy), sx, height, width, fg, bg);
12921294
}
12931295

12941296
static void fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,

drivers/video/fbdev/core/fbcon.h

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct fbcon_ops {
5555
void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
5656
int sx, int dy, int dx, int height, int width);
5757
void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
58-
int sx, int height, int width);
58+
int sx, int height, int width, int fb, int bg);
5959
void (*putcs)(struct vc_data *vc, struct fb_info *info,
6060
const unsigned short *s, int count, int yy, int xx,
6161
int fg, int bg);
@@ -116,42 +116,6 @@ static inline int mono_col(const struct fb_info *info)
116116
return (~(0xfff << max_len)) & 0xff;
117117
}
118118

119-
static inline int attr_col_ec(int shift, struct vc_data *vc,
120-
struct fb_info *info, int is_fg)
121-
{
122-
int is_mono01;
123-
int col;
124-
int fg;
125-
int bg;
126-
127-
if (!vc)
128-
return 0;
129-
130-
if (vc->vc_can_do_color)
131-
return is_fg ? attr_fgcol(shift,vc->vc_video_erase_char)
132-
: attr_bgcol(shift,vc->vc_video_erase_char);
133-
134-
if (!info)
135-
return 0;
136-
137-
col = mono_col(info);
138-
is_mono01 = info->fix.visual == FB_VISUAL_MONO01;
139-
140-
if (attr_reverse(vc->vc_video_erase_char)) {
141-
fg = is_mono01 ? col : 0;
142-
bg = is_mono01 ? 0 : col;
143-
}
144-
else {
145-
fg = is_mono01 ? 0 : col;
146-
bg = is_mono01 ? col : 0;
147-
}
148-
149-
return is_fg ? fg : bg;
150-
}
151-
152-
#define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0)
153-
#define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1)
154-
155119
/*
156120
* Scroll Method
157121
*/

drivers/video/fbdev/core/fbcon_ccw.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,13 @@ static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
7878
}
7979

8080
static void ccw_clear(struct vc_data *vc, struct fb_info *info, int sy,
81-
int sx, int height, int width)
81+
int sx, int height, int width, int fg, int bg)
8282
{
8383
struct fbcon_ops *ops = info->fbcon_par;
8484
struct fb_fillrect region;
85-
int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
8685
u32 vyres = GETVYRES(ops->p, info);
8786

88-
region.color = attr_bgcol_ec(bgshift,vc,info);
87+
region.color = bg;
8988
region.dx = sy * vc->vc_font.height;
9089
region.dy = vyres - ((sx + width) * vc->vc_font.width);
9190
region.height = width * vc->vc_font.width;

drivers/video/fbdev/core/fbcon_cw.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,13 @@ static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
6363
}
6464

6565
static void cw_clear(struct vc_data *vc, struct fb_info *info, int sy,
66-
int sx, int height, int width)
66+
int sx, int height, int width, int fg, int bg)
6767
{
6868
struct fbcon_ops *ops = info->fbcon_par;
6969
struct fb_fillrect region;
70-
int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
7170
u32 vxres = GETVXRES(ops->p, info);
7271

73-
region.color = attr_bgcol_ec(bgshift,vc,info);
72+
region.color = bg;
7473
region.dx = vxres - ((sy + height) * vc->vc_font.height);
7574
region.dy = sx * vc->vc_font.width;
7675
region.height = width * vc->vc_font.width;

drivers/video/fbdev/core/fbcon_ud.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy,
6464
}
6565

6666
static void ud_clear(struct vc_data *vc, struct fb_info *info, int sy,
67-
int sx, int height, int width)
67+
int sx, int height, int width, int fg, int bg)
6868
{
6969
struct fbcon_ops *ops = info->fbcon_par;
7070
struct fb_fillrect region;
71-
int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
7271
u32 vyres = GETVYRES(ops->p, info);
7372
u32 vxres = GETVXRES(ops->p, info);
7473

75-
region.color = attr_bgcol_ec(bgshift,vc,info);
74+
region.color = bg;
7675
region.dy = vyres - ((sy + height) * vc->vc_font.height);
7776
region.dx = vxres - ((sx + width) * vc->vc_font.width);
7877
region.width = width * vc->vc_font.width;

drivers/video/fbdev/core/tileblit.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ static void tile_bmove(struct vc_data *vc, struct fb_info *info, int sy,
3232
}
3333

3434
static void tile_clear(struct vc_data *vc, struct fb_info *info, int sy,
35-
int sx, int height, int width)
35+
int sx, int height, int width, int fg, int bg)
3636
{
3737
struct fb_tilerect rect;
38-
int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
39-
int fgshift = (vc->vc_hi_font_mask) ? 9 : 8;
4038

4139
rect.index = vc->vc_video_erase_char &
4240
((vc->vc_hi_font_mask) ? 0x1ff : 0xff);
43-
rect.fg = attr_fgcol_ec(fgshift, vc, info);
44-
rect.bg = attr_bgcol_ec(bgshift, vc, info);
41+
rect.fg = fg;
42+
rect.bg = bg;
4543
rect.sx = sx;
4644
rect.sy = sy;
4745
rect.width = width;

0 commit comments

Comments
 (0)