xref: /illumos-gate/usr/src/uts/common/sys/rgb.h (revision 6f1fa39e3cf1b335f342bbca41590e9d76ab29b7)
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 2018 Toomas Soome <tsoome@me.com>
14  */
15 
16 #ifndef _SYS_RGB_H
17 #define	_SYS_RGB_H
18 
19 #include <sys/types.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /*
26  * Number of "base" colors is 16, 8 dark and 8 bright/light.
27  * Color map size for indexed colors is 256, to support VGA 256-color modes.
28  */
29 #define	NCOLORS		16
30 #define	NCMAP		256
31 
32 /*
33  * Color data from bootloader.
34  */
35 typedef struct rgb_color {
36 	uint8_t pos;
37 	uint8_t size;
38 } rgb_color_t;
39 
40 typedef struct rgb {
41 	rgb_color_t red;
42 	rgb_color_t green;
43 	rgb_color_t blue;
44 } rgb_t;
45 
46 typedef struct {
47 	uint8_t red[NCOLORS];
48 	uint8_t green[NCOLORS];
49 	uint8_t blue[NCOLORS];
50 } text_cmap_t;
51 
52 extern const text_cmap_t cmap4_to_24;
53 /*
54  * ANSI color to sun color translation.
55  */
56 
57 /* The pc color here is actually referring to standard 16 color VGA map. */
58 typedef enum pc_colors {
59 	pc_black	= 0,
60 	pc_blue		= 1,
61 	pc_green	= 2,
62 	pc_cyan		= 3,
63 	pc_red		= 4,
64 	pc_magenta	= 5,
65 	pc_brown	= 6,
66 	pc_white	= 7,
67 	pc_grey		= 8,
68 	pc_brt_blue	= 9,
69 	pc_brt_green	= 10,
70 	pc_brt_cyan	= 11,
71 	pc_brt_red	= 12,
72 	pc_brt_magenta	= 13,
73 	pc_yellow	= 14,
74 	pc_brt_white	= 15
75 } pc_colors_t;
76 
77 typedef enum sun_colors {
78 	sun_brt_white	= 0,
79 	sun_black	= 1,
80 	sun_blue	= 2,
81 	sun_green	= 3,
82 	sun_cyan	= 4,
83 	sun_red		= 5,
84 	sun_magenta	= 6,
85 	sun_brown	= 7,
86 	sun_white	= 8,
87 	sun_grey	= 9,
88 	sun_brt_blue	= 10,
89 	sun_brt_green	= 11,
90 	sun_brt_cyan	= 12,
91 	sun_brt_red	= 13,
92 	sun_brt_magenta	= 14,
93 	sun_yellow	= 15,
94 } sun_colors_t;
95 
96 #define	XLATE_NCOLORS	8
97 extern const uint8_t dim_xlate[XLATE_NCOLORS];
98 extern const uint8_t brt_xlate[XLATE_NCOLORS];
99 extern const uint8_t solaris_color_to_pc_color[NCOLORS];
100 extern const uint8_t pc_color_to_solaris_color[NCOLORS];
101 
102 extern uint32_t rgb_color_map(const rgb_t *, uint8_t);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* _SYS_RGB_H */
109