vce_v2_0.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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 "smu/smu_7_0_1_d.h"
  35. #include "smu/smu_7_0_1_sh_mask.h"
  36. #include "oss/oss_2_0_d.h"
  37. #include "oss/oss_2_0_sh_mask.h"
  38. #define VCE_V2_0_FW_SIZE (256 * 1024)
  39. #define VCE_V2_0_STACK_SIZE (64 * 1024)
  40. #define VCE_V2_0_DATA_SIZE (23552 * AMDGPU_MAX_VCE_HANDLES)
  41. #define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
  42. static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev);
  43. static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev);
  44. /**
  45. * vce_v2_0_ring_get_rptr - get read pointer
  46. *
  47. * @ring: amdgpu_ring pointer
  48. *
  49. * Returns the current hardware read pointer
  50. */
  51. static uint64_t vce_v2_0_ring_get_rptr(struct amdgpu_ring *ring)
  52. {
  53. struct amdgpu_device *adev = ring->adev;
  54. if (ring == &adev->vce.ring[0])
  55. return RREG32(mmVCE_RB_RPTR);
  56. else
  57. return RREG32(mmVCE_RB_RPTR2);
  58. }
  59. /**
  60. * vce_v2_0_ring_get_wptr - get write pointer
  61. *
  62. * @ring: amdgpu_ring pointer
  63. *
  64. * Returns the current hardware write pointer
  65. */
  66. static uint64_t vce_v2_0_ring_get_wptr(struct amdgpu_ring *ring)
  67. {
  68. struct amdgpu_device *adev = ring->adev;
  69. if (ring == &adev->vce.ring[0])
  70. return RREG32(mmVCE_RB_WPTR);
  71. else
  72. return RREG32(mmVCE_RB_WPTR2);
  73. }
  74. /**
  75. * vce_v2_0_ring_set_wptr - set write pointer
  76. *
  77. * @ring: amdgpu_ring pointer
  78. *
  79. * Commits the write pointer to the hardware
  80. */
  81. static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
  82. {
  83. struct amdgpu_device *adev = ring->adev;
  84. if (ring == &adev->vce.ring[0])
  85. WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
  86. else
  87. WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
  88. }
  89. static int vce_v2_0_lmi_clean(struct amdgpu_device *adev)
  90. {
  91. int i, j;
  92. for (i = 0; i < 10; ++i) {
  93. for (j = 0; j < 100; ++j) {
  94. uint32_t status = RREG32(mmVCE_LMI_STATUS);
  95. if (status & 0x337f)
  96. return 0;
  97. mdelay(10);
  98. }
  99. }
  100. return -ETIMEDOUT;
  101. }
  102. static int vce_v2_0_firmware_loaded(struct amdgpu_device *adev)
  103. {
  104. int i, j;
  105. for (i = 0; i < 10; ++i) {
  106. for (j = 0; j < 100; ++j) {
  107. uint32_t status = RREG32(mmVCE_STATUS);
  108. if (status & VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK)
  109. return 0;
  110. mdelay(10);
  111. }
  112. DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
  113. WREG32_P(mmVCE_SOFT_RESET,
  114. VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
  115. ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  116. mdelay(10);
  117. WREG32_P(mmVCE_SOFT_RESET, 0,
  118. ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  119. mdelay(10);
  120. }
  121. return -ETIMEDOUT;
  122. }
  123. static void vce_v2_0_disable_cg(struct amdgpu_device *adev)
  124. {
  125. WREG32(mmVCE_CGTT_CLK_OVERRIDE, 7);
  126. }
  127. static void vce_v2_0_init_cg(struct amdgpu_device *adev)
  128. {
  129. u32 tmp;
  130. tmp = RREG32(mmVCE_CLOCK_GATING_A);
  131. tmp &= ~0xfff;
  132. tmp |= ((0 << 0) | (4 << 4));
  133. tmp |= 0x40000;
  134. WREG32(mmVCE_CLOCK_GATING_A, tmp);
  135. tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
  136. tmp &= ~0xfff;
  137. tmp |= ((0 << 0) | (4 << 4));
  138. WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
  139. tmp = RREG32(mmVCE_CLOCK_GATING_B);
  140. tmp |= 0x10;
  141. tmp &= ~0x100000;
  142. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  143. }
  144. static void vce_v2_0_mc_resume(struct amdgpu_device *adev)
  145. {
  146. uint32_t size, offset;
  147. WREG32_P(mmVCE_CLOCK_GATING_A, 0, ~(1 << 16));
  148. WREG32_P(mmVCE_UENC_CLOCK_GATING, 0x1FF000, ~0xFF9FF000);
  149. WREG32_P(mmVCE_UENC_REG_CLOCK_GATING, 0x3F, ~0x3F);
  150. WREG32(mmVCE_CLOCK_GATING_B, 0xf7);
  151. WREG32(mmVCE_LMI_CTRL, 0x00398000);
  152. WREG32_P(mmVCE_LMI_CACHE_CTRL, 0x0, ~0x1);
  153. WREG32(mmVCE_LMI_SWAP_CNTL, 0);
  154. WREG32(mmVCE_LMI_SWAP_CNTL1, 0);
  155. WREG32(mmVCE_LMI_VM_CTRL, 0);
  156. WREG32(mmVCE_LMI_VCPU_CACHE_40BIT_BAR, (adev->vce.gpu_addr >> 8));
  157. offset = AMDGPU_VCE_FIRMWARE_OFFSET;
  158. size = VCE_V2_0_FW_SIZE;
  159. WREG32(mmVCE_VCPU_CACHE_OFFSET0, offset & 0x7fffffff);
  160. WREG32(mmVCE_VCPU_CACHE_SIZE0, size);
  161. offset += size;
  162. size = VCE_V2_0_STACK_SIZE;
  163. WREG32(mmVCE_VCPU_CACHE_OFFSET1, offset & 0x7fffffff);
  164. WREG32(mmVCE_VCPU_CACHE_SIZE1, size);
  165. offset += size;
  166. size = VCE_V2_0_DATA_SIZE;
  167. WREG32(mmVCE_VCPU_CACHE_OFFSET2, offset & 0x7fffffff);
  168. WREG32(mmVCE_VCPU_CACHE_SIZE2, size);
  169. WREG32_P(mmVCE_LMI_CTRL2, 0x0, ~0x100);
  170. WREG32_FIELD(VCE_SYS_INT_EN, VCE_SYS_INT_TRAP_INTERRUPT_EN, 1);
  171. }
  172. static bool vce_v2_0_is_idle(void *handle)
  173. {
  174. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  175. return !(RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK);
  176. }
  177. static int vce_v2_0_wait_for_idle(void *handle)
  178. {
  179. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  180. unsigned i;
  181. for (i = 0; i < adev->usec_timeout; i++) {
  182. if (vce_v2_0_is_idle(handle))
  183. return 0;
  184. }
  185. return -ETIMEDOUT;
  186. }
  187. /**
  188. * vce_v2_0_start - start VCE block
  189. *
  190. * @adev: amdgpu_device pointer
  191. *
  192. * Setup and start the VCE block
  193. */
  194. static int vce_v2_0_start(struct amdgpu_device *adev)
  195. {
  196. struct amdgpu_ring *ring;
  197. int r;
  198. /* set BUSY flag */
  199. WREG32_P(mmVCE_STATUS, 1, ~1);
  200. vce_v2_0_init_cg(adev);
  201. vce_v2_0_disable_cg(adev);
  202. vce_v2_0_mc_resume(adev);
  203. ring = &adev->vce.ring[0];
  204. WREG32(mmVCE_RB_RPTR, lower_32_bits(ring->wptr));
  205. WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
  206. WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
  207. WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
  208. WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
  209. ring = &adev->vce.ring[1];
  210. WREG32(mmVCE_RB_RPTR2, lower_32_bits(ring->wptr));
  211. WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
  212. WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
  213. WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
  214. WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
  215. WREG32_FIELD(VCE_VCPU_CNTL, CLK_EN, 1);
  216. WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 1);
  217. mdelay(100);
  218. WREG32_FIELD(VCE_SOFT_RESET, ECPU_SOFT_RESET, 0);
  219. r = vce_v2_0_firmware_loaded(adev);
  220. /* clear BUSY flag */
  221. WREG32_P(mmVCE_STATUS, 0, ~1);
  222. if (r) {
  223. DRM_ERROR("VCE not responding, giving up!!!\n");
  224. return r;
  225. }
  226. return 0;
  227. }
  228. static int vce_v2_0_stop(struct amdgpu_device *adev)
  229. {
  230. int i;
  231. int status;
  232. if (vce_v2_0_lmi_clean(adev)) {
  233. DRM_INFO("vce is not idle \n");
  234. return 0;
  235. }
  236. if (vce_v2_0_wait_for_idle(adev)) {
  237. DRM_INFO("VCE is busy, Can't set clock gateing");
  238. return 0;
  239. }
  240. /* Stall UMC and register bus before resetting VCPU */
  241. WREG32_P(mmVCE_LMI_CTRL2, 1 << 8, ~(1 << 8));
  242. for (i = 0; i < 100; ++i) {
  243. status = RREG32(mmVCE_LMI_STATUS);
  244. if (status & 0x240)
  245. break;
  246. mdelay(1);
  247. }
  248. WREG32_P(mmVCE_VCPU_CNTL, 0, ~0x80001);
  249. /* put LMI, VCPU, RBC etc... into reset */
  250. WREG32_P(mmVCE_SOFT_RESET, 1, ~0x1);
  251. WREG32(mmVCE_STATUS, 0);
  252. return 0;
  253. }
  254. static void vce_v2_0_set_sw_cg(struct amdgpu_device *adev, bool gated)
  255. {
  256. u32 tmp;
  257. if (gated) {
  258. tmp = RREG32(mmVCE_CLOCK_GATING_B);
  259. tmp |= 0xe70000;
  260. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  261. tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
  262. tmp |= 0xff000000;
  263. WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
  264. tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
  265. tmp &= ~0x3fc;
  266. WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
  267. WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
  268. } else {
  269. tmp = RREG32(mmVCE_CLOCK_GATING_B);
  270. tmp |= 0xe7;
  271. tmp &= ~0xe70000;
  272. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  273. tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
  274. tmp |= 0x1fe000;
  275. tmp &= ~0xff000000;
  276. WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
  277. tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
  278. tmp |= 0x3fc;
  279. WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
  280. }
  281. }
  282. static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated)
  283. {
  284. u32 orig, tmp;
  285. /* LMI_MC/LMI_UMC always set in dynamic,
  286. * set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {0, 0}
  287. */
  288. tmp = RREG32(mmVCE_CLOCK_GATING_B);
  289. tmp &= ~0x00060006;
  290. /* Exception for ECPU, IH, SEM, SYS blocks needs to be turned on/off by SW */
  291. if (gated) {
  292. tmp |= 0xe10000;
  293. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  294. } else {
  295. tmp |= 0xe1;
  296. tmp &= ~0xe10000;
  297. WREG32(mmVCE_CLOCK_GATING_B, tmp);
  298. }
  299. orig = tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
  300. tmp &= ~0x1fe000;
  301. tmp &= ~0xff000000;
  302. if (tmp != orig)
  303. WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
  304. orig = tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
  305. tmp &= ~0x3fc;
  306. if (tmp != orig)
  307. WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
  308. /* set VCE_UENC_REG_CLOCK_GATING always in dynamic mode */
  309. WREG32(mmVCE_UENC_REG_CLOCK_GATING, 0x00);
  310. if(gated)
  311. WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
  312. }
  313. static void vce_v2_0_enable_mgcg(struct amdgpu_device *adev, bool enable,
  314. bool sw_cg)
  315. {
  316. if (enable && (adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)) {
  317. if (sw_cg)
  318. vce_v2_0_set_sw_cg(adev, true);
  319. else
  320. vce_v2_0_set_dyn_cg(adev, true);
  321. } else {
  322. vce_v2_0_disable_cg(adev);
  323. if (sw_cg)
  324. vce_v2_0_set_sw_cg(adev, false);
  325. else
  326. vce_v2_0_set_dyn_cg(adev, false);
  327. }
  328. }
  329. static int vce_v2_0_early_init(void *handle)
  330. {
  331. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  332. adev->vce.num_rings = 2;
  333. vce_v2_0_set_ring_funcs(adev);
  334. vce_v2_0_set_irq_funcs(adev);
  335. return 0;
  336. }
  337. static int vce_v2_0_sw_init(void *handle)
  338. {
  339. struct amdgpu_ring *ring;
  340. int r, i;
  341. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  342. /* VCE */
  343. r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 167, &adev->vce.irq);
  344. if (r)
  345. return r;
  346. r = amdgpu_vce_sw_init(adev, VCE_V2_0_FW_SIZE +
  347. VCE_V2_0_STACK_SIZE + VCE_V2_0_DATA_SIZE);
  348. if (r)
  349. return r;
  350. r = amdgpu_vce_resume(adev);
  351. if (r)
  352. return r;
  353. for (i = 0; i < adev->vce.num_rings; i++) {
  354. ring = &adev->vce.ring[i];
  355. sprintf(ring->name, "vce%d", i);
  356. r = amdgpu_ring_init(adev, ring, 512,
  357. &adev->vce.irq, 0);
  358. if (r)
  359. return r;
  360. }
  361. return r;
  362. }
  363. static int vce_v2_0_sw_fini(void *handle)
  364. {
  365. int r;
  366. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  367. r = amdgpu_vce_suspend(adev);
  368. if (r)
  369. return r;
  370. return amdgpu_vce_sw_fini(adev);
  371. }
  372. static int vce_v2_0_hw_init(void *handle)
  373. {
  374. int r, i;
  375. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  376. amdgpu_asic_set_vce_clocks(adev, 10000, 10000);
  377. vce_v2_0_enable_mgcg(adev, true, false);
  378. for (i = 0; i < adev->vce.num_rings; i++)
  379. adev->vce.ring[i].ready = false;
  380. for (i = 0; i < adev->vce.num_rings; i++) {
  381. r = amdgpu_ring_test_ring(&adev->vce.ring[i]);
  382. if (r)
  383. return r;
  384. else
  385. adev->vce.ring[i].ready = true;
  386. }
  387. DRM_INFO("VCE initialized successfully.\n");
  388. return 0;
  389. }
  390. static int vce_v2_0_hw_fini(void *handle)
  391. {
  392. return 0;
  393. }
  394. static int vce_v2_0_suspend(void *handle)
  395. {
  396. int r;
  397. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  398. r = vce_v2_0_hw_fini(adev);
  399. if (r)
  400. return r;
  401. return amdgpu_vce_suspend(adev);
  402. }
  403. static int vce_v2_0_resume(void *handle)
  404. {
  405. int r;
  406. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  407. r = amdgpu_vce_resume(adev);
  408. if (r)
  409. return r;
  410. return vce_v2_0_hw_init(adev);
  411. }
  412. static int vce_v2_0_soft_reset(void *handle)
  413. {
  414. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  415. WREG32_FIELD(SRBM_SOFT_RESET, SOFT_RESET_VCE, 1);
  416. mdelay(5);
  417. return vce_v2_0_start(adev);
  418. }
  419. static int vce_v2_0_set_interrupt_state(struct amdgpu_device *adev,
  420. struct amdgpu_irq_src *source,
  421. unsigned type,
  422. enum amdgpu_interrupt_state state)
  423. {
  424. uint32_t val = 0;
  425. if (state == AMDGPU_IRQ_STATE_ENABLE)
  426. val |= VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK;
  427. WREG32_P(mmVCE_SYS_INT_EN, val, ~VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK);
  428. return 0;
  429. }
  430. static int vce_v2_0_process_interrupt(struct amdgpu_device *adev,
  431. struct amdgpu_irq_src *source,
  432. struct amdgpu_iv_entry *entry)
  433. {
  434. DRM_DEBUG("IH: VCE\n");
  435. switch (entry->src_data[0]) {
  436. case 0:
  437. case 1:
  438. amdgpu_fence_process(&adev->vce.ring[entry->src_data[0]]);
  439. break;
  440. default:
  441. DRM_ERROR("Unhandled interrupt: %d %d\n",
  442. entry->src_id, entry->src_data[0]);
  443. break;
  444. }
  445. return 0;
  446. }
  447. static int vce_v2_0_set_clockgating_state(void *handle,
  448. enum amd_clockgating_state state)
  449. {
  450. bool gate = false;
  451. bool sw_cg = false;
  452. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  453. if (state == AMD_CG_STATE_GATE) {
  454. gate = true;
  455. sw_cg = true;
  456. }
  457. vce_v2_0_enable_mgcg(adev, gate, sw_cg);
  458. return 0;
  459. }
  460. static int vce_v2_0_set_powergating_state(void *handle,
  461. enum amd_powergating_state state)
  462. {
  463. /* This doesn't actually powergate the VCE block.
  464. * That's done in the dpm code via the SMC. This
  465. * just re-inits the block as necessary. The actual
  466. * gating still happens in the dpm code. We should
  467. * revisit this when there is a cleaner line between
  468. * the smc and the hw blocks
  469. */
  470. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  471. if (state == AMD_PG_STATE_GATE)
  472. return vce_v2_0_stop(adev);
  473. else
  474. return vce_v2_0_start(adev);
  475. }
  476. static const struct amd_ip_funcs vce_v2_0_ip_funcs = {
  477. .name = "vce_v2_0",
  478. .early_init = vce_v2_0_early_init,
  479. .late_init = NULL,
  480. .sw_init = vce_v2_0_sw_init,
  481. .sw_fini = vce_v2_0_sw_fini,
  482. .hw_init = vce_v2_0_hw_init,
  483. .hw_fini = vce_v2_0_hw_fini,
  484. .suspend = vce_v2_0_suspend,
  485. .resume = vce_v2_0_resume,
  486. .is_idle = vce_v2_0_is_idle,
  487. .wait_for_idle = vce_v2_0_wait_for_idle,
  488. .soft_reset = vce_v2_0_soft_reset,
  489. .set_clockgating_state = vce_v2_0_set_clockgating_state,
  490. .set_powergating_state = vce_v2_0_set_powergating_state,
  491. };
  492. static const struct amdgpu_ring_funcs vce_v2_0_ring_funcs = {
  493. .type = AMDGPU_RING_TYPE_VCE,
  494. .align_mask = 0xf,
  495. .nop = VCE_CMD_NO_OP,
  496. .support_64bit_ptrs = false,
  497. .get_rptr = vce_v2_0_ring_get_rptr,
  498. .get_wptr = vce_v2_0_ring_get_wptr,
  499. .set_wptr = vce_v2_0_ring_set_wptr,
  500. .parse_cs = amdgpu_vce_ring_parse_cs,
  501. .emit_frame_size = 6, /* amdgpu_vce_ring_emit_fence x1 no user fence */
  502. .emit_ib_size = 4, /* amdgpu_vce_ring_emit_ib */
  503. .emit_ib = amdgpu_vce_ring_emit_ib,
  504. .emit_fence = amdgpu_vce_ring_emit_fence,
  505. .test_ring = amdgpu_vce_ring_test_ring,
  506. .test_ib = amdgpu_vce_ring_test_ib,
  507. .insert_nop = amdgpu_ring_insert_nop,
  508. .pad_ib = amdgpu_ring_generic_pad_ib,
  509. .begin_use = amdgpu_vce_ring_begin_use,
  510. .end_use = amdgpu_vce_ring_end_use,
  511. };
  512. static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev)
  513. {
  514. int i;
  515. for (i = 0; i < adev->vce.num_rings; i++)
  516. adev->vce.ring[i].funcs = &vce_v2_0_ring_funcs;
  517. }
  518. static const struct amdgpu_irq_src_funcs vce_v2_0_irq_funcs = {
  519. .set = vce_v2_0_set_interrupt_state,
  520. .process = vce_v2_0_process_interrupt,
  521. };
  522. static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev)
  523. {
  524. adev->vce.irq.num_types = 1;
  525. adev->vce.irq.funcs = &vce_v2_0_irq_funcs;
  526. };
  527. const struct amdgpu_ip_block_version vce_v2_0_ip_block =
  528. {
  529. .type = AMD_IP_BLOCK_TYPE_VCE,
  530. .major = 2,
  531. .minor = 0,
  532. .rev = 0,
  533. .funcs = &vce_v2_0_ip_funcs,
  534. };