Skip to content

Commit

Permalink
13360 loader: use BGRA RBG data in gfx functions
Browse files Browse the repository at this point in the history
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
tsoome committed Jan 26, 2021
1 parent a98e9e2 commit 2d84dc9
Show file tree
Hide file tree
Showing 10 changed files with 812 additions and 650 deletions.
1,210 changes: 710 additions & 500 deletions usr/src/boot/sys/boot/common/gfx_fb.c

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion usr/src/boot/sys/boot/common/gfx_fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,24 @@ typedef TAILQ_HEAD(edid_resolution, resolution) edid_res_list_t;

extern multiboot_tag_framebuffer_t gfx_fb;

typedef enum {
GfxFbBltVideoFill,
GfxFbBltVideoToBltBuffer,
GfxFbBltBufferToVideo,
GfxFbBltVideoToVideo,
GfxFbBltOperationMax,
} GFXFB_BLT_OPERATION;

int gfxfb_blt(void *, GFXFB_BLT_OPERATION, uint32_t, uint32_t,
uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);

void bios_text_font(bool);
bool gfx_get_edid_resolution(struct vesa_edid_info *, edid_res_list_t *);
void gfx_framework_init(struct visual_ops *);
void gfx_framework_init(void);
uint32_t gfx_fb_color_map(uint8_t);
int gfx_fb_cons_clear(struct vis_consclear *);
void gfx_fb_cons_copy(struct vis_conscopy *);
void gfx_fb_cons_display(struct vis_consdisplay *);
void gfx_fb_display_cursor(struct vis_conscursor *);
void gfx_fb_setpixel(uint32_t, uint32_t);
void gfx_fb_drawrect(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
Expand Down
126 changes: 9 additions & 117 deletions usr/src/boot/sys/boot/common/tem.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@ static void tem_pix_cls_range(struct tem_vt_state *, screen_pos_t, int,
static void tem_pix_cls(struct tem_vt_state *, int,
screen_pos_t, screen_pos_t);

static void bit_to_pix4(struct tem_vt_state *tem, tem_char_t c,
text_color_t fg_color, text_color_t bg_color);
static void bit_to_pix8(struct tem_vt_state *tem, tem_char_t c,
text_color_t fg_color, text_color_t bg_color);
static void bit_to_pix16(struct tem_vt_state *tem, tem_char_t c,
text_color_t fg_color, text_color_t bg_color);
static void bit_to_pix24(struct tem_vt_state *tem, tem_char_t c,
text_color_t fg_color, text_color_t bg_color);
static void bit_to_pix32(struct tem_vt_state *tem, tem_char_t c,
text_color_t fg_color, text_color_t bg_color);

Expand Down Expand Up @@ -2291,35 +2283,12 @@ static void
tem_pix_bit2pix(struct tem_vt_state *tem, term_char_t c)
{
text_color_t fg, bg;
void (*fp)(struct tem_vt_state *, tem_char_t,
unsigned char, unsigned char);

fg = DEFAULT_ANSI_FOREGROUND;
bg = DEFAULT_ANSI_BACKGROUND;

tem_get_color(&fg, &bg, c);
switch (tems.ts_pdepth) {
case 4:
fp = bit_to_pix4;
break;
case 8:
fp = bit_to_pix8;
break;
case 15:
case 16:
fp = bit_to_pix16;
break;
case 24:
fp = bit_to_pix24;
break;
case 32:
fp = bit_to_pix32;
break;
default:
return;
}

fp(tem, c.tc_char, fg, bg);
bit_to_pix32(tem, c.tc_char, fg, bg);
}


Expand Down Expand Up @@ -2657,36 +2626,14 @@ tem_pix_cursor(struct tem_vt_state *tem, short action)
bg = DEFAULT_ANSI_BACKGROUND;
tem_get_color(&fg, &bg, c);

switch (tems.ts_pdepth) {
case 4:
ca.fg_color.mono = fg;
ca.bg_color.mono = bg;
break;
case 8:
ca.fg_color.mono = tems.ts_color_map(fg);
ca.bg_color.mono = tems.ts_color_map(bg);
break;
case 15:
case 16:
color = tems.ts_color_map(fg);
ca.fg_color.sixteen[0] = (color >> 8) & 0xFF;
ca.fg_color.sixteen[1] = color & 0xFF;
color = tems.ts_color_map(bg);
ca.bg_color.sixteen[0] = (color >> 8) & 0xFF;
ca.bg_color.sixteen[1] = color & 0xFF;
break;
case 24:
case 32:
color = tems.ts_color_map(fg);
ca.fg_color.twentyfour[0] = (color >> 16) & 0xFF;
ca.fg_color.twentyfour[1] = (color >> 8) & 0xFF;
ca.fg_color.twentyfour[2] = color & 0xFF;
color = tems.ts_color_map(bg);
ca.bg_color.twentyfour[0] = (color >> 16) & 0xFF;
ca.bg_color.twentyfour[1] = (color >> 8) & 0xFF;
ca.bg_color.twentyfour[2] = color & 0xFF;
break;
}
color = tems.ts_color_map(fg);
ca.fg_color.twentyfour[0] = (color >> 16) & 0xFF;
ca.fg_color.twentyfour[1] = (color >> 8) & 0xFF;
ca.fg_color.twentyfour[2] = color & 0xFF;
color = tems.ts_color_map(bg);
ca.bg_color.twentyfour[0] = (color >> 16) & 0xFF;
ca.bg_color.twentyfour[1] = (color >> 8) & 0xFF;
ca.bg_color.twentyfour[2] = color & 0xFF;

ca.action = action;

Expand All @@ -2707,61 +2654,6 @@ tem_pix_cursor(struct tem_vt_state *tem, short action)
}
}

static void
bit_to_pix4(struct tem_vt_state *tem,
tem_char_t c,
text_color_t fg_color,
text_color_t bg_color)
{
uint8_t *dest = (uint8_t *)tem->tvs_pix_data;
font_bit_to_pix4(&tems.ts_font, dest, c, fg_color, bg_color);
}

static void
bit_to_pix8(struct tem_vt_state *tem,
tem_char_t c,
text_color_t fg_color,
text_color_t bg_color)
{
uint8_t *dest = (uint8_t *)tem->tvs_pix_data;

fg_color = (text_color_t)tems.ts_color_map(fg_color);
bg_color = (text_color_t)tems.ts_color_map(bg_color);
font_bit_to_pix8(&tems.ts_font, dest, c, fg_color, bg_color);
}

static void
bit_to_pix16(struct tem_vt_state *tem,
tem_char_t c,
text_color_t fg_color4,
text_color_t bg_color4)
{
uint16_t fg_color16, bg_color16;
uint16_t *dest;

fg_color16 = (uint16_t)tems.ts_color_map(fg_color4);
bg_color16 = (uint16_t)tems.ts_color_map(bg_color4);

dest = (uint16_t *)tem->tvs_pix_data;
font_bit_to_pix16(&tems.ts_font, dest, c, fg_color16, bg_color16);
}

static void
bit_to_pix24(struct tem_vt_state *tem,
tem_char_t c,
text_color_t fg_color4,
text_color_t bg_color4)
{
uint32_t fg_color32, bg_color32;
uint8_t *dest;

fg_color32 = tems.ts_color_map(fg_color4);
bg_color32 = tems.ts_color_map(bg_color4);

dest = (uint8_t *)tem->tvs_pix_data;
font_bit_to_pix24(&tems.ts_font, dest, c, fg_color32, bg_color32);
}

static void
bit_to_pix32(struct tem_vt_state *tem,
tem_char_t c,
Expand Down
8 changes: 4 additions & 4 deletions usr/src/boot/sys/boot/efi/libefi/efi_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ struct visual_ops fb_ops = {
.ident = &fb_ident,
.kdsetmode = NULL,
.devinit = efi_fb_devinit,
.cons_copy = NULL,
.cons_display = NULL,
.cons_copy = gfx_fb_cons_copy,
.cons_display = gfx_fb_cons_display,
.cons_cursor = efi_cons_cursor,
.cons_clear = NULL,
.cons_clear = gfx_fb_cons_clear,
.cons_put_cmap = NULL
};

Expand Down Expand Up @@ -539,7 +539,7 @@ efi_cons_init(struct console *cp, int arg __unused)
if (status == EFI_SUCCESS)
ecd->ecd_coninex = coninex;

gfx_framework_init(&fb_ops);
gfx_framework_init();

if (tem_info_init(cp) == 0 && tem == NULL) {
tem = tem_init();
Expand Down
2 changes: 1 addition & 1 deletion usr/src/boot/sys/boot/i386/libi386/vbe.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ vbe_set_palette(const struct paletteentry *entry, size_t slot)
pe.Blue = entry->Blue;
pe.Green = entry->Green;
pe.Red = entry->Red;
pe.Alignment = entry->Alignment;
pe.Reserved = entry->Reserved;

if (vbe->Capabilities & VBE_CAP_SNOW)
mode = 0x80;
Expand Down
2 changes: 1 addition & 1 deletion usr/src/boot/sys/boot/i386/libi386/vbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct paletteentry {
uint8_t Blue;
uint8_t Green;
uint8_t Red;
uint8_t Alignment;
uint8_t Reserved;
} __packed;

struct flatpanelinfo
Expand Down
38 changes: 19 additions & 19 deletions usr/src/boot/sys/boot/i386/libi386/vidconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ struct visual_ops fb_ops = {
.ident = &fb_ident,
.kdsetmode = NULL,
.devinit = vidc_vbe_devinit,
.cons_copy = NULL,
.cons_display = NULL,
.cons_copy = gfx_fb_cons_copy,
.cons_display = gfx_fb_cons_display,
.cons_cursor = vidc_cons_cursor,
.cons_clear = NULL,
.cons_clear = gfx_fb_cons_clear,
.cons_put_cmap = vidc_vbe_cons_put_cmap
};

Expand Down Expand Up @@ -570,24 +570,24 @@ vidc_vbe_cons_put_cmap(struct vis_cmap *cm)
rgb.blue.pos = gfx_fb.u.fb2.framebuffer_blue_field_position;
rgb.blue.size = gfx_fb.u.fb2.framebuffer_blue_mask_size;

/*
* The first 16 colors need to be in VGA color order.
*/
for (i = cm->index; i < 256 && rc == 0; i++) {
if (i < 16) {
if (i < 15)
c = rgb_color_map(&rgb, i + 1);
else
c = rgb_color_map(&rgb, 0);
} else {
c = rgb_color_map(&rgb, i);
}
for (i = cm->index; i < NCMAP && rc == 0; i++) {
int idx;

/* Pick RGB from cmap4_to_24 */
c = rgb_color_map(&rgb, i);
/* The first 16 colors need to be in VGA color order. */
if (i < NCOLORS)
idx = solaris_color_to_pc_color[i];
else
idx = i;

pe8[i].Red = (c >> rgb.red.pos) & ((1 << rgb.red.size) - 1);
pe8[i].Green =
(c >> rgb.green.pos) & ((1 << rgb.green.size) - 1);
pe8[i].Blue = (c >> rgb.blue.pos) & ((1 << rgb.blue.size) - 1);
pe8[i].Alignment = 0;
rc = vbe_set_palette(&pe8[i], i);
pe8[i].Blue =
(c >> rgb.blue.pos) & ((1 << rgb.blue.size) - 1);
pe8[i].Reserved = 0;
rc = vbe_set_palette(&pe8[i], idx);
}
return (rc);
}
Expand Down Expand Up @@ -869,7 +869,7 @@ vidc_init(struct console *cp, int arg)
}
}

gfx_framework_init(&fb_ops);
gfx_framework_init();
/* set up callback before calling tem_info_init(). */
tem_register_modechg_cb(vidc_install_font, (tem_modechg_cb_arg_t)cp);
rc = tem_info_init(cp);
Expand Down
4 changes: 2 additions & 2 deletions usr/src/boot/sys/sys/tem_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct tem_vt_state {
term_char_t *tvs_outbuf; /* place to keep incomplete lines */
int tvs_outindex; /* index into a_outbuf */
void *tvs_pix_data; /* pointer to tmp bitmap area */
int tvs_pix_data_size;
unsigned tvs_pix_data_size;
text_color_t tvs_fg_color;
text_color_t tvs_bg_color;
int tvs_first_line; /* kernel console output begins */
Expand Down Expand Up @@ -226,7 +226,7 @@ typedef struct tem_state {
struct tem_size ts_p_dimension; /* screen dimensions in pixels */
struct tem_pix_pos ts_p_offset; /* pix offset to center the display */

int ts_pix_data_size; /* size of bitmap data areas */
unsigned ts_pix_data_size; /* size of bitmap data areas */
int ts_pdepth; /* pixel depth */
struct font ts_font; /* font table */
bool update_font; /* flag the font change */
Expand Down
21 changes: 20 additions & 1 deletion usr/src/common/font/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const uint8_t solaris_color_to_pc_color[16] = {
pc_magenta, /* 6 - magenta */
pc_brown, /* 7 - brown */
pc_white, /* 8 - white */
pc_grey, /* 9 - gery */
pc_grey, /* 9 - grey */
pc_brt_blue, /* 10 - brt_blue */
pc_brt_green, /* 11 - brt_green */
pc_brt_cyan, /* 12 - brt_cyan */
Expand All @@ -71,6 +71,25 @@ const uint8_t solaris_color_to_pc_color[16] = {
pc_yellow /* 15 - yellow */
};

const uint8_t pc_color_to_solaris_color[16] = {
sun_black, /* 0 - black */
sun_blue, /* 1 - blue */
sun_green, /* 2 - green */
sun_cyan, /* 3 - cyan */
sun_red, /* 4 - red */
sun_magenta, /* 5 - magenta */
sun_brown, /* 6 - brown */
sun_white, /* 7 - white */
sun_grey, /* 8 - grey */
sun_brt_blue, /* 9 - brt_blue */
sun_brt_green, /* 10 - brt_green */
sun_brt_cyan, /* 11 - brt_cyan */
sun_brt_red, /* 12 - brt_red */
sun_brt_magenta, /* 13 - brt_magenta */
sun_yellow, /* 14 - yellow */
sun_brt_white /* 15 - brt_white */
};

/* 4-bit to 24-bit color translation. */
const text_cmap_t cmap4_to_24 = {
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Expand Down
Loading

0 comments on commit 2d84dc9

Please sign in to comment.