Skip to content

Commit afac4c6

Browse files
committed
Merge tag 'fbdev-for-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
Pull fbdev updates from Helge Deller: "A major refactorization by Thomas Zimmermann from SUSE regarding handling of console font data, addition of helpers for console font rotation and split into individual components for glyphs, fonts and the overall fbcon state. And there is the round of usual code cleanups and fixes: Cleanups: - atyfb: Remove unused fb_list (Geert Uytterhoeven) - goldfishfb, wmt_ge_rops: use devm_platform_ioremap_resource() (Amin GATTOUT) - matroxfb: Mark variable with __maybe_unused (Andy Shevchenko) - omapfb: Add missing error check for clk_get() (Chen Ni) - tdfxfb: Make the VGA register initialisation a bit more obvious (Daniel Palmer) - macfb: Replace deprecated strcpy with strscpy (Thorsten Blum) Fixes: - tdfxfb, udlfb: avoid divide-by-zero on FBIOPUT_VSCREENINFO (Greg Kroah-Hartman) - omap2: fix inconsistent lock returns in omapfb_mmap (Hongling Zeng) - viafb: check ioremap return value in viafb_lcd_get_mobile_state (Wang Jun)" * tag 'fbdev-for-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev: (40 commits) fbdev: udlfb: avoid divide-by-zero on FBIOPUT_VSCREENINFO fbdev: tdfxfb: avoid divide-by-zero on FBIOPUT_VSCREENINFO fbdev: omap2: fix inconsistent lock returns in omapfb_mmap MAINTAINERS: Add dedicated entry for fbcon fbcon: Put font-rotation state into separate struct fbcon: Fill cursor mask in helper function lib/fonts: Implement font rotation lib/fonts: Refactor glyph-rotation helpers lib/fonts: Refactor glyph-pattern helpers lib/fonts: Implement glyph rotation lib/fonts: Clean up Makefile lib/fonts: Provide helpers for calculating glyph pitch and size vt: Implement helpers for struct vc_font in source file fbcon: Avoid OOB font access if console rotation fails fbdev: atyfb: Remove unused fb_list fbdev: matroxfb: Mark variable with __maybe_unused to avoid W=1 build break fbdev: update help text for CONFIG_FB_NVIDIA fbdev: omapfb: Add missing error check for clk_get() fbdev: viafb: check ioremap return value in viafb_lcd_get_mobile_state lib/fonts: Remove internal symbols and macros from public header file ...
2 parents 00c6649 + a31e451 commit afac4c6

45 files changed

Lines changed: 1328 additions & 790 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

MAINTAINERS

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10073,6 +10073,29 @@ S: Maintained
1007310073
W: https://floatingpoint.billm.au/
1007410074
F: arch/x86/math-emu/
1007510075

10076+
FRAMEBUFFER CONSOLE
10077+
M: Helge Deller <[email protected]>
10078+
M: Thomas Zimmermann <[email protected]>
10079+
10080+
10081+
S: Maintained
10082+
T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
10083+
F: Documentation/fb/fbcon.rst
10084+
F: drivers/video/fbdev/core/bitblit.c
10085+
F: drivers/video/fbdev/core/fb_logo.c
10086+
F: drivers/video/fbdev/core/fbcon.c
10087+
F: drivers/video/fbdev/core/fbcon.h
10088+
F: drivers/video/fbdev/core/fbcon_ccw.c
10089+
F: drivers/video/fbdev/core/fbcon_cw.c
10090+
F: drivers/video/fbdev/core/fbcon_rotate.c
10091+
F: drivers/video/fbdev/core/fbcon_rotate.h
10092+
F: drivers/video/fbdev/core/fbcon_ud.c
10093+
F: drivers/video/fbdev/core/softcursor.c
10094+
F: drivers/video/fbdev/core/tileblit.c
10095+
F: include/linux/fbcon.h
10096+
F: include/linux/font.h
10097+
F: lib/fonts/
10098+
1007610099
FRAMEBUFFER CORE
1007710100
M: Simona Vetter <[email protected]>
1007810101
S: Odd Fixes

drivers/tty/vt/vt.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,40 @@ enum {
230230
blank_vesa_wait,
231231
};
232232

233+
/*
234+
* struct vc_font
235+
*/
236+
237+
/**
238+
* vc_font_pitch - Calculates the number of bytes between two adjacent scanlines
239+
* @font: The VC font
240+
*
241+
* Returns:
242+
* The number of bytes between two adjacent scanlines in the font data
243+
*/
244+
unsigned int vc_font_pitch(const struct vc_font *font)
245+
{
246+
return font_glyph_pitch(font->width);
247+
}
248+
EXPORT_SYMBOL_GPL(vc_font_pitch);
249+
250+
/**
251+
* vc_font_size - Calculates the size of the font data in bytes
252+
* @font: The VC font
253+
*
254+
* vc_font_size() calculates the number of bytes of font data in the
255+
* font specified by @font. The function calculates the size from the
256+
* font parameters.
257+
*
258+
* Returns:
259+
* The size of the font data in bytes.
260+
*/
261+
unsigned int vc_font_size(const struct vc_font *font)
262+
{
263+
return font_glyph_size(font->width, font->height) * font->charcount;
264+
}
265+
EXPORT_SYMBOL_GPL(vc_font_size);
266+
233267
/*
234268
* /sys/class/tty/tty0/
235269
*

drivers/video/console/newport_con.c

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333

3434
#define NEWPORT_LEN 0x10000
3535

36-
#define FONT_DATA ((unsigned char *)font_vga_8x16.data)
36+
#define FONT_DATA font_vga_8x16.data
3737

38-
static unsigned char *font_data[MAX_NR_CONSOLES];
38+
static font_data_t *font_data[MAX_NR_CONSOLES];
3939

4040
static struct newport_regs *npregs;
4141
static unsigned long newport_addr;
@@ -370,9 +370,9 @@ static void newport_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
370370
static void newport_putc(struct vc_data *vc, u16 charattr, unsigned int ypos,
371371
unsigned int xpos)
372372
{
373-
unsigned char *p;
373+
const unsigned char *p;
374374

375-
p = &font_data[vc->vc_num][(charattr & 0xff) << 4];
375+
p = &font_data_buf(font_data[vc->vc_num])[(charattr & 0xff) << 4];
376376
charattr = (charattr >> 8) & 0xff;
377377
xpos <<= 3;
378378
ypos <<= 4;
@@ -400,7 +400,7 @@ static void newport_putcs(struct vc_data *vc, const u16 *s,
400400
unsigned int count, unsigned int ypos,
401401
unsigned int xpos)
402402
{
403-
unsigned char *p;
403+
const unsigned char *p;
404404
unsigned int i;
405405
u16 charattr;
406406

@@ -424,7 +424,7 @@ static void newport_putcs(struct vc_data *vc, const u16 *s,
424424
NPORT_DMODE0_L32);
425425

426426
for (i = 0; i < count; i++, xpos += 8) {
427-
p = &font_data[vc->vc_num][(scr_readw(s++) & 0xff) << 4];
427+
p = &font_data_buf(font_data[vc->vc_num])[(scr_readw(s++) & 0xff) << 4];
428428

429429
newport_wait(npregs);
430430

@@ -501,65 +501,42 @@ static int newport_set_font(int unit, const struct console_font *op,
501501
{
502502
int w = op->width;
503503
int h = op->height;
504-
int size = h * op->charcount;
505504
int i;
506-
unsigned char *new_data, *data = op->data, *p;
505+
font_data_t *new_data;
507506

508507
/* ladis: when I grow up, there will be a day... and more sizes will
509508
* be supported ;-) */
510-
if ((w != 8) || (h != 16) || (vpitch != 32)
511-
|| (op->charcount != 256 && op->charcount != 512))
509+
if (w != 8 || h != 16 || (op->charcount != 256 && op->charcount != 512))
512510
return -EINVAL;
513511

514-
if (!(new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size,
515-
GFP_USER))) return -ENOMEM;
516-
517-
new_data += FONT_EXTRA_WORDS * sizeof(int);
518-
FNTSIZE(new_data) = size;
519-
FNTCHARCNT(new_data) = op->charcount;
520-
REFCOUNT(new_data) = 0; /* usage counter */
521-
FNTSUM(new_data) = 0;
522-
523-
p = new_data;
524-
for (i = 0; i < op->charcount; i++) {
525-
memcpy(p, data, h);
526-
data += 32;
527-
p += h;
528-
}
512+
new_data = font_data_import(op, vpitch, NULL);
513+
if (IS_ERR(new_data))
514+
return PTR_ERR(new_data);
529515

530516
/* check if font is already used by other console */
531517
for (i = 0; i < MAX_NR_CONSOLES; i++) {
532-
if (font_data[i] != FONT_DATA
533-
&& FNTSIZE(font_data[i]) == size
534-
&& !memcmp(font_data[i], new_data, size)) {
535-
kfree(new_data - FONT_EXTRA_WORDS * sizeof(int));
518+
if (font_data_is_equal(font_data[i], new_data)) {
519+
font_data_put(new_data);
536520
/* current font is the same as the new one */
537521
if (i == unit)
538522
return 0;
539523
new_data = font_data[i];
524+
font_data_get(new_data);
540525
break;
541526
}
542527
}
543-
/* old font is user font */
544-
if (font_data[unit] != FONT_DATA) {
545-
if (--REFCOUNT(font_data[unit]) == 0)
546-
kfree(font_data[unit] -
547-
FONT_EXTRA_WORDS * sizeof(int));
548-
}
549-
REFCOUNT(new_data)++;
528+
529+
font_data_put(font_data[unit]);
550530
font_data[unit] = new_data;
551531

552532
return 0;
553533
}
554534

555535
static int newport_set_def_font(int unit, struct console_font *op)
556536
{
557-
if (font_data[unit] != FONT_DATA) {
558-
if (--REFCOUNT(font_data[unit]) == 0)
559-
kfree(font_data[unit] -
560-
FONT_EXTRA_WORDS * sizeof(int));
561-
font_data[unit] = FONT_DATA;
562-
}
537+
font_data_put(font_data[unit]);
538+
font_data[unit] = FONT_DATA;
539+
font_data_get(font_data[unit]);
563540

564541
return 0;
565542
}

drivers/video/fbdev/Kconfig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,12 @@ config FB_NVIDIA
668668
select BITREVERSE
669669
select VGASTATE
670670
help
671-
This driver supports graphics boards with the nVidia chips, TNT
672-
and newer. For very old chipsets, such as the RIVA128, then use
673-
the rivafb.
674-
Say Y if you have such a graphics board.
671+
This driver supports graphics boards with the nVidia chips, from TNT
672+
through early GeForce generations (NV4–NV2x: Twintor, Twintor2, Celsius,
673+
Kelvin).
674+
Later architectures (Rankine and newer) are not reliably supported.
675+
For very old chipsets, such as the RIVA128, use rivafb.
676+
If unsure, say N.
675677

676678
To compile this driver as a module, choose M here: the
677679
module will be called nvidiafb.

drivers/video/fbdev/aty/atyfb_base.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,8 +2324,6 @@ static void aty_calc_mem_refresh(struct atyfb_par *par, int xclk)
23242324
* Initialisation
23252325
*/
23262326

2327-
static struct fb_info *fb_list = NULL;
2328-
23292327
#if defined(__i386__) && defined(CONFIG_FB_ATY_GENERIC_LCD)
23302328
static int atyfb_get_timings_from_lcd(struct atyfb_par *par,
23312329
struct fb_var_screeninfo *var)
@@ -2758,8 +2756,6 @@ static int aty_init(struct fb_info *info)
27582756
#endif
27592757
}
27602758

2761-
fb_list = info;
2762-
27632759
PRINTKI("fb%d: %s frame buffer device on %s\n",
27642760
info->node, info->fix.id, par->bus_type == ISA ? "ISA" : "PCI");
27652761
return 0;

drivers/video/fbdev/core/bitblit.c

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
/*
2323
* Accelerated handlers.
2424
*/
25-
static void update_attr(u8 *dst, u8 *src, int attribute,
26-
struct vc_data *vc)
25+
static void update_attr(u8 *dst, const u8 *src, int attribute, struct vc_data *vc)
2726
{
2827
int i, offset = (vc->vc_font.height < 10) ? 1 : 2;
2928
int width = DIV_ROUND_UP(vc->vc_font.width, 8);
@@ -81,7 +80,7 @@ static inline void bit_putcs_aligned(struct vc_data *vc, struct fb_info *info,
8180
u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
8281
unsigned int charcnt = vc->vc_font.charcount;
8382
u32 idx = vc->vc_font.width >> 3;
84-
u8 *src;
83+
const u8 *src;
8584

8685
while (cnt--) {
8786
u16 ch = scr_readw(s++) & charmask;
@@ -120,7 +119,7 @@ static inline void bit_putcs_unaligned(struct vc_data *vc,
120119
u32 shift_low = 0, mod = vc->vc_font.width % 8;
121120
u32 shift_high = 8;
122121
u32 idx = vc->vc_font.width >> 3;
123-
u8 *src;
122+
const u8 *src;
124123

125124
while (cnt--) {
126125
u16 ch = scr_readw(s++) & charmask;
@@ -267,7 +266,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
267266
int y = real_y(par->p, vc->state.y);
268267
int attribute, use_sw = vc->vc_cursor_type & CUR_SW;
269268
int err = 1;
270-
char *src;
269+
const u8 *src;
271270

272271
cursor.set = 0;
273272

@@ -278,7 +277,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
278277
attribute = get_attribute(info, c);
279278
src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height));
280279

281-
if (par->cursor_state.image.data != src ||
280+
if (par->cursor_state.image.data != (const char *)src ||
282281
par->cursor_reset) {
283282
par->cursor_state.image.data = src;
284283
cursor.set |= FB_CUR_SETIMAGE;
@@ -330,46 +329,17 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
330329
vc->vc_cursor_type != par->p->cursor_shape ||
331330
par->cursor_state.mask == NULL ||
332331
par->cursor_reset) {
333-
char *mask = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
334-
int cur_height, size, i = 0;
335-
u8 msk = 0xff;
332+
unsigned char *mask = kmalloc_array(vc->vc_font.height, w, GFP_ATOMIC);
336333

337334
if (!mask)
338335
return;
336+
fbcon_fill_cursor_mask(par, vc, mask);
339337

340338
kfree(par->cursor_state.mask);
341-
par->cursor_state.mask = mask;
339+
par->cursor_state.mask = (const char *)mask;
342340

343341
par->p->cursor_shape = vc->vc_cursor_type;
344342
cursor.set |= FB_CUR_SETSHAPE;
345-
346-
switch (CUR_SIZE(par->p->cursor_shape)) {
347-
case CUR_NONE:
348-
cur_height = 0;
349-
break;
350-
case CUR_UNDERLINE:
351-
cur_height = (vc->vc_font.height < 10) ? 1 : 2;
352-
break;
353-
case CUR_LOWER_THIRD:
354-
cur_height = vc->vc_font.height/3;
355-
break;
356-
case CUR_LOWER_HALF:
357-
cur_height = vc->vc_font.height >> 1;
358-
break;
359-
case CUR_TWO_THIRDS:
360-
cur_height = (vc->vc_font.height << 1)/3;
361-
break;
362-
case CUR_BLOCK:
363-
default:
364-
cur_height = vc->vc_font.height;
365-
break;
366-
}
367-
size = (vc->vc_font.height - cur_height) * w;
368-
while (size--)
369-
mask[i++] = ~msk;
370-
size = cur_height * w;
371-
while (size--)
372-
mask[i++] = msk;
373343
}
374344

375345
par->cursor_state.enable = enable && !use_sw;

0 commit comments

Comments
 (0)