From patchwork Wed Nov 16 17:40:05 2016 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: 9432263 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 9228D60476 for ; Wed, 16 Nov 2016 17:40:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D5028F2E for ; Wed, 16 Nov 2016 17:40:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 798D028F41; Wed, 16 Nov 2016 17:40:23 +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.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 ED14828F2E for ; Wed, 16 Nov 2016 17:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752999AbcKPRkV (ORCPT ); Wed, 16 Nov 2016 12:40:21 -0500 Received: from mout.gmx.net ([212.227.15.19]:57355 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752938AbcKPRkU (ORCPT ); Wed, 16 Nov 2016 12:40:20 -0500 Received: from schoellingm.dzne.de ([37.201.241.34]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MbgWb-1cNucZ1Oez-00J428; Wed, 16 Nov 2016 18:40:10 +0100 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, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, andrey_utkin@fastmail.com Subject: [PATCH v4 1/2] console: Move scrollback data into its own struct Date: Wed, 16 Nov 2016 18:40:05 +0100 Message-Id: <1479318006-22023-1-git-send-email-manuel.schoelling@gmx.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1479317933-21849-3-git-send-email-manuel.schoelling@gmx.de> References: <1479317933-21849-3-git-send-email-manuel.schoelling@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K0:LQmDvLKJ3i5Jdw8TpeoIYVMX+FKKRcEZI3xlB8SNXPrVd21h/rq 5dkgca+gcgTsEH2N6fcLjooFXM3lyGACsy3z6s4Rq/9mTZgmeb8xPj6NsInPitBHDnbymT/ WtNbMNtyj/5Jm4QeWarcVP+AnIcBM1t3nuNVaqRgWo7Mef3VM+jYtl2WdUTZkr0/V+6iwr9 uY9sIVSWp8wURYJw/7fkw== X-UI-Out-Filterresults: notjunk:1; V01:K0:kCgtEXsjyc0=:kco28oUbHGQTRVcNEF53E7 KEG2eZWlJZ51v0/hd25TyRL5d9EZ7vvULh2Np+3mO6rQvfhot75jl3SFTO9SFIt6EKBbiua4V zwKBsL/4JqUW27OZ0j3brt6bf+9AMbL8FEJZ1+6fiPZJQ1Nm3UEJixAje3tqBJ1c6VYD/vXSm 7ABTWvqB/F9NN23I3O/8hgx3nNwmWawkn2Kq7dUlYGXGCn+yX1QbcMWZpjpfPOOIFw/eGdtN4 Ox8yd/vfCzwE1ELgIaslw3nOyDEWFqfhYTBbZMGtGQg/pgTTqh3UxoKng3Nf5QiozEjz9y1vi /044iVdHVRQtfL0C/hjKXS2Ge9LG+4GvNKx2QoUviiQnpJNffdR1okqSHrUUSpAGymt3AbFYy QfdW70FW057z/xyID7NvjI6DwXd959cd55DO7bEi+m9O0wjYxIMTCr0Zrnyc07EJJTzYD64/7 U2yLNfJNXvmPixHpNo5GyHH++wlZ0EYtcII4odDcz+Oh0Mxbj4nD2Tln65JFwFHwS5JJD0ZsC saNH9oEPEO1tbCcpiDM3DY7Hy+2T29LKs8DCQv8LIlVOfUsrfze/TwK47796Cx7tydX/2v4sE gOv5qUdm/g1kef1Slc9o+Zgn4TH/fQGv32wpKkguZqa+eHixiWoF0vDmC7vlF+wW8kkIyIxHr MYBhvPtx9PRH8aYYC6du807/J9SWCDtmwYnBWkIhDiIIZbPh3j7OafZMpagMYv/0Eu9smRWXJ CLfZEQG+pr4z/a+tEhE9ZaUWtQw+4gO7akg62eASVFJxpCC7v9sBhkFldsK73sDxFONWFCQgD Y/wOeQb 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 --- drivers/video/console/vgacon.c | 82 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index c22a562..d3f823a 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -162,31 +162,33 @@ 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 +196,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,17 +241,17 @@ 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) @@ -264,16 +266,16 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) 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 +289,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; }