ovly827e.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. static void
  26. ovly827e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
  27. {
  28. u32 *push;
  29. if ((push = evo_wait(&wndw->wndw, 12))) {
  30. evo_mthd(push, 0x0084, 1);
  31. evo_data(push, asyw->image.interval << 4);
  32. evo_mthd(push, 0x00c0, 1);
  33. evo_data(push, asyw->image.handle[0]);
  34. evo_mthd(push, 0x0100, 1);
  35. evo_data(push, 0x00000002);
  36. evo_mthd(push, 0x0800, 1);
  37. evo_data(push, asyw->image.offset[0] >> 8);
  38. evo_mthd(push, 0x0808, 3);
  39. evo_data(push, asyw->image.h << 16 | asyw->image.w);
  40. evo_data(push, asyw->image.layout << 20 |
  41. (asyw->image.pitch[0] >> 8) << 8 |
  42. asyw->image.blocks[0] << 8 |
  43. asyw->image.blockh);
  44. evo_data(push, asyw->image.format << 8 |
  45. asyw->image.colorspace);
  46. evo_kick(push, &wndw->wndw);
  47. }
  48. }
  49. int
  50. ovly827e_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset,
  51. struct nvif_device *device)
  52. {
  53. s64 time = nvif_msec(device, 2000ULL,
  54. u32 data = nouveau_bo_rd32(bo, offset / 4 + 3);
  55. if ((data & 0xffff0000) == 0xffff0000)
  56. break;
  57. usleep_range(1, 2);
  58. );
  59. return time < 0 ? time : 0;
  60. }
  61. void
  62. ovly827e_ntfy_reset(struct nouveau_bo *bo, u32 offset)
  63. {
  64. nouveau_bo_wr32(bo, offset / 4 + 0, 0x00000000);
  65. nouveau_bo_wr32(bo, offset / 4 + 1, 0x00000000);
  66. nouveau_bo_wr32(bo, offset / 4 + 2, 0x00000000);
  67. nouveau_bo_wr32(bo, offset / 4 + 3, 0x80000000);
  68. }
  69. static const struct nv50_wndw_func
  70. ovly827e = {
  71. .acquire = ovly507e_acquire,
  72. .release = ovly507e_release,
  73. .ntfy_set = ovly507e_ntfy_set,
  74. .ntfy_clr = ovly507e_ntfy_clr,
  75. .ntfy_reset = ovly827e_ntfy_reset,
  76. .ntfy_wait_begun = ovly827e_ntfy_wait_begun,
  77. .image_set = ovly827e_image_set,
  78. .image_clr = ovly507e_image_clr,
  79. .scale_set = ovly507e_scale_set,
  80. .update = ovly507e_update,
  81. };
  82. const u32
  83. ovly827e_format[] = {
  84. DRM_FORMAT_YUYV,
  85. DRM_FORMAT_UYVY,
  86. DRM_FORMAT_XRGB8888,
  87. DRM_FORMAT_ARGB8888,
  88. DRM_FORMAT_XRGB1555,
  89. DRM_FORMAT_ARGB1555,
  90. DRM_FORMAT_XBGR2101010,
  91. DRM_FORMAT_ABGR2101010,
  92. 0
  93. };
  94. int
  95. ovly827e_new(struct nouveau_drm *drm, int head, s32 oclass,
  96. struct nv50_wndw **pwndw)
  97. {
  98. return ovly507e_new_(&ovly827e, ovly827e_format, drm, head, oclass,
  99. 0x00000004 << (head * 8), pwndw);
  100. }