wimmc37b.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 "wimm.h"
  23. #include "atom.h"
  24. #include "wndw.h"
  25. #include <nvif/if0014.h>
  26. #include <nvif/pushc37b.h>
  27. #include <nvhw/class/clc37b.h>
  28. static int
  29. wimmc37b_update(struct nv50_wndw *wndw, u32 *interlock)
  30. {
  31. struct nvif_push *push = wndw->wimm.push;
  32. int ret;
  33. if ((ret = PUSH_WAIT(push, 2)))
  34. return ret;
  35. PUSH_MTHD(push, NVC37B, UPDATE, 0x00000001 |
  36. NVVAL(NVC37B, UPDATE, INTERLOCK_WITH_WINDOW,
  37. !!(interlock[NV50_DISP_INTERLOCK_WNDW] & wndw->interlock.data)));
  38. return PUSH_KICK(push);
  39. }
  40. static int
  41. wimmc37b_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
  42. {
  43. struct nvif_push *push = wndw->wimm.push;
  44. int ret;
  45. if ((ret = PUSH_WAIT(push, 2)))
  46. return ret;
  47. PUSH_MTHD(push, NVC37B, SET_POINT_OUT(0),
  48. NVVAL(NVC37B, SET_POINT_OUT, X, asyw->point.x) |
  49. NVVAL(NVC37B, SET_POINT_OUT, Y, asyw->point.y));
  50. return 0;
  51. }
  52. static const struct nv50_wimm_func
  53. wimmc37b = {
  54. .point = wimmc37b_point,
  55. .update = wimmc37b_update,
  56. };
  57. static int
  58. wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
  59. s32 oclass, struct nv50_wndw *wndw)
  60. {
  61. struct nvif_disp_chan_v0 args = {
  62. .id = wndw->id,
  63. };
  64. struct nv50_disp *disp = nv50_disp(drm->dev);
  65. int ret;
  66. ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
  67. &oclass, 0, &args, sizeof(args), -1,
  68. &wndw->wimm);
  69. if (ret) {
  70. NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
  71. return ret;
  72. }
  73. wndw->interlock.wimm = wndw->interlock.data;
  74. wndw->immd = func;
  75. return 0;
  76. }
  77. int
  78. wimmc37b_init(struct nouveau_drm *drm, s32 oclass, struct nv50_wndw *wndw)
  79. {
  80. return wimmc37b_init_(&wimmc37b, drm, oclass, wndw);
  81. }