Date: Sun, 12 Apr 2026 13:44:09 +0000 From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 4bb6ec63dace - stable/14 - stand: use a common function in gfx_fb for setting up teken colors Message-ID: <69dba1a9.42f4f.5b9a1a20@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=4bb6ec63dace8fb6d522fe246700ffc30bc79ab5 commit 4bb6ec63dace8fb6d522fe246700ffc30bc79ab5 Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2025-08-22 03:48:14 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2026-04-12 13:43:37 +0000 stand: use a common function in gfx_fb for setting up teken colors These are basically identical, with exception to the hook installed which is specific to the loader we're building by necessity. Pull these out into common/gfx_fb.c and just parameterize the hooks to make it easier to change the logic. Reviewed by: imp (cherry picked from commit c43de099d0138b369b705b3af2c3254d3f3afc6e) --- stand/common/gfx_fb.c | 31 +++++++++++++++++++++++++++++++ stand/common/gfx_fb.h | 1 + stand/efi/libefi/efi_console.c | 23 +---------------------- stand/i386/libi386/vidconsole.c | 21 +-------------------- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index 67f757983cd3..9aa0431a04d6 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -223,6 +223,37 @@ gfx_parse_mode_str(char *str, int *x, int *y, int *depth) return (true); } +void +gfx_fb_setcolors(teken_attr_t *attr, ev_sethook_t sethook, + ev_unsethook_t unsethook) +{ + const char *ptr; + char env[10]; + + /* + * On first run, we setup an environment hook to process any color + * changes. If the env is already set, we pick up fg and bg color + * values from the environment. + */ + ptr = getenv("teken.fg_color"); + if (ptr != NULL) { + attr->ta_fgcolor = strtol(ptr, NULL, 10); + ptr = getenv("teken.bg_color"); + attr->ta_bgcolor = strtol(ptr, NULL, 10); + + teken_set_defattr(&gfx_state.tg_teken, attr); + } else { + snprintf(env, sizeof(env), "%d", + attr->ta_fgcolor); + env_setenv("teken.fg_color", EV_VOLATILE, env, + sethook, unsethook); + snprintf(env, sizeof(env), "%d", + attr->ta_bgcolor); + env_setenv("teken.bg_color", EV_VOLATILE, env, + sethook, unsethook); + } +} + static uint32_t rgb_color_map(uint8_t index, uint32_t rmax, int roffset, uint32_t gmax, int goffset, uint32_t bmax, int boffset) diff --git a/stand/common/gfx_fb.h b/stand/common/gfx_fb.h index 17e419d8ffd3..d12bcd76b7fa 100644 --- a/stand/common/gfx_fb.h +++ b/stand/common/gfx_fb.h @@ -277,6 +277,7 @@ void gfx_fb_bezier(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, int gfx_fb_putimage(png_t *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); bool gfx_parse_mode_str(char *, int *, int *, int *); +void gfx_fb_setcolors(teken_attr_t *, ev_sethook_t, ev_unsethook_t); void term_image_display(teken_gfx_t *, const teken_rect_t *); void reset_font_flags(void); diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c index a112528d8c95..26b38603bb3b 100644 --- a/stand/efi/libefi/efi_console.c +++ b/stand/efi/libefi/efi_console.c @@ -1041,28 +1041,7 @@ cons_update_mode(bool use_gfx_mode) a = teken_get_defattr(&gfx_state.tg_teken); attr = *a; - /* - * On first run, we set up the efi_set_colors() - * callback. If the env is already set, we - * pick up fg and bg color values from the environment. - */ - ptr = getenv("teken.fg_color"); - if (ptr != NULL) { - attr.ta_fgcolor = strtol(ptr, NULL, 10); - ptr = getenv("teken.bg_color"); - attr.ta_bgcolor = strtol(ptr, NULL, 10); - - teken_set_defattr(&gfx_state.tg_teken, &attr); - } else { - snprintf(env, sizeof(env), "%d", - attr.ta_fgcolor); - env_setenv("teken.fg_color", EV_VOLATILE, env, - efi_set_colors, env_nounset); - snprintf(env, sizeof(env), "%d", - attr.ta_bgcolor); - env_setenv("teken.bg_color", EV_VOLATILE, env, - efi_set_colors, env_nounset); - } + gfx_fb_setcolors(&attr, efi_set_colors, env_nounset); } } diff --git a/stand/i386/libi386/vidconsole.c b/stand/i386/libi386/vidconsole.c index 414803e9af3d..3938bd7822ea 100644 --- a/stand/i386/libi386/vidconsole.c +++ b/stand/i386/libi386/vidconsole.c @@ -956,26 +956,7 @@ cons_update_mode(bool use_gfx_mode) a = teken_get_defattr(&gfx_state.tg_teken); attr = *a; - /* - * On first run, we set up the vidc_set_colors() - * callback. If the env is already set, we - * pick up fg and bg color values from the environment. - */ - ptr = getenv("teken.fg_color"); - if (ptr != NULL) { - attr.ta_fgcolor = strtol(ptr, NULL, 10); - ptr = getenv("teken.bg_color"); - attr.ta_bgcolor = strtol(ptr, NULL, 10); - - teken_set_defattr(&gfx_state.tg_teken, &attr); - } else { - snprintf(env, sizeof(env), "%d", attr.ta_fgcolor); - env_setenv("teken.fg_color", EV_VOLATILE, env, - vidc_set_colors, env_nounset); - snprintf(env, sizeof(env), "%d", attr.ta_bgcolor); - env_setenv("teken.bg_color", EV_VOLATILE, env, - vidc_set_colors, env_nounset); - } + gfx_fb_setcolors(&attr, vidc_set_colors, env_nounset); /* Improve visibility */ if (attr.ta_bgcolor == TC_WHITE)home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69dba1a9.42f4f.5b9a1a20>
