drm_format_helper.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2016 Noralf Trønnes
  4. */
  5. #ifndef __LINUX_DRM_FORMAT_HELPER_H
  6. #define __LINUX_DRM_FORMAT_HELPER_H
  7. #include <linux/types.h>
  8. struct drm_device;
  9. struct drm_format_info;
  10. struct drm_framebuffer;
  11. struct drm_rect;
  12. struct iosys_map;
  13. /**
  14. * struct drm_format_conv_state - Stores format-conversion state
  15. *
  16. * DRM helpers for format conversion store temporary state in
  17. * struct drm_xfrm_buf. The buffer's resources can be reused
  18. * among multiple conversion operations.
  19. *
  20. * All fields are considered private.
  21. */
  22. struct drm_format_conv_state {
  23. /* private: */
  24. struct {
  25. void *mem;
  26. size_t size;
  27. bool preallocated;
  28. } tmp;
  29. };
  30. #define __DRM_FORMAT_CONV_STATE_INIT(_mem, _size, _preallocated) { \
  31. .tmp = { \
  32. .mem = (_mem), \
  33. .size = (_size), \
  34. .preallocated = (_preallocated), \
  35. } \
  36. }
  37. /**
  38. * DRM_FORMAT_CONV_STATE_INIT - Initializer for struct drm_format_conv_state
  39. *
  40. * Initializes an instance of struct drm_format_conv_state to default values.
  41. */
  42. #define DRM_FORMAT_CONV_STATE_INIT \
  43. __DRM_FORMAT_CONV_STATE_INIT(NULL, 0, false)
  44. /**
  45. * DRM_FORMAT_CONV_STATE_INIT_PREALLOCATED - Initializer for struct drm_format_conv_state
  46. * @_mem: The preallocated memory area
  47. * @_size: The number of bytes in _mem
  48. *
  49. * Initializes an instance of struct drm_format_conv_state to preallocated
  50. * storage. The caller is responsible for releasing the provided memory range.
  51. */
  52. #define DRM_FORMAT_CONV_STATE_INIT_PREALLOCATED(_mem, _size) \
  53. __DRM_FORMAT_CONV_STATE_INIT(_mem, _size, true)
  54. void drm_format_conv_state_init(struct drm_format_conv_state *state);
  55. void drm_format_conv_state_copy(struct drm_format_conv_state *state,
  56. const struct drm_format_conv_state *old_state);
  57. void *drm_format_conv_state_reserve(struct drm_format_conv_state *state,
  58. size_t new_size, gfp_t flags);
  59. void drm_format_conv_state_release(struct drm_format_conv_state *state);
  60. unsigned int drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format,
  61. const struct drm_rect *clip);
  62. void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch,
  63. const struct iosys_map *src, const struct drm_framebuffer *fb,
  64. const struct drm_rect *clip);
  65. void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
  66. const struct iosys_map *src, const struct drm_framebuffer *fb,
  67. const struct drm_rect *clip, bool cached,
  68. struct drm_format_conv_state *state);
  69. void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch,
  70. const struct iosys_map *src, const struct drm_framebuffer *fb,
  71. const struct drm_rect *clip, struct drm_format_conv_state *state);
  72. void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch,
  73. const struct iosys_map *src, const struct drm_framebuffer *fb,
  74. const struct drm_rect *clip, struct drm_format_conv_state *state);
  75. void drm_fb_xrgb8888_to_rgb565be(struct iosys_map *dst, const unsigned int *dst_pitch,
  76. const struct iosys_map *src, const struct drm_framebuffer *fb,
  77. const struct drm_rect *clip, struct drm_format_conv_state *state);
  78. void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
  79. const struct iosys_map *src, const struct drm_framebuffer *fb,
  80. const struct drm_rect *clip, struct drm_format_conv_state *state);
  81. void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
  82. const struct iosys_map *src, const struct drm_framebuffer *fb,
  83. const struct drm_rect *clip, struct drm_format_conv_state *state);
  84. void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_pitch,
  85. const struct iosys_map *src, const struct drm_framebuffer *fb,
  86. const struct drm_rect *clip, struct drm_format_conv_state *state);
  87. void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
  88. const struct iosys_map *src, const struct drm_framebuffer *fb,
  89. const struct drm_rect *clip, struct drm_format_conv_state *state);
  90. void drm_fb_xrgb8888_to_bgr888(struct iosys_map *dst, const unsigned int *dst_pitch,
  91. const struct iosys_map *src, const struct drm_framebuffer *fb,
  92. const struct drm_rect *clip, struct drm_format_conv_state *state);
  93. void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch,
  94. const struct iosys_map *src, const struct drm_framebuffer *fb,
  95. const struct drm_rect *clip, struct drm_format_conv_state *state);
  96. void drm_fb_xrgb8888_to_abgr8888(struct iosys_map *dst, const unsigned int *dst_pitch,
  97. const struct iosys_map *src, const struct drm_framebuffer *fb,
  98. const struct drm_rect *clip, struct drm_format_conv_state *state);
  99. void drm_fb_xrgb8888_to_xbgr8888(struct iosys_map *dst, const unsigned int *dst_pitch,
  100. const struct iosys_map *src, const struct drm_framebuffer *fb,
  101. const struct drm_rect *clip, struct drm_format_conv_state *state);
  102. void drm_fb_xrgb8888_to_bgrx8888(struct iosys_map *dst, const unsigned int *dst_pitch,
  103. const struct iosys_map *src, const struct drm_framebuffer *fb,
  104. const struct drm_rect *clip, struct drm_format_conv_state *state);
  105. void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
  106. const struct iosys_map *src, const struct drm_framebuffer *fb,
  107. const struct drm_rect *clip,
  108. struct drm_format_conv_state *state);
  109. void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
  110. const struct iosys_map *src, const struct drm_framebuffer *fb,
  111. const struct drm_rect *clip,
  112. struct drm_format_conv_state *state);
  113. void drm_fb_xrgb8888_to_gray8(struct iosys_map *dst, const unsigned int *dst_pitch,
  114. const struct iosys_map *src, const struct drm_framebuffer *fb,
  115. const struct drm_rect *clip, struct drm_format_conv_state *state);
  116. void drm_fb_argb8888_to_argb4444(struct iosys_map *dst, const unsigned int *dst_pitch,
  117. const struct iosys_map *src, const struct drm_framebuffer *fb,
  118. const struct drm_rect *clip, struct drm_format_conv_state *state);
  119. void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitch,
  120. const struct iosys_map *src, const struct drm_framebuffer *fb,
  121. const struct drm_rect *clip, struct drm_format_conv_state *state);
  122. void drm_fb_xrgb8888_to_gray2(struct iosys_map *dst, const unsigned int *dst_pitch,
  123. const struct iosys_map *src, const struct drm_framebuffer *fb,
  124. const struct drm_rect *clip, struct drm_format_conv_state *state);
  125. #endif /* __LINUX_DRM_FORMAT_HELPER_H */