Received: by 2002:ac8:1418:0:b0:3ab:920c:4c8b with SMTP id k24csp434286qtj; Thu, 19 Jan 2023 08:05:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXvAfgQ8YNFLt/VuRroFp6MMjmD61djGNPaMMKLX/P+dvcghtDvlAsyuO9KUzWKd4DSWtS8p X-Received: by 2002:a17:902:7c15:b0:189:77c1:b5a7 with SMTP id x21-20020a1709027c1500b0018977c1b5a7mr11489077pll.41.1674144355790; Thu, 19 Jan 2023 08:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674144355; cv=none; d=google.com; s=arc-20160816; b=KEX3P23WriQP24/hVdf9yDfsh7y6T39TsXXVoOkAIeemLQnczsx7kBTp99Hiu2hzV9 PIUcgZuXwlZoBCrT2UeESIYnTtU2U8RlPj2gaA+NDy1h7yKV6NQq/y1uzYpcIaMC+M/0 /gj1TD4kNpYtie66ePgPu8GvwfRB84jIISV/t8rLWkD1KoefOrFY5RhprCQSYrv9sNJv Yr5Uts4CMvDi8tWsmreSUJLYvVd18WkSlcvLE4UQ6Tg3vQeOajbkvUYciIOrrZFHrRvZ ucuFd50ORgdkojsS35JjwRXVvukridLzwro50+iGzVH2EJu5WtIDzs+FJcuKtsk5Fhx8 /YlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=l73fC64ccu8ncbrRCW2NKFPhU+voWUpvmAP+8oIcqL0=; b=WO/ocHYSW3i57rCGV1bRlGxwF/oxmmgqXTbhwRQQo0YVL4h1V3GquTH1dhaf05naWA pNb2YlR3swxBAgF6vA/+tFIJedNEyMf4vQehYMctfRQWz9qu9uSR62O3S1p+RniAsH7Q 2irr3IXHCFpnfBhhS0wakPA8TTpbG5BcnL/q0W7vHP1xIRQddnGEPM3Vm8I8Jq4w3S4h +QM4GeQeidWd86agJeAit9nLSlKNpKHm1qOaHFTs45M693/iPuaNLPSEIxjfgHvhlHW7 BlpQ5v2XoaO2Tw+1bKBwXa2uobr5wkNUDGoIoPWZfhSOc8zrYBSdPR5T420gweR3WSG2 TH/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a170902ea0c00b001926d641de9si42128086plg.553.2023.01.19.08.05.49; Thu, 19 Jan 2023 08:05:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbjASPUF (ORCPT + 45 others); Thu, 19 Jan 2023 10:20:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbjASPT5 (ORCPT ); Thu, 19 Jan 2023 10:19:57 -0500 Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A126B82D58 for ; Thu, 19 Jan 2023 07:19:55 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id E71C6200FB; Thu, 19 Jan 2023 16:19:53 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YvQta9sPITvO; Thu, 19 Jan 2023 16:19:53 +0100 (CET) Received: from begin (nat-inria-interne-52-gw-01-bso.bordeaux.inria.fr [194.199.1.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 6CCF820105; Thu, 19 Jan 2023 16:19:53 +0100 (CET) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pIWhl-008cHt-0T; Thu, 19 Jan 2023 16:19:53 +0100 Message-ID: <20230119151935.013597162@ens-lyon.org> User-Agent: quilt/0.66 Date: Thu, 19 Jan 2023 16:19:16 +0100 From: Samuel Thibault To: Greg Kroah-Hartman , Jiri Slaby , kbd@lists.altlinux.org Cc: linux-kernel@vger.kernel.org, "linux-kernel@vger.kernel.org, Samuel Thibault" Subject: [PATCHv3 2/3] VT: Add KD_FONT_OP_SET/GET_TALL operations References: <20230119151914.931619963@ens-lyon.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The KD_FONT_OP_SET/GET operations hardcode vpitch to be 32 pixels, which only dates from the old VGA hardware which as asserting this. Drivers such as fbcon however do not have such limitation, so this introduces KD_FONT_OP_SET/GET_TALL operations, which userland can try to use to avoid this limitation, thus opening the patch to >32 pixels font height. Signed-off-by: Samuel Thibault Index: linux-6.0/drivers/tty/vt/vt.c =================================================================== --- linux-6.0.orig/drivers/tty/vt/vt.c +++ linux-6.0/drivers/tty/vt/vt.c @@ -4592,6 +4592,7 @@ static int con_font_get(struct vc_data * struct console_font font; int rc = -EINVAL; int c; + unsigned int vpitch = op->op == KD_FONT_OP_GET_TALL ? op->height : 32; if (op->data) { font.data = kmalloc(max_font_size, GFP_KERNEL); @@ -4604,7 +4605,7 @@ static int con_font_get(struct vc_data * if (vc->vc_mode != KD_TEXT) rc = -EINVAL; else if (vc->vc_sw->con_font_get) - rc = vc->vc_sw->con_font_get(vc, &font, 32); + rc = vc->vc_sw->con_font_get(vc, &font, vpitch); else rc = -ENOSYS; console_unlock(); @@ -4612,7 +4613,7 @@ static int con_font_get(struct vc_data * if (rc) goto out; - c = (font.width+7)/8 * 32 * font.charcount; + c = (font.width+7)/8 * vpitch * font.charcount; if (op->data && font.charcount > op->charcount) rc = -ENOSPC; @@ -4638,6 +4639,7 @@ static int con_font_set(struct vc_data * struct console_font font; int rc = -EINVAL; int size; + unsigned int vpitch = op->op == KD_FONT_OP_SET_TALL ? op->height : 32; if (vc->vc_mode != KD_TEXT) return -EINVAL; @@ -4647,7 +4649,9 @@ static int con_font_set(struct vc_data * return -EINVAL; if (op->width <= 0 || op->width > 32 || !op->height || op->height > 32) return -EINVAL; - size = (op->width+7)/8 * 32 * op->charcount; + if (vpitch < op->height) + return -EINVAL; + size = (op->width+7)/8 * vpitch * op->charcount; if (size > max_font_size) return -ENOSPC; @@ -4665,7 +4669,7 @@ static int con_font_set(struct vc_data * else if (vc->vc_sw->con_font_set) { if (vc_is_sel(vc)) clear_selection(); - rc = vc->vc_sw->con_font_set(vc, &font, 32, op->flags); + rc = vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags); } else rc = -ENOSYS; console_unlock(); @@ -4711,8 +4715,10 @@ int con_font_op(struct vc_data *vc, stru { switch (op->op) { case KD_FONT_OP_SET: + case KD_FONT_OP_SET_TALL: return con_font_set(vc, op); case KD_FONT_OP_GET: + case KD_FONT_OP_GET_TALL: return con_font_get(vc, op); case KD_FONT_OP_SET_DEFAULT: return con_font_default(vc, op); Index: linux-6.0/include/uapi/linux/kd.h =================================================================== --- linux-6.0.orig/include/uapi/linux/kd.h +++ linux-6.0/include/uapi/linux/kd.h @@ -161,19 +161,25 @@ struct console_font_op { unsigned int flags; /* KD_FONT_FLAG_* */ unsigned int width, height; /* font size */ unsigned int charcount; - unsigned char __user *data; /* font data with height fixed to 32 */ + unsigned char __user *data; /* font data with vpitch fixed to 32 for + * KD_FONT_OP_SET/GET + */ }; struct console_font { unsigned int width, height; /* font size */ unsigned int charcount; - unsigned char *data; /* font data with height fixed to 32 */ + unsigned char *data; /* font data with vpitch fixed to 32 for + * KD_FONT_OP_SET/GET + */ }; #define KD_FONT_OP_SET 0 /* Set font */ #define KD_FONT_OP_GET 1 /* Get font */ #define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */ #define KD_FONT_OP_COPY 3 /* Obsolete, do not use */ +#define KD_FONT_OP_SET_TALL 4 /* Set font with vpitch = height */ +#define KD_FONT_OP_GET_TALL 5 /* Get font with vpitch = height */ #define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size [compat] */