head827d.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. #include <nvif/push507c.h>
  25. #include <nvhw/class/cl827d.h>
  26. static int
  27. head827d_curs_clr(struct nv50_head *head)
  28. {
  29. struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
  30. const int i = head->base.index;
  31. int ret;
  32. if ((ret = PUSH_WAIT(push, 4)))
  33. return ret;
  34. PUSH_MTHD(push, NV827D, HEAD_SET_CONTROL_CURSOR(i),
  35. NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, ENABLE, DISABLE) |
  36. NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, FORMAT, A8R8G8B8) |
  37. NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, SIZE, W64_H64));
  38. PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_CURSOR(i), 0x00000000);
  39. return 0;
  40. }
  41. static int
  42. head827d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
  43. {
  44. struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
  45. const int i = head->base.index;
  46. int ret;
  47. if ((ret = PUSH_WAIT(push, 5)))
  48. return ret;
  49. PUSH_MTHD(push, NV827D, HEAD_SET_CONTROL_CURSOR(i),
  50. NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) |
  51. NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) |
  52. NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) |
  53. NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) |
  54. NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) |
  55. NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, ALPHA_BLEND) |
  56. NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, SUB_OWNER, NONE),
  57. HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 8);
  58. PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_CURSOR(i), asyh->curs.handle);
  59. return 0;
  60. }
  61. static int
  62. head827d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
  63. {
  64. struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
  65. const int i = head->base.index;
  66. int ret;
  67. if ((ret = PUSH_WAIT(push, 9)))
  68. return ret;
  69. PUSH_MTHD(push, NV827D, HEAD_SET_OFFSET(i, 0),
  70. NVVAL(NV827D, HEAD_SET_OFFSET, ORIGIN, asyh->core.offset >> 8));
  71. PUSH_MTHD(push, NV827D, HEAD_SET_SIZE(i),
  72. NVVAL(NV827D, HEAD_SET_SIZE, WIDTH, asyh->core.w) |
  73. NVVAL(NV827D, HEAD_SET_SIZE, HEIGHT, asyh->core.h),
  74. HEAD_SET_STORAGE(i),
  75. NVVAL(NV827D, HEAD_SET_STORAGE, BLOCK_HEIGHT, asyh->core.blockh) |
  76. NVVAL(NV827D, HEAD_SET_STORAGE, PITCH, asyh->core.pitch >> 8) |
  77. NVVAL(NV827D, HEAD_SET_STORAGE, PITCH, asyh->core.blocks) |
  78. NVVAL(NV827D, HEAD_SET_STORAGE, MEMORY_LAYOUT, asyh->core.layout),
  79. HEAD_SET_PARAMS(i),
  80. NVVAL(NV827D, HEAD_SET_PARAMS, FORMAT, asyh->core.format) |
  81. NVDEF(NV827D, HEAD_SET_PARAMS, SUPER_SAMPLE, X1_AA) |
  82. NVDEF(NV827D, HEAD_SET_PARAMS, GAMMA, LINEAR),
  83. HEAD_SET_CONTEXT_DMAS_ISO(i, 0),
  84. NVVAL(NV827D, HEAD_SET_CONTEXT_DMAS_ISO, HANDLE, asyh->core.handle));
  85. PUSH_MTHD(push, NV827D, HEAD_SET_VIEWPORT_POINT_IN(i, 0),
  86. NVVAL(NV827D, HEAD_SET_VIEWPORT_POINT_IN, X, asyh->core.x) |
  87. NVVAL(NV827D, HEAD_SET_VIEWPORT_POINT_IN, Y, asyh->core.y));
  88. return 0;
  89. }
  90. static int
  91. head827d_olut_clr(struct nv50_head *head)
  92. {
  93. struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
  94. const int i = head->base.index;
  95. int ret;
  96. if ((ret = PUSH_WAIT(push, 4)))
  97. return ret;
  98. PUSH_MTHD(push, NV827D, HEAD_SET_BASE_LUT_LO(i),
  99. NVDEF(NV827D, HEAD_SET_BASE_LUT_LO, ENABLE, DISABLE));
  100. PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_LUT(i), 0x00000000);
  101. return 0;
  102. }
  103. static int
  104. head827d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
  105. {
  106. struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
  107. const int i = head->base.index;
  108. int ret;
  109. if ((ret = PUSH_WAIT(push, 5)))
  110. return ret;
  111. PUSH_MTHD(push, NV827D, HEAD_SET_BASE_LUT_LO(i),
  112. NVDEF(NV827D, HEAD_SET_BASE_LUT_LO, ENABLE, ENABLE) |
  113. NVVAL(NV827D, HEAD_SET_BASE_LUT_LO, MODE, asyh->olut.mode) |
  114. NVVAL(NV827D, HEAD_SET_BASE_LUT_LO, ORIGIN, 0),
  115. HEAD_SET_BASE_LUT_HI(i),
  116. NVVAL(NV827D, HEAD_SET_BASE_LUT_HI, ORIGIN, asyh->olut.offset >> 8));
  117. PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_LUT(i), asyh->olut.handle);
  118. return 0;
  119. }
  120. const struct nv50_head_func
  121. head827d = {
  122. .view = head507d_view,
  123. .mode = head507d_mode,
  124. .olut = head507d_olut,
  125. .olut_size = 256,
  126. .olut_set = head827d_olut_set,
  127. .olut_clr = head827d_olut_clr,
  128. .core_calc = head507d_core_calc,
  129. .core_set = head827d_core_set,
  130. .core_clr = head507d_core_clr,
  131. .curs_layout = head507d_curs_layout,
  132. .curs_format = head507d_curs_format,
  133. .curs_set = head827d_curs_set,
  134. .curs_clr = head827d_curs_clr,
  135. .base = head507d_base,
  136. .ovly = head507d_ovly,
  137. .dither = head507d_dither,
  138. .procamp = head507d_procamp,
  139. };