mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/7] vt: Simplify console-blanking interface
@ 2026-10-23 13:16 Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 1/7] vt: Add con_unblank callback to struct consw Thomas Zimmermann
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2026-10-23 13:16 UTC (permalink / raw)
  To: gregkh, jirislaby, deller, James.Bottomley, simona
  Cc: linux-kernel, linux-serial, linux-fbdev, linux-parisc,
	sashiko-reviews, Thomas Zimmermann

Update con_blank from struct consw to use enum vesa_blank_mode according
to its intended semantics. Handle unblanking in the separate new callback
con_unblank. Update all consoles.

Some background: the vt subsystem calls con_blank with what at first
appears to be nonsensical arguments: the blank value and the type of the
blank parameter do not match. con_blank mixes up console blank state and
monitor DPMS levels for power saving in the same argument. The
implementation of con_blank in various consoles suffers from a similar
problem: their interpretation of the given blank value often disagrees
with what the value's type suggests.

Patch 1 adds a new helper con_unblank, which handles all unblanking. This
allows for changing con_blank to only handle blanking. There's support
for both semantics while consoles are being converted.

Patches 2 to 6 implement con_unblank for the individual consoles. With
this, con_blank changes to its new semantics. Each console gets a single
callback for blanking and a single callback for unblanking.

With all consoles updated, patch 7 removes the old semantics and the
mode_switch parameter.

Tested with vgacon on a SiS 6202 VGA and with fbcon on a Matrox G200
VGA device. The latter also ran fbcon via DRM fbdev emulation. It's easy
to test this with setterm, like this:

  setterm --blank force          # blank
  setterm --blank poke           # unblank
  setterm --powersave powerdown  # set VESA DPMS level 3
  setterm --blank force          # blank and turn off monitor
  setterm --blank poke           # unblank

Blanking and unblanking still works in all tested cases.

Newport and sticon are built-only, due to a lack of test equipment.

Future directions: console blanking helper currently handle switching a
console between text and graphics mode. The mode_switch parameter indicates
this to the console. As suggested in earlier reviews, a later series might
rework the mode switching entirely.

v3:
- avoid possible regressions by adding back mode_switch
v2:
- rewrite series with con_unblank (GregKH)
- drop mode_switch from console implementations

Thomas Zimmermann (7):
  vt: Add con_unblank callback to struct consw
  dummycon: Implement struct consw.con_unblank
  fbcon: Implement struct consw.con_unblank
  newport_con: Implement struct consw.con_unblank
  sticon: Implement struct consw.con_unblank
  vgacon: Implement struct consw.con_unblank
  vt: Remove old-style con_blank

 drivers/tty/vt/vt.c                 | 11 +++---
 drivers/video/console/dummycon.c    | 12 +++++++
 drivers/video/console/newport_con.c | 24 +++++++------
 drivers/video/console/sticon.c      | 20 ++++++-----
 drivers/video/console/vgacon.c      | 46 +++++++++++++-----------
 drivers/video/fbdev/core/fbcon.c    | 55 ++++++++++++++++++++---------
 include/linux/console.h             | 10 ++++--
 7 files changed, 114 insertions(+), 64 deletions(-)


base-commit: 5b9ee97c47574138633a1cb70a32d118b6860a43
-- 
2.56.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/7] vt: Add con_unblank callback to struct consw
  2026-10-23 13:16 [PATCH v3 0/7] vt: Simplify console-blanking interface Thomas Zimmermann
@ 2026-10-23 13:16 ` Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 2/7] dummycon: Implement struct consw.con_unblank Thomas Zimmermann
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2026-10-23 13:16 UTC (permalink / raw)
  To: gregkh, jirislaby, deller, James.Bottomley, simona
  Cc: linux-kernel, linux-serial, linux-fbdev, linux-parisc,
	sashiko-reviews, Thomas Zimmermann

Add struct consw.con_unblank as inverse operation to con_blank.

If implemented invoke con_blank to turn the console from blanked to
unblanked. Also update the semantics of con_blank in this case: The
blank parameter of con_blank receives a VESA blank mode from enum
vesa_blank_mode instead of the hybrid unblank/blank values it has
used so far.

With con_unblank not implemented, invoke con_blank for blanking and
unblanking as before.

The old semantics of con_blank will be removed when all consoles
implement con_unblank.

v3:
- fix typo in commit description (Helge)
- add mode_switch parameter to con_unblank

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/tty/vt/vt.c     | 30 +++++++++++++++++++++++-------
 include/linux/console.h | 10 +++++++---
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 8415e274e4be..82885f357f76 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -4788,7 +4788,10 @@ void do_blank_screen(int entering_gfx)
 	if (console_blanked) {
 		if (blank_state == blank_vesa_wait) {
 			blank_state = blank_off;
-			vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0);
+			if (vc->vc_sw->con_unblank)
+				vc->vc_sw->con_blank(vc, vesa_blank_mode, 0);
+			else
+				vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0);
 		}
 		return;
 	}
@@ -4797,7 +4800,10 @@ void do_blank_screen(int entering_gfx)
 	if (entering_gfx) {
 		hide_cursor(vc);
 		save_screen(vc);
-		vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1);
+		if (vc->vc_sw->con_unblank)
+			vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, 1);
+		else
+			vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1);
 		console_blanked = fg_console + 1;
 		blank_state = blank_off;
 		set_origin(vc);
@@ -4818,8 +4824,12 @@ 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 ? VESA_VSYNC_SUSPEND :
-				 (vesa_blank_mode + 1), 0);
+	if (vc->vc_sw->con_unblank)
+		i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_NO_BLANKING :
+					 vesa_blank_mode, 0);
+	else
+		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);
@@ -4870,9 +4880,15 @@ void do_unblank_screen(int leaving_gfx)
 	}
 
 	console_blanked = 0;
-	if (vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, leaving_gfx))
-		/* Low-level driver cannot restore -> do it ourselves */
-		update_screen(vc);
+	if (vc->vc_sw->con_unblank) {
+		if (vc->vc_sw->con_unblank(vc, leaving_gfx))
+			/* Low-level driver cannot restore -> do it ourselves */
+			update_screen(vc);
+	} else {
+		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)
 		console_blank_hook(0);
 	set_palette(vc);
diff --git a/include/linux/console.h b/include/linux/console.h
index df23148987ee..cb8be9ea4a76 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -55,9 +55,12 @@ 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_blank:  blank the console. The preferred VESA blank 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_unblank: unblank the console. The hook is supposed to return true if
+ *		a redraw is needed. @mode_switch is set if changing from/to
+ *		text/graphics.
  * @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.
@@ -99,6 +102,7 @@ struct consw {
 	bool	(*con_switch)(struct vc_data *vc);
 	bool	(*con_blank)(struct vc_data *vc, enum vesa_blank_mode blank,
 			     bool mode_switch);
+	bool	(*con_unblank)(struct vc_data *vc, bool mode_switch);
 	int	(*con_font_set)(struct vc_data *vc,
 				const struct console_font *font,
 				unsigned int vpitch, unsigned int flags);
-- 
2.56.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 2/7] dummycon: Implement struct consw.con_unblank
  2026-10-23 13:16 [PATCH v3 0/7] vt: Simplify console-blanking interface Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 1/7] vt: Add con_unblank callback to struct consw Thomas Zimmermann
@ 2026-10-23 13:16 ` Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 3/7] fbcon: " Thomas Zimmermann
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2026-10-23 13:16 UTC (permalink / raw)
  To: gregkh, jirislaby, deller, James.Bottomley, simona
  Cc: linux-kernel, linux-serial, linux-fbdev, linux-parisc,
	sashiko-reviews, Thomas Zimmermann

Implement con_unblank from struct consw as a duplicate of con_blank.
As dummycon does not do anything, the implementation only returns
true or false to trigger a redraw (or not).

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/console/dummycon.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index 7d02470f19b9..44856df84d99 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -86,6 +86,11 @@ static bool dummycon_blank(struct vc_data *vc, enum vesa_blank_mode blank,
 	return true;
 }
 
+static bool dummycon_unblank(struct vc_data *vc, bool mode_switch)
+{
+	return true;
+}
+
 static bool dummycon_switch(struct vc_data *vc)
 {
 	/*
@@ -104,6 +109,12 @@ static bool dummycon_blank(struct vc_data *vc, enum vesa_blank_mode blank,
 {
 	return false;
 }
+
+static bool dummycon_unblank(struct vc_data *vc, bool mode_switch)
+{
+	return false;
+}
+
 static bool dummycon_switch(struct vc_data *vc)
 {
 	return false;
@@ -155,5 +166,6 @@ const struct consw dummy_con = {
 	.con_scroll =	dummycon_scroll,
 	.con_switch =	dummycon_switch,
 	.con_blank =	dummycon_blank,
+	.con_unblank =	dummycon_unblank,
 };
 EXPORT_SYMBOL_GPL(dummy_con);
-- 
2.56.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 3/7] fbcon: Implement struct consw.con_unblank
  2026-10-23 13:16 [PATCH v3 0/7] vt: Simplify console-blanking interface Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 1/7] vt: Add con_unblank callback to struct consw Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 2/7] dummycon: Implement struct consw.con_unblank Thomas Zimmermann
@ 2026-10-23 13:16 ` Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 4/7] newport_con: " Thomas Zimmermann
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2026-10-23 13:16 UTC (permalink / raw)
  To: gregkh, jirislaby, deller, James.Bottomley, simona
  Cc: linux-kernel, linux-serial, linux-fbdev, linux-parisc,
	sashiko-reviews, Thomas Zimmermann

Implement con_unblank from struct consw with the !blank branches from
fbcon_blank(). The new function is called fbcon_unblank(). Remove the
duplicated code from fbcon_blank().

Fbcon tracks fbdev blank state in par->blank_state using fbdev's FB_BLANK
constants. In fbcon_unblank() the stored value is always FB_BLANK_UNBLANK.
In fbcon_blank(), the new blank state is 1 + plus the VESA blank mode
given in the parameter blank.

fbcon_blank() now disables the cursor worker unconditionally.

v3:
- take mode_switch from parameter

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/fbdev/core/fbcon.c | 55 ++++++++++++++++++++++----------
 1 file changed, 38 insertions(+), 17 deletions(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index d97d94bb8e99..f6139e3c26a2 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2270,32 +2270,52 @@ static bool fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank,
 	struct fb_info *info = fbcon_info_from_console(vc->vc_num);
 	struct fbcon_par *par = info->fbcon_par;
 
-	if (mode_switch) {
-		struct fb_var_screeninfo var = info->var;
+	if (mode_switch)
+		par->graphics = true;
 
-		par->graphics = 1;
+	if (fbcon_is_active(vc, info)) {
+		int blank_state = 1 + blank; /* convert VESA to FB_BLANK constant */
 
-		if (!blank) {
-			var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE |
-				FB_ACTIVATE_KD_TEXT;
-			fb_set_var(info, &var);
-			par->graphics = 0;
-			par->var = info->var;
+		if (par->blank_state != blank_state) {
+			par->blank_state = blank_state;
+			fbcon_cursor(vc, false);
+			par->cursor_flash = false;
+
+			if (fb_blank(info, blank_state))
+				fbcon_generic_blank(vc, info, true);
 		}
 	}
 
+	fbcon_del_cursor_work(info);
+
+	return false;
+}
+
+static bool fbcon_unblank(struct vc_data *vc, bool mode_switch)
+{
+	struct fb_info *info = fbcon_info_from_console(vc->vc_num);
+	struct fbcon_par *par = info->fbcon_par;
+
+	if (mode_switch) {
+		struct fb_var_screeninfo var = info->var;
+
+		var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE | FB_ACTIVATE_KD_TEXT;
+		fb_set_var(info, &var);
+		par->graphics = false;
+		par->var = info->var;
+	}
+
 	if (fbcon_is_active(vc, info)) {
-		if (par->blank_state != blank) {
-			par->blank_state = blank;
-			fbcon_cursor(vc, !blank);
-			par->cursor_flash = (!blank);
+		if (par->blank_state != FB_BLANK_UNBLANK) {
+			par->blank_state = FB_BLANK_UNBLANK;
+			fbcon_cursor(vc, true);
+			par->cursor_flash = true;
 
-			if (fb_blank(info, blank))
-				fbcon_generic_blank(vc, info, blank);
+			if (fb_blank(info, FB_BLANK_UNBLANK))
+				fbcon_generic_blank(vc, info, false);
 		}
 
-		if (!blank)
-			update_screen(vc);
+		update_screen(vc);
 	}
 
 	if (mode_switch || !fbcon_is_active(vc, info) || par->blank_state != FB_BLANK_UNBLANK)
@@ -3145,6 +3165,7 @@ static const struct consw fb_con = {
 	.con_scroll 		= fbcon_scroll,
 	.con_switch 		= fbcon_switch,
 	.con_blank 		= fbcon_blank,
+	.con_unblank		= fbcon_unblank,
 	.con_font_set 		= fbcon_set_font,
 	.con_font_get 		= fbcon_get_font,
 	.con_font_default	= fbcon_set_def_font,
-- 
2.56.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 4/7] newport_con: Implement struct consw.con_unblank
  2026-10-23 13:16 [PATCH v3 0/7] vt: Simplify console-blanking interface Thomas Zimmermann
                   ` (2 preceding siblings ...)
  2026-10-23 13:16 ` [PATCH v3 3/7] fbcon: " Thomas Zimmermann
@ 2026-10-23 13:16 ` Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 5/7] sticon: " Thomas Zimmermann
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2026-10-23 13:16 UTC (permalink / raw)
  To: gregkh, jirislaby, deller, James.Bottomley, simona
  Cc: linux-kernel, linux-serial, linux-fbdev, linux-parisc,
	sashiko-reviews, Thomas Zimmermann

Implement con_unblank from struct consw with the VESA_NO_BLANKING
branch from newport_blank(). Remove that code from the blank helper.

Both helpers, newport_blank() and newport_unbank(), clear or set
a single flag in a hardware register. No further VESA DPMS blanking
is supported.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/console/newport_con.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
index ecbbe2e4e2a6..1a6f9e8a79aa 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -481,17 +481,18 @@ static bool newport_blank(struct vc_data *c, enum vesa_blank_mode blank,
 {
 	unsigned short treg;
 
-	if (blank == VESA_NO_BLANKING) {
-		/* unblank console */
-		treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
-		newport_vc2_set(npregs, VC2_IREG_CONTROL,
-				(treg | VC2_CTRL_EDISP));
-	} else {
-		/* blank console */
-		treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
-		newport_vc2_set(npregs, VC2_IREG_CONTROL,
-				(treg & ~(VC2_CTRL_EDISP)));
-	}
+	treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
+	newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg & ~(VC2_CTRL_EDISP)));
+
+	return true;
+}
+
+static bool newport_unblank(struct vc_data *c, bool mode_switch)
+{
+	unsigned short treg;
+
+	treg = newport_vc2_get(npregs, VC2_IREG_CONTROL);
+	newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg | VC2_CTRL_EDISP));
 
 	return true;
 }
@@ -666,6 +667,7 @@ const struct consw newport_con = {
 	.con_scroll	  = newport_scroll,
 	.con_switch	  = newport_switch,
 	.con_blank	  = newport_blank,
+	.con_unblank	  = newport_unblank,
 	.con_font_set	  = newport_font_set,
 	.con_font_default = newport_font_default,
 	.con_save_screen  = newport_save_screen
-- 
2.56.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 5/7] sticon: Implement struct consw.con_unblank
  2026-10-23 13:16 [PATCH v3 0/7] vt: Simplify console-blanking interface Thomas Zimmermann
                   ` (3 preceding siblings ...)
  2026-10-23 13:16 ` [PATCH v3 4/7] newport_con: " Thomas Zimmermann
@ 2026-10-23 13:16 ` Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 6/7] vgacon: " Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 7/7] vt: Remove old-style con_blank Thomas Zimmermann
  6 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2026-10-23 13:16 UTC (permalink / raw)
  To: gregkh, jirislaby, deller, James.Bottomley, simona
  Cc: linux-kernel, linux-serial, linux-fbdev, linux-parisc,
	sashiko-reviews, Thomas Zimmermann

Implement con_unblank from struct consw. The new function is called
sticon_unblank(). Remove the related code from sticon_blank().

There is no display unblanking in sticon: only return true to redraw
the console.

v3:
- take mode_switch from parameter

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/console/sticon.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
index 6f58e6a9e76a..d1b5e1e5594d 100644
--- a/drivers/video/console/sticon.c
+++ b/drivers/video/console/sticon.c
@@ -302,17 +302,20 @@ static bool sticon_switch(struct vc_data *conp)
 static bool sticon_blank(struct vc_data *c, enum vesa_blank_mode blank,
 			 bool mode_switch)
 {
-    if (blank == VESA_NO_BLANKING) {
+	sti_clear(sticon_sti, 0, 0, c->vc_rows, c->vc_cols, BLANK, font_data[c->vc_num]);
+
 	if (mode_switch)
-	    vga_is_gfx = 0;
+		vga_is_gfx = 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 true;
+static bool sticon_unblank(struct vc_data *c, bool mode_switch)
+{
+	if (mode_switch)
+		vga_is_gfx = 0;
+
+	return true;
 }
 
 static u8 sticon_build_attr(struct vc_data *conp, u8 color,
@@ -356,6 +359,7 @@ static const struct consw sti_con = {
 	.con_scroll		= sticon_scroll,
 	.con_switch		= sticon_switch,
 	.con_blank		= sticon_blank,
+	.con_unblank		= sticon_unblank,
 	.con_font_set		= sticon_font_set,
 	.con_font_default	= sticon_font_default,
 	.con_build_attr		= sticon_build_attr,
-- 
2.56.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 6/7] vgacon: Implement struct consw.con_unblank
  2026-10-23 13:16 [PATCH v3 0/7] vt: Simplify console-blanking interface Thomas Zimmermann
                   ` (4 preceding siblings ...)
  2026-10-23 13:16 ` [PATCH v3 5/7] sticon: " Thomas Zimmermann
@ 2026-10-23 13:16 ` Thomas Zimmermann
  2026-10-23 13:16 ` [PATCH v3 7/7] vt: Remove old-style con_blank Thomas Zimmermann
  6 siblings, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2026-10-23 13:16 UTC (permalink / raw)
  To: gregkh, jirislaby, deller, James.Bottomley, simona
  Cc: linux-kernel, linux-serial, linux-fbdev, linux-parisc,
	sashiko-reviews, Thomas Zimmermann

Implement con_unblank from struct consw with the VESA_NO_BLANKING
case from vgacon_blank(). The new function is called vgacon_unblank().
Remove the duplicated code from vgacon_blank().

v3:
- take mode_switch from parameter
- restore vga_is_gfx setting

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/console/vgacon.c | 46 +++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 2dcb1e38bd6b..e7e6750f1f87 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -778,38 +778,43 @@ static bool vgacon_blank(struct vc_data *c, enum vesa_blank_mode blank,
 			 bool mode_switch)
 {
 	switch (blank) {
-	case VESA_NO_BLANKING:		/* Unblank */
-		if (vga_vesa_blanked) {
-			vga_vesa_unblank(&vgastate);
-			vga_vesa_blanked = VESA_NO_BLANKING;
-		}
-		if (vga_palette_blanked) {
-			vga_set_palette(c, color_table);
-			vga_palette_blanked = false;
-			return 0;
-		}
-		vga_is_gfx = false;
-		/* Tell console.c that it has to restore the screen itself */
-		return 1;
-	case VESA_VSYNC_SUSPEND:	/* Normal blanking */
+	case VESA_NO_BLANKING:	/* Normal blanking */
 		if (!mode_switch && vga_video_type == VIDEO_TYPE_VGAC) {
 			vga_pal_blank(&vgastate);
 			vga_palette_blanked = true;
-			return 0;
+			return false;
 		}
 		vgacon_set_origin(c);
-		scr_memsetw((void *) vga_vram_base, BLANK,
-			    c->vc_screenbuf_size);
+		scr_memsetw((void *)vga_vram_base, BLANK, c->vc_screenbuf_size);
 		if (mode_switch)
 			vga_is_gfx = true;
-		return 1;
+		return true;
 	default:		/* VESA blanking */
 		if (vga_video_type == VIDEO_TYPE_VGAC) {
-			vga_vesa_blank(&vgastate, blank - 1);
+			vga_vesa_blank(&vgastate, blank);
 			vga_vesa_blanked = blank;
 		}
-		return 0;
+		return false;
+	}
+}
+
+static bool vgacon_unblank(struct vc_data *c, bool mode_switch)
+{
+	if (vga_vesa_blanked) {
+		vga_vesa_unblank(&vgastate);
+		vga_vesa_blanked = VESA_NO_BLANKING;
+	}
+
+	if (vga_palette_blanked) {
+		vga_set_palette(c, color_table);
+		vga_palette_blanked = false;
+		return false;
 	}
+
+	vga_is_gfx = false;
+
+	/* Tell console.c that it has to restore the screen itself */
+	return true;
 }
 
 /*
@@ -1178,6 +1183,7 @@ const struct consw vga_con = {
 	.con_scroll = vgacon_scroll,
 	.con_switch = vgacon_switch,
 	.con_blank = vgacon_blank,
+	.con_unblank = vgacon_unblank,
 	.con_font_set = vgacon_font_set,
 	.con_font_get = vgacon_font_get,
 	.con_resize = vgacon_resize,
-- 
2.56.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 7/7] vt: Remove old-style con_blank
  2026-10-23 13:16 [PATCH v3 0/7] vt: Simplify console-blanking interface Thomas Zimmermann
                   ` (5 preceding siblings ...)
  2026-10-23 13:16 ` [PATCH v3 6/7] vgacon: " Thomas Zimmermann
@ 2026-10-23 13:16 ` Thomas Zimmermann
  2026-10-23 13:37   ` Greg KH
  6 siblings, 1 reply; 9+ messages in thread
From: Thomas Zimmermann @ 2026-10-23 13:16 UTC (permalink / raw)
  To: gregkh, jirislaby, deller, James.Bottomley, simona
  Cc: linux-kernel, linux-serial, linux-fbdev, linux-parisc,
	sashiko-reviews, Thomas Zimmermann

All consoles implement the new con_blank plus con_unblank. Remove
the old semantics from con_blank. Always pass a VESA blank mode to
the blank parameter.

v3:
- keep con_blank's mode_switch parameter

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/tty/vt/vt.c | 31 ++++++++-----------------------
 1 file changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 82885f357f76..7dbc0072a40a 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -4788,10 +4788,7 @@ void do_blank_screen(int entering_gfx)
 	if (console_blanked) {
 		if (blank_state == blank_vesa_wait) {
 			blank_state = blank_off;
-			if (vc->vc_sw->con_unblank)
-				vc->vc_sw->con_blank(vc, vesa_blank_mode, 0);
-			else
-				vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0);
+			vc->vc_sw->con_blank(vc, vesa_blank_mode, false);
 		}
 		return;
 	}
@@ -4800,10 +4797,7 @@ void do_blank_screen(int entering_gfx)
 	if (entering_gfx) {
 		hide_cursor(vc);
 		save_screen(vc);
-		if (vc->vc_sw->con_unblank)
-			vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, 1);
-		else
-			vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1);
+		vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, true);
 		console_blanked = fg_console + 1;
 		blank_state = blank_off;
 		set_origin(vc);
@@ -4824,12 +4818,9 @@ void do_blank_screen(int entering_gfx)
 
 	save_screen(vc);
 	/* In case we need to reset origin, blanking hook returns 1 */
-	if (vc->vc_sw->con_unblank)
-		i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_NO_BLANKING :
-					 vesa_blank_mode, 0);
-	else
-		i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_VSYNC_SUSPEND :
-					 (vesa_blank_mode + 1), 0);
+	i = vc->vc_sw->con_blank(vc,
+				 vesa_off_interval ? VESA_NO_BLANKING : vesa_blank_mode,
+				 false);
 	console_blanked = fg_console + 1;
 	if (i)
 		set_origin(vc);
@@ -4880,15 +4871,9 @@ void do_unblank_screen(int leaving_gfx)
 	}
 
 	console_blanked = 0;
-	if (vc->vc_sw->con_unblank) {
-		if (vc->vc_sw->con_unblank(vc, leaving_gfx))
-			/* Low-level driver cannot restore -> do it ourselves */
-			update_screen(vc);
-	} else {
-		if (vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, leaving_gfx))
-			/* Low-level driver cannot restore -> do it ourselves */
-			update_screen(vc);
-	}
+	if (vc->vc_sw->con_unblank(vc, leaving_gfx))
+		/* Low-level driver cannot restore -> do it ourselves */
+		update_screen(vc);
 	if (console_blank_hook)
 		console_blank_hook(0);
 	set_palette(vc);
-- 
2.56.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 7/7] vt: Remove old-style con_blank
  2026-10-23 13:16 ` [PATCH v3 7/7] vt: Remove old-style con_blank Thomas Zimmermann
@ 2026-10-23 13:37   ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2026-10-23 13:37 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: jirislaby, deller, James.Bottomley, simona, linux-kernel,
	linux-serial, linux-fbdev, linux-parisc, sashiko-reviews

On Fri, Oct 23, 2026 at 03:16:17PM +0200, Thomas Zimmermann wrote:
> All consoles implement the new con_blank plus con_unblank. Remove
> the old semantics from con_blank. Always pass a VESA blank mode to
> the blank parameter.
> 
> v3:
> - keep con_blank's mode_switch parameter

Shouldn't the "v3:" stuff go below the --- line?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-10-23 15:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 13:16 [PATCH v3 0/7] vt: Simplify console-blanking interface Thomas Zimmermann
2026-10-23 13:16 ` [PATCH v3 1/7] vt: Add con_unblank callback to struct consw Thomas Zimmermann
2026-10-23 13:16 ` [PATCH v3 2/7] dummycon: Implement struct consw.con_unblank Thomas Zimmermann
2026-10-23 13:16 ` [PATCH v3 3/7] fbcon: " Thomas Zimmermann
2026-10-23 13:16 ` [PATCH v3 4/7] newport_con: " Thomas Zimmermann
2026-10-23 13:16 ` [PATCH v3 5/7] sticon: " Thomas Zimmermann
2026-10-23 13:16 ` [PATCH v3 6/7] vgacon: " Thomas Zimmermann
2026-10-23 13:16 ` [PATCH v3 7/7] vt: Remove old-style con_blank Thomas Zimmermann
2026-10-23 13:37   ` Greg KH

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®