linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Manuel Schölling" <manuel.schoelling@gmx.de>
To: plagnioj@jcrosoft.com, tomi.valkeinen@ti.com
Cc: manuel.schoelling@gmx.de, jslaby@suse.cz,
	gregkh@linuxfoundation.org, andrey_utkin@fastmail.com,
	kilobyte@angband.pl, linux-fbdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v7 2/3] console: Add callback to flush scrollback buffer to consw struct
Date: Sun, 27 Nov 2016 17:51:48 +0100	[thread overview]
Message-ID: <1480265509-20922-3-git-send-email-manuel.schoelling@gmx.de> (raw)
In-Reply-To: <1480265509-20922-1-git-send-email-manuel.schoelling@gmx.de>

This new callback is in preparation for persistent scrollback buffer
support for VGA consoles.
With a single scrollback buffer for all consoles, we could flush the
buffer just by invocating consw->con_switch(). But when each VGA console
has its own scrollback buffer, we need a new callback to tell the
video console driver which buffer to flush.

Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
 drivers/tty/vt/vt.c            |  9 +++++++++
 drivers/video/console/vgacon.c | 24 +++++++++++++++++++++++-
 include/linux/console.h        |  4 ++++
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 4c10a9d..9d3ce50 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -625,6 +625,14 @@ static void save_screen(struct vc_data *vc)
 		vc->vc_sw->con_save_screen(vc);
 }
 
+static void flush_scrollback(struct vc_data *vc)
+{
+	WARN_CONSOLE_UNLOCKED();
+
+	if (vc->vc_sw->con_flush_scrollback)
+		vc->vc_sw->con_flush_scrollback(vc);
+}
+
 /*
  *	Redrawing of screen
  */
@@ -1171,6 +1179,7 @@ static void csi_J(struct vc_data *vc, int vpar)
 		case 3: /* erase scroll-back buffer (and whole display) */
 			scr_memsetw(vc->vc_screenbuf, vc->vc_video_erase_char,
 				    vc->vc_screenbuf_size);
+			flush_scrollback(vc);
 			set_origin(vc);
 			if (con_is_visible(vc))
 				update_screen(vc);
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 48b9764..9a7c2bb 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -173,6 +173,16 @@ static struct vgacon_scrollback_info {
 	int restore;
 } vgacon_scrollback;
 
+static void vgacon_scrollback_reset(size_t reset_size)
+{
+	if (vgacon_scrollback.data && reset_size > 0)
+		memset(vgacon_scrollback.data, 0, reset_size);
+
+	vgacon_scrollback.cnt  = 0;
+	vgacon_scrollback.tail = 0;
+	vgacon_scrollback.cur  = 0;
+}
+
 static void vgacon_scrollback_init(int pitch)
 {
 	int rows = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024/pitch;
@@ -305,6 +315,14 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
 	} else
 		vgacon_cursor(c, CM_MOVE);
 }
+
+static void vgacon_flush_scrollback(struct vc_data *c)
+{
+	size_t size = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024;
+
+	if (c->vc_num == fg_console)
+		vgacon_scrollback_reset(size);
+}
 #else
 #define vgacon_scrollback_startup(...) do { } while (0)
 #define vgacon_scrollback_init(...)    do { } while (0)
@@ -322,6 +340,10 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines)
 			vga_vram_size);
 	vga_set_mem_top(c);
 }
+
+static void vgacon_flush_scrollback(struct vc_data *c)
+{
+}
 #endif /* CONFIG_VGACON_SOFT_SCROLLBACK */
 
 static const char *vgacon_startup(void)
@@ -1329,7 +1351,6 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,
 	return true;
 }
 
-
 /*
  *  The console `switch' structure for the VGA based console
  */
@@ -1362,6 +1383,7 @@ const struct consw vga_con = {
 	.con_save_screen = vgacon_save_screen,
 	.con_build_attr = vgacon_build_attr,
 	.con_invert_region = vgacon_invert_region,
+	.con_flush_scrollback = vgacon_flush_scrollback,
 };
 EXPORT_SYMBOL(vga_con);
 
diff --git a/include/linux/console.h b/include/linux/console.h
index 9c26c66..5949d18 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -73,6 +73,10 @@ struct consw {
 	u16    *(*con_screen_pos)(struct vc_data *, int);
 	unsigned long (*con_getxy)(struct vc_data *, unsigned long, int *, int *);
 	/*
+	 * Flush the video console driver's scrollback buffer
+	 */
+	void	(*con_flush_scrollback)(struct vc_data *);
+	/*
 	 * 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.
-- 
2.1.4

  parent reply	other threads:[~2016-11-27 16:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20161118005309.GC26324@dell-m4800.home>
2016-11-20 21:58 ` [PATCH v5 0/2] console: Add persistent scrollback buffers for all VGA console Manuel Schölling
2016-11-20 21:58   ` [PATCH v5 1/2] console: Move scrollback data into its own struct Manuel Schölling
2016-11-20 21:58   ` [PATCH v5 2/2] console: Add persistent scrollback buffers for all VGA consoles Manuel Schölling
2016-11-20 22:23     ` kbuild test robot
2016-11-21 20:17     ` Adam Borowski
2016-11-22 16:56       ` Manuel Schölling
2016-11-23 17:33         ` Adam Borowski
2016-11-27 16:51           ` [PATCH v7 0/3] " Manuel Schölling
2016-11-27 16:51             ` [PATCH v7 1/3] console: Move scrollback data into its own struct Manuel Schölling
2016-11-27 16:51             ` Manuel Schölling [this message]
2016-11-27 16:51             ` [PATCH v7 3/3] console: Add persistent scrollback buffers for all VGA consoles Manuel Schölling
2016-11-27 21:37             ` [PATCH v7 0/3] " Andrey Utkin
2016-11-27 23:15               ` Adam Borowski
2016-11-27 23:30                 ` Jakub Wilk
2016-11-28  0:02                 ` Andrey Utkin
2016-11-28 21:28               ` Manuel Schölling
2016-11-29 10:01                 ` Andrey Utkin
2016-11-29 10:44                   ` Adam Borowski
2016-11-29 16:35                   ` Manuel Schölling
2016-12-01 21:03                   ` Manuel Schölling
2016-12-01 21:31                     ` Andrey Utkin
2016-11-27 23:53             ` Adam Borowski
2016-11-28 21:23               ` Manuel Schölling
2016-11-23 17:33       ` [PATCH v5 2/2] " Manuel Schölling
2016-12-04 10:53 [PATCH v7 0/3] " Manuel Schölling
2016-12-04 10:53 ` [PATCH v7 2/3] console: Add callback to flush scrollback buffer to consw struct Manuel Schölling

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=1480265509-20922-3-git-send-email-manuel.schoelling@gmx.de \
    --to=manuel.schoelling@gmx.de \
    --cc=andrey_utkin@fastmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=kilobyte@angband.pl \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=plagnioj@jcrosoft.com \
    --cc=tomi.valkeinen@ti.com \
    /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;
as well as URLs for NNTP newsgroup(s).