vce_v3_0.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /*
  2. * Copyright 2014 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 "vid.h"
  32. #include "vce/vce_3_0_d.h"
  33. #include "vce/vce_3_0_sh_mask.h"
  34. #include "oss/oss_2_0_d.h"
  35. #include "oss/oss_2_0_sh_mask.h"
  36. #include "gca/gfx_8_0_d.h"
  37. #define GRBM_GFX_INDEX__VCE_INSTANCE__SHIFT 0x04
  38. #define GRBM_GFX_INDEX__VCE_INSTANCE_MASK 0x10
  39. #define VCE_V3_0_FW_SIZE (384 * 1024)
  40. #define VCE_V3_0_STACK_SIZE (64 * 1024)
  41. #define VCE_V3_0_DATA_SIZE ((16 * 1024 * AMDGPU_MAX_VCE_HANDLES) + (52 * 1024))
  42. static void vce_v3_0_mc_resume(struct amdgpu_device *adev, int idx);
  43. static void vce_v3_0_set_ring_funcs(struct amdgpu_device *adev);
  44. static void vce_v3_0_set_irq_funcs(struct amdgpu_device *adev);
  45. /**
  46. * vce_v3_0_ring_get_rptr - get read pointer
  47. *
  48. * @ring: amdgpu_ring pointer
  49. *
  50. * Returns the current hardware read pointer
  51. */
  52. static uint32_t vce_v3_0_ring_get_rptr(struct amdgpu_ring *ring)
  53. {
  54. struct amdgpu_device *adev = ring->adev;
  55. if (ring == &adev->vce.ring[0])
  56. return RREG32(mmVCE_RB_RPTR);
  57. else
  58. return RREG32(mmVCE_RB_RPTR2);
  59. }
  60. /**
  61. * vce_v3_0_ring_get_wptr - get write pointer
  62. *
  63. * @ring: amdgpu_ring pointer
  64. *
  65. * Returns the current hardware write pointer
  66. */
  67. static uint32_t vce_v3_0_ring_get_wptr(struct amdgpu_ring *ring)
  68. {
  69. struct amdgpu_device *adev = ring->adev;
  70. if (ring == &adev->vce.ring[0])
  71. return RREG32(mmVCE_RB_WPTR);
  72. else
  73. return RREG32(mmVCE_RB_WPTR2);
  74. }
  75. /**
  76. * vce_v3_0_ring_set_wptr - set write pointer
  77. *
  78. * @ring: amdgpu_ring pointer
  79. *
  80. * Commits the write pointer to the hardware
  81. */
  82. static void vce_v3_0_ring_set_wptr(struct amdgpu_ring *ring)
  83. {
  84. struct amdgpu_device *adev = ring->adev;
  85. if (ring == &adev->vce.ring[0])
  86. WREG32(mmVCE_RB_WPTR, ring->wptr);
  87. else
  88. WREG32(mmVCE_RB_WPTR2, ring->wptr);
  89. }
  90. /**
  91. * vce_v3_0_start - start VCE block
  92. *
  93. * @adev: amdgpu_device pointer
  94. *
  95. * Setup and start the VCE block
  96. */
  97. static int vce_v3_0_start(struct amdgpu_device *adev)
  98. {
  99. struct amdgpu_ring *ring;
  100. int idx, i, j, r;
  101. mutex_lock(&adev->grbm_idx_mutex);
  102. for (idx = 0; idx < 2; ++idx) {
  103. if(idx == 0)
  104. WREG32_P(mmGRBM_GFX_INDEX, 0,
  105. ~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
  106. else
  107. WREG32_P(mmGRBM_GFX_INDEX,
  108. GRBM_GFX_INDEX__VCE_INSTANCE_MASK,
  109. ~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
  110. vce_v3_0_mc_resume(adev, idx);
  111. /* set BUSY flag */
  112. WREG32_P(mmVCE_STATUS, 1, ~1);
  113. WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK,
  114. ~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,
  120. ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  121. for (i = 0; i < 10; ++i) {
  122. uint32_t status;
  123. for (j = 0; j < 100; ++j) {
  124. status = RREG32(mmVCE_STATUS);
  125. if (status & 2)
  126. break;
  127. mdelay(10);
  128. }
  129. r = 0;
  130. if (status & 2)
  131. break;
  132. DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
  133. WREG32_P(mmVCE_SOFT_RESET,
  134. VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
  135. ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  136. mdelay(10);
  137. WREG32_P(mmVCE_SOFT_RESET, 0,
  138. ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
  139. mdelay(10);
  140. r = -1;
  141. }
  142. /* clear BUSY flag */
  143. WREG32_P(mmVCE_STATUS, 0, ~1);
  144. if (r) {
  145. DRM_ERROR("VCE not responding, giving up!!!\n");
  146. mutex_unlock(&adev->grbm_idx_mutex);
  147. return r;
  148. }
  149. }
  150. WREG32_P(mmGRBM_GFX_INDEX, 0, ~GRBM_GFX_INDEX__VCE_INSTANCE_MASK);
  151. mutex_unlock(&adev->grbm_idx_mutex);
  152. ring = &adev->vce.ring[0];
  153. WREG32(mmVCE_RB_RPTR, ring->wptr);
  154. WREG32(mmVCE_RB_WPTR, ring->wptr);
  155. WREG32(mmVCE_RB_BASE_LO, ring->gpu_addr);
  156. WREG32(mmVCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
  157. WREG32(mmVCE_RB_SIZE, ring->ring_size / 4);
  158. ring = &adev->vce.ring[1];
  159. WREG32(mmVCE_RB_RPTR2, ring->wptr);
  160. WREG32(mmVCE_RB_WPTR2, ring->wptr);
  161. WREG32(mmVCE_RB_BASE_LO2, ring->gpu_addr);
  162. WREG32(mmVCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
  163. WREG32(mmVCE_RB_SIZE2, ring->ring_size / 4);
  164. return 0;
  165. }
  166. static int vce_v3_0_early_init(void *handle)
  167. {
  168. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  169. vce_v3_0_set_ring_funcs(adev);
  170. vce_v3_0_set_irq_funcs(adev);
  171. return 0;
  172. }
  173. static int vce_v3_0_sw_init(void *handle)
  174. {
  175. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  176. struct amdgpu_ring *ring;
  177. int r;
  178. /* VCE */
  179. r = amdgpu_irq_add_id(adev, 167, &adev->vce.irq);
  180. if (r)
  181. return r;
  182. r = amdgpu_vce_sw_init(adev, VCE_V3_0_FW_SIZE +
  183. (VCE_V3_0_STACK_SIZE + VCE_V3_0_DATA_SIZE) * 2);
  184. if (r)
  185. return r;
  186. r = amdgpu_vce_resume(adev);
  187. if (r)
  188. return r;
  189. ring = &adev->vce.ring[0];
  190. sprintf(ring->name, "vce0");
  191. r = amdgpu_ring_init(adev, ring, 4096, VCE_CMD_NO_OP, 0xf,
  192. &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE);
  193. if (r)
  194. return r;
  195. ring = &adev->vce.ring[1];
  196. sprintf(ring->name, "vce1");
  197. r = amdgpu_ring_init(adev, ring, 4096, VCE_CMD_NO_OP, 0xf,
  198. &adev->vce.irq, 0, AMDGPU_RING_TYPE_VCE);
  199. if (r)
  200. return r;
  201. return r;
  202. }
  203. static int vce_v3_0_sw_fini(void *handle)
  204. {
  205. int r;
  206. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  207. r = amdgpu_vce_suspend(adev);
  208. if (r)
  209. return r;
  210. r = amdgpu_vce_sw_fini(adev);
  211. if (r)
  212. return r;
  213. return r;
  214. }
  215. static int vce_v3_0_hw_init(void *handle)
  216. {
  217. struct amdgpu_ring *ring;
  218. int r;
  219. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  220. r = vce_v3_0_start(adev);
  221. if (r)
  222. return r;
  223. ring = &adev->vce.ring[0];
  224. ring->ready = true;
  225. r = amdgpu_ring_test_ring(ring);
  226. if (r) {
  227. ring->ready = false;
  228. return r;
  229. }
  230. ring = &adev->vce.ring[1];
  231. ring->ready = true;
  232. r = amdgpu_ring_test_ring(ring);
  233. if (r) {
  234. ring->ready = false;
  235. return r;
  236. }
  237. DRM_INFO("VCE initialized successfully.\n");
  238. return 0;
  239. }
  240. static int vce_v3_0_hw_fini(void *handle)
  241. {
  242. return 0;
  243. }
  244. static int vce_v3_0_suspend(void *handle)
  245. {
  246. int r;
  247. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  248. r = vce_v3_0_hw_fini(adev);
  249. if (r)
  250. return r;
  251. r = amdgpu_vce_suspend(adev);
  252. if (r)
  253. return r;
  254. return r;
  255. }
  256. static int vce_v3_0_resume(void *handle)
  257. {
  258. int r;
  259. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  260. r = amdgpu_vce_resume(adev);
  261. if (r)
  262. return r;
  263. r = vce_v3_0_hw_init(adev);
  264. if (r)
  265. return r;
  266. return r;
  267. }
  268. static void vce_v3_0_mc_resume(struct amdgpu_device *adev, int idx)
  269. {
  270. uint32_t offset, size;
  271. WREG32_P(mmVCE_CLOCK_GATING_A, 0, ~(1 << 16));
  272. WREG32_P(mmVCE_UENC_CLOCK_GATING, 0x1FF000, ~0xFF9FF000);
  273. WREG32_P(mmVCE_UENC_REG_CLOCK_GATING, 0x3F, ~0x3F);
  274. WREG32(mmVCE_CLOCK_GATING_B, 0xf7);
  275. WREG32(mmVCE_LMI_CTRL, 0x00398000);
  276. WREG32_P(mmVCE_LMI_CACHE_CTRL, 0x0, ~0x1);
  277. WREG32(mmVCE_LMI_SWAP_CNTL, 0);
  278. WREG32(mmVCE_LMI_SWAP_CNTL1, 0);
  279. WREG32(mmVCE_LMI_VM_CTRL, 0);
  280. WREG32(mmVCE_LMI_VCPU_CACHE_40BIT_BAR, (adev->vce.gpu_addr >> 8));
  281. offset = AMDGPU_VCE_FIRMWARE_OFFSET;
  282. size = VCE_V3_0_FW_SIZE;
  283. WREG32(mmVCE_VCPU_CACHE_OFFSET0, offset & 0x7fffffff);
  284. WREG32(mmVCE_VCPU_CACHE_SIZE0, size);
  285. if (idx == 0) {
  286. offset += size;
  287. size = VCE_V3_0_STACK_SIZE;
  288. WREG32(mmVCE_VCPU_CACHE_OFFSET1, offset & 0x7fffffff);
  289. WREG32(mmVCE_VCPU_CACHE_SIZE1, size);
  290. offset += size;
  291. size = VCE_V3_0_DATA_SIZE;
  292. WREG32(mmVCE_VCPU_CACHE_OFFSET2, offset & 0x7fffffff);
  293. WREG32(mmVCE_VCPU_CACHE_SIZE2, size);
  294. } else {
  295. offset += size + VCE_V3_0_STACK_SIZE + VCE_V3_0_DATA_SIZE;
  296. size = VCE_V3_0_STACK_SIZE;
  297. WREG32(mmVCE_VCPU_CACHE_OFFSET1, offset & 0xfffffff);
  298. WREG32(mmVCE_VCPU_CACHE_SIZE1, size);
  299. offset += size;
  300. size = VCE_V3_0_DATA_SIZE;
  301. WREG32(mmVCE_VCPU_CACHE_OFFSET2, offset & 0xfffffff);
  302. WREG32(mmVCE_VCPU_CACHE_SIZE2, size);
  303. }
  304. WREG32_P(mmVCE_LMI_CTRL2, 0x0, ~0x100);
  305. WREG32_P(mmVCE_SYS_INT_EN, VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK,
  306. ~VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK);
  307. }
  308. static bool vce_v3_0_is_idle(void *handle)
  309. {
  310. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  311. return !(RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK);
  312. }
  313. static int vce_v3_0_wait_for_idle(void *handle)
  314. {
  315. unsigned i;
  316. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  317. for (i = 0; i < adev->usec_timeout; i++) {
  318. if (!(RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK))
  319. return 0;
  320. }
  321. return -ETIMEDOUT;
  322. }
  323. static int vce_v3_0_soft_reset(void *handle)
  324. {
  325. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  326. WREG32_P(mmSRBM_SOFT_RESET, SRBM_SOFT_RESET__SOFT_RESET_VCE_MASK,
  327. ~SRBM_SOFT_RESET__SOFT_RESET_VCE_MASK);
  328. mdelay(5);
  329. return vce_v3_0_start(adev);
  330. }
  331. static void vce_v3_0_print_status(void *handle)
  332. {
  333. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  334. dev_info(adev->dev, "VCE 3.0 registers\n");
  335. dev_info(adev->dev, " VCE_STATUS=0x%08X\n",
  336. RREG32(mmVCE_STATUS));
  337. dev_info(adev->dev, " VCE_VCPU_CNTL=0x%08X\n",
  338. RREG32(mmVCE_VCPU_CNTL));
  339. dev_info(adev->dev, " VCE_VCPU_CACHE_OFFSET0=0x%08X\n",
  340. RREG32(mmVCE_VCPU_CACHE_OFFSET0));
  341. dev_info(adev->dev, " VCE_VCPU_CACHE_SIZE0=0x%08X\n",
  342. RREG32(mmVCE_VCPU_CACHE_SIZE0));
  343. dev_info(adev->dev, " VCE_VCPU_CACHE_OFFSET1=0x%08X\n",
  344. RREG32(mmVCE_VCPU_CACHE_OFFSET1));
  345. dev_info(adev->dev, " VCE_VCPU_CACHE_SIZE1=0x%08X\n",
  346. RREG32(mmVCE_VCPU_CACHE_SIZE1));
  347. dev_info(adev->dev, " VCE_VCPU_CACHE_OFFSET2=0x%08X\n",
  348. RREG32(mmVCE_VCPU_CACHE_OFFSET2));
  349. dev_info(adev->dev, " VCE_VCPU_CACHE_SIZE2=0x%08X\n",
  350. RREG32(mmVCE_VCPU_CACHE_SIZE2));
  351. dev_info(adev->dev, " VCE_SOFT_RESET=0x%08X\n",
  352. RREG32(mmVCE_SOFT_RESET));
  353. dev_info(adev->dev, " VCE_RB_BASE_LO2=0x%08X\n",
  354. RREG32(mmVCE_RB_BASE_LO2));
  355. dev_info(adev->dev, " VCE_RB_BASE_HI2=0x%08X\n",
  356. RREG32(mmVCE_RB_BASE_HI2));
  357. dev_info(adev->dev, " VCE_RB_SIZE2=0x%08X\n",
  358. RREG32(mmVCE_RB_SIZE2));
  359. dev_info(adev->dev, " VCE_RB_RPTR2=0x%08X\n",
  360. RREG32(mmVCE_RB_RPTR2));
  361. dev_info(adev->dev, " VCE_RB_WPTR2=0x%08X\n",
  362. RREG32(mmVCE_RB_WPTR2));
  363. dev_info(adev->dev, " VCE_RB_BASE_LO=0x%08X\n",
  364. RREG32(mmVCE_RB_BASE_LO));
  365. dev_info(adev->dev, " VCE_RB_BASE_HI=0x%08X\n",
  366. RREG32(mmVCE_RB_BASE_HI));
  367. dev_info(adev->dev, " VCE_RB_SIZE=0x%08X\n",
  368. RREG32(mmVCE_RB_SIZE));
  369. dev_info(adev->dev, " VCE_RB_RPTR=0x%08X\n",
  370. RREG32(mmVCE_RB_RPTR));
  371. dev_info(adev->dev, " VCE_RB_WPTR=0x%08X\n",
  372. RREG32(mmVCE_RB_WPTR));
  373. dev_info(adev->dev, " VCE_CLOCK_GATING_A=0x%08X\n",
  374. RREG32(mmVCE_CLOCK_GATING_A));
  375. dev_info(adev->dev, " VCE_CLOCK_GATING_B=0x%08X\n",
  376. RREG32(mmVCE_CLOCK_GATING_B));
  377. dev_info(adev->dev, " VCE_UENC_CLOCK_GATING=0x%08X\n",
  378. RREG32(mmVCE_UENC_CLOCK_GATING));
  379. dev_info(adev->dev, " VCE_UENC_REG_CLOCK_GATING=0x%08X\n",
  380. RREG32(mmVCE_UENC_REG_CLOCK_GATING));
  381. dev_info(adev->dev, " VCE_SYS_INT_EN=0x%08X\n",
  382. RREG32(mmVCE_SYS_INT_EN));
  383. dev_info(adev->dev, " VCE_LMI_CTRL2=0x%08X\n",
  384. RREG32(mmVCE_LMI_CTRL2));
  385. dev_info(adev->dev, " VCE_LMI_CTRL=0x%08X\n",
  386. RREG32(mmVCE_LMI_CTRL));
  387. dev_info(adev->dev, " VCE_LMI_VM_CTRL=0x%08X\n",
  388. RREG32(mmVCE_LMI_VM_CTRL));
  389. dev_info(adev->dev, " VCE_LMI_SWAP_CNTL=0x%08X\n",
  390. RREG32(mmVCE_LMI_SWAP_CNTL));
  391. dev_info(adev->dev, " VCE_LMI_SWAP_CNTL1=0x%08X\n",
  392. RREG32(mmVCE_LMI_SWAP_CNTL1));
  393. dev_info(adev->dev, " VCE_LMI_CACHE_CTRL=0x%08X\n",
  394. RREG32(mmVCE_LMI_CACHE_CTRL));
  395. }
  396. static int vce_v3_0_set_interrupt_state(struct amdgpu_device *adev,
  397. struct amdgpu_irq_src *source,
  398. unsigned type,
  399. enum amdgpu_interrupt_state state)
  400. {
  401. uint32_t val = 0;
  402. if (state == AMDGPU_IRQ_STATE_ENABLE)
  403. val |= VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK;
  404. WREG32_P(mmVCE_SYS_INT_EN, val, ~VCE_SYS_INT_EN__VCE_SYS_INT_TRAP_INTERRUPT_EN_MASK);
  405. return 0;
  406. }
  407. static int vce_v3_0_process_interrupt(struct amdgpu_device *adev,
  408. struct amdgpu_irq_src *source,
  409. struct amdgpu_iv_entry *entry)
  410. {
  411. DRM_DEBUG("IH: VCE\n");
  412. switch (entry->src_data) {
  413. case 0:
  414. amdgpu_fence_process(&adev->vce.ring[0]);
  415. break;
  416. case 1:
  417. amdgpu_fence_process(&adev->vce.ring[1]);
  418. break;
  419. default:
  420. DRM_ERROR("Unhandled interrupt: %d %d\n",
  421. entry->src_id, entry->src_data);
  422. break;
  423. }
  424. return 0;
  425. }
  426. static int vce_v3_0_set_clockgating_state(void *handle,
  427. enum amd_clockgating_state state)
  428. {
  429. return 0;
  430. }
  431. static int vce_v3_0_set_powergating_state(void *handle,
  432. enum amd_powergating_state state)
  433. {
  434. /* This doesn't actually powergate the VCE block.
  435. * That's done in the dpm code via the SMC. This
  436. * just re-inits the block as necessary. The actual
  437. * gating still happens in the dpm code. We should
  438. * revisit this when there is a cleaner line between
  439. * the smc and the hw blocks
  440. */
  441. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  442. if (state == AMD_PG_STATE_GATE)
  443. /* XXX do we need a vce_v3_0_stop()? */
  444. return 0;
  445. else
  446. return vce_v3_0_start(adev);
  447. }
  448. const struct amd_ip_funcs vce_v3_0_ip_funcs = {
  449. .early_init = vce_v3_0_early_init,
  450. .late_init = NULL,
  451. .sw_init = vce_v3_0_sw_init,
  452. .sw_fini = vce_v3_0_sw_fini,
  453. .hw_init = vce_v3_0_hw_init,
  454. .hw_fini = vce_v3_0_hw_fini,
  455. .suspend = vce_v3_0_suspend,
  456. .resume = vce_v3_0_resume,
  457. .is_idle = vce_v3_0_is_idle,
  458. .wait_for_idle = vce_v3_0_wait_for_idle,
  459. .soft_reset = vce_v3_0_soft_reset,
  460. .print_status = vce_v3_0_print_status,
  461. .set_clockgating_state = vce_v3_0_set_clockgating_state,
  462. .set_powergating_state = vce_v3_0_set_powergating_state,
  463. };
  464. static const struct amdgpu_ring_funcs vce_v3_0_ring_funcs = {
  465. .get_rptr = vce_v3_0_ring_get_rptr,
  466. .get_wptr = vce_v3_0_ring_get_wptr,
  467. .set_wptr = vce_v3_0_ring_set_wptr,
  468. .parse_cs = amdgpu_vce_ring_parse_cs,
  469. .emit_ib = amdgpu_vce_ring_emit_ib,
  470. .emit_fence = amdgpu_vce_ring_emit_fence,
  471. .emit_semaphore = amdgpu_vce_ring_emit_semaphore,
  472. .test_ring = amdgpu_vce_ring_test_ring,
  473. .test_ib = amdgpu_vce_ring_test_ib,
  474. .is_lockup = amdgpu_ring_test_lockup,
  475. };
  476. static void vce_v3_0_set_ring_funcs(struct amdgpu_device *adev)
  477. {
  478. adev->vce.ring[0].funcs = &vce_v3_0_ring_funcs;
  479. adev->vce.ring[1].funcs = &vce_v3_0_ring_funcs;
  480. }
  481. static const struct amdgpu_irq_src_funcs vce_v3_0_irq_funcs = {
  482. .set = vce_v3_0_set_interrupt_state,
  483. .process = vce_v3_0_process_interrupt,
  484. };
  485. static void vce_v3_0_set_irq_funcs(struct amdgpu_device *adev)
  486. {
  487. adev->vce.irq.num_types = 1;
  488. adev->vce.irq.funcs = &vce_v3_0_irq_funcs;
  489. };