xref: /illumos-gate/usr/src/common/ficl/emu/gfx_fb.h (revision ce17336ed725d3b7fdff67bf0a0ee2b55018fec6)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2016 Toomas Some <tsoome@me.com>
14  * Copyright 2020 RackTop Systems, Inc.
15  */
16 
17 #ifndef _GFX_FB_H
18 #define	_GFX_FB_H
19 
20 /*
21  * Graphics support for loader emulation.
22  */
23 #include <sys/visual_io.h>
24 #include <pnglite.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 struct framebuffer {
31 	struct vis_identifier ident;
32 	int fd;			/* frame buffer device descriptor */
33 	uint8_t *fb_addr;	/* mapped framebuffer */
34 
35 	int fb_height;		/* in pixels */
36 	int fb_width;		/* in pixels */
37 	int fb_depth;		/* bits per pixel */
38 	int fb_bpp;		/* bytes per pixel */
39 	int fb_size;		/* total size in bytes */
40 	int fb_pitch;		/* bytes per scanline */
41 	uint16_t terminal_origin_x;
42 	uint16_t terminal_origin_y;
43 	uint16_t font_width;
44 	uint16_t font_height;
45 	uint8_t red_mask_size;
46 	uint8_t red_field_position;
47 	uint8_t green_mask_size;
48 	uint8_t green_field_position;
49 	uint8_t blue_mask_size;
50 	uint8_t blue_field_position;
51 };
52 
53 extern struct framebuffer fb;
54 
55 void gfx_framework_init(void);
56 void gfx_framework_fini(void);
57 void gfx_fb_setpixel(uint32_t, uint32_t);
58 void gfx_fb_drawrect(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
59 void gfx_term_drawrect(uint32_t, uint32_t, uint32_t, uint32_t);
60 void gfx_fb_line(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
61 void gfx_fb_bezier(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
62 	uint32_t);
63 
64 #define	FL_PUTIMAGE_BORDER	0x1
65 #define	FL_PUTIMAGE_NOSCROLL	0x2
66 #define	FL_PUTIMAGE_DEBUG	0x80
67 
68 int gfx_fb_putimage(png_t *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* _GFX_FB_H */
75