vce_v2_0.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /*
  2. * Copyright 2013 Advanced Micro Devices, Inc.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sub license, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  16. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  17. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  18. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  19. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. *
  21. * The above copyright notice and this permission notice (including the
  22. * next paragraph) shall be included in all copies or substantial portions
  23. * of the Software.
  24. *
  25. * Authors: Christian König <christian.koenig@amd.com>
  26. */
  27. #include <linux/firmware.h>
  28. #include <drm/drmP.h>
  29. #include "amdgpu.h"
  30. #include "amdgpu_vce.h"
  31. #include "cikd.h"
  32. #include "vce/vce_2_0_d.h"
  33. #include "vce/vce_2_0_sh_mask.h"
  34. #include "oss/oss_2_0_d.h"
  35. #include "oss/oss_2_0_sh_mask.h"
  36. #define VCE_V2_0_FW_SIZE (256 * 1024)
  37. #define VCE_V2_0_STACK_SIZE (64 * 1024)
  38. #define VCE_V2_0_DATA_SIZE (23552 * AMDGPU_MAX_VCE_HANDLES)
  39. static void vce_v2_0_mc_resume(struct amdgpu_device *adev);
  40. static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev);
  41. static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev);
  42. static int vce_v2_0_wait_for_idle(void *handle);
  43. /**
  44. * vce_v2_0_ring_get_rptr - get read pointer
  45. *
  46. * @ring: amdgpu_ring pointer
  47. *
  48. * Returns the current hardware read pointer
  49. */
  50. static uint32_t vce_v2_0_ring_get_rptr(struct amdgpu_ring *ring)
  51. {
  52. struct amdgpu_device *adev = ring->adev;
  53. if (ring == &adev->vce.ring[0])
  54. return RREG32(mmVCE_RB_RPTR);
  55. else
  56. return RREG32(mmVCE_RB_RPTR2);
  57. }
  58. /**
  59. * vce_v2_0_ring_get_wptr - get write pointer
  60. *
  61. * @ring: amdgpu_ring pointer
  62. *
  63. * Returns the current hardware write pointer
  64. */
  65. static uint32_t vce_v2_0_ring_get_wptr(struct amdgpu_ring *ring)
  66. {
  67. struct amdgpu_device *adev = ring->adev;
  68. if (ring == &adev->vce.ring[0])
  69. return RREG32(mmVCE_RB_WPTR);
  70. else
  71. return RREG32(mmVCE_RB_WPTR2);
  72. }
  73. /**
  74. * vce_v2_0_ring_set_wptr - set write pointer
  75. *
  76. * @ring: amdgpu_ring pointer
  77. *
  78. * Commits the write pointer to the hardware
  79. */
  80. static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
  81. {
  82. struct amdgpu_device *adev = ring->adev;
  83. if (ring == &adev->vce.ring[0])
  84. WREG32(mmVCE_RB_WPTR, ring->wptr);
  85. else
  86. WREG32(mmVCE_RB_WPTR2, ring->wptr);
  87. }
  88. /**
  89. * vce_v2_0_start - start VCE block
  90. *
  91. * @adev: amdgpu_device pointer
  92. *
  93. * Setup and start the VCE block
  94. */
  95. static int vce_v2_0_start(struct amdgpu_device *adev)
  96. {
  97. struct amdgpu_ring *ring;
  98. int i, j, r;
  99. vce_v2_0_mc_resume(adev);
  100. /* set BUSY flag */
  101. WREG32_P(mmVCE_STATUS, 1, ~1);
  102. ring = &adev->vce.ring[0];
  103. WREG32(mmVCE_RB_RPTR, ring->wptr);
  104. WREG32(mmVCE_RB_WPTR, ring->wptr);
  105. WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
  106. WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
  107. WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
  108. ring = &adev->vce.ring[1];
  109. WREG32(mmVCE_RB_RPTR2, ring->wptr);
  110. WREG32(mmVCE_RB_WPTR2, ring->wptr);
  111. WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
  112. WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
  113. WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
  114. WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
  115. WREG32_P(mmVCE_SOFT_RESET,
  116. VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
  117. ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  118. mdelay(100);
  119. WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  120. for (i = 0; i < 10; ++i) {
  121. uint32_t status;
  122. for (j = 0; j < 100; ++j) {
  123. status = RREG32(mmVCE_STATUS);
  124. if (status & 2)
  125. break;
  126. mdelay(10);
  127. }
  128. r = 0;
  129. if (status & 2)
  130. break;
  131. DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
  132. WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
  133. ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  134. mdelay(10);
  135. WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  136. mdelay(10);
  137. r = -1;
  138. }
  139. /* clear BUSY flag */
  140. WREG32_P(mmVCE_STATUS, 0, ~1);
  141. if (r) {
  142. DRM_ERROR("VCE not responding, giving up!!!\n");
  143. return r;
  144. }
  145. return 0;
  146. }
  147. static int vce_v2_0_early_init(void *handle)
  148. {
  149. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  150. vce_v2_0_set_ring_funcs(adev);
  151. vce_v2_0_set_irq_funcs(adev);
  152. return 0;
  153. }
  154. static int vce_v2_0_sw_init(void *handle)
  155. {
  156. struct amdgpu_ring *ring;
  157. int r;
  158. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  159. /* VCE */
  160. r = amdgpu_irq_add_id(adev, 167, &adev->vce.irq);
  161. if (r)
  162. return r;
  163. r = amdgpu_vce_sw_init(adev, VCE_V2_0_FW_SIZE +
  164. VCE_V2_0_STACK_SIZE + VCE_V2_0_DATA_SIZE);
  165. if (r)
  166. return r;
  167. r = amdgpu_vce_resume(adev);
  168. if (r)
  169. return r;
  170. ring = &adev->vce.ring[0];
  171. sprintf(ring->name, "vce0");
  172. r = amdgpu_ring_init(adev, ring, 512, VCE_CMD_NO_OP, 0xf,
  173. &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE);
  174. if (r)
  175. return r;
  176. ring = &adev->vce.ring[1];
  177. sprintf(ring->name, "vce1");
  178. r = amdgpu_ring_init(adev, ring, 512, VCE_CMD_NO_OP, 0xf,
  179. &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE);
  180. if (r)
  181. return r;
  182. return r;
  183. }
  184. static int vce_v2_0_sw_fini(void *handle)
  185. {
  186. int r;
  187. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  188. r = amdgpu_vce_suspend(adev);
  189. if (r)
  190. return r;
  191. r = amdgpu_vce_sw_fini(adev);
  192. if (r)
  193. return r;
  194. return r;
  195. }
  196. static int vce_v2_0_hw_init(void *handle)
  197. {
  198. struct amdgpu_ring *ring;
  199. int r;
  200. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  201. r = vce_v2_0_start(adev);
  202. if (r)
  203. /* this error mean vcpu not in running state, so just skip ring test, not stop driver initialize */
  204. return 0;
  205. ring = &adev->vce.ring[0];
  206. ring->ready = true;
  207. r = amdgpu_ring_test_ring(ring);
  208. if (r) {
  209. ring->ready = false;
  210. return r;
  211. }
  212. ring = &adev->vce.ring[1];
  213. ring->ready = true;
  214. r = amdgpu_ring_test_ring(ring);
  215. if (r) {
  216. ring->ready = false;
  217. return r;
  218. }
  219. DRM_INFO("VCE initialized successfully.\n");
  220. return 0;
  221. }
  222. static int vce_v2_0_hw_fini(void *handle)
  223. {
  224. return 0;
  225. }
  226. static int vce_v2_0_suspend(void *handle)
  227. {
  228. int r;
  229. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  230. r = vce_v2_0_hw_fini(adev);
  231. if (r)
  232. return r;
  233. r = amdgpu_vce_suspend(adev);
  234. if (r)
  235. return r;
  236. return r;
  237. }
  238. static int vce_v2_0_resume(void *handle)
  239. {
  240. int r;
  241. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  242. r = amdgpu_vce_resume(adev);
  243. if (r)
  244. return r;
  245. r = vce_v2_0_hw_init(adev);
  246. if (r)
  247. return r;
  248. return r;
  249. }
  250. static void vce_v2_0_set_sw_cg(struct amdgpu_device *adev, bool gated)
  251. {
  252. u32 tmp;
  253. if (gated) {
  254. tmp = RREG32(mmVCE_CLOCK_GATING_B);
  255. tmp |= 0xe70000;
  256. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  257. tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
  258. tmp |= 0xff000000;
  259. WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
  260. tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
  261. tmp &= ~0x3fc;
  262. WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
  263. WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
  264. } else {
  265. tmp = RREG32(mmVCE_CLOCK_GATING_B);
  266. tmp |= 0xe7;
  267. tmp &= ~0xe70000;
  268. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  269. tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
  270. tmp |= 0x1fe000;
  271. tmp &= ~0xff000000;
  272. WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
  273. tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
  274. tmp |= 0x3fc;
  275. WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
  276. }
  277. }
  278. static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated)
  279. {
  280. u32 orig, tmp;
  281. if (gated) {
  282. if (vce_v2_0_wait_for_idle(adev)) {
  283. DRM_INFO("VCE is busy, Can't set clock gateing");
  284. return;
  285. }
  286. WREG32_P(mmVCE_VCPU_CNTL, 0, ~VCE_VCPU_CNTL__CLK_EN_MASK);
  287. WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  288. mdelay(100);
  289. WREG32(mmVCE_STATUS, 0);
  290. } else {
  291. WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
  292. WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  293. mdelay(100);
  294. }
  295. tmp = RREG32(mmVCE_CLOCK_GATING_B);
  296. tmp &= ~0x00060006;
  297. if (gated) {
  298. tmp |= 0xe10000;
  299. } else {
  300. tmp |= 0xe1;
  301. tmp &= ~0xe10000;
  302. }
  303. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  304. orig = tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
  305. tmp &= ~0x1fe000;
  306. tmp &= ~0xff000000;
  307. if (tmp != orig)
  308. WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
  309. orig = tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
  310. tmp &= ~0x3fc;
  311. if (tmp != orig)
  312. WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
  313. if (gated)
  314. WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
  315. WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  316. }
  317. static void vce_v2_0_disable_cg(struct amdgpu_device *adev)
  318. {
  319. WREG32(mmVCE_CGTT_CLK_OVERRIDE, 7);
  320. }
  321. static void vce_v2_0_enable_mgcg(struct amdgpu_device *adev, bool enable)
  322. {
  323. bool sw_cg = false;
  324. if (enable && (adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)) {
  325. if (sw_cg)
  326. vce_v2_0_set_sw_cg(adev, true);
  327. else
  328. vce_v2_0_set_dyn_cg(adev, true);
  329. } else {
  330. vce_v2_0_disable_cg(adev);
  331. if (sw_cg)
  332. vce_v2_0_set_sw_cg(adev, false);
  333. else
  334. vce_v2_0_set_dyn_cg(adev, false);
  335. }
  336. }
  337. static void vce_v2_0_init_cg(struct amdgpu_device *adev)
  338. {
  339. u32 tmp;
  340. tmp = RREG32(mmVCE_CLOCK_GATING_A);
  341. tmp &= ~0xfff;
  342. tmp |= ((0 << 0) | (4 << 4));
  343. tmp |= 0x40000;
  344. WREG32(mmVCE_CLOCK_GATING_A, tmp);
  345. tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
  346. tmp &= ~0xfff;
  347. tmp |= ((0 << 0) | (4 << 4));
  348. WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
  349. tmp = RREG32(mmVCE_CLOCK_GATING_B);
  350. tmp |= 0x10;
  351. tmp &= ~0x100000;
  352. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  353. }
  354. static void vce_v2_0_mc_resume(struct amdgpu_device *adev)
  355. {
  356. uint64_t addr = adev->vce.gpu_addr;
  357. uint32_t size;
  358. WREG32_P(mmVCE_CLOCK_GATING_A, 0, ~(1 << 16));
  359. WREG32_P(mmVCE_UENC_CLOCK_GATING, 0x1FF000, ~0xFF9FF000);
  360. WREG32_P(mmVCE_UENC_REG_CLOCK_GATING, 0x3F, ~0x3F);
  361. WREG32(mmVCE_CLOCK_GATING_B, 0xf7);
  362. WREG32(mmVCE_LMI_CTRL, 0x00398000);
  363. WREG32_P(mmVCE_LMI_CACHE_CTRL, 0x0, ~0x1);
  364. WREG32(mmVCE_LMI_SWAP_CNTL, 0);
  365. WREG32(mmVCE_LMI_SWAP_CNTL1, 0);
  366. WREG32(mmVCE_LMI_VM_CTRL, 0);
  367. addr += AMDGPU_VCE_FIRMWARE_OFFSET;
  368. size = VCE_V2_0_FW_SIZE;
  369. WREG32(mmVCE_VCPU_CACHE_OFFSET0, addr & 0x7fffffff);
  370. WREG32(mmVCE_VCPU_CACHE_SIZE0, size);
  371. addr += size;
  372. size = VCE_V2_0_STACK_SIZE;
  373. WREG32(mmVCE_VCPU_CACHE_OFFSET1, addr & 0x7fffffff);
  374. WREG32(mmVCE_VCPU_CACHE_SIZE1, size);
  375. addr += size;
  376. size = VCE_V2_0_DATA_SIZE;
  377. WREG32(mmVCE_VCPU_CACHE_OFFSET2, addr & 0x7fffffff);
  378. WREG32(mmVCE_VCPU_CACHE_SIZE2, size);
  379. WREG32_P(mmVCE_LMI_CTRL2, 0x0, ~0x100);
  380. WREG32_P(mmVCE_SYS_INT_EN, VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK,
  381. ~VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK);
  382. vce_v2_0_init_cg(adev);
  383. }
  384. static bool vce_v2_0_is_idle(void *handle)
  385. {
  386. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  387. return !(RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK);
  388. }
  389. static int vce_v2_0_wait_for_idle(void *handle)
  390. {
  391. unsigned i;
  392. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  393. for (i = 0; i < adev->usec_timeout; i++) {
  394. if (!(RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK))
  395. return 0;
  396. }
  397. return -ETIMEDOUT;
  398. }
  399. static int vce_v2_0_soft_reset(void *handle)
  400. {
  401. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  402. WREG32_P(mmSRBM_SOFT_RESET, SRBM_SOFT_RESET__SOFT_RESET_VCE_MASK,
  403. ~SRBM_SOFT_RESET__SOFT_RESET_VCE_MASK);
  404. mdelay(5);
  405. return vce_v2_0_start(adev);
  406. }
  407. static int vce_v2_0_set_interrupt_state(struct amdgpu_device *adev,
  408. struct amdgpu_irq_src *source,
  409. unsigned type,
  410. enum amdgpu_interrupt_state state)
  411. {
  412. uint32_t val = 0;
  413. if (state == AMDGPU_IRQ_STATE_ENABLE)
  414. val |= VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK;
  415. WREG32_P(mmVCE_SYS_INT_EN, val, ~VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK);
  416. return 0;
  417. }
  418. static int vce_v2_0_process_interrupt(struct amdgpu_device *adev,
  419. struct amdgpu_irq_src *source,
  420. struct amdgpu_iv_entry *entry)
  421. {
  422. DRM_DEBUG("IH: VCE\n");
  423. switch (entry->src_data) {
  424. case 0:
  425. amdgpu_fence_process(&adev->vce.ring[0]);
  426. break;
  427. case 1:
  428. amdgpu_fence_process(&adev->vce.ring[1]);
  429. break;
  430. default:
  431. DRM_ERROR("Unhandled interrupt: %d %d\n",
  432. entry->src_id, entry->src_data);
  433. break;
  434. }
  435. return 0;
  436. }
  437. static int vce_v2_0_set_clockgating_state(void *handle,
  438. enum amd_clockgating_state state)
  439. {
  440. bool gate = false;
  441. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  442. if (state == AMD_CG_STATE_GATE)
  443. gate = true;
  444. vce_v2_0_enable_mgcg(adev, gate);
  445. return 0;
  446. }
  447. static int vce_v2_0_set_powergating_state(void *handle,
  448. enum amd_powergating_state state)
  449. {
  450. /* This doesn't actually powergate the VCE block.
  451. * That's done in the dpm code via the SMC. This
  452. * just re-inits the block as necessary. The actual
  453. * gating still happens in the dpm code. We should
  454. * revisit this when there is a cleaner line between
  455. * the smc and the hw blocks
  456. */
  457. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  458. if (!(adev->pg_flags & AMD_PG_SUPPORT_VCE))
  459. return 0;
  460. if (state == AMD_PG_STATE_GATE)
  461. /* XXX do we need a vce_v2_0_stop()? */
  462. return 0;
  463. else
  464. return vce_v2_0_start(adev);
  465. }
  466. const struct amd_ip_funcs vce_v2_0_ip_funcs = {
  467. .early_init = vce_v2_0_early_init,
  468. .late_init = NULL,
  469. .sw_init = vce_v2_0_sw_init,
  470. .sw_fini = vce_v2_0_sw_fini,
  471. .hw_init = vce_v2_0_hw_init,
  472. .hw_fini = vce_v2_0_hw_fini,
  473. .suspend = vce_v2_0_suspend,
  474. .resume = vce_v2_0_resume,
  475. .is_idle = vce_v2_0_is_idle,
  476. .wait_for_idle = vce_v2_0_wait_for_idle,
  477. .soft_reset = vce_v2_0_soft_reset,
  478. .set_clockgating_state = vce_v2_0_set_clockgating_state,
  479. .set_powergating_state = vce_v2_0_set_powergating_state,
  480. };
  481. static const struct amdgpu_ring_funcs vce_v2_0_ring_funcs = {
  482. .get_rptr = vce_v2_0_ring_get_rptr,
  483. .get_wptr = vce_v2_0_ring_get_wptr,
  484. .set_wptr = vce_v2_0_ring_set_wptr,
  485. .parse_cs = amdgpu_vce_ring_parse_cs,
  486. .emit_ib = amdgpu_vce_ring_emit_ib,
  487. .emit_fence = amdgpu_vce_ring_emit_fence,
  488. .test_ring = amdgpu_vce_ring_test_ring,
  489. .test_ib = amdgpu_vce_ring_test_ib,
  490. .insert_nop = amdgpu_ring_insert_nop,
  491. .pad_ib = amdgpu_ring_generic_pad_ib,
  492. };
  493. static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev)
  494. {
  495. adev->vce.ring[0].funcs = &vce_v2_0_ring_funcs;
  496. adev->vce.ring[1].funcs = &vce_v2_0_ring_funcs;
  497. }
  498. static const struct amdgpu_irq_src_funcs vce_v2_0_irq_funcs = {
  499. .set = vce_v2_0_set_interrupt_state,
  500. .process = vce_v2_0_process_interrupt,
  501. };
  502. static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev)
  503. {
  504. adev->vce.irq.num_types = 1;
  505. adev->vce.irq.funcs = &vce_v2_0_irq_funcs;
  506. };