blob: 47fc4889d2074c2c7d734cb1e86d8acf95413262 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glassbbc09bf2014-02-27 13:26:17 -07002/*
3 * Copyright (c) 2013 Google, Inc
Simon Glassbbc09bf2014-02-27 13:26:17 -07004 */
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
Simon Glass6be88c72020-02-03 07:36:13 -070020 * @double_size: true to double the visible size in each direction for high-DPI
21 * displays
Simon Glassbbc09bf2014-02-27 13:26:17 -070022 * @return 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize
23 * and -EPERM if the video failed to come up.
24 */
Simon Glass6be88c72020-02-03 07:36:13 -070025int sandbox_sdl_init_display(int width, int height, int log2_bpp,
26 bool double_size);
Simon Glassbbc09bf2014-02-27 13:26:17 -070027
28/**
29 * sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL
30 *
31 * This must be called periodically to update the screen for SDL so that the
32 * user can see it.
33 *
34 * @lcd_base: Base of frame buffer
35 * @return 0 if screen was updated, -ENODEV is there is no screen.
36 */
37int sandbox_sdl_sync(void *lcd_base);
38
39/**
40 * sandbox_sdl_scan_keys() - scan for pressed keys
41 *
42 * Works out which keys are pressed and returns a list
43 *
44 * @key: Array to receive keycodes
45 * @max_keys: Size of array
46 * @return number of keycodes found, 0 if none, -ENODEV if no keyboard
47 */
48int sandbox_sdl_scan_keys(int key[], int max_keys);
49
50/**
51 * sandbox_sdl_key_pressed() - check if a particular key is pressed
52 *
53 * @keycode: Keycode to check (KEY_... - see include/linux/input.h
54 * @return 0 if pressed, -ENOENT if not pressed. -ENODEV if keybord not
55 * available,
56 */
57int sandbox_sdl_key_pressed(int keycode);
58
59/**
Simon Glassf2b25c92018-12-10 10:37:47 -070060 * sandbox_sdl_sound_play() - Play a sound
Simon Glassbbc09bf2014-02-27 13:26:17 -070061 *
Simon Glassf2b25c92018-12-10 10:37:47 -070062 * @data: Data to play (typically 16-bit)
63 * @count: Number of bytes in data
Simon Glassbbc09bf2014-02-27 13:26:17 -070064 */
Simon Glassf2b25c92018-12-10 10:37:47 -070065int sandbox_sdl_sound_play(const void *data, uint count);
Simon Glassbbc09bf2014-02-27 13:26:17 -070066
67/**
68 * sandbox_sdl_sound_stop() - stop playing a sound
69 *
70 * @return 0 if OK, -ENODEV if no sound is available
71 */
72int sandbox_sdl_sound_stop(void);
73
74/**
Simon Glassbbc09bf2014-02-27 13:26:17 -070075 * sandbox_sdl_sound_init() - set up the sound system
76 *
Simon Glasse221cdc2018-12-10 10:37:50 -070077 * @rate: Sample rate to use
78 * @channels: Number of channels to use (1=mono, 2=stereo)
Simon Glassbbc09bf2014-02-27 13:26:17 -070079 * @return 0 if OK, -ENODEV if no sound is available
80 */
Simon Glasse221cdc2018-12-10 10:37:50 -070081int sandbox_sdl_sound_init(int rate, int channels);
Simon Glassbbc09bf2014-02-27 13:26:17 -070082
83#else
Simon Glass6be88c72020-02-03 07:36:13 -070084static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp,
85 bool double_size)
Simon Glassbbc09bf2014-02-27 13:26:17 -070086{
87 return -ENODEV;
88}
89
90static inline int sandbox_sdl_sync(void *lcd_base)
91{
92 return -ENODEV;
93}
94
95static inline int sandbox_sdl_scan_keys(int key[], int max_keys)
96{
97 return -ENODEV;
98}
99
100static inline int sandbox_sdl_key_pressed(int keycode)
101{
102 return -ENODEV;
103}
104
105static inline int sandbox_sdl_sound_start(uint frequency)
106{
107 return -ENODEV;
108}
109
Christian Gmeiner65397002019-04-09 11:27:00 +0200110static inline int sandbox_sdl_sound_play(const void *data, uint count)
Simon Glassf2b25c92018-12-10 10:37:47 -0700111{
112 return -ENODEV;
113}
114
Simon Glassbbc09bf2014-02-27 13:26:17 -0700115static inline int sandbox_sdl_sound_stop(void)
116{
117 return -ENODEV;
118}
119
Christian Gmeiner65397002019-04-09 11:27:00 +0200120static inline int sandbox_sdl_sound_init(int rate, int channels)
Simon Glassbbc09bf2014-02-27 13:26:17 -0700121{
122 return -ENODEV;
123}
124
125#endif
126
127#endif