From: Samuel Thibault <samuel.thibault@ens-lyon.org> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, kbd@lists.altlinux.org Cc: "linux-kernel@vger.kernel.org, Samuel Thibault" <samuel.thibault@ens-lyon.org>, linux-kernel@vger.kernel.org Subject: [kbd] [PATCHv3 2/3] VT: Add KD_FONT_OP_SET/GET_TALL operations Date: Thu, 19 Jan 2023 16:19:16 +0100 Message-ID: <20230119151935.013597162@ens-lyon.org> (raw) In-Reply-To: <20230119151914.931619963@ens-lyon.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 <samuel.thibault@ens-lyon.org> 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] */
next prev parent reply other threads:[~2023-01-19 15:19 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-19 15:19 [kbd] [PATCHv3 0/3] VT: Support >32x32 fonts for hidpi displays Samuel Thibault 2023-01-19 15:19 ` [kbd] [PATCHv3 1/3] VT: Add height parameter to con_font_get/set consw operations Samuel Thibault 2023-01-19 15:19 ` Samuel Thibault [this message] 2023-01-19 15:19 ` [kbd] [PATCHv3 3/3] VT: Bump font size limitation to 64x128 pixels Samuel Thibault 2023-01-19 15:23 ` [kbd] [PATCHv3 0/3] VT: Support >32x32 fonts for hidpi displays Greg Kroah-Hartman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230119151935.013597162@ens-lyon.org \ --to=samuel.thibault@ens-lyon.org \ --cc=gregkh@linuxfoundation.org \ --cc=jirislaby@kernel.org \ --cc=kbd@lists.altlinux.org \ --cc=linux-kernel@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux console tools development discussion This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/kbd/0 kbd/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 kbd kbd/ http://lore.altlinux.org/kbd \ kbd@lists.altlinux.org kbd@lists.altlinux.ru kbd@lists.altlinux.com public-inbox-index kbd Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.kbd AGPL code for this site: git clone https://public-inbox.org/public-inbox.git