xref: /openbmc/u-boot/arch/sandbox/include/asm/sdl.h (revision 78a88f79)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2013 Google, Inc
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
20  * @return 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize
21  *		and -EPERM if the video failed to come up.
22  */
23 int sandbox_sdl_init_display(int width, int height, int log2_bpp);
24 
25 /**
26  * sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL
27  *
28  * This must be called periodically to update the screen for SDL so that the
29  * user can see it.
30  *
31  * @lcd_base: Base of frame buffer
32  * @return 0 if screen was updated, -ENODEV is there is no screen.
33  */
34 int sandbox_sdl_sync(void *lcd_base);
35 
36 /**
37  * sandbox_sdl_scan_keys() - scan for pressed keys
38  *
39  * Works out which keys are pressed and returns a list
40  *
41  * @key:	Array to receive keycodes
42  * @max_keys:	Size of array
43  * @return number of keycodes found, 0 if none, -ENODEV if no keyboard
44  */
45 int sandbox_sdl_scan_keys(int key[], int max_keys);
46 
47 /**
48  * sandbox_sdl_key_pressed() - check if a particular key is pressed
49  *
50  * @keycode:	Keycode to check (KEY_... - see include/linux/input.h
51  * @return 0 if pressed, -ENOENT if not pressed. -ENODEV if keybord not
52  * available,
53  */
54 int sandbox_sdl_key_pressed(int keycode);
55 
56 /**
57  * sandbox_sdl_sound_start() - start playing a sound
58  *
59  * @frequency:	Frequency of sounds in Hertz
60  * @return 0 if OK, -ENODEV if no sound is available
61  */
62 int sandbox_sdl_sound_start(uint frequency);
63 
64 /**
65  * sandbox_sdl_sound_stop() - stop playing a sound
66  *
67  * @return 0 if OK, -ENODEV if no sound is available
68  */
69 int sandbox_sdl_sound_stop(void);
70 
71 /**
72  * sandbox_sdl_sound_init() - set up the sound system
73  *
74  * @return 0 if OK, -ENODEV if no sound is available
75  */
76 int sandbox_sdl_sound_init(void);
77 
78 #else
79 static inline int sandbox_sdl_init_display(int width, int height,
80 					    int log2_bpp)
81 {
82 	return -ENODEV;
83 }
84 
85 static inline int sandbox_sdl_sync(void *lcd_base)
86 {
87 	return -ENODEV;
88 }
89 
90 static inline int sandbox_sdl_scan_keys(int key[], int max_keys)
91 {
92 	return -ENODEV;
93 }
94 
95 static inline int sandbox_sdl_key_pressed(int keycode)
96 {
97 	return -ENODEV;
98 }
99 
100 static inline int sandbox_sdl_sound_start(uint frequency)
101 {
102 	return -ENODEV;
103 }
104 
105 static inline int sandbox_sdl_sound_stop(void)
106 {
107 	return -ENODEV;
108 }
109 
110 static inline int sandbox_sdl_sound_init(void)
111 {
112 	return -ENODEV;
113 }
114 
115 #endif
116 
117 #endif
118