1 /*
2  * Copyright (c) 2018 Jan Van Winkel <jan.van_winkel@dxplore.eu>
3  * Copyright (c) 2023 Nordic Semiconductor
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  *
7  * "Bottom" of the SDL display driver.
8  * When built with the native_simulator this will be built in the runner context,
9  * that is, with the host C library, and with the host include paths.
10  */
11 #ifndef DRIVERS_DISPLAY_DISPLAY_SDL_BOTTOM_H
12 #define DRIVERS_DISPLAY_DISPLAY_SDL_BOTTOM_H
13 
14 #include <stdbool.h>
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /* Note: None of these functions are public interfaces. But internal to the SDL display driver */
22 
23 struct sdl_display_init_params {
24 	uint16_t height;
25 	uint16_t width;
26 	uint16_t zoom_pct;
27 	bool use_accelerator;
28 	void **window;
29 	const void *window_user_data;
30 	const char *title;
31 	void **renderer;
32 	void **mutex;
33 	void **texture;
34 	void **read_texture;
35 	void **background_texture;
36 	uint32_t transparency_grid_color1;
37 	uint32_t transparency_grid_color2;
38 	uint16_t transparency_grid_cell_size;
39 	void **round_disp_mask;
40 	uint32_t mask_color;
41 };
42 
43 struct sdl_display_write_params {
44 	uint16_t height;
45 	uint16_t width;
46 	uint16_t x;
47 	uint16_t y;
48 	void *renderer;
49 	void *mutex;
50 	void *texture;
51 	void *background_texture;
52 	uint8_t *buf;
53 	bool display_on;
54 	bool frame_incomplete;
55 	uint32_t color_tint;
56 	void *round_disp_mask;
57 };
58 
59 struct sdl_display_read_params {
60 	uint16_t height;
61 	uint16_t width;
62 	uint16_t x;
63 	uint16_t y;
64 	void *renderer;
65 	void *buf;
66 	uint16_t pitch;
67 	void *mutex;
68 	void *texture;
69 	void *read_texture;
70 };
71 
72 struct sdl_display_blanking_off_params {
73 	void *renderer;
74 	void *texture;
75 	void *background_texture;
76 	uint32_t color_tint;
77 	void *round_disp_mask;
78 };
79 
80 struct sdl_display_cleanup_params {
81 	void **window;
82 	void **renderer;
83 	void **mutex;
84 	void **texture;
85 	void **read_texture;
86 	void **background_texture;
87 	void **round_disp_mask;
88 };
89 
90 int sdl_display_init_bottom(struct sdl_display_init_params *params);
91 void sdl_display_write_bottom(const struct sdl_display_write_params *params);
92 int sdl_display_read_bottom(const struct sdl_display_read_params *params);
93 void sdl_display_blanking_off_bottom(const struct sdl_display_blanking_off_params *params);
94 void sdl_display_blanking_on_bottom(void *renderer);
95 void sdl_display_cleanup_bottom(const struct sdl_display_cleanup_params *params);
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /* DRIVERS_DISPLAY_DISPLAY_SDL_BOTTOM_H */
102