Repository navigation
Commit a1ac250
fbcon: Avoid using FNTCHARCNT() and hard-coded built-in font charcount
For user-provided fonts, the framebuffer layer is using a magic
negative-indexing macro, FNTCHARCNT(), to keep track of their number of
characters:
#define FNTCHARCNT(fd) (((int *)(fd))[-3])
For built-in fonts, it is using hard-coded values (256). This results in
something like the following:
map.length = (ops->p->userfont) ?
FNTCHARCNT(ops->p->fontdata) : 256;
This is unsatisfactory. In fact, there is already a `charcount` field in
our virtual console descriptor (see `struct console_font` inside `struct
vc_data`), let us use it:
map.length = vc->vc_font.charcount;
Recently we added a `charcount` field to `struct font_desc`. Use it to set
`vc->vc_font.charcount` properly. The idea is:
- We only use FNTCHARCNT() on `vc->vc_font.data` and `p->fontdata`.
Assume FNTCHARCNT() is working as intended;
- Whenever `vc->vc_font.data` is set, also set `vc->vc_font.charcount`
properly;
- We can now replace `FNTCHARCNT(vc->vc_font.data)` with
`vc->vc_font.charcount`;
- Since `p->fontdata` always point to the same font data buffer with
`vc->vc_font.data`, we can also replace `FNTCHARCNT(p->fontdata)` with
`vc->vc_font.charcount`.
In conclusion, set `vc->vc_font.charcount` properly in fbcon_startup(),
fbcon_init(), fbcon_set_disp() and fbcon_do_set_font(), then replace
FNTCHARCNT() with `vc->vc_font.charcount`. No more if-else between
negative-indexing macros and hard-coded values.
Do not include <linux/font.h> in fbcon_rotate.c and tileblit.c, since they
no longer need it.
Depends on patch "Fonts: Add charcount field to font_desc".
Suggested-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/e460a5780e54e3022661d5f09555144583b4cc59.1605169912.git.yepeilin.cs@gmail.com1 parent 4497364 commit a1ac250
3 files changed
Lines changed: 23 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1004 | 1004 | | |
1005 | 1005 | | |
1006 | 1006 | | |
1007 | | - | |
| 1007 | + | |
1008 | 1008 | | |
1009 | 1009 | | |
1010 | 1010 | | |
| |||
1032 | 1032 | | |
1033 | 1033 | | |
1034 | 1034 | | |
1035 | | - | |
| 1035 | + | |
1036 | 1036 | | |
1037 | 1037 | | |
1038 | 1038 | | |
| |||
1068 | 1068 | | |
1069 | 1069 | | |
1070 | 1070 | | |
| 1071 | + | |
1071 | 1072 | | |
1072 | 1073 | | |
1073 | 1074 | | |
| |||
1083 | 1084 | | |
1084 | 1085 | | |
1085 | 1086 | | |
1086 | | - | |
1087 | | - | |
| 1087 | + | |
1088 | 1088 | | |
1089 | 1089 | | |
1090 | 1090 | | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | 1091 | | |
1095 | 1092 | | |
1096 | | - | |
| 1093 | + | |
1097 | 1094 | | |
1098 | 1095 | | |
1099 | 1096 | | |
| |||
1358 | 1355 | | |
1359 | 1356 | | |
1360 | 1357 | | |
1361 | | - | |
| 1358 | + | |
1362 | 1359 | | |
1363 | 1360 | | |
1364 | 1361 | | |
| |||
1378 | 1375 | | |
1379 | 1376 | | |
1380 | 1377 | | |
| 1378 | + | |
1381 | 1379 | | |
1382 | 1380 | | |
1383 | 1381 | | |
1384 | 1382 | | |
1385 | | - | |
1386 | | - | |
1387 | 1383 | | |
1388 | 1384 | | |
1389 | 1385 | | |
| |||
1393 | 1389 | | |
1394 | 1390 | | |
1395 | 1391 | | |
1396 | | - | |
| 1392 | + | |
1397 | 1393 | | |
1398 | 1394 | | |
1399 | 1395 | | |
| |||
2027 | 2023 | | |
2028 | 2024 | | |
2029 | 2025 | | |
2030 | | - | |
| 2026 | + | |
2031 | 2027 | | |
2032 | 2028 | | |
2033 | 2029 | | |
| |||
2075 | 2071 | | |
2076 | 2072 | | |
2077 | 2073 | | |
2078 | | - | |
| 2074 | + | |
2079 | 2075 | | |
2080 | 2076 | | |
2081 | 2077 | | |
| |||
2152 | 2148 | | |
2153 | 2149 | | |
2154 | 2150 | | |
2155 | | - | |
2156 | | - | |
2157 | | - | |
2158 | | - | |
| 2151 | + | |
2159 | 2152 | | |
2160 | 2153 | | |
2161 | 2154 | | |
| |||
2405 | 2398 | | |
2406 | 2399 | | |
2407 | 2400 | | |
2408 | | - | |
| 2401 | + | |
2409 | 2402 | | |
2410 | 2403 | | |
2411 | 2404 | | |
2412 | 2405 | | |
2413 | 2406 | | |
2414 | 2407 | | |
2415 | | - | |
2416 | 2408 | | |
2417 | 2409 | | |
2418 | 2410 | | |
2419 | 2411 | | |
2420 | 2412 | | |
2421 | | - | |
2422 | | - | |
2423 | | - | |
2424 | | - | |
2425 | 2413 | | |
2426 | 2414 | | |
2427 | 2415 | | |
2428 | 2416 | | |
2429 | 2417 | | |
2430 | | - | |
| 2418 | + | |
| 2419 | + | |
2431 | 2420 | | |
2432 | | - | |
| 2421 | + | |
2433 | 2422 | | |
2434 | 2423 | | |
2435 | 2424 | | |
| |||
2496 | 2485 | | |
2497 | 2486 | | |
2498 | 2487 | | |
| 2488 | + | |
| 2489 | + | |
2499 | 2490 | | |
2500 | 2491 | | |
2501 | | - | |
2502 | 2492 | | |
2503 | 2493 | | |
2504 | 2494 | | |
| |||
2524 | 2514 | | |
2525 | 2515 | | |
2526 | 2516 | | |
2527 | | - | |
| 2517 | + | |
2528 | 2518 | | |
2529 | 2519 | | |
2530 | 2520 | | |
| |||
2540 | 2530 | | |
2541 | 2531 | | |
2542 | 2532 | | |
2543 | | - | |
| 2533 | + | |
2544 | 2534 | | |
2545 | 2535 | | |
2546 | 2536 | | |
| |||
3009 | 2999 | | |
3010 | 3000 | | |
3011 | 3001 | | |
3012 | | - | |
3013 | 3002 | | |
3014 | 3003 | | |
3015 | 3004 | | |
| |||
3018 | 3007 | | |
3019 | 3008 | | |
3020 | 3009 | | |
3021 | | - | |
3022 | 3010 | | |
3023 | 3011 | | |
3024 | | - | |
3025 | | - | |
| 3012 | + | |
3026 | 3013 | | |
3027 | 3014 | | |
3028 | 3015 | | |
| |||
3032 | 3019 | | |
3033 | 3020 | | |
3034 | 3021 | | |
3035 | | - | |
3036 | 3022 | | |
3037 | 3023 | | |
3038 | | - | |
3039 | | - | |
| 3024 | + | |
3040 | 3025 | | |
3041 | 3026 | | |
3042 | 3027 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
| 35 | + | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
145 | 144 | | |
146 | 145 | | |
147 | 146 | | |
148 | | - | |
149 | | - | |
| 147 | + | |
150 | 148 | | |
151 | 149 | | |
152 | 150 | | |
| |||
0 commit comments