Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013 Google, Inc |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 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 |
Simon Glass | f91de0b | 2020-02-03 07:36:13 -0700 | [diff] [blame] | 20 | * @double_size: true to double the visible size in each direction for high-DPI |
| 21 | * displays |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 22 | * @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 Glass | f91de0b | 2020-02-03 07:36:13 -0700 | [diff] [blame] | 25 | int sandbox_sdl_init_display(int width, int height, int log2_bpp, |
| 26 | bool double_size); |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 27 | |
| 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 | */ |
| 37 | int 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 | */ |
| 48 | int 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 | */ |
| 57 | int sandbox_sdl_key_pressed(int keycode); |
| 58 | |
| 59 | /** |
Simon Glass | ab6dbe6 | 2018-12-10 10:37:47 -0700 | [diff] [blame] | 60 | * sandbox_sdl_sound_play() - Play a sound |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 61 | * |
Simon Glass | ab6dbe6 | 2018-12-10 10:37:47 -0700 | [diff] [blame] | 62 | * @data: Data to play (typically 16-bit) |
| 63 | * @count: Number of bytes in data |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 64 | */ |
Simon Glass | ab6dbe6 | 2018-12-10 10:37:47 -0700 | [diff] [blame] | 65 | int sandbox_sdl_sound_play(const void *data, uint count); |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * sandbox_sdl_sound_stop() - stop playing a sound |
| 69 | * |
| 70 | * @return 0 if OK, -ENODEV if no sound is available |
| 71 | */ |
| 72 | int sandbox_sdl_sound_stop(void); |
| 73 | |
| 74 | /** |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 75 | * sandbox_sdl_sound_init() - set up the sound system |
| 76 | * |
Simon Glass | 658a874 | 2018-12-10 10:37:50 -0700 | [diff] [blame] | 77 | * @rate: Sample rate to use |
| 78 | * @channels: Number of channels to use (1=mono, 2=stereo) |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 79 | * @return 0 if OK, -ENODEV if no sound is available |
| 80 | */ |
Simon Glass | 658a874 | 2018-12-10 10:37:50 -0700 | [diff] [blame] | 81 | int sandbox_sdl_sound_init(int rate, int channels); |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 82 | |
| 83 | #else |
Simon Glass | f91de0b | 2020-02-03 07:36:13 -0700 | [diff] [blame] | 84 | static inline int sandbox_sdl_init_display(int width, int height, int log2_bpp, |
| 85 | bool double_size) |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 86 | { |
| 87 | return -ENODEV; |
| 88 | } |
| 89 | |
| 90 | static inline int sandbox_sdl_sync(void *lcd_base) |
| 91 | { |
| 92 | return -ENODEV; |
| 93 | } |
| 94 | |
| 95 | static inline int sandbox_sdl_scan_keys(int key[], int max_keys) |
| 96 | { |
| 97 | return -ENODEV; |
| 98 | } |
| 99 | |
| 100 | static inline int sandbox_sdl_key_pressed(int keycode) |
| 101 | { |
| 102 | return -ENODEV; |
| 103 | } |
| 104 | |
| 105 | static inline int sandbox_sdl_sound_start(uint frequency) |
| 106 | { |
| 107 | return -ENODEV; |
| 108 | } |
| 109 | |
Christian Gmeiner | c679def | 2019-04-09 11:27:00 +0200 | [diff] [blame] | 110 | static inline int sandbox_sdl_sound_play(const void *data, uint count) |
Simon Glass | ab6dbe6 | 2018-12-10 10:37:47 -0700 | [diff] [blame] | 111 | { |
| 112 | return -ENODEV; |
| 113 | } |
| 114 | |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 115 | static inline int sandbox_sdl_sound_stop(void) |
| 116 | { |
| 117 | return -ENODEV; |
| 118 | } |
| 119 | |
Christian Gmeiner | c679def | 2019-04-09 11:27:00 +0200 | [diff] [blame] | 120 | static inline int sandbox_sdl_sound_init(int rate, int channels) |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 121 | { |
| 122 | return -ENODEV; |
| 123 | } |
| 124 | |
| 125 | #endif |
| 126 | |
| 127 | #endif |