From patchwork Fri Feb 2 06:55:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 195656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp254375dyc; Thu, 1 Feb 2024 23:05:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtpi15S3AHCZmCSSRGKUyYhosrmT5UC8p+ZRfkD2tYYTfIXboNjRvCUQxMdmzc8cYUN09P X-Received: by 2002:a05:6a00:1acf:b0:6db:957:d241 with SMTP id f15-20020a056a001acf00b006db0957d241mr1936689pfv.1.1706857532879; Thu, 01 Feb 2024 23:05:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857532; cv=pass; d=google.com; s=arc-20160816; b=nI0wKnvl6T80wCXbwH+5oGHqvMJlz5YaTd7n2zVdzNo9CDby7y77Bhn/dsMsTd4D9N h1ygZFUfAz5lnVe/90gXgAKQcuwq5yHwpl3G8wTSBjib9mrFIOmzFOM21WL6qdGGRcEq IZhlJCgkY6EJhQO+pFIelgtCCYWeMUI5qVk+GTz3WW30QNSoaPwDlLb2bYTsEd0vQKav PJfTf9PgASShkQL5+sCPfzeOpnSazBxvLnv+C6MPnWAqfV3E/Jvs2vVcsNWVhCn/c5jP IcKYwID9rKsZ6tsW5BsgNhEeWm3/IWx4hZU5hLCDuqHKYR9YQExv4V6Thy12N0kkYffe S6Uw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QBq6GzAJ1JLQJrsjBzliG6IglMPgLVO2bz4edX9hsMc=; fh=i8o2xpWcl9tFLSkocHfih1UrNWFoX2FGgITBOb9IXnM=; b=ycuqgzjKd74woicyGmrmnQeYy16XgAJXCVnB92KGS8Ly0IgdIKKAjhEAkiZDQRASkX LDmqBsendiArnXb50xzhBkFefMsO47E3chA5B/5xsx3G+ee9RNp+hXCy7EESM30YWmxB NWsP8QJCIbXHMKeg2MrMC4MzeYD0qXbWf+O+2TkFxAn/pkDgWZZfeIo3eVYcKtjVduW4 D6VeQv65qausJlbOetfFARfRT4hVrtiBr3Fvt7Wc0HaGYXYASMtU645PPseemOtFZQzd yBMRc3lNqWkt23bZiKsH+EiX8dJwh6LWmwrViHuhRspk2zNuflt4+Pfsi+0KzLnEgpxK exKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RASuBlnz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWsqRYyW0oUywhHqLrRQ1RPg3B3nAvq+QpwX2N/IddAhoyxkxlBC4p+6T4CtFULS5KQwnv7xEnOOgSNvb83Ms1UfBZGCA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u29-20020a62d45d000000b006de39f137ecsi1064371pfl.92.2024.02.01.23.05.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:05:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RASuBlnz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 17692B260BE for ; Fri, 2 Feb 2024 06:57:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D64418636; Fri, 2 Feb 2024 06:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RASuBlnz" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 905AD18036; Fri, 2 Feb 2024 06:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856978; cv=none; b=FEabLS1bxAPVfC71/S7wGeQAItpBaNyK2JeGRXcsLWtDcQbMUQ+2WXVNBJzfZdvYZzHLGoZTEkU5lb7bNkePXfTWJQp0CyCLXDrvxBK4GI9zUNBaiDkq1wOedc3dqsk+aup46H1KyJOdqGZafoSDqkiAqwerlkHS2C8itOeR/sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856978; c=relaxed/simple; bh=miH8BEvG/hsFaXFdQjVxX6ykS62LQxmbGXrx1onhjCA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p4WxYzeupey9TVm7qIumQB06SfmujKT3I/0PPajS23U6KvHPbWpzx7qdw2W7a9h5jdVPSPm33gOt2eayvU0jtgXTLJGIjfOsUYE/vAajNqbY4gpUh41zoOLy0C7B1WRVwZcMZyDhl7/W+4KhpveRxkd2eWQdiI76ghjeWL1NikA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RASuBlnz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE841C433C7; Fri, 2 Feb 2024 06:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856978; bh=miH8BEvG/hsFaXFdQjVxX6ykS62LQxmbGXrx1onhjCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RASuBlnzt4kzH4bqRksl37SOd8Mpr2gElneWbxC6iEeW5Tn7GTLbGe3kS11DD2XWW U/aZ6bCHc/HDD/cpIj2Ji1r1+KLsUigWKqF80hF9Qq2ikc/GE5QF/DJCBu7JCniEFA TBVr9CGOh4/rTR6zyR7DjMypg71e0ZPy/GVe4AfP/K+YJf9+AW6KMmsJw5Jgi5d0JN b1gkZflbUN8N+HlLns9vwALQ7Jo9SNBPAaTe1BjakhbbFp8zYam/ReYR7ygcQfRvkr QQzGBHFxP0j/iYfeCpGd6b22wsAauN2lKAWs5hzKV+OUQ8InoSSUswN3KJgqG+GIIp +cGJYBatY5VaQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 04/22] tty: vt: split DEC CSI+h/l handling into csi_DEC_hl() Date: Fri, 2 Feb 2024 07:55:50 +0100 Message-ID: <20240202065608.14019-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769844310443276 X-GMAIL-MSGID: 1789769844310443276 The DEC and ECMA handling of CSI+h/l is needlessly complicated. Split these two, so that DEC is handled when the state is EPdec ('CSI ?' was seen) and ECMA is handled in the EPecma state (no '?'). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 144 +++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 67 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index ae333f49790a..d04dbafc0517 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1874,6 +1874,59 @@ enum { CSI_DEC_hl_MOUSE_VT200 = 1000, }; +/* console_lock is held */ +static void csi_DEC_hl(struct vc_data *vc, bool on_off) +{ + unsigned int i; + + for (i = 0; i <= vc->vc_npar; i++) + switch (vc->vc_par[i]) { + case CSI_DEC_hl_CURSOR_KEYS: + if (on_off) + set_kbd(vc, decckm); + else + clr_kbd(vc, decckm); + break; + case CSI_DEC_hl_132_COLUMNS: /* unimplemented */ +#if 0 + vc_resize(deccolm ? 132 : 80, vc->vc_rows); + /* this alone does not suffice; some user mode + utility has to change the hardware regs */ +#endif + break; + case CSI_DEC_hl_REVERSE_VIDEO: + if (vc->vc_decscnm != on_off) { + vc->vc_decscnm = on_off; + invert_screen(vc, 0, vc->vc_screenbuf_size, + false); + update_attr(vc); + } + break; + case CSI_DEC_hl_ORIGIN_MODE: + vc->vc_decom = on_off; + gotoxay(vc, 0, 0); + break; + case CSI_DEC_hl_AUTOWRAP: + vc->vc_decawm = on_off; + break; + case CSI_DEC_hl_AUTOREPEAT: + if (on_off) + set_kbd(vc, decarm); + else + clr_kbd(vc, decarm); + break; + case CSI_DEC_hl_MOUSE_X10: + vc->vc_report_mouse = on_off ? 1 : 0; + break; + case CSI_DEC_hl_SHOW_CURSOR: + vc->vc_deccm = on_off; + break; + case CSI_DEC_hl_MOUSE_VT200: + vc->vc_report_mouse = on_off ? 2 : 0; + break; + } +} + enum { CSI_hl_DISPLAY_CTRL = 3, /* handle ansi control chars */ CSI_hl_INSERT = 4, /* IRM: insert/replace */ @@ -1883,71 +1936,22 @@ enum { /* console_lock is held */ static void csi_hl(struct vc_data *vc, bool on_off) { - int i; + unsigned int i; for (i = 0; i <= vc->vc_npar; i++) - if (vc->vc_priv == EPdec) { - switch(vc->vc_par[i]) { /* DEC private modes set/reset */ - case CSI_DEC_hl_CURSOR_KEYS: - if (on_off) - set_kbd(vc, decckm); - else - clr_kbd(vc, decckm); - break; - case CSI_DEC_hl_132_COLUMNS: /* unimplemented */ -#if 0 - vc_resize(deccolm ? 132 : 80, vc->vc_rows); - /* this alone does not suffice; some user mode - utility has to change the hardware regs */ -#endif - break; - case CSI_DEC_hl_REVERSE_VIDEO: - if (vc->vc_decscnm != on_off) { - vc->vc_decscnm = on_off; - invert_screen(vc, 0, - vc->vc_screenbuf_size, - false); - update_attr(vc); - } - break; - case CSI_DEC_hl_ORIGIN_MODE: - vc->vc_decom = on_off; - gotoxay(vc, 0, 0); - break; - case CSI_DEC_hl_AUTOWRAP: - vc->vc_decawm = on_off; - break; - case CSI_DEC_hl_AUTOREPEAT: - if (on_off) - set_kbd(vc, decarm); - else - clr_kbd(vc, decarm); - break; - case CSI_DEC_hl_MOUSE_X10: - vc->vc_report_mouse = on_off ? 1 : 0; - break; - case CSI_DEC_hl_SHOW_CURSOR: - vc->vc_deccm = on_off; - break; - case CSI_DEC_hl_MOUSE_VT200: - vc->vc_report_mouse = on_off ? 2 : 0; - break; - } - } else { - switch(vc->vc_par[i]) { /* ANSI modes set/reset */ - case CSI_hl_DISPLAY_CTRL: - vc->vc_disp_ctrl = on_off; - break; - case CSI_hl_INSERT: - vc->vc_decim = on_off; - break; - case CSI_hl_AUTO_NL: - if (on_off) - set_kbd(vc, lnm); - else - clr_kbd(vc, lnm); - break; - } + switch (vc->vc_par[i]) { /* ANSI modes set/reset */ + case CSI_hl_DISPLAY_CTRL: + vc->vc_disp_ctrl = on_off; + break; + case CSI_hl_INSERT: + vc->vc_decim = on_off; + break; + case CSI_hl_AUTO_NL: + if (on_off) + set_kbd(vc, lnm); + else + clr_kbd(vc, lnm); + break; } } @@ -2379,12 +2383,12 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_state = ESnormal; switch(c) { case 'h': - if (vc->vc_priv <= EPdec) - csi_hl(vc, true); + if (vc->vc_priv == EPdec) + csi_DEC_hl(vc, true); return; case 'l': - if (vc->vc_priv <= EPdec) - csi_hl(vc, false); + if (vc->vc_priv == EPdec) + csi_DEC_hl(vc, false); return; case 'c': if (vc->vc_priv == EPdec) { @@ -2494,6 +2498,12 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) else if (vc->vc_par[0] == 3) bitmap_zero(vc->vc_tab_stop, VC_TABSTOPS_COUNT); return; + case 'h': + csi_hl(vc, true); + return; + case 'l': + csi_hl(vc, false); + return; case 'm': csi_m(vc); return;