Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3143201imm; Sun, 17 Jun 2018 12:08:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKkypVD4O3DGvNFvOeoLTs217amtchczPW59yjfi6CpEq+QlYLWEy8RWmILr3eM5tc/OEzf X-Received: by 2002:a17:902:262:: with SMTP id 89-v6mr2223364plc.252.1529262505360; Sun, 17 Jun 2018 12:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529262505; cv=none; d=google.com; s=arc-20160816; b=HFmvDLaQJN+H/a7Ak3GcQQSPgA8KD2BT+2nfzu51R3a/wBYgxhmLEyFP/8JNg8/jG5 MrY+eGzgWo1+wQpjWG+0PSUG6uldtHbc/vhnPGwqFODG0nNoAqyl7HrNFOaCtTjXyFgy +cc1BtF+heynYw6lrNHkleTvHOdGir//NFMThDdtLeH66WXFQutKaPaD2Ry/TWn5R7O/ XYOwMJTpIee8Rlpw5NATTGg1BBkEWE7Sj5UUDzASmQLyxDC9UnZGtPqnAdbNtux0tVlV yKWMzwMMBnd4fKd1yuTi7keIhnZkgDsvkqXnzaK5NrH3/pgDT66UOIr+ZE1XGpc5c3d8 zl1g== 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=oCIWBVMKS0igT29Pa4NHplLMzOPFDDTUwRCqM4bZyi0=; b=oNPJpFuwBkpyNc4vcWc8GFPacP0xpUE+Hd9YmfJNnl2+ySAdRXRaCL2suiY7vX+4w/ CSopYGw1hXtvCczSV3z58uw3xg9RMTNukB5nHD3JwklMHC/Ye/LSFGgrEckKQ9O4dbRW NNQJ2PTa/7k0FasAXXIwsqHAEkaab30Kzc6vxAkrvTNr8bILYEJYe2C382ljuVdTCxvN 4J+/6EknoqPeiqxOVjOCiv8mex5YTnSVp5SLk1OfJP6D9EU4kOadolt6gATQ+0aq9TZz hlqLzckkMwh6oYOprTYA11Tt0Dm7ROHHAcnsATn1P+q7Rqu0ob1MP+e7ANdXJu2SqlTL tARA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=MkTwNdl6; 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 v127-v6si10667709pgv.212.2018.06.17.12.08.10; Sun, 17 Jun 2018 12:08:25 -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=MkTwNdl6; 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 S1755347AbeFQTHT (ORCPT + 99 others); Sun, 17 Jun 2018 15:07:19 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:63272 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753979AbeFQTHM (ORCPT ); Sun, 17 Jun 2018 15:07:12 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 227D2FC13D; Sun, 17 Jun 2018 15:07:10 -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=a5Gh xUmqV6OkvOYBm2zqBNKyM2Q=; b=MkTwNdl6OWjxL7jZwYkxhcBwPULTE38WWWNg te/oGsH9UqiRfAuKUK2I1W+oBbuPDU0XatzpthvgSINB1WShsUPYYHEmUVH+RT/j mZbZPFFY6oLJ2lONS3qWA7t+6GBdCeLY8nGc4jwQwMFIJZubRtoX/QilK5kjj14L GSbmIRk= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 199A0FC13C; Sun, 17 Jun 2018 15:07:10 -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-smtp1.pobox.com (Postfix) with ESMTPSA id A0C1BFC132; Sun, 17 Jun 2018 15:07:09 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id D05ED2DA0677; Sun, 17 Jun 2018 15:07:08 -0400 (EDT) From: Nicolas Pitre To: Greg Kroah-Hartman Cc: Dave Mielke , Samuel Thibault , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] vt: unicode fallback for scrollback Date: Sun, 17 Jun 2018 15:07:05 -0400 Message-Id: <20180617190706.14614-4-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180617190706.14614-1-nicolas.pitre@linaro.org> References: <20180617190706.14614-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: A265053A-7261-11E8-90DD-44CE1968708C-78420484!pb-smtp1.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(-) 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); -- 2.17.1