From patchwork Fri Feb 2 06:55:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 195641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp251193dyc; Thu, 1 Feb 2024 22:58:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFagV8tNTuwJLyXnij1Xl5dTUNpuhEQ+v60g0jCVlM4aazLT3boxvTZH+va5SvRdBIiwugG X-Received: by 2002:a05:620a:24c6:b0:783:9999:85 with SMTP id m6-20020a05620a24c600b0078399990085mr6382652qkn.42.1706857112730; Thu, 01 Feb 2024 22:58:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857112; cv=pass; d=google.com; s=arc-20160816; b=IhmJPql9QStdPPh9q644nDfMWpkSfWT/JpT9sZeF5/6AKKQz8GprwEavvtG9QuQFpr 0GWPLUAB7OfPa3g72GPlFKQFMAV7htWKkJ/sx7kJK6gyK7ve7hTzCcZ0WuibFIlVnprh vwxwFIJMfAYWkrKvbJhXrm1v32zYgk4cA2sF24aabM5jDTeOjyWu6NPrGBEdfRhtyW/e bpAD+YilqC3duYtUaExKWG8xDoJSsrUHXJ4Xt2kkV20DQHUVf+uqjpdPHaBcMg/P3YIh qBMX4dVZO9yaeFBWKR4Ce67ibCD5AFYwxHXX75lUQNhQZRPuW6HnzV1XYMOuPE95jRyh FQ1w== 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=aoo4vYxIONPZv3PPU7zQCkhkNDI8qgQyf2FpG8t+nA8=; fh=dr5sXeIbOv0fn3/o/SALjbOG+WSDHbde81K6JzVjBGE=; b=zPn4RrF7CcvXuTjWEWxdikwhkV0/IB7yzXBvi1gCXxc/UBPpN6QR1hNI4r8hIzrdUS zbIpZfprdNvv9E2W6rlsfCHwh45BWz22xCMUAlkAAWiH1TrFbzdBsCCgUj4pzeqWb2NL quXZNsXS/XVmYGgUq4hfAve6n67F+O3t/hHM15O04YyPX8uIS3NZcuT7Big7FGksZ+CV fDfl+04WH4XKdiEzTzJlhLeU8N6gGbnimuQm2JGPp8SvU/owipMiHSck3k6C2MxnlRc7 GKMiXoCN5qxBZ6yqgXIx1lU+fl8/rckJcbybcE0daYYGCEMYU/WSDc07Uj8BhOdfkdXl ePsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VsC1hGXa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXDhxZBJMF8E3sPWqm0fNf+W+2n1eJIax2bCetBbb37HulptMyruamb8l0YsJdm0I2YWdl5VpX7td3tcvSfRtPeKrdDxg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u13-20020a05620a454d00b00783f800eb25si1499008qkp.712.2024.02.01.22.58.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:58:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VsC1hGXa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49322-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49322-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6F4B71C234B8 for ; Fri, 2 Feb 2024 06:58:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFA0B1AACF; Fri, 2 Feb 2024 06:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VsC1hGXa" 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 108EE18B1A; Fri, 2 Feb 2024 06:56:22 +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=1706856983; cv=none; b=Dc2fg2dNjRVT+EWWi04z+wE9AgHMgLo0emsXAQ8PkBz99eS/zlMn10ojKUbc+yG1w/OX/IELWzkAcq5/Dg70DTXQzwnd4TuIgwxXTLO9xzVJOo3BKmKDj/qOZc2IxcwNa93GocflMiOv0VqO1tyNqudjK4UTieHA9cz8Qavttw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856983; c=relaxed/simple; bh=zkznFitIGz2Pjh+DWBKkgJYWUMuKCoX2dndhJadUQuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aPI9/88JNKa7u7vKAUl9rJt2x0XGHXa+GJJf5A30kFMeSwhp0NY4qam+7cblhwDsQuZhhRDxruzrYjzVurQYY8TUqGwSpjXnrRQGx7FqODe9I9YTyqSFRCjYoCIrYXUdNpl00CUsqHYEl+C3jQllKv2kxBoUPiCp/rAfmiBekno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VsC1hGXa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78580C433C7; Fri, 2 Feb 2024 06:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856982; bh=zkznFitIGz2Pjh+DWBKkgJYWUMuKCoX2dndhJadUQuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VsC1hGXai8T/J6kGDOoqZZn+xt85UFy8vY+mX3xA/YfJZ2XfS48vU2OTg5yVRIyB9 AEh21ZTb7aYIXdB5yyg1hu4pXaRv3cXW3F/uR8KZUVpNvUevxaLbsdsi8fsIQ1EkjX aOVWKsXEKicbmZzKOd0x1i/gW4cknOBqCeOTWgSeAEp6dRyXmkpUmmh8+dqQfv/6Xy xj7sRtR4JC3scoWps3WP/mt18u1I7RBeJeYaPCLxqlOw80TgNoXyfGc0OE4/WOnhTj JTjTmOa2aHEPEKqk7Mrn+pSUvbUtQyeYAw7RwmGjeho8WHa/UuMlMSm3O62JeFxGLX EZgDxl1afKvIA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 07/22] tty: vt: define an enum for CSI+] codes Date: Fri, 2 Feb 2024 07:55:53 +0100 Message-ID: <20240202065608.14019-8-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: 1789769403925862983 X-GMAIL-MSGID: 1789769403925862983 Decrypt the constant values by proper enum names. This time in setterm_command() (to be renamed to csi_RSB() in the next patches). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 04d109464994..9db545f305dc 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1955,62 +1955,76 @@ static void csi_hl(struct vc_data *vc, bool on_off) } } +enum CSI_right_square_bracket { + CSI_RSB_COLOR_FOR_UNDERLINE = 1, + CSI_RSB_COLOR_FOR_HALF_BRIGHT = 2, + CSI_RSB_MAKE_CUR_COLOR_DEFAULT = 8, + CSI_RSB_BLANKING_INTERVAL = 9, + CSI_RSB_BELL_FREQUENCY = 10, + CSI_RSB_BELL_DURATION = 11, + CSI_RSB_BRING_CONSOLE_TO_FRONT = 12, + CSI_RSB_UNBLANK = 13, + CSI_RSB_VESA_OFF_INTERVAL = 14, + CSI_RSB_BRING_PREV_CONSOLE_TO_FRONT = 15, + CSI_RSB_CURSOR_BLINK_INTERVAL = 16, +}; + /* console_lock is held */ static void setterm_command(struct vc_data *vc) { switch (vc->vc_par[0]) { - case 1: /* set color for underline mode */ + case CSI_RSB_COLOR_FOR_UNDERLINE: if (vc->vc_can_do_color && vc->vc_par[1] < 16) { vc->vc_ulcolor = color_table[vc->vc_par[1]]; if (vc->state.underline) update_attr(vc); } break; - case 2: /* set color for half intensity mode */ + case CSI_RSB_COLOR_FOR_HALF_BRIGHT: if (vc->vc_can_do_color && vc->vc_par[1] < 16) { vc->vc_halfcolor = color_table[vc->vc_par[1]]; if (vc->state.intensity == VCI_HALF_BRIGHT) update_attr(vc); } break; - case 8: /* store colors as defaults */ + case CSI_RSB_MAKE_CUR_COLOR_DEFAULT: vc->vc_def_color = vc->vc_attr; if (vc->vc_hi_font_mask == 0x100) vc->vc_def_color >>= 1; default_attr(vc); update_attr(vc); break; - case 9: /* set blanking interval */ + case CSI_RSB_BLANKING_INTERVAL: blankinterval = min(vc->vc_par[1], 60U) * 60; poke_blanked_console(); break; - case 10: /* set bell frequency in Hz */ + case CSI_RSB_BELL_FREQUENCY: if (vc->vc_npar >= 1) vc->vc_bell_pitch = vc->vc_par[1]; else vc->vc_bell_pitch = DEFAULT_BELL_PITCH; break; - case 11: /* set bell duration in msec */ + case CSI_RSB_BELL_DURATION: if (vc->vc_npar >= 1) vc->vc_bell_duration = (vc->vc_par[1] < 2000) ? msecs_to_jiffies(vc->vc_par[1]) : 0; else vc->vc_bell_duration = DEFAULT_BELL_DURATION; break; - case 12: /* bring specified console to the front */ + case CSI_RSB_BRING_CONSOLE_TO_FRONT: if (vc->vc_par[1] >= 1 && vc_cons_allocated(vc->vc_par[1] - 1)) set_console(vc->vc_par[1] - 1); break; - case 13: /* unblank the screen */ + case CSI_RSB_UNBLANK: poke_blanked_console(); break; - case 14: /* set vesa powerdown interval */ + case CSI_RSB_VESA_OFF_INTERVAL: vesa_off_interval = min(vc->vc_par[1], 60U) * 60 * HZ; break; - case 15: /* activate the previous console */ + case CSI_RSB_BRING_PREV_CONSOLE_TO_FRONT: set_console(last_console); break; - case 16: /* set cursor blink duration in msec */ + case CSI_RSB_CURSOR_BLINK_INTERVAL: if (vc->vc_npar >= 1 && vc->vc_par[1] >= 50 && vc->vc_par[1] <= USHRT_MAX) vc->vc_cur_blink_ms = vc->vc_par[1];