atom.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. #ifndef __NV50_KMS_ATOM_H__
  2. #define __NV50_KMS_ATOM_H__
  3. #define nv50_atom(p) container_of((p), struct nv50_atom, state)
  4. #include <drm/drm_atomic.h>
  5. #include "crc.h"
  6. struct nouveau_encoder;
  7. struct nv50_atom {
  8. struct drm_atomic_state state;
  9. struct list_head outp;
  10. bool lock_core;
  11. bool flush_disable;
  12. };
  13. #define nv50_head_atom(p) container_of((p), struct nv50_head_atom, state)
  14. struct nv50_head_atom {
  15. struct drm_crtc_state state;
  16. struct {
  17. u32 mask;
  18. u32 owned;
  19. u32 olut;
  20. } wndw;
  21. struct {
  22. u16 iW;
  23. u16 iH;
  24. u16 oW;
  25. u16 oH;
  26. } view;
  27. struct nv50_head_mode {
  28. bool interlace;
  29. u32 clock;
  30. struct {
  31. u16 active;
  32. u16 synce;
  33. u16 blanke;
  34. u16 blanks;
  35. } h;
  36. struct {
  37. u32 active;
  38. u16 synce;
  39. u16 blanke;
  40. u16 blanks;
  41. u16 blank2s;
  42. u16 blank2e;
  43. u16 blankus;
  44. } v;
  45. } mode;
  46. struct {
  47. bool visible;
  48. u32 handle;
  49. u64 offset:40;
  50. u8 buffer:1;
  51. u8 mode:4;
  52. u16 size:11;
  53. u8 range:2;
  54. u8 output_mode:2;
  55. void (*load)(struct drm_color_lut *, int size, void __iomem *);
  56. } olut;
  57. struct {
  58. bool visible;
  59. u32 handle;
  60. u64 offset:40;
  61. u8 format;
  62. u8 kind:7;
  63. u8 layout:1;
  64. u8 blockh:4;
  65. u16 blocks:12;
  66. u32 pitch:20;
  67. u16 x;
  68. u16 y;
  69. u16 w;
  70. u16 h;
  71. } core;
  72. struct {
  73. bool visible;
  74. u32 handle;
  75. u64 offset:40;
  76. u8 layout:2;
  77. u8 format:8;
  78. } curs;
  79. struct {
  80. u8 depth;
  81. u8 cpp;
  82. u16 x;
  83. u16 y;
  84. u16 w;
  85. u16 h;
  86. } base;
  87. struct {
  88. u8 cpp;
  89. } ovly;
  90. struct {
  91. bool enable:1;
  92. u8 bits:2;
  93. u8 mode:4;
  94. } dither;
  95. struct {
  96. struct {
  97. u16 cos:12;
  98. u16 sin:12;
  99. } sat;
  100. } procamp;
  101. struct {
  102. u8 nhsync:1;
  103. u8 nvsync:1;
  104. u8 depth:4;
  105. u8 crc_raster:2;
  106. u8 bpc;
  107. } or;
  108. struct nv50_crc_atom crc;
  109. /* Currently only used for MST */
  110. struct {
  111. int pbn;
  112. u8 tu:6;
  113. } dp;
  114. union nv50_head_atom_mask {
  115. struct {
  116. bool olut:1;
  117. bool core:1;
  118. bool curs:1;
  119. bool view:1;
  120. bool mode:1;
  121. bool base:1;
  122. bool ovly:1;
  123. bool dither:1;
  124. bool procamp:1;
  125. bool crc:1;
  126. bool or:1;
  127. };
  128. u16 mask;
  129. } set, clr;
  130. };
  131. static inline struct nv50_head_atom *
  132. nv50_head_atom_get(struct drm_atomic_state *state, struct drm_crtc *crtc)
  133. {
  134. struct drm_crtc_state *statec = drm_atomic_get_crtc_state(state, crtc);
  135. if (IS_ERR(statec))
  136. return (void *)statec;
  137. return nv50_head_atom(statec);
  138. }
  139. static inline struct drm_encoder *
  140. nv50_head_atom_get_encoder(struct nv50_head_atom *atom)
  141. {
  142. struct drm_encoder *encoder;
  143. /* We only ever have a single encoder */
  144. drm_for_each_encoder_mask(encoder, atom->state.crtc->dev,
  145. atom->state.encoder_mask)
  146. return encoder;
  147. return NULL;
  148. }
  149. #define nv50_wndw_atom(p) container_of((p), struct nv50_wndw_atom, state)
  150. struct nv50_wndw_atom {
  151. struct drm_plane_state state;
  152. struct drm_property_blob *ilut;
  153. bool visible;
  154. struct {
  155. u32 handle;
  156. u16 offset:12;
  157. bool awaken:1;
  158. } ntfy;
  159. struct {
  160. u32 handle;
  161. u16 offset:12;
  162. u32 acquire;
  163. u32 release;
  164. } sema;
  165. struct {
  166. u32 handle;
  167. struct {
  168. u64 offset:40;
  169. u8 buffer:1;
  170. u8 enable:2;
  171. u8 mode:4;
  172. u16 size:11;
  173. u8 range:2;
  174. u8 output_mode:2;
  175. void (*load)(struct drm_color_lut *, int size,
  176. void __iomem *);
  177. } i;
  178. } xlut;
  179. struct {
  180. u32 matrix[12];
  181. bool valid;
  182. } csc;
  183. struct {
  184. u8 mode:2;
  185. u8 interval:4;
  186. u8 colorspace:2;
  187. u8 format;
  188. u8 kind:7;
  189. u8 layout:1;
  190. u8 blockh:4;
  191. u16 blocks[3];
  192. u32 pitch[3];
  193. u16 w;
  194. u16 h;
  195. u32 handle[6];
  196. u64 offset[6];
  197. } image;
  198. struct {
  199. u16 sx;
  200. u16 sy;
  201. u16 sw;
  202. u16 sh;
  203. u16 dw;
  204. u16 dh;
  205. } scale;
  206. struct {
  207. u16 x;
  208. u16 y;
  209. } point;
  210. struct {
  211. u8 depth;
  212. u8 k1;
  213. u8 src_color:4;
  214. u8 dst_color:4;
  215. } blend;
  216. union nv50_wndw_atom_mask {
  217. struct {
  218. bool ntfy:1;
  219. bool sema:1;
  220. bool xlut:1;
  221. bool csc:1;
  222. bool image:1;
  223. bool scale:1;
  224. bool point:1;
  225. bool blend:1;
  226. };
  227. u8 mask;
  228. } set, clr;
  229. };
  230. #endif