mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yifeng Li <tomli@tomli.me>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	Adam Borowski <kilobyte@angband.pl>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Alexander Potapenko <glider@google.com>,
	Yifeng Li <tomli@tomli.me>, Mike Frysinger <vapier@chromium.org>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [RFC 1/1] tty: vt.c: Fix TIOCL_BLANKSCREEN VT console blanking if blankinterval == 0
Date: Tue, 26 Feb 2019 00:43:46 +0800	[thread overview]
Message-ID: <20190225164346.1359-2-tomli@tomli.me> (raw)
In-Reply-To: <20190225164346.1359-1-tomli@tomli.me>

In vt.c, "blank_state" will be initialized to "blank_normal_wait" in
con_init() if AND ONLY IF ("blankinterval" > 0). If "blankinterval" is 0,
"blank_state" will be "blank_off" (== 0), and a call to do_blank_screen()
will always abort. Even if a forced blanking is required from the user by
calling TIOCL_BLANKSCREEN, the console won't be blanked.

In this commit,  we introduce a 4th "blank_state" - "blank_normal_notimer",
it indicates the console can be blanked, but not automatically by a timer.
Then, we made a change to "con_init()" - if (blankinterval == 0),
"blank_state" will be set to "blank_normal_notimer" (we have similar
changes to "do_unblank_screen()" and "poke_blanked_console()"). Finally,
we change do_blank_screen() - now it will return if "blank_state" is
neither "blank_normal_wait" nor "blank_normal_notimer", thus allowing
the console to be blanked even if there's no timed autoblanking.

Signed-off-by: Yifeng Li <tomli@tomli.me>
---
 drivers/tty/vt/vt.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 41ec8e5010f3..ec84bc2868e1 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -238,6 +238,7 @@ enum {
 	blank_off = 0,
 	blank_normal_wait,
 	blank_vesa_wait,
+	blank_normal_notimer, /* no auto blanking, only manual blanking */
 };
 
 /*
@@ -3334,6 +3335,8 @@ static int __init con_init(void)
 	if (blankinterval) {
 		blank_state = blank_normal_wait;
 		mod_timer(&console_timer, jiffies + (blankinterval * HZ));
+	} else {
+		blank_state = blank_normal_notimer;
 	}
 
 	for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
@@ -4168,7 +4171,8 @@ void do_blank_screen(int entering_gfx)
 		return;
 	}
 
-	if (blank_state != blank_normal_wait)
+	if (blank_state != blank_normal_wait &&
+			blank_state != blank_normal_notimer)
 		return;
 	blank_state = blank_off;
 
@@ -4232,6 +4236,8 @@ void do_unblank_screen(int leaving_gfx)
 	if (blankinterval) {
 		mod_timer(&console_timer, jiffies + (blankinterval * HZ));
 		blank_state = blank_normal_wait;
+	} else {
+		blank_state = blank_normal_notimer;
 	}
 
 	console_blanked = 0;
@@ -4293,7 +4299,8 @@ void poke_blanked_console(void)
 	else if (blankinterval) {
 		mod_timer(&console_timer, jiffies + (blankinterval * HZ));
 		blank_state = blank_normal_wait;
-	}
+	} else if (!blankinterval)
+		blank_state = blank_normal_notimer;
 }
 
 /*
-- 
2.20.1


  reply	other threads:[~2019-02-25 16:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 16:43 [RFC 0/1] " Yifeng Li
2019-02-25 16:43 ` Yifeng Li [this message]
2019-02-25 18:29   ` [RFC 1/1] tty: vt.c: " Nicolas Pitre
2019-02-26 11:20     ` Tom Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190225164346.1359-2-tomli@tomli.me \
    --to=tomli@tomli.me \
    --cc=daniel.vetter@ffwll.ch \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=kilobyte@angband.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=nicolas.pitre@linaro.org \
    --cc=vapier@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®