wndwc67e.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright 2021 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 "wndw.h"
  23. #include "atom.h"
  24. #include <nvif/pushc37b.h>
  25. #include <nvhw/class/clc57e.h>
  26. static int
  27. wndwc67e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
  28. {
  29. struct nvif_push *push = wndw->wndw.push;
  30. int ret;
  31. if ((ret = PUSH_WAIT(push, 17)))
  32. return ret;
  33. PUSH_MTHD(push, NVC57E, SET_PRESENT_CONTROL,
  34. NVVAL(NVC57E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval) |
  35. NVVAL(NVC57E, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) |
  36. NVDEF(NVC57E, SET_PRESENT_CONTROL, TIMESTAMP_MODE, DISABLE));
  37. PUSH_MTHD(push, NVC57E, SET_SIZE,
  38. NVVAL(NVC57E, SET_SIZE, WIDTH, asyw->image.w) |
  39. NVVAL(NVC57E, SET_SIZE, HEIGHT, asyw->image.h),
  40. SET_STORAGE,
  41. NVVAL(NVC57E, SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh),
  42. SET_PARAMS,
  43. NVVAL(NVC57E, SET_PARAMS, FORMAT, asyw->image.format) |
  44. NVDEF(NVC57E, SET_PARAMS, CLAMP_BEFORE_BLEND, DISABLE) |
  45. NVDEF(NVC57E, SET_PARAMS, SWAP_UV, DISABLE) |
  46. NVDEF(NVC57E, SET_PARAMS, FMT_ROUNDING_MODE, ROUND_TO_NEAREST),
  47. SET_PLANAR_STORAGE(0),
  48. NVVAL(NVC57E, SET_PLANAR_STORAGE, PITCH, asyw->image.blocks[0]) |
  49. NVVAL(NVC57E, SET_PLANAR_STORAGE, PITCH, asyw->image.pitch[0] >> 6));
  50. PUSH_MTHD(push, NVC57E, SET_CONTEXT_DMA_ISO(0), asyw->image.handle, 1);
  51. PUSH_MTHD(push, NVC57E, SET_OFFSET(0), asyw->image.offset[0] >> 8);
  52. PUSH_MTHD(push, NVC57E, SET_POINT_IN(0),
  53. NVVAL(NVC57E, SET_POINT_IN, X, asyw->state.src_x >> 16) |
  54. NVVAL(NVC57E, SET_POINT_IN, Y, asyw->state.src_y >> 16));
  55. PUSH_MTHD(push, NVC57E, SET_SIZE_IN,
  56. NVVAL(NVC57E, SET_SIZE_IN, WIDTH, asyw->state.src_w >> 16) |
  57. NVVAL(NVC57E, SET_SIZE_IN, HEIGHT, asyw->state.src_h >> 16));
  58. PUSH_MTHD(push, NVC57E, SET_SIZE_OUT,
  59. NVVAL(NVC57E, SET_SIZE_OUT, WIDTH, asyw->state.crtc_w) |
  60. NVVAL(NVC57E, SET_SIZE_OUT, HEIGHT, asyw->state.crtc_h));
  61. return 0;
  62. }
  63. static const struct nv50_wndw_func
  64. wndwc67e = {
  65. .acquire = wndwc37e_acquire,
  66. .release = wndwc37e_release,
  67. .sema_set = wndwc37e_sema_set,
  68. .sema_clr = wndwc37e_sema_clr,
  69. .ntfy_set = wndwc37e_ntfy_set,
  70. .ntfy_clr = wndwc37e_ntfy_clr,
  71. .ntfy_reset = corec37d_ntfy_init,
  72. .ntfy_wait_begun = base507c_ntfy_wait_begun,
  73. .ilut = wndwc57e_ilut,
  74. .ilut_identity = true,
  75. .ilut_size = 1024,
  76. .xlut_set = wndwc57e_ilut_set,
  77. .xlut_clr = wndwc57e_ilut_clr,
  78. .csc = base907c_csc,
  79. .csc_set = wndwc57e_csc_set,
  80. .csc_clr = wndwc57e_csc_clr,
  81. .image_set = wndwc67e_image_set,
  82. .image_clr = wndwc37e_image_clr,
  83. .blend_set = wndwc37e_blend_set,
  84. .update = wndwc37e_update,
  85. };
  86. int
  87. wndwc67e_new(struct nouveau_drm *drm, enum drm_plane_type type, int index,
  88. s32 oclass, struct nv50_wndw **pwndw)
  89. {
  90. return wndwc37e_new_(&wndwc67e, drm, type, index, oclass, BIT(index >> 1), pwndw);
  91. }