head917d.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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/push.h"
  25. #include <nvif/push507c.h>
  26. #include <nvhw/class/cl917d.h>
  27. static int
  28. head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
  29. {
  30. struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
  31. const int i = head->base.index;
  32. int ret;
  33. if ((ret = PUSH_WAIT(push, 2)))
  34. return ret;
  35. PUSH_MTHD(push, NV917D, HEAD_SET_DITHER_CONTROL(i),
  36. NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, ENABLE, asyh->dither.enable) |
  37. NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, BITS, asyh->dither.bits) |
  38. NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, MODE, asyh->dither.mode) |
  39. NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, PHASE, 0));
  40. return 0;
  41. }
  42. static int
  43. head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
  44. {
  45. struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
  46. const int i = head->base.index;
  47. u32 bounds = 0;
  48. int ret;
  49. if (asyh->base.cpp) {
  50. switch (asyh->base.cpp) {
  51. case 8: bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_64); break;
  52. case 4: bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_32); break;
  53. case 2: bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_16); break;
  54. case 1: bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_8); break;
  55. default:
  56. WARN_ON(1);
  57. break;
  58. }
  59. bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, USABLE, TRUE);
  60. bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, BASE_LUT, USAGE_1025);
  61. }
  62. if ((ret = PUSH_WAIT(push, 2)))
  63. return ret;
  64. PUSH_MTHD(push, NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS(i), bounds);
  65. return 0;
  66. }
  67. static int
  68. head917d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
  69. {
  70. struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
  71. const int i = head->base.index;
  72. int ret;
  73. ret = PUSH_WAIT(push, 5);
  74. if (ret)
  75. return ret;
  76. PUSH_MTHD(push, NV917D, HEAD_SET_CONTROL_CURSOR(i),
  77. NVDEF(NV917D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) |
  78. NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) |
  79. NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) |
  80. NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) |
  81. NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) |
  82. NVDEF(NV917D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, ALPHA_BLEND),
  83. HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 8);
  84. PUSH_MTHD(push, NV917D, HEAD_SET_CONTEXT_DMA_CURSOR(i), asyh->curs.handle);
  85. return 0;
  86. }
  87. int
  88. head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw,
  89. struct nv50_head_atom *asyh)
  90. {
  91. switch (asyw->state.fb->width) {
  92. case 32: asyh->curs.layout = NV917D_HEAD_SET_CONTROL_CURSOR_SIZE_W32_H32; break;
  93. case 64: asyh->curs.layout = NV917D_HEAD_SET_CONTROL_CURSOR_SIZE_W64_H64; break;
  94. case 128: asyh->curs.layout = NV917D_HEAD_SET_CONTROL_CURSOR_SIZE_W128_H128; break;
  95. case 256: asyh->curs.layout = NV917D_HEAD_SET_CONTROL_CURSOR_SIZE_W256_H256; break;
  96. default:
  97. return -EINVAL;
  98. }
  99. return 0;
  100. }
  101. const struct nv50_head_func
  102. head917d = {
  103. .view = head907d_view,
  104. .mode = head907d_mode,
  105. .olut = head907d_olut,
  106. .ilut_check = head907d_ilut_check,
  107. .olut_size = 1024,
  108. .olut_set = head907d_olut_set,
  109. .olut_clr = head907d_olut_clr,
  110. .core_calc = head507d_core_calc,
  111. .core_set = head907d_core_set,
  112. .core_clr = head907d_core_clr,
  113. .curs_layout = head917d_curs_layout,
  114. .curs_format = head507d_curs_format,
  115. .curs_set = head917d_curs_set,
  116. .curs_clr = head907d_curs_clr,
  117. .base = head917d_base,
  118. .ovly = head907d_ovly,
  119. .dither = head917d_dither,
  120. .procamp = head907d_procamp,
  121. .or = head907d_or,
  122. };