drivers/gpu/drm/radeon/radeon_uvd.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/radeon/radeon_uvd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/radeon/radeon_uvd.c- Extension
.c- Size
- 25789 bytes
- Lines
- 1042
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/firmware.hlinux/module.hdrm/drm.hradeon.hradeon_ucode.hr600d.h
Detected Declarations
function radeon_uvd_initfunction radeon_uvd_finifunction radeon_uvd_suspendfunction radeon_uvd_resumefunction radeon_uvd_force_into_uvd_segmentfunction radeon_uvd_free_handlesfunction radeon_uvd_cs_msg_decodefunction radeon_uvd_validate_codecfunction radeon_uvd_cs_msgfunction radeon_uvd_cs_relocfunction radeon_uvd_cs_regfunction radeon_uvd_cs_parsefunction radeon_uvd_send_msgfunction radeon_uvd_get_create_msgfunction radeon_uvd_get_destroy_msgfunction radeon_uvd_count_handlesfunction radeon_uvd_idle_work_handlerfunction radeon_uvd_note_usagefunction radeon_uvd_calc_upll_post_divfunction UPLLfunction radeon_uvd_send_upll_ctlreq
Annotated Snippet
if (r) {
dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
fw_name);
} else {
struct common_firmware_header *hdr = (void *)rdev->uvd_fw->data;
unsigned version_major, version_minor, family_id;
r = radeon_ucode_validate(rdev->uvd_fw);
if (r)
return r;
rdev->uvd.fw_header_present = true;
family_id = (__force u32)(hdr->ucode_version) & 0xff;
version_major = (le32_to_cpu((__force __le32)(hdr->ucode_version))
>> 24) & 0xff;
version_minor = (le32_to_cpu((__force __le32)(hdr->ucode_version))
>> 8) & 0xff;
DRM_INFO("Found UVD firmware Version: %u.%u Family ID: %u\n",
version_major, version_minor, family_id);
/*
* Limit the number of UVD handles depending on
* microcode major and minor versions.
*/
if ((version_major >= 0x01) && (version_minor >= 0x37))
rdev->uvd.max_handles = RADEON_MAX_UVD_HANDLES;
}
}
/*
* In case there is only legacy firmware, or we encounter an error
* while loading the new firmware, we fall back to loading the legacy
* firmware now.
*/
if (!fw_name || r) {
r = request_firmware(&rdev->uvd_fw, legacy_fw_name, rdev->dev);
if (r) {
dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
legacy_fw_name);
return r;
}
}
bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) +
RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE +
RADEON_UVD_SESSION_SIZE * rdev->uvd.max_handles;
r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_VRAM, 0, NULL,
NULL, &rdev->uvd.vcpu_bo);
if (r) {
dev_err(rdev->dev, "(%d) failed to allocate UVD bo\n", r);
return r;
}
r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false);
if (r) {
radeon_bo_unref(&rdev->uvd.vcpu_bo);
dev_err(rdev->dev, "(%d) failed to reserve UVD bo\n", r);
return r;
}
r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM,
&rdev->uvd.gpu_addr);
if (r) {
radeon_bo_unreserve(rdev->uvd.vcpu_bo);
radeon_bo_unref(&rdev->uvd.vcpu_bo);
dev_err(rdev->dev, "(%d) UVD bo pin failed\n", r);
return r;
}
r = radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr);
if (r) {
dev_err(rdev->dev, "(%d) UVD map failed\n", r);
return r;
}
radeon_bo_unreserve(rdev->uvd.vcpu_bo);
for (i = 0; i < rdev->uvd.max_handles; ++i) {
atomic_set(&rdev->uvd.handles[i], 0);
rdev->uvd.filp[i] = NULL;
rdev->uvd.img_size[i] = 0;
}
return 0;
}
void radeon_uvd_fini(struct radeon_device *rdev)
{
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `drm/drm.h`, `radeon.h`, `radeon_ucode.h`, `r600d.h`.
- Detected declarations: `function radeon_uvd_init`, `function radeon_uvd_fini`, `function radeon_uvd_suspend`, `function radeon_uvd_resume`, `function radeon_uvd_force_into_uvd_segment`, `function radeon_uvd_free_handles`, `function radeon_uvd_cs_msg_decode`, `function radeon_uvd_validate_codec`, `function radeon_uvd_cs_msg`, `function radeon_uvd_cs_reloc`.
- 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.