Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964894AbcLUQi4 (ORCPT ); Wed, 21 Dec 2016 11:38:56 -0500 Received: from mout.gmx.net ([212.227.15.18]:50313 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934824AbcLUQiX (ORCPT ); Wed, 21 Dec 2016 11:38:23 -0500 From: =?UTF-8?q?Manuel=20Sch=C3=B6lling?= 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 RESEND v7 2/3] console: Add callback to flush scrollback buffer to consw struct Date: Wed, 21 Dec 2016 17:37:37 +0100 Message-Id: <1482338258-21388-3-git-send-email-manuel.schoelling@gmx.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1482338258-21388-1-git-send-email-manuel.schoelling@gmx.de> References: <1480848836-11330-1-git-send-email-manuel.schoelling@gmx.de> <1482338258-21388-1-git-send-email-manuel.schoelling@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:7ZxufTkOSpen2dtWSVrAfunEgiZPP3AGZ+ITuj6knIQ3V1/jsEO jHSrwHX7k3dhHdqivcT29NblQn0scNlgHtx8BwlIHmVi0VIlQUJrhqaLFubXVeQi19RUvws zFjZnswU8AtJv//EXmRLak8/dFH7selqq4W2e873UBwlalDcC2k4e6b1QL87Qo7XH6iUYAI mh0DyWJl+wHflpZHwrjbA== X-UI-Out-Filterresults: notjunk:1;V01:K0:MMRqXGMqjiM=:xwKrRVACodeUZuRqlETk9d zojhv4GSdbp21t2kX3pts6OEffxzAmKE5nByuxodBoR6ddAT7Z9MbWTZYWpelzy/0+m0SnFXa 0yDJfiQEp+E0NQo/T5gY76Wli9hEXrSKyK3t9WApST6B+1TkW2Qty1QDFBxXdb26ltZW5w6mG lVNU2Lx35/IG877M2Kiq9gwVbvohaUaNR5ByW1OhbNFMvvD3ZOE5PGberPTMsXxp5S9Jfpac8 PRgFppLC0wJaRn49VRbnA1UlCYsgJ96O/lkMiJu2S5yp4aM1OeK9hs7m1rzU3bcf+sUxQHE8p J4ADet6Us4zl6rwvf5c4VdD2hZV7iX6BI2N+UpOyGBWd4YF/6+xlOI8HQDUFyHx3DTSlOUKLX XffIQnLFCdU8YE39JVJ4UqZvzfzSU+EfxOAFs7lB09qfT12U+5Qm/Zy0h7VoEASPSzfnfrFVN iQMuF43zU1q7s9LItJFtHkLNIyPMd4PX1FNCiDt38wu9/N9a5bq9pxYLC9LXtucxIAZD6CjuS ZOxJ9RTJm+K4FOjtTw/9iN1Dz0/Sk86sNKDVZ9r0e4aPpaZwe59/5cGctPHMiDvxmKwXi0HHN cqmQ9Pr3db0aRq3p5wgqTDWN5ZtevgKwwrfD194XppTnbQemQ1WY62z36G/+AwrqYHQ+UKLQm PnHYmL1cAVkosOY7gYaNUI8iacGzVY22tTKKgp5/Fc7ivvTdIe7JuxahuKexumd+mr95hdQeY /3hbOlD2LF/voszkExM6ecloXc2bHG3LUybAdsGqhsAio7cBatRVMgCuuiKZ6okunGVkuGQmG TCXtRTk Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3978 Lines: 125 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 Reviewed-by: Andrey Utkin Tested-by: Andrey Utkin Tested-by: Adam Borowski --- 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