head907d.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * Copyright 2018 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #include "head.h"
  23. #include "core.h"
  24. void
  25. head907d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
  26. {
  27. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  28. u32 *push;
  29. if ((push = evo_wait(core, 3))) {
  30. evo_mthd(push, 0x0404 + (head->base.index * 0x300), 2);
  31. evo_data(push, 0x00000001 | asyh->or.depth << 6 |
  32. asyh->or.nvsync << 4 |
  33. asyh->or.nhsync << 3);
  34. evo_data(push, 0x31ec6000 | head->base.index << 25 |
  35. asyh->mode.interlace);
  36. evo_kick(push, core);
  37. }
  38. }
  39. void
  40. head907d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
  41. {
  42. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  43. u32 *push;
  44. if ((push = evo_wait(core, 2))) {
  45. evo_mthd(push, 0x0498 + (head->base.index * 0x300), 1);
  46. evo_data(push, asyh->procamp.sat.sin << 20 |
  47. asyh->procamp.sat.cos << 8);
  48. evo_kick(push, core);
  49. }
  50. }
  51. static void
  52. head907d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
  53. {
  54. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  55. u32 *push;
  56. if ((push = evo_wait(core, 2))) {
  57. evo_mthd(push, 0x0490 + (head->base.index * 0x0300), 1);
  58. evo_data(push, asyh->dither.mode << 3 |
  59. asyh->dither.bits << 1 |
  60. asyh->dither.enable);
  61. evo_kick(push, core);
  62. }
  63. }
  64. void
  65. head907d_ovly(struct nv50_head *head, struct nv50_head_atom *asyh)
  66. {
  67. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  68. u32 bounds = 0;
  69. u32 *push;
  70. if (asyh->ovly.cpp) {
  71. switch (asyh->ovly.cpp) {
  72. case 8: bounds |= 0x00000500; break;
  73. case 4: bounds |= 0x00000300; break;
  74. case 2: bounds |= 0x00000100; break;
  75. default:
  76. WARN_ON(1);
  77. break;
  78. }
  79. bounds |= 0x00000001;
  80. } else {
  81. bounds |= 0x00000100;
  82. }
  83. if ((push = evo_wait(core, 2))) {
  84. evo_mthd(push, 0x04d4 + head->base.index * 0x300, 1);
  85. evo_data(push, bounds);
  86. evo_kick(push, core);
  87. }
  88. }
  89. static void
  90. head907d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
  91. {
  92. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  93. u32 bounds = 0;
  94. u32 *push;
  95. if (asyh->base.cpp) {
  96. switch (asyh->base.cpp) {
  97. case 8: bounds |= 0x00000500; break;
  98. case 4: bounds |= 0x00000300; break;
  99. case 2: bounds |= 0x00000100; break;
  100. case 1: bounds |= 0x00000000; break;
  101. default:
  102. WARN_ON(1);
  103. break;
  104. }
  105. bounds |= 0x00000001;
  106. }
  107. if ((push = evo_wait(core, 2))) {
  108. evo_mthd(push, 0x04d0 + head->base.index * 0x300, 1);
  109. evo_data(push, bounds);
  110. evo_kick(push, core);
  111. }
  112. }
  113. void
  114. head907d_curs_clr(struct nv50_head *head)
  115. {
  116. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  117. u32 *push;
  118. if ((push = evo_wait(core, 4))) {
  119. evo_mthd(push, 0x0480 + head->base.index * 0x300, 1);
  120. evo_data(push, 0x05000000);
  121. evo_mthd(push, 0x048c + head->base.index * 0x300, 1);
  122. evo_data(push, 0x00000000);
  123. evo_kick(push, core);
  124. }
  125. }
  126. void
  127. head907d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
  128. {
  129. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  130. u32 *push;
  131. if ((push = evo_wait(core, 5))) {
  132. evo_mthd(push, 0x0480 + head->base.index * 0x300, 2);
  133. evo_data(push, 0x80000000 | asyh->curs.layout << 26 |
  134. asyh->curs.format << 24);
  135. evo_data(push, asyh->curs.offset >> 8);
  136. evo_mthd(push, 0x048c + head->base.index * 0x300, 1);
  137. evo_data(push, asyh->curs.handle);
  138. evo_kick(push, core);
  139. }
  140. }
  141. void
  142. head907d_core_clr(struct nv50_head *head)
  143. {
  144. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  145. u32 *push;
  146. if ((push = evo_wait(core, 2))) {
  147. evo_mthd(push, 0x0474 + head->base.index * 0x300, 1);
  148. evo_data(push, 0x00000000);
  149. evo_kick(push, core);
  150. }
  151. }
  152. void
  153. head907d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
  154. {
  155. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  156. u32 *push;
  157. if ((push = evo_wait(core, 9))) {
  158. evo_mthd(push, 0x0460 + head->base.index * 0x300, 1);
  159. evo_data(push, asyh->core.offset >> 8);
  160. evo_mthd(push, 0x0468 + head->base.index * 0x300, 4);
  161. evo_data(push, asyh->core.h << 16 | asyh->core.w);
  162. evo_data(push, asyh->core.layout << 24 |
  163. (asyh->core.pitch >> 8) << 8 |
  164. asyh->core.blocks << 8 |
  165. asyh->core.blockh);
  166. evo_data(push, asyh->core.format << 8);
  167. evo_data(push, asyh->core.handle);
  168. evo_mthd(push, 0x04b0 + head->base.index * 0x300, 1);
  169. evo_data(push, asyh->core.y << 16 | asyh->core.x);
  170. evo_kick(push, core);
  171. }
  172. }
  173. void
  174. head907d_olut_clr(struct nv50_head *head)
  175. {
  176. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  177. u32 *push;
  178. if ((push = evo_wait(core, 4))) {
  179. evo_mthd(push, 0x0448 + (head->base.index * 0x300), 1);
  180. evo_data(push, 0x00000000);
  181. evo_mthd(push, 0x045c + (head->base.index * 0x300), 1);
  182. evo_data(push, 0x00000000);
  183. evo_kick(push, core);
  184. }
  185. }
  186. void
  187. head907d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
  188. {
  189. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  190. u32 *push;
  191. if ((push = evo_wait(core, 5))) {
  192. evo_mthd(push, 0x0448 + (head->base.index * 0x300), 2);
  193. evo_data(push, 0x80000000 | asyh->olut.mode << 24);
  194. evo_data(push, asyh->olut.offset >> 8);
  195. evo_mthd(push, 0x045c + (head->base.index * 0x300), 1);
  196. evo_data(push, asyh->olut.handle);
  197. evo_kick(push, core);
  198. }
  199. }
  200. void
  201. head907d_olut(struct nv50_head *head, struct nv50_head_atom *asyh)
  202. {
  203. asyh->olut.mode = 7;
  204. }
  205. void
  206. head907d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
  207. {
  208. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  209. struct nv50_head_mode *m = &asyh->mode;
  210. u32 *push;
  211. if ((push = evo_wait(core, 14))) {
  212. evo_mthd(push, 0x0410 + (head->base.index * 0x300), 6);
  213. evo_data(push, 0x00000000);
  214. evo_data(push, m->v.active << 16 | m->h.active );
  215. evo_data(push, m->v.synce << 16 | m->h.synce );
  216. evo_data(push, m->v.blanke << 16 | m->h.blanke );
  217. evo_data(push, m->v.blanks << 16 | m->h.blanks );
  218. evo_data(push, m->v.blank2e << 16 | m->v.blank2s);
  219. evo_mthd(push, 0x042c + (head->base.index * 0x300), 2);
  220. evo_data(push, 0x00000000); /* ??? */
  221. evo_data(push, 0xffffff00);
  222. evo_mthd(push, 0x0450 + (head->base.index * 0x300), 3);
  223. evo_data(push, m->clock * 1000);
  224. evo_data(push, 0x00200000); /* ??? */
  225. evo_data(push, m->clock * 1000);
  226. evo_kick(push, core);
  227. }
  228. }
  229. void
  230. head907d_view(struct nv50_head *head, struct nv50_head_atom *asyh)
  231. {
  232. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  233. u32 *push;
  234. if ((push = evo_wait(core, 8))) {
  235. evo_mthd(push, 0x0494 + (head->base.index * 0x300), 1);
  236. evo_data(push, 0x00000000);
  237. evo_mthd(push, 0x04b8 + (head->base.index * 0x300), 1);
  238. evo_data(push, asyh->view.iH << 16 | asyh->view.iW);
  239. evo_mthd(push, 0x04c0 + (head->base.index * 0x300), 3);
  240. evo_data(push, asyh->view.oH << 16 | asyh->view.oW);
  241. evo_data(push, asyh->view.oH << 16 | asyh->view.oW);
  242. evo_data(push, asyh->view.oH << 16 | asyh->view.oW);
  243. evo_kick(push, core);
  244. }
  245. }
  246. const struct nv50_head_func
  247. head907d = {
  248. .view = head907d_view,
  249. .mode = head907d_mode,
  250. .olut = head907d_olut,
  251. .olut_set = head907d_olut_set,
  252. .olut_clr = head907d_olut_clr,
  253. .core_calc = head507d_core_calc,
  254. .core_set = head907d_core_set,
  255. .core_clr = head907d_core_clr,
  256. .curs_layout = head507d_curs_layout,
  257. .curs_format = head507d_curs_format,
  258. .curs_set = head907d_curs_set,
  259. .curs_clr = head907d_curs_clr,
  260. .base = head907d_base,
  261. .ovly = head907d_ovly,
  262. .dither = head907d_dither,
  263. .procamp = head907d_procamp,
  264. .or = head907d_or,
  265. };