drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c- Extension
.c- Size
- 24299 bytes
- Lines
- 880
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
amdgpu.hamdgpu_jpeg.hamdgpu_pm.hsoc15.hsoc15d.hjpeg_v2_0.hjpeg_v4_0.hmmsch_v4_0.hvcn/vcn_4_0_0_offset.hvcn/vcn_4_0_0_sh_mask.hivsrcid/vcn/irqsrcs_vcn_4_0.h
Detected Declarations
function jpeg_v4_0_early_initfunction jpeg_v4_0_sw_initfunction jpeg_v4_0_sw_finifunction jpeg_v4_0_hw_initfunction jpeg_v4_0_hw_finifunction jpeg_v4_0_suspendfunction jpeg_v4_0_resumefunction jpeg_v4_0_disable_clock_gatingfunction jpeg_v4_0_enable_clock_gatingfunction jpeg_v4_0_disable_static_power_gatingfunction jpeg_v4_0_enable_static_power_gatingfunction jpeg_v4_0_startfunction jpeg_v4_0_start_sriovfunction jpeg_v4_0_stopfunction jpeg_v4_0_dec_ring_get_rptrfunction jpeg_v4_0_dec_ring_get_wptrfunction jpeg_v4_0_dec_ring_set_wptrfunction jpeg_v4_0_is_idlefunction jpeg_v4_0_wait_for_idlefunction jpeg_v4_0_set_clockgating_statefunction jpeg_v4_0_set_powergating_statefunction jpeg_v4_0_set_ras_interrupt_statefunction jpeg_v4_0_process_interruptfunction jpeg_v4_0_ring_resetfunction jpeg_v4_0_set_dec_ring_funcsfunction jpeg_v4_0_set_irq_funcsfunction jpeg_v4_0_query_poison_by_instancefunction jpeg_v4_0_query_ras_poison_statusfunction jpeg_v4_0_set_ras_funcs
Annotated Snippet
if (r) {
drm_err(adev_to_drm(adev), "failed to disable JPEG power gating\n");
return r;
}
}
/* disable anti hang mechanism */
WREG32_P(SOC15_REG_OFFSET(JPEG, 0, regUVD_JPEG_POWER_STATUS), 0,
~UVD_JPEG_POWER_STATUS__JPEG_POWER_STATUS_MASK);
/* keep the JPEG in static PG mode */
WREG32_P(SOC15_REG_OFFSET(JPEG, 0, regUVD_JPEG_POWER_STATUS), 0,
~UVD_JPEG_POWER_STATUS__JPEG_PG_MODE_MASK);
return 0;
}
static int jpeg_v4_0_enable_static_power_gating(struct amdgpu_device *adev)
{
/* enable anti hang mechanism */
WREG32_P(SOC15_REG_OFFSET(JPEG, 0, regUVD_JPEG_POWER_STATUS),
UVD_JPEG_POWER_STATUS__JPEG_POWER_STATUS_MASK,
~UVD_JPEG_POWER_STATUS__JPEG_POWER_STATUS_MASK);
if (adev->pg_flags & AMD_PG_SUPPORT_JPEG) {
uint32_t data = 0;
int r = 0;
data = 2 << UVD_PGFSM_CONFIG__UVDJ_PWR_CONFIG__SHIFT;
WREG32(SOC15_REG_OFFSET(JPEG, 0, regUVD_PGFSM_CONFIG), data);
r = SOC15_WAIT_ON_RREG(JPEG, 0, regUVD_PGFSM_STATUS,
(2 << UVD_PGFSM_STATUS__UVDJ_PWR_STATUS__SHIFT),
UVD_PGFSM_STATUS__UVDJ_PWR_STATUS_MASK);
if (r) {
drm_err(adev_to_drm(adev), "failed to enable JPEG power gating\n");
return r;
}
}
return 0;
}
/**
* jpeg_v4_0_start - start JPEG block
*
* @adev: amdgpu_device pointer
*
* Setup and start the JPEG block
*/
static int jpeg_v4_0_start(struct amdgpu_device *adev)
{
struct amdgpu_ring *ring = adev->jpeg.inst->ring_dec;
int r;
if (adev->pm.dpm_enabled)
amdgpu_dpm_enable_jpeg(adev, true);
/* disable power gating */
r = jpeg_v4_0_disable_static_power_gating(adev);
if (r)
return r;
/* JPEG disable CGC */
jpeg_v4_0_disable_clock_gating(adev);
/* MJPEG global tiling registers */
WREG32_SOC15(JPEG, 0, regJPEG_DEC_GFX10_ADDR_CONFIG,
adev->gfx.config.gb_addr_config);
/* enable JMI channel */
WREG32_P(SOC15_REG_OFFSET(JPEG, 0, regUVD_JMI_CNTL), 0,
~UVD_JMI_CNTL__SOFT_RESET_MASK);
/* enable System Interrupt for JRBC */
WREG32_P(SOC15_REG_OFFSET(JPEG, 0, regJPEG_SYS_INT_EN),
JPEG_SYS_INT_EN__DJRBC_MASK,
~JPEG_SYS_INT_EN__DJRBC_MASK);
WREG32_SOC15(JPEG, 0, regUVD_LMI_JRBC_RB_VMID, 0);
WREG32_SOC15(JPEG, 0, regUVD_JRBC_RB_CNTL, (0x00000001L | 0x00000002L));
WREG32_SOC15(JPEG, 0, regUVD_LMI_JRBC_RB_64BIT_BAR_LOW,
lower_32_bits(ring->gpu_addr));
WREG32_SOC15(JPEG, 0, regUVD_LMI_JRBC_RB_64BIT_BAR_HIGH,
upper_32_bits(ring->gpu_addr));
WREG32_SOC15(JPEG, 0, regUVD_JRBC_RB_RPTR, 0);
WREG32_SOC15(JPEG, 0, regUVD_JRBC_RB_WPTR, 0);
WREG32_SOC15(JPEG, 0, regUVD_JRBC_RB_CNTL, 0x00000002L);
Annotation
- Immediate include surface: `amdgpu.h`, `amdgpu_jpeg.h`, `amdgpu_pm.h`, `soc15.h`, `soc15d.h`, `jpeg_v2_0.h`, `jpeg_v4_0.h`, `mmsch_v4_0.h`.
- Detected declarations: `function jpeg_v4_0_early_init`, `function jpeg_v4_0_sw_init`, `function jpeg_v4_0_sw_fini`, `function jpeg_v4_0_hw_init`, `function jpeg_v4_0_hw_fini`, `function jpeg_v4_0_suspend`, `function jpeg_v4_0_resume`, `function jpeg_v4_0_disable_clock_gating`, `function jpeg_v4_0_enable_clock_gating`, `function jpeg_v4_0_disable_static_power_gating`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.