atmel_hlcdc_dc.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. * @layers: a layer description table describing available layers
  48. * @nlayers: layer description table size
  49. */
  50. struct atmel_hlcdc_dc_desc {
  51. int min_width;
  52. int min_height;
  53. int max_width;
  54. int max_height;
  55. const struct atmel_hlcdc_layer_desc *layers;
  56. int nlayers;
  57. };
  58. /**
  59. * Atmel HLCDC Plane properties.
  60. *
  61. * This structure stores plane property definitions.
  62. *
  63. * @alpha: alpha blending (or transparency) property
  64. * @rotation: rotation property
  65. */
  66. struct atmel_hlcdc_plane_properties {
  67. struct drm_property *alpha;
  68. };
  69. /**
  70. * Atmel HLCDC Plane.
  71. *
  72. * @base: base DRM plane structure
  73. * @layer: HLCDC layer structure
  74. * @properties: pointer to the property definitions structure
  75. * @rotation: current rotation status
  76. */
  77. struct atmel_hlcdc_plane {
  78. struct drm_plane base;
  79. struct atmel_hlcdc_layer layer;
  80. struct atmel_hlcdc_plane_properties *properties;
  81. };
  82. static inline struct atmel_hlcdc_plane *
  83. drm_plane_to_atmel_hlcdc_plane(struct drm_plane *p)
  84. {
  85. return container_of(p, struct atmel_hlcdc_plane, base);
  86. }
  87. static inline struct atmel_hlcdc_plane *
  88. atmel_hlcdc_layer_to_plane(struct atmel_hlcdc_layer *l)
  89. {
  90. return container_of(l, struct atmel_hlcdc_plane, layer);
  91. }
  92. /**
  93. * Atmel HLCDC Planes.
  94. *
  95. * This structure stores the instantiated HLCDC Planes and can be accessed by
  96. * the HLCDC Display Controller or the HLCDC CRTC.
  97. *
  98. * @primary: primary plane
  99. * @cursor: hardware cursor plane
  100. * @overlays: overlay plane table
  101. * @noverlays: number of overlay planes
  102. */
  103. struct atmel_hlcdc_planes {
  104. struct atmel_hlcdc_plane *primary;
  105. struct atmel_hlcdc_plane *cursor;
  106. struct atmel_hlcdc_plane **overlays;
  107. int noverlays;
  108. };
  109. /**
  110. * Atmel HLCDC Display Controller.
  111. *
  112. * @desc: HLCDC Display Controller description
  113. * @hlcdc: pointer to the atmel_hlcdc structure provided by the MFD device
  114. * @fbdev: framebuffer device attached to the Display Controller
  115. * @crtc: CRTC provided by the display controller
  116. * @planes: instantiated planes
  117. * @layers: active HLCDC layer
  118. * @wq: display controller workqueue
  119. */
  120. struct atmel_hlcdc_dc {
  121. const struct atmel_hlcdc_dc_desc *desc;
  122. struct atmel_hlcdc *hlcdc;
  123. struct drm_fbdev_cma *fbdev;
  124. struct drm_crtc *crtc;
  125. struct atmel_hlcdc_planes *planes;
  126. struct atmel_hlcdc_layer *layers[ATMEL_HLCDC_MAX_LAYERS];
  127. struct workqueue_struct *wq;
  128. };
  129. extern struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_formats;
  130. extern struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_and_yuv_formats;
  131. int atmel_hlcdc_dc_mode_valid(struct atmel_hlcdc_dc *dc,
  132. struct drm_display_mode *mode);
  133. struct atmel_hlcdc_planes *
  134. atmel_hlcdc_create_planes(struct drm_device *dev);
  135. int atmel_hlcdc_plane_prepare_disc_area(struct drm_crtc_state *c_state);
  136. void atmel_hlcdc_crtc_irq(struct drm_crtc *c);
  137. void atmel_hlcdc_crtc_cancel_page_flip(struct drm_crtc *crtc,
  138. struct drm_file *file);
  139. void atmel_hlcdc_crtc_suspend(struct drm_crtc *crtc);
  140. void atmel_hlcdc_crtc_resume(struct drm_crtc *crtc);
  141. int atmel_hlcdc_crtc_create(struct drm_device *dev);
  142. int atmel_hlcdc_create_outputs(struct drm_device *dev);
  143. #endif /* DRM_ATMEL_HLCDC_H */