From patchwork Wed Jun 27 03:56:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 140088 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp358784ljj; Tue, 26 Jun 2018 20:57:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKOCHIfvOTwg1feK/u+Odl13TghInWGxeI+fa7XYDPnKbu1gj9yAIwqYcl80iT6HK2EqQR9 X-Received: by 2002:a17:902:b217:: with SMTP id t23-v6mr4381946plr.312.1530071851657; Tue, 26 Jun 2018 20:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530071851; cv=none; d=google.com; s=arc-20160816; b=KStd7jyZySBtPgsSi5KkAmH667LnPkoI9XIqFgNGEa0fCUtXAMU+8/SudfUrrByv/J REYpO2dXNn2z+eq0BLs+FvtipVxtWVSLFq0hY/0iuZslGKJhMy2gfRfOCl/Kd2loLD0A qN+5BU4BdLkrIql6A4RwjwrB+jDTfY1p9ekLaO/KSPX8oBsf5WNUIByLZBgqQ0YY6cH+ SIi+oF9BENBsJPmAQqAtGtzz9FeCg3Fmlse7kqNnCuC8yrflqtC0/J3rlgM7X06PYpuK mQbKJecsNfLw92g3RYL7TJS0MXjYcsVLhlojARFsdmZHtuJNJVQxSvkGp7UpUUk/DBSD SLKg== 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=DbeQjCKISlqtemaVyjv7Z+nnAkbZkPz0fA9A5n1dtlI=; b=wneDl1IOI4fl62FskOvyFAQuTPIa6DcYBbPAFI1akbFXrwSWlKJKFjAO0a9opVlIyf SB0ujJfV8MAjHb2az/a8TId6LqGUyMLXgp5hFbnhQDWMbODgX+96m8D/uEEfuJY8gbmG Yp84bTm7aZyvDoCmQIm/iTmmljujncp/PKgMCfjJbu7hqLMIetThNjiSWFlmxb0Xm7th KkHB1w9rOZ4dbkRaKHX/9OrFzexQtAh80nCr/oviU40Z3MZefEoHNnGMPR5lRkv7ISyX HvadLaqj6bqi2/XapTQ6d5vwB4szQjjIVdxLeD97gXioDWeLueUhz8Ka5/TtWI1t2DzJ eUMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=PYLJBPNl; 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 w135-v6si3109868pff.18.2018.06.26.20.57.31; Tue, 26 Jun 2018 20:57:31 -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=PYLJBPNl; 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 S1753238AbeF0D4u (ORCPT + 31 others); Tue, 26 Jun 2018 23:56:50 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:50274 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750909AbeF0D4s (ORCPT ); Tue, 26 Jun 2018 23:56:48 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 54FC7E7782; Tue, 26 Jun 2018 23:56:46 -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=ABWv dJzh4qOnthHLY9zePogflFs=; b=PYLJBPNlfai7KssOzRHPYcJfQBVDiZhw8ixP V4DlhF0kYRvQ3a+qOcJkSX8877QcPFaytdovukSsurXR47P2VIPx14OgthBY+0JD StPALUs/NqF5v0hOARORmN8AesL9xaGExaJgOYm6yoBpOa+dN0PWqGIx0SMq0ldS 344f6jM= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4CC31E7780; Tue, 26 Jun 2018 23:56:46 -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 A194CE777D; Tue, 26 Jun 2018 23:56:45 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id EA1242DA0674; Tue, 26 Jun 2018 23:56:44 -0400 (EDT) From: Nicolas Pitre To: Greg Kroah-Hartman Cc: Dave Mielke , Samuel Thibault , Adam Borowski , Alan Cox , linux-kernel@vger.kernel.org, linux-console@vger.kernel.org Subject: [PATCH v3 3/3] vt: unicode fallback for scrollback Date: Tue, 26 Jun 2018 23:56:42 -0400 Message-Id: <20180627035642.8561-4-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180627035642.8561-1-nicolas.pitre@linaro.org> References: <20180627035642.8561-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: 1C1620EA-79BE-11E8-8995-40570C78B957-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 Acked-by: Adam Borowski --- 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.1 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 062ce6be79..2d14bb195d 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -533,13 +533,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);