]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
bbc09bf2 SG |
2 | /* |
3 | * Copyright (c) 2013 Google, Inc | |
bbc09bf2 SG |
4 | */ |
5 | ||
6 | #ifndef __SANDBOX_SDL_H | |
7 | #define __SANDBOX_SDL_H | |
8 | ||
9 | #include <errno.h> | |
10 | ||
11 | #ifdef CONFIG_SANDBOX_SDL | |
12 | ||
13 | /** | |
14 | * sandbox_sdl_init_display() - Set up SDL video ready for use | |
15 | * | |
16 | * @width: Window width in pixels | |
17 | * @height Window height in pixels | |
18 | * @log2_bpp: Log to base 2 of the number of bits per pixel. So a 32bpp | |
19 | * display will pass 5, since 2*5 = 32 | |
6be88c72 SG |
20 | * @double_size: true to double the visible size in each direction for high-DPI |
21 | * displays | |
185f812c | 22 | * Return: 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize |
bbc09bf2 SG |
23 | * and -EPERM if the video failed to come up. |
24 | */ | |
6be88c72 SG |
25 | int sandbox_sdl_init_display(int width, int height, int log2_bpp, |
26 | bool double_size); | |
bbc09bf2 | 27 | |
250e735c SG |
28 | /** |
29 | * sandbox_sdl_remove_display() - Remove the SDL screen | |
30 | * | |
185f812c | 31 | * Return: 0 if OK, -ENOENT if the SDL had not been inited. |
250e735c SG |
32 | */ |
33 | int sandbox_sdl_remove_display(void); | |
34 | ||
bbc09bf2 SG |
35 | /** |
36 | * sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL | |
37 | * | |
38 | * This must be called periodically to update the screen for SDL so that the | |
39 | * user can see it. | |
40 | * | |
41 | * @lcd_base: Base of frame buffer | |
185f812c | 42 | * Return: 0 if screen was updated, -ENODEV is there is no screen. |
bbc09bf2 SG |
43 | */ |
44 | int sandbox_sdl_sync(void *lcd_base); | |
45 | ||
46 | /** | |
47 | * sandbox_sdl_scan_keys() - scan for pressed keys | |
48 | * | |
49 | * Works out which keys are pressed and returns a list | |
50 | * | |
51 | * @key: Array to receive keycodes | |
52 | * @max_keys: Size of array | |
185f812c | 53 | * Return: number of keycodes found, 0 if none, -ENODEV if no keyboard |
bbc09bf2 SG |
54 | */ |
55 | int sandbox_sdl_scan_keys(int key[], int max_keys); | |
56 | ||
57 | /** | |
58 | * sandbox_sdl_key_pressed() - check if a particular key is pressed | |
59 | * | |
60 | * @keycode: Keycode to check (KEY_... - see include/linux/input.h | |
185f812c | 61 | * Return: 0 if pressed, -ENOENT if not pressed. -ENODEV if keybord not |
bbc09bf2 SG |
62 | * available, |
63 | */ | |
64 | int sandbox_sdl_key_pressed(int keycode); | |
65 | ||
66 | /** | |
f2b25c9b | 67 | * sandbox_sdl_sound_play() - Play a sound |
bbc09bf2 | 68 | * |
f2b25c9b SG |
69 | * @data: Data to play (typically 16-bit) |
70 | * @count: Number of bytes in data | |
bbc09bf2 | 71 | */ |
f2b25c9b | 72 | int sandbox_sdl_sound_play(const void *data, uint count); |
bbc09bf2 SG |
73 | |
74 | /** | |
75 | * sandbox_sdl_sound_stop() - stop playing a sound | |
76 | * | |
185f812c | 77 | * Return: 0 if OK, -ENODEV if no sound is available |
bbc09bf2 SG |
78 | */ |
79 | int sandbox_sdl_sound_stop(void); | |
80 | ||
81 | /** | |
82 | * sandbox_sdl_sound_init() - set up the sound system | |
83 | * | |
e221cdcf SG |
84 | * @rate: Sample rate to use |
85 | * @channels: Number of channels to use (1=mono, 2=stereo) | |
185f812c | 86 | * Return: 0 if OK, -ENODEV if no sound is available |
bbc09bf2 | 87 | */ |
e221cdcf | 88 | int sandbox_sdl_sound_init(int rate, int channels); |
bbc09bf2 SG |
89 | |
90 | #else | |
6be88c72 SG |
91 | static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp, |
92 | bool double_size) | |
bbc09bf2 SG |
93 | { |
94 | return -ENODEV; | |
95 | } | |
96 | ||
97 | static inline int sandbox_sdl_sync(void *lcd_base) | |
98 | { | |
99 | return -ENODEV; | |
100 | } | |
101 | ||
102 | static inline int sandbox_sdl_scan_keys(int key[], int max_keys) | |
103 | { | |
104 | return -ENODEV; | |
105 | } | |
106 | ||
107 | static inline int sandbox_sdl_key_pressed(int keycode) | |
108 | { | |
109 | return -ENODEV; | |
110 | } | |
111 | ||
112 | static inline int sandbox_sdl_sound_start(uint frequency) | |
113 | { | |
114 | return -ENODEV; | |
115 | } | |
116 | ||
6539700d | 117 | static inline int sandbox_sdl_sound_play(const void *data, uint count) |
f2b25c9b SG |
118 | { |
119 | return -ENODEV; | |
120 | } | |
121 | ||
bbc09bf2 SG |
122 | static inline int sandbox_sdl_sound_stop(void) |
123 | { | |
124 | return -ENODEV; | |
125 | } | |
126 | ||
6539700d | 127 | static inline int sandbox_sdl_sound_init(int rate, int channels) |
bbc09bf2 SG |
128 | { |
129 | return -ENODEV; | |
130 | } | |
131 | ||
132 | #endif | |
133 | ||
134 | #endif |