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 |
| 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 | /** |
Simon Glass | ab6dbe6 | 2018-12-10 10:37:47 -0700 | [diff] [blame] | 57 | * sandbox_sdl_sound_play() - Play a sound |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 58 | * |
Simon Glass | ab6dbe6 | 2018-12-10 10:37:47 -0700 | [diff] [blame] | 59 | * @data: Data to play (typically 16-bit) |
| 60 | * @count: Number of bytes in data |
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 | int sandbox_sdl_sound_play(const void *data, uint count); |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 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 | /** |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 72 | * sandbox_sdl_sound_init() - set up the sound system |
| 73 | * |
Simon Glass | 658a874 | 2018-12-10 10:37:50 -0700 | [diff] [blame] | 74 | * @rate: Sample rate to use |
| 75 | * @channels: Number of channels to use (1=mono, 2=stereo) |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 76 | * @return 0 if OK, -ENODEV if no sound is available |
| 77 | */ |
Simon Glass | 658a874 | 2018-12-10 10:37:50 -0700 | [diff] [blame] | 78 | int sandbox_sdl_sound_init(int rate, int channels); |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 79 | |
| 80 | #else |
| 81 | static inline int sandbox_sdl_init_display(int width, int height, |
| 82 | int log2_bpp) |
| 83 | { |
| 84 | return -ENODEV; |
| 85 | } |
| 86 | |
| 87 | static inline int sandbox_sdl_sync(void *lcd_base) |
| 88 | { |
| 89 | return -ENODEV; |
| 90 | } |
| 91 | |
| 92 | static inline int sandbox_sdl_scan_keys(int key[], int max_keys) |
| 93 | { |
| 94 | return -ENODEV; |
| 95 | } |
| 96 | |
| 97 | static inline int sandbox_sdl_key_pressed(int keycode) |
| 98 | { |
| 99 | return -ENODEV; |
| 100 | } |
| 101 | |
| 102 | static inline int sandbox_sdl_sound_start(uint frequency) |
| 103 | { |
| 104 | return -ENODEV; |
| 105 | } |
| 106 | |
Christian Gmeiner | c679def | 2019-04-09 11:27:00 +0200 | [diff] [blame] | 107 | static inline int sandbox_sdl_sound_play(const void *data, uint count) |
Simon Glass | ab6dbe6 | 2018-12-10 10:37:47 -0700 | [diff] [blame] | 108 | { |
| 109 | return -ENODEV; |
| 110 | } |
| 111 | |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 112 | static inline int sandbox_sdl_sound_stop(void) |
| 113 | { |
| 114 | return -ENODEV; |
| 115 | } |
| 116 | |
Christian Gmeiner | c679def | 2019-04-09 11:27:00 +0200 | [diff] [blame] | 117 | static inline int sandbox_sdl_sound_init(int rate, int channels) |
Simon Glass | 0d10f29 | 2014-02-27 13:26:17 -0700 | [diff] [blame] | 118 | { |
| 119 | return -ENODEV; |
| 120 | } |
| 121 | |
| 122 | #endif |
| 123 | |
| 124 | #endif |