FB.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Platform.h>
  8. #include <stddef.h>
  9. #include <sys/cdefs.h>
  10. #include <sys/ioctl.h>
  11. __BEGIN_DECLS
  12. ALWAYS_INLINE int fb_get_properties(int fd, FBProperties* info)
  13. {
  14. return ioctl(fd, FB_IOCTL_GET_PROPERTIES, info);
  15. }
  16. ALWAYS_INLINE int fb_get_head_properties(int fd, FBHeadProperties* info)
  17. {
  18. return ioctl(fd, FB_IOCTL_GET_HEAD_PROPERTIES, info);
  19. }
  20. ALWAYS_INLINE int fb_get_resolution(int fd, FBHeadResolution* info)
  21. {
  22. FBHeadProperties head_properties;
  23. head_properties.head_index = info->head_index;
  24. if (auto rc = ioctl(fd, FB_IOCTL_GET_HEAD_PROPERTIES, &head_properties); rc < 0)
  25. return rc;
  26. info->head_index = head_properties.head_index;
  27. info->pitch = head_properties.pitch;
  28. info->width = head_properties.width;
  29. info->height = head_properties.height;
  30. return 0;
  31. }
  32. ALWAYS_INLINE int fb_set_resolution(int fd, FBHeadResolution* info)
  33. {
  34. return ioctl(fd, FB_IOCTL_SET_HEAD_RESOLUTION, info);
  35. }
  36. ALWAYS_INLINE int fb_get_head_vertical_offset_buffer(int fd, FBHeadVerticalOffset* vertical_offset)
  37. {
  38. return ioctl(fd, FB_IOCTL_GET_HEAD_VERTICAL_OFFSET_BUFFER, vertical_offset);
  39. }
  40. ALWAYS_INLINE int fb_set_head_vertical_offset_buffer(int fd, FBHeadVerticalOffset* vertical_offset)
  41. {
  42. return ioctl(fd, FB_IOCTL_SET_HEAD_VERTICAL_OFFSET_BUFFER, vertical_offset);
  43. }
  44. ALWAYS_INLINE int fb_flush_buffers(int fd, int index, FBRect const* rects, unsigned count)
  45. {
  46. FBFlushRects fb_flush_rects;
  47. fb_flush_rects.buffer_index = index;
  48. fb_flush_rects.count = count;
  49. fb_flush_rects.rects = rects;
  50. return ioctl(fd, FB_IOCTL_FLUSH_HEAD_BUFFERS, &fb_flush_rects);
  51. }
  52. __END_DECLS