summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2020-06-15 09:48:34 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-24 17:08:31 +0200
commitb84ae3dc70fedf4bdee2dbfa487fd23b606fbb82 (patch)
tree8ac0566ef82fda9be4a0a77f8b29bb4cbabed2f2 /drivers
parent28bc24fc46f9c9f39ddefb424d6072041805b563 (diff)
vt: introduce enum vc_intensity for intensity
Introduce names (en enum) for 0, 1, and 2 constants. We now have VCI_HALF_BRIGHT, VCI_NORMAL, and VCI_BOLD instead. Apart from the cleanup, 1) the enum allows for better type checking, and 2) this saves some code. No more fiddling with bits is needed in assembly now. (OTOH, the structure is larger.) Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200615074910.19267-2-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/vt/vt.c32
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_con.c6
-rw-r--r--drivers/video/console/mdacon.c5
-rw-r--r--drivers/video/console/sticon.c3
-rw-r--r--drivers/video/console/vgacon.c9
5 files changed, 30 insertions, 25 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 76f52935e0c8..71bf483e5640 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -705,8 +705,9 @@ void update_region(struct vc_data *vc, unsigned long start, int count)
/* Structure of attributes is hardware-dependent */
-static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink,
- u8 _underline, u8 _reverse, u8 _italic)
+static u8 build_attr(struct vc_data *vc, u8 _color,
+ enum vc_intensity _intensity, u8 _blink, u8 _underline,
+ u8 _reverse, u8 _italic)
{
if (vc->vc_sw->con_build_attr)
return vc->vc_sw->con_build_attr(vc, _color, _intensity,
@@ -734,13 +735,13 @@ static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink,
a = (a & 0xF0) | vc->vc_itcolor;
else if (_underline)
a = (a & 0xf0) | vc->vc_ulcolor;
- else if (_intensity == 0)
+ else if (_intensity == VCI_HALF_BRIGHT)
a = (a & 0xf0) | vc->vc_halfcolor;
if (_reverse)
a = ((a) & 0x88) | ((((a) >> 4) | ((a) << 4)) & 0x77);
if (_blink)
a ^= 0x80;
- if (_intensity == 2)
+ if (_intensity == VCI_BOLD)
a ^= 0x08;
if (vc->vc_hi_font_mask == 0x100)
a <<= 1;
@@ -753,8 +754,9 @@ static void update_attr(struct vc_data *vc)
vc->vc_attr = build_attr(vc, vc->state.color, vc->state.intensity,
vc->state.blink, vc->state.underline,
vc->state.reverse ^ vc->vc_decscnm, vc->state.italic);
- vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color, 1,
- vc->state.blink, 0, vc->vc_decscnm, 0) << 8);
+ vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color,
+ VCI_NORMAL, vc->state.blink, 0, vc->vc_decscnm,
+ 0) << 8);
}
/* Note: inverting the screen twice should revert to the original state */
@@ -1611,7 +1613,7 @@ static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar posi
static void default_attr(struct vc_data *vc)
{
- vc->state.intensity = 1;
+ vc->state.intensity = VCI_NORMAL;
vc->state.italic = 0;
vc->state.underline = 0;
vc->state.reverse = 0;
@@ -1652,11 +1654,11 @@ static void rgb_foreground(struct vc_data *vc, const struct rgb *c)
if (hue == 7 && max <= 0x55) {
hue = 0;
- vc->state.intensity = 2;
+ vc->state.intensity = VCI_BOLD;
} else if (max > 0xaa)
- vc->state.intensity = 2;
+ vc->state.intensity = VCI_BOLD;
else
- vc->state.intensity = 1;
+ vc->state.intensity = VCI_NORMAL;
vc->state.color = (vc->state.color & 0xf0) | hue;
}
@@ -1715,10 +1717,10 @@ static void csi_m(struct vc_data *vc)
default_attr(vc);
break;
case 1:
- vc->state.intensity = 2;
+ vc->state.intensity = VCI_BOLD;
break;
case 2:
- vc->state.intensity = 0;
+ vc->state.intensity = VCI_HALF_BRIGHT;
break;
case 3:
vc->state.italic = 1;
@@ -1764,7 +1766,7 @@ static void csi_m(struct vc_data *vc)
vc->vc_toggle_meta = 1;
break;
case 22:
- vc->state.intensity = 1;
+ vc->state.intensity = VCI_NORMAL;
break;
case 23:
vc->state.italic = 0;
@@ -1795,7 +1797,7 @@ static void csi_m(struct vc_data *vc)
default:
if (vc->vc_par[i] >= 90 && vc->vc_par[i] <= 107) {
if (vc->vc_par[i] < 100)
- vc->state.intensity = 2;
+ vc->state.intensity = VCI_BOLD;
vc->vc_par[i] -= 60;
}
if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37)
@@ -1934,7 +1936,7 @@ static void setterm_command(struct vc_data *vc)
case 2: /* set color for half intensity mode */
if (vc->vc_can_do_color && vc->vc_par[1] < 16) {
vc->vc_halfcolor = color_table[vc->vc_par[1]];
- if (vc->state.intensity == 0)
+ if (vc->state.intensity == VCI_HALF_BRIGHT)
update_attr(vc);
}
break;
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c
index cd0155310fea..c59fe641b8b5 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_con.c
+++ b/drivers/usb/misc/sisusbvga/sisusb_con.c
@@ -302,14 +302,14 @@ sisusbcon_deinit(struct vc_data *c)
/* interface routine */
static u8
-sisusbcon_build_attr(struct vc_data *c, u8 color, u8 intensity,
+sisusbcon_build_attr(struct vc_data *c, u8 color, enum vc_intensity intensity,
u8 blink, u8 underline, u8 reverse, u8 unused)
{
u8 attr = color;
if (underline)
attr = (attr & 0xf0) | c->vc_ulcolor;
- else if (intensity == 0)
+ else if (intensity == VCI_HALF_BRIGHT)
attr = (attr & 0xf0) | c->vc_halfcolor;
if (reverse)
@@ -320,7 +320,7 @@ sisusbcon_build_attr(struct vc_data *c, u8 color, u8 intensity,
if (blink)
attr ^= 0x80;
- if (intensity == 2)
+ if (intensity == VCI_BOLD)
attr ^= 0x08;
return attr;
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index d64c5ce84125..e3da664df16c 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -394,7 +394,8 @@ static inline u16 mda_convert_attr(u16 ch)
(ch & 0x00ff) | attr;
}
-static u8 mdacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
+static u8 mdacon_build_attr(struct vc_data *c, u8 color,
+ enum vc_intensity intensity,
u8 blink, u8 underline, u8 reverse, u8 italic)
{
/* The attribute is just a bit vector:
@@ -405,7 +406,7 @@ static u8 mdacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
* Bit 7 : blink
*/
- return (intensity & 3) |
+ return (intensity & VCI_MASK) |
((underline & 1) << 2) |
((reverse & 1) << 3) |
(!!italic << 4) |
diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 90083eb80515..a847067abbe5 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -288,7 +288,8 @@ static unsigned long sticon_getxy(struct vc_data *conp, unsigned long pos,
return ret;
}
-static u8 sticon_build_attr(struct vc_data *conp, u8 color, u8 intens,
+static u8 sticon_build_attr(struct vc_data *conp, u8 color,
+ enum vc_intensity intens,
u8 blink, u8 underline, u8 reverse, u8 italic)
{
u8 attr = ((color & 0x70) >> 1) | ((color & 7));
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index d073fa167e87..d0b26e2318d3 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -629,7 +629,8 @@ static void vgacon_deinit(struct vc_data *c)
con_set_default_unimap(c);
}
-static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
+static u8 vgacon_build_attr(struct vc_data *c, u8 color,
+ enum vc_intensity intensity,
u8 blink, u8 underline, u8 reverse, u8 italic)
{
u8 attr = color;
@@ -639,7 +640,7 @@ static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
attr = (attr & 0xF0) | c->vc_itcolor;
else if (underline)
attr = (attr & 0xf0) | c->vc_ulcolor;
- else if (intensity == 0)
+ else if (intensity == VCI_HALF_BRIGHT)
attr = (attr & 0xf0) | c->vc_halfcolor;
}
if (reverse)
@@ -648,14 +649,14 @@ static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
0x77);
if (blink)
attr ^= 0x80;
- if (intensity == 2)
+ if (intensity == VCI_BOLD)
attr ^= 0x08;
if (!vga_can_do_color) {
if (italic)
attr = (attr & 0xF8) | 0x02;
else if (underline)
attr = (attr & 0xf8) | 0x01;
- else if (intensity == 0)
+ else if (intensity == VCI_HALF_BRIGHT)
attr = (attr & 0xf0) | 0x08;
}
return attr;