2009-09-04 15:42:16

by Matthew Garrett

[permalink] [raw]
Subject: [PATCH] VT: Add a boot option to disable cursor on boot

The VT code currently enables a visible cursor on boot. This is a fairly
unnecessary visual distraction for setups which boot to a splash screen
before going directly into X, so add a boot option (vt.hide_boot_cursor=1)
that doesn't enable the cursor for initial VT setup. VT resets and any
later VT creation will leave the cursor turned on, as before.

Signed-off-by: Matthew Garrett <[email protected]>
---
Documentation/kernel-parameters.txt | 6 ++++++
drivers/char/vt.c | 23 ++++++++++++++---------
2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 7936b80..c60ce61 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2645,6 +2645,12 @@ and is between 256 and 4096 characters. It is defined in the file
Default is 1, i.e. UTF-8 mode is enabled for all
newly opened terminals.

+ vt.hide_boot_cursor=
+ [VT]
+ Format=<0|1>
+ Hide the VT cursor on boot. Default is 0, resulting
+ in the cursor being shown by default.
+
waveartist= [HW,OSS]
Format: <io>,<irq>,<dma>,<dma2>

diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 404f4c1..a885311 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -146,10 +146,12 @@ static const struct consw *con_driver_map[MAX_NR_CONSOLES];

static int con_open(struct tty_struct *, struct file *);
static void vc_init(struct vc_data *vc, unsigned int rows,
- unsigned int cols, int do_clear);
+ unsigned int cols, int do_clear,
+ int show_cursor);
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 reset_terminal(struct vc_data *vc, int do_clear,
+ int show_cursor);
static void con_flush_chars(struct tty_struct *tty);
static int set_vesa_blanking(char __user *p);
static void set_cursor(struct vc_data *vc);
@@ -159,6 +161,8 @@ static void blank_screen_t(unsigned long dummy);
static void set_palette(struct vc_data *vc);

static int printable; /* Is console ready for printing? */
+static int hide_boot_cursor; /* Show the cursor at boot time? */
+module_param(hide_boot_cursor, int, S_IRUGO | S_IWUSR);
int default_utf8 = true;
module_param(default_utf8, int, S_IRUGO | S_IWUSR);

@@ -776,7 +780,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
vc_cons[currcons].d = NULL;
return -ENOMEM;
}
- vc_init(vc, vc->vc_rows, vc->vc_cols, 1);
+ vc_init(vc, vc->vc_rows, vc->vc_cols, 1, 1);
vcs_make_sysfs(currcons);
atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param);
}
@@ -1595,7 +1599,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
ESpalette };

/* console_sem is held (except via vc_init()) */
-static void reset_terminal(struct vc_data *vc, int do_clear)
+static void reset_terminal(struct vc_data *vc, int do_clear, int show_cursor)
{
vc->vc_top = 0;
vc->vc_bottom = vc->vc_rows;
@@ -1616,7 +1620,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
vc->vc_decscnm = 0;
vc->vc_decom = 0;
vc->vc_decawm = 1;
- vc->vc_deccm = 1;
+ vc->vc_deccm = show_cursor;
vc->vc_decim = 0;

set_kbd(vc, decarm);
@@ -1756,7 +1760,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
vc->vc_state = EShash;
return;
case 'c':
- reset_terminal(vc, 1);
+ reset_terminal(vc, 1, 1);
return;
case '>': /* Numeric keypad */
clr_kbd(vc, kbdapplic);
@@ -2803,7 +2807,7 @@ module_param_named(italic, default_italic_color, int, S_IRUGO | S_IWUSR);
module_param_named(underline, default_underline_color, int, S_IRUGO | S_IWUSR);

static void vc_init(struct vc_data *vc, unsigned int rows,
- unsigned int cols, int do_clear)
+ unsigned int cols, int do_clear, int show_cursor)
{
int j, k ;

@@ -2825,7 +2829,7 @@ static void vc_init(struct vc_data *vc, unsigned int rows,
vc->vc_itcolor = default_italic_color;
vc->vc_halfcolor = 0x08; /* grey */
init_waitqueue_head(&vc->paste_wait);
- reset_terminal(vc, do_clear);
+ reset_terminal(vc, do_clear, show_cursor);
}

/*
@@ -2877,7 +2881,8 @@ static int __init con_init(void)
visual_init(vc, currcons, 1);
vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
vc_init(vc, vc->vc_rows, vc->vc_cols,
- currcons || !vc->vc_sw->con_save_screen);
+ currcons || !vc->vc_sw->con_save_screen,
+ !hide_boot_cursor);
}
currcons = fg_console = 0;
master_display_fg = vc = vc_cons[currcons].d;
--
1.6.4.1


2009-09-04 16:15:10

by Matthew Garrett

[permalink] [raw]
Subject: Re: [PATCH] VT: Add a boot option to disable cursor on boot

On Fri, Sep 04, 2009 at 06:03:02PM +0100, Alan Cox wrote:

> Seems odd to me - why can't the splash screen app in initrd just issue
> the call to turn off the cursor - or is this splash screen coming from
> something else ?

The kernel unconditionally enables the cursor before any userspace has
run, even if we've turned it off in the bootloader. That's the window
I'm trying to close.

> - If the splash screen is kernel based then the splash screen module
> needs to be able to ask the vt driver itself
> - If not then the user space can use ioctls like everyone else (see
> setterm)

(see above)

> - It should be implemented without adding an extra condition to a pile of
> ifs (or the condition mess at least become a single cursor_visible_p())

It doesn't add or alter any conditionals in its current form?

--
Matthew Garrett | [email protected]

2009-09-04 16:03:25

by Alan

[permalink] [raw]
Subject: Re: [PATCH] VT: Add a boot option to disable cursor on boot

On Fri, 4 Sep 2009 11:48:09 -0400
Matthew Garrett <[email protected]> wrote:

> The VT code currently enables a visible cursor on boot. This is a fairly
> unnecessary visual distraction for setups which boot to a splash screen
> before going directly into X, so add a boot option (vt.hide_boot_cursor=1)
> that doesn't enable the cursor for initial VT setup. VT resets and any
> later VT creation will leave the cursor turned on, as before.

Seems odd to me - why can't the splash screen app in initrd just issue
the call to turn off the cursor - or is this splash screen coming from
something else ?

Either way the implementation in your patch is butt-ugly adding an extra
special case all over the place.

IMHO
- If the splash screen is kernel based then the splash screen module
needs to be able to ask the vt driver itself
- If not then the user space can use ioctls like everyone else (see
setterm)
- It should be implemented without adding an extra condition to a pile of
ifs (or the condition mess at least become a single cursor_visible_p())

Alan