Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/vt/colors/vt_termcolors.c
Show All 28 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/libkern.h> | #include <sys/libkern.h> | ||||
#include <sys/fbio.h> | |||||
#include <dev/vt/colors/vt_termcolors.h> | #include <dev/vt/colors/vt_termcolors.h> | ||||
static struct { | static struct { | ||||
unsigned char r; /* Red percentage value. */ | unsigned char r; /* Red percentage value. */ | ||||
unsigned char g; /* Green percentage value. */ | unsigned char g; /* Green percentage value. */ | ||||
unsigned char b; /* Blue percentage value. */ | unsigned char b; /* Blue percentage value. */ | ||||
} color_def[NCOLORS] = { | } color_def[NCOLORS] = { | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | if (TUNABLE_STR_FETCH(tunable, rgb, sizeof(rgb))) { | ||||
color_def[i].r = r*100/255; | color_def[i].r = r*100/255; | ||||
color_def[i].g = g*100/255; | color_def[i].g = g*100/255; | ||||
color_def[i].b = b*100/255; | color_def[i].b = b*100/255; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
int | static int | ||||
vt_generate_cons_palette(uint32_t *palette, int format, uint32_t rmax, | vt_generate_cons_palette(uint32_t *palette, int format, uint32_t rmax, | ||||
int roffset, uint32_t gmax, int goffset, uint32_t bmax, int boffset) | int roffset, uint32_t gmax, int goffset, uint32_t bmax, int boffset) | ||||
{ | { | ||||
int i; | int i; | ||||
switch (format) { | switch (format) { | ||||
case COLOR_FORMAT_VGA: | case COLOR_FORMAT_VGA: | ||||
for (i = 0; i < NCOLORS; i++) | for (i = 0; i < NCOLORS; i++) | ||||
palette[i] = cons_to_vga_colors[i]; | palette[i] = cons_to_vga_colors[i]; | ||||
break; | break; | ||||
case COLOR_FORMAT_RGB: | case COLOR_FORMAT_RGB: | ||||
vt_palette_init(); | vt_palette_init(); | ||||
#define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset) | #define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset) | ||||
for (i = 0; i < NCOLORS; i++) | for (i = 0; i < NCOLORS; i++) | ||||
palette[i] = CF(r, i) | CF(g, i) | CF(b, i); | palette[i] = CF(r, i) | CF(g, i) | CF(b, i); | ||||
#undef CF | #undef CF | ||||
break; | break; | ||||
default: | default: | ||||
return (ENODEV); | return (ENODEV); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | |||||
int | |||||
vt_config_cons_colors(struct fb_info *info, int format, uint32_t rmax, | |||||
int roffset, uint32_t gmax, int goffset, uint32_t bmax, int boffset) | |||||
{ | |||||
if (format == COLOR_FORMAT_RGB) { | |||||
info->fb_rgboffs.red = roffset; | |||||
info->fb_rgboffs.green = goffset; | |||||
info->fb_rgboffs.blue = boffset; | |||||
} else | |||||
memset(&info->fb_rgboffs, 0, sizeof(info->fb_rgboffs)); | |||||
return (vt_generate_cons_palette(info->fb_cmap, format, rmax, | |||||
roffset, gmax, goffset, bmax, boffset)); | |||||
} | } |