corec37d.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 "core.h"
  23. #include "head.h"
  24. #include <nouveau_bo.h>
  25. static void
  26. corec37d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
  27. {
  28. u32 *push;
  29. if ((push = evo_wait(&core->chan, 9))) {
  30. if (ntfy) {
  31. evo_mthd(push, 0x020c, 1);
  32. evo_data(push, 0x00001000 | NV50_DISP_CORE_NTFY);
  33. }
  34. evo_mthd(push, 0x0218, 2);
  35. evo_data(push, interlock[NV50_DISP_INTERLOCK_CURS]);
  36. evo_data(push, interlock[NV50_DISP_INTERLOCK_WNDW]);
  37. evo_mthd(push, 0x0200, 1);
  38. evo_data(push, 0x00000001);
  39. if (ntfy) {
  40. evo_mthd(push, 0x020c, 1);
  41. evo_data(push, 0x00000000);
  42. }
  43. evo_kick(push, &core->chan);
  44. }
  45. }
  46. int
  47. corec37d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset,
  48. struct nvif_device *device)
  49. {
  50. u32 data;
  51. s64 time = nvif_msec(device, 2000ULL,
  52. data = nouveau_bo_rd32(bo, offset / 4 + 0);
  53. if ((data & 0xc0000000) == 0x80000000)
  54. break;
  55. usleep_range(1, 2);
  56. );
  57. return time < 0 ? time : 0;
  58. }
  59. void
  60. corec37d_ntfy_init(struct nouveau_bo *bo, u32 offset)
  61. {
  62. nouveau_bo_wr32(bo, offset / 4 + 0, 0x00000000);
  63. nouveau_bo_wr32(bo, offset / 4 + 1, 0x00000000);
  64. nouveau_bo_wr32(bo, offset / 4 + 2, 0x00000000);
  65. nouveau_bo_wr32(bo, offset / 4 + 3, 0x00000000);
  66. }
  67. void
  68. corec37d_init(struct nv50_core *core)
  69. {
  70. const u32 windows = 8; /*XXX*/
  71. u32 *push, i;
  72. if ((push = evo_wait(&core->chan, 2 + 6 * windows + 2))) {
  73. evo_mthd(push, 0x0208, 1);
  74. evo_data(push, core->chan.sync.handle);
  75. for (i = 0; i < windows; i++) {
  76. evo_mthd(push, 0x1000 + (i * 0x080), 3);
  77. evo_data(push, i >> 1);
  78. evo_data(push, 0x00000017);
  79. evo_data(push, 0x00000000);
  80. evo_mthd(push, 0x1010 + (i * 0x080), 1);
  81. evo_data(push, 0x00127fff);
  82. }
  83. evo_mthd(push, 0x0200, 1);
  84. evo_data(push, 0x00000001);
  85. evo_kick(push, &core->chan);
  86. }
  87. }
  88. static const struct nv50_core_func
  89. corec37d = {
  90. .init = corec37d_init,
  91. .ntfy_init = corec37d_ntfy_init,
  92. .ntfy_wait_done = corec37d_ntfy_wait_done,
  93. .update = corec37d_update,
  94. .head = &headc37d,
  95. .sor = &sorc37d,
  96. };
  97. int
  98. corec37d_new(struct nouveau_drm *drm, s32 oclass, struct nv50_core **pcore)
  99. {
  100. return core507d_new_(&corec37d, drm, oclass, pcore);
  101. }