tty: vt: cleanup and documentation
Subsystems (7)
Jiri Slaby (SUSE)
maintainerv2 cover tty: vt: cleanup and documentation
Push the console code (vt.c, vt.h, console.h, ...) into a bit more maintainable state. Especially all around consw structure and document it.
CSI parser is also a bit cleaned up. More to follow some time in the next round.
[v2] See respective patches for changes. The major changes:
* vesa.h introduced
* parameters of csi*() simplified
Jiri Slaby (SUSE) (47):
vgacon: inline vc_scrolldelta_helper() into vgacon_scrolldelta()
fbcon: make display_desc a static array in fbcon_startup()
tty: vt: fix 20 vs 0x20 typo in EScsiignore
tty: vt: expect valid vc when in tty ops
tty: vt: pass proper pointers from tioclinux()
tty: vt: push console lock from tioclinux() down to 2 functions
tty: vt: pass vc_resize_user as a parameter
tty: vt: make vc_is_sel()'s vc const
tty: vt: define an enum for CSI+m codes
tty: vt: use case ranges for CSI+m fg/bg colors
tty: vt: define an enum for CSI+J codes
tty: vt: reflow csi_J()
use clamp() for counts in csi_?() handlers
don't pass vc->vc_par[0] to csi_?() handlers
tty: vt: define an enum for CSI+K codes
tty: vt: reflow csi_K()
tty: vt: define an enum for ascii characters
tty: vt: remove extern from functions in selection.h
tty: vt: make consw::con_debug_*() return void
tty: vt: make init parameter of consw::con_init() a bool
tty: vt: sanitize arguments of consw::con_clear()
tty: vt: remove checks for count in consw::con_clear() implementations
tty: vt: add con_putc() helper
tty: vt: eliminate unneeded consw::con_putc() implementations
tty: vt: sanitize consw::con_putc() parameters
tty: vt: sanitize consw::con_putcs() parameters
consoles: use if instead of switch-case in consw::con_cursor() fbdev/core: simplify cursor_state setting in fbcon_ops::cursor()
tty: vt: remove CM_* constants
tty: vt: make consw::con_switch() return a bool
tty: vt: stop using -1 for blank mode in consw::con_blank()
tty: vt: define a common enum for VESA blanking constants
tty: vt: use VESA blanking constants
tty: vt: use enum constants for VESA blanking modes
tty: vt: make types around consw::con_blank() bool
tty: vt: make font of consw::con_font_set() const
tty: vt: make consw::con_font_default()'s name const
tty: vt: change consw::con_set_origin() return type
fbcon: remove consw::con_screen_pos()
tty: vt: remove consw::con_screen_pos()
tty: vt: make types of screenpos() more consistent
fbcon: remove fbcon_getxy()
tty: vt: remove consw::con_getxy()
tty: vt: remove unused consw::con_flush_scrollback()
tty: vt: document the rest of struct consw
tty: vt: fix up kernel-doc
Documentation: add console.rst
Documentation/driver-api/tty/console.rst | 45 ++ Documentation/driver-api/tty/index.rst | 1 + drivers/tty/vt/selection.c | 43 +- drivers/tty/vt/vt.c | 645 +++++++++++------------ drivers/tty/vt/vt_ioctl.c | 6 +- drivers/video/console/dummycon.c | 38 +- drivers/video/console/mdacon.c | 43 +- drivers/video/console/newport_con.c | 69 +-- drivers/video/console/sticon.c | 79 ++- drivers/video/console/vgacon.c | 152 +++--- drivers/video/fbdev/core/bitblit.c | 13 +- drivers/video/fbdev/core/fbcon.c | 123 ++--- drivers/video/fbdev/core/fbcon.h | 4 +- drivers/video/fbdev/core/fbcon_ccw.c | 13 +- drivers/video/fbdev/core/fbcon_cw.c | 13 +- drivers/video/fbdev/core/fbcon_ud.c | 13 +- drivers/video/fbdev/core/tileblit.c | 4 +- include/linux/console.h | 124 +++-- include/linux/console_struct.h | 1 - include/linux/selection.h | 56 +- include/linux/vt_kern.h | 12 +- include/uapi/linux/fb.h | 8 +- include/uapi/linux/vesa.h | 18 + 23 files changed, 755 insertions(+), 768 deletions(-) create mode 100644 Documentation/driver-api/tty/console.rst create mode 100644 include/uapi/linux/vesa.h
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 1/47 vgacon: inline vc_scrolldelta_helper() into vgacon_scrolldelta()
Since commit 74d58cd48a8f ("USB: sisusbvga: remove console support"), vgacon_scrolldelta() is the only user of vc_scrolldelta_helper().
Inline the helper into vgacon_scrolldelta() and drop it.
--- drivers/tty/vt/vt.c | 40 ---------------------------------- drivers/video/console/vgacon.c | 36 ++++++++++++++++++++++++++++-- include/linux/vt_kern.h | 3 --- 3 files changed, 34 insertions(+), 45 deletions(-)
drivers/tty/vt/vt.c +0 -40
@@ -4748,43 +4748,3 @@ void vcs_scr_updated(struct vc_data *vc) {notify_update (vc); } - -void vc_scrolldelta_helper (struct vc_data *c,int lines, -unsigned int rolled_over,void *base,unsigned int size) -{ -unsigned long ubase = (unsigned long )base; -ptrdiff_t scr_end = (void *)c->vc_scr_end - base; -ptrdiff_t vorigin = (void *)c->vc_visible_origin - base; -ptrdiff_t origin = (void *)c->vc_origin - base; -int margin = c->vc_size_row *4 ; -int from, wrap, from_off, avail; - -/* Turn scrollback off */ -if (!lines) { - c->vc_visible_origin = c->vc_origin; -return ; - } - -/* Do we have already enough to allow jumping from 0 to the end? */ -if (rolled_over > scr_end + margin) { - from = scr_end; - wrap = rolled_over + c->vc_size_row; - }else { - from =0 ; - wrap = size; - } - - from_off = (vorigin - from + wrap) % wrap + lines * c->vc_size_row; - avail = (origin - from + wrap) % wrap; - -/* Only a little piece would be left? Show all incl. the piece! */ -if (avail <2 * margin) - margin =0 ; -if (from_off < margin) - from_off =0 ; -if (from_off > avail - margin) - from_off = avail; - - c->vc_visible_origin = ubase + (from + from_off) % wrap; -} -EXPORT_SYMBOL_GPL (vc_scrolldelta_helper);
drivers/video/console/vgacon.c +34 -2
@@ -138,8 +138,40 @@ static inline void vga_set_mem_top(struct vc_data *c)static void vgacon_scrolldelta (struct vc_data *c,int lines) { -vc_scrolldelta_helper (c, lines, vga_rolled_over, (void *)vga_vram_base, - vga_vram_size); +unsigned long scr_end = c->vc_scr_end - vga_vram_base; +unsigned long vorigin = c->vc_visible_origin - vga_vram_base; +unsigned long origin = c->vc_origin - vga_vram_base; +int margin = c->vc_size_row *4 ; +int from, wrap, from_off, avail; + +/* Turn scrollback off */ +if (!lines) { + c->vc_visible_origin = c->vc_origin; +return ; + } + +/* Do we have already enough to allow jumping from 0 to the end? */ +if (vga_rolled_over > scr_end + margin) { + from = scr_end; + wrap = vga_rolled_over + c->vc_size_row; + }else { + from =0 ; + wrap = vga_vram_size; + } + + from_off = (vorigin - from + wrap) % wrap + lines * c->vc_size_row; + avail = (origin - from + wrap) % wrap; + +/* Only a little piece would be left? Show all incl. the piece! */ +if (avail <2 * margin) + margin =0 ; +if (from_off < margin) + from_off =0 ; +if (from_off > avail - margin) + from_off = avail; + + c->vc_visible_origin = vga_vram_base + (from + from_off) % wrap; +vga_set_mem_top (c); }
include/linux/vt_kern.h +0 -3
@@ -168,7 +168,4 @@ void vt_set_led_state(unsigned int console, int leds);void vt_kbd_con_start (unsigned int console);void vt_kbd_con_stop (unsigned int console); -void vc_scrolldelta_helper (struct vc_data *c,int lines, -unsigned int rolled_over,void *_base,unsigned int size); -#endif /* _VT_KERN_H */
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 2/47 fbcon: make display_desc a static array in fbcon_startup()
In reply to Jiri Slaby (SUSE)display_desc is a pointer to a RO string. Instead, switch display_desc to a static array as we are used to. It BTW saves unnecessary 8B on the stack.
--- drivers/video/fbdev/core/fbcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/core/fbcon.c +1 -1
@@ -921,7 +921,7 @@ static void display_to_var(struct fb_var_screeninfo *var,static const char *fbcon_startup (void ) { -const char *display_desc ="frame buffer device" ; +static const char display_desc[] ="frame buffer device" ;struct fbcon_display *p = &fb_display[fg_console];struct vc_data *vc = vc_cons[fg_console].d;const struct font_desc *font =NULL ;
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 3/47 tty: vt: fix 20 vs 0x20 typo in EScsiignore
In reply to Jiri Slaby (SUSE)The if (c >= 20 && c <= 0x3f) test added in commit 7a99565f8732 is wrong. 20 is DC4 in ascii and it makes no sense to consider that as the bottom limit. Instead, it should be 0x20 as in the other test in the commit above. This is supposed to NOT change anything as we handle interesting 20-0x20 asciis far before this if.
So for sakeness, change to 0x20 (which is SPACE).
--- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vt/vt.c +1 -1
@@ -2469,7 +2469,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) }return ;case EScsiignore: -if (c >=20 && c <=0x3f ) +if (c >=0x20 && c <=0x3f )return ; vc->vc_state = ESnormal;return ;
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 4/47 tty: vt: expect valid vc when in tty ops
In reply to Jiri Slaby (SUSE)At least since commits feebed6515a1 ("tty: shutdown method") and bc1e99d93f09 ("TTY: vt, add ->install"), tty->driver_data in vc is expected to be set since tty_operations::install() till ::cleanup().
So the checks of !tty->driver_data (aka !vc) in:
* vc_do_resize() by tty -> ioctl(TIOCSWINSZ) -> vt_resize()
* do_con_write() by tty -> tty_operations::write()/::put_char()
* con_flush_chars() by tty -> ::flush_chars()
are all superfluous. And also, holding a console lock is not needed to fetch tty->driver_data.
Note there is even a stale comment in con_flush_chars() about a race between that and con_close(). But con_close() does not set tty->driver_data to NULL for years already.
Drop all these in a hope I am not terribly mistaken.
--- drivers/tty/vt/vt.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/tty/vt/vt.c +3 -16
@@ -1154,9 +1154,6 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,WARN_CONSOLE_UNLOCKED (); -if (!vc) -return -ENXIO ; - user = vc->vc_resize_user; vc->vc_resize_user =0 ;
@@ -2852,7 +2849,7 @@ static int do_con_write(struct tty_struct *tty, const u8 *buf, int count) };int c, tc, n =0 ;unsigned int currcons; -struct vc_data *vc; +struct vc_data *vc = tty->driver_data;struct vt_notifier_param param;bool rescan;
@@ -2860,13 +2857,6 @@ static int do_con_write(struct tty_struct *tty, const u8 *buf, int count)return count;console_lock (); - vc = tty->driver_data; -if (vc ==NULL ) { -pr_err ("vt: argh, driver_data is NULL !\n" ); -console_unlock (); -return 0 ; - } - currcons = vc->vc_num;if (!vc_cons_allocated (currcons)) {/* could this happen? */
@@ -3312,16 +3302,13 @@ static void con_start(struct tty_struct *tty)static void con_flush_chars (struct tty_struct *tty) { -struct vc_data *vc; +struct vc_data *vc = tty->driver_data;if (in_interrupt ())/* from flush_to_ldisc */ return ; -/* if we race with con_close(), vt may be null */ console_lock (); - vc = tty->driver_data; -if (vc) -set_cursor (vc); +set_cursor (vc);console_unlock (); }
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 5/47 tty: vt: pass proper pointers from tioclinux()
In reply to Jiri Slaby (SUSE)Pass proper types and proper pointers (the data with an offset) to the TIOCL_* handlers. So that they need not to cast or add anything to the passed pointer.
This makes obvious what is passed/consumed.
--- drivers/tty/vt/selection.c | 8 ++++---- drivers/tty/vt/vt.c | 19 ++++++++++--------- include/linux/selection.h | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-)
drivers/tty/vt/selection.c +4 -4
@@ -7,7 +7,7 @@* 'int set_selection_kernel(struct tiocl_selection *, struct tty_struct *)' * 'void clear_selection(void)' * 'int paste_selection(struct tty_struct *)' -* 'int sel_loadlut(char __user *)' +* 'int sel_loadlut(u32 __user *)' * * Now that /dev/vcs exists, most of this can disappear again. */
@@ -111,15 +111,15 @@ static inline int inword(const u32 c)/** * sel_loadlut() - load the LUT table -* @p: user table +* @lut: user table * * Load the LUT table from user space. The caller must hold the console * lock. Make a temporary copy so a partial update doesn't make a mess. */ -int sel_loadlut (char __user *p) +int sel_loadlut (u32 __user *lut) {u32 tmplut[ARRAY_SIZE (inwordLut)]; -if (copy_from_user (tmplut, (u32 __user *)(p+4 ),sizeof (inwordLut))) +if (copy_from_user (tmplut, lut,sizeof (inwordLut)))return -EFAULT ;memcpy (inwordLut, tmplut,sizeof (inwordLut));return 0 ;
drivers/tty/vt/vt.c +10 -9
@@ -145,7 +145,7 @@ static void gotoxy(struct vc_data *vc, int new_x, int new_y);static void save_cur (struct vc_data *vc);static void reset_terminal (struct vc_data *vc,int do_clear);static void con_flush_chars (struct tty_struct *tty); -static int set_vesa_blanking (char __user *p); +static int set_vesa_blanking (u8 __user *mode);static void set_cursor (struct vc_data *vc);static void hide_cursor (struct vc_data *vc);static void console_callback (struct work_struct *ignored);
@@ -3134,6 +3134,8 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) {char type, data;char __user *p = (char __user *)arg; +void __user *param_aligned32 = (u32 __user *)arg +1 ; +void __user *param = (void __user *)arg +1 ;int lines;int ret;
@@ -3147,8 +3149,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)case TIOCL_SETSEL :if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -return set_selection_user ((struct tiocl_selection -__user *)(p+1 ), tty); +return set_selection_user (param, tty);case TIOCL_PASTESEL :if (!capable (CAP_SYS_ADMIN ))return -EPERM ;
@@ -3162,7 +3163,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)if (!capable (CAP_SYS_ADMIN ))return -EPERM ;console_lock (); - ret =sel_loadlut (p); + ret =sel_loadlut (param_aligned32);console_unlock ();break ;case TIOCL_GETSHIFTSTATE :
@@ -3181,7 +3182,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)return put_user (data, p);case TIOCL_SETVESABLANK :console_lock (); - ret =set_vesa_blanking (p); + ret =set_vesa_blanking (param);console_unlock ();break ;case TIOCL_GETKMSGREDIRECT :
@@ -3204,7 +3205,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)*/ return fg_console;case TIOCL_SCROLLCONSOLE : -if (get_user (lines, (s32 __user *)(p+4 ))) +if (get_user (lines, (s32 __user *)param_aligned32))return -EFAULT ;/*
@@ -4262,11 +4263,11 @@ postcore_initcall(vtconsole_class_init);* Screen blanking */ -static int set_vesa_blanking (char __user *p) +static int set_vesa_blanking (u8 __user *mode_user) { -unsigned int mode; +u8 mode; -if (get_user (mode, p +1 )) +if (get_user (mode, mode_user))return -EFAULT ; vesa_blank_mode = (mode <4 ) ? mode :0 ;
include/linux/selection.h +1 -1
@@ -20,7 +20,7 @@ extern int set_selection_user(const struct tiocl_selection __user *sel,extern int set_selection_kernel (struct tiocl_selection *v,struct tty_struct *tty);extern int paste_selection (struct tty_struct *tty); -extern int sel_loadlut (char __user *p); +extern int sel_loadlut (u32 __user *lut);extern int mouse_reporting (void );extern void mouse_report (struct tty_struct * tty,int butt,int mrx,int mry);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 6/47 tty: vt: push console lock from tioclinux() down to 2 functions
In reply to Jiri Slaby (SUSE)Avoid costly user copies under the console lock. So push the lock down from tioclinux() to sel_loadlut() and set_vesa_blanking().
It is now obvious what is actually protected.
--- drivers/tty/vt/selection.c | 11 +++++++++-- drivers/tty/vt/vt.c | 13 +++++-------- 2 files changed, 14 insertions(+), 10 deletions(-)
drivers/tty/vt/selection.c +9 -2
@@ -113,15 +113,22 @@ static inline int inword(const u32 c)* sel_loadlut() - load the LUT table * @lut: user table * -* Load the LUT table from user space. The caller must hold the console -* lock. Make a temporary copy so a partial update doesn't make a mess. +* Load the LUT table from user space. Make a temporary copy so a partial +* update doesn't make a mess. +* +* Locking: The console lock is acquired. */ int sel_loadlut (u32 __user *lut) {u32 tmplut[ARRAY_SIZE (inwordLut)]; +if (copy_from_user (tmplut, lut,sizeof (inwordLut)))return -EFAULT ; + +console_lock ();memcpy (inwordLut, tmplut,sizeof (inwordLut)); +console_unlock (); +return 0 ; }
drivers/tty/vt/vt.c +5 -8
@@ -3162,10 +3162,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)case TIOCL_SELLOADLUT :if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -console_lock (); - ret =sel_loadlut (param_aligned32); -console_unlock (); -break ; +return sel_loadlut (param_aligned32);case TIOCL_GETSHIFTSTATE :/* * Make it possible to react to Shift+Mousebutton. Note that
@@ -3181,10 +3178,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)console_unlock ();return put_user (data, p);case TIOCL_SETVESABLANK : -console_lock (); - ret =set_vesa_blanking (param); -console_unlock (); -break ; +return set_vesa_blanking (param);case TIOCL_GETKMSGREDIRECT : data =vt_get_kmsg_redirect ();return put_user (data, p);
@@ -4270,7 +4264,10 @@ static int set_vesa_blanking(u8 __user *mode_user)if (get_user (mode, mode_user))return -EFAULT ; +console_lock (); vesa_blank_mode = (mode <4 ) ? mode :0 ; +console_unlock (); +return 0 ; }
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 7/47 tty: vt: pass vc_resize_user as a parameter
In reply to Jiri Slaby (SUSE)It is pretty unfortunate to set vc_data::vc_resize_user in two callers of vc_do_resize(). vc_resize_user is immediately reset there (while remembering it). So instead of this back and forth, pass 'from_user' as a parameter.
Notes on 'int user':
* The name changes from 'user' to 'from_user' on some places to be consistent.
* The type is bool now as 'int user' might evoke user's uid or whatever.
Provided vc_resize() is called on many places and they need not to care about this parameter, its prototype is kept unchanged. Instead, it is now an inline calling a new __vc_resize() which implements the above.
This patch makes the situation much more obvious.
--- drivers/tty/vt/vt.c | 28 +++++++++++++--------------- drivers/tty/vt/vt_ioctl.c | 6 ++---- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 2 +- include/linux/console.h | 2 +- include/linux/console_struct.h | 1 - include/linux/vt_kern.h | 9 ++++++++- 7 files changed, 27 insertions(+), 25 deletions(-)
drivers/tty/vt/vt.c +13 -15
@@ -1115,13 +1115,13 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ }static inline int resize_screen (struct vc_data *vc,int width,int height, -int user) +bool from_user) {/* Resizes the resolution of the display adapater */ int err =0 ;if (vc->vc_sw->con_resize) - err = vc->vc_sw->con_resize (vc, width, height, user); + err = vc->vc_sw->con_resize (vc, width, height, from_user);return err; }
@@ -1132,6 +1132,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,* @vc: virtual console private data * @cols: columns * @lines: lines +* @from_user: invoked by a user? * * Resize a virtual console, clipping according to the actual constraints. * If the caller passes a tty structure then update the termios winsize
@@ -1142,21 +1143,17 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,*/ static int vc_do_resize (struct tty_struct *tty,struct vc_data *vc, -unsigned int cols,unsigned int lines) +unsigned int cols,unsigned int lines,bool from_user) {unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err =0 ;unsigned long end;unsigned int old_rows, old_row_size, first_copied_row;unsigned int new_cols, new_rows, new_row_size, new_screen_size; -unsigned int user;unsigned short *oldscreen, *newscreen;u32 **new_uniscr =NULL ;WARN_CONSOLE_UNLOCKED (); - user = vc->vc_resize_user; - vc->vc_resize_user =0 ; -if (cols >VC_MAXCOL || lines >VC_MAXROW )return -EINVAL ;
@@ -1182,7 +1179,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,* to deal with possible errors from the code below, we call * the resize_screen here as well. */ -return resize_screen (vc, new_cols, new_rows, user); +return resize_screen (vc, new_cols, new_rows, from_user); }if (new_screen_size >KMALLOC_MAX_SIZE || !new_screen_size)
@@ -1205,7 +1202,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, old_rows = vc->vc_rows; old_row_size = vc->vc_size_row; - err =resize_screen (vc, new_cols, new_rows, user); + err =resize_screen (vc, new_cols, new_rows, from_user);if (err) {kfree (newscreen);vc_uniscr_free (new_uniscr);
@@ -1292,22 +1289,23 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, }/** -* vc_resize - resize a VT +* __vc_resize - resize a VT * @vc: virtual console * @cols: columns * @rows: rows +* @from_user: invoked by a user? * * Resize a virtual console as seen from the console end of things. We * use the common vc_do_resize methods to update the structures. The * caller must hold the console sem to protect console internals and * vc->port.tty */ - -int vc_resize (struct vc_data *vc,unsigned int cols,unsigned int rows) +int __vc_resize (struct vc_data *vc,unsigned int cols,unsigned int rows, +bool from_user) { -return vc_do_resize (vc->port.tty, vc, cols, rows); +return vc_do_resize (vc->port.tty, vc, cols, rows, from_user); } -EXPORT_SYMBOL (vc_resize); +EXPORT_SYMBOL (__vc_resize);/** * vt_resize - resize a VT
@@ -1327,7 +1325,7 @@ static int vt_resize(struct tty_struct *tty, struct winsize *ws)int ret;console_lock (); - ret =vc_do_resize (tty, vc, ws->ws_col, ws->ws_row); + ret =vc_do_resize (tty, vc, ws->ws_col, ws->ws_row, false);console_unlock ();return ret; }
drivers/tty/vt/vt_ioctl.c +2 -4
@@ -714,8 +714,7 @@ static int vt_resizex(struct vc_data *vc, struct vt_consize __user *cs) vcp->vc_scan_lines = v.v_vlin;if (v.v_clin) vcp->vc_cell_height = v.v_clin; - vcp->vc_resize_user =1 ; - ret =vc_resize (vcp, v.v_cols, v.v_rows); + ret =__vc_resize (vcp, v.v_cols, v.v_rows, true);if (ret) { vcp->vc_scan_lines = save_scan_lines; vcp->vc_cell_height = save_cell_height;
@@ -923,9 +922,8 @@ int vt_ioctl(struct tty_struct *tty, vc = vc_cons[i].d;if (vc) { - vc->vc_resize_user =1 ;/* FIXME: review v tty lock */ -vc_resize (vc_cons[i].d, cc, ll); +__vc_resize (vc_cons[i].d, cc, ll, true); } }console_unlock ();
drivers/video/console/vgacon.c +2 -2
@@ -1081,12 +1081,12 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font, unsigne }static int vgacon_resize (struct vc_data *c,unsigned int width, -unsigned int height,unsigned int user) +unsigned int height,bool from_user) {if ((width <<1 ) * height > vga_vram_size)return -EINVAL ; -if (user) { +if (from_user) {/* * Ho ho! Someone (svgatextmode, eh?) may have reprogrammed * the video mode! Set the new defaults then and go away.
drivers/video/fbdev/core/fbcon.c +1 -1
@@ -1996,7 +1996,7 @@ static void updatescrollmode(struct fbcon_display *p,#define CALC_FONTSZ (h, p, c) ((h) * (p) * (c))/* size = height * pitch * charcount */ static int fbcon_resize (struct vc_data *vc,unsigned int width, -unsigned int height,unsigned int user) +unsigned int height,bool from_user) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);struct fbcon_ops *ops = info->fbcon_par;
include/linux/console.h +1 -1
@@ -66,7 +66,7 @@ struct consw {int (*con_font_default)(struct vc_data *vc,struct console_font *font,char *name);int (*con_resize)(struct vc_data *vc,unsigned int width, -unsigned int height,unsigned int user); +unsigned int height,bool from_user);void (*con_set_palette)(struct vc_data *vc,const unsigned char *table);void (*con_scrolldelta)(struct vc_data *vc,int lines);
include/linux/console_struct.h +0 -1
@@ -151,7 +151,6 @@ struct vc_data {DECLARE_BITMAP (vc_tab_stop,VC_TABSTOPS_COUNT );/* Tab stops. 256 columns. */ unsigned char vc_palette[16 *3 ];/* Colour palette for VGA+ */ unsigned short * vc_translate; -unsigned int vc_resize_user;/* resize request from user */ unsigned int vc_bell_pitch;/* Console bell pitch */ unsigned int vc_bell_duration;/* Console bell duration */ unsigned short vc_cur_blink_ms;/* Cursor blink duration */
include/linux/vt_kern.h +8 -1
@@ -25,7 +25,8 @@ extern int fg_console, last_console, want_console;int vc_allocate (unsigned int console);int vc_cons_allocated (unsigned int console); -int vc_resize (struct vc_data *vc,unsigned int cols,unsigned int lines); +int __vc_resize (struct vc_data *vc,unsigned int cols,unsigned int lines, +bool from_user);struct vc_data *vc_deallocate (unsigned int console);void reset_palette (struct vc_data *vc);void do_blank_screen (int entering_gfx);
@@ -42,6 +43,12 @@ void redraw_screen(struct vc_data *vc, int is_switch);#define update_screen (x) redraw_screen(x, 0)#define switch_screen (x) redraw_screen(x, 1) +static inline int vc_resize (struct vc_data *vc,unsigned int cols, +unsigned int lines) +{ +return __vc_resize (vc, cols, lines, false); +} +struct tty_struct ;int tioclinux (struct tty_struct *tty,unsigned long arg);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 8/47 tty: vt: make vc_is_sel()'s vc const
In reply to Jiri Slaby (SUSE)It's only an aid to people reading the header and/or calling vc_is_sel(). vc is only tested there, so having it const makes sense.
--- drivers/tty/vt/selection.c | 2 +- include/linux/selection.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/tty/vt/selection.c +1 -1
@@ -88,7 +88,7 @@ void clear_selection(void) }EXPORT_SYMBOL_GPL (clear_selection); -bool vc_is_sel (struct vc_data *vc) +bool vc_is_sel (const struct vc_data *vc) {return vc == vc_sel.cons; }
include/linux/selection.h +1 -1
@@ -24,7 +24,7 @@ extern int sel_loadlut(u32 __user *lut);extern int mouse_reporting (void );extern void mouse_report (struct tty_struct * tty,int butt,int mrx,int mry); -bool vc_is_sel (struct vc_data *vc); +bool vc_is_sel (const struct vc_data *vc);extern int console_blanked;
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 9/47 tty: vt: define an enum for CSI+m codes
In reply to Jiri Slaby (SUSE)It's always confusing to read all those case 0:, case 1: etc. in csi_* handlers. Define enum entries for all those constants in CSI+m and use them in csi_m().
--- drivers/tty/vt/vt.c | 98 +++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 29 deletions(-)
drivers/tty/vt/vt.c +69 -29
@@ -1676,6 +1676,39 @@ static int vc_t416_color(struct vc_data *vc, int i,return i; } +enum { + CSI_m_DEFAULT =0 , + CSI_m_BOLD =1 , + CSI_m_HALF_BRIGHT =2 , + CSI_m_ITALIC =3 , + CSI_m_UNDERLINE =4 , + CSI_m_BLINK =5 , + CSI_m_REVERSE =7 , + CSI_m_PRI_FONT =10 , + CSI_m_ALT_FONT1 =11 , + CSI_m_ALT_FONT2 =12 , + CSI_m_DOUBLE_UNDERLINE =21 , + CSI_m_NORMAL_INTENSITY =22 , + CSI_m_NO_ITALIC =23 , + CSI_m_NO_UNDERLINE =24 , + CSI_m_NO_BLINK =25 , + CSI_m_NO_REVERSE =27 , + CSI_m_FG_COLOR_BEG =30 , + CSI_m_FG_COLOR_END =37 , + CSI_m_FG_COLOR =38 , + CSI_m_DEFAULT_FG_COLOR =39 , + CSI_m_BG_COLOR_BEG =40 , + CSI_m_BG_COLOR_END =47 , + CSI_m_BG_COLOR =48 , + CSI_m_DEFAULT_BG_COLOR =49 , + CSI_m_BRIGHT_FG_COLOR_BEG =90 , + CSI_m_BRIGHT_FG_COLOR_END =97 , + CSI_m_BRIGHT_FG_COLOR_OFF = CSI_m_BRIGHT_FG_COLOR_BEG - CSI_m_FG_COLOR_BEG, + CSI_m_BRIGHT_BG_COLOR_BEG =100 , + CSI_m_BRIGHT_BG_COLOR_END =107 , + CSI_m_BRIGHT_BG_COLOR_OFF = CSI_m_BRIGHT_BG_COLOR_BEG - CSI_m_BG_COLOR_BEG, +}; +/* console_lock is held */ static void csi_m (struct vc_data *vc) {
@@ -1683,33 +1716,33 @@ 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 */ +case CSI_m_DEFAULT:/* all attributes off */ default_attr (vc);break ; -case 1 : +case CSI_m_BOLD: vc->state.intensity =VCI_BOLD ;break ; -case 2 : +case CSI_m_HALF_BRIGHT: vc->state.intensity =VCI_HALF_BRIGHT ;break ; -case 3 : +case CSI_m_ITALIC: vc->state.italic = true;break ; -case 21 : +case CSI_m_DOUBLE_UNDERLINE:/* * No console drivers support double underline, so * convert it to a single underline. */ -case 4 : +case CSI_m_UNDERLINE: vc->state.underline = true;break ; -case 5 : +case CSI_m_BLINK: vc->state.blink = true;break ; -case 7 : +case CSI_m_REVERSE: vc->state.reverse = true;break ; -case 10 :/* ANSI X3.64-1979 (SCO-ish?) +case CSI_m_PRI_FONT:/* ANSI X3.64-1979 (SCO-ish?) * Select primary font, don't display control chars if * defined, don't set bit 8 on output. */
@@ -1717,7 +1750,7 @@ static void csi_m(struct vc_data *vc) vc->vc_disp_ctrl =0 ; vc->vc_toggle_meta =0 ;break ; -case 11 :/* ANSI X3.64-1979 (SCO-ish?) +case CSI_m_ALT_FONT1:/* ANSI X3.64-1979 (SCO-ish?) * Select first alternate font, lets chars < 32 be * displayed as ROM chars. */
@@ -1725,7 +1758,7 @@ static void csi_m(struct vc_data *vc) vc->vc_disp_ctrl =1 ; vc->vc_toggle_meta =0 ;break ; -case 12 :/* ANSI X3.64-1979 (SCO-ish?) +case CSI_m_ALT_FONT2:/* ANSI X3.64-1979 (SCO-ish?) * Select second alternate font, toggle high bit * before displaying as ROM char. */
@@ -1733,47 +1766,54 @@ static void csi_m(struct vc_data *vc) vc->vc_disp_ctrl =1 ; vc->vc_toggle_meta =1 ;break ; -case 22 : +case CSI_m_NORMAL_INTENSITY: vc->state.intensity =VCI_NORMAL ;break ; -case 23 : +case CSI_m_NO_ITALIC: vc->state.italic = false;break ; -case 24 : +case CSI_m_NO_UNDERLINE: vc->state.underline = false;break ; -case 25 : +case CSI_m_NO_BLINK: vc->state.blink = false;break ; -case 27 : +case CSI_m_NO_REVERSE: vc->state.reverse = false;break ; -case 38 : +case CSI_m_FG_COLOR: i =vc_t416_color (vc, i, rgb_foreground);break ; -case 48 : +case CSI_m_BG_COLOR: i =vc_t416_color (vc, i, rgb_background);break ; -case 39 : +case CSI_m_DEFAULT_FG_COLOR: vc->state.color = (vc->vc_def_color &0x0f ) | (vc->state.color &0xf0 );break ; -case 49 : +case CSI_m_DEFAULT_BG_COLOR: vc->state.color = (vc->vc_def_color &0xf0 ) | (vc->state.color &0x0f );break ;default : -if (vc->vc_par[i] >=90 && vc->vc_par[i] <=107 ) { -if (vc->vc_par[i] <100 ) +if (vc->vc_par[i] >= CSI_m_BRIGHT_FG_COLOR_BEG && + vc->vc_par[i] <= CSI_m_BRIGHT_BG_COLOR_END) { +if (vc->vc_par[i] < CSI_m_BRIGHT_BG_COLOR_BEG) vc->state.intensity =VCI_BOLD ; - vc->vc_par[i] -=60 ; + vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; } -if (vc->vc_par[i] >=30 && vc->vc_par[i] <=37 ) - vc->state.color = color_table[vc->vc_par[i] -30 ] - | (vc->state.color &0xf0 ); -else if (vc->vc_par[i] >=40 && vc->vc_par[i] <=47 ) - vc->state.color = (color_table[vc->vc_par[i] -40 ] <<4 ) - | (vc->state.color &0x0f ); +if (vc->vc_par[i] >= CSI_m_FG_COLOR_BEG && + vc->vc_par[i] <= CSI_m_FG_COLOR_END) { + vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; + vc->state.color = color_table[vc->vc_par[i]] | + (vc->state.color &0xf0 ); + }else if (vc->vc_par[i] >= CSI_m_BG_COLOR_BEG && + vc->vc_par[i] <= CSI_m_BG_COLOR_END) { + vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; + vc->state.color = (color_table[vc->vc_par[i]] <<4 ) | + (vc->state.color &0x0f ); + } +break ; }update_attr (vc);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 10/47 tty: vt: use case ranges for CSI+m fg/bg colors
In reply to Jiri Slaby (SUSE)Replacing the default case with the iffery by case ranges makes the code more understandable at last.
--- drivers/tty/vt/vt.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-)
drivers/tty/vt/vt.c +16 -19
@@ -1795,25 +1795,22 @@ static void csi_m(struct vc_data *vc) vc->state.color = (vc->vc_def_color &0xf0 ) | (vc->state.color &0x0f );break ; -default : -if (vc->vc_par[i] >= CSI_m_BRIGHT_FG_COLOR_BEG && - vc->vc_par[i] <= CSI_m_BRIGHT_BG_COLOR_END) { -if (vc->vc_par[i] < CSI_m_BRIGHT_BG_COLOR_BEG) - vc->state.intensity =VCI_BOLD ; - vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; - } -if (vc->vc_par[i] >= CSI_m_FG_COLOR_BEG && - vc->vc_par[i] <= CSI_m_FG_COLOR_END) { - vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; - vc->state.color = color_table[vc->vc_par[i]] | - (vc->state.color &0xf0 ); - }else if (vc->vc_par[i] >= CSI_m_BG_COLOR_BEG && - vc->vc_par[i] <= CSI_m_BG_COLOR_END) { - vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; - vc->state.color = (color_table[vc->vc_par[i]] <<4 ) | - (vc->state.color &0x0f ); - } - + case CSI_m_BRIGHT_FG_COLOR_BEG ... CSI_m_BRIGHT_FG_COLOR_END: + vc->state.intensity =VCI_BOLD ; + vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; + fallthrough; + case CSI_m_FG_COLOR_BEG ... CSI_m_FG_COLOR_END: + vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; + vc->state.color = color_table[vc->vc_par[i]] | + (vc->state.color &0xf0 ); +break ; + case CSI_m_BRIGHT_BG_COLOR_BEG ... CSI_m_BRIGHT_BG_COLOR_END: + vc->vc_par[i] -= CSI_m_BRIGHT_BG_COLOR_OFF; + fallthrough; + case CSI_m_BG_COLOR_BEG ... CSI_m_BG_COLOR_END: + vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; + vc->state.color = (color_table[vc->vc_par[i]] <<4 ) | + (vc->state.color &0x0f );break ; }update_attr (vc);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 11/47 tty: vt: define an enum for CSI+J codes
In reply to Jiri Slaby (SUSE)Decrypt the constant values by proper enum names. This time in csi_J().
---
Notes:
[v2] use the new names also in csi_J() callers and the enum as the param
type
drivers/tty/vt/vt.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/tty/vt/vt.c +15 -8
@@ -1498,13 +1498,20 @@ static inline void del(struct vc_data *vc)/* ignored */ } -static void csi_J (struct vc_data *vc,int vpar) +enum CSI_J { +CSI_J_CURSOR_TO_END =0 , +CSI_J_START_TO_CURSOR =1 , +CSI_J_VISIBLE =2 , +CSI_J_FULL =3 , +}; + +static void csi_J (struct vc_data *vc,enum CSI_J vpar) {unsigned int count;unsigned short * start;switch (vpar) { -case 0 :/* erase from cursor to end of display */ +case CSI_J_CURSOR_TO_END :vc_uniscr_clear_line (vc, vc->state.x, vc->vc_cols - vc->state.x); vc_uniscr_clear_lines(vc, vc->state.y + 1,
@@ -1512,16 +1519,16 @@ static void csi_J(struct vc_data *vc, int vpar) count = (vc->vc_scr_end - vc->vc_pos) >>1 ; start = (unsigned short *)vc->vc_pos;break ; -case 1 :/* erase from start to cursor */ +case CSI_J_START_TO_CURSOR :vc_uniscr_clear_line (vc,0 , vc->state.x +1 );vc_uniscr_clear_lines (vc,0 , vc->state.y); count = ((vc->vc_pos - vc->vc_origin) >>1 ) +1 ; start = (unsigned short *)vc->vc_origin;break ; -case 3 :/* include scrollback */ +case CSI_J_FULL :flush_scrollback (vc); fallthrough; -case 2 :/* erase whole display */ +case CSI_J_VISIBLE :vc_uniscr_clear_lines (vc,0 , vc->vc_rows); count = vc->vc_cols * vc->vc_rows; start = (unsigned short *)vc->vc_origin;
@@ -2110,7 +2117,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)gotoxy (vc,0 ,0 );save_cur (vc);if (do_clear) -csi_J (vc,2 ); +csi_J (vc,CSI_J_VISIBLE ); }static void vc_setGx (struct vc_data *vc,unsigned int which,int c)
@@ -2526,7 +2533,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)/* DEC screen alignment test. kludge :-) */ vc->vc_video_erase_char = (vc->vc_video_erase_char &0xff00 ) |'E' ; -csi_J (vc,2 ); +csi_J (vc,CSI_J_VISIBLE ); vc->vc_video_erase_char = (vc->vc_video_erase_char &0xff00 ) |' ' ;do_update_region (vc, vc->vc_origin, vc->vc_screenbuf_size /2 );
@@ -3498,7 +3505,7 @@ static int __init con_init(void)set_origin (vc);save_screen (vc);gotoxy (vc, vc->state.x, vc->state.y); -csi_J (vc,0 ); +csi_J (vc,CSI_J_CURSOR_TO_END );update_screen (vc); pr_info("Console: %s %s %dx%d\n", vc->vc_can_do_color ? "colour" : "mono",
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 12/47 tty: vt: reflow csi_J()
In reply to Jiri Slaby (SUSE)Push cases one level left, according to coding style. And reorder local variables.
--- drivers/tty/vt/vt.c | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-)
drivers/tty/vt/vt.c +25 -25
@@ -1507,34 +1507,34 @@ enum CSI_J {static void csi_J (struct vc_data *vc,enum CSI_J vpar) { +unsigned short *start;unsigned int count; -unsigned short * start;switch (vpar) { -case CSI_J_CURSOR_TO_END : -vc_uniscr_clear_line (vc, vc->state.x, - vc->vc_cols - vc->state.x); -vc_uniscr_clear_lines (vc, vc->state.y +1 , - vc->vc_rows - vc->state.y -1 ); - count = (vc->vc_scr_end - vc->vc_pos) >>1 ; - start = (unsigned short *)vc->vc_pos; -break ; -case CSI_J_START_TO_CURSOR : -vc_uniscr_clear_line (vc,0 , vc->state.x +1 ); -vc_uniscr_clear_lines (vc,0 , vc->state.y); - count = ((vc->vc_pos - vc->vc_origin) >>1 ) +1 ; - start = (unsigned short *)vc->vc_origin; -break ; -case CSI_J_FULL : -flush_scrollback (vc); - fallthrough; -case CSI_J_VISIBLE : -vc_uniscr_clear_lines (vc,0 , vc->vc_rows); - count = vc->vc_cols * vc->vc_rows; - start = (unsigned short *)vc->vc_origin; -break ; -default : -return ; +case CSI_J_CURSOR_TO_END : +vc_uniscr_clear_line (vc, vc->state.x, + vc->vc_cols - vc->state.x); +vc_uniscr_clear_lines (vc, vc->state.y +1 , + vc->vc_rows - vc->state.y -1 ); + count = (vc->vc_scr_end - vc->vc_pos) >>1 ; + start = (unsigned short *)vc->vc_pos; +break ; +case CSI_J_START_TO_CURSOR : +vc_uniscr_clear_line (vc,0 , vc->state.x +1 ); +vc_uniscr_clear_lines (vc,0 , vc->state.y); + count = ((vc->vc_pos - vc->vc_origin) >>1 ) +1 ; + start = (unsigned short *)vc->vc_origin; +break ; +case CSI_J_FULL : +flush_scrollback (vc); + fallthrough; +case CSI_J_VISIBLE : +vc_uniscr_clear_lines (vc,0 , vc->vc_rows); + count = vc->vc_cols * vc->vc_rows; + start = (unsigned short *)vc->vc_origin; +break ; +default : +return ; }scr_memsetw (start, vc->vc_video_erase_char,2 * count);if (con_should_update (vc))
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 13/47 use clamp() for counts in csi_?() handlers
In reply to Jiri Slaby (SUSE)The count to process is supposed to be between 1 and vc->vc_cols - vc->state.x (or rows and .y). clamp() can be used exactly for this, instead of ifs and min().
---
Notes:
[v2] new in v2.
drivers/tty/vt/vt.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
drivers/tty/vt/vt.c +5 -22
@@ -1574,12 +1574,7 @@ static void csi_K(struct vc_data *vc, int vpar)/* erase the following vpar positions */ static void csi_X (struct vc_data *vc,unsigned int vpar) {/* not vt100? */ -unsigned int count; - -if (!vpar) - vpar++; - - count =min (vpar, vc->vc_cols - vc->state.x); +unsigned int count =clamp (vpar,1 , vc->vc_cols - vc->state.x);vc_uniscr_clear_line (vc, vc->state.x, count);scr_memsetw ((unsigned short *)vc->vc_pos, vc->vc_video_erase_char,2 * count);
@@ -2010,20 +2005,14 @@ static void setterm_command(struct vc_data *vc)/* console_lock is held */ static void csi_at (struct vc_data *vc,unsigned int nr) { -if (nr > vc->vc_cols - vc->state.x) - nr = vc->vc_cols - vc->state.x; -else if (!nr) - nr =1 ; + nr =clamp (nr,1 , vc->vc_cols - vc->state.x);insert_char (vc, nr); }/* console_lock is held */ static void csi_L (struct vc_data *vc,unsigned int nr) { -if (nr > vc->vc_rows - vc->state.y) - nr = vc->vc_rows - vc->state.y; -else if (!nr) - nr =1 ; + nr =clamp (nr,1 , vc->vc_rows - vc->state.y);con_scroll (vc, vc->state.y, vc->vc_bottom,SM_DOWN , nr); vc->vc_need_wrap =0 ; }
@@ -2031,20 +2020,14 @@ static void csi_L(struct vc_data *vc, unsigned int nr)/* console_lock is held */ static void csi_P (struct vc_data *vc,unsigned int nr) { -if (nr > vc->vc_cols - vc->state.x) - nr = vc->vc_cols - vc->state.x; -else if (!nr) - nr =1 ; + nr =clamp (nr,1 , vc->vc_cols - vc->state.x);delete_char (vc, nr); }/* console_lock is held */ static void csi_M (struct vc_data *vc,unsigned int nr) { -if (nr > vc->vc_rows - vc->state.y) - nr = vc->vc_rows - vc->state.y; -else if (!nr) - nr=1 ; + nr =clamp (nr,1 , vc->vc_rows - vc->state.y);con_scroll (vc, vc->state.y, vc->vc_bottom,SM_UP , nr); vc->vc_need_wrap =0 ; }
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 14/47 don't pass vc->vc_par[0] to csi_?() handlers
In reply to Jiri Slaby (SUSE)Fetch the value directly in the helpers instead.
---
Notes:
[v2] new in v2.
drivers/tty/vt/vt.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/tty/vt/vt.c +19 -16
@@ -1542,13 +1542,13 @@ static void csi_J(struct vc_data *vc, enum CSI_J vpar) vc->vc_need_wrap =0 ; } -static void csi_K (struct vc_data *vc,int vpar) +static void csi_K (struct vc_data *vc) {unsigned int count;unsigned short *start = (unsigned short *)vc->vc_pos;int offset; -switch (vpar) { +switch (vc->vc_par[0 ]) {case 0 :/* erase from cursor to end of line */ offset =0 ; count = vc->vc_cols - vc->state.x;
@@ -1571,10 +1571,10 @@ static void csi_K(struct vc_data *vc, int vpar)do_update_region (vc, (unsigned long )(start + offset), count); } -/* erase the following vpar positions */ -static void csi_X (struct vc_data *vc,unsigned int vpar) +/* erase the following count positions */ +static void csi_X (struct vc_data *vc) {/* not vt100? */ -unsigned int count =clamp (vpar,1 , vc->vc_cols - vc->state.x); +unsigned int count =clamp (vc->vc_par[0 ],1 , vc->vc_cols - vc->state.x);vc_uniscr_clear_line (vc, vc->state.x, count);scr_memsetw ((unsigned short *)vc->vc_pos, vc->vc_video_erase_char,2 * count);
@@ -2010,24 +2010,27 @@ static void csi_at(struct vc_data *vc, unsigned int nr) }/* console_lock is held */ -static void csi_L (struct vc_data *vc,unsigned int nr) +static void csi_L (struct vc_data *vc) { - nr =clamp (nr,1 , vc->vc_rows - vc->state.y); +unsigned int nr =clamp (vc->vc_par[0 ],1 , vc->vc_rows - vc->state.y); +con_scroll (vc, vc->state.y, vc->vc_bottom,SM_DOWN , nr); vc->vc_need_wrap =0 ; }/* console_lock is held */ -static void csi_P (struct vc_data *vc,unsigned int nr) +static void csi_P (struct vc_data *vc) { - nr =clamp (nr,1 , vc->vc_cols - vc->state.x); +unsigned int nr =clamp (vc->vc_par[0 ],1 , vc->vc_cols - vc->state.x); +delete_char (vc, nr); }/* console_lock is held */ -static void csi_M (struct vc_data *vc,unsigned int nr) +static void csi_M (struct vc_data *vc) { - nr =clamp (nr,1 , vc->vc_rows - vc->state.y); +unsigned int nr =clamp (vc->vc_par[0 ],1 , vc->vc_rows - vc->state.y); +con_scroll (vc, vc->state.y, vc->vc_bottom,SM_UP , nr); vc->vc_need_wrap =0 ; }
@@ -2430,16 +2433,16 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)csi_J (vc, vc->vc_par[0 ]);return ;case 'K' : -csi_K (vc, vc->vc_par[0 ]); +csi_K (vc);return ;case 'L' : -csi_L (vc, vc->vc_par[0 ]); +csi_L (vc);return ;case 'M' : -csi_M (vc, vc->vc_par[0 ]); +csi_M (vc);return ;case 'P' : -csi_P (vc, vc->vc_par[0 ]); +csi_P (vc);return ;case 'c' :if (!vc->vc_par[0 ])
@@ -2480,7 +2483,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)restore_cur (vc);return ;case 'X' : -csi_X (vc, vc->vc_par[0 ]); +csi_X (vc);return ;case '@' :csi_at (vc, vc->vc_par[0 ]);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 15/47 tty: vt: define an enum for CSI+K codes
In reply to Jiri Slaby (SUSE)Decrypt the constant values by proper enum names. This time in csi_K().
--- drivers/tty/vt/vt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/tty/vt/vt.c +9 -3
@@ -1542,6 +1542,12 @@ static void csi_J(struct vc_data *vc, enum CSI_J vpar) vc->vc_need_wrap =0 ; } +enum { +CSI_K_CURSOR_TO_LINEEND =0 , +CSI_K_LINESTART_TO_CURSOR =1 , +CSI_K_LINE =2 , +}; +static void csi_K (struct vc_data *vc) {unsigned int count;
@@ -1549,15 +1555,15 @@ static void csi_K(struct vc_data *vc)int offset;switch (vc->vc_par[0 ]) { -case 0 :/* erase from cursor to end of line */ +case CSI_K_CURSOR_TO_LINEEND : offset =0 ; count = vc->vc_cols - vc->state.x;break ; -case 1 :/* erase from start of line to cursor */ +case CSI_K_LINESTART_TO_CURSOR : offset = -vc->state.x; count = vc->state.x +1 ;break ; -case 2 :/* erase whole line */ +case CSI_K_LINE : offset = -vc->state.x; count = vc->vc_cols;break ;
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 16/47 tty: vt: reflow csi_K()
In reply to Jiri Slaby (SUSE)Push cases one level left, according to coding style.
--- drivers/tty/vt/vt.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/tty/vt/vt.c +14 -14
@@ -1555,20 +1555,20 @@ static void csi_K(struct vc_data *vc)int offset;switch (vc->vc_par[0 ]) { -case CSI_K_CURSOR_TO_LINEEND : - offset =0 ; - count = vc->vc_cols - vc->state.x; -break ; -case CSI_K_LINESTART_TO_CURSOR : - offset = -vc->state.x; - count = vc->state.x +1 ; -break ; -case CSI_K_LINE : - offset = -vc->state.x; - count = vc->vc_cols; -break ; -default : -return ; +case CSI_K_CURSOR_TO_LINEEND : + offset =0 ; + count = vc->vc_cols - vc->state.x; +break ; +case CSI_K_LINESTART_TO_CURSOR : + offset = -vc->state.x; + count = vc->state.x +1 ; +break ; +case CSI_K_LINE : + offset = -vc->state.x; + count = vc->vc_cols; +break ; +default : +return ; }vc_uniscr_clear_line (vc, vc->state.x + offset, count);scr_memsetw (start + offset, vc->vc_video_erase_char,2 * count);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 17/47 tty: vt: define an enum for ascii characters
In reply to Jiri Slaby (SUSE)I didn't find definitions for ascii in the kernel yet, so define it for non-printable characters used here.
Note we use ' ' instead of 32 on one line too.
--- drivers/tty/vt/vt.c | 62 ++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 18 deletions(-)
drivers/tty/vt/vt.c +44 -18
@@ -2143,6 +2143,28 @@ static bool ansi_control_string(unsigned int state)return false; } +enum { +ASCII_NULL =0 , +ASCII_BELL =7 , +ASCII_BACKSPACE =8 , +ASCII_IGNORE_FIRST =ASCII_BACKSPACE , +ASCII_HTAB =9 , +ASCII_LINEFEED =10 , +ASCII_VTAB =11 , +ASCII_FORMFEED =12 , +ASCII_CAR_RET =13 , +ASCII_IGNORE_LAST =ASCII_CAR_RET , +ASCII_SHIFTOUT =14 , +ASCII_SHIFTIN =15 , +ASCII_CANCEL =24 , +ASCII_SUBSTITUTE =26 , +ASCII_ESCAPE =27 , +ASCII_CSI_IGNORE_FIRST =' ' ,/* 0x2x, 0x3a and 0x3c - 0x3f */ +ASCII_CSI_IGNORE_LAST ='?' , +ASCII_DEL =127 , +ASCII_EXT_CSI =128 +ASCII_ESCAPE , +}; +/* console_lock is held */ static void do_con_trol (struct tty_struct *tty,struct vc_data *vc,int c) {
@@ -2150,21 +2172,22 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)* Control characters can be used in the _middle_ * of an escape sequence, aside from ANSI control strings. */ -if (ansi_control_string (vc->vc_state) && c >=8 && c <=13 ) +if (ansi_control_string (vc->vc_state) && c >=ASCII_IGNORE_FIRST && + c <=ASCII_IGNORE_LAST )return ;switch (c) { -case 0 : +case ASCII_NULL :return ; -case 7 : +case ASCII_BELL :if (ansi_control_string (vc->vc_state)) vc->vc_state = ESnormal;else if (vc->vc_bell_duration)kd_mksound (vc->vc_bell_pitch, vc->vc_bell_duration);return ; -case 8 : +case ASCII_BACKSPACE :bs (vc);return ; -case 9 : +case ASCII_HTAB : vc->vc_pos -= (vc->state.x <<1 ); vc->state.x = find_next_bit(vc->vc_tab_stop,
@@ -2176,34 +2199,37 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_pos += (vc->state.x <<1 );notify_write (vc,'\t' );return ; -case 10 :case 11 :case 12 : +case ASCII_LINEFEED : +case ASCII_VTAB : +case ASCII_FORMFEED :lf (vc);if (!is_kbd (vc, lnm))return ; fallthrough; -case 13 : +case ASCII_CAR_RET :cr (vc);return ; -case 14 : +case ASCII_SHIFTOUT : vc->state.charset =1 ; vc->vc_translate =set_translate (vc->state.Gx_charset[1 ], vc); vc->vc_disp_ctrl =1 ;return ; -case 15 : +case ASCII_SHIFTIN : vc->state.charset =0 ; vc->vc_translate =set_translate (vc->state.Gx_charset[0 ], vc); vc->vc_disp_ctrl =0 ;return ; -case 24 :case 26 : +case ASCII_CANCEL : +case ASCII_SUBSTITUTE : vc->vc_state = ESnormal;return ; -case 27 : +case ASCII_ESCAPE : vc->vc_state = ESesc;return ; -case 127 : +case ASCII_DEL :del (vc);return ; -case 128 +27 : +case ASCII_EXT_CSI : vc->vc_state = ESsquare;return ; }
@@ -2338,7 +2364,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_par[vc->vc_npar] += c -'0' ;return ; } -if (c >=0x20 && c <=0x3f ) {/* 0x2x, 0x3a and 0x3c - 0x3f */ +if (c >=ASCII_CSI_IGNORE_FIRST && c <=ASCII_CSI_IGNORE_LAST ) { vc->vc_state = EScsiignore;return ; }
@@ -2500,7 +2526,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) }return ;case EScsiignore: -if (c >=0x20 && c <=0x3f ) +if (c >=ASCII_CSI_IGNORE_FIRST && c <=ASCII_CSI_IGNORE_LAST )return ; vc->vc_state = ESnormal;return ;
@@ -2761,17 +2787,17 @@ static bool vc_is_control(struct vc_data *vc, int tc, int c)* useless without them; to display an arbitrary font position use the * direct-to-font zone in UTF-8 mode. */ -if (c <32 ) { +if (c <' ' ) {if (vc->vc_disp_ctrl)return CTRL_ALWAYS &BIT (c);else return vc->vc_utf || (CTRL_ACTION &BIT (c)); } -if (c ==127 && !vc->vc_disp_ctrl) +if (c ==ASCII_DEL && !vc->vc_disp_ctrl)return true; -if (c ==128 +27 ) +if (c ==ASCII_EXT_CSI )return true;return false;
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 18/47 tty: vt: remove extern from functions in selection.h
In reply to Jiri Slaby (SUSE)Remove unneeded 'extern' keyword from function prototypes in selection.h. This makes it more readable as no more wrapping is needed on many places.
--- include/linux/selection.h | 52 ++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 28 deletions(-)
include/linux/selection.h +24 -28
@@ -14,15 +14,14 @@struct tty_struct ;struct vc_data ; -extern void clear_selection (void ); -extern int set_selection_user (const struct tiocl_selection __user *sel, -struct tty_struct *tty); -extern int set_selection_kernel (struct tiocl_selection *v, -struct tty_struct *tty); -extern int paste_selection (struct tty_struct *tty); -extern int sel_loadlut (u32 __user *lut); -extern int mouse_reporting (void ); -extern void mouse_report (struct tty_struct * tty,int butt,int mrx,int mry); +void clear_selection (void ); +int set_selection_user (const struct tiocl_selection __user *sel, +struct tty_struct *tty); +int set_selection_kernel (struct tiocl_selection *v,struct tty_struct *tty); +int paste_selection (struct tty_struct *tty); +int sel_loadlut (u32 __user *lut); +int mouse_reporting (void ); +void mouse_report (struct tty_struct *tty,int butt,int mrx,int mry);bool vc_is_sel (const struct vc_data *vc);
@@ -33,24 +32,21 @@ extern unsigned char default_red[];extern unsigned char default_grn[];extern unsigned char default_blu[]; -extern unsigned short *screen_pos (const struct vc_data *vc,int w_offset, -bool viewed); -extern u16 screen_glyph (const struct vc_data *vc,int offset); -extern u32 screen_glyph_unicode (const struct vc_data *vc,int offset); -extern void complement_pos (struct vc_data *vc,int offset); -extern void invert_screen (struct vc_data *vc,int offset,int count,bool viewed); - -extern void getconsxy (const struct vc_data *vc,unsigned char xy[static 2 ]); -extern void putconsxy (struct vc_data *vc,unsigned char xy[static const 2 ]); - -extern u16 vcs_scr_readw (const struct vc_data *vc,const u16 *org); -extern void vcs_scr_writew (struct vc_data *vc,u16 val,u16 *org); -extern void vcs_scr_updated (struct vc_data *vc); - -extern int vc_uniscr_check (struct vc_data *vc); -extern void vc_uniscr_copy_line (const struct vc_data *vc,void *dest, -bool viewed, -unsigned int row,unsigned int col, -unsigned int nr); +unsigned short *screen_pos (const struct vc_data *vc,int w_offset,bool viewed); +u16 screen_glyph (const struct vc_data *vc,int offset); +u32 screen_glyph_unicode (const struct vc_data *vc,int offset); +void complement_pos (struct vc_data *vc,int offset); +void invert_screen (struct vc_data *vc,int offset,int count,bool viewed); + +void getconsxy (const struct vc_data *vc,unsigned char xy[static 2 ]); +void putconsxy (struct vc_data *vc,unsigned char xy[static const 2 ]); + +u16 vcs_scr_readw (const struct vc_data *vc,const u16 *org); +void vcs_scr_writew (struct vc_data *vc,u16 val,u16 *org); +void vcs_scr_updated (struct vc_data *vc); + +int vc_uniscr_check (struct vc_data *vc); +void vc_uniscr_copy_line (const struct vc_data *vc,void *dest,bool viewed, +unsigned int row,unsigned int col,unsigned int nr);#endif
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 19/47 tty: vt: make consw::con_debug_*() return void
In reply to Jiri Slaby (SUSE)The return value of con_debug_enter() and con_debug_leave() is ignored on many fronts. So just don't propagate errors (the current implementations return 0 anyway) and make the return type a void.
--- drivers/tty/vt/vt.c | 21 ++++----------------- drivers/video/fbdev/core/fbcon.c | 6 ++---- include/linux/console.h | 18 ++++++------------ 3 files changed, 12 insertions(+), 33 deletions(-)
drivers/tty/vt/vt.c +4 -17
@@ -4012,15 +4012,9 @@ EXPORT_SYMBOL(con_is_visible);* Called when the console is taken over by the kernel debugger, this * function needs to save the current console state, then put the console * into a state suitable for the kernel debugger. -* -* RETURNS: -* Zero on success, nonzero if a failure occurred when trying to prepare -* the console for the debugger. */ -int con_debug_enter (struct vc_data *vc) +void con_debug_enter (struct vc_data *vc) { -int ret =0 ; - saved_fg_console = fg_console; saved_last_console = last_console; saved_want_console = want_console;
@@ -4029,7 +4023,7 @@ int con_debug_enter(struct vc_data *vc) vc->vc_mode =KD_TEXT ; console_blanked =0 ;if (vc->vc_sw->con_debug_enter) - ret = vc->vc_sw->con_debug_enter (vc); + vc->vc_sw->con_debug_enter (vc);#ifdef CONFIG_KGDB_KDB /* Set the initial LINES variable if it is not already set */ if (vc->vc_rows <999 ) {
@@ -4059,7 +4053,6 @@ int con_debug_enter(struct vc_data *vc) } }#endif /* CONFIG_KGDB_KDB */ -return ret; }EXPORT_SYMBOL_GPL (con_debug_enter);
@@ -4068,15 +4061,10 @@ EXPORT_SYMBOL_GPL(con_debug_enter);* * Restore the console state to what it was before the kernel debugger * was invoked. -* -* RETURNS: -* Zero on success, nonzero if a failure occurred when trying to restore -* the console. */ -int con_debug_leave (void ) +void con_debug_leave (void ) {struct vc_data *vc; -int ret =0 ; fg_console = saved_fg_console; last_console = saved_last_console;
@@ -4086,8 +4074,7 @@ int con_debug_leave(void) vc = vc_cons[fg_console].d;if (vc->vc_sw->con_debug_leave) - ret = vc->vc_sw->con_debug_leave (vc); -return ret; + vc->vc_sw->con_debug_leave (vc); }EXPORT_SYMBOL_GPL (con_debug_leave);
drivers/video/fbdev/core/fbcon.c +2 -4
@@ -2243,7 +2243,7 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)return 0 ; } -static int fbcon_debug_enter (struct vc_data *vc) +static void fbcon_debug_enter (struct vc_data *vc) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);struct fbcon_ops *ops = info->fbcon_par;
@@ -2253,10 +2253,9 @@ static int fbcon_debug_enter(struct vc_data *vc)if (info->fbops->fb_debug_enter) info->fbops->fb_debug_enter (info);fbcon_set_palette (vc, color_table); -return 0 ; } -static int fbcon_debug_leave (struct vc_data *vc) +static void fbcon_debug_leave (struct vc_data *vc) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);struct fbcon_ops *ops = info->fbcon_par;
@@ -2264,7 +2263,6 @@ static int fbcon_debug_leave(struct vc_data *vc) ops->graphics = ops->save_graphics;if (info->fbops->fb_debug_leave) info->fbops->fb_debug_leave (info); -return 0 ; }static int fbcon_get_font (struct vc_data *vc,struct console_font *font,unsigned int vpitch)
include/linux/console.h +6 -12
@@ -88,11 +88,11 @@ struct consw {* limited to, unblanking the console, loading an appropriate * palette, and allowing debugger generated output. */ -int (*con_debug_enter)(struct vc_data *vc); +void (*con_debug_enter)(struct vc_data *vc);/* * Restore the console to its pre-debug state as closely as possible. */ -int (*con_debug_leave)(struct vc_data *vc); +void (*con_debug_leave)(struct vc_data *vc); };extern const struct consw *conswitchp;
@@ -113,17 +113,11 @@ int do_unregister_con_driver(const struct consw *csw);int do_take_over_console (const struct consw *sw,int first,int last,int deflt);void give_up_console (const struct consw *sw);#ifdef CONFIG_HW_CONSOLE -int con_debug_enter (struct vc_data *vc); -int con_debug_leave (void ); +void con_debug_enter (struct vc_data *vc); +void con_debug_leave (void );#else -static inline int con_debug_enter (struct vc_data *vc) -{ -return 0 ; -} -static inline int con_debug_leave (void ) -{ -return 0 ; -} +static inline void con_debug_enter (struct vc_data *vc) { } +static inline void con_debug_leave (void ) { }#endif /* cursor */
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 20/47 tty: vt: make init parameter of consw::con_init() a bool
In reply to Jiri Slaby (SUSE)The 'init' parameter of consw::con_init() is true for the first call of the hook on a particular console. So make the parameter a bool.
And document the hook.
---
Notes:
[v2] fix up the comment (Geert)
drivers/tty/vt/vt.c | 8 ++++---- drivers/video/console/dummycon.c | 2 +- drivers/video/console/mdacon.c | 2 +- drivers/video/console/newport_con.c | 2 +- drivers/video/console/sticon.c | 2 +- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 2 +- include/linux/console.h | 4 +++- 8 files changed, 14 insertions(+), 12 deletions(-)
drivers/tty/vt/vt.c +4 -4
@@ -999,7 +999,7 @@ int vc_cons_allocated(unsigned int i)return (i <MAX_NR_CONSOLES && vc_cons[i].d); } -static void visual_init (struct vc_data *vc,int num,int init) +static void visual_init (struct vc_data *vc,int num,bool init) {/* ++Geert: vc->vc_sw->con_init determines console size */ if (vc->vc_sw)
@@ -1083,7 +1083,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ vc->port.ops = &vc_port_ops;INIT_WORK (&vc_cons[currcons].SAK_work, vc_SAK); -visual_init (vc, currcons,1 ); +visual_init (vc, currcons, true);if (!*vc->uni_pagedict_loc)con_set_default_unimap (vc);
@@ -3513,7 +3513,7 @@ static int __init con_init(void) vc_cons[currcons].d = vc =kzalloc (sizeof (struct vc_data ),GFP_NOWAIT );INIT_WORK (&vc_cons[currcons].SAK_work, vc_SAK);tty_port_init (&vc->port); -visual_init (vc, currcons,1 ); +visual_init (vc, currcons, true);/* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */ vc->vc_screenbuf =kzalloc (vc->vc_screenbuf_size,GFP_NOWAIT );vc_init (vc, currcons || !vc->vc_sw->con_save_screen);
@@ -3682,7 +3682,7 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last, old_was_color = vc->vc_can_do_color; vc->vc_sw->con_deinit (vc); vc->vc_origin = (unsigned long )vc->vc_screenbuf; -visual_init (vc, i,0 ); +visual_init (vc, i, false);set_origin (vc);update_attr (vc);
drivers/video/console/dummycon.c +1 -1
@@ -98,7 +98,7 @@ static const char *dummycon_startup(void)return "dummy device" ; } -static void dummycon_init (struct vc_data *vc,int init) +static void dummycon_init (struct vc_data *vc,bool init) { vc->vc_can_do_color =1 ;if (init) {
drivers/video/console/mdacon.c +1 -1
@@ -352,7 +352,7 @@ static const char *mdacon_startup(void)return "MDA-2" ; } -static void mdacon_init (struct vc_data *c,int init) +static void mdacon_init (struct vc_data *c,bool init) { c->vc_complement_mask =0x0800 ;/* reverse video */ c->vc_display_fg = &mda_display_fg;
drivers/video/console/newport_con.c +1 -1
@@ -324,7 +324,7 @@ static const char *newport_startup(void)return NULL ; } -static void newport_init (struct vc_data *vc,int init) +static void newport_init (struct vc_data *vc,bool init) {int cols, rows;
drivers/video/console/sticon.c +1 -1
@@ -273,7 +273,7 @@ static int sticon_font_set(struct vc_data *vc, struct console_font *font,return sticon_set_font (vc, font, vpitch); } -static void sticon_init (struct vc_data *c,int init) +static void sticon_init (struct vc_data *c,bool init) {struct sti_struct *sti = sticon_sti;int vc_cols, vc_rows;
drivers/video/console/vgacon.c +2 -2
@@ -367,7 +367,7 @@ static const char *vgacon_startup(void)return display_desc; } -static void vgacon_init (struct vc_data *c,int init) +static void vgacon_init (struct vc_data *c,bool init) {struct uni_pagedict *p;
@@ -384,7 +384,7 @@ static void vgacon_init(struct vc_data *c, int init) c->vc_scan_lines = vga_scan_lines; c->vc_font.height = c->vc_cell_height = vga_video_font_height; -/* set dimensions manually if init != 0 since vc_resize() will fail */ +/* set dimensions manually if init is true since vc_resize() will fail */ if (init) { c->vc_cols = vga_video_num_columns; c->vc_rows = vga_video_num_lines;
drivers/video/fbdev/core/fbcon.c +1 -1
@@ -988,7 +988,7 @@ static const char *fbcon_startup(void)return display_desc; } -static void fbcon_init (struct vc_data *vc,int init) +static void fbcon_init (struct vc_data *vc,bool init) {struct fb_info *info;struct fbcon_ops *ops;
include/linux/console.h +3 -1
@@ -36,6 +36,8 @@ enum vc_intensity;/** * struct consw - callbacks for consoles * +* @con_init: initialize the console on @vc. @init is true for the very first +* call on this @vc. * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console.
@@ -46,7 +48,7 @@ enum vc_intensity;struct consw {struct module *owner;const char *(*con_startup)(void ); -void (*con_init)(struct vc_data *vc,int init); +void (*con_init)(struct vc_data *vc,bool init);void (*con_deinit)(struct vc_data *vc);void (*con_clear)(struct vc_data *vc,int sy,int sx,int height,int width);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 21/47 tty: vt: sanitize arguments of consw::con_clear()
In reply to Jiri Slaby (SUSE)In consw::con_clear():
* Height is always 1, so drop it.
* Offsets and width are always unsigned values, so re-type them as such.
This needs a new __fbcon_clear() in the fbcon code to still handle height which might not be 1 when called internally.
Note that tests for negative count/width are left in place -- they are taken care of in the next patches.
And document the hook.
--- drivers/tty/vt/vt.c | 2 +- drivers/video/console/dummycon.c | 4 ++-- drivers/video/console/mdacon.c | 15 +++++--------- drivers/video/console/newport_con.c | 6 +++--- drivers/video/console/sticon.c | 8 ++++---- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 32 +++++++++++++++++------------ include/linux/console.h | 5 +++-- 8 files changed, 39 insertions(+), 37 deletions(-)
drivers/tty/vt/vt.c +1 -1
@@ -1585,7 +1585,7 @@ static void csi_X(struct vc_data *vc)vc_uniscr_clear_line (vc, vc->state.x, count);scr_memsetw ((unsigned short *)vc->vc_pos, vc->vc_video_erase_char,2 * count);if (con_should_update (vc)) - vc->vc_sw->con_clear (vc, vc->state.y, vc->state.x,1 , count); + vc->vc_sw->con_clear (vc, vc->state.y, vc->state.x, count); vc->vc_need_wrap =0 ; }
drivers/video/console/dummycon.c +2 -2
@@ -109,8 +109,8 @@ static void dummycon_init(struct vc_data *vc, bool init) }static void dummycon_deinit (struct vc_data *vc) { } -static void dummycon_clear (struct vc_data *vc,int sy,int sx,int height, -int width) { } +static void dummycon_clear (struct vc_data *vc,unsigned int sy,unsigned int sx, +unsigned int width) { }static void dummycon_cursor (struct vc_data *vc,int mode) { } static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
drivers/video/console/mdacon.c +5 -10
@@ -442,23 +442,18 @@ static void mdacon_putcs(struct vc_data *c, const unsigned short *s, } } -static void mdacon_clear (struct vc_data *c,int y,int x, -int height,int width) +static void mdacon_clear (struct vc_data *c,unsigned int y,unsigned int x, +unsigned int width) {u16 *dest =mda_addr (x, y);u16 eattr =mda_convert_attr (c->vc_video_erase_char); -if (width <=0 || height <=0 ) +if (width <=0 )return ; -if (x==0 && width==mda_num_columns) { -scr_memsetw (dest, eattr, height*width*2 ); - }else { -for (; height >0 ; height--, dest+=mda_num_columns) -scr_memsetw (dest, eattr, width*2 ); - } +scr_memsetw (dest, eattr, width *2 ); } - +static int mdacon_switch (struct vc_data *c) {return 1 ;/* redrawing needed */
drivers/video/console/newport_con.c +3 -3
@@ -346,12 +346,12 @@ static void newport_deinit(struct vc_data *c) } } -static void newport_clear (struct vc_data *vc,int sy,int sx,int height, -int width) +static void newport_clear (struct vc_data *vc,unsigned int sy,unsigned int sx, +unsigned int width) {int xend = ((sx + width) <<3 ) -1 ;int ystart = ((sy <<4 ) + topscan) &0x3ff ; -int yend = (((sy + height) <<4 ) + topscan -1 ) &0x3ff ; +int yend = (((sy +1 ) <<4 ) + topscan -1 ) &0x3ff ;if (logo_active)return ;
drivers/video/console/sticon.c +4 -4
@@ -300,13 +300,13 @@ static void sticon_deinit(struct vc_data *c)sticon_set_def_font (i); } -static void sticon_clear (struct vc_data *conp,int sy,int sx,int height, -int width) +static void sticon_clear (struct vc_data *conp,unsigned int sy,unsigned int sx, +unsigned int width) { -if (!height || !width) +if (!width)return ; -sti_clear (sticon_sti, sy, sx, height, width, +sti_clear (sticon_sti, sy, sx,1 , width, conp->vc_video_erase_char, font_data[conp->vc_num]); }
drivers/video/console/vgacon.c +2 -2
@@ -1191,8 +1191,8 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,* The console `switch' structure for the VGA based console */ -static void vgacon_clear (struct vc_data *vc,int sy,int sx,int height, -int width) { } +static void vgacon_clear (struct vc_data *vc,unsigned int sy,unsigned int sx, +unsigned int width) { }static void vgacon_putc (struct vc_data *vc,int c,int ypos,int xpos) { }static void vgacon_putcs (struct vc_data *vc,const unsigned short *s,int count,int ypos,int xpos) { }
drivers/video/fbdev/core/fbcon.c +19 -13
@@ -1235,8 +1235,8 @@ static void fbcon_deinit(struct vc_data *vc)* restriction is simplicity & efficiency at the moment. */ -static void fbcon_clear (struct vc_data *vc,int sy,int sx,int height, -int width) +static void __fbcon_clear (struct vc_data *vc,unsigned int sy,unsigned int sx, +unsigned int height,unsigned int width) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);struct fbcon_ops *ops = info->fbcon_par;
@@ -1273,6 +1273,12 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, ops->clear (vc, info,real_y (p, sy), sx, height, width); } +static void fbcon_clear (struct vc_data *vc,unsigned int sy,unsigned int sx, +unsigned int width) +{ +__fbcon_clear (vc, sy, sx,1 , width); +} +static void fbcon_putcs (struct vc_data *vc,const unsigned short *s,int count,int ypos,int xpos) {
@@ -1760,7 +1766,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,case SCROLL_MOVE :fbcon_redraw_blit (vc, info, p, t, b - t - count, count); -fbcon_clear (vc, b - count,0 , count, vc->vc_cols); +__fbcon_clear (vc, b - count,0 , count, vc->vc_cols); scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * (b - count)),
@@ -1783,7 +1789,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, b - t - count, vc->vc_cols); else goto redraw_up; -fbcon_clear (vc, b - count,0 , count, vc->vc_cols); +__fbcon_clear (vc, b - count,0 , count, vc->vc_cols);break ;case SCROLL_PAN_REDRAW :
@@ -1801,7 +1807,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, vc->vc_rows - b, b); }else fbcon_redraw_move (vc, p, t + count, b - t - count, t); -fbcon_clear (vc, b - count,0 , count, vc->vc_cols); +__fbcon_clear (vc, b - count,0 , count, vc->vc_cols);break ;case SCROLL_PAN_MOVE :
@@ -1824,14 +1830,14 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, b - t - count, vc->vc_cols); else goto redraw_up; -fbcon_clear (vc, b - count,0 , count, vc->vc_cols); +__fbcon_clear (vc, b - count,0 , count, vc->vc_cols);break ;case SCROLL_REDRAW : redraw_up:fbcon_redraw (vc, t, b - t - count, count * vc->vc_cols); -fbcon_clear (vc, b - count,0 , count, vc->vc_cols); +__fbcon_clear (vc, b - count,0 , count, vc->vc_cols); scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * (b - count)),
@@ -1848,7 +1854,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,case SCROLL_MOVE :fbcon_redraw_blit (vc, info, p, b -1 , b - t - count, -count); -fbcon_clear (vc, t,0 , count, vc->vc_cols); +__fbcon_clear (vc, t,0 , count, vc->vc_cols); scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * t),
@@ -1871,7 +1877,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, b - t - count, vc->vc_cols); else goto redraw_down; -fbcon_clear (vc, t,0 , count, vc->vc_cols); +__fbcon_clear (vc, t,0 , count, vc->vc_cols);break ;case SCROLL_PAN_MOVE :
@@ -1893,7 +1899,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, b - t - count, vc->vc_cols); else goto redraw_down; -fbcon_clear (vc, t,0 , count, vc->vc_cols); +__fbcon_clear (vc, t,0 , count, vc->vc_cols);break ;case SCROLL_PAN_REDRAW :
@@ -1910,14 +1916,14 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,fbcon_redraw_move (vc, p, count, t,0 ); }else fbcon_redraw_move (vc, p, t, b - t - count, t + count); -fbcon_clear (vc, t,0 , count, vc->vc_cols); +__fbcon_clear (vc, t,0 , count, vc->vc_cols);break ;case SCROLL_REDRAW : redraw_down:fbcon_redraw (vc, b -1 , b - t - count, -count * vc->vc_cols); -fbcon_clear (vc, t,0 , count, vc->vc_cols); +__fbcon_clear (vc, t,0 , count, vc->vc_cols); scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * t),
@@ -2196,7 +2202,7 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, oldc = vc->vc_video_erase_char; vc->vc_video_erase_char &= charmask; -fbcon_clear (vc,0 ,0 , vc->vc_rows, vc->vc_cols); +__fbcon_clear (vc,0 ,0 , vc->vc_rows, vc->vc_cols); vc->vc_video_erase_char = oldc; } }
include/linux/console.h +3 -2
@@ -38,6 +38,7 @@ enum vc_intensity;* * @con_init: initialize the console on @vc. @init is true for the very first * call on this @vc. +* @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console.
@@ -50,8 +51,8 @@ struct consw {const char *(*con_startup)(void );void (*con_init)(struct vc_data *vc,bool init);void (*con_deinit)(struct vc_data *vc); -void (*con_clear)(struct vc_data *vc,int sy,int sx,int height, -int width); +void (*con_clear)(struct vc_data *vc,unsigned int y, +unsigned int x,unsigned int count);void (*con_putc)(struct vc_data *vc,int c,int ypos,int xpos);void (*con_putcs)(struct vc_data *vc,const unsigned short *s,int count,int ypos,int xpos);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 22/47 tty: vt: remove checks for count in consw::con_clear() implementations
In reply to Jiri Slaby (SUSE)'count' in consw::con_clear() is guaranteed to be positive. csi_X() (the only caller) takes the minimum of the vc parameter (which is at least 1) and count of characters till the end of the line. The latter is computed as a subtraction of vc->vc_cols (count) and vc->state.x (offset). So for the worst case, full line, it is 1.
Therefore, there is no point in checking zero or negative values (width is now unsigned anyway).
--- drivers/video/console/mdacon.c | 3 --- drivers/video/console/sticon.c | 3 --- 2 files changed, 6 deletions(-)
drivers/video/console/mdacon.c +0 -3
@@ -448,9 +448,6 @@ static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x,u16 *dest =mda_addr (x, y);u16 eattr =mda_convert_attr (c->vc_video_erase_char); -if (width <=0 ) -return ; -scr_memsetw (dest, eattr, width *2 ); }
drivers/video/console/sticon.c +0 -3
@@ -303,9 +303,6 @@ static void sticon_deinit(struct vc_data *c)static void sticon_clear (struct vc_data *conp,unsigned int sy,unsigned int sx,unsigned int width) { -if (!width) -return ; -sti_clear (sticon_sti, sy, sx,1 , width, conp->vc_video_erase_char, font_data[conp->vc_num]); }
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 23/47 tty: vt: add con_putc() helper
In reply to Jiri Slaby (SUSE)And let it call consw::con_putc() if it exists, otherwise consw::con_putcs(). This is similar to tty_put_char().
It supports dropping unneeded duplication of code like sticon_putc() is (see the next patch).
--- drivers/tty/vt/vt.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/tty/vt/vt.c +13 -5
@@ -300,6 +300,14 @@ static inline unsigned short *screenpos(const struct vc_data *vc, int offset,return p; } +static void con_putc (struct vc_data *vc,u16 ca,unsigned int y,unsigned int x) +{ +if (vc->vc_sw->con_putc) + vc->vc_sw->con_putc (vc, ca, y, x); +else + vc->vc_sw->con_putcs (vc, &ca,1 , y, x); +} +/* Called from the keyboard irq path.. */ static inline void scrolldelta (int lines) {
@@ -762,7 +770,7 @@ void complement_pos(struct vc_data *vc, int offset) old_offset < vc->vc_screenbuf_size) {scr_writew (old,screenpos (vc, old_offset, true));if (con_should_update (vc)) - vc->vc_sw->con_putc (vc, old, oldy, oldx); +con_putc (vc, old, oldy, oldx);notify_update (vc); }
@@ -779,7 +787,7 @@ void complement_pos(struct vc_data *vc, int offset)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); +con_putc (vc, new, oldy, oldx); }notify_update (vc); }
@@ -833,7 +841,7 @@ static void add_softcursor(struct vc_data *vc) i ^=CUR_FG ;scr_writew (i, (u16 *)vc->vc_pos);if (con_should_update (vc)) - vc->vc_sw->con_putc (vc, i, vc->state.y, vc->state.x); +con_putc (vc, i, vc->state.y, vc->state.x); }static void hide_softcursor (struct vc_data *vc)
@@ -841,8 +849,8 @@ static void hide_softcursor(struct vc_data *vc)if (softcursor_original !=-1 ) {scr_writew (softcursor_original, (u16 *)vc->vc_pos);if (con_should_update (vc)) - vc->vc_sw->con_putc (vc, softcursor_original, - vc->state.y, vc->state.x); +con_putc (vc, softcursor_original, vc->state.y, + vc->state.x); softcursor_original =-1 ; } }
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 24/47 tty: vt: eliminate unneeded consw::con_putc() implementations
In reply to Jiri Slaby (SUSE)All these consw::con_putc() implementations do the same as consw::con_putcs() (only for one charattr) or even call consw::con_putcs() on their own.
Drop them, as thanks to the new con_putc() helper in the previous patch, the console code performs this already -- exactly if consw::con_putc() is missing (NULL).
--- drivers/video/console/mdacon.c | 6 ------ drivers/video/console/sticon.c | 12 ------------ drivers/video/console/vgacon.c | 2 -- drivers/video/fbdev/core/fbcon.c | 9 --------- 4 files changed, 29 deletions(-)
drivers/video/console/mdacon.c +0 -6
@@ -427,11 +427,6 @@ static inline u16 *mda_addr(unsigned int x, unsigned int y)return mda_vram_base + y * mda_num_columns + x; } -static void mdacon_putc (struct vc_data *c,int ch,int y,int x) -{ -scr_writew (mda_convert_attr (ch),mda_addr (x, y)); -} -static void mdacon_putcs (struct vc_data *c,const unsigned short *s,int count,int y,int x) {
@@ -536,7 +531,6 @@ static const struct consw mda_con = { .con_init = mdacon_init, .con_deinit = mdacon_deinit, .con_clear = mdacon_clear, - .con_putc = mdacon_putc, .con_putcs = mdacon_putcs, .con_cursor = mdacon_cursor, .con_scroll = mdacon_scroll,
drivers/video/console/sticon.c +0 -12
@@ -71,17 +71,6 @@ static const char *sticon_startup(void)return "STI console" ; } -static void sticon_putc (struct vc_data *conp,int c,int ypos,int xpos) -{ -if (vga_is_gfx || console_blanked) -return ; - -if (conp->vc_mode !=KD_TEXT ) -return ; - -sti_putc (sticon_sti, c, ypos, xpos, font_data[conp->vc_num]); -} -static void sticon_putcs (struct vc_data *conp,const unsigned short *s,int count,int ypos,int xpos) {
@@ -362,7 +351,6 @@ static const struct consw sti_con = { .con_init = sticon_init, .con_deinit = sticon_deinit, .con_clear = sticon_clear, - .con_putc = sticon_putc, .con_putcs = sticon_putcs, .con_cursor = sticon_cursor, .con_scroll = sticon_scroll,
drivers/video/console/vgacon.c +0 -2
@@ -1193,7 +1193,6 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,static void vgacon_clear (struct vc_data *vc,unsigned int sy,unsigned int sx,unsigned int width) { } -static void vgacon_putc (struct vc_data *vc,int c,int ypos,int xpos) { }static void vgacon_putcs (struct vc_data *vc,const unsigned short *s,int count,int ypos,int xpos) { }
@@ -1203,7 +1202,6 @@ const struct consw vga_con = { .con_init = vgacon_init, .con_deinit = vgacon_deinit, .con_clear = vgacon_clear, - .con_putc = vgacon_putc, .con_putcs = vgacon_putcs, .con_cursor = vgacon_cursor, .con_scroll = vgacon_scroll,
drivers/video/fbdev/core/fbcon.c +0 -9
@@ -1292,14 +1292,6 @@ static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, get_color(vc, info, scr_readw(s), 0)); } -static void fbcon_putc (struct vc_data *vc,int c,int ypos,int xpos) -{ -unsigned short chr; - -scr_writew (c, &chr); -fbcon_putcs (vc, &chr,1 , ypos, xpos); -} -static void fbcon_clear_margins (struct vc_data *vc,int bottom_only) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);
@@ -3159,7 +3151,6 @@ static const struct consw fb_con = { .con_init = fbcon_init, .con_deinit = fbcon_deinit, .con_clear = fbcon_clear, - .con_putc = fbcon_putc, .con_putcs = fbcon_putcs, .con_cursor = fbcon_cursor, .con_scroll = fbcon_scroll,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 25/47 tty: vt: sanitize consw::con_putc() parameters
In reply to Jiri Slaby (SUSE)Make parameters of consw::con_putc() saner:
* x and y are unsigned now, as they cannot be negative, and
* ca is made u16, as it is composed of two 8bit values (character and attribute). See the con_putcs() hook, u16/ushort is worked on there.
And document the hook.
--- drivers/video/console/dummycon.c | 6 ++++-- drivers/video/console/newport_con.c | 4 ++-- include/linux/console.h | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-)
drivers/video/console/dummycon.c +4 -2
@@ -50,7 +50,8 @@ void dummycon_unregister_output_notifier(struct notifier_block *nb)raw_notifier_chain_unregister (&dummycon_output_nh, nb); } -static void dummycon_putc (struct vc_data *vc,int c,int ypos,int xpos) +static void dummycon_putc (struct vc_data *vc,u16 c,unsigned int y, +unsigned int x) {WARN_CONSOLE_UNLOCKED ();
@@ -84,7 +85,8 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) return 1; }#else -static void dummycon_putc (struct vc_data *vc,int c,int ypos,int xpos) { } +static void dummycon_putc (struct vc_data *vc,u16 c,unsigned int y, +unsigned int x) { }static void dummycon_putcs (struct vc_data *vc,const unsigned short *s,int count,int ypos,int xpos) { }static int dummycon_blank (struct vc_data *vc,int blank,int mode_switch)
drivers/video/console/newport_con.c +2 -2
@@ -367,8 +367,8 @@ static void newport_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, } } -static void newport_putc (struct vc_data *vc,int charattr,int ypos, -int xpos) +static void newport_putc (struct vc_data *vc,u16 charattr,unsigned int ypos, +unsigned int xpos) {unsigned char *p;
include/linux/console.h +4 -1
@@ -39,6 +39,8 @@ enum vc_intensity;* @con_init: initialize the console on @vc. @init is true for the very first * call on this @vc. * @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. +* @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. +* (optional -- @con_putcs would be called instead) * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console.
@@ -53,7 +55,8 @@ struct consw {void (*con_deinit)(struct vc_data *vc);void (*con_clear)(struct vc_data *vc,unsigned int y,unsigned int x,unsigned int count); -void (*con_putc)(struct vc_data *vc,int c,int ypos,int xpos); +void (*con_putc)(struct vc_data *vc,u16 ca,unsigned int y, +unsigned int x);void (*con_putcs)(struct vc_data *vc,const unsigned short *s,int count,int ypos,int xpos);void (*con_cursor)(struct vc_data *vc,int mode);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 26/47 tty: vt: sanitize consw::con_putcs() parameters
In reply to Jiri Slaby (SUSE)Similar to con_putc() in the previous patch:
* make the pointer to charattr a pointer to u16, and
* make x, y, and count unsigned as they are strictly non-negative.
And again, document that hook.
--- drivers/video/console/dummycon.c | 10 +++++----- drivers/video/console/mdacon.c | 4 ++-- drivers/video/console/newport_con.c | 9 +++++---- drivers/video/console/sticon.c | 4 ++-- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 4 ++-- include/linux/console.h | 6 ++++-- 7 files changed, 22 insertions(+), 19 deletions(-)
drivers/video/console/dummycon.c +5 -5
@@ -59,10 +59,10 @@ static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y,raw_notifier_call_chain (&dummycon_output_nh,0 ,NULL ); } -static void dummycon_putcs (struct vc_data *vc,const unsigned short *s, -int count,int ypos,int xpos) +static void dummycon_putcs (struct vc_data *vc,const u16 *s,unsigned int count, +unsigned int ypos,unsigned int xpos) { -int i; +unsigned int i;if (!dummycon_putc_called) {/* Ignore erases */
@@ -87,8 +87,8 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch)#else static void dummycon_putc (struct vc_data *vc,u16 c,unsigned int y,unsigned int x) { } -static void dummycon_putcs (struct vc_data *vc,const unsigned short *s, -int count,int ypos,int xpos) { } +static void dummycon_putcs (struct vc_data *vc,const u16 *s,unsigned int count, +unsigned int ypos,unsigned int xpos) { }static int dummycon_blank (struct vc_data *vc,int blank,int mode_switch) {return 0 ;
drivers/video/console/mdacon.c +2 -2
@@ -427,8 +427,8 @@ static inline u16 *mda_addr(unsigned int x, unsigned int y)return mda_vram_base + y * mda_num_columns + x; } -static void mdacon_putcs (struct vc_data *c,const unsigned short *s, -int count,int y,int x) +static void mdacon_putcs (struct vc_data *c,const u16 *s,unsigned int count, +unsigned int y,unsigned int x) {u16 *dest =mda_addr (x, y);
drivers/video/console/newport_con.c +5 -4
@@ -396,12 +396,13 @@ static void newport_putc(struct vc_data *vc, u16 charattr, unsigned int ypos,RENDER (npregs, p); } -static void newport_putcs (struct vc_data *vc,const unsigned short *s, -int count,int ypos,int xpos) +static void newport_putcs (struct vc_data *vc,const u16 *s, +unsigned int count,unsigned int ypos, +unsigned int xpos) { -int i; -int charattr;unsigned char *p; +unsigned int i; +u16 charattr; charattr = (scr_readw (s) >>8 ) &0xff ;
drivers/video/console/sticon.c +2 -2
@@ -71,8 +71,8 @@ static const char *sticon_startup(void)return "STI console" ; } -static void sticon_putcs (struct vc_data *conp,const unsigned short *s, -int count,int ypos,int xpos) +static void sticon_putcs (struct vc_data *conp,const u16 *s,unsigned int count, +unsigned int ypos,unsigned int xpos) {if (vga_is_gfx || console_blanked)return ;
drivers/video/console/vgacon.c +2 -2
@@ -1193,8 +1193,8 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,static void vgacon_clear (struct vc_data *vc,unsigned int sy,unsigned int sx,unsigned int width) { } -static void vgacon_putcs (struct vc_data *vc,const unsigned short *s, -int count,int ypos,int xpos) { } +static void vgacon_putcs (struct vc_data *vc,const u16 *s,unsigned int count, +unsigned int ypos,unsigned int xpos) { }const struct consw vga_con = { .owner =THIS_MODULE ,
drivers/video/fbdev/core/fbcon.c +2 -2
@@ -1279,8 +1279,8 @@ static void fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,__fbcon_clear (vc, sy, sx,1 , width); } -static void fbcon_putcs (struct vc_data *vc,const unsigned short *s, -int count,int ypos,int xpos) +static void fbcon_putcs (struct vc_data *vc,const u16 *s,unsigned int count, +unsigned int ypos,unsigned int xpos) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);struct fbcon_display *p = &fb_display[vc->vc_num];
include/linux/console.h +4 -2
@@ -41,6 +41,7 @@ enum vc_intensity;* @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. * @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. * (optional -- @con_putcs would be called instead) +* @con_putcs: emit @count characters with attributes @s to [@x, @y] on @vc. * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console.
@@ -57,8 +58,9 @@ struct consw { unsigned int x, unsigned int count);void (*con_putc)(struct vc_data *vc,u16 ca,unsigned int y,unsigned int x); -void (*con_putcs)(struct vc_data *vc,const unsigned short *s, -int count,int ypos,int xpos); +void (*con_putcs)(struct vc_data *vc,const u16 *s, +unsigned int count,unsigned int ypos, +unsigned int xpos);void (*con_cursor)(struct vc_data *vc,int mode); bool (*con_scroll)(struct vc_data *vc, unsigned int top, unsigned int bottom, enum con_scroll dir,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 27/47 consoles: use if instead of switch-case in consw::con_cursor()
In reply to Jiri Slaby (SUSE)This is only a preparation for the following cleanup patch to make it easier. Provided CM_ERASE is the only different, use 'if' instead of 'switch+case' in all those.
--- drivers/video/console/newport_con.c | 26 +++++------- drivers/video/console/sticon.c | 27 ++++++------ drivers/video/console/vgacon.c | 66 +++++++++++++---------------- 3 files changed, 53 insertions(+), 66 deletions(-)
drivers/video/console/newport_con.c +11 -15
@@ -443,24 +443,20 @@ static void newport_cursor(struct vc_data *vc, int mode)unsigned short treg;int xcurs, ycurs; -switch (mode) { -case CM_ERASE : - treg =newport_vc2_get (npregs,VC2_IREG_CONTROL ); -newport_vc2_set (npregs,VC2_IREG_CONTROL , - (treg & ~(VC2_CTRL_ECDISP ))); -break ; + treg =newport_vc2_get (npregs,VC2_IREG_CONTROL ); -case CM_MOVE : -case CM_DRAW : - treg =newport_vc2_get (npregs,VC2_IREG_CONTROL ); +if (mode ==CM_ERASE ) {newport_vc2_set (npregs,VC2_IREG_CONTROL , - (treg |VC2_CTRL_ECDISP )); - xcurs = (vc->vc_pos - vc->vc_visible_origin) /2 ; - ycurs = ((xcurs / vc->vc_cols) <<4 ) +31 ; - xcurs = ((xcurs % vc->vc_cols) <<3 ) + xcurs_correction; -newport_vc2_set (npregs,VC2_IREG_CURSX , xcurs); -newport_vc2_set (npregs,VC2_IREG_CURSY , ycurs); + (treg & ~(VC2_CTRL_ECDISP ))); +return ; } + +newport_vc2_set (npregs,VC2_IREG_CONTROL , (treg |VC2_CTRL_ECDISP )); + xcurs = (vc->vc_pos - vc->vc_visible_origin) /2 ; + ycurs = ((xcurs / vc->vc_cols) <<4 ) +31 ; + xcurs = ((xcurs % vc->vc_cols) <<3 ) + xcurs_correction; +newport_vc2_set (npregs,VC2_IREG_CURSX , xcurs); +newport_vc2_set (npregs,VC2_IREG_CURSY , ycurs); }static int newport_switch (struct vc_data *vc)
drivers/video/console/sticon.c +12 -15
@@ -95,23 +95,20 @@ static void sticon_cursor(struct vc_data *conp, int mode)return ; car1 = conp->vc_screenbuf[conp->state.x + conp->state.y * conp->vc_cols]; -switch (mode) { -case CM_ERASE : +if (mode ==CM_ERASE ) {sti_putc (sticon_sti, car1, conp->state.y, conp->state.x, font_data[conp->vc_num]); -break ; -case CM_MOVE : -case CM_DRAW : -switch (CUR_SIZE (conp->vc_cursor_type)) { -case CUR_UNDERLINE : -case CUR_LOWER_THIRD : -case CUR_LOWER_HALF : -case CUR_TWO_THIRDS : -case CUR_BLOCK : -sti_putc (sticon_sti, (car1 &255 ) + (0 <<8 ) + (7 <<11 ), - conp->state.y, conp->state.x, font_data[conp->vc_num]); -break ; - } +return ; + } + +switch (CUR_SIZE (conp->vc_cursor_type)) { +case CUR_UNDERLINE : +case CUR_LOWER_THIRD : +case CUR_LOWER_HALF : +case CUR_TWO_THIRDS : +case CUR_BLOCK : +sti_putc (sticon_sti, (car1 &255 ) + (0 <<8 ) + (7 <<11 ), + conp->state.y, conp->state.x, font_data[conp->vc_num]);break ; } }
drivers/video/console/vgacon.c +30 -36
77 lines not on this page · raw message
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 28/47 fbdev/core: simplify cursor_state setting in fbcon_ops::cursor()
In reply to Jiri Slaby (SUSE)There is a switch decicing if cursor should be drawn or not. The whole switch can be simplified to one line. Do this cleanup as a preparatory work for the next patch. There, all the CM_* constants are removed.
--- drivers/video/fbdev/core/bitblit.c | 11 +---------- drivers/video/fbdev/core/fbcon_ccw.c | 11 +---------- drivers/video/fbdev/core/fbcon_cw.c | 11 +---------- drivers/video/fbdev/core/fbcon_ud.c | 11 +---------- 4 files changed, 4 insertions(+), 40 deletions(-)
drivers/video/fbdev/core/bitblit.c +1 -10
@@ -348,16 +348,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, mask[i++] = msk; } -switch (mode) { -case CM_ERASE : - ops->cursor_state.enable =0 ; -break ; -case CM_DRAW : -case CM_MOVE : -default : - ops->cursor_state.enable = (use_sw) ?0 :1 ; -break ; - } + ops->cursor_state.enable = (mode !=CM_ERASE ) && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color;
drivers/video/fbdev/core/fbcon_ccw.c +1 -10
@@ -349,16 +349,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode,kfree (tmp); } -switch (mode) { -case CM_ERASE : - ops->cursor_state.enable =0 ; -break ; -case CM_DRAW : -case CM_MOVE : -default : - ops->cursor_state.enable = (use_sw) ?0 :1 ; -break ; - } + ops->cursor_state.enable = (mode !=CM_ERASE ) && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color;
drivers/video/fbdev/core/fbcon_cw.c +1 -10
@@ -332,16 +332,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,kfree (tmp); } -switch (mode) { -case CM_ERASE : - ops->cursor_state.enable =0 ; -break ; -case CM_DRAW : -case CM_MOVE : -default : - ops->cursor_state.enable = (use_sw) ?0 :1 ; -break ; - } + ops->cursor_state.enable = (mode !=CM_ERASE ) && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color;
drivers/video/fbdev/core/fbcon_ud.c +1 -10
@@ -372,16 +372,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, mask[i++] = ~msk; } -switch (mode) { -case CM_ERASE : - ops->cursor_state.enable =0 ; -break ; -case CM_DRAW : -case CM_MOVE : -default : - ops->cursor_state.enable = (use_sw) ?0 :1 ; -break ; - } + ops->cursor_state.enable = (mode !=CM_ERASE ) && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color;
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 29/47 tty: vt: remove CM_* constants
In reply to Jiri Slaby (SUSE)There is no difference between CM_MOVE and CM_DRAW. Either of them enables the cursor. CM_ERASE then disables cursor.
So get rid of all of them and use simple "bool enable".
Note that this propagates down to the fbcon code.
And document the hook.
--- drivers/tty/vt/vt.c | 4 ++-- drivers/video/console/dummycon.c | 2 +- drivers/video/console/mdacon.c | 4 ++-- drivers/video/console/newport_con.c | 4 ++-- drivers/video/console/sticon.c | 6 +++--- drivers/video/console/vgacon.c | 6 +++--- drivers/video/fbdev/core/bitblit.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 19 +++++++++---------- drivers/video/fbdev/core/fbcon.h | 4 ++-- drivers/video/fbdev/core/fbcon_ccw.c | 4 ++-- drivers/video/fbdev/core/fbcon_cw.c | 4 ++-- drivers/video/fbdev/core/fbcon_ud.c | 4 ++-- drivers/video/fbdev/core/tileblit.c | 4 ++-- include/linux/console.h | 8 ++------ 14 files changed, 36 insertions(+), 41 deletions(-)
drivers/tty/vt/vt.c +2 -2
@@ -860,7 +860,7 @@ static void hide_cursor(struct vc_data *vc)if (vc_is_sel (vc))clear_selection (); - vc->vc_sw->con_cursor (vc,CM_ERASE ); + vc->vc_sw->con_cursor (vc, false);hide_softcursor (vc); }
@@ -873,7 +873,7 @@ static void set_cursor(struct vc_data *vc)clear_selection ();add_softcursor (vc);if (CUR_SIZE (vc->vc_cursor_type) !=CUR_NONE ) - vc->vc_sw->con_cursor (vc,CM_DRAW ); + vc->vc_sw->con_cursor (vc, true); }else hide_cursor (vc); }
drivers/video/console/dummycon.c +1 -1
@@ -113,7 +113,7 @@ static void dummycon_init(struct vc_data *vc, bool init)static void dummycon_deinit (struct vc_data *vc) { }static void dummycon_clear (struct vc_data *vc,unsigned int sy,unsigned int sx,unsigned int width) { } -static void dummycon_cursor (struct vc_data *vc,int mode) { } +static void dummycon_cursor (struct vc_data *vc,bool enable) { } static bool dummycon_scroll(struct vc_data *vc, unsigned int top, unsigned int bottom, enum con_scroll dir,
drivers/video/console/mdacon.c +2 -2
@@ -470,9 +470,9 @@ static int mdacon_blank(struct vc_data *c, int blank, int mode_switch) } } -static void mdacon_cursor (struct vc_data *c,int mode) +static void mdacon_cursor (struct vc_data *c,bool enable) { -if (mode ==CM_ERASE ) { +if (!enable) {mda_set_cursor (mda_vram_len -1 );return ; }
drivers/video/console/newport_con.c +2 -2
@@ -438,14 +438,14 @@ static void newport_putcs(struct vc_data *vc, const u16 *s, } } -static void newport_cursor (struct vc_data *vc,int mode) +static void newport_cursor (struct vc_data *vc,bool enable) {unsigned short treg;int xcurs, ycurs; treg =newport_vc2_get (npregs,VC2_IREG_CONTROL ); -if (mode ==CM_ERASE ) { +if (!enable) {newport_vc2_set (npregs,VC2_IREG_CONTROL , (treg & ~(VC2_CTRL_ECDISP )));return ;
drivers/video/console/sticon.c +3 -3
@@ -86,7 +86,7 @@ static void sticon_putcs(struct vc_data *conp, const u16 *s, unsigned int count, } } -static void sticon_cursor (struct vc_data *conp,int mode) +static void sticon_cursor (struct vc_data *conp,bool enable) {unsigned short car1;
@@ -95,7 +95,7 @@ static void sticon_cursor(struct vc_data *conp, int mode)return ; car1 = conp->vc_screenbuf[conp->state.x + conp->state.y * conp->vc_cols]; -if (mode ==CM_ERASE ) { +if (!enable) {sti_putc (sticon_sti, car1, conp->state.y, conp->state.x, font_data[conp->vc_num]);return ;
@@ -121,7 +121,7 @@ static bool sticon_scroll(struct vc_data *conp, unsigned int t,if (vga_is_gfx)return false; -sticon_cursor (conp,CM_ERASE ); +sticon_cursor (conp, false);switch (dir) {case SM_UP :
drivers/video/console/vgacon.c +3 -3
@@ -503,7 +503,7 @@ static void vgacon_set_cursor_size(int from, int to)raw_spin_unlock_irqrestore (&vga_lock, flags); } -static void vgacon_cursor (struct vc_data *c,int mode) +static void vgacon_cursor (struct vc_data *c,bool enable) {unsigned int c_height;
@@ -516,7 +516,7 @@ static void vgacon_cursor(struct vc_data *c, int mode)write_vga (14 , (c->vc_pos - vga_vram_base) /2 ); -if (mode ==CM_ERASE ) { +if (!enable) {if (vga_video_type >=VIDEO_TYPE_VGAC )vgacon_set_cursor_size (31 ,30 );else
@@ -1030,7 +1030,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight)/* void size to cause regs to be rewritten */ cursor_size_lastfrom =0 ; cursor_size_lastto =0 ; - c->vc_sw->con_cursor (c,CM_DRAW ); + c->vc_sw->con_cursor (c, true); } c->vc_font.height = c->vc_cell_height = fontheight;vc_resize (c,0 , rows);/* Adjust console size */
drivers/video/fbdev/core/bitblit.c +2 -2
@@ -233,7 +233,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, } } -static void bit_cursor (struct vc_data *vc,struct fb_info *info,int mode, +static void bit_cursor (struct vc_data *vc,struct fb_info *info,bool enable,int fg,int bg) {struct fb_cursor cursor;
@@ -348,7 +348,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, mask[i++] = msk; } - ops->cursor_state.enable = (mode !=CM_ERASE ) && !use_sw; + ops->cursor_state.enable = enable && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color;
drivers/video/fbdev/core/fbcon.c +9 -10
@@ -351,7 +351,7 @@ static void fb_flashcursor(struct work_struct *work)struct fb_info *info;struct vc_data *vc =NULL ;int c; -int mode; +bool enable;int ret;/* FIXME: we should sort out the unbind locking instead */
@@ -375,9 +375,8 @@ static void fb_flashcursor(struct work_struct *work) } c =scr_readw ((u16 *) vc->vc_pos); - mode = (!ops->cursor_flash || ops->cursor_state.enable) ? -CM_ERASE :CM_DRAW ; - ops->cursor (vc, info, mode,get_color (vc, info, c,1 ), + enable = ops->cursor_flash && !ops->cursor_state.enable; + ops->cursor (vc, info, enable,get_color (vc, info, c,1 ),get_color (vc, info, c,0 ));console_unlock ();
@@ -1301,7 +1300,7 @@ static void fbcon_clear_margins(struct vc_data *vc, int bottom_only) ops->clear_margins (vc, info, margin_color, bottom_only); } -static void fbcon_cursor (struct vc_data *vc,int mode) +static void fbcon_cursor (struct vc_data *vc,bool enable) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);struct fbcon_ops *ops = info->fbcon_par;
@@ -1317,12 +1316,12 @@ static void fbcon_cursor(struct vc_data *vc, int mode)else fbcon_add_cursor_work (info); - ops->cursor_flash = (mode ==CM_ERASE ) ?0 :1 ; + ops->cursor_flash = enable;if (!ops->cursor)return ; - ops->cursor (vc, info, mode,get_color (vc, info, c,1 ), + ops->cursor (vc, info, enable,get_color (vc, info, c,1 ),get_color (vc, info, c,0 )); }
@@ -1742,7 +1741,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,if (fbcon_is_inactive (vc, info))return true; -fbcon_cursor (vc,CM_ERASE ); +fbcon_cursor (vc, false);/* * ++Geert: Only use ywrap/ypan if the console is in text mode
@@ -2221,7 +2220,7 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)if (!fbcon_is_inactive (vc, info)) {if (ops->blank_state != blank) { ops->blank_state = blank; -fbcon_cursor (vc, blank ?CM_ERASE :CM_DRAW ); +fbcon_cursor (vc, !blank); ops->cursor_flash = (!blank);if (fb_blank (info, blank))
@@ -2649,7 +2648,7 @@ void fbcon_suspended(struct fb_info *info) vc = vc_cons[ops->currcon].d;/* Clear cursor, restore saved data */ -fbcon_cursor (vc,CM_ERASE ); +fbcon_cursor (vc, false); }void fbcon_resumed (struct fb_info *info)
drivers/video/fbdev/core/fbcon.h +2 -2
@@ -61,8 +61,8 @@ struct fbcon_ops { int fg, int bg);void (*clear_margins)(struct vc_data *vc,struct fb_info *info,int color,int bottom_only); -void (*cursor)(struct vc_data *vc,struct fb_info *info,int mode, -int fg,int bg); +void (*cursor)(struct vc_data *vc,struct fb_info *info, +bool enable,int fg,int bg);int (*update_start)(struct fb_info *info);int (*rotate_font)(struct fb_info *info,struct vc_data *vc);struct fb_var_screeninfo var;/* copy of the current fb_var_screeninfo */
drivers/video/fbdev/core/fbcon_ccw.c +2 -2
@@ -218,7 +218,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info, } } -static void ccw_cursor (struct vc_data *vc,struct fb_info *info,int mode, +static void ccw_cursor (struct vc_data *vc,struct fb_info *info,bool enable,int fg,int bg) {struct fb_cursor cursor;
@@ -349,7 +349,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode,kfree (tmp); } - ops->cursor_state.enable = (mode !=CM_ERASE ) && !use_sw; + ops->cursor_state.enable = enable && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color;
drivers/video/fbdev/core/fbcon_cw.c +2 -2
@@ -201,7 +201,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info, } } -static void cw_cursor (struct vc_data *vc,struct fb_info *info,int mode, +static void cw_cursor (struct vc_data *vc,struct fb_info *info,bool enable,int fg,int bg) {struct fb_cursor cursor;
@@ -332,7 +332,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,kfree (tmp); } - ops->cursor_state.enable = (mode !=CM_ERASE ) && !use_sw; + ops->cursor_state.enable = enable && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color;
drivers/video/fbdev/core/fbcon_ud.c +2 -2
@@ -248,7 +248,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info, } } -static void ud_cursor (struct vc_data *vc,struct fb_info *info,int mode, +static void ud_cursor (struct vc_data *vc,struct fb_info *info,bool enable,int fg,int bg) {struct fb_cursor cursor;
@@ -372,7 +372,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, mask[i++] = ~msk; } - ops->cursor_state.enable = (mode !=CM_ERASE ) && !use_sw; + ops->cursor_state.enable = enable && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color;
drivers/video/fbdev/core/tileblit.c +2 -2
@@ -79,7 +79,7 @@ static void tile_clear_margins(struct vc_data *vc, struct fb_info *info,return ; } -static void tile_cursor (struct vc_data *vc,struct fb_info *info,int mode, +static void tile_cursor (struct vc_data *vc,struct fb_info *info,bool enable,int fg,int bg) {struct fb_tilecursor cursor;
@@ -87,7 +87,7 @@ static void tile_cursor(struct vc_data *vc, struct fb_info *info, int mode, cursor.sx = vc->state.x; cursor.sy = vc->state.y; - cursor.mode = (mode ==CM_ERASE || use_sw) ?0 :1 ; + cursor.mode = enable && !use_sw; cursor.fg = fg; cursor.bg = bg;
include/linux/console.h +2 -6
@@ -42,6 +42,7 @@ enum vc_intensity;* @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. * (optional -- @con_putcs would be called instead) * @con_putcs: emit @count characters with attributes @s to [@x, @y] on @vc. +* @con_cursor: enable/disable cursor depending on @enable * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console.
@@ -61,7 +62,7 @@ struct consw {void (*con_putcs)(struct vc_data *vc,const u16 *s,unsigned int count,unsigned int ypos,unsigned int xpos); -void (*con_cursor)(struct vc_data *vc,int mode); +void (*con_cursor)(struct vc_data *vc,bool enable);bool (*con_scroll)(struct vc_data *vc,unsigned int top,unsigned int bottom,enum con_scroll dir,unsigned int lines);
@@ -128,11 +129,6 @@ static inline void con_debug_enter(struct vc_data *vc) { }static inline void con_debug_leave (void ) { }#endif -/* cursor */ -#define CM_DRAW (1) -#define CM_ERASE (2) -#define CM_MOVE (3) -/* * The interface for a console, or any other device that wants to capture * console messages (printer driver?)
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 30/47 tty: vt: make consw::con_switch() return a bool
In reply to Jiri Slaby (SUSE)The non-zero (true) return value from consw::con_switch() means a redraw is needed. So make this return type a bool explicitly instead of int. The latter might imply that -Eerrors are expected. They are not.
And document the hook.
--- drivers/tty/vt/vt.c | 2 +- drivers/video/console/dummycon.c | 4 ++-- drivers/video/console/mdacon.c | 4 ++-- drivers/video/console/newport_con.c | 4 ++-- drivers/video/console/sticon.c | 4 ++-- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 6 +++--- include/linux/console.h | 4 +++- 8 files changed, 17 insertions(+), 15 deletions(-)
drivers/tty/vt/vt.c +1 -1
@@ -970,7 +970,7 @@ void redraw_screen(struct vc_data *vc, int is_switch) }if (redraw) { -int update; +bool update;int old_was_color = vc->vc_can_do_color;set_origin (vc);
drivers/video/console/dummycon.c +2 -2
@@ -122,9 +122,9 @@ static bool dummycon_scroll(struct vc_data *vc, unsigned int top,return false; } -static int dummycon_switch (struct vc_data *vc) +static bool dummycon_switch (struct vc_data *vc) { -return 0 ; +return false; }/*
drivers/video/console/mdacon.c +2 -2
@@ -446,9 +446,9 @@ static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x,scr_memsetw (dest, eattr, width *2 ); } -static int mdacon_switch (struct vc_data *c) +static bool mdacon_switch (struct vc_data *c) { -return 1 ;/* redrawing needed */ +return true;/* redrawing needed */ }static int mdacon_blank (struct vc_data *c,int blank,int mode_switch)
drivers/video/console/newport_con.c +2 -2
@@ -459,7 +459,7 @@ static void newport_cursor(struct vc_data *vc, bool enable)newport_vc2_set (npregs,VC2_IREG_CURSY , ycurs); } -static int newport_switch (struct vc_data *vc) +static bool newport_switch (struct vc_data *vc) {static int logo_drawn =0 ;
@@ -473,7 +473,7 @@ static int newport_switch(struct vc_data *vc) } } -return 1 ; +return true; }static int newport_blank (struct vc_data *c,int blank,int mode_switch)
drivers/video/console/sticon.c +2 -2
@@ -293,9 +293,9 @@ static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx, conp->vc_video_erase_char, font_data[conp->vc_num]); } -static int sticon_switch (struct vc_data *conp) +static bool sticon_switch (struct vc_data *conp) { -return 1 ;/* needs refreshing */ +return true;/* needs refreshing */ }static int sticon_blank (struct vc_data *c,int blank,int mode_switch)
drivers/video/console/vgacon.c +2 -2
@@ -614,7 +614,7 @@ static void vgacon_doresize(struct vc_data *c,raw_spin_unlock_irqrestore (&vga_lock, flags); } -static int vgacon_switch (struct vc_data *c) +static bool vgacon_switch (struct vc_data *c) {int x = c->vc_cols *VGA_FONTWIDTH ;int y = c->vc_rows * c->vc_cell_height;
@@ -643,7 +643,7 @@ static int vgacon_switch(struct vc_data *c)vgacon_doresize (c, c->vc_cols, c->vc_rows); } -return 0 ;/* Redrawing not needed */ +return false;/* Redrawing not needed */ }static void vga_set_palette (struct vc_data *vc,const unsigned char *table)
drivers/video/fbdev/core/fbcon.c +3 -3
@@ -2056,7 +2056,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,return 0 ; } -static int fbcon_switch (struct vc_data *vc) +static bool fbcon_switch (struct vc_data *vc) {struct fb_info *info, *old_info =NULL ;struct fbcon_ops *ops;
@@ -2178,9 +2178,9 @@ static int fbcon_switch(struct vc_data *vc) vc->vc_origin + vc->vc_size_row * vc->vc_top, vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2); -return 0 ; +return false; } -return 1 ; +return true; } static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
include/linux/console.h +3 -1
@@ -46,6 +46,8 @@ enum vc_intensity;* @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console. +* @con_switch: notifier about the console switch; it is supposed to return +* true if a redraw is needed. * @con_set_palette: sets the palette of the console to @table (optional) * @con_scrolldelta: the contents of the console should be scrolled by @lines. * Invoked by user. (optional)
@@ -66,7 +68,7 @@ struct consw {bool (*con_scroll)(struct vc_data *vc,unsigned int top,unsigned int bottom,enum con_scroll dir,unsigned int lines); -int (*con_switch)(struct vc_data *vc); +bool (*con_switch)(struct vc_data *vc);int (*con_blank)(struct vc_data *vc,int blank,int mode_switch);int (*con_font_set)(struct vc_data *vc,struct console_font *font,unsigned int vpitch,unsigned int flags);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 31/47 tty: vt: stop using -1 for blank mode in consw::con_blank()
In reply to Jiri Slaby (SUSE)-1 is the same as VESA_VSYNC_SUSPEND in all con_blank() implementations. So we can remove this special case from vgacon now too.
Despite con_blank() of fbcon looks complicated, the "if (!fbcon_is_inactive(vc, info))" branch is not taken as we set "ops->graphics = 1;" few lines above. So what matters there (as in all other blank implementations except vgacon) is if 'blank' is zero or not.
--- drivers/tty/vt/vt.c | 2 +- drivers/video/console/vgacon.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/tty/vt/vt.c +1 -1
@@ -4347,7 +4347,7 @@ void do_blank_screen(int entering_gfx)if (entering_gfx) {hide_cursor (vc);save_screen (vc); - vc->vc_sw->con_blank (vc,-1 ,1 ); + vc->vc_sw->con_blank (vc,1 ,1 ); console_blanked = fg_console +1 ; blank_state = blank_off;set_origin (vc);
drivers/video/console/vgacon.c +0 -1
@@ -814,7 +814,6 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch)/* Tell console.c that it has to restore the screen itself */ return 1 ;case 1 :/* Normal blanking */ -case -1 :/* Obsolete */ if (!mode_switch && vga_video_type ==VIDEO_TYPE_VGAC ) {vga_pal_blank (&vgastate); vga_palette_blanked = true;
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 32/47 tty: vt: define a common enum for VESA blanking constants
In reply to Jiri Slaby (SUSE)There are currently two places with VESA blanking constants definitions:fb.h and console.h. Extract/unify the two to a separate header (vesa.h).
Given the fb's is in an uapi header, create the common header in uapi too.
Note that instead of macros, an enum (vesa_blank_mode) is created. But the macros are kept too (they now expand to the enum constants), just in case someone in userspace performs some #ifdeffery.
---
Notes:
[v2] new in v2
include/linux/console.h | 7 +------ include/uapi/linux/fb.h | 8 +------- include/uapi/linux/vesa.h | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 include/uapi/linux/vesa.h
include/linux/console.h +1 -6
@@ -18,6 +18,7 @@#include <linux/bits.h> #include <linux/rculist.h> #include <linux/types.h> +#include <linux/vesa.h> struct vc_data ;struct console_font_op ;
@@ -520,12 +521,6 @@ void vcs_remove_sysfs(int index);*/ extern atomic_t ignore_console_lock_warning; -/* VESA Blanking Levels */ -#define VESA_NO_BLANKING 0 -#define VESA_VSYNC_SUSPEND 1 -#define VESA_HSYNC_SUSPEND 2 -#define VESA_POWERDOWN 3 -extern void console_init (void );/* For deferred console takeover */
include/uapi/linux/fb.h +1 -7
@@ -4,6 +4,7 @@#include <linux/types.h> #include <linux/i2c.h> +#include <linux/vesa.h> /* Definitions of frame buffers */
@@ -293,13 +294,6 @@ struct fb_con2fbmap {__u32 framebuffer; }; -/* VESA Blanking Levels */ -#define VESA_NO_BLANKING 0 -#define VESA_VSYNC_SUSPEND 1 -#define VESA_HSYNC_SUSPEND 2 -#define VESA_POWERDOWN 3 - -enum {/* screen: unblanked, hsync: on, vsync: on */ FB_BLANK_UNBLANK =VESA_NO_BLANKING ,
include/uapi/linux/vesa.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_VESA_H +#define _UAPI_LINUX_VESA_H + +/* VESA Blanking Levels */ +enum vesa_blank_mode { +VESA_NO_BLANKING =0 , +#define VESA_NO_BLANKING VESA_NO_BLANKING + VESA_VSYNC_SUSPEND = 1, +#define VESA_VSYNC_SUSPEND VESA_VSYNC_SUSPEND + VESA_HSYNC_SUSPEND = 2, +#define VESA_HSYNC_SUSPEND VESA_HSYNC_SUSPEND + VESA_POWERDOWN = VESA_VSYNC_SUSPEND | VESA_HSYNC_SUSPEND, +#define VESA_POWERDOWN VESA_POWERDOWN + VESA_BLANK_MAX = VESA_POWERDOWN, +}; + +#endif
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 33/47 tty: vt: use VESA blanking constants
In reply to Jiri Slaby (SUSE)There are VESA blanking constants defined in vesa.h. So use them in the console code instead of constant values.
---
Notes:
[v2] reword the commit log after vesa.h introduction
drivers/tty/vt/vt.c | 9 +++++---- drivers/video/console/newport_con.c | 2 +- drivers/video/console/sticon.c | 2 +- drivers/video/console/vgacon.c | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-)
drivers/tty/vt/vt.c +5 -4
@@ -4320,7 +4320,7 @@ static int set_vesa_blanking(u8 __user *mode_user)return -EFAULT ;console_lock (); - vesa_blank_mode = (mode <4 ) ? mode :0 ; + vesa_blank_mode = (mode <4 ) ? mode :VESA_NO_BLANKING ;console_unlock ();return 0 ;
@@ -4347,7 +4347,7 @@ void do_blank_screen(int entering_gfx)if (entering_gfx) {hide_cursor (vc);save_screen (vc); - vc->vc_sw->con_blank (vc,1 ,1 ); + vc->vc_sw->con_blank (vc,VESA_VSYNC_SUSPEND ,1 ); console_blanked = fg_console +1 ; blank_state = blank_off;set_origin (vc);
@@ -4368,7 +4368,8 @@ void do_blank_screen(int entering_gfx)save_screen (vc);/* In case we need to reset origin, blanking hook returns 1 */ - i = vc->vc_sw->con_blank (vc, vesa_off_interval ?1 : (vesa_blank_mode +1 ),0 ); + i = vc->vc_sw->con_blank (vc, vesa_off_interval ?VESA_VSYNC_SUSPEND : + (vesa_blank_mode +1 ),0 ); console_blanked = fg_console +1 ;if (i)set_origin (vc);
@@ -4419,7 +4420,7 @@ void do_unblank_screen(int leaving_gfx) } console_blanked =0 ; -if (vc->vc_sw->con_blank (vc,0 , leaving_gfx)) +if (vc->vc_sw->con_blank (vc,VESA_NO_BLANKING , leaving_gfx))/* Low-level driver cannot restore -> do it ourselves */ update_screen (vc);if (console_blank_hook)
drivers/video/console/newport_con.c +1 -1
@@ -480,7 +480,7 @@ static int newport_blank(struct vc_data *c, int blank, int mode_switch) {unsigned short treg; -if (blank ==0 ) { +if (blank ==VESA_NO_BLANKING ) {/* unblank console */ treg =newport_vc2_get (npregs,VC2_IREG_CONTROL ); newport_vc2_set(npregs, VC2_IREG_CONTROL,
drivers/video/console/sticon.c +1 -1
@@ -300,7 +300,7 @@ static bool sticon_switch(struct vc_data *conp)static int sticon_blank (struct vc_data *c,int blank,int mode_switch) { -if (blank ==0 ) { +if (blank ==VESA_NO_BLANKING ) {if (mode_switch) vga_is_gfx =0 ;return 1 ;
drivers/video/console/vgacon.c +3 -3
@@ -800,10 +800,10 @@ static void vga_pal_blank(struct vgastate *state)static int vgacon_blank (struct vc_data *c,int blank,int mode_switch) {switch (blank) { -case 0 :/* Unblank */ +case VESA_NO_BLANKING :/* Unblank */ if (vga_vesa_blanked) {vga_vesa_unblank (&vgastate); - vga_vesa_blanked =0 ; + vga_vesa_blanked =VESA_NO_BLANKING ; }if (vga_palette_blanked) {vga_set_palette (c, color_table);
@@ -813,7 +813,7 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch) vga_is_gfx = false;/* Tell console.c that it has to restore the screen itself */ return 1 ; -case 1 :/* Normal blanking */ +case VESA_VSYNC_SUSPEND :/* Normal blanking */ if (!mode_switch && vga_video_type ==VIDEO_TYPE_VGAC ) {vga_pal_blank (&vgastate); vga_palette_blanked = true;
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 34/47 tty: vt: use enum constants for VESA blanking modes
In reply to Jiri Slaby (SUSE)Use the new enum for VESA constants. This improves type checking in consw::con_blank().
---
Notes:
[v2] the enum is added earlier, so reword and rebase
drivers/tty/vt/vt.c | 4 ++-- drivers/video/console/dummycon.c | 6 ++++-- drivers/video/console/mdacon.c | 3 ++- drivers/video/console/newport_con.c | 3 ++- drivers/video/console/sticon.c | 3 ++- drivers/video/console/vgacon.c | 7 ++++--- drivers/video/fbdev/core/fbcon.c | 3 ++- include/linux/console.h | 3 ++- 8 files changed, 20 insertions(+), 12 deletions(-)
drivers/tty/vt/vt.c +2 -2
@@ -175,7 +175,7 @@ int do_poke_blanked_console;int console_blanked;EXPORT_SYMBOL (console_blanked); -static int vesa_blank_mode;/* 0:none 1:suspendV 2:suspendH 3:powerdown */ +static enum vesa_blank_mode vesa_blank_mode;static int vesa_off_interval;static int blankinterval;core_param (consoleblank, blankinterval, int,0444 );
@@ -4320,7 +4320,7 @@ static int set_vesa_blanking(u8 __user *mode_user)return -EFAULT ;console_lock (); - vesa_blank_mode = (mode <4 ) ? mode :VESA_NO_BLANKING ; + vesa_blank_mode = (mode <=VESA_BLANK_MAX ) ? mode :VESA_NO_BLANKING ;console_unlock ();return 0 ;
drivers/video/console/dummycon.c +4 -2
@@ -79,7 +79,8 @@ static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count,raw_notifier_call_chain (&dummycon_output_nh,0 ,NULL ); } -static int dummycon_blank (struct vc_data *vc,int blank,int mode_switch) +static int dummycon_blank (struct vc_data *vc,enum vesa_blank_mode blank, +int mode_switch) {/* Redraw, so that we get putc(s) for output done while blanked */ return 1 ;
@@ -89,7 +90,8 @@ static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y, unsigned int x) { }static void dummycon_putcs (struct vc_data *vc,const u16 *s,unsigned int count,unsigned int ypos,unsigned int xpos) { } -static int dummycon_blank (struct vc_data *vc,int blank,int mode_switch) +static int dummycon_blank (struct vc_data *vc,enum vesa_blank_mode blank, +int mode_switch) {return 0 ; }
drivers/video/console/mdacon.c +2 -1
@@ -451,7 +451,8 @@ static bool mdacon_switch(struct vc_data *c)return true;/* redrawing needed */ } -static int mdacon_blank (struct vc_data *c,int blank,int mode_switch) +static int mdacon_blank (struct vc_data *c,enum vesa_blank_mode blank, +int mode_switch) {if (mda_type ==TYPE_MDA ) {if (blank)
drivers/video/console/newport_con.c +2 -1
@@ -476,7 +476,8 @@ static bool newport_switch(struct vc_data *vc)return true; } -static int newport_blank (struct vc_data *c,int blank,int mode_switch) +static int newport_blank (struct vc_data *c,enum vesa_blank_mode blank, +int mode_switch) {unsigned short treg;
drivers/video/console/sticon.c +2 -1
@@ -298,7 +298,8 @@ static bool sticon_switch(struct vc_data *conp)return true;/* needs refreshing */ } -static int sticon_blank (struct vc_data *c,int blank,int mode_switch) +static int sticon_blank (struct vc_data *c,enum vesa_blank_mode blank, +int mode_switch) {if (blank ==VESA_NO_BLANKING ) {if (mode_switch)
drivers/video/console/vgacon.c +4 -3
@@ -81,7 +81,7 @@ static unsigned int vga_video_num_lines; /* Number of text lines */static bool vga_can_do_color;/* Do we support colors? */ static unsigned int vga_default_font_height__read_mostly ;/* Height of default screen font */ static unsigned char vga_video_type__read_mostly ;/* Card type */ -static int vga_vesa_blanked; +static enum vesa_blank_mode vga_vesa_blanked;static bool vga_palette_blanked;static bool vga_is_gfx;static bool vga_512_chars;
@@ -683,7 +683,7 @@ static struct {unsigned char ClockingMode;/* Seq-Controller:01h */ } vga_state; -static void vga_vesa_blank (struct vgastate *state,int mode) +static void vga_vesa_blank (struct vgastate *state,enum vesa_blank_mode mode) {/* save original values of VGA controller registers */ if (!vga_vesa_blanked) {
@@ -797,7 +797,8 @@ static void vga_pal_blank(struct vgastate *state) } } -static int vgacon_blank (struct vc_data *c,int blank,int mode_switch) +static int vgacon_blank (struct vc_data *c,enum vesa_blank_mode blank, +int mode_switch) {switch (blank) {case VESA_NO_BLANKING :/* Unblank */
drivers/video/fbdev/core/fbcon.c +2 -1
@@ -2198,7 +2198,8 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, } } -static int fbcon_blank (struct vc_data *vc,int blank,int mode_switch) +static int fbcon_blank (struct vc_data *vc,enum vesa_blank_mode blank, +int mode_switch) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);struct fbcon_ops *ops = info->fbcon_par;
include/linux/console.h +2 -1
@@ -70,7 +70,8 @@ struct consw { unsigned int bottom, enum con_scroll dir, unsigned int lines);bool (*con_switch)(struct vc_data *vc); -int (*con_blank)(struct vc_data *vc,int blank,int mode_switch); +int (*con_blank)(struct vc_data *vc,enum vesa_blank_mode blank, +int mode_switch);int (*con_font_set)(struct vc_data *vc,struct console_font *font,unsigned int vpitch,unsigned int flags); int (*con_font_get)(struct vc_data *vc, struct console_font *font,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 35/47 tty: vt: make types around consw::con_blank() bool
In reply to Jiri Slaby (SUSE)Both the mode_switch parameter and the return value (a redraw needed) are true/false. So switch them to bool, so that users won't return -Eerrors or anything else.
And document the hook.
--- drivers/video/console/dummycon.c | 12 ++++++------ drivers/video/console/mdacon.c | 8 ++++---- drivers/video/console/newport_con.c | 7 ++++--- drivers/video/console/sticon.c | 9 +++++---- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 6 +++--- include/linux/console.h | 7 +++++-- 7 files changed, 29 insertions(+), 24 deletions(-)
drivers/video/console/dummycon.c +6 -6
@@ -79,21 +79,21 @@ static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, raw_notifier_call_chain(&dummycon_output_nh, 0, NULL); } -static int dummycon_blank (struct vc_data *vc,enum vesa_blank_mode blank, -int mode_switch) +static bool dummycon_blank (struct vc_data *vc,enum vesa_blank_mode blank, +bool mode_switch) {/* Redraw, so that we get putc(s) for output done while blanked */ -return 1 ; +return true; }#else static void dummycon_putc (struct vc_data *vc,u16 c,unsigned int y,unsigned int x) { }static void dummycon_putcs (struct vc_data *vc,const u16 *s,unsigned int count,unsigned int ypos,unsigned int xpos) { } -static int dummycon_blank (struct vc_data *vc,enum vesa_blank_mode blank, -int mode_switch) +static bool dummycon_blank (struct vc_data *vc,enum vesa_blank_mode blank, +bool mode_switch) { -return 0 ; +return false; }#endif
drivers/video/console/mdacon.c +4 -4
@@ -451,8 +451,8 @@ static bool mdacon_switch(struct vc_data *c)return true;/* redrawing needed */ } -static int mdacon_blank (struct vc_data *c,enum vesa_blank_mode blank, -int mode_switch) +static bool mdacon_blank (struct vc_data *c,enum vesa_blank_mode blank, +bool mode_switch) {if (mda_type ==TYPE_MDA ) {if (blank)
@@ -460,14 +460,14 @@ static int mdacon_blank(struct vc_data *c, enum vesa_blank_mode blank,mda_convert_attr (c->vc_video_erase_char), c->vc_screenbuf_size);/* Tell console.c that it has to restore the screen itself */ -return 1 ; +return true; }else {if (blank)outb_p (0x00 , mda_mode_port);/* disable video */ else outb_p (MDA_MODE_VIDEO_EN |MDA_MODE_BLINK_EN , mda_mode_port); -return 0 ; +return false; } }
drivers/video/console/newport_con.c +4 -3
@@ -476,8 +476,8 @@ static bool newport_switch(struct vc_data *vc)return true; } -static int newport_blank (struct vc_data *c,enum vesa_blank_mode blank, -int mode_switch) +static bool newport_blank (struct vc_data *c,enum vesa_blank_mode blank, +bool mode_switch) {unsigned short treg;
@@ -492,7 +492,8 @@ static int newport_blank(struct vc_data *c, enum vesa_blank_mode blank,newport_vc2_set (npregs,VC2_IREG_CONTROL , (treg & ~(VC2_CTRL_EDISP ))); } -return 1 ; + +return true; }static int newport_set_font (int unit,struct console_font *op,unsigned int vpitch)
drivers/video/console/sticon.c +5 -4
@@ -298,19 +298,20 @@ static bool sticon_switch(struct vc_data *conp)return true;/* needs refreshing */ } -static int sticon_blank (struct vc_data *c,enum vesa_blank_mode blank, -int mode_switch) +static bool sticon_blank (struct vc_data *c,enum vesa_blank_mode blank, +bool mode_switch) {if (blank ==VESA_NO_BLANKING ) {if (mode_switch) vga_is_gfx =0 ; -return 1 ; +return true; }sti_clear (sticon_sti,0 ,0 , c->vc_rows, c->vc_cols,BLANK , font_data[c->vc_num]);if (mode_switch) vga_is_gfx =1 ; -return 1 ; + +return true; } static u8 sticon_build_attr(struct vc_data *conp, u8 color,
drivers/video/console/vgacon.c +2 -2
@@ -797,8 +797,8 @@ static void vga_pal_blank(struct vgastate *state) } } -static int vgacon_blank (struct vc_data *c,enum vesa_blank_mode blank, -int mode_switch) +static bool vgacon_blank (struct vc_data *c,enum vesa_blank_mode blank, +bool mode_switch) {switch (blank) {case VESA_NO_BLANKING :/* Unblank */
drivers/video/fbdev/core/fbcon.c +3 -3
@@ -2198,8 +2198,8 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, } } -static int fbcon_blank (struct vc_data *vc,enum vesa_blank_mode blank, -int mode_switch) +static bool fbcon_blank (struct vc_data *vc,enum vesa_blank_mode blank, +bool mode_switch) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);struct fbcon_ops *ops = info->fbcon_par;
@@ -2238,7 +2238,7 @@ static int fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank,else fbcon_add_cursor_work (info); -return 0 ; +return false; }static void fbcon_debug_enter (struct vc_data *vc)
include/linux/console.h +5 -2
@@ -49,6 +49,9 @@ enum vc_intensity;* Invoked by csi_M and printing to the console. * @con_switch: notifier about the console switch; it is supposed to return * true if a redraw is needed. +* @con_blank: blank/unblank the console. The target mode is passed in @blank. +* @mode_switch is set if changing from/to text/graphics. The hook +* is supposed to return true if a redraw is needed. * @con_set_palette: sets the palette of the console to @table (optional) * @con_scrolldelta: the contents of the console should be scrolled by @lines. * Invoked by user. (optional)
@@ -70,8 +73,8 @@ struct consw { unsigned int bottom, enum con_scroll dir, unsigned int lines);bool (*con_switch)(struct vc_data *vc); -int (*con_blank)(struct vc_data *vc,enum vesa_blank_mode blank, -int mode_switch); +bool (*con_blank)(struct vc_data *vc,enum vesa_blank_mode blank, +bool mode_switch);int (*con_font_set)(struct vc_data *vc,struct console_font *font,unsigned int vpitch,unsigned int flags); int (*con_font_get)(struct vc_data *vc, struct console_font *font,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 36/47 tty: vt: make font of consw::con_font_set() const
In reply to Jiri Slaby (SUSE)Provided the font parameter of consw::con_font_set() is not supposed to be changed, make it const.
--- drivers/tty/vt/vt.c | 2 +- drivers/video/console/newport_con.c | 5 +++-- drivers/video/console/sticon.c | 4 ++-- drivers/video/console/vgacon.c | 2 +- drivers/video/fbdev/core/fbcon.c | 2 +- include/linux/console.h | 5 +++-- 6 files changed, 11 insertions(+), 9 deletions(-)
drivers/tty/vt/vt.c +1 -1
@@ -4625,7 +4625,7 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)return rc; } -static int con_font_set (struct vc_data *vc,struct console_font_op *op) +static int con_font_set (struct vc_data *vc,const struct console_font_op *op) {struct console_font font;int rc = -EINVAL ;
drivers/video/console/newport_con.c +3 -2
@@ -496,7 +496,8 @@ static bool newport_blank(struct vc_data *c, enum vesa_blank_mode blank,return true; } -static int newport_set_font (int unit,struct console_font *op,unsigned int vpitch) +static int newport_set_font (int unit,const struct console_font *op, +unsigned int vpitch) {int w = op->width;int h = op->height;
@@ -568,7 +569,7 @@ static int newport_font_default(struct vc_data *vc, struct console_font *op, chareturn newport_set_def_font (vc->vc_num, op); } -static int newport_font_set (struct vc_data *vc,struct console_font *font, +static int newport_font_set (struct vc_data *vc,const struct console_font *font,unsigned int vpitch,unsigned int flags) {return newport_set_font (vc->vc_num, font, vpitch);
drivers/video/console/sticon.c +2 -2
@@ -153,7 +153,7 @@ static void sticon_set_def_font(int unit) } } -static int sticon_set_font (struct vc_data *vc,struct console_font *op, +static int sticon_set_font (struct vc_data *vc,const struct console_font *op,unsigned int vpitch) {struct sti_struct *sti = sticon_sti;
@@ -253,7 +253,7 @@ static int sticon_font_default(struct vc_data *vc, struct console_font *op, charreturn 0 ; } -static int sticon_font_set (struct vc_data *vc,struct console_font *font, +static int sticon_font_set (struct vc_data *vc,const struct console_font *font,unsigned int vpitch,unsigned int flags) {return sticon_set_font (vc, font, vpitch);
drivers/video/console/vgacon.c +1 -1
@@ -1039,7 +1039,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight)return 0 ; } -static int vgacon_font_set (struct vc_data *c,struct console_font *font, +static int vgacon_font_set (struct vc_data *c,const struct console_font *font,unsigned int vpitch,unsigned int flags) {unsigned charcount = font->charcount;
drivers/video/fbdev/core/fbcon.c +1 -1
@@ -2460,7 +2460,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,* but lets not assume that, since charcount of 512 is small for unicode support. */ -static int fbcon_set_font (struct vc_data *vc,struct console_font *font, +static int fbcon_set_font (struct vc_data *vc,const struct console_font *font,unsigned int vpitch,unsigned int flags) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);
include/linux/console.h +3 -2
@@ -75,8 +75,9 @@ struct consw {bool (*con_switch)(struct vc_data *vc);bool (*con_blank)(struct vc_data *vc,enum vesa_blank_mode blank,bool mode_switch); -int (*con_font_set)(struct vc_data *vc,struct console_font *font, -unsigned int vpitch,unsigned int flags); +int (*con_font_set)(struct vc_data *vc, +const struct console_font *font, +unsigned int vpitch,unsigned int flags);int (*con_font_get)(struct vc_data *vc,struct console_font *font,unsigned int vpitch); int (*con_font_default)(struct vc_data *vc,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 37/47 tty: vt: make consw::con_font_default()'s name const
In reply to Jiri Slaby (SUSE)It's a name after all and that is not supposed to be changed. So make it const to make this obvious.
--- drivers/video/console/newport_con.c | 3 ++- drivers/video/console/sticon.c | 3 ++- drivers/video/fbdev/core/fbcon.c | 3 ++- include/linux/console.h | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-)
drivers/video/console/newport_con.c +2 -1
@@ -564,7 +564,8 @@ static int newport_set_def_font(int unit, struct console_font *op)return 0 ; } -static int newport_font_default (struct vc_data *vc,struct console_font *op,char *name) +static int newport_font_default (struct vc_data *vc,struct console_font *op, +const char *name) {return newport_set_def_font (vc->vc_num, op); }
drivers/video/console/sticon.c +2 -1
@@ -246,7 +246,8 @@ static int sticon_set_font(struct vc_data *vc, const struct console_font *op,return 0 ; } -static int sticon_font_default (struct vc_data *vc,struct console_font *op,char *name) +static int sticon_font_default (struct vc_data *vc,struct console_font *op, +const char *name) {sticon_set_def_font (vc->vc_num);
drivers/video/fbdev/core/fbcon.c +2 -1
@@ -2533,7 +2533,8 @@ static int fbcon_set_font(struct vc_data *vc, const struct console_font *font,return fbcon_do_set_font (vc, font->width, font->height, charcount, new_data,1 ); } -static int fbcon_set_def_font (struct vc_data *vc,struct console_font *font,char *name) +static int fbcon_set_def_font (struct vc_data *vc,struct console_font *font, +const char *name) {struct fb_info *info =fbcon_info_from_console (vc->vc_num);const struct font_desc *f;
include/linux/console.h +1 -1
@@ -81,7 +81,7 @@ struct consw {int (*con_font_get)(struct vc_data *vc,struct console_font *font,unsigned int vpitch);int (*con_font_default)(struct vc_data *vc, -struct console_font *font,char *name); +struct console_font *font,const char *name);int (*con_resize)(struct vc_data *vc,unsigned int width,unsigned int height,bool from_user); void (*con_set_palette)(struct vc_data *vc,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 38/47 tty: vt: change consw::con_set_origin() return type
In reply to Jiri Slaby (SUSE)The return value of consw::con_set_origin() is only true/false, meaining if vc->vc_origin is set to vc->vc_screenbuf or not.
So switch the type and returned values accordingly.
And document the hook.
--- drivers/video/console/vgacon.c | 8 ++++---- include/linux/console.h | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/video/console/vgacon.c +4 -4
@@ -65,7 +65,7 @@ static struct vgastate vgastate;* Interface used by the world */ -static int vgacon_set_origin (struct vc_data *c); +static bool vgacon_set_origin (struct vc_data *c);static struct uni_pagedict *vgacon_uni_pagedir;static int vgacon_refcount;
@@ -1100,15 +1100,15 @@ static int vgacon_resize(struct vc_data *c, unsigned int width,return 0 ; } -static int vgacon_set_origin (struct vc_data *c) +static bool vgacon_set_origin (struct vc_data *c) {if (vga_is_gfx ||/* We don't play origin tricks in graphic modes */ (console_blanked && !vga_palette_blanked))/* Nor we write to blanked screens */ -return 0 ; +return false; c->vc_origin = c->vc_visible_origin = vga_vram_base;vga_set_mem_top (c); vga_rolled_over =0 ; -return 1 ; +return true; }static void vgacon_save_screen (struct vc_data *c)
include/linux/console.h +4 -1
@@ -55,6 +55,9 @@ enum vc_intensity;* @con_set_palette: sets the palette of the console to @table (optional) * @con_scrolldelta: the contents of the console should be scrolled by @lines. * Invoked by user. (optional) +* @con_set_origin: set origin (see &vc_data::vc_origin) of the @vc. If not +* provided or returns false, the origin is set to +* @vc->vc_screenbuf. (optional) */ struct consw {struct module *owner;
@@ -87,7 +90,7 @@ struct consw {void (*con_set_palette)(struct vc_data *vc,const unsigned char *table);void (*con_scrolldelta)(struct vc_data *vc,int lines); -int (*con_set_origin)(struct vc_data *vc); +bool (*con_set_origin)(struct vc_data *vc);void (*con_save_screen)(struct vc_data *vc); u8 (*con_build_attr)(struct vc_data *vc, u8 color, enum vc_intensity intensity,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 39/47 fbcon: remove consw::con_screen_pos()
In reply to Jiri Slaby (SUSE)fbcon_screen_pos() performs the same as the default implementation. The only difference in the default implementation is that is considers both vc->vc_origin and vc->vc_visible_origin. But given fbcon's softscroll code was already removed in commit 50145474f6ef (fbcon: remove soft scrollback code), both are always the same.
So remove fbcon_screen_pos() too.
--- drivers/video/fbdev/core/fbcon.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/video/fbdev/core/fbcon.c +0 -6
@@ -2593,11 +2593,6 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table)fb_set_cmap (&palette_cmap, info); } -static u16 *fbcon_screen_pos (const struct vc_data *vc,int offset) -{ -return (u16 *) (vc->vc_origin + offset); -} -static unsigned long fbcon_getxy (struct vc_data *vc,unsigned long pos,int *px,int *py) {
@@ -3162,7 +3157,6 @@ static const struct consw fb_con = { .con_font_default = fbcon_set_def_font, .con_set_palette = fbcon_set_palette, .con_invert_region = fbcon_invert_region, - .con_screen_pos = fbcon_screen_pos, .con_getxy = fbcon_getxy, .con_resize = fbcon_resize, .con_debug_enter = fbcon_debug_enter,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 40/47 tty: vt: remove consw::con_screen_pos()
In reply to Jiri Slaby (SUSE)After the previous patch, nobody sets that hook. So drop it completely.
--- drivers/tty/vt/vt.c | 12 +++--------- include/linux/console.h | 1 - 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/tty/vt/vt.c +3 -9
@@ -289,15 +289,9 @@ static inline bool con_should_update(const struct vc_data *vc)static inline unsigned short *screenpos (const struct vc_data *vc,int offset,bool viewed) { -unsigned short *p; - -if (!viewed) - p = (unsigned short *)(vc->vc_origin + offset); -else if (!vc->vc_sw->con_screen_pos) - p = (unsigned short *)(vc->vc_visible_origin + offset); -else - p = vc->vc_sw->con_screen_pos (vc, offset); -return p; +unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin; + +return (unsigned short *)(origin + offset); }static void con_putc (struct vc_data *vc,u16 ca,unsigned int y,unsigned int x)
include/linux/console.h +0 -1
@@ -96,7 +96,6 @@ struct consw {enum vc_intensity intensity, bool blink, bool underline, bool reverse, bool italic);void (*con_invert_region)(struct vc_data *vc,u16 *p,int count); -u16 *(*con_screen_pos)(const struct vc_data *vc,int offset);unsigned long (*con_getxy)(struct vc_data *vc,unsigned long position,int *px,int *py);/*
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 41/47 tty: vt: make types of screenpos() more consistent
In reply to Jiri Slaby (SUSE)* parameter offset: it is expected to be non-negative, so switch to unsigned
* return type: switch from ushort to explicit u16. This is expected on most places. And fix the remaining two places too.
--- drivers/tty/vt/vt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/tty/vt/vt.c +5 -6
@@ -286,12 +286,12 @@ static inline bool con_should_update(const struct vc_data *vc)return con_is_visible (vc) && !console_blanked; } -static inline unsigned short *screenpos (const struct vc_data *vc,int offset, -bool viewed) +static inline u16 *screenpos (const struct vc_data *vc,unsigned int offset, +bool viewed) {unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin; -return (unsigned short *)(origin + offset); +return (u16 *)(origin + offset); }static void con_putc (struct vc_data *vc,u16 ca,unsigned int y,unsigned int x)
@@ -705,7 +705,7 @@ static void update_attr(struct vc_data *vc)/* Note: inverting the screen twice should revert to the original state */ void invert_screen (struct vc_data *vc,int offset,int count,bool viewed) { -unsigned short *p; +u16 *p;WARN_CONSOLE_UNLOCKED ();
@@ -773,8 +773,7 @@ void complement_pos(struct vc_data *vc, int offset)if (offset !=-1 && offset >=0 && offset < vc->vc_screenbuf_size) {unsigned short new; -unsigned short *p; - p =screenpos (vc, offset, true); +u16 *p =screenpos (vc, offset, true); old =scr_readw (p); new = old ^ vc->vc_complement_mask;scr_writew (new, p);
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 42/47 fbcon: remove fbcon_getxy()
In reply to Jiri Slaby (SUSE)Again, fbcon_getxy() is the same as the default implementation since the softscroll removal in commit 50145474f6ef (fbcon: remove soft scrollback code). Drop that.
--- drivers/video/fbdev/core/fbcon.c | 25 ------------------------- 1 file changed, 25 deletions(-)
drivers/video/fbdev/core/fbcon.c +0 -25
@@ -2593,30 +2593,6 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table)fb_set_cmap (&palette_cmap, info); } -static unsigned long fbcon_getxy (struct vc_data *vc,unsigned long pos, -int *px,int *py) -{ -unsigned long ret; -int x, y; - -if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { -unsigned long offset = (pos - vc->vc_origin) /2 ; - - x = offset % vc->vc_cols; - y = offset / vc->vc_cols; - ret = pos + (vc->vc_cols - x) *2 ; - }else { -/* Should not happen */ - x = y =0 ; - ret = vc->vc_origin; - } -if (px) - *px = x; -if (py) - *py = y; -return ret; -} -/* As we might be inside of softback, we may work with non-contiguous buffer, that's why we have to use a separate routine. */ static void fbcon_invert_region (struct vc_data *vc,u16 * p,int cnt)
@@ -3157,7 +3133,6 @@ static const struct consw fb_con = { .con_font_default = fbcon_set_def_font, .con_set_palette = fbcon_set_palette, .con_invert_region = fbcon_invert_region, - .con_getxy = fbcon_getxy, .con_resize = fbcon_resize, .con_debug_enter = fbcon_debug_enter, .con_debug_leave = fbcon_debug_leave,
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 43/47 tty: vt: remove consw::con_getxy()
In reply to Jiri Slaby (SUSE)After the previous patch, nobody sets that hook. So drop it completely.
--- drivers/tty/vt/vt.c | 20 +++++--------------- include/linux/console.h | 2 -- 2 files changed, 5 insertions(+), 17 deletions(-)
drivers/tty/vt/vt.c +5 -15
@@ -593,18 +593,12 @@ static void con_scroll(struct vc_data *vc, unsigned int top,static void do_update_region (struct vc_data *vc,unsigned long start,int count) {unsigned int xx, yy, offset; -u16 *p; +u16 *p = (u16 *)start; + + offset = (start - vc->vc_origin) /2 ; + xx = offset % vc->vc_cols; + yy = offset / vc->vc_cols; - p = (u16 *) start; -if (!vc->vc_sw->con_getxy) { - offset = (start - vc->vc_origin) /2 ; - xx = offset % vc->vc_cols; - yy = offset / vc->vc_cols; - }else { -int nxx, nyy; - start = vc->vc_sw->con_getxy (vc, start, &nxx, &nyy); - xx = nxx; yy = nyy; - }for (;;) {u16 attrib =scr_readw (p) &0xff00 ;int startx = xx;
@@ -627,10 +621,6 @@ static void do_update_region(struct vc_data *vc, unsigned long start, int count)break ; xx =0 ; yy++; -if (vc->vc_sw->con_getxy) { - p = (u16 *)start; - start = vc->vc_sw->con_getxy (vc, start,NULL ,NULL ); - } } }
include/linux/console.h +0 -2
@@ -96,8 +96,6 @@ struct consw {enum vc_intensity intensity, bool blink, bool underline, bool reverse, bool italic);void (*con_invert_region)(struct vc_data *vc,u16 *p,int count); -unsigned long (*con_getxy)(struct vc_data *vc,unsigned long position, -int *px,int *py);/* * Flush the video console driver's scrollback buffer */
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 44/47 tty: vt: remove unused consw::con_flush_scrollback()
In reply to Jiri Slaby (SUSE)consw::con_flush_scrollback() is unused since commit 973c096f6a85 (vgacon: remove software scrollback support). Drop it.
--- drivers/tty/vt/vt.c | 27 ++++++++++++--------------- include/linux/console.h | 4 ---- 2 files changed, 12 insertions(+), 19 deletions(-)
drivers/tty/vt/vt.c +12 -15
@@ -888,21 +888,18 @@ static void flush_scrollback(struct vc_data *vc)WARN_CONSOLE_UNLOCKED ();set_origin (vc); -if (vc->vc_sw->con_flush_scrollback) { - vc->vc_sw->con_flush_scrollback (vc); - }else if (con_is_visible (vc)) { -/* -* When no con_flush_scrollback method is provided then the -* legacy way for flushing the scrollback buffer is to use -* a side effect of the con_switch method. We do it only on -* the foreground console as background consoles have no -* scrollback buffers in that case and we obviously don't -* want to switch to them. -*/ -hide_cursor (vc); - vc->vc_sw->con_switch (vc); -set_cursor (vc); - } +if (!con_is_visible (vc)) +return ; + +/* +* The legacy way for flushing the scrollback buffer is to use a side +* effect of the con_switch method. We do it only on the foreground +* console as background consoles have no scrollback buffers in that +* case and we obviously don't want to switch to them. +*/ +hide_cursor (vc); + vc->vc_sw->con_switch (vc); +set_cursor (vc); }/*
include/linux/console.h +0 -4
@@ -96,10 +96,6 @@ struct consw {enum vc_intensity intensity, bool blink, bool underline, bool reverse, bool italic);void (*con_invert_region)(struct vc_data *vc,u16 *p,int count); -/* -* Flush the video console driver's scrollback buffer -*/ -void (*con_flush_scrollback)(struct vc_data *vc);/* * Prepare the console for the debugger. This includes, but is not * limited to, unblanking the console, loading an appropriate
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 45/47 tty: vt: document the rest of struct consw
In reply to Jiri Slaby (SUSE)There are still members of struct consw which are not documented yet. Fix that up, so we can generate kernel-doc for that struct.
--- include/linux/console.h | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
include/linux/console.h +25 -9
@@ -37,8 +37,11 @@ enum vc_intensity;/** * struct consw - callbacks for consoles * +* @owner: the module to get references of when this console is used +* @con_startup: set up the console and return its name (like VGA, EGA, ...) * @con_init: initialize the console on @vc. @init is true for the very first * call on this @vc. +* @con_deinit: deinitialize the console from @vc. * @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. * @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. * (optional -- @con_putcs would be called instead)
@@ -52,12 +55,33 @@ enum vc_intensity;* @con_blank: blank/unblank the console. The target mode is passed in @blank. * @mode_switch is set if changing from/to text/graphics. The hook * is supposed to return true if a redraw is needed. -* @con_set_palette: sets the palette of the console to @table (optional) +* @con_font_set: set console @vc font to @font with height @vpitch. @flags can +* be %KD_FONT_FLAG_DONT_RECALC. (optional) +* @con_font_get: fetch the current font on @vc of height @vpitch into @font. +* (optional) +* @con_font_default: set default font on @vc. @name can be %NULL or font name +* to search for. @font can be filled back. (optional) +* @con_resize: resize the @vc console to @width x @height. @from_user is true +* when this change comes from the user space. +* @con_set_palette: sets the palette of the console @vc to @table (optional) * @con_scrolldelta: the contents of the console should be scrolled by @lines. * Invoked by user. (optional) * @con_set_origin: set origin (see &vc_data::vc_origin) of the @vc. If not * provided or returns false, the origin is set to * @vc->vc_screenbuf. (optional) +* @con_save_screen: save screen content into @vc->vc_screenbuf. Called e.g. +* upon entering graphics. (optional) +* @con_build_attr: build attributes based on @color, @intensity and other +* parameters. The result is used for both normal and erase +* characters. (optional) +* @con_invert_region: invert a region of length @count on @vc starting at @p. +* (optional) +* @con_debug_enter: prepare the console for the debugger. This includes, but +* is not limited to, unblanking the console, loading an +* appropriate palette, and allowing debugger generated output. +* (optional) +* @con_debug_leave: restore the console to its pre-debug state as closely as +* possible. (optional) */ struct consw {struct module *owner;
@@ -96,15 +120,7 @@ struct consw {enum vc_intensity intensity, bool blink, bool underline, bool reverse, bool italic);void (*con_invert_region)(struct vc_data *vc,u16 *p,int count); -/* -* Prepare the console for the debugger. This includes, but is not -* limited to, unblanking the console, loading an appropriate -* palette, and allowing debugger generated output. -*/ void (*con_debug_enter)(struct vc_data *vc); -/* -* Restore the console to its pre-debug state as closely as possible. -*/ void (*con_debug_leave)(struct vc_data *vc); };
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 46/47 tty: vt: fix up kernel-doc
In reply to Jiri Slaby (SUSE)selection.c and vt.c still uses tabs in the kernel-doc. This misrenders the functions in the output -- sphinx misinterprets the description. So remove these tabs, incl. those around dashes.
'enum' keyword is needed before enum names. Fix that.
Superfluous \n after the comments are also removed. They are not completely faulty, but this unifies all the kernel-doc in the files.
Finally fix up the cross references.
--- drivers/tty/vt/selection.c | 30 ++++++------- drivers/tty/vt/vt.c | 86 +++++++++++++++++++------------------- include/linux/console.h | 6 +-- 3 files changed, 62 insertions(+), 60 deletions(-)
drivers/tty/vt/selection.c +16 -14
@@ -73,10 +73,12 @@ sel_pos(int n, bool unicode) }/** -* clear_selection - remove current selection +* clear_selection - remove current selection * -* Remove the current selection highlight, if any from the console -* holding the selection. The caller must hold the console lock. +* Remove the current selection highlight, if any from the console holding the +* selection. +* +* Locking: The caller must hold the console lock. */ void clear_selection (void ) {
@@ -110,13 +112,13 @@ static inline int inword(const u32 c) }/** -* sel_loadlut() - load the LUT table -* @lut: user table +* sel_loadlut() - load the LUT table +* @lut: user table * -* Load the LUT table from user space. Make a temporary copy so a partial -* update doesn't make a mess. +* Load the LUT table from user space. Make a temporary copy so a partial +* update doesn't make a mess. * -* Locking: The console lock is acquired. +* Locking: The console lock is acquired. */ int sel_loadlut (u32 __user *lut) {
@@ -173,14 +175,14 @@ static int store_utf8(u32 c, char *p) }/** -* set_selection_user - set the current selection. -* @sel: user selection info -* @tty: the console tty +* set_selection_user - set the current selection. +* @sel: user selection info +* @tty: the console tty * -* Invoked by the ioctl handle for the vt layer. +* Invoked by the ioctl handle for the vt layer. * -* The entire selection process is managed under the console_lock. It's -* a lot under the lock but its hardly a performance path +* Locking: The entire selection process is managed under the console_lock. +* It's a lot under the lock but its hardly a performance path. */ int set_selection_user (const struct tiocl_selection __user *sel,struct tty_struct *tty)
drivers/tty/vt/vt.c +43 -43
149 lines not on this page · raw message
include/linux/console.h +3 -3
@@ -155,7 +155,7 @@ static inline void con_debug_leave(void) { }*/ /** -* cons_flags - General console flags +* enum cons_flags - General console flags * @CON_PRINTBUFFER: Used by newly registered consoles to avoid duplicate * output of messages that were already shown by boot * consoles or read by userspace via syslog() syscall.
@@ -236,7 +236,7 @@ struct nbcon_state {static_assert (sizeof (struct nbcon_state ) <=sizeof (int ));/** -* nbcon_prio - console owner priority for nbcon consoles +* enum nbcon_prio - console owner priority for nbcon consoles * @NBCON_PRIO_NONE: Unused * @NBCON_PRIO_NORMAL: Normal (non-emergency) usage * @NBCON_PRIO_EMERGENCY: Emergency output (WARN/OOPS...)
@@ -468,7 +468,7 @@ static inline bool console_is_registered(const struct console *con)* for_each_console() - Iterator over registered consoles * @con: struct console pointer used as loop cursor * -* The console list and the console->flags are immutable while iterating. +* The console list and the &console.flags are immutable while iterating. * * Requires console_list_lock to be held. */
Signature · 1 line
2.43.0
Jiri Slaby (SUSE)
maintainerPATCH v2 47/47 Documentation: add console.rst
In reply to Jiri Slaby (SUSE)Now, that the console kernel-doc is in better shape, include it in the tty/ docs.
It's not supernice, but it is what it is. At least for the beginning.
--- Documentation/driver-api/tty/console.rst | 45 ++++++++++++++++++++++++ Documentation/driver-api/tty/index.rst | 1 + 2 files changed, 46 insertions(+) create mode 100644 Documentation/driver-api/tty/console.rst
Documentation/driver-api/tty/console.rst new file +45 -0
@@ -0,0 +1,45 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======= +Console +======= + +.. contents:: :local: + +Struct Console +============== + +.. kernel-doc:: include/linux/console.h + :identifiers: console cons_flags + +Internals +--------- + +.. kernel-doc:: include/linux/console.h + :identifiers: nbcon_state nbcon_prio nbcon_context nbcon_write_context + +Struct Consw +============ + +.. kernel-doc:: include/linux/console.h + :identifiers: consw + +Console functions +================= + +.. kernel-doc:: include/linux/console.h + :identifiers: console_srcu_read_flags console_srcu_write_flags + console_is_registered for_each_console_srcu for_each_console + +.. kernel-doc:: drivers/tty/vt/selection.c + :export: +.. kernel-doc:: drivers/tty/vt/vt.c + :export: + +Internals +--------- + +.. kernel-doc:: drivers/tty/vt/selection.c + :internal: +.. kernel-doc:: drivers/tty/vt/vt.c + :internal:
Documentation/driver-api/tty/index.rst +1 -0
@@ -38,6 +38,7 @@ In-detail description of the named TTY structures is in separate documents: tty_buffer tty_ioctl tty_internals + console Writing TTY Driver ==================
Signature · 1 line
2.43.0
Quoted 6 lines · Jiri Slaby (SUSE)
Push the console code (
vt.c,vt.h,console.h, ...) into a bit more maintainable state. Especially all around consw structure and document it.CSI parser is also a bit cleaned up. More to follow some time in the next round.
I've not yet looked through all of those patches, but I tried to boot up a machine with the STI console driver and I've not seen any issues yet.
So far:
Helge
Quoted 92 lines
[v2] See respective patches for changes. The major changes:
*vesa.hintroduced
* parameters of csi*() simplifiedCc Daniel Vetter <[email protected]>Cc Helge Deller <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Martin Hostettler <[email protected]>Cc Thomas Zimmermann <[email protected]>Jiri Slaby (SUSE) (47):
vgacon: inline
vc_scrolldelta_helper()intovgacon_scrolldelta()
fbcon: makedisplay_desca static array infbcon_startup()
tty: vt: fix 20 vs0x20typo in EScsiignore
tty: vt: expect valid vc when in tty ops
tty: vt: pass proper pointers fromtioclinux()
tty: vt: push console lock fromtioclinux()down to 2 functions
tty: vt: passvc_resize_useras a parameter
tty: vt: make vc_is_sel()'s vc const
tty: vt: define an enum for CSI+m codes
tty: vt: use case ranges for CSI+m fg/bg colors
tty: vt: define an enum for CSI+J codes
tty: vt: reflowcsi_J()
useclamp()for counts in csi_?() handlers
don't pass vc->vc_par[0] to csi_?() handlers
tty: vt: define an enum for CSI+K codes
tty: vt: reflowcsi_K()
tty: vt: define an enum for ascii characters
tty: vt: remove extern from functions inselection.h
tty: vt: make consw::con_debug_*() return void
tty: vt: make init parameter ofconsw::con_init()a bool
tty: vt: sanitize arguments ofconsw::con_clear()
tty: vt: remove checks for count inconsw::con_clear()implementations
tty: vt: addcon_putc()helper
tty: vt: eliminate unneededconsw::con_putc()implementations
tty: vt: sanitizeconsw::con_putc()parameters
tty: vt: sanitizeconsw::con_putcs()parameters
consoles: use if instead of switch-case inconsw::con_cursor()fbdev/core: simplifycursor_statesetting infbcon_ops::cursor()
tty: vt: remove CM_* constants
tty: vt: makeconsw::con_switch()return a bool
tty: vt: stop using -1 for blank mode inconsw::con_blank()
tty: vt: define a common enum for VESA blanking constants
tty: vt: use VESA blanking constants
tty: vt: use enum constants for VESA blanking modes
tty: vt: make types aroundconsw::con_blank()bool
tty: vt: make font ofconsw::con_font_set()const
tty: vt: make consw::con_font_default()'s name const
tty: vt: changeconsw::con_set_origin()return type
fbcon: removeconsw::con_screen_pos()
tty: vt: removeconsw::con_screen_pos()
tty: vt: make types ofscreenpos()more consistent
fbcon: removefbcon_getxy()
tty: vt: removeconsw::con_getxy()
tty: vt: remove unusedconsw::con_flush_scrollback()
tty: vt: document the rest of struct consw
tty: vt: fix up kernel-doc
Documentation: addconsole.rstDocumentation/driver-api/tty/console.rst | 45 ++ Documentation/driver-api/tty/index.rst | 1 + drivers/tty/vt/selection.c | 43 +- drivers/tty/vt/vt.c | 645 +++++++++++------------ drivers/tty/vt/vt_ioctl.c | 6 +- drivers/video/console/dummycon.c | 38 +- drivers/video/console/mdacon.c | 43 +- drivers/video/console/newport_con.c | 69 +-- drivers/video/console/sticon.c | 79 ++- drivers/video/console/vgacon.c | 152 +++--- drivers/video/fbdev/core/bitblit.c | 13 +- drivers/video/fbdev/core/fbcon.c | 123 ++--- drivers/video/fbdev/core/fbcon.h | 4 +- drivers/video/fbdev/core/fbcon_ccw.c | 13 +- drivers/video/fbdev/core/fbcon_cw.c | 13 +- drivers/video/fbdev/core/fbcon_ud.c | 13 +- drivers/video/fbdev/core/tileblit.c | 4 +- include/linux/console.h | 124 +++-- include/linux/console_struct.h | 1 - include/linux/selection.h | 56 +- include/linux/vt_kern.h | 12 +- include/uapi/linux/fb.h | 8 +- include/uapi/linux/vesa.h | 18 + 23 files changed, 755 insertions(+), 768 deletions(-)create mode 100644
Documentation/driver-api/tty/console.rstcreate mode 100644include/uapi/linux/vesa.h
Re: [PATCH v2 46/47] tty: vt: fix up kernel-doc
In reply to Jiri Slaby (SUSE)Quoted 4 lines · Jiri Slaby (SUSE)
selection.candvt.cstill uses tabs in the kernel-doc. This misrenders the functions in the output -- sphinx misinterprets the description. So remove these tabs, incl. those around dashes.
Quoted 8 lines
'enum' keyword is needed before enum names. Fix that.
Superfluous \n after the comments are also removed. They are not completely faulty, but this unifies all the kernel-doc in the files.
Finally fix up the cross references.
Signed-off-by Jiri Slaby (SUSE) <[email protected]>
Thanks.
Quoted 6 lines
--- drivers/tty/vt/selection.c | 30 ++++++------- drivers/tty/vt/vt.c | 86 +++++++++++++++++++------------------- include/linux/console.h | 6 +-- 3 files changed, 62 insertions(+), 60 deletions(-)
Signature · 1 line
#Randy