sdl.h 2.6 KB

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