18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2014 Advanced Micro Devices, Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#ifndef __AMDGPU_VCE_H__ 258c2ecf20Sopenharmony_ci#define __AMDGPU_VCE_H__ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#define AMDGPU_MAX_VCE_HANDLES 16 288c2ecf20Sopenharmony_ci#define AMDGPU_VCE_FIRMWARE_OFFSET 256 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define AMDGPU_VCE_HARVEST_VCE0 (1 << 0) 318c2ecf20Sopenharmony_ci#define AMDGPU_VCE_HARVEST_VCE1 (1 << 1) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define AMDGPU_VCE_FW_53_45 ((53 << 24) | (45 << 16)) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct amdgpu_vce { 368c2ecf20Sopenharmony_ci struct amdgpu_bo *vcpu_bo; 378c2ecf20Sopenharmony_ci uint64_t gpu_addr; 388c2ecf20Sopenharmony_ci void *cpu_addr; 398c2ecf20Sopenharmony_ci void *saved_bo; 408c2ecf20Sopenharmony_ci unsigned fw_version; 418c2ecf20Sopenharmony_ci unsigned fb_version; 428c2ecf20Sopenharmony_ci atomic_t handles[AMDGPU_MAX_VCE_HANDLES]; 438c2ecf20Sopenharmony_ci struct drm_file *filp[AMDGPU_MAX_VCE_HANDLES]; 448c2ecf20Sopenharmony_ci uint32_t img_size[AMDGPU_MAX_VCE_HANDLES]; 458c2ecf20Sopenharmony_ci struct delayed_work idle_work; 468c2ecf20Sopenharmony_ci struct mutex idle_mutex; 478c2ecf20Sopenharmony_ci const struct firmware *fw; /* VCE firmware */ 488c2ecf20Sopenharmony_ci struct amdgpu_ring ring[AMDGPU_MAX_VCE_RINGS]; 498c2ecf20Sopenharmony_ci struct amdgpu_irq_src irq; 508c2ecf20Sopenharmony_ci unsigned harvest_config; 518c2ecf20Sopenharmony_ci struct drm_sched_entity entity; 528c2ecf20Sopenharmony_ci uint32_t srbm_soft_reset; 538c2ecf20Sopenharmony_ci unsigned num_rings; 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ciint amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size); 578c2ecf20Sopenharmony_ciint amdgpu_vce_sw_fini(struct amdgpu_device *adev); 588c2ecf20Sopenharmony_ciint amdgpu_vce_entity_init(struct amdgpu_device *adev); 598c2ecf20Sopenharmony_ciint amdgpu_vce_suspend(struct amdgpu_device *adev); 608c2ecf20Sopenharmony_ciint amdgpu_vce_resume(struct amdgpu_device *adev); 618c2ecf20Sopenharmony_civoid amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp); 628c2ecf20Sopenharmony_ciint amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx); 638c2ecf20Sopenharmony_ciint amdgpu_vce_ring_parse_cs_vm(struct amdgpu_cs_parser *p, uint32_t ib_idx); 648c2ecf20Sopenharmony_civoid amdgpu_vce_ring_emit_ib(struct amdgpu_ring *ring, struct amdgpu_job *job, 658c2ecf20Sopenharmony_ci struct amdgpu_ib *ib, uint32_t flags); 668c2ecf20Sopenharmony_civoid amdgpu_vce_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, 678c2ecf20Sopenharmony_ci unsigned flags); 688c2ecf20Sopenharmony_ciint amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring); 698c2ecf20Sopenharmony_ciint amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout); 708c2ecf20Sopenharmony_civoid amdgpu_vce_ring_begin_use(struct amdgpu_ring *ring); 718c2ecf20Sopenharmony_civoid amdgpu_vce_ring_end_use(struct amdgpu_ring *ring); 728c2ecf20Sopenharmony_ciunsigned amdgpu_vce_ring_get_emit_ib_size(struct amdgpu_ring *ring); 738c2ecf20Sopenharmony_ciunsigned amdgpu_vce_ring_get_dma_frame_size(struct amdgpu_ring *ring); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#endif 76