atmel_hlcdc_dc.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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_atomic.h>
  27. #include <drm/drm_atomic_helper.h>
  28. #include <drm/drm_crtc.h>
  29. #include <drm/drm_crtc_helper.h>
  30. #include <drm/drm_fb_cma_helper.h>
  31. #include <drm/drm_gem_cma_helper.h>
  32. #include <drm/drm_panel.h>
  33. #include <drm/drm_plane_helper.h>
  34. #include <drm/drmP.h>
  35. #include "atmel_hlcdc_layer.h"
  36. #define ATMEL_HLCDC_MAX_LAYERS 5
  37. /**
  38. * Atmel HLCDC Display Controller description structure.
  39. *
  40. * This structure describe the HLCDC IP capabilities and depends on the
  41. * HLCDC IP version (or Atmel SoC family).
  42. *
  43. * @min_width: minimum width supported by the Display Controller
  44. * @min_height: minimum height supported by the Display Controller
  45. * @max_width: maximum width supported by the Display Controller
  46. * @max_height: maximum height supported by the Display Controller
  47. * @max_spw: maximum vertical/horizontal pulse width
  48. * @max_vpw: maximum vertical back/front porch width
  49. * @max_hpw: maximum horizontal back/front porch width
  50. * @conflicting_output_formats: true if RGBXXX output formats conflict with
  51. * each other.
  52. * @layers: a layer description table describing available layers
  53. * @nlayers: layer description table size
  54. */
  55. struct atmel_hlcdc_dc_desc {
  56. int min_width;
  57. int min_height;
  58. int max_width;
  59. int max_height;
  60. int max_spw;
  61. int max_vpw;
  62. int max_hpw;
  63. bool conflicting_output_formats;
  64. const struct atmel_hlcdc_layer_desc *layers;
  65. int nlayers;
  66. };
  67. /**
  68. * Atmel HLCDC Plane properties.
  69. *
  70. * This structure stores plane property definitions.
  71. *
  72. * @alpha: alpha blending (or transparency) property
  73. * @rotation: rotation property
  74. */
  75. struct atmel_hlcdc_plane_properties {
  76. struct drm_property *alpha;
  77. };
  78. /**
  79. * Atmel HLCDC Plane.
  80. *
  81. * @base: base DRM plane structure
  82. * @layer: HLCDC layer structure
  83. * @properties: pointer to the property definitions structure
  84. * @rotation: current rotation status
  85. */
  86. struct atmel_hlcdc_plane {
  87. struct drm_plane base;
  88. struct atmel_hlcdc_layer layer;
  89. struct atmel_hlcdc_plane_properties *properties;
  90. };
  91. static inline struct atmel_hlcdc_plane *
  92. drm_plane_to_atmel_hlcdc_plane(struct drm_plane *p)
  93. {
  94. return container_of(p, struct atmel_hlcdc_plane, base);
  95. }
  96. static inline struct atmel_hlcdc_plane *
  97. atmel_hlcdc_layer_to_plane(struct atmel_hlcdc_layer *l)
  98. {
  99. return container_of(l, struct atmel_hlcdc_plane, layer);
  100. }
  101. /**
  102. * Atmel HLCDC Planes.
  103. *
  104. * This structure stores the instantiated HLCDC Planes and can be accessed by
  105. * the HLCDC Display Controller or the HLCDC CRTC.
  106. *
  107. * @primary: primary plane
  108. * @cursor: hardware cursor plane
  109. * @overlays: overlay plane table
  110. * @noverlays: number of overlay planes
  111. */
  112. struct atmel_hlcdc_planes {
  113. struct atmel_hlcdc_plane *primary;
  114. struct atmel_hlcdc_plane *cursor;
  115. struct atmel_hlcdc_plane **overlays;
  116. int noverlays;
  117. };
  118. /**
  119. * Atmel HLCDC Display Controller.
  120. *
  121. * @desc: HLCDC Display Controller description
  122. * @hlcdc: pointer to the atmel_hlcdc structure provided by the MFD device
  123. * @fbdev: framebuffer device attached to the Display Controller
  124. * @crtc: CRTC provided by the display controller
  125. * @planes: instantiated planes
  126. * @layers: active HLCDC layer
  127. * @wq: display controller workqueue
  128. * @commit: used for async commit handling
  129. */
  130. struct atmel_hlcdc_dc {
  131. const struct atmel_hlcdc_dc_desc *desc;
  132. struct atmel_hlcdc *hlcdc;
  133. struct drm_fbdev_cma *fbdev;
  134. struct drm_crtc *crtc;
  135. struct atmel_hlcdc_planes *planes;
  136. struct atmel_hlcdc_layer *layers[ATMEL_HLCDC_MAX_LAYERS];
  137. struct workqueue_struct *wq;
  138. struct {
  139. wait_queue_head_t wait;
  140. bool pending;
  141. } commit;
  142. };
  143. extern struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_formats;
  144. extern struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_and_yuv_formats;
  145. int atmel_hlcdc_dc_mode_valid(struct atmel_hlcdc_dc *dc,
  146. struct drm_display_mode *mode);
  147. struct atmel_hlcdc_planes *
  148. atmel_hlcdc_create_planes(struct drm_device *dev);
  149. int atmel_hlcdc_plane_prepare_disc_area(struct drm_crtc_state *c_state);
  150. int atmel_hlcdc_plane_prepare_ahb_routing(struct drm_crtc_state *c_state);
  151. void atmel_hlcdc_crtc_irq(struct drm_crtc *c);
  152. void atmel_hlcdc_crtc_suspend(struct drm_crtc *crtc);
  153. void atmel_hlcdc_crtc_resume(struct drm_crtc *crtc);
  154. int atmel_hlcdc_crtc_create(struct drm_device *dev);
  155. int atmel_hlcdc_create_outputs(struct drm_device *dev);
  156. #endif /* DRM_ATMEL_HLCDC_H */