diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-24 17:14:37 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-24 17:14:37 -0700 |
commit | 721413aff218118548b84b18cb5b49660e6e2940 (patch) | |
tree | 967b1c535645a25c19e948d0b9fdf096f93b253e /drivers/tty/vt | |
parent | 25a0dc4be86fc0d8c7e81bb5f8be8427022bf15f (diff) | |
parent | 67417f9c262e2cd4b706eba3e1fd879d0bebc6d8 (diff) |
Merge tag 'tty-4.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial driver updates from Greg KH:
"Here is the big tty and serial driver update for 4.8-rc1.
Lots of good cleanups from Jiri on a number of vt and other tty
related things, and the normal driver updates. Full details are in
the shortlog.
All of these have been in linux-next for a while with no reported
issues"
* tag 'tty-4.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (90 commits)
tty/serial: atmel: enforce tasklet init and termination sequences
serial: sh-sci: Stop transfers in sci_shutdown()
serial: 8250_ingenic: drop #if conditional surrounding earlycon code
serial: 8250_mtk: drop !defined(MODULE) conditional
serial: 8250_uniphier: drop !defined(MODULE) conditional
earlycon: mark earlycon code as __used iif the caller is built-in
tty/serial/8250: use mctrl_gpio helpers
serial: mctrl_gpio: enable API usage only for initialized mctrl_gpios struct
serial: mctrl_gpio: add modem control read routine
tty/serial/8250: make UART_MCR register access consistent
serial: 8250_mid: Read RX buffer on RX DMA timeout for DNV
serial: 8250_dma: Export serial8250_rx_dma_flush()
dmaengine: hsu: Export hsu_dma_get_status()
tty: serial: 8250: add CON_CONSDEV to flags
tty: serial: samsung: add byte-order aware bit functions
tty: serial: samsung: fixup accessors for endian
serial: sirf: make fifo functions static
serial: mps2-uart: make driver explicitly non-modular
serial: mvebu-uart: free the IRQ in ->shutdown()
serial/bcm63xx_uart: use correct alias naming
...
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r-- | drivers/tty/vt/consolemap.c | 13 | ||||
-rw-r--r-- | drivers/tty/vt/keyboard.c | 16 | ||||
-rw-r--r-- | drivers/tty/vt/vt.c | 431 | ||||
-rw-r--r-- | drivers/tty/vt/vt_ioctl.c | 8 |
4 files changed, 221 insertions, 247 deletions
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index c8c91f0476a2..9d7ab7b66a8a 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -499,9 +499,8 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos) return 0; } -/* ui is a leftover from using a hashtable, but might be used again - Caller must hold the lock */ -static int con_do_clear_unimap(struct vc_data *vc, struct unimapinit *ui) +/* Caller must hold the lock */ +static int con_do_clear_unimap(struct vc_data *vc) { struct uni_pagedir *p, *q; @@ -524,11 +523,11 @@ static int con_do_clear_unimap(struct vc_data *vc, struct unimapinit *ui) return 0; } -int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui) +int con_clear_unimap(struct vc_data *vc) { int ret; console_lock(); - ret = con_do_clear_unimap(vc, ui); + ret = con_do_clear_unimap(vc); console_unlock(); return ret; } @@ -556,7 +555,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list) int j, k; u16 **p1, *p2, l; - err1 = con_do_clear_unimap(vc, NULL); + err1 = con_do_clear_unimap(vc); if (err1) { console_unlock(); return err1; @@ -677,7 +676,7 @@ int con_set_default_unimap(struct vc_data *vc) /* The default font is always 256 characters */ - err = con_do_clear_unimap(vc, NULL); + err = con_do_clear_unimap(vc); if (err) return err; diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 1e93a37e27f0..0f8caae4267d 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -567,7 +567,7 @@ static void fn_scroll_forw(struct vc_data *vc) static void fn_scroll_back(struct vc_data *vc) { - scrollback(vc, 0); + scrollback(vc); } static void fn_show_mem(struct vc_data *vc) @@ -1733,16 +1733,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm) return -EINVAL; if (ct) { - buf = kmalloc(ct * sizeof(struct kbdiacruc), - GFP_KERNEL); - if (buf == NULL) - return -ENOMEM; - - if (copy_from_user(buf, a->kbdiacruc, - ct * sizeof(struct kbdiacruc))) { - kfree(buf); - return -EFAULT; - } + buf = memdup_user(a->kbdiacruc, + ct * sizeof(struct kbdiacruc)); + if (IS_ERR(buf)) + return PTR_ERR(buf); } spin_lock_irqsave(&kbd_event_lock, flags); if (ct) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 5b0fe97c46ca..2705ca960e92 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -277,13 +277,15 @@ static void notify_update(struct vc_data *vc) * Low-Level Functions */ -#define IS_FG(vc) ((vc)->vc_num == fg_console) +static inline bool con_is_fg(const struct vc_data *vc) +{ + return vc->vc_num == fg_console; +} -#ifdef VT_BUF_VRAM_ONLY -#define DO_UPDATE(vc) 0 -#else -#define DO_UPDATE(vc) (CON_IS_VISIBLE(vc) && !console_blanked) -#endif +static inline bool con_should_update(const struct vc_data *vc) +{ + return con_is_visible(vc) && !console_blanked; +} static inline unsigned short *screenpos(struct vc_data *vc, int offset, int viewed) { @@ -321,7 +323,7 @@ static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr) nr = b - t - 1; if (b > vc->vc_rows || t >= b || nr < 1) return; - if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_UP, nr)) + if (con_is_visible(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_UP, nr)) return; d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr)); @@ -339,7 +341,7 @@ static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr) nr = b - t - 1; if (b > vc->vc_rows || t >= b || nr < 1) return; - if (CON_IS_VISIBLE(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_DOWN, nr)) + if (con_is_visible(vc) && vc->vc_sw->con_scroll(vc, t, b, SM_DOWN, nr)) return; s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); step = vc->vc_cols * nr; @@ -349,7 +351,6 @@ static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr) static void do_update_region(struct vc_data *vc, unsigned long start, int count) { -#ifndef VT_BUF_VRAM_ONLY unsigned int xx, yy, offset; u16 *p; @@ -390,14 +391,13 @@ static void do_update_region(struct vc_data *vc, unsigned long start, int count) start = vc->vc_sw->con_getxy(vc, start, NULL, NULL); } } -#endif } void update_region(struct vc_data *vc, unsigned long start, int count) { WARN_CONSOLE_UNLOCKED(); - if (DO_UPDATE(vc)) { + if (con_should_update(vc)) { hide_cursor(vc); do_update_region(vc, start, count); set_cursor(vc); @@ -413,7 +413,6 @@ static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, return vc->vc_sw->con_build_attr(vc, _color, _intensity, _blink, _underline, _reverse, _italic); -#ifndef VT_BUF_VRAM_ONLY /* * ++roman: I completely changed the attribute format for monochrome * mode (!can_do_color). The formerly used MDA (monochrome display @@ -448,9 +447,6 @@ static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, a <<= 1; return a; } -#else - return 0; -#endif } static void update_attr(struct vc_data *vc) @@ -470,10 +466,9 @@ void invert_screen(struct vc_data *vc, int offset, int count, int viewed) count /= 2; p = screenpos(vc, offset, viewed); - if (vc->vc_sw->con_invert_region) + if (vc->vc_sw->con_invert_region) { vc->vc_sw->con_invert_region(vc, p, count); -#ifndef VT_BUF_VRAM_ONLY - else { + } else { u16 *q = p; int cnt = count; u16 a; @@ -501,8 +496,8 @@ void invert_screen(struct vc_data *vc, int offset, int count, int viewed) } } } -#endif - if (DO_UPDATE(vc)) + + if (con_should_update(vc)) do_update_region(vc, (unsigned long) p, count); notify_update(vc); } @@ -519,7 +514,7 @@ void complement_pos(struct vc_data *vc, int offset) if (old_offset != -1 && old_offset >= 0 && old_offset < vc->vc_screenbuf_size) { scr_writew(old, screenpos(vc, old_offset, 1)); - if (DO_UPDATE(vc)) + if (con_should_update(vc)) vc->vc_sw->con_putc(vc, old, oldy, oldx); notify_update(vc); } @@ -534,7 +529,7 @@ void complement_pos(struct vc_data *vc, int offset) old = scr_readw(p); new = old ^ vc->vc_complement_mask; scr_writew(new, p); - if (DO_UPDATE(vc)) { + if (con_should_update(vc)) { oldx = (offset >> 1) % vc->vc_cols; oldy = (offset >> 1) / vc->vc_cols; vc->vc_sw->con_putc(vc, new, oldy, oldx); @@ -550,7 +545,7 @@ static void insert_char(struct vc_data *vc, unsigned int nr) scr_memmovew(p + nr, p, (vc->vc_cols - vc->vc_x - nr) * 2); scr_memsetw(p, vc->vc_video_erase_char, nr * 2); vc->vc_need_wrap = 0; - if (DO_UPDATE(vc)) + if (con_should_update(vc)) do_update_region(vc, (unsigned long) p, vc->vc_cols - vc->vc_x); } @@ -563,7 +558,7 @@ static void delete_char(struct vc_data *vc, unsigned int nr) scr_memsetw(p + vc->vc_cols - vc->vc_x - nr, vc->vc_video_erase_char, nr * 2); vc->vc_need_wrap = 0; - if (DO_UPDATE(vc)) + if (con_should_update(vc)) do_update_region(vc, (unsigned long) p, vc->vc_cols - vc->vc_x); } @@ -583,7 +578,7 @@ static void add_softcursor(struct vc_data *vc) if ((type & 0x20) && ((softcursor_original & 0x7000) == (i & 0x7000))) i ^= 0x7000; if ((type & 0x40) && ((i & 0x700) == ((i & 0x7000) >> 4))) i ^= 0x0700; scr_writew(i, (u16 *) vc->vc_pos); - if (DO_UPDATE(vc)) + if (con_should_update(vc)) vc->vc_sw->con_putc(vc, i, vc->vc_y, vc->vc_x); } @@ -591,7 +586,7 @@ static void hide_softcursor(struct vc_data *vc) { if (softcursor_original != -1) { scr_writew(softcursor_original, (u16 *)vc->vc_pos); - if (DO_UPDATE(vc)) + if (con_should_update(vc)) vc->vc_sw->con_putc(vc, softcursor_original, vc->vc_y, vc->vc_x); softcursor_original = -1; @@ -608,8 +603,7 @@ static void hide_cursor(struct vc_data *vc) static void set_cursor(struct vc_data *vc) { - if (!IS_FG(vc) || console_blanked || - vc->vc_mode == KD_GRAPHICS) + if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS) return; if (vc->vc_deccm) { if (vc == sel_cons) @@ -625,7 +619,7 @@ static void set_origin(struct vc_data *vc) { WARN_CONSOLE_UNLOCKED(); - if (!CON_IS_VISIBLE(vc) || + if (!con_is_visible(vc) || !vc->vc_sw->con_set_origin || !vc->vc_sw->con_set_origin(vc)) vc->vc_origin = (unsigned long)vc->vc_screenbuf; @@ -673,12 +667,12 @@ void redraw_screen(struct vc_data *vc, int is_switch) struct vc_data *old_vc = vc_cons[fg_console].d; if (old_vc == vc) return; - if (!CON_IS_VISIBLE(vc)) + if (!con_is_visible(vc)) redraw = 1; *vc->vc_display_fg = vc; fg_console = vc->vc_num; hide_cursor(old_vc); - if (!CON_IS_VISIBLE(old_vc)) { + if (!con_is_visible(old_vc)) { save_screen(old_vc); set_origin(old_vc); } @@ -954,7 +948,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, tty_do_resize(tty, &ws); } - if (CON_IS_VISIBLE(vc)) + if (con_is_visible(vc)) update_screen(vc); vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num); return err; @@ -1103,11 +1097,9 @@ static void gotoxay(struct vc_data *vc, int new_x, int new_y) gotoxy(vc, new_x, vc->vc_decom ? (vc->vc_top + new_y) : new_y); } -void scrollback(struct vc_data *vc, int lines) +void scrollback(struct vc_data *vc) { - if (!lines) - lines = vc->vc_rows / 2; - scrolldelta(-lines); + scrolldelta(-(vc->vc_rows / 2)); } void scrollfront(struct vc_data *vc, int lines) @@ -1186,7 +1178,7 @@ static void csi_J(struct vc_data *vc, int vpar) scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char, vc->vc_screenbuf_size >> 1); set_origin(vc); - if (CON_IS_VISIBLE(vc)) + if (con_is_visible(vc)) update_screen(vc); /* fall through */ case 2: /* erase whole display */ @@ -1197,7 +1189,7 @@ static void csi_J(struct vc_data *vc, int vpar) return; } scr_memsetw(start, vc->vc_video_erase_char, 2 * count); - if (DO_UPDATE(vc)) + if (con_should_update(vc)) do_update_region(vc, (unsigned long) start, count); vc->vc_need_wrap = 0; } @@ -1225,7 +1217,7 @@ static void csi_K(struct vc_data *vc, int vpar) } scr_memsetw(start, vc->vc_video_erase_char, 2 * count); vc->vc_need_wrap = 0; - if (DO_UPDATE(vc)) + if (con_should_update(vc)) do_update_region(vc, (unsigned long) start, count); } @@ -1238,7 +1230,7 @@ static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar posi count = (vpar > vc->vc_cols - vc->vc_x) ? (vc->vc_cols - vc->vc_x) : vpar; scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); - if (DO_UPDATE(vc)) + if (con_should_update(vc)) vc->vc_sw->con_clear(vc, vc->vc_y, vc->vc_x, 1, count); vc->vc_need_wrap = 0; } @@ -1255,48 +1247,87 @@ static void default_attr(struct vc_data *vc) struct rgb { u8 r; u8 g; u8 b; }; -static struct rgb rgb_from_256(int i) +static void rgb_from_256(int i, struct rgb *c) { - struct rgb c; if (i < 8) { /* Standard colours. */ - c.r = i&1 ? 0xaa : 0x00; - c.g = i&2 ? 0xaa : 0x00; - c.b = i&4 ? 0xaa : 0x00; + c->r = i&1 ? 0xaa : 0x00; + c->g = i&2 ? 0xaa : 0x00; + c->b = i&4 ? 0xaa : 0x00; } else if (i < 16) { - c.r = i&1 ? 0xff : 0x55; - c.g = i&2 ? 0xff : 0x55; - c.b = i&4 ? 0xff : 0x55; + c->r = i&1 ? 0xff : 0x55; + c->g = i&2 ? 0xff : 0x55; + c->b = i&4 ? 0xff : 0x55; } else if (i < 232) { /* 6x6x6 colour cube. */ - c.r = (i - 16) / 36 * 85 / 2; - c.g = (i - 16) / 6 % 6 * 85 / 2; - c.b = (i - 16) % 6 * 85 / 2; + c->r = (i - 16) / 36 * 85 / 2; + c->g = (i - 16) / 6 % 6 * 85 / 2; + c->b = (i - 16) % 6 * 85 / 2; } else /* Grayscale ramp. */ - c.r = c.g = c.b = i * 10 - 2312; - return c; + c->r = c->g = c->b = i * 10 - 2312; } -static void rgb_foreground(struct vc_data *vc, struct rgb c) +static void rgb_foreground(struct vc_data *vc, const struct rgb *c) { - u8 hue, max = c.r; - if (c.g > max) - max = c.g; - if (c.b > max) - max = c.b; - hue = (c.r > max/2 ? 4 : 0) - | (c.g > max/2 ? 2 : 0) - | (c.b > max/2 ? 1 : 0); - if (hue == 7 && max <= 0x55) - hue = 0, vc->vc_intensity = 2; + u8 hue = 0, max = max3(c->r, c->g, c->b); + + if (c->r > max / 2) + hue |= 4; + if (c->g > max / 2) + hue |= 2; + if (c->b > max / 2) + hue |= 1; + + if (hue == 7 && max <= 0x55) { + hue = 0; + vc->vc_intensity = 2; + } else if (max > 0xaa) + vc->vc_intensity = 2; else - vc->vc_intensity = (max > 0xaa) + 1; + vc->vc_intensity = 1; + vc->vc_color = (vc->vc_color & 0xf0) | hue; } -static void rgb_background(struct vc_data *vc, struct rgb c) +static void rgb_background(struct vc_data *vc, const struct rgb *c) { /* For backgrounds, err on the dark side. */ vc->vc_color = (vc->vc_color & 0x0f) - | (c.r&0x80) >> 1 | (c.g&0x80) >> 2 | (c.b&0x80) >> 3; + | (c->r&0x80) >> 1 | (c->g&0x80) >> 2 | (c->b&0x80) >> 3; +} + +/* + * ITU T.416 Higher colour modes. They break the usual properties of SGR codes + * and thus need to be detected and ignored by hand. Strictly speaking, that + * standard also wants : rather than ; as separators, contrary to ECMA-48, but + * no one produces such codes and almost no one accepts them. + * + * Subcommands 3 (CMY) and 4 (CMYK) are so insane there's no point in + * supporting them. + */ +static int vc_t416_color(struct vc_data *vc, int i, + void(*set_color)(struct vc_data *vc, const struct rgb *c)) +{ + struct rgb c; + + i++; + if (i > vc->vc_npar) + return i; + + if (vc->vc_par[i] == 5 && i < vc->vc_npar) { + /* 256 colours -- ubiquitous */ + i++; + rgb_from_256(vc->vc_par[i], &c); + } else if (vc->vc_par[i] == 2 && i <= vc->vc_npar + 3) { + /* 24 bit -- extremely rare */ + c.r = vc->vc_par[i + 1]; + c.g = vc->vc_par[i + 2]; + c.b = vc->vc_par[i + 3]; + i += 3; + } else + return i; + + set_color(vc, &c); + + return i; } /* console_lock is held */ @@ -1306,135 +1337,91 @@ static void csi_m(struct vc_data *vc) for (i = 0; i <= vc->vc_npar; i++) switch (vc->vc_par[i]) { - case 0: /* all attributes off */ - default_attr(vc); - break; - case 1: - vc->vc_intensity = 2; - break; - case 2: - vc->vc_intensity = 0; - break; - case 3: - vc->vc_italic = 1; - break; - case 4: - vc->vc_underline = 1; - break; - case 5: - vc->vc_blink = 1; - break; - case 7: - vc->vc_reverse = 1; - break; - case 10: /* ANSI X3.64-1979 (SCO-ish?) - * Select primary font, don't display - * control chars if defined, don't set - * bit 8 on output. - */ - vc->vc_translate = set_translate(vc->vc_charset == 0 - ? vc->vc_G0_charset - : vc->vc_G1_charset, vc); - vc->vc_disp_ctrl = 0; - vc->vc_toggle_meta = 0; - break; - case 11: /* ANSI X3.64-1979 (SCO-ish?) - * Select first alternate font, lets - * chars < 32 be displayed as ROM chars. - */ - vc->vc_translate = set_translate(IBMPC_MAP, vc); - vc->vc_disp_ctrl = 1; - vc->vc_toggle_meta = 0; - break; - case 12: /* ANSI X3.64-1979 (SCO-ish?) - * Select second alternate font, toggle - * high bit before displaying as ROM char. - */ - vc->vc_translate = set_translate(IBMPC_MAP, vc); - vc->vc_disp_ctrl = 1; - vc->vc_toggle_meta = 1; - break; - case 21: - case 22: - vc->vc_intensity = 1; - break; - case 23: - vc->vc_italic = 0; - break; - case 24: - vc->vc_underline = 0; - break; - case 25: - vc->vc_blink = 0; - break; - case 27: - vc->vc_reverse = 0; - break; - case 38: /* ITU T.416 - * Higher colour modes. - * They break the usual properties of SGR codes - * and thus need to be detected and ignored by - * hand. Strictly speaking, that standard also - * wants : rather than ; as separators, contrary - * to ECMA-48, but no one produces such codes - * and almost no one accepts them. - */ - i++; - if (i > vc->vc_npar) - break; - if (vc->vc_par[i] == 5 && /* 256 colours */ - i < vc->vc_npar) { /* ubiquitous */ - i++; - rgb_foreground(vc, - rgb_from_256(vc->vc_par[i])); - } else if (vc->vc_par[i] == 2 && /* 24 bit */ - i <= vc->vc_npar + 3) {/* extremely rare */ - struct rgb c = { - .r = vc->vc_par[i + 1], - .g = vc->vc_par[i + 2], - .b = vc->vc_par[i + 3], - }; - rgb_foreground(vc, c); - i += 3; - } - /* Subcommands 3 (CMY) and 4 (CMYK) are so insane - * there's no point in supporting them. - */ - break; - case 48: - i++; - if (i > vc->vc_npar) - break; - if (vc->vc_par[i] == 5 && /* 256 colours */ - i < vc->vc_npar) { - i++; - rgb_background(vc, - rgb_from_256(vc->vc_par[i])); - } else if (vc->vc_par[i] == 2 && /* 24 bit */ - i <= vc->vc_npar + 3) { - struct rgb c = { - .r = vc->vc_par[i + 1], - .g = vc->vc_par[i + 2], - .b = vc->vc_par[i + 3], - }; - rgb_background(vc, c); - i += 3; - } - break; - case 39: - vc->vc_color = (vc->vc_def_color & 0x0f) | (vc->vc_color & 0xf0); - break; - case 49: - vc->vc_color = (vc->vc_def_color & 0xf0) | (vc->vc_color & 0x0f); - break; - default: - if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) - vc->vc_color = color_table[vc->vc_par[i] - 30] - | (vc->vc_color & 0xf0); - else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) - vc->vc_color = (color_table[vc->vc_par[i] - 40] << 4) - | (vc->vc_color & 0x0f); - break; + case 0: /* all attributes off */ + default_attr(vc); + break; + case 1: + vc->vc_intensity = 2; + break; + case 2: + vc->vc_intensity = 0; + break; + case 3: + vc->vc_italic = 1; + break; + case 4: + vc->vc_underline = 1; + break; + case 5: + vc->vc_blink = 1; + break; + case 7: + vc->vc_reverse = 1; + break; + case 10: /* ANSI X3.64-1979 (SCO-ish?) + * Select primary font, don't display control chars if + * defined, don't set bit 8 on output. + */ + vc->vc_translate = set_translate(vc->vc_charset == 0 + ? vc->vc_G0_charset + : vc->vc_G1_charset, vc); + vc->vc_disp_ctrl = 0; + vc->vc_toggle_meta = 0; + break; + case 11: /* ANSI X3.64-1979 (SCO-ish?) + * Select first alternate font, lets chars < 32 be + * displayed as ROM chars. + */ + vc->vc_translate = set_translate(IBMPC_MAP, vc); + vc->vc_disp_ctrl = 1; + vc->vc_toggle_meta = 0; + break; + case 12: /* ANSI X3.64-1979 (SCO-ish?) + * Select second alternate font, toggle high bit + * before displaying as ROM char. + */ + vc->vc_translate = set_translate(IBMPC_MAP, vc); + vc->vc_disp_ctrl = 1; + vc->vc_toggle_meta = 1; + break; + case 21: + case 22: + vc->vc_intensity = 1; + break; + case 23: + vc->vc_italic = 0; + break; + case 24: + vc->vc_underline = 0; + break; + case 25: + vc->vc_blink = 0; + break; + case 27: + vc->vc_reverse = 0; + break; + case 38: + i = vc_t416_color(vc, i, rgb_foreground); + break; + case 48: + i = vc_t416_color(vc, i, rgb_background); + break; + case 39: + vc->vc_color = (vc->vc_def_color & 0x0f) | + (vc->vc_color & 0xf0); + break; + case 49: + vc->vc_color = (vc->vc_def_color & 0xf0) | + (vc->vc_color & 0x0f); + break; + default: + if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) + vc->vc_color = color_table[vc->vc_par[i] - 30] + | (vc->vc_color & 0xf0); + else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) + vc->vc_color = (color_table[vc->vc_par[i] - 40] << 4) + | (vc->vc_color & 0x0f); + break; } update_attr(vc); } @@ -1496,7 +1483,6 @@ static void set_mode(struct vc_data *vc, int on_off) clr_kbd(vc, decckm); break; case 3: /* 80/132 mode switch unimplemented */ - vc->vc_deccolm = on_off; #if 0 vc_resize(deccolm ? 132 : 80, vc->vc_rows); /* this alone does not suffice; some user mode @@ -2178,18 +2164,20 @@ static int is_double_width(uint32_t ucs) return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1); } +static void con_flush(struct vc_data *vc, unsigned long draw_from, + unsigned long draw_to, int *draw_x) +{ + if (*draw_x < 0) + return; + + vc->vc_sw->con_putcs(vc, (u16 *)draw_from, + (u16 *)draw_to - (u16 *)draw_from, vc->vc_y, *draw_x); + *draw_x = -1; +} + /* acquires console_lock */ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) { -#ifdef VT_BUF_VRAM_ONLY -#define FLUSH do { } while(0); -#else -#define FLUSH if (draw_x >= 0) { \ - vc->vc_sw->con_putcs(vc, (u16 *)draw_from, (u16 *)draw_to - (u16 *)draw_from, vc->vc_y, draw_x); \ - draw_x = -1; \ - } -#endif - int c, tc, ok, n = 0, draw_x = -1; unsigned int currcons; unsigned long draw_from = 0, draw_to = 0; @@ -2226,7 +2214,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co charmask = himask ? 0x1ff : 0xff; /* undraw cursor first */ - if (IS_FG(vc)) + if (con_is_fg(vc)) hide_cursor(vc); param.vc = vc; @@ -2381,12 +2369,13 @@ rescan_last_byte: } else { vc_attr = ((vc->vc_attr) & 0x88) | (((vc->vc_attr) & 0x70) >> 4) | (((vc->vc_attr) & 0x07) << 4); } - FLUSH + con_flush(vc, draw_from, draw_to, &draw_x); } while (1) { if (vc->vc_need_wrap || vc->vc_decim) - FLUSH + con_flush(vc, draw_from, draw_to, + &draw_x); if (vc->vc_need_wrap) { cr(vc); lf(vc); @@ -2397,7 +2386,7 @@ rescan_last_byte: ((vc_attr << 8) & ~himask) + ((tc & 0x100) ? himask : 0) + (tc & 0xff) : (vc_attr << 8) + tc, (u16 *) vc->vc_pos); - if (DO_UPDATE(vc) && draw_x < 0) { + if (con_should_update(vc) && draw_x < 0) { draw_x = vc->vc_x; draw_from = vc->vc_pos; } @@ -2416,9 +2405,8 @@ rescan_last_byte: } notify_write(vc, c); - if (inverse) { - FLUSH - } + if (inverse) + con_flush(vc, draw_from, draw_to, &draw_x); if (rescan) { rescan = 0; @@ -2429,15 +2417,14 @@ rescan_last_byte: } continue; } - FLUSH + con_flush(vc, draw_from, draw_to, &draw_x); do_con_trol(tty, vc, orig); } - FLUSH + con_flush(vc, draw_from, draw_to, &draw_x); console_conditional_schedule(); console_unlock(); notify_update(vc); return n; -#undef FLUSH } /* @@ -2471,7 +2458,7 @@ static void console_callback(struct work_struct *ignored) if (scrollback_delta) { struct vc_data *vc = vc_cons[fg_console].d; clear_selection(); - if (vc->vc_mode == KD_TEXT) + if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta) vc->vc_sw->con_scrolldelta(vc, scrollback_delta); scrollback_delta = 0; } @@ -2583,7 +2570,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) goto quit; /* undraw cursor first */ - if (IS_FG(vc)) + if (con_is_fg(vc)) hide_cursor(vc); start = (ushort *)vc->vc_pos; @@ -2594,7 +2581,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) c = *b++; if (c == 10 || c == 13 || c == 8 || vc->vc_need_wrap) { if (cnt > 0) { - if (CON_IS_VISIBLE(vc)) + if (con_is_visible(vc)) vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); vc->vc_x += cnt; if (vc->vc_need_wrap) @@ -2626,7 +2613,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count) myx++; } if (cnt > 0) { - if (CON_IS_VISIBLE(vc)) + if (con_is_visible(vc)) vc->vc_sw->con_putcs(vc, start, cnt, vc->vc_y, vc->vc_x); vc->vc_x += cnt; if (vc->vc_x == vc->vc_cols) { @@ -3173,7 +3160,7 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last, j = i; - if (CON_IS_VISIBLE(vc)) { + if (con_is_visible(vc)) { k = i; save_screen(vc); } @@ -3981,7 +3968,7 @@ static void set_palette(struct vc_data *vc) { WARN_CONSOLE_UNLOCKED(); - if (vc->vc_mode != KD_GRAPHICS) + if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_set_palette) vc->vc_sw->con_set_palette(vc, color_table); } diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c index 97d5a74558a3..f62c598810ff 100644 --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -1006,16 +1006,10 @@ int vt_ioctl(struct tty_struct *tty, break; case PIO_UNIMAPCLR: - { struct unimapinit ui; if (!perm) return -EPERM; - ret = copy_from_user(&ui, up, sizeof(struct unimapinit)); - if (ret) - ret = -EFAULT; - else - con_clear_unimap(vc, &ui); + con_clear_unimap(vc); break; - } case PIO_UNIMAP: case GIO_UNIMAP: |