vt(4): Put for() loop outside switch() in vt_generate_cons_palette()

This makes it more logical:
 1. It checks the requested color format
 2. It fills the palette accordingly

Also vt_palette_init() is only called when needed (i.e. when the format
is `COLOR_FORMAT_RGB`).
This commit is contained in:
Jean-Sébastien Pédron 2018-05-10 16:41:47 +00:00
parent 66fe09d8d9
commit e525438697
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333463

View File

@ -171,21 +171,21 @@ vt_generate_cons_palette(uint32_t *palette, int format, uint32_t rmax,
{
int i;
vt_palette_init();
#define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset)
for (i = 0; i < NCOLORS; i++) {
switch (format) {
case COLOR_FORMAT_VGA:
switch (format) {
case COLOR_FORMAT_VGA:
for (i = 0; i < NCOLORS; i++)
palette[i] = cons_to_vga_colors[i];
break;
case COLOR_FORMAT_RGB:
break;
case COLOR_FORMAT_RGB:
vt_palette_init();
#define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset)
for (i = 0; i < NCOLORS; i++)
palette[i] = CF(r, i) | CF(g, i) | CF(b, i);
break;
default:
return (ENODEV);
}
}
#undef CF
break;
default:
return (ENODEV);
}
return (0);
}