From patchwork Tue Jan 10 21:28:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Manuel_Sch=C3=B6lling?= X-Patchwork-Id: 9508529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F29C860231 for ; Tue, 10 Jan 2017 21:29:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9208285BF for ; Tue, 10 Jan 2017 21:29:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB3D4285C1; Tue, 10 Jan 2017 21:29:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D6EE285BF for ; Tue, 10 Jan 2017 21:29:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752200AbdAJV3t (ORCPT ); Tue, 10 Jan 2017 16:29:49 -0500 Received: from mout.gmx.net ([212.227.17.21]:64316 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752118AbdAJV3s (ORCPT ); Tue, 10 Jan 2017 16:29:48 -0500 Received: from localhost.localdomain ([88.152.9.218]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MGXV6-1cDshJ1Yye-00DEp5; Tue, 10 Jan 2017 22:29:01 +0100 From: =?UTF-8?q?Manuel=20Sch=C3=B6lling?= To: gregkh@linuxfoundation.org Cc: jslaby@suse.com, kilobyte@angband.pl, lkml14@scotdoyle.com, rdunlap@infradead.org, shorne@gmail.com, andrey_utkin@fastmail.com, akpm@linux-foundation.org, paul.burton@imgtec.com, daniel.vetter@ffwll.ch, tj@kernel.org, hdegoede@redhat.com, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, =?UTF-8?q?Manuel=20Sch=C3=B6lling?= Subject: [PATCH v9 1/4] console: Move scrollback data into its own struct Date: Tue, 10 Jan 2017 22:28:35 +0100 Message-Id: <20170110212838.16175-2-manuel.schoelling@gmx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170110212838.16175-1-manuel.schoelling@gmx.de> References: <20170110212838.16175-1-manuel.schoelling@gmx.de> In-Reply-To: <4640722.jsFVORW8WM@amdc3058> References: <4640722.jsFVORW8WM@amdc3058> MIME-Version: 1.0 X-Provags-ID: V03:K0:8MoxeP9z5Ev9XO/qldGWzgDtbB88TK9xWpsylAl0ODVB00FAbcs m7kAlkdCjpYS3DccDs6/nC1TLQMw04EJc1FXQnA2gZakU+mAdLKyLuVGOqkQ9k+e88FJHLC HvwyC1J4qWTSReb9OsITeant/t6W9oLGEW+9yJktnz+nQ87mLjdNpJDkAdSY0ziWm1iJ4Vg J6DCyYB03DzIs9+mcusvA== X-UI-Out-Filterresults: notjunk:1; V01:K0:pvQ6IfD0iyM=:N4wHIf9Ae6dDylH/Th8hQU 853hiRXmke1la3BeeC+NMHitN+7qaKMWvEZ7xD9D+Yz76weauZ6qSAned9+g/JIOERgxh60ag C5oRNdxuWWJ2/uEwrdtR4pDjB2zlmTWVRpCJMfGZjxIjzKelChVFLBYbM4SiTHuk6T+IAel5z ITRw+sQS+7LyLE9fj5LGjdFfUWfKOeTgSB+bZ9bSTZ9wd4YIa49qa8dHdigLEsXFYRAD08u/z fa/z99igqia0Q2aotkPYF/h9CMdrWVmQ4CKwSyZBL61QEU12CFecYC+XIYxFMKPR0q99mYvH1 9/SLn2Pjn5oBfi+piGGwNaYEWgIrKUpo1SRcH7UHczsjf6JMmELvzNzkBj1E89e9WTMsxkl6D jXQunb2Ri7x0Z1IbhbiWhDYDiUAozBhjfD9CxBi+9W1il8gnG4uiHnz193XigDus8AhOr6tdj YF+YwsSZuRtNHg5Fmyo6mAgJmfeNVEPK6JNQyCjAJe66RoHYb4xBCUyQP7xEr1htfDRSZLZse 1h1eELHvY/I40ll032nwUUY95WGMhD2e8GZVs7joPHm3Ulr8bF+y/I0F6o7zLyD42m9Tdh7FJ fNiQbBCEZV266hPD0uhIqTquDr1DJI0fgji284aPp7md6gWu/HrtMdj1JgBns48+KJ34DoyG0 t2R0bHes2JuoLWSERSW7qpMDXZcoyxmFhsohjxnn1Xqf4b17Zc6QGncC6XecBlKAxeIytxW69 zcBzG0SH0TfBos8ydPVnmHyiCUkvuLkYzg1fgDFGrI7LcPONV/Iz5crMkwRhmLpl50IOIwokE CJvEzdA4t105mWY68manVkTX3nNiqRNGgQhyDfj8T7axS03+rLbTGV7dEvfUJqU3PAw5nXTCM aktwTUzWUiaipajLGqxBDBGZwCMiYKSgl020sfxG9rfc1zVcfPF3V4FtJ9zJ35XhrW/K4KIhv AvRwIKJ8b4MlUAOH48JjABddz9t7oti5KlRILo4IYFO6jgfHRr39M0tX+pB9FwDW3Y6XZ6+ip x/wFkcJhQaHyhgAVtYmtPw1hHJ5nROziBP0/FNfybtvKKlQ8KAcN5MTUOwY6b0eUoQ== Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This refactoring is in preparation for persistent scrollback support for VGA console. Signed-off-by: Manuel Schölling Reviewed-by: Andrey Utkin Tested-by: Andrey Utkin Tested-by: Adam Borowski --- drivers/video/console/vgacon.c | 91 ++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index c22a56232b7c..48b97648d4af 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -162,31 +162,34 @@ static inline void vga_set_mem_top(struct vc_data *c) #ifdef CONFIG_VGACON_SOFT_SCROLLBACK /* software scrollback */ -static void *vgacon_scrollback; -static int vgacon_scrollback_tail; -static int vgacon_scrollback_size; -static int vgacon_scrollback_rows; -static int vgacon_scrollback_cnt; -static int vgacon_scrollback_cur; -static int vgacon_scrollback_save; -static int vgacon_scrollback_restore; +static struct vgacon_scrollback_info { + void *data; + int tail; + int size; + int rows; + int cnt; + int cur; + int save; + int restore; +} vgacon_scrollback; static void vgacon_scrollback_init(int pitch) { int rows = CONFIG_VGACON_SOFT_SCROLLBACK_SIZE * 1024/pitch; - if (vgacon_scrollback) { - vgacon_scrollback_cnt = 0; - vgacon_scrollback_tail = 0; - vgacon_scrollback_cur = 0; - vgacon_scrollback_rows = rows - 1; - vgacon_scrollback_size = rows * pitch; + if (vgacon_scrollback.data) { + vgacon_scrollback.cnt = 0; + vgacon_scrollback.tail = 0; + vgacon_scrollback.cur = 0; + vgacon_scrollback.rows = rows - 1; + vgacon_scrollback.size = rows * pitch; } } static void vgacon_scrollback_startup(void) { - vgacon_scrollback = kcalloc(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE, 1024, GFP_NOWAIT); + vgacon_scrollback.data = kcalloc(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE, + 1024, GFP_NOWAIT); vgacon_scrollback_init(vga_video_num_columns * 2); } @@ -194,38 +197,38 @@ static void vgacon_scrollback_update(struct vc_data *c, int t, int count) { void *p; - if (!vgacon_scrollback_size || c->vc_num != fg_console) + if (!vgacon_scrollback.size || c->vc_num != fg_console) return; p = (void *) (c->vc_origin + t * c->vc_size_row); while (count--) { - scr_memcpyw(vgacon_scrollback + vgacon_scrollback_tail, + scr_memcpyw(vgacon_scrollback.data + vgacon_scrollback.tail, p, c->vc_size_row); - vgacon_scrollback_cnt++; + vgacon_scrollback.cnt++; p += c->vc_size_row; - vgacon_scrollback_tail += c->vc_size_row; + vgacon_scrollback.tail += c->vc_size_row; - if (vgacon_scrollback_tail >= vgacon_scrollback_size) - vgacon_scrollback_tail = 0; + if (vgacon_scrollback.tail >= vgacon_scrollback.size) + vgacon_scrollback.tail = 0; - if (vgacon_scrollback_cnt > vgacon_scrollback_rows) - vgacon_scrollback_cnt = vgacon_scrollback_rows; + if (vgacon_scrollback.cnt > vgacon_scrollback.rows) + vgacon_scrollback.cnt = vgacon_scrollback.rows; - vgacon_scrollback_cur = vgacon_scrollback_cnt; + vgacon_scrollback.cur = vgacon_scrollback.cnt; } } static void vgacon_restore_screen(struct vc_data *c) { - vgacon_scrollback_save = 0; + vgacon_scrollback.save = 0; - if (!vga_is_gfx && !vgacon_scrollback_restore) { + if (!vga_is_gfx && !vgacon_scrollback.restore) { scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf, c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size); - vgacon_scrollback_restore = 1; - vgacon_scrollback_cur = vgacon_scrollback_cnt; + vgacon_scrollback.restore = 1; + vgacon_scrollback.cur = vgacon_scrollback.cnt; } } @@ -239,41 +242,41 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) return; } - if (!vgacon_scrollback) + if (!vgacon_scrollback.data) return; - if (!vgacon_scrollback_save) { + if (!vgacon_scrollback.save) { vgacon_cursor(c, CM_ERASE); vgacon_save_screen(c); - vgacon_scrollback_save = 1; + vgacon_scrollback.save = 1; } - vgacon_scrollback_restore = 0; - start = vgacon_scrollback_cur + lines; + vgacon_scrollback.restore = 0; + start = vgacon_scrollback.cur + lines; end = start + abs(lines); if (start < 0) start = 0; - if (start > vgacon_scrollback_cnt) - start = vgacon_scrollback_cnt; + if (start > vgacon_scrollback.cnt) + start = vgacon_scrollback.cnt; if (end < 0) end = 0; - if (end > vgacon_scrollback_cnt) - end = vgacon_scrollback_cnt; + if (end > vgacon_scrollback.cnt) + end = vgacon_scrollback.cnt; - vgacon_scrollback_cur = start; + vgacon_scrollback.cur = start; count = end - start; - soff = vgacon_scrollback_tail - ((vgacon_scrollback_cnt - end) * + soff = vgacon_scrollback.tail - ((vgacon_scrollback.cnt - end) * c->vc_size_row); soff -= count * c->vc_size_row; if (soff < 0) - soff += vgacon_scrollback_size; + soff += vgacon_scrollback.size; - count = vgacon_scrollback_cnt - start; + count = vgacon_scrollback.cnt - start; if (count > c->vc_rows) count = c->vc_rows; @@ -287,13 +290,13 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) count *= c->vc_size_row; /* how much memory to end of buffer left? */ - copysize = min(count, vgacon_scrollback_size - soff); - scr_memcpyw(d, vgacon_scrollback + soff, copysize); + copysize = min(count, vgacon_scrollback.size - soff); + scr_memcpyw(d, vgacon_scrollback.data + soff, copysize); d += copysize; count -= copysize; if (count) { - scr_memcpyw(d, vgacon_scrollback, count); + scr_memcpyw(d, vgacon_scrollback.data, count); d += count; }