Debian Codegraph @

src/include/bootsplash.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #ifndef __BOOTSPLASH_H__
4 #define __BOOTSPLASH_H__
5
6 #include <boot/coreboot_tables.h>
7 #include <types.h>
8
9 enum bootsplash_type {
10 /* Indicates a low battery bootsplash logo. */
11 BOOTSPLASH_LOW_BATTERY,
12 /* Indicates a Main OEM defined bootsplash logo for center of the splash screen. */
13 BOOTSPLASH_CENTER,
14 /* Indicates an optional OEM defined bootsplash logo for footer of the splash screen. */
15 BOOTSPLASH_FOOTER,
16
17 /* It's used to determine the total number of bootsplash types. */
18 BOOTSPLASH_MAX_NUM,
19 };
20
21 /**
22 * Sets up the framebuffer with the bootsplash.jpg from cbfs.
23 * Returns 0 on success
24 * CB_ERR on cbfs errors
25 * and >0 on jpeg errors.
26 */
27 void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
28 unsigned int y_resolution, unsigned int bytes_per_line,
29 unsigned int fb_resolution);
30
31 /*
32 * Specifies the vertical alignment for the splash screen image.
33 *
34 * Visual Guide (representing the display area and the [LOGO]):
35 *
36 * Each option dictates the vertical placement of the splash image
37 * within the display's height.
38 */
39 enum fw_splash_vertical_alignment {
40 /*
41 * The splash image is centered vertically `(Y-axis - logo_height)/2` on the screen.
42 * The center of the [LOGO] aligns with the vertical center of the screen.
43 *
44 * +---------------+
45 * | |
46 * | |
47 * | [LOGO] | <-- Vertically Centered
48 * | |
49 * | |
50 * +---------------+
51 */
52 FW_SPLASH_VALIGNMENT_CENTER = 0,
53
54 /*
55 * The splash image is aligned to the top edge of the screen.
56 *
57 * +---------------+
58 * | [LOGO] | <-- Top Aligned
59 * | |
60 * | |
61 * | |
62 * | |
63 * +---------------+
64 */
65 FW_SPLASH_VALIGNMENT_TOP = 1,
66
67 /*
68 * The splash image is aligned to the bottom edge of the screen.
69 *
70 * +---------------+
71 * | |
72 * | |
73 * | |
74 * | |
75 * | [LOGO] | <-- Bottom Aligned
76 * +---------------+
77 */
78 FW_SPLASH_VALIGNMENT_BOTTOM = 2,
79
80 /*
81 * The splash image is placed in the vertical middle `(Y-axis/2)` of the screen
82 * (without considering the `logo height`). This means the TOP EDGE of the
83 * [LOGO] aligns with the screen's vertical midpoint line.
84 *
85 * +---------------+
86 * | (Upper Half) |
87 * | |
88 * | [LOGO] | <-- [LOGO] aligns at Middle of the Y-axis
89 * | |
90 * | (Lower Half) |
91 * +---------------+
92 *
93 * Note: The distinction between CENTER and MIDDLE is relevant as in for MIDDLE
94 * alignment, it ignores the logo height (i.e., the logo's top edge is placed
95 * at the screen's Y-midpoint). CENTER alignment, by contrast, would place
96 * the geometrical center of the logo at the screen's Y-midpoint.
97 */
98 FW_SPLASH_VALIGNMENT_MIDDLE = 3,
99 };
100
101 enum fw_splash_horizontal_alignment {
102 /*
103 * The splash image is centered horizontally `(X-axis - logo_width)/2` on the screen.
104 * The center of the [LOGO] aligns with the horizontal center of the screen.
105 *
106 * +-----------------+
107 * | [LOGO] |
108 * +-----------------+
109 */
110 FW_SPLASH_HALIGNMENT_CENTER = 0,
111
112 /*
113 * The splash image is aligned to the left edge of the screen.
114 *
115 * +-----------------+
116 * |[LOGO] |
117 * +-----------------+
118 */
119 FW_SPLASH_HALIGNMENT_LEFT = 1,
120
121 /*
122 * The splash image is aligned to the right edge of the screen.
123 *
124 * +-----------------+
125 * | [LOGO]|
126 * +-----------------+
127 */
128 FW_SPLASH_HALIGNMENT_RIGHT = 2,
129 };
130
131 struct logo_config {
132 uintptr_t framebuffer_base;
133 uint32_t horizontal_resolution;
134 uint32_t vertical_resolution;
135 uint32_t bytes_per_scanline;
136 enum lb_fb_orientation panel_orientation;
137 enum fw_splash_horizontal_alignment halignment;
138 enum fw_splash_vertical_alignment valignment;
139 uint8_t logo_bottom_margin;
140 };
141
142 void render_logo_to_framebuffer(struct logo_config *config);
143 void load_and_convert_bmp_to_blt(uintptr_t *logo, size_t *logo_size,
144 uintptr_t *blt, size_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width,
145 enum lb_fb_orientation orientation);
146 void convert_bmp_to_blt(uintptr_t logo, size_t logo_size,
147 uintptr_t *blt, size_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width,
148 enum lb_fb_orientation orientation);
149
150 /*
151 * Allow platform-specific BMP logo overrides via HAVE_CUSTOM_BMP_LOGO config.
152 * For example: Introduce configurable BMP logo for customization on platforms like ChromeOS
153 */
154 const char *bmp_logo_filename(void);
155 void *bmp_load_logo(size_t *logo_size);
156 void *bmp_load_logo_by_type(enum bootsplash_type type, size_t *logo_size);
157 void bmp_release_logo(void);
158 /*
159 * Platform specific callbacks for power-off handling.
160 *
161 * These callbacks allow the platform to determine if a power-off is
162 * necessary due to various reasons, such as low battery detection.
163 *
164 * Additionally, API to perform platform specific power-off
165 */
166 #if CONFIG(PLATFORM_HAS_LOW_BATTERY_INDICATOR)
167 bool platform_is_low_battery_shutdown_needed(void);
168 #else
169 static inline bool platform_is_low_battery_shutdown_needed(void) { return false; }
170 #endif
171
172 #endif