aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/console/fbcon.h
diff options
context:
space:
mode:
authorThomas Pfaff <tpfaff@pcs.com>2008-02-06 04:39:45 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:18 -0500
commit91c4313206e4409871e2ddd13c29508afe1c8834 (patch)
treea37ae47c38b3f1fa119f141d546c000f58502eb9 /drivers/video/console/fbcon.h
parente8973637bd49de225130f9c04ceb388d48969d98 (diff)
fbcon: fix color generation for monochrome framebuffer
The current attr_fgcol_ec / attr_bgcol_ec macros do a simple shift of bits to get the color from vc_video_erase_char. For a monochrome display however the attribute does not contain any color, only attribute bits. Furthermore the reverse bit is lost because it is shifted out, the resulting color is always 0. This can bee seen on a monochrome console either directly or by setting it to inverse mode via "setterm -inversescreen on" . Text is written with correct color, fb_fillrects from a bit_clear / bit_clear_margins will get wrong colors. Signed-off-by: Thomas Pfaff <tpfaff@pcs.com> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/console/fbcon.h')
-rw-r--r--drivers/video/console/fbcon.h47
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index 8e6ef4bc7a5c..3706307e70ed 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -93,10 +93,6 @@ struct fbcon_ops {
93 (((s) >> (fgshift)) & 0x0f) 93 (((s) >> (fgshift)) & 0x0f)
94#define attr_bgcol(bgshift,s) \ 94#define attr_bgcol(bgshift,s) \
95 (((s) >> (bgshift)) & 0x0f) 95 (((s) >> (bgshift)) & 0x0f)
96#define attr_bgcol_ec(bgshift,vc) \
97 ((vc) ? (((vc)->vc_video_erase_char >> (bgshift)) & 0x0f) : 0)
98#define attr_fgcol_ec(fgshift,vc) \
99 ((vc) ? (((vc)->vc_video_erase_char >> (fgshift)) & 0x0f) : 0)
100 96
101/* Monochrome */ 97/* Monochrome */
102#define attr_bold(s) \ 98#define attr_bold(s) \
@@ -108,6 +104,49 @@ struct fbcon_ops {
108#define attr_blink(s) \ 104#define attr_blink(s) \
109 ((s) & 0x8000) 105 ((s) & 0x8000)
110 106
107#define mono_col(info) \
108 (~(0xfff << (max((info)->var.green.length, \
109 max((info)->var.red.length, \
110 (info)->var.blue.length)))) & 0xff)
111
112static inline int attr_col_ec(int shift, struct vc_data *vc,
113 struct fb_info *info, int is_fg)
114{
115 int is_mono01;
116 int col;
117 int fg;
118 int bg;
119
120 if (!vc)
121 return 0;
122
123 if (vc->vc_can_do_color)
124 return is_fg ? attr_fgcol(shift,vc->vc_video_erase_char)
125 : attr_bgcol(shift,vc->vc_video_erase_char);
126
127 if (!info)
128 return 0;
129
130 col = mono_col(info);
131 is_mono01 = info->fix.visual == FB_VISUAL_MONO01;
132
133 if (attr_reverse(vc->vc_video_erase_char)) {
134 fg = is_mono01 ? col : 0;
135 bg = is_mono01 ? 0 : col;
136 }
137 else {
138 fg = is_mono01 ? 0 : col;
139 bg = is_mono01 ? col : 0;
140 }
141
142 return is_fg ? fg : bg;
143}
144
145#define attr_bgcol_ec(bgshift,vc,info) \
146 attr_col_ec(bgshift,vc,info,0);
147#define attr_fgcol_ec(fgshift,vc,info) \
148 attr_col_ec(fgshift,vc,info,1);
149
111/* Font */ 150/* Font */
112#define REFCOUNT(fd) (((int *)(fd))[-1]) 151#define REFCOUNT(fd) (((int *)(fd))[-1])
113#define FNTSIZE(fd) (((int *)(fd))[-2]) 152#define FNTSIZE(fd) (((int *)(fd))[-2])