sdl.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2013 Google, Inc
  4. */
  5. #ifndef __SANDBOX_SDL_H
  6. #define __SANDBOX_SDL_H
  7. #include <errno.h>
  8. #ifdef CONFIG_SANDBOX_SDL
  9. /**
  10. * sandbox_sdl_init_display() - Set up SDL video ready for use
  11. *
  12. * @width: Window width in pixels
  13. * @height Window height in pixels
  14. * @log2_bpp: Log to base 2 of the number of bits per pixel. So a 32bpp
  15. * display will pass 5, since 2*5 = 32
  16. * @return 0 if OK, -ENODEV if no device, -EIO if SDL failed to initialize
  17. * and -EPERM if the video failed to come up.
  18. */
  19. int sandbox_sdl_init_display(int width, int height, int log2_bpp);
  20. /**
  21. * sandbox_sdl_sync() - Sync current U-Boot LCD frame buffer to SDL
  22. *
  23. * This must be called periodically to update the screen for SDL so that the
  24. * user can see it.
  25. *
  26. * @lcd_base: Base of frame buffer
  27. * @return 0 if screen was updated, -ENODEV is there is no screen.
  28. */
  29. int sandbox_sdl_sync(void *lcd_base);
  30. /**
  31. * sandbox_sdl_scan_keys() - scan for pressed keys
  32. *
  33. * Works out which keys are pressed and returns a list
  34. *
  35. * @key: Array to receive keycodes
  36. * @max_keys: Size of array
  37. * @return number of keycodes found, 0 if none, -ENODEV if no keyboard
  38. */
  39. int sandbox_sdl_scan_keys(int key[], int max_keys);
  40. /**
  41. * sandbox_sdl_key_pressed() - check if a particular key is pressed
  42. *
  43. * @keycode: Keycode to check (KEY_... - see include/linux/input.h
  44. * @return 0 if pressed, -ENOENT if not pressed. -ENODEV if keybord not
  45. * available,
  46. */
  47. int sandbox_sdl_key_pressed(int keycode);
  48. /**
  49. * sandbox_sdl_sound_start() - start playing a sound
  50. *
  51. * @frequency: Frequency of sounds in Hertz
  52. * @return 0 if OK, -ENODEV if no sound is available
  53. */
  54. int sandbox_sdl_sound_start(uint frequency);
  55. /**
  56. * sandbox_sdl_sound_stop() - stop playing a sound
  57. *
  58. * @return 0 if OK, -ENODEV if no sound is available
  59. */
  60. int sandbox_sdl_sound_stop(void);
  61. /**
  62. * sandbox_sdl_sound_init() - set up the sound system
  63. *
  64. * @return 0 if OK, -ENODEV if no sound is available
  65. */
  66. int sandbox_sdl_sound_init(void);
  67. #else
  68. static inline int sandbox_sdl_init_display(int width, int height,
  69. int log2_bpp)
  70. {
  71. return -ENODEV;
  72. }
  73. static inline int sandbox_sdl_sync(void *lcd_base)
  74. {
  75. return -ENODEV;
  76. }
  77. static inline int sandbox_sdl_scan_keys(int key[], int max_keys)
  78. {
  79. return -ENODEV;
  80. }
  81. static inline int sandbox_sdl_key_pressed(int keycode)
  82. {
  83. return -ENODEV;
  84. }
  85. static inline int sandbox_sdl_sound_start(uint frequency)
  86. {
  87. return -ENODEV;
  88. }
  89. static inline int sandbox_sdl_sound_stop(void)
  90. {
  91. return -ENODEV;
  92. }
  93. static inline int sandbox_sdl_sound_init(void)
  94. {
  95. return -ENODEV;
  96. }
  97. #endif
  98. #endif