drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c- Extension
.c- Size
- 34884 bytes
- Lines
- 1385
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/firmware.hlinux/module.hdrm/drm.hdrm/drm_drv.hamdgpu.hamdgpu_pm.hamdgpu_uvd.hamdgpu_cs.hcikd.huvd/uvd_4_2_d.hamdgpu_ras.h
Detected Declarations
struct amdgpu_uvd_cs_ctxfunction amdgpu_uvd_create_msg_bo_helperfunction amdgpu_uvd_sw_initfunction amdgpu_uvd_sw_finifunction amdgpu_uvd_entity_initfunction amdgpu_uvd_prepare_suspendfunction amdgpu_uvd_suspendfunction amdgpu_uvd_resumefunction amdgpu_uvd_free_handlesfunction amdgpu_uvd_force_into_uvd_segmentfunction amdgpu_uvd_get_addr_from_ctxfunction amdgpu_uvd_cs_pass1function amdgpu_uvd_cs_msg_decodefunction amdgpu_uvd_cs_msgfunction amdgpu_uvd_cs_pass2function amdgpu_uvd_cs_regfunction amdgpu_uvd_cs_packetsfunction amdgpu_uvd_ring_parse_csfunction amdgpu_uvd_send_msgfunction amdgpu_uvd_get_create_msgfunction amdgpu_uvd_get_destroy_msgfunction amdgpu_uvd_idle_work_handlerfunction amdgpu_uvd_ring_begin_usefunction amdgpu_uvd_ring_end_usefunction amdgpu_uvd_ring_test_ibfunction amdgpu_uvd_used_handles
Annotated Snippet
struct amdgpu_uvd_cs_ctx {
struct amdgpu_cs_parser *parser;
unsigned int reg, count;
unsigned int data0, data1;
unsigned int idx;
struct amdgpu_ib *ib;
/* does the IB has a msg command */
bool has_msg_cmd;
/* minimum buffer sizes */
unsigned int *buf_sizes;
};
#ifdef CONFIG_DRM_AMDGPU_SI
MODULE_FIRMWARE(FIRMWARE_TAHITI);
MODULE_FIRMWARE(FIRMWARE_VERDE);
MODULE_FIRMWARE(FIRMWARE_PITCAIRN);
MODULE_FIRMWARE(FIRMWARE_OLAND);
#endif
#ifdef CONFIG_DRM_AMDGPU_CIK
MODULE_FIRMWARE(FIRMWARE_BONAIRE);
MODULE_FIRMWARE(FIRMWARE_KABINI);
MODULE_FIRMWARE(FIRMWARE_KAVERI);
MODULE_FIRMWARE(FIRMWARE_HAWAII);
MODULE_FIRMWARE(FIRMWARE_MULLINS);
#endif
MODULE_FIRMWARE(FIRMWARE_TONGA);
MODULE_FIRMWARE(FIRMWARE_CARRIZO);
MODULE_FIRMWARE(FIRMWARE_FIJI);
MODULE_FIRMWARE(FIRMWARE_STONEY);
MODULE_FIRMWARE(FIRMWARE_POLARIS10);
MODULE_FIRMWARE(FIRMWARE_POLARIS11);
MODULE_FIRMWARE(FIRMWARE_POLARIS12);
MODULE_FIRMWARE(FIRMWARE_VEGAM);
MODULE_FIRMWARE(FIRMWARE_VEGA10);
MODULE_FIRMWARE(FIRMWARE_VEGA12);
MODULE_FIRMWARE(FIRMWARE_VEGA20);
static void amdgpu_uvd_idle_work_handler(struct work_struct *work);
static void amdgpu_uvd_force_into_uvd_segment(struct amdgpu_bo *abo);
static int amdgpu_uvd_create_msg_bo_helper(struct amdgpu_device *adev,
uint32_t size,
struct amdgpu_bo **bo_ptr)
{
struct ttm_operation_ctx ctx = { true, false };
struct amdgpu_bo *bo = NULL;
void *addr;
int r;
r = amdgpu_bo_create_reserved(adev, size, PAGE_SIZE,
AMDGPU_GEM_DOMAIN_GTT,
&bo, NULL, &addr);
if (r)
return r;
if (adev->uvd.address_64_bit)
goto succ;
amdgpu_bo_kunmap(bo);
amdgpu_bo_unpin(bo);
amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_VRAM);
amdgpu_uvd_force_into_uvd_segment(bo);
r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
if (r)
goto err;
r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_VRAM);
if (r)
goto err_pin;
r = amdgpu_bo_kmap(bo, &addr);
if (r)
goto err_kmap;
succ:
amdgpu_bo_unreserve(bo);
*bo_ptr = bo;
return 0;
err_kmap:
amdgpu_bo_unpin(bo);
err_pin:
err:
amdgpu_bo_unreserve(bo);
amdgpu_bo_unref(&bo);
return r;
}
int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
{
unsigned long bo_size;
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `drm/drm.h`, `drm/drm_drv.h`, `amdgpu.h`, `amdgpu_pm.h`, `amdgpu_uvd.h`, `amdgpu_cs.h`.
- Detected declarations: `struct amdgpu_uvd_cs_ctx`, `function amdgpu_uvd_create_msg_bo_helper`, `function amdgpu_uvd_sw_init`, `function amdgpu_uvd_sw_fini`, `function amdgpu_uvd_entity_init`, `function amdgpu_uvd_prepare_suspend`, `function amdgpu_uvd_suspend`, `function amdgpu_uvd_resume`, `function amdgpu_uvd_free_handles`, `function amdgpu_uvd_force_into_uvd_segment`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.