base827c.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 "base.h"
  23. #include <nvif/push507c.h>
  24. #include <nvhw/class/cl827c.h>
  25. static int
  26. base827c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
  27. {
  28. struct nvif_push *push = wndw->wndw.push;
  29. int ret;
  30. if ((ret = PUSH_WAIT(push, 13)))
  31. return ret;
  32. PUSH_MTHD(push, NV827C, SET_PRESENT_CONTROL,
  33. NVVAL(NV827C, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) |
  34. NVVAL(NV827C, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval));
  35. PUSH_MTHD(push, NV827C, SET_CONTEXT_DMAS_ISO(0), asyw->image.handle, 1);
  36. if (asyw->image.format == NV827C_SURFACE_SET_PARAMS_FORMAT_RF16_GF16_BF16_AF16) {
  37. PUSH_MTHD(push, NV827C, SET_PROCESSING,
  38. NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, ENABLE),
  39. SET_CONVERSION,
  40. NVVAL(NV827C, SET_CONVERSION, GAIN, 0) |
  41. NVVAL(NV827C, SET_CONVERSION, OFS, 0x64));
  42. } else {
  43. PUSH_MTHD(push, NV827C, SET_PROCESSING,
  44. NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, DISABLE),
  45. SET_CONVERSION,
  46. NVVAL(NV827C, SET_CONVERSION, GAIN, 0) |
  47. NVVAL(NV827C, SET_CONVERSION, OFS, 0));
  48. }
  49. PUSH_MTHD(push, NV827C, SURFACE_SET_OFFSET(0, 0), asyw->image.offset[0] >> 8,
  50. SURFACE_SET_OFFSET(0, 1), 0x00000000,
  51. SURFACE_SET_SIZE(0),
  52. NVVAL(NV827C, SURFACE_SET_SIZE, WIDTH, asyw->image.w) |
  53. NVVAL(NV827C, SURFACE_SET_SIZE, HEIGHT, asyw->image.h),
  54. SURFACE_SET_STORAGE(0),
  55. NVVAL(NV827C, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) |
  56. NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.pitch[0] >> 8) |
  57. NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) |
  58. NVVAL(NV827C, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout),
  59. SURFACE_SET_PARAMS(0),
  60. NVVAL(NV827C, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) |
  61. NVDEF(NV827C, SURFACE_SET_PARAMS, SUPER_SAMPLE, X1_AA) |
  62. NVDEF(NV827C, SURFACE_SET_PARAMS, GAMMA, LINEAR) |
  63. NVDEF(NV827C, SURFACE_SET_PARAMS, LAYOUT, FRM));
  64. return 0;
  65. }
  66. static const struct nv50_wndw_func
  67. base827c = {
  68. .acquire = base507c_acquire,
  69. .release = base507c_release,
  70. .sema_set = base507c_sema_set,
  71. .sema_clr = base507c_sema_clr,
  72. .ntfy_reset = base507c_ntfy_reset,
  73. .ntfy_set = base507c_ntfy_set,
  74. .ntfy_clr = base507c_ntfy_clr,
  75. .ntfy_wait_begun = base507c_ntfy_wait_begun,
  76. .olut_core = 1,
  77. .xlut_set = base507c_xlut_set,
  78. .xlut_clr = base507c_xlut_clr,
  79. .image_set = base827c_image_set,
  80. .image_clr = base507c_image_clr,
  81. .update = base507c_update,
  82. };
  83. int
  84. base827c_new(struct nouveau_drm *drm, int head, s32 oclass,
  85. struct nv50_wndw **pwndw)
  86. {
  87. return base507c_new_(&base827c, base507c_format, drm, head, oclass,
  88. 0x00000002 << (head * 8), pwndw);
  89. }