head917d.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. static void
  25. head917d_dither(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, 2))) {
  30. evo_mthd(push, 0x04a0 + (head->base.index * 0x0300), 1);
  31. evo_data(push, asyh->dither.mode << 3 |
  32. asyh->dither.bits << 1 |
  33. asyh->dither.enable);
  34. evo_kick(push, core);
  35. }
  36. }
  37. static void
  38. head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
  39. {
  40. struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  41. u32 bounds = 0;
  42. u32 *push;
  43. if (asyh->base.cpp) {
  44. switch (asyh->base.cpp) {
  45. case 8: bounds |= 0x00000500; break;
  46. case 4: bounds |= 0x00000300; break;
  47. case 2: bounds |= 0x00000100; break;
  48. case 1: bounds |= 0x00000000; break;
  49. default:
  50. WARN_ON(1);
  51. break;
  52. }
  53. bounds |= 0x00020001;
  54. }
  55. if ((push = evo_wait(core, 2))) {
  56. evo_mthd(push, 0x04d0 + head->base.index * 0x300, 1);
  57. evo_data(push, bounds);
  58. evo_kick(push, core);
  59. }
  60. }
  61. int
  62. head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw,
  63. struct nv50_head_atom *asyh)
  64. {
  65. switch (asyw->state.fb->width) {
  66. case 32: asyh->curs.layout = 0; break;
  67. case 64: asyh->curs.layout = 1; break;
  68. case 128: asyh->curs.layout = 2; break;
  69. case 256: asyh->curs.layout = 3; break;
  70. default:
  71. return -EINVAL;
  72. }
  73. return 0;
  74. }
  75. const struct nv50_head_func
  76. head917d = {
  77. .view = head907d_view,
  78. .mode = head907d_mode,
  79. .olut = head907d_olut,
  80. .olut_set = head907d_olut_set,
  81. .olut_clr = head907d_olut_clr,
  82. .core_calc = head507d_core_calc,
  83. .core_set = head907d_core_set,
  84. .core_clr = head907d_core_clr,
  85. .curs_layout = head917d_curs_layout,
  86. .curs_format = head507d_curs_format,
  87. .curs_set = head907d_curs_set,
  88. .curs_clr = head907d_curs_clr,
  89. .base = head917d_base,
  90. .ovly = head907d_ovly,
  91. .dither = head917d_dither,
  92. .procamp = head907d_procamp,
  93. .or = head907d_or,
  94. };