Skip to content

Commit 24d6938

Browse files
sthibaulgregkh
authored andcommitted
VT: Add KD_FONT_OP_SET/GET_TALL operations
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ffc1e08 commit 24d6938

File tree

2 files changed

+18
-6
lines changed
  • drivers/tty/vt
  • include/uapi/linux

2 files changed

+18
-6
lines changed

drivers/tty/vt/vt.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4540,6 +4540,7 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
45404540
struct console_font font;
45414541
int rc = -EINVAL;
45424542
int c;
4543+
unsigned int vpitch = op->op == KD_FONT_OP_GET_TALL ? op->height : 32;
45434544

45444545
if (op->data) {
45454546
font.data = kmalloc(max_font_size, GFP_KERNEL);
@@ -4552,15 +4553,15 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
45524553
if (vc->vc_mode != KD_TEXT)
45534554
rc = -EINVAL;
45544555
else if (vc->vc_sw->con_font_get)
4555-
rc = vc->vc_sw->con_font_get(vc, &font, 32);
4556+
rc = vc->vc_sw->con_font_get(vc, &font, vpitch);
45564557
else
45574558
rc = -ENOSYS;
45584559
console_unlock();
45594560

45604561
if (rc)
45614562
goto out;
45624563

4563-
c = (font.width+7)/8 * 32 * font.charcount;
4564+
c = (font.width+7)/8 * vpitch * font.charcount;
45644565

45654566
if (op->data && font.charcount > op->charcount)
45664567
rc = -ENOSPC;
@@ -4586,6 +4587,7 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
45864587
struct console_font font;
45874588
int rc = -EINVAL;
45884589
int size;
4590+
unsigned int vpitch = op->op == KD_FONT_OP_SET_TALL ? op->height : 32;
45894591

45904592
if (vc->vc_mode != KD_TEXT)
45914593
return -EINVAL;
@@ -4595,7 +4597,9 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
45954597
return -EINVAL;
45964598
if (op->width <= 0 || op->width > 32 || !op->height || op->height > 32)
45974599
return -EINVAL;
4598-
size = (op->width+7)/8 * 32 * op->charcount;
4600+
if (vpitch < op->height)
4601+
return -EINVAL;
4602+
size = (op->width+7)/8 * vpitch * op->charcount;
45994603
if (size > max_font_size)
46004604
return -ENOSPC;
46014605

@@ -4613,7 +4617,7 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
46134617
else if (vc->vc_sw->con_font_set) {
46144618
if (vc_is_sel(vc))
46154619
clear_selection();
4616-
rc = vc->vc_sw->con_font_set(vc, &font, 32, op->flags);
4620+
rc = vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags);
46174621
} else
46184622
rc = -ENOSYS;
46194623
console_unlock();
@@ -4659,8 +4663,10 @@ int con_font_op(struct vc_data *vc, struct console_font_op *op)
46594663
{
46604664
switch (op->op) {
46614665
case KD_FONT_OP_SET:
4666+
case KD_FONT_OP_SET_TALL:
46624667
return con_font_set(vc, op);
46634668
case KD_FONT_OP_GET:
4669+
case KD_FONT_OP_GET_TALL:
46644670
return con_font_get(vc, op);
46654671
case KD_FONT_OP_SET_DEFAULT:
46664672
return con_font_default(vc, op);

include/uapi/linux/kd.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,25 @@ struct console_font_op {
161161
unsigned int flags; /* KD_FONT_FLAG_* */
162162
unsigned int width, height; /* font size */
163163
unsigned int charcount;
164-
unsigned char __user *data; /* font data with height fixed to 32 */
164+
unsigned char __user *data; /* font data with vpitch fixed to 32 for
165+
* KD_FONT_OP_SET/GET
166+
*/
165167
};
166168

167169
struct console_font {
168170
unsigned int width, height; /* font size */
169171
unsigned int charcount;
170-
unsigned char *data; /* font data with height fixed to 32 */
172+
unsigned char *data; /* font data with vpitch fixed to 32 for
173+
* KD_FONT_OP_SET/GET
174+
*/
171175
};
172176

173177
#define KD_FONT_OP_SET 0 /* Set font */
174178
#define KD_FONT_OP_GET 1 /* Get font */
175179
#define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */
176180
#define KD_FONT_OP_COPY 3 /* Obsolete, do not use */
181+
#define KD_FONT_OP_SET_TALL 4 /* Set font with vpitch = height */
182+
#define KD_FONT_OP_GET_TALL 5 /* Get font with vpitch = height */
177183

178184
#define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size [compat] */
179185

0 commit comments

Comments
 (0)