blob: 56dcb84803d332456cb032c7d5d9669e6e9a724b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass0d10f292014-02-27 13:26:17 -07002/*
3 * Copyright (c) 2013 Google, Inc
Simon Glass0d10f292014-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 Glassf91de0b2020-02-03 07:36:13 -070020 * @double_size: true to double the visible size in each direction for high-DPI
21 * displays
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010022 * Return: 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize
Simon Glass0d10f292014-02-27 13:26:17 -070023 * and -EPERM if the video failed to come up.
24 */
Simon Glassf91de0b2020-02-03 07:36:13 -070025int sandbox_sdl_init_display(int width, int height, int log2_bpp,
26 bool double_size);
Simon Glass0d10f292014-02-27 13:26:17 -070027
28/**
Simon Glasscce74802021-11-19 13:23:46 -070029 * sandbox_sdl_remove_display() - Remove the SDL screen
30 *
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010031 * Return: 0 if OK, -ENOENT if the SDL had not been inited.
Simon Glasscce74802021-11-19 13:23:46 -070032 */
33int sandbox_sdl_remove_display(void);
34
35/**
Simon Glass0d10f292014-02-27 13:26:17 -070036 * 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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010042 * Return: 0 if screen was updated, -ENODEV is there is no screen.
Simon Glass0d10f292014-02-27 13:26:17 -070043 */
44int 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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010053 * Return: number of keycodes found, 0 if none, -ENODEV if no keyboard
Simon Glass0d10f292014-02-27 13:26:17 -070054 */
55int 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
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010061 * Return: 0 if pressed, -ENOENT if not pressed. -ENODEV if keybord not
Simon Glass0d10f292014-02-27 13:26:17 -070062 * available,
63 */
64int sandbox_sdl_key_pressed(int keycode);
65
66/**
Simon Glassab6dbe62018-12-10 10:37:47 -070067 * sandbox_sdl_sound_play() - Play a sound
Simon Glass0d10f292014-02-27 13:26:17 -070068 *
Simon Glassab6dbe62018-12-10 10:37:47 -070069 * @data: Data to play (typically 16-bit)
70 * @count: Number of bytes in data
Simon Glass0d10f292014-02-27 13:26:17 -070071 */
Simon Glassab6dbe62018-12-10 10:37:47 -070072int sandbox_sdl_sound_play(const void *data, uint count);
Simon Glass0d10f292014-02-27 13:26:17 -070073
74/**
75 * sandbox_sdl_sound_stop() - stop playing a sound
76 *
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010077 * Return: 0 if OK, -ENODEV if no sound is available
Simon Glass0d10f292014-02-27 13:26:17 -070078 */
79int sandbox_sdl_sound_stop(void);
80
81/**
Simon Glass0d10f292014-02-27 13:26:17 -070082 * sandbox_sdl_sound_init() - set up the sound system
83 *
Simon Glass658a8742018-12-10 10:37:50 -070084 * @rate: Sample rate to use
85 * @channels: Number of channels to use (1=mono, 2=stereo)
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010086 * Return: 0 if OK, -ENODEV if no sound is available
Simon Glass0d10f292014-02-27 13:26:17 -070087 */
Simon Glass658a8742018-12-10 10:37:50 -070088int sandbox_sdl_sound_init(int rate, int channels);
Simon Glass0d10f292014-02-27 13:26:17 -070089
90#else
Simon Glassf91de0b2020-02-03 07:36:13 -070091static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp,
92 bool double_size)
Simon Glass0d10f292014-02-27 13:26:17 -070093{
94 return -ENODEV;
95}
96
Andrew Scull33747042022-03-23 20:20:37 +000097static inline int sandbox_sdl_remove_display(void)
98{
99 return -ENODEV;
100}
101
Simon Glass0d10f292014-02-27 13:26:17 -0700102static inline int sandbox_sdl_sync(void *lcd_base)
103{
104 return -ENODEV;
105}
106
107static inline int sandbox_sdl_scan_keys(int key[], int max_keys)
108{
109 return -ENODEV;
110}
111
112static inline int sandbox_sdl_key_pressed(int keycode)
113{
114 return -ENODEV;
115}
116
117static inline int sandbox_sdl_sound_start(uint frequency)
118{
119 return -ENODEV;
120}
121
Christian Gmeinerc679def2019-04-09 11:27:00 +0200122static inline int sandbox_sdl_sound_play(const void *data, uint count)
Simon Glassab6dbe62018-12-10 10:37:47 -0700123{
124 return -ENODEV;
125}
126
Simon Glass0d10f292014-02-27 13:26:17 -0700127static inline int sandbox_sdl_sound_stop(void)
128{
129 return -ENODEV;
130}
131
Christian Gmeinerc679def2019-04-09 11:27:00 +0200132static inline int sandbox_sdl_sound_init(int rate, int channels)
Simon Glass0d10f292014-02-27 13:26:17 -0700133{
134 return -ENODEV;
135}
136
137#endif
138
139#endif