xref: /illumos-gate/usr/src/uts/common/sys/rgb.h (revision fa9eb22261c7b7a35c7a6957acb3c2b26c39e15b)
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 extern rgb_t rgb_info;
47 
48 typedef struct {
49 	uint8_t red[NCOLORS];
50 	uint8_t green[NCOLORS];
51 	uint8_t blue[NCOLORS];
52 } text_cmap_t;
53 
54 extern const text_cmap_t cmap4_to_24;
55 /*
56  * ANSI color to sun color translation.
57  */
58 
59 /* The pc color here is actually referring to standard 16 color VGA map. */
60 typedef enum pc_colors {
61 	pc_black	= 0,
62 	pc_blue		= 1,
63 	pc_green	= 2,
64 	pc_cyan		= 3,
65 	pc_red		= 4,
66 	pc_magenta	= 5,
67 	pc_brown	= 6,
68 	pc_white	= 7,
69 	pc_grey		= 8,
70 	pc_brt_blue	= 9,
71 	pc_brt_green	= 10,
72 	pc_brt_cyan	= 11,
73 	pc_brt_red	= 12,
74 	pc_brt_magenta	= 13,
75 	pc_yellow	= 14,
76 	pc_brt_white	= 15
77 } pc_colors_t;
78 
79 typedef enum sun_colors {
80 	sun_brt_white	= 0,
81 	sun_black	= 1,
82 	sun_blue	= 2,
83 	sun_green	= 3,
84 	sun_cyan	= 4,
85 	sun_red		= 5,
86 	sun_magenta	= 6,
87 	sun_brown	= 7,
88 	sun_white	= 8,
89 	sun_grey	= 9,
90 	sun_brt_blue	= 10,
91 	sun_brt_green	= 11,
92 	sun_brt_cyan	= 12,
93 	sun_brt_red	= 13,
94 	sun_brt_magenta	= 14,
95 	sun_yellow	= 15,
96 } sun_colors_t;
97 
98 #define	XLATE_NCOLORS	8
99 extern const uint8_t dim_xlate[XLATE_NCOLORS];
100 extern const uint8_t brt_xlate[XLATE_NCOLORS];
101 extern const uint8_t solaris_color_to_pc_color[NCOLORS];
102 extern const uint8_t pc_color_to_solaris_color[NCOLORS];
103 
104 extern uint32_t rgb_to_color(const rgb_t *, uint32_t, uint32_t, uint32_t,
105     uint32_t);
106 extern uint32_t rgb_color_map(const rgb_t *, uint8_t, uint8_t);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif /* _SYS_RGB_H */
113