From patchwork Wed May 30 21:27:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 137294 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp5817398lji; Wed, 30 May 2018 14:29:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKVoxqBeCYQ7jvtzSylwzdYsQsk0lHGfiCzoaRVSqAuVlLcjtUYOGBUGraame1xB0M1diTa X-Received: by 2002:a63:3348:: with SMTP id z69-v6mr69765pgz.171.1527715773993; Wed, 30 May 2018 14:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527715773; cv=none; d=google.com; s=arc-20160816; b=pMlnvwD4nXPaYjpsZ8FKF5UqBjRY+iVqw3Zyn/mR89Gbau1WyWYopBESbn7VBqUSJa 4duZfNkKt5Vfcni6UgkdMaMPiUhEzVaijCs8kbjd8PfTFBobXPl+VJ7Srv2Xzi1emAtZ On5RUClBy4VyxZ5Z+5JncvToISqbepDU62GFq7xZTj0qzDdglHAKzfZkseETRwVpIYn2 AxJV4v/0EqdZ28A77r5f4e5/ZmqgJ41dyHLiov3m1tOg48Vpb4+jhV/wzz/deFmITftD BReGpjM6F9X45Tbm6IGJMezMxLdX6j0n0UIfCKooBuT4AfHGRn0uCBcKiAwTeylp2NfZ zkVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=iAjb683DhMOW6yqjytXqBoz3NYNKYs8M2FBnsUSkbRw=; b=O/YnOnbsvR2g1nMKkLSnVroQJ4rD1XmPc/l/5ODQbEWIMWxbuC65FeSlRoBOQDe9dh 1/zaQlUciJEm0iCDu/zdIROtCQW57VrZm3ae/BCXReijO9nmoyq6JZc9VM2A4o1kCEp4 UvkkJqejpo9E+OvmrOkE1aAKEJ10mGAGatmR4A3gkDq+R6JvCYsJ/CZ5Oid2pMs7m+Tx IYAwfr3xA8NEcdd6AmGQMwNAUQ2Yup3qts+uFw395j8kEQ4NvV8Hzw0DGJYPDdE3qJjS gFzuGsyVjfGVwGniSs9+bmdDqOIk67DoGmiAidSbHgXnoRGrRMRaCAGd4rte+9xTVO3K 8+kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=SFyfKDGF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14-v6si18592699plo.359.2018.05.30.14.29.33; Wed, 30 May 2018 14:29:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=SFyfKDGF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932653AbeE3V3b (ORCPT + 30 others); Wed, 30 May 2018 17:29:31 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:62606 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932300AbeE3V2V (ORCPT ); Wed, 30 May 2018 17:28:21 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 6CFCFF351A; Wed, 30 May 2018 17:28:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=9DAw iQEBBOWmo4PgLUwwV9ngQQ4=; b=SFyfKDGF8nG1Ic0ZlnMC7bw4Wq9ptw3sUgUb 7GxXfyDsnB6QUscuZRyyadjZbM0o4bxXpf4SXwG9JeuFT+6zu4a0xJU70sjZM+m0 NSq2c7e7C6JrKt6nA7knLywwExC9/EKC3ZX/Q6P4tWzkzweA8F9nCi2m7l7+1elY TN0Qn48= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 63C48F3519; Wed, 30 May 2018 17:28:19 -0400 (EDT) Received: from yoda.home (unknown [70.82.104.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id E0416F3512; Wed, 30 May 2018 17:28:18 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 2D2C22DA06B7; Wed, 30 May 2018 17:28:18 -0400 (EDT) From: Nicolas Pitre To: Greg Kroah-Hartman Cc: Dave Mielke , Samuel Thibault , linux-kernel@vger.kernel.org Subject: [PATCH 4/5] vt: unicode fallback for scrollback Date: Wed, 30 May 2018 17:27:44 -0400 Message-Id: <20180530212745.10997-5-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530212745.10997-1-nicolas.pitre@linaro.org> References: <20180530212745.10997-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: 5F0906B6-6450-11E8-B454-67830C78B957-78420484!pb-smtp2.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is currently no provision for scrollback content in the core code, leaving that to backend video drivers where this can be highly optimized. There is currently no common method for those drivers to tell the core what part of the scrollback is actually displayed and what size the scrollback buffer is either. Because of that, the unicode screen buffer has no provision for any scrollback. At least we can provide backtranslated glyph values when the scrollback is active which should be plenty good enough for now. Signed-off-by: Nicolas Pitre Tested-by: Dave Mielke --- drivers/tty/vt/vc_screen.c | 3 ++- drivers/tty/vt/vt.c | 31 +++++++++++++++++++++++++++++-- include/linux/selection.h | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) -- 2.17.0 diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c index 9c44252e52..2384ea85ff 100644 --- a/drivers/tty/vt/vc_screen.c +++ b/drivers/tty/vt/vc_screen.c @@ -311,7 +311,8 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) do { if (nr > this_round/4) nr = this_round/4; - vc_uniscr_copy_line(vc, con_buf0, row, col, nr); + vc_uniscr_copy_line(vc, con_buf0, viewed, + row, col, nr); con_buf0 += nr * 4; this_round -= nr * 4; row++; diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 2cba6089ca..e7c3cabeb1 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -535,13 +535,40 @@ int vc_uniscr_check(struct vc_data *vc) * This must be preceded by a successful call to vc_uniscr_check() once * the console lock has been taken. */ -void vc_uniscr_copy_line(struct vc_data *vc, void *dest, +void vc_uniscr_copy_line(struct vc_data *vc, void *dest, int viewed, unsigned int row, unsigned int col, unsigned int nr) { struct uni_screen *uniscr = get_vc_uniscr(vc); + int offset = row * vc->vc_size_row + col * 2; + unsigned long pos; BUG_ON(!uniscr); - memcpy(dest, &uniscr->lines[row][col], nr * sizeof(char32_t)); + + pos = (unsigned long)screenpos(vc, offset, viewed); + if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { + /* + * Desired position falls in the main screen buffer. + * However the actual row/col might be different if + * scrollback is active. + */ + row = (pos - vc->vc_origin) / vc->vc_size_row; + col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2; + memcpy(dest, &uniscr->lines[row][col], nr * sizeof(char32_t)); + } else { + /* + * Scrollback is active. For now let's simply backtranslate + * the screen glyphs until the unicode screen buffer does + * synchronize with console display drivers for a scrollback + * buffer of its own. + */ + u16 *p = (u16 *)pos; + int mask = vc->vc_hi_font_mask | 0xff; + char32_t *uni_buf = dest; + while (nr--) { + u16 glyph = scr_readw(p++) & mask; + *uni_buf++ = inverse_translate(vc, glyph, true); + } + } } diff --git a/include/linux/selection.h b/include/linux/selection.h index 2b34df9f1e..067d2e99c7 100644 --- a/include/linux/selection.h +++ b/include/linux/selection.h @@ -43,7 +43,7 @@ extern void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org); extern void vcs_scr_updated(struct vc_data *vc); extern int vc_uniscr_check(struct vc_data *vc); -extern void vc_uniscr_copy_line(struct vc_data *vc, void *dest, +extern void vc_uniscr_copy_line(struct vc_data *vc, void *dest, int viewed, unsigned int row, unsigned int col, unsigned int nr);