ovly827e.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 "ovly.h"
  23. #include "atom.h"
  24. #include <nouveau_bo.h>
  25. #include <nvif/push507c.h>
  26. #include <nvif/timer.h>
  27. #include <nvhw/class/cl827e.h>
  28. static int
  29. ovly827e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
  30. {
  31. struct nvif_push *push = wndw->wndw.push;
  32. int ret;
  33. if ((ret = PUSH_WAIT(push, 12)))
  34. return ret;
  35. PUSH_MTHD(push, NV827E, SET_PRESENT_CONTROL,
  36. NVDEF(NV827E, SET_PRESENT_CONTROL, BEGIN_MODE, ASAP) |
  37. NVVAL(NV827E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval));
  38. PUSH_MTHD(push, NV827E, SET_CONTEXT_DMA_ISO, asyw->image.handle[0]);
  39. PUSH_MTHD(push, NV827E, SET_COMPOSITION_CONTROL,
  40. NVDEF(NV827E, SET_COMPOSITION_CONTROL, MODE, OPAQUE_SUSPEND_BASE));
  41. PUSH_MTHD(push, NV827E, SURFACE_SET_OFFSET, asyw->image.offset[0] >> 8);
  42. PUSH_MTHD(push, NV827E, SURFACE_SET_SIZE,
  43. NVVAL(NV827E, SURFACE_SET_SIZE, WIDTH, asyw->image.w) |
  44. NVVAL(NV827E, SURFACE_SET_SIZE, HEIGHT, asyw->image.h),
  45. SURFACE_SET_STORAGE,
  46. NVVAL(NV827E, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) |
  47. NVVAL(NV827E, SURFACE_SET_STORAGE, PITCH, (asyw->image.pitch[0] >> 8)) |
  48. NVVAL(NV827E, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) |
  49. NVVAL(NV827E, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout),
  50. SURFACE_SET_PARAMS,
  51. NVVAL(NV827E, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) |
  52. NVVAL(NV827E, SURFACE_SET_PARAMS, COLOR_SPACE, asyw->image.colorspace));
  53. return 0;
  54. }
  55. int
  56. ovly827e_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset,
  57. struct nvif_device *device)
  58. {
  59. s64 time = nvif_msec(device, 2000ULL,
  60. if (NVBO_TD32(bo, offset, NV_DISP_NOTIFICATION_1, _3, STATUS, ==, BEGUN))
  61. break;
  62. usleep_range(1, 2);
  63. );
  64. return time < 0 ? time : 0;
  65. }
  66. void
  67. ovly827e_ntfy_reset(struct nouveau_bo *bo, u32 offset)
  68. {
  69. NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, TIME_STAMP_0, 0);
  70. NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, TIME_STAMP_1, 0);
  71. NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, _2, 0);
  72. NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, _3,
  73. NVDEF(NV_DISP_NOTIFICATION_1, _3, STATUS, NOT_BEGUN));
  74. }
  75. static const struct nv50_wndw_func
  76. ovly827e = {
  77. .acquire = ovly507e_acquire,
  78. .release = ovly507e_release,
  79. .ntfy_set = base507c_ntfy_set,
  80. .ntfy_clr = base507c_ntfy_clr,
  81. .ntfy_reset = ovly827e_ntfy_reset,
  82. .ntfy_wait_begun = ovly827e_ntfy_wait_begun,
  83. .image_set = ovly827e_image_set,
  84. .image_clr = base507c_image_clr,
  85. .scale_set = ovly507e_scale_set,
  86. .update = base507c_update,
  87. };
  88. const u32
  89. ovly827e_format[] = {
  90. DRM_FORMAT_YUYV,
  91. DRM_FORMAT_UYVY,
  92. DRM_FORMAT_XRGB8888,
  93. DRM_FORMAT_XRGB1555,
  94. DRM_FORMAT_XBGR2101010,
  95. 0
  96. };
  97. int
  98. ovly827e_new(struct nouveau_drm *drm, int head, s32 oclass,
  99. struct nv50_wndw **pwndw)
  100. {
  101. return ovly507e_new_(&ovly827e, ovly827e_format, drm, head, oclass,
  102. 0x00000004 << (head * 8), pwndw);
  103. }