atmel_hlcdc_dc.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * Copyright (C) 2014 Traphandler
  3. * Copyright (C) 2014 Free Electrons
  4. * Copyright (C) 2014 Atmel
  5. *
  6. * Author: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
  7. * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef DRM_ATMEL_HLCDC_H
  22. #define DRM_ATMEL_HLCDC_H
  23. #include <linux/clk.h>
  24. #include <linux/irqdomain.h>
  25. #include <linux/pwm.h>
  26. #include <drm/drm_crtc.h>
  27. #include <drm/drm_crtc_helper.h>
  28. #include <drm/drm_fb_cma_helper.h>
  29. #include <drm/drm_gem_cma_helper.h>
  30. #include <drm/drm_panel.h>
  31. #include <drm/drmP.h>
  32. #include "atmel_hlcdc_layer.h"
  33. #define ATMEL_HLCDC_MAX_LAYERS 5
  34. /**
  35. * Atmel HLCDC Display Controller description structure.
  36. *
  37. * This structure describe the HLCDC IP capabilities and depends on the
  38. * HLCDC IP version (or Atmel SoC family).
  39. *
  40. * @min_width: minimum width supported by the Display Controller
  41. * @min_height: minimum height supported by the Display Controller
  42. * @max_width: maximum width supported by the Display Controller
  43. * @max_height: maximum height supported by the Display Controller
  44. * @layers: a layer description table describing available layers
  45. * @nlayers: layer description table size
  46. */
  47. struct atmel_hlcdc_dc_desc {
  48. int min_width;
  49. int min_height;
  50. int max_width;
  51. int max_height;
  52. const struct atmel_hlcdc_layer_desc *layers;
  53. int nlayers;
  54. };
  55. /**
  56. * Atmel HLCDC Plane properties.
  57. *
  58. * This structure stores plane property definitions.
  59. *
  60. * @alpha: alpha blending (or transparency) property
  61. * @rotation: rotation property
  62. */
  63. struct atmel_hlcdc_plane_properties {
  64. struct drm_property *alpha;
  65. struct drm_property *rotation;
  66. };
  67. /**
  68. * Atmel HLCDC Plane.
  69. *
  70. * @base: base DRM plane structure
  71. * @layer: HLCDC layer structure
  72. * @properties: pointer to the property definitions structure
  73. * @rotation: current rotation status
  74. */
  75. struct atmel_hlcdc_plane {
  76. struct drm_plane base;
  77. struct atmel_hlcdc_layer layer;
  78. struct atmel_hlcdc_plane_properties *properties;
  79. unsigned int rotation;
  80. };
  81. static inline struct atmel_hlcdc_plane *
  82. drm_plane_to_atmel_hlcdc_plane(struct drm_plane *p)
  83. {
  84. return container_of(p, struct atmel_hlcdc_plane, base);
  85. }
  86. static inline struct atmel_hlcdc_plane *
  87. atmel_hlcdc_layer_to_plane(struct atmel_hlcdc_layer *l)
  88. {
  89. return container_of(l, struct atmel_hlcdc_plane, layer);
  90. }
  91. /**
  92. * Atmel HLCDC Plane update request structure.
  93. *
  94. * @crtc_x: x position of the plane relative to the CRTC
  95. * @crtc_y: y position of the plane relative to the CRTC
  96. * @crtc_w: visible width of the plane
  97. * @crtc_h: visible height of the plane
  98. * @src_x: x buffer position
  99. * @src_y: y buffer position
  100. * @src_w: buffer width
  101. * @src_h: buffer height
  102. * @fb: framebuffer object object
  103. * @bpp: bytes per pixel deduced from pixel_format
  104. * @offsets: offsets to apply to the GEM buffers
  105. * @xstride: value to add to the pixel pointer between each line
  106. * @pstride: value to add to the pixel pointer between each pixel
  107. * @nplanes: number of planes (deduced from pixel_format)
  108. */
  109. struct atmel_hlcdc_plane_update_req {
  110. int crtc_x;
  111. int crtc_y;
  112. unsigned int crtc_w;
  113. unsigned int crtc_h;
  114. uint32_t src_x;
  115. uint32_t src_y;
  116. uint32_t src_w;
  117. uint32_t src_h;
  118. struct drm_framebuffer *fb;
  119. /* These fields are private and should not be touched */
  120. int bpp[ATMEL_HLCDC_MAX_PLANES];
  121. unsigned int offsets[ATMEL_HLCDC_MAX_PLANES];
  122. int xstride[ATMEL_HLCDC_MAX_PLANES];
  123. int pstride[ATMEL_HLCDC_MAX_PLANES];
  124. int nplanes;
  125. };
  126. /**
  127. * Atmel HLCDC Planes.
  128. *
  129. * This structure stores the instantiated HLCDC Planes and can be accessed by
  130. * the HLCDC Display Controller or the HLCDC CRTC.
  131. *
  132. * @primary: primary plane
  133. * @cursor: hardware cursor plane
  134. * @overlays: overlay plane table
  135. * @noverlays: number of overlay planes
  136. */
  137. struct atmel_hlcdc_planes {
  138. struct atmel_hlcdc_plane *primary;
  139. struct atmel_hlcdc_plane *cursor;
  140. struct atmel_hlcdc_plane **overlays;
  141. int noverlays;
  142. };
  143. /**
  144. * Atmel HLCDC Display Controller.
  145. *
  146. * @desc: HLCDC Display Controller description
  147. * @hlcdc: pointer to the atmel_hlcdc structure provided by the MFD device
  148. * @fbdev: framebuffer device attached to the Display Controller
  149. * @crtc: CRTC provided by the display controller
  150. * @planes: instantiated planes
  151. * @layers: active HLCDC layer
  152. * @wq: display controller workqueue
  153. */
  154. struct atmel_hlcdc_dc {
  155. const struct atmel_hlcdc_dc_desc *desc;
  156. struct atmel_hlcdc *hlcdc;
  157. struct drm_fbdev_cma *fbdev;
  158. struct drm_crtc *crtc;
  159. struct atmel_hlcdc_planes *planes;
  160. struct atmel_hlcdc_layer *layers[ATMEL_HLCDC_MAX_LAYERS];
  161. struct workqueue_struct *wq;
  162. };
  163. extern struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_formats;
  164. extern struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_and_yuv_formats;
  165. int atmel_hlcdc_dc_mode_valid(struct atmel_hlcdc_dc *dc,
  166. struct drm_display_mode *mode);
  167. struct atmel_hlcdc_planes *
  168. atmel_hlcdc_create_planes(struct drm_device *dev);
  169. int atmel_hlcdc_plane_prepare_update_req(struct drm_plane *p,
  170. struct atmel_hlcdc_plane_update_req *req,
  171. const struct drm_display_mode *mode);
  172. int atmel_hlcdc_plane_apply_update_req(struct drm_plane *p,
  173. struct atmel_hlcdc_plane_update_req *req);
  174. int atmel_hlcdc_plane_update_with_mode(struct drm_plane *p,
  175. struct drm_crtc *crtc,
  176. struct drm_framebuffer *fb,
  177. int crtc_x, int crtc_y,
  178. unsigned int crtc_w,
  179. unsigned int crtc_h,
  180. uint32_t src_x, uint32_t src_y,
  181. uint32_t src_w, uint32_t src_h,
  182. const struct drm_display_mode *mode);
  183. void atmel_hlcdc_crtc_irq(struct drm_crtc *c);
  184. void atmel_hlcdc_crtc_cancel_page_flip(struct drm_crtc *crtc,
  185. struct drm_file *file);
  186. int atmel_hlcdc_crtc_create(struct drm_device *dev);
  187. int atmel_hlcdc_create_outputs(struct drm_device *dev);
  188. #endif /* DRM_ATMEL_HLCDC_H */