lib/fonts: add font 6x8 for OLED display
Subsystems (3)
PATCH v2 1/1 lib/fonts: add font 6x8 for OLED display
From: Sven Schneider <[email protected]>
This font is derived from lib/fonts/font_6x10.c and is useful for small OLED displays
---
Changes since v1:
- re-added lost Signed-off-by lines
- do not mode change include/linux/font.h to 0755
- Add SPDX tag
- Whitespace cleanup
include/linux/font.h | 4 +- lib/fonts/Kconfig | 7 + lib/fonts/Makefile | 1 + lib/fonts/font_6x8.c | 2576 ++++++++++++++++++++++++++++++++++++++++++ lib/fonts/fonts.c | 3 + 5 files changed, 2590 insertions(+), 1 deletion(-) create mode 100644 lib/fonts/font_6x8.c
include/linux/font.h +3 -1
@@ -33,6 +33,7 @@ struct font_desc {#define MINI4x6_IDX 9#define FONT6x10_IDX 10#define TER16x32_IDX 11 +#define FONT6x8_IDX 12extern const struct font_desc font_vga_8x8, font_vga_8x16,
@@ -45,7 +46,8 @@ extern const struct font_desc font_vga_8x8, font_acorn_8x8, font_mini_4x6, font_6x10, - font_ter_16x32; + font_ter_16x32, + font_6x8;/* Find a font with a specific name */
lib/fonts/Kconfig +7 -0
@@ -119,6 +119,12 @@ config FONT_TER16x32 This is the high resolution, large version for use with HiDPI screens. If the standard font is unreadable for you, say Y, otherwise say N. +config FONT_6x8 + bool "OLED 6x8 font" if FONTS + depends on FRAMEBUFFER_CONSOLE + help + This font is useful for small displays (OLED). + config FONT_AUTOSELECT def_bool y depends on !FONT_8x8
@@ -132,6 +138,7 @@ config FONT_AUTOSELECT depends on !FONT_SUN12x22 depends on !FONT_10x18 depends on !FONT_TER16x32 + depends on !FONT_6x8 select FONT_8x16 endif # FONT_SUPPORT
lib/fonts/Makefile +1 -0
@@ -15,6 +15,7 @@ font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o font-objs-$(CONFIG_FONT_MINI_4x6) += font_mini_4x6.o font-objs-$(CONFIG_FONT_6x10) += font_6x10.o font-objs-$(CONFIG_FONT_TER16x32) += font_ter16x32.o +font-objs-$(CONFIG_FONT_6x8) += font_6x8.o font-objs += $(font-objs-y)
lib/fonts/font_6x8.c new file +2576 -0
2,576 lines not on this page · raw message
lib/fonts/fonts.c +3 -0
@@ -57,6 +57,9 @@ static const struct font_desc *fonts[] = {#ifdef CONFIG_FONT_TER16x32 &font_ter_16x32,#endif +#ifdef CONFIG_FONT_6x8 + &font_6x8, +#endif };#define num_fonts ARRAY_SIZE(fonts)
Signature · 1 line
2.28.0
Quoted 7 lines · Sascha Hauer
From: Sven Schneider <[email protected]>
This font is derived from
lib/fonts/font_6x10.cand is useful for small OLED displaysSigned-off-by Sven Schneider <[email protected]>Signed-off-by Sascha Hauer <[email protected]>
Bartlomiej Zolnierkiewicz
AppliedQuoted 10 lines · Greg Kroah-Hartman
Quoted 7 lines · Sascha Hauer
From: Sven Schneider <[email protected]>
This font is derived from
lib/fonts/font_6x10.cand is useful for small OLED displaysSigned-off-by Sven Schneider <[email protected]>Signed-off-by Sascha Hauer <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>
Applied to drm-misc-next tree, thanks.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
PATCH 1/2 Fonts: Support FONT_EXTRA_WORDS macros for font_6x8
In reply to Sascha HauerRecently, in commit 6735b4632def ("Fonts: Support FONT_EXTRA_WORDS macros for built-in fonts"), we wrapped each of our built-in data buffers in a font_data structure, in order to use the following macros on them, see include/linux/font.h:
#define REFCOUNT(fd) (((int *)(fd))[-1]) #define FNTSIZE(fd) (((int *)(fd))[-2]) #define FNTCHARCNT(fd) (((int *)(fd))[-3]) #define FNTSUM(fd) (((int *)(fd))[-4]) #define FONT_EXTRA_WORDS 4
Do the same thing to our new 6x8 font. For built-in fonts, currently we only use FNTSIZE(). Since this is only a temporary solution for an out-of-bounds issue in the framebuffer layer (see commit 5af08640795b ("fbcon: Fix global-out-of-bounds read in fbcon_get_font()")), all the three other fields are intentionally set to zero in order to discourage using these negative-indexing macros.
--- lib/fonts/font_6x8.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/fonts/font_6x8.c +4 -4
@@ -3,8 +3,8 @@#define FONTDATAMAX 2048 -static const unsigned char fontdata_6x8[FONTDATAMAX ] = { - +static struct font_data fontdata_6x8 = { + {0 ,0 ,FONTDATAMAX ,0 }, {/* 0 0x00 '^@' */ 0x00 ,/* 000000 */ 0x00 ,/* 000000 */
@@ -2564,13 +2564,13 @@ static const unsigned char fontdata_6x8[FONTDATAMAX] = { 0x00, /* 000000 */ 0x00, /* 000000 */ 0x00, /* 000000 */ -}; +} };const struct font_desc font_6x8 = { .idx = FONT6x8_IDX, .name ="6x8" , .width =6 , .height =8 , - .data = fontdata_6x8, + .data = fontdata_6x8.data, .pref =0 , };
Signature · 1 line
2.25.1
PATCH 2/2 docs: fb: Add font_6x8 to available built-in fonts
Recently we added a new 6x8 font in commit e2028c8e6bf9 ("lib/fonts: add font 6x8 for OLED display"). Add its name to the "compiled-in fonts" list.
--- Documentation/fb/fbcon.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/fb/fbcon.rst +1 -1
@@ -81,7 +81,7 @@ C. Boot options 1. fbcon=font:<name> Select the initial font to use. The value 'name' can be any of the - compiled-in fonts: 10x18, 6x10, 7x14, Acorn8x8, MINI4x6, + compiled-in fonts: 10x18, 6x10, 6x8, 7x14, Acorn8x8, MINI4x6, PEARL8x8, ProFont6x11, SUN12x22, SUN8x16, TER16x32, VGA8x16, VGA8x8. Note, not all drivers can handle font with widths not divisible by 8,
Signature · 1 line
2.25.1
PATCH RESEND 2/2 docs: fb: Add font_6x8 to available built-in fonts
Recently we added a new 6x8 font in commit e2028c8e6bf9 ("lib/fonts: add font 6x8 for OLED display"). Add its name to the "compiled-in fonts" list.
---
Resending +Cc: dri-devel, sorry if I spammed.
Documentation/fb/fbcon.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/fb/fbcon.rst +1 -1
@@ -81,7 +81,7 @@ C. Boot options 1. fbcon=font:<name> Select the initial font to use. The value 'name' can be any of the - compiled-in fonts: 10x18, 6x10, 7x14, Acorn8x8, MINI4x6, + compiled-in fonts: 10x18, 6x10, 6x8, 7x14, Acorn8x8, MINI4x6, PEARL8x8, ProFont6x11, SUN12x22, SUN8x16, TER16x32, VGA8x16, VGA8x8. Note, not all drivers can handle font with widths not divisible by 8,
Signature · 1 line
2.25.1
Re: [PATCH 2/2 RESEND] docs: fb: Add font_6x8 to available built-in fonts
Quoted 7 lines · Peilin Ye
Recently we added a new 6x8 font in commit
e2028c8e6bf9("lib/fonts: add font 6x8 for OLED display"). Add its name to the "compiled-in fonts" list.Signed-off-by Peilin Ye <[email protected]>---
Resending +Cc: dri-devel, sorry if I spammed.
Both this and patch 1/2 with the actual bugfix merged to drm-misc-next-fixes, should still make it into the merge window before -rc1.
Thanks, Daniel
Quoted 20 lines
Documentation/fb/fbcon.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/fb/fbcon.rst +1
-1@@ -81,7 +81,7 @@ C. Boot options 1. fbcon=font:<name> Select the initial font to use. The value 'name' can be any of the - compiled-in fonts: 10x18, 6x10, 7x14, Acorn8x8, MINI4x6, + compiled-in fonts: 10x18, 6x10, 6x8, 7x14, Acorn8x8, MINI4x6, PEARL8x8, ProFont6x11, SUN12x22, SUN8x16, TER16x32, VGA8x16, VGA8x8. Note, not all drivers can handle font with widths not divisible by 8,Signature · 1 line
2.25.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH 1/2] Fonts: Support FONT_EXTRA_WORDS macros for font_6x8
In reply to Peilin YeAdding dri-devel too, not sure anyone is still listening on linux-fbdev.
Quoted 13 lines · Peilin Ye
Recently, in commit
6735b4632def("Fonts: SupportFONT_EXTRA_WORDSmacros for built-in fonts"), we wrapped each of our built-in data buffers in afont_datastructure, in order to use the following macros on them, seeinclude/linux/font.h:#define REFCOUNT(fd) (((int *)(fd))[-1]) #define FNTSIZE(fd) (((int *)(fd))[-2]) #define FNTCHARCNT(fd) (((int *)(fd))[-3]) #define FNTSUM(fd) (((int *)(fd))[-4])#define FONT_EXTRA_WORDS 4
Quoted 8 lines
Do the same thing to our new 6x8 font. For built-in fonts, currently we only use
FNTSIZE(). Since this is only a temporary solution for an out-of-bounds issue in the framebuffer layer (see commit5af08640795b("fbcon: Fix global-out-of-bounds read infbcon_get_font()")), all the three other fields are intentionally set to zero in order to discourage using these negative-indexing macros.Signed-off-by Peilin Ye <[email protected]>
Patch looks good to me, but it says 1/2 and I can't find 2/2 anywhere, not even on lore. Did that get lost?
-Daniel
Quoted 38 lines
--- lib/fonts/font_6x8.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)lib/fonts/font_6x8.c +4
-5@@ -3,8 +3,8 @@#define FONTDATAMAX 2048 -static const unsigned char fontdata_6x8[FONTDATAMAX ] = { - +static struct font_data fontdata_6x8 = { + {0 ,0 ,FONTDATAMAX ,0 }, {/* 0 0x00 '^@' */ 0x00 ,/* 000000 */ 0x00 ,/* 000000 */ @@ -2564,13 +2564,13 @@ static const unsigned char fontdata_6x8[FONTDATAMAX] = { 0x00, /* 000000 */ 0x00, /* 000000 */ 0x00, /* 000000 */ -}; +} };const struct font_desc font_6x8 = { .idx = FONT6x8_IDX, .name ="6x8" , .width =6 , .height =8 , - .data = fontdata_6x8, + .data = fontdata_6x8.data, .pref =0 , }; --2.25.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH 1/2] Fonts: Support FONT_EXTRA_WORDS macros for font_6x8
Quoted 1 line · Daniel Vetter
Adding dri-devel too, not sure anyone is still listening on linux-fbdev.
I see, thanks!
Quoted 21 lines · Peilin Ye
Quoted 20 lines
Recently, in commit
6735b4632def("Fonts: SupportFONT_EXTRA_WORDSmacros for built-in fonts"), we wrapped each of our built-in data buffers in afont_datastructure, in order to use the following macros on them, seeinclude/linux/font.h:#define REFCOUNT(fd) (((int *)(fd))[-1]) #define FNTSIZE(fd) (((int *)(fd))[-2]) #define FNTCHARCNT(fd) (((int *)(fd))[-3]) #define FNTSUM(fd) (((int *)(fd))[-4])#define FONT_EXTRA_WORDS 4Do the same thing to our new 6x8 font. For built-in fonts, currently we only use
FNTSIZE(). Since this is only a temporary solution for an out-of-bounds issue in the framebuffer layer (see commit5af08640795b("fbcon: Fix global-out-of-bounds read infbcon_get_font()")), all the three other fields are intentionally set to zero in order to discourage using these negative-indexing macros.
Quoted 4 lines
Quoted 1 line
Signed-off-by Peilin Ye <[email protected]>Patch looks good to me, but it says 1/2 and I can't find 2/2 anywhere, not even on lore. Did that get lost?
2/2 is just updating the fb documentation:
[PATCH 2/2] docs: fb: Add font_6x8 to available built-in fonts
https://lore.kernel.org/lkml/717bb41dda8e2ed615f3faadfbc3e215de726d38.1603037079.git.yepeilin.cs@gmail.com/
I did git format-patch -2 --threadÞep, did I do something wrong when sending it?
Thank you,
Peilin Ye
Re: [PATCH 1/2] Fonts: Support FONT_EXTRA_WORDS macros for font_6x8
Quoted 32 lines · Peilin Ye
Quoted 1 line · Daniel Vetter
Adding dri-devel too, not sure anyone is still listening on linux-fbdev.
I see, thanks!
Quoted 21 lines · Peilin Ye
Quoted 20 lines
Recently, in commit
6735b4632def("Fonts: SupportFONT_EXTRA_WORDSmacros for built-in fonts"), we wrapped each of our built-in data buffers in afont_datastructure, in order to use the following macros on them, seeinclude/linux/font.h:#define REFCOUNT(fd) (((int *)(fd))[-1]) #define FNTSIZE(fd) (((int *)(fd))[-2]) #define FNTCHARCNT(fd) (((int *)(fd))[-3]) #define FNTSUM(fd) (((int *)(fd))[-4])#define FONT_EXTRA_WORDS 4Do the same thing to our new 6x8 font. For built-in fonts, currently we only use
FNTSIZE(). Since this is only a temporary solution for an out-of-bounds issue in the framebuffer layer (see commit5af08640795b("fbcon: Fix global-out-of-bounds read infbcon_get_font()")), all the three other fields are intentionally set to zero in order to discourage using these negative-indexing macros.Quoted 4 lines
Quoted 1 line
Signed-off-by Peilin Ye <[email protected]>Patch looks good to me, but it says 1/2 and I can't find 2/2 anywhere, not even on lore. Did that get lost?
Quoted 7 lines
2/2 is just updating the fb documentation:
[PATCH 2/2] docs: fb: Add
font_6x8to available built-in fonts
https://lore.kernel.org/lkml/717bb41dda8e2ed615f3faadfbc3e215de726d38.1603037079.git.yepeilin.cs@gmail.com/I did
git format-patch -2 --threadÞep, did I do something wrong when sending it?
No idea, it just didn't arrive anywhere I could find. And I did get your previous patch series. Maybe just try again with dri-devel included and hope it works then?
-Daniel
Quoted 1 line
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Re: [PATCH 1/2] Fonts: Support FONT_EXTRA_WORDS macros for font_6x8
Quoted 6 lines · Daniel Vetter
Quoted 5 lines · Peilin Ye
2/2 is just updating the fb documentation:
[PATCH 2/2] docs: fb: Add
font_6x8to available built-in fonts
https://lore.kernel.org/lkml/717bb41dda8e2ed615f3faadfbc3e215de726d38.1603037079.git.yepeilin.cs@gmail.com/
Quoted 6 lines
Quoted 2 lines
I did
git format-patch -2 --threadÞep, did I do something wrong when sending it?No idea, it just didn't arrive anywhere I could find. And I did get your previous patch series. Maybe just try again with dri-devel included and hope it works then?
I'm confused, I see it on LKML in the link above. Sure I'll resend soon.
Peilin Ye
Re: [PATCH 1/2] Fonts: Support FONT_EXTRA_WORDS macros for font_6x8
Quoted 8 lines · Peilin Ye
Quoted 6 lines · Daniel Vetter
Quoted 5 lines · Peilin Ye
2/2 is just updating the fb documentation:
[PATCH 2/2] docs: fb: Add
font_6x8to available built-in fonts
https://lore.kernel.org/lkml/717bb41dda8e2ed615f3faadfbc3e215de726d38.1603037079.git.yepeilin.cs@gmail.com/
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I did
git format-patch -2 --threadÞep, did I do something wrong when sending it?No idea, it just didn't arrive anywhere I could find. And I did get your previous patch series. Maybe just try again with dri-devel included and hope it works then?
I'm confused, I see it on LKML in the link above. Sure I'll resend soon.
My brain didn't work, sorry about the confusion.
I'll pick up the patches tomorrow, probably not a good idea I do anything more today :-)
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH 1/2] Fonts: Support FONT_EXTRA_WORDS macros for font_6x8
Quoted 7 lines · Daniel Vetter
Quoted 1 line · Peilin Ye
I'm confused, I see it on LKML in the link above. Sure I'll resend soon.
My brain didn't work, sorry about the confusion.
I'll pick up the patches tomorrow, probably not a good idea I do anything more today :-)
Ah, no worries, thanks!
Peilin Ye