headc37d.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 "atom.h"
  24. #include "core.h"
  25. static void
  26. headc37d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
  27. {
  28. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  29. u32 *push;
  30. if ((push = evo_wait(core, 2))) {
  31. /*XXX: This is a dirty hack until OR depth handling is
  32. * improved later for deep colour etc.
  33. */
  34. switch (asyh->or.depth) {
  35. case 6: asyh->or.depth = 5; break;
  36. case 5: asyh->or.depth = 4; break;
  37. case 2: asyh->or.depth = 1; break;
  38. case 0: asyh->or.depth = 4; break;
  39. default:
  40. WARN_ON(1);
  41. break;
  42. }
  43. evo_mthd(push, 0x2004 + (head->base.index * 0x400), 1);
  44. evo_data(push, 0x00000001 |
  45. asyh->or.depth << 4 |
  46. asyh->or.nvsync << 3 |
  47. asyh->or.nhsync << 2);
  48. evo_kick(push, core);
  49. }
  50. }
  51. static void
  52. headc37d_procamp(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, 0x2000 + (head->base.index * 0x400), 1);
  58. evo_data(push, 0x80000000 |
  59. asyh->procamp.sat.sin << 16 |
  60. asyh->procamp.sat.cos << 4);
  61. evo_kick(push, core);
  62. }
  63. }
  64. static void
  65. headc37d_dither(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 *push;
  69. if ((push = evo_wait(core, 2))) {
  70. evo_mthd(push, 0x2018 + (head->base.index * 0x0400), 1);
  71. evo_data(push, asyh->dither.mode << 8 |
  72. asyh->dither.bits << 4 |
  73. asyh->dither.enable);
  74. evo_kick(push, core);
  75. }
  76. }
  77. static void
  78. headc37d_curs_clr(struct nv50_head *head)
  79. {
  80. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  81. u32 *push;
  82. if ((push = evo_wait(core, 4))) {
  83. evo_mthd(push, 0x209c + head->base.index * 0x400, 1);
  84. evo_data(push, 0x000000cf);
  85. evo_mthd(push, 0x2088 + head->base.index * 0x400, 1);
  86. evo_data(push, 0x00000000);
  87. evo_kick(push, core);
  88. }
  89. }
  90. static void
  91. headc37d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
  92. {
  93. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  94. u32 *push;
  95. if ((push = evo_wait(core, 7))) {
  96. evo_mthd(push, 0x209c + head->base.index * 0x400, 2);
  97. evo_data(push, 0x80000000 |
  98. asyh->curs.layout << 8 |
  99. asyh->curs.format << 0);
  100. evo_data(push, 0x000072ff);
  101. evo_mthd(push, 0x2088 + head->base.index * 0x400, 1);
  102. evo_data(push, asyh->curs.handle);
  103. evo_mthd(push, 0x2090 + head->base.index * 0x400, 1);
  104. evo_data(push, asyh->curs.offset >> 8);
  105. evo_kick(push, core);
  106. }
  107. }
  108. static int
  109. headc37d_curs_format(struct nv50_head *head, struct nv50_wndw_atom *asyw,
  110. struct nv50_head_atom *asyh)
  111. {
  112. asyh->curs.format = asyw->image.format;
  113. return 0;
  114. }
  115. static void
  116. headc37d_olut_clr(struct nv50_head *head)
  117. {
  118. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  119. u32 *push;
  120. if ((push = evo_wait(core, 2))) {
  121. evo_mthd(push, 0x20ac + (head->base.index * 0x400), 1);
  122. evo_data(push, 0x00000000);
  123. evo_kick(push, core);
  124. }
  125. }
  126. static void
  127. headc37d_olut_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, 4))) {
  132. evo_mthd(push, 0x20a4 + (head->base.index * 0x400), 3);
  133. evo_data(push, asyh->olut.output_mode << 8 |
  134. asyh->olut.range << 4 |
  135. asyh->olut.size);
  136. evo_data(push, asyh->olut.offset >> 8);
  137. evo_data(push, asyh->olut.handle);
  138. evo_kick(push, core);
  139. }
  140. }
  141. static void
  142. headc37d_olut(struct nv50_head *head, struct nv50_head_atom *asyh)
  143. {
  144. asyh->olut.mode = 2;
  145. asyh->olut.size = 0;
  146. asyh->olut.range = 0;
  147. asyh->olut.output_mode = 1;
  148. }
  149. static void
  150. headc37d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
  151. {
  152. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  153. struct nv50_head_mode *m = &asyh->mode;
  154. u32 *push;
  155. if ((push = evo_wait(core, 12))) {
  156. evo_mthd(push, 0x2064 + (head->base.index * 0x400), 5);
  157. evo_data(push, (m->v.active << 16) | m->h.active );
  158. evo_data(push, (m->v.synce << 16) | m->h.synce );
  159. evo_data(push, (m->v.blanke << 16) | m->h.blanke );
  160. evo_data(push, (m->v.blanks << 16) | m->h.blanks );
  161. evo_data(push, (m->v.blank2e << 16) | m->v.blank2s);
  162. evo_mthd(push, 0x200c + (head->base.index * 0x400), 1);
  163. evo_data(push, m->clock * 1000);
  164. evo_mthd(push, 0x2028 + (head->base.index * 0x400), 1);
  165. evo_data(push, m->clock * 1000);
  166. /*XXX: HEAD_USAGE_BOUNDS, doesn't belong here. */
  167. evo_mthd(push, 0x2030 + (head->base.index * 0x400), 1);
  168. evo_data(push, 0x00000124);
  169. evo_kick(push, core);
  170. }
  171. }
  172. static void
  173. headc37d_view(struct nv50_head *head, struct nv50_head_atom *asyh)
  174. {
  175. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  176. u32 *push;
  177. if ((push = evo_wait(core, 4))) {
  178. evo_mthd(push, 0x204c + (head->base.index * 0x400), 1);
  179. evo_data(push, (asyh->view.iH << 16) | asyh->view.iW);
  180. evo_mthd(push, 0x2058 + (head->base.index * 0x400), 1);
  181. evo_data(push, (asyh->view.oH << 16) | asyh->view.oW);
  182. evo_kick(push, core);
  183. }
  184. }
  185. const struct nv50_head_func
  186. headc37d = {
  187. .view = headc37d_view,
  188. .mode = headc37d_mode,
  189. .olut = headc37d_olut,
  190. .olut_set = headc37d_olut_set,
  191. .olut_clr = headc37d_olut_clr,
  192. .curs_layout = head917d_curs_layout,
  193. .curs_format = headc37d_curs_format,
  194. .curs_set = headc37d_curs_set,
  195. .curs_clr = headc37d_curs_clr,
  196. .dither = headc37d_dither,
  197. .procamp = headc37d_procamp,
  198. .or = headc37d_or,
  199. };