2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2014-02-27 20:26:17 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SANDBOX_SDL_H
|
|
|
|
#define __SANDBOX_SDL_H
|
|
|
|
|
|
|
|
#include <errno.h>
|
2023-06-12 21:19:04 +00:00
|
|
|
#include <video.h>
|
2014-02-27 20:26:17 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_SANDBOX_SDL
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sandbox_sdl_init_display() - Set up SDL video ready for use
|
|
|
|
*
|
|
|
|
* @width: Window width in pixels
|
|
|
|
* @height Window height in pixels
|
|
|
|
* @log2_bpp: Log to base 2 of the number of bits per pixel. So a 32bpp
|
|
|
|
* display will pass 5, since 2*5 = 32
|
2020-02-03 14:36:13 +00:00
|
|
|
* @double_size: true to double the visible size in each direction for high-DPI
|
|
|
|
* displays
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize
|
2014-02-27 20:26:17 +00:00
|
|
|
* and -EPERM if the video failed to come up.
|
|
|
|
*/
|
2020-02-03 14:36:13 +00:00
|
|
|
int sandbox_sdl_init_display(int width, int height, int log2_bpp,
|
|
|
|
bool double_size);
|
2014-02-27 20:26:17 +00:00
|
|
|
|
2021-11-19 20:23:46 +00:00
|
|
|
/**
|
|
|
|
* sandbox_sdl_remove_display() - Remove the SDL screen
|
|
|
|
*
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: 0 if OK, -ENOENT if the SDL had not been inited.
|
2021-11-19 20:23:46 +00:00
|
|
|
*/
|
|
|
|
int sandbox_sdl_remove_display(void);
|
|
|
|
|
2014-02-27 20:26:17 +00:00
|
|
|
/**
|
|
|
|
* sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL
|
|
|
|
*
|
|
|
|
* This must be called periodically to update the screen for SDL so that the
|
|
|
|
* user can see it.
|
|
|
|
*
|
|
|
|
* @lcd_base: Base of frame buffer
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: 0 if screen was updated, -ENODEV is there is no screen.
|
2014-02-27 20:26:17 +00:00
|
|
|
*/
|
|
|
|
int sandbox_sdl_sync(void *lcd_base);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sandbox_sdl_scan_keys() - scan for pressed keys
|
|
|
|
*
|
|
|
|
* Works out which keys are pressed and returns a list
|
|
|
|
*
|
|
|
|
* @key: Array to receive keycodes
|
|
|
|
* @max_keys: Size of array
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: number of keycodes found, 0 if none, -ENODEV if no keyboard
|
2014-02-27 20:26:17 +00:00
|
|
|
*/
|
|
|
|
int sandbox_sdl_scan_keys(int key[], int max_keys);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sandbox_sdl_key_pressed() - check if a particular key is pressed
|
|
|
|
*
|
|
|
|
* @keycode: Keycode to check (KEY_... - see include/linux/input.h
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: 0 if pressed, -ENOENT if not pressed. -ENODEV if keybord not
|
2014-02-27 20:26:17 +00:00
|
|
|
* available,
|
|
|
|
*/
|
|
|
|
int sandbox_sdl_key_pressed(int keycode);
|
|
|
|
|
|
|
|
/**
|
2018-12-10 17:37:47 +00:00
|
|
|
* sandbox_sdl_sound_play() - Play a sound
|
2014-02-27 20:26:17 +00:00
|
|
|
*
|
2018-12-10 17:37:47 +00:00
|
|
|
* @data: Data to play (typically 16-bit)
|
|
|
|
* @count: Number of bytes in data
|
2014-02-27 20:26:17 +00:00
|
|
|
*/
|
2018-12-10 17:37:47 +00:00
|
|
|
int sandbox_sdl_sound_play(const void *data, uint count);
|
2014-02-27 20:26:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* sandbox_sdl_sound_stop() - stop playing a sound
|
|
|
|
*
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: 0 if OK, -ENODEV if no sound is available
|
2014-02-27 20:26:17 +00:00
|
|
|
*/
|
|
|
|
int sandbox_sdl_sound_stop(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sandbox_sdl_sound_init() - set up the sound system
|
|
|
|
*
|
2018-12-10 17:37:50 +00:00
|
|
|
* @rate: Sample rate to use
|
|
|
|
* @channels: Number of channels to use (1=mono, 2=stereo)
|
2022-01-19 17:05:50 +00:00
|
|
|
* Return: 0 if OK, -ENODEV if no sound is available
|
2014-02-27 20:26:17 +00:00
|
|
|
*/
|
2018-12-10 17:37:50 +00:00
|
|
|
int sandbox_sdl_sound_init(int rate, int channels);
|
2014-02-27 20:26:17 +00:00
|
|
|
|
2023-06-12 21:19:04 +00:00
|
|
|
/**
|
|
|
|
* sandbox_sdl_set_bpp() - Set the depth of the sandbox display
|
|
|
|
*
|
|
|
|
* The device must not be active when this function is called. It activiates it
|
|
|
|
* before returning.
|
|
|
|
*
|
|
|
|
* This updates the depth value and adjusts a few other settings accordingly.
|
|
|
|
* It must be called before the display is probed.
|
|
|
|
*
|
|
|
|
* @dev: Device to adjust
|
|
|
|
* @l2bpp: depth to set
|
|
|
|
* Return: 0 if the device was already active, other error if it fails to probe
|
|
|
|
* after the change
|
|
|
|
*/
|
|
|
|
int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp);
|
|
|
|
|
2014-02-27 20:26:17 +00:00
|
|
|
#else
|
2020-02-03 14:36:13 +00:00
|
|
|
static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp,
|
|
|
|
bool double_size)
|
2014-02-27 20:26:17 +00:00
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2022-03-23 20:20:37 +00:00
|
|
|
static inline int sandbox_sdl_remove_display(void)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2014-02-27 20:26:17 +00:00
|
|
|
static inline int sandbox_sdl_sync(void *lcd_base)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sandbox_sdl_scan_keys(int key[], int max_keys)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sandbox_sdl_key_pressed(int keycode)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sandbox_sdl_sound_start(uint frequency)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2019-04-09 09:27:00 +00:00
|
|
|
static inline int sandbox_sdl_sound_play(const void *data, uint count)
|
2018-12-10 17:37:47 +00:00
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2014-02-27 20:26:17 +00:00
|
|
|
static inline int sandbox_sdl_sound_stop(void)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2019-04-09 09:27:00 +00:00
|
|
|
static inline int sandbox_sdl_sound_init(int rate, int channels)
|
2014-02-27 20:26:17 +00:00
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2023-06-12 21:19:04 +00:00
|
|
|
static inline int sandbox_sdl_set_bpp(struct udevice *dev,
|
|
|
|
enum video_log2_bpp l2bpp)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2014-02-27 20:26:17 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|