wimmc37b.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/clc37b.h>
  26. static void
  27. wimmc37b_update(struct nv50_wndw *wndw, u32 *interlock)
  28. {
  29. u32 *push;
  30. if ((push = evo_wait(&wndw->wimm, 2))) {
  31. evo_mthd(push, 0x0200, 1);
  32. if (interlock[NV50_DISP_INTERLOCK_WNDW] & wndw->interlock.data)
  33. evo_data(push, 0x00000003);
  34. else
  35. evo_data(push, 0x00000001);
  36. evo_kick(push, &wndw->wimm);
  37. }
  38. }
  39. static void
  40. wimmc37b_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
  41. {
  42. u32 *push;
  43. if ((push = evo_wait(&wndw->wimm, 2))) {
  44. evo_mthd(push, 0x0208, 1);
  45. evo_data(push, asyw->point.y << 16 | asyw->point.x);
  46. evo_kick(push, &wndw->wimm);
  47. }
  48. }
  49. static const struct nv50_wimm_func
  50. wimmc37b = {
  51. .point = wimmc37b_point,
  52. .update = wimmc37b_update,
  53. };
  54. static int
  55. wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
  56. s32 oclass, struct nv50_wndw *wndw)
  57. {
  58. struct nvc37b_window_imm_channel_dma_v0 args = {
  59. .pushbuf = 0xb0007b00 | wndw->id,
  60. .index = wndw->id,
  61. };
  62. struct nv50_disp *disp = nv50_disp(drm->dev);
  63. int ret;
  64. ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
  65. &oclass, 0, &args, sizeof(args), 0,
  66. &wndw->wimm);
  67. if (ret) {
  68. NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
  69. return ret;
  70. }
  71. wndw->immd = func;
  72. return 0;
  73. }
  74. int
  75. wimmc37b_init(struct nouveau_drm *drm, s32 oclass, struct nv50_wndw *wndw)
  76. {
  77. return wimmc37b_init_(&wimmc37b, drm, oclass, wndw);
  78. }