====== Improve vt(4) splash screen support ====== | Repository | https://github.com/0mp/freebsd/tree/splash-vt | | Bugzilla | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210432 | ===== Overview ===== At the moment (2018-09-11) vt(4) has very limited support for splash screens. The goal of this project is to extend it a little bit. It should be possible to: * load a specified BMP file to be displayed as splash screen * control display colors via kernel tunables A stretched goal is to support bitmaps with the color depth of more than 1. ===== Roadmap ===== | Add sysctl tunables for splash colors in vt(4). | {o} | ===== References ===== * [[https://www.freebsd.org/cgi/man.cgi?query=splash&manpath=FreeBSD+11.2-RELEASE+and+Ports|splash(4)]] * [[/Newcons]] * [[https://en.wikipedia.org/wiki/BMP_file_format|BMP file format (Wikipedia)]] ==== Mailing list threads ==== * [[https://lists.freebsd.org/pipermail/freebsd-hackers/2018-September/053329.html|Let's improve splash screen support in vt(4) (freebsd-hackers@, 2018-09-11)]] ===== Research ===== Commit adding some splash screen support to vt(4): 2ecca071d5eccf38f9a5fd7a03052b261b7bd7d2 sc(4) supports 8-bit colors. Interesting functions: * ''%%vd_bitblt_bmp%%'' * ''%%vt_fb_bitblt_bitmap%%'' (vt_fb.c) * ''%%vt_fb_setpixel%%'': it seems to be the function which is capable of setting pixel colors in a console controlled by vt(4). ==== The vtterm_splash function ==== There's a function called ''%%vtterm_splash%%'' in ''%%vt_core.c%%'', which displays a boot splash when the kernel is compiled with ''%%DEV_SPLASH%%'' option, textmode is not activated and a muted booting was requested by the user (for example via specifying ''%%-m%%'' to boot(8%%))%%. Also the following part of the ''%%vtterm_splash%%'' function: switch (vt_logo_depth) { case 1: /* XXX: Unhardcode colors! */ vd->vd_driver->vd_bitblt_bmp(vd, vd->vd_curwindow, vt_logo_image, NULL, vt_logo_width, vt_logo_height, left, top, TC_WHITE, TC_BLACK); Source: vt_core.c suggests that: - Monochrome colors are the only one supported at the moment. - It should not be complicated to add support for 4-bit and 8-bit colors. * Actually, there is an sc(4) file, which has a very similar switch construct handling various color depth configurations. * What's the name of the sc(4) function with that switch case? * There's no such function in sc(4). There is ''%%bmp_SetPix%%'' in ''%%sys/dev/fb/splash_bmp.c%%'' but it does not help much as it directly sets video bits. Its signature looks like this: ''%%static void bmp_SetPix(BMP_INFO *info, int x, int y, u_char val)%%''. Other questions regarding the ''%%vtterm_splash%%'' function: - {o} What is the ''%%VDF_SPLASH%%'' flag inside ''%%vd->vd_flags%%'' for? - {o} How to load a BMP file into a structure accepted by functions displaying pixels? Could it be that the splash(4) driver provides all the required functions to do so? Ideal scenario: - The splash(4) driver reads the bitmap file that was specified in loader.conf(5) and converts it to a structure accepted by internal vt(4) functions. - vt(4) gets the structure from splash(4). - vt(4) displays the bitmap. - {o} How does the ''%%vd->vd_driver->vd_bitblt_bmp%%'' function work? * ''%%struct vt_driver%%'' seems to be an interface for different hardware have to implement in order to use the vt(4) driver. ''%%vd_bitblt_bmp%%'' happens to be one of the drawing functions. It has various implementations like ''%%ofwfb_bitblt_bitmap%%'', ''%%vga_bitblt_bitmap%%'' or ''%%vt_fb_bitblt_bitmap%%''. At the moment the vt(4) driver stores logos in ''%%unsigned char%%'' structures (see ''%%sys/dev/vt/logo/logo_beastie.c%%''), which roughly correspond to the ''%%u_char *data%%'' member of the ''%%BMP_INFO%%'' structure (see ''%%sys/dev/fb/splash_bmp.c%%''). typedef struct { int width,height; /* image dimensions */ int swidth,sheight; /* screen dimensions for the current mode */ u_char depth; /* image depth (1, 4, 8, 24 bits) */ u_char sdepth; /* screen depth (1, 4, 8 bpp) */ int ncols; /* number of colours */ u_char palette[256][3]; /* raw palette data */ u_char format; /* one of the BI_* constants above */ u_char *data; /* pointer to the raw data */ u_char *index; /* running pointer to the data while drawing */ u_char *vidmem; /* video memory allocated for drawing */ video_adapter_t *adp; int bank; } BMP_INFO; Source: sys/dev/fb/splash_bmp.c const unsigned char vt_beastie_vga16[] = { 0x16, 0x00, 0x62, 0x16, 0x88, 0x03, 0x80, 0x16, 0x00, 0x23, 0x88, 0x80, 0x00, 0x00, 0x08, 0x88, 0x16, 0x00, 0x21, 0x08, 0x16, 0x00, 0x06, 0x88, 0x16, 0x00, 0x20, 0x80, 0x16, 0x00, 0x06, 0x08, 0x80, 0x16, 0x00, 0x1e, Source: sys/dev/vt/logo/logo_beastie.c ==== Glossary ==== * **DIB**: device independent bitmap ---- {{tag>Project}}