From nobody Wed Feb 11 10:38:05 2026 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) (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 72C5912C522 for ; Mon, 26 Feb 2024 15:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.211.30.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960960; cv=none; b=txSVx+g+XLOZTsdsuRYzkY+TMO18Zgp2iLtzYYTa2bYYq+HPCNkabJkjlny5HvjQYQ+nCyZH0VWU9LO3wczB708bXGMXAOiR1VjKPQvjzSCNOP4Tc1GQ3q0OOPX8C2xdMa67G2fXlwhOGKgVndOs4cUkGOWEXrCwkqTMx/yQ2S4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960960; c=relaxed/simple; bh=XXRAFqi6kit/CJzUZCswo5V1wts4Yus3f0+vof+UBHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z4WrzbEZYsmGGpcZkseMtCh4PpcD6ouQtK/dYEm7RmgxTB4HLcbxulTiVVI6KSFLP27QOylkaMXbhT83EaOpevnjXwI5zvLK7SRrJqTcUD2jyNrkf/KdLMaSbYLizHzH77bjpEP377S/S3/uIVz+DCsLKD9FSRdzF75kKC0qiLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=fail smtp.mailfrom=kernel.org; arc=none smtp.client-ip=207.211.30.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-qE5a-wOcMIKf7NpvicHYHg-1; Mon, 26 Feb 2024 10:21:23 -0500 X-MC-Unique: qE5a-wOcMIKf7NpvicHYHg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D37ED800074; Mon, 26 Feb 2024 15:21:22 +0000 (UTC) Received: from gentoo.redhat.com (unknown [10.45.224.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21406492BE2; Mon, 26 Feb 2024 15:21:22 +0000 (UTC) From: Alexey Gladkov To: LKML , Greg Kroah-Hartman , Jiri Slaby Cc: linux-api@vger.kernel.org Subject: [RFC PATCH v2 1/5] VT: Add KD_FONT_OP_GET_INFO operation Date: Mon, 26 Feb 2024 16:21:10 +0100 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Content-Type: text/plain; charset="utf-8" Each driver has its own restrictions on font size. There is currently no way to understand what the requirements are. The new operation allows userspace to get the maximum font size values. Signed-off-by: Alexey Gladkov --- drivers/tty/vt/vt.c | 24 ++++++++++++++++++++++++ drivers/tty/vt/vt_ioctl.c | 12 ++++++++++++ include/linux/console.h | 2 ++ include/linux/vt_kern.h | 1 + include/uapi/linux/kd.h | 13 ++++++++++++- 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 156efda7c80d..8c2a3d98b5ec 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4680,6 +4680,30 @@ int con_font_op(struct vc_data *vc, struct console_f= ont_op *op) return -ENOSYS; } =20 +int con_font_info(struct vc_data *vc, struct console_font_info *info) +{ + int rc =3D -EINVAL; + + info->min_height =3D 0; + info->max_height =3D max_font_height; + + info->min_width =3D 0; + info->max_width =3D max_font_width; + + info->flags =3D KD_FONT_INFO_FLAG_LOW_SIZE | KD_FONT_INFO_FLAG_HIGH_SIZE; + + console_lock(); + if (vc->vc_mode !=3D KD_TEXT) + rc =3D -EINVAL; + else if (vc->vc_sw->con_font_info) + rc =3D vc->vc_sw->con_font_info(vc, info); + else + rc =3D -ENOSYS; + console_unlock(); + + return rc; +} + /* * Interface exported to selection and vcs. */ diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c index 8c685b501404..a5f160e15a76 100644 --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -479,6 +479,18 @@ static int vt_k_ioctl(struct tty_struct *tty, unsigned= int cmd, break; } =20 + case KDFONTINFO: + struct console_font_info fnt_info; + + if (copy_from_user(&fnt_info, up, sizeof(fnt_info))) + return -EFAULT; + ret =3D con_font_info(vc, &fnt_info); + if (ret) + return ret; + if (copy_to_user(up, &fnt_info, sizeof(fnt_info))) + return -EFAULT; + break; + default: return -ENOIOCTLCMD; } diff --git a/include/linux/console.h b/include/linux/console.h index 779d388af8a0..5bea6f6c2042 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -20,6 +20,7 @@ #include =20 struct vc_data; +struct console_font_info; struct console_font_op; struct console_font; struct module; @@ -59,6 +60,7 @@ struct consw { unsigned int lines); int (*con_switch)(struct vc_data *vc); int (*con_blank)(struct vc_data *vc, int blank, int mode_switch); + int (*con_font_info)(struct vc_data *vc, struct console_font_info *info); int (*con_font_set)(struct vc_data *vc, struct console_font *font, unsigned int vpitch, unsigned int flags); int (*con_font_get)(struct vc_data *vc, struct console_font *font, diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h index c1f5aebef170..6bda4cc1fe6f 100644 --- a/include/linux/vt_kern.h +++ b/include/linux/vt_kern.h @@ -32,6 +32,7 @@ void do_blank_screen(int entering_gfx); void do_unblank_screen(int leaving_gfx); void poke_blanked_console(void); int con_font_op(struct vc_data *vc, struct console_font_op *op); +int con_font_info(struct vc_data *vc, struct console_font_info *info); int con_set_cmap(unsigned char __user *cmap); int con_get_cmap(unsigned char __user *cmap); void scrollback(struct vc_data *vc); diff --git a/include/uapi/linux/kd.h b/include/uapi/linux/kd.h index 6b384065c013..781e086e55bf 100644 --- a/include/uapi/linux/kd.h +++ b/include/uapi/linux/kd.h @@ -183,8 +183,19 @@ struct console_font { =20 #define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size = [compat] */ =20 +#define KDFONTINFO 0x4B73 /* font information */ + +#define KD_FONT_INFO_FLAG_LOW_SIZE (1U << 0) /* 256 */ +#define KD_FONT_INFO_FLAG_HIGH_SIZE (1U << 1) /* 512 */ + +struct console_font_info { + unsigned int min_width, min_height; /* minimal font size */ + unsigned int max_width, max_height; /* maximum font size */ + unsigned int flags; /* KD_FONT_INFO_FLAG_* */ +}; + /* note: 0x4B00-0x4B4E all have had a value at some time; don't reuse for the time being */ -/* note: 0x4B60-0x4B6D, 0x4B70-0x4B72 used above */ +/* note: 0x4B60-0x4B6D, 0x4B70-0x4B73 used above */ =20 #endif /* _UAPI_LINUX_KD_H */ --=20 2.44.0 From nobody Wed Feb 11 10:38:05 2026 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) (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 8A28012A176 for ; Mon, 26 Feb 2024 15:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.139.111.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960956; cv=none; b=rfLBBUaSHTXGMa0kKV/Gw7YAVmBDg/5ecNbyy3haXrfIkYeXTbw83qcELgjdskQuYefTMsp2vOstgXZ7lGtSMHCTdK5EjCJlo0iwEH426zrJiFJsHP0ovUB1K5AtXmbCG5RnISNf/0Xo/8b7rxl1Eq7nYWp0SFn+eHAUqr1m1C4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960956; c=relaxed/simple; bh=yxolVSJbX/m3dNfKsgTDQ8S6trHvUXOwfNqXfcacNxk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DEczITiYzUGwFtrwZcK636NCHuYkbXR2FGimRrwF69bHAyy4q35Ned2O23CLSRXwlts2vTSjJXVV7u33zVhRwwMhTYFktIoIpoQoqk615narCQZQlLSkQsqPv9Yq01XnGGVW9bzVsgwVqtRjfR35OOu5WEkt49HG05uZ9YjdeFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=fail smtp.mailfrom=kernel.org; arc=none smtp.client-ip=205.139.111.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-0P7e64eiMSCuA8or5N7p9w-1; Mon, 26 Feb 2024 10:21:24 -0500 X-MC-Unique: 0P7e64eiMSCuA8or5N7p9w-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C827C85A59A; Mon, 26 Feb 2024 15:21:23 +0000 (UTC) Received: from gentoo.redhat.com (unknown [10.45.224.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 170BE492BD7; Mon, 26 Feb 2024 15:21:22 +0000 (UTC) From: Alexey Gladkov To: LKML , Greg Kroah-Hartman , Jiri Slaby Cc: linux-api@vger.kernel.org Subject: [RFC PATCH v2 2/5] newport_con: Allow to get max font width and height Date: Mon, 26 Feb 2024 16:21:11 +0100 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alexey Gladkov --- drivers/video/console/newport_con.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/ne= wport_con.c index e8e4f82cd4a1..87f174a95fa8 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -33,6 +33,9 @@ =20 #define NEWPORT_LEN 0x10000 =20 +#define NEWPORT_MAX_FONT_WIDTH 8 +#define NEWPORT_MAX_FONT_HEIGHT 16 + #define FONT_DATA ((unsigned char *)font_vga_8x16.data) =20 static unsigned char *font_data[MAX_NR_CONSOLES]; @@ -328,8 +331,8 @@ static void newport_init(struct vc_data *vc, int init) { int cols, rows; =20 - cols =3D newport_xsize / 8; - rows =3D newport_ysize / 16; + cols =3D newport_xsize / NEWPORT_MAX_FONT_WIDTH; + rows =3D newport_ysize / NEWPORT_MAX_FONT_HEIGHT; vc->vc_can_do_color =3D 1; if (init) { vc->vc_cols =3D cols; @@ -507,8 +510,8 @@ static int newport_set_font(int unit, struct console_fo= nt *op, unsigned int vpit =20 /* ladis: when I grow up, there will be a day... and more sizes will * be supported ;-) */ - if ((w !=3D 8) || (h !=3D 16) || (vpitch !=3D 32) - || (op->charcount !=3D 256 && op->charcount !=3D 512)) + if ((w !=3D NEWPORT_MAX_FONT_WIDTH) || (h !=3D NEWPORT_MAX_FONT_HEIGHT) || + (vpitch !=3D 32) || (op->charcount !=3D 256 && op->charcount !=3D 512= )) return -EINVAL; =20 if (!(new_data =3D kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, @@ -569,6 +572,15 @@ static int newport_font_default(struct vc_data *vc, st= ruct console_font *op, cha return newport_set_def_font(vc->vc_num, op); } =20 +static int newport_font_info(struct vc_data *vc, struct console_font_info = *info) +{ + info->min_width =3D info->max_width =3D NEWPORT_MAX_FONT_WIDTH; + info->min_height =3D info->max_height =3D NEWPORT_MAX_FONT_HEIGHT; + info->flags =3D KD_FONT_INFO_FLAG_LOW_SIZE | KD_FONT_INFO_FLAG_HIGH_SIZE; + + return 0; +} + static int newport_font_set(struct vc_data *vc, struct console_font *font, unsigned int vpitch, unsigned int flags) { @@ -688,6 +700,7 @@ const struct consw newport_con =3D { .con_scroll =3D newport_scroll, .con_switch =3D newport_switch, .con_blank =3D newport_blank, + .con_font_info =3D newport_font_info, .con_font_set =3D newport_font_set, .con_font_default =3D newport_font_default, .con_save_screen =3D newport_save_screen --=20 2.44.0 From nobody Wed Feb 11 10:38:05 2026 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) (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 F063112C812 for ; Mon, 26 Feb 2024 15:22:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.139.111.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960967; cv=none; b=KD5PHcJN2qmHt79+s+2LV7T6q7NWyfZiLd8zIP0unQ8rQAQZbyzQznUrmuz2CRyUxLThkcbTSDHJ7P/+pmdDSCxRijzQZvieXX9jVPlAZmhPqc3oTw4RA7X5OrpvLbm7Oq+r13jTRjdf7N/y1jdQsUO3ivNXrSAhuBAX/uxx5So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960967; c=relaxed/simple; bh=kmBEBhIPZ3K6yo8dFqH+CwKILdo/XwZlWONCFjWvj5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SeYBM+7LvNqvu7nzGYBZj3G3T8o3RMvtQ8ZbjDHgduZ15JIT0LCuPcJLoIBU9TG5mLaQaDv0mnAujD99GoG7XJmowhLA1DZ2ALawqaWMgwAfB8OBiCBCvJuTGwMM0OUVlPsn+9TRddpHIKboQHWlL04wkoE8CYN1dERONuIUXVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=fail smtp.mailfrom=kernel.org; arc=none smtp.client-ip=205.139.111.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-LNEoIRY9OxCisOBL_DgNZg-1; Mon, 26 Feb 2024 10:21:25 -0500 X-MC-Unique: LNEoIRY9OxCisOBL_DgNZg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C09591097B05; Mon, 26 Feb 2024 15:21:24 +0000 (UTC) Received: from gentoo.redhat.com (unknown [10.45.224.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C3DB492BE2; Mon, 26 Feb 2024 15:21:23 +0000 (UTC) From: Alexey Gladkov To: LKML , Greg Kroah-Hartman , Jiri Slaby Cc: linux-api@vger.kernel.org Subject: [RFC PATCH v2 3/5] sticon: Allow to get max font width and height Date: Mon, 26 Feb 2024 16:21:12 +0100 Message-ID: <07c0cb7f0c175460561957190e48a6e01a74a676.1708960303.git.legion@kernel.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alexey Gladkov --- drivers/video/console/sticon.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 992a4fa431aa..d32ca458eb77 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -56,6 +56,11 @@ #define BLANK 0 static int vga_is_gfx; =20 +#define STICON_MIN_FONT_WIDTH 6 +#define STICON_MIN_FONT_HEIGHT 6 +#define STICON_MAX_FONT_WIDTH 32 +#define STICON_MAX_FONT_HEIGHT 32 + #define STI_DEF_FONT sticon_sti->font =20 /* borrowed from fbcon.c */ @@ -180,8 +185,10 @@ static int sticon_set_font(struct vc_data *vc, struct = console_font *op, struct sti_cooked_font *cooked_font; unsigned char *data =3D op->data, *p; =20 - if ((w < 6) || (h < 6) || (w > 32) || (h > 32) || (vpitch !=3D 32) - || (op->charcount !=3D 256 && op->charcount !=3D 512)) + if (!in_range(w, STICON_MIN_FONT_WIDTH, STICON_MAX_FONT_WIDTH) || + !in_range(h, STICON_MIN_FONT_HEIGHT, STICON_MAX_FONT_HEIGHT) || + (vpitch !=3D 32) || + (op->charcount !=3D 256 && op->charcount !=3D 512)) return -EINVAL; pitch =3D ALIGN(w, 8) / 8; bpc =3D pitch * h; @@ -273,6 +280,19 @@ static int sticon_font_set(struct vc_data *vc, struct = console_font *font, return sticon_set_font(vc, font, vpitch); } =20 +static int sticon_font_info(struct vc_data *vc, struct console_font_info *= info) +{ + info->min_width =3D STICON_MIN_FONT_WIDTH; + info->min_height =3D STICON_MIN_FONT_HEIGHT; + + info->max_width =3D STICON_MAX_FONT_WIDTH; + info->max_height =3D STICON_MAX_FONT_HEIGHT; + + info->flags =3D KD_FONT_INFO_FLAG_LOW_SIZE | KD_FONT_INFO_FLAG_HIGH_SIZE; + + return 0; +} + static void sticon_init(struct vc_data *c, int init) { struct sti_struct *sti =3D sticon_sti; @@ -371,6 +391,7 @@ static const struct consw sti_con =3D { .con_scroll =3D sticon_scroll, .con_switch =3D sticon_switch, .con_blank =3D sticon_blank, + .con_font_info =3D sticon_font_info, .con_font_set =3D sticon_font_set, .con_font_default =3D sticon_font_default, .con_build_attr =3D sticon_build_attr, --=20 2.44.0 From nobody Wed Feb 11 10:38:05 2026 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) (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 72CA912C528 for ; Mon, 26 Feb 2024 15:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.211.30.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960959; cv=none; b=edr8QLnMiLRkfW1y4VR3SpScVH1lbfTCOafmMoGT9M30od4aW8/y7kQPRnM6DLWUwrN46XYX1DprHR0YJC3WGC7mZFcg4Xzya9oJRiDQHhep5vaV1qvZqV8GWH6f9qtCBx7nMzBD+EjxtnDYSwYdLzUGDU/i/5MRHUIk9DB0h6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960959; c=relaxed/simple; bh=jJGWS4fls7FxdD0C7TzlrnH9rCl6Eia5MnOtRY3vNvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FdlwwKQwxyz6VtDgSjxNiUeTQuTFDK+YFba2RrBNTQMXnF/Xw7vQLvXZSQVH67rCaNaTlTdU+oGhp/C/9VCNe8AX1RHys53b1LSh3/m3UM1/k69+W34nIMhBZlJ/MlKL+HTOUdEJFg3CsBzLWrrA6wZahKAmYg785rz/rd+ka2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=fail smtp.mailfrom=kernel.org; arc=none smtp.client-ip=207.211.30.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-A_t5tt-EMT2pGOjzsrEoTQ-1; Mon, 26 Feb 2024 10:21:26 -0500 X-MC-Unique: A_t5tt-EMT2pGOjzsrEoTQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5CE71C106A1; Mon, 26 Feb 2024 15:21:25 +0000 (UTC) Received: from gentoo.redhat.com (unknown [10.45.224.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04798492BD7; Mon, 26 Feb 2024 15:21:24 +0000 (UTC) From: Alexey Gladkov To: LKML , Greg Kroah-Hartman , Jiri Slaby Cc: linux-api@vger.kernel.org Subject: [RFC PATCH v2 4/5] vgacon: Allow to get max font width and height Date: Mon, 26 Feb 2024 16:21:13 +0100 Message-ID: <6e8da86c7c8aa955158e8fec048a2c89cba4b592.1708960303.git.legion@kernel.org> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alexey Gladkov --- drivers/video/console/vgacon.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 8ef1579fa57f..b75d31ef3353 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -61,6 +61,10 @@ static struct vgastate vgastate; #define BLANK 0x0020 =20 #define VGA_FONTWIDTH 8 /* VGA does not support fontwidths !=3D 8 = */ + +#define VGACON_MAX_FONT_WIDTH VGA_FONTWIDTH +#define VGACON_MAX_FONT_HEIGHT 32 + /* * Interface used by the world */ @@ -1013,6 +1017,19 @@ static int vgacon_adjust_height(struct vc_data *vc, = unsigned fontheight) return 0; } =20 +static int vgacon_font_info(struct vc_data *vc, struct console_font_info *= info) +{ + info->min_width =3D VGACON_MAX_FONT_WIDTH; + info->min_height =3D 0; + + info->max_width =3D VGACON_MAX_FONT_WIDTH; + info->max_height =3D VGACON_MAX_FONT_HEIGHT; + + info->flags =3D KD_FONT_INFO_FLAG_LOW_SIZE | KD_FONT_INFO_FLAG_HIGH_SIZE; + + return 0; +} + static int vgacon_font_set(struct vc_data *c, struct console_font *font, unsigned int vpitch, unsigned int flags) { @@ -1022,7 +1039,8 @@ static int vgacon_font_set(struct vc_data *c, struct = console_font *font, if (vga_video_type < VIDEO_TYPE_EGAM) return -EINVAL; =20 - if (font->width !=3D VGA_FONTWIDTH || font->height > 32 || vpitch !=3D 32= || + if (font->width !=3D VGACON_MAX_FONT_WIDTH || + font->height > VGACON_MAX_FONT_HEIGHT || vpitch !=3D 32 || (charcount !=3D 256 && charcount !=3D 512)) return -EINVAL; =20 @@ -1177,6 +1195,7 @@ const struct consw vga_con =3D { .con_scroll =3D vgacon_scroll, .con_switch =3D vgacon_switch, .con_blank =3D vgacon_blank, + .con_font_info =3D vgacon_font_info, .con_font_set =3D vgacon_font_set, .con_font_get =3D vgacon_font_get, .con_resize =3D vgacon_resize, --=20 2.44.0 From nobody Wed Feb 11 10:38:05 2026 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) (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 1D33A128368 for ; Mon, 26 Feb 2024 15:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.139.111.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960897; cv=none; b=f45cIzuLETPsOCr+gkirWNPbFY/Tbmriyi36Q6915WP8cslvjxq9KXpZGT0Gv09juo1MTBSFsp4RU9mJKlOk8YMogJ4z8LiBHZwiu5Pl5Q4VfYcY51zOJYznCu0YfRBMeDUd6PCcLlhpD1k29ORfcRu16HHRlduUeACRxzpPduQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708960897; c=relaxed/simple; bh=y3ktYAlWGlGh0UnsX6kzOaJ18fiNnqB5N6XWTMa6ZYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q+oRc58eBSP1I0qpqC665Mtkc7o8YKUmRVY92oF5/SEz/YDFR3OC4ujmba6MzsuCv4nyAbcvt+8kNXJdL5Wzc5moYNnYeIm4dcA44f9jL4FKevW0dl2gj9lp5OQCqlsaAFbSaYWqzdF0x32Ku3yQLvINvWEaqy2qHYxEP00M704= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=fail smtp.mailfrom=kernel.org; arc=none smtp.client-ip=205.139.111.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-hUFdyclRNYa7u9Dzspq9HQ-1; Mon, 26 Feb 2024 10:21:27 -0500 X-MC-Unique: hUFdyclRNYa7u9Dzspq9HQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC846185A781; Mon, 26 Feb 2024 15:21:26 +0000 (UTC) Received: from gentoo.redhat.com (unknown [10.45.224.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED5D3492BE2; Mon, 26 Feb 2024 15:21:25 +0000 (UTC) From: Alexey Gladkov To: LKML , Greg Kroah-Hartman , Jiri Slaby Cc: linux-api@vger.kernel.org Subject: [RFC PATCH v2 5/5] fbcon: Allow to get max font width and height Date: Mon, 26 Feb 2024 16:21:14 +0100 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alexey Gladkov --- drivers/video/fbdev/core/fbcon.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fb= con.c index 1183e7a871f8..055d0d01243c 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -101,6 +101,9 @@ enum { FBCON_LOGO_DONTSHOW =3D -3 /* do not show the logo */ }; =20 +#define FBCON_MAX_FONT_WIDTH 32 +#define FBCON_MAX_FONT_HEIGHT 32 + static struct fbcon_display fb_display[MAX_NR_CONSOLES]; =20 static struct fb_info *fbcon_registered_fb[FB_MAX]; @@ -2458,6 +2461,21 @@ static int fbcon_do_set_font(struct vc_data *vc, int= w, int h, int charcount, return ret; } =20 + +static int fbcon_font_info(struct vc_data *vc, struct console_font_info *i= nfo) +{ + info->min_width =3D 0; + info->min_height =3D 0; + + info->max_width =3D FBCON_MAX_FONT_WIDTH; + info->max_height =3D FBCON_MAX_FONT_HEIGHT; + + info->flags =3D KD_FONT_INFO_FLAG_LOW_SIZE | KD_FONT_INFO_FLAG_HIGH_SIZE; + + return 0; +} + + /* * User asked to set font; we are guaranteed that charcount does not exce= ed 512 * but lets not assume that, since charcount of 512 is small for unicode = support. @@ -2485,7 +2503,8 @@ static int fbcon_set_font(struct vc_data *vc, struct = console_font *font, h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres)) return -EINVAL; =20 - if (font->width > 32 || font->height > 32) + if (font->width > FBCON_MAX_FONT_WIDTH || + font->height > FBCON_MAX_FONT_HEIGHT) return -EINVAL; =20 /* Make sure drawing engine can handle the font */ @@ -3160,6 +3179,7 @@ static const struct consw fb_con =3D { .con_scroll =3D fbcon_scroll, .con_switch =3D fbcon_switch, .con_blank =3D fbcon_blank, + .con_font_info =3D fbcon_font_info, .con_font_set =3D fbcon_set_font, .con_font_get =3D fbcon_get_font, .con_font_default =3D fbcon_set_def_font, --=20 2.44.0