drivers/staging/media/meson/vdec/codec_h264.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/meson/vdec/codec_h264.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/meson/vdec/codec_h264.c- Extension
.c- Size
- 15160 bytes
- Lines
- 486
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
media/v4l2-mem2mem.hmedia/videobuf2-dma-contig.hvdec_helpers.hdos_regs.hcodec_h264.h
Detected Declarations
struct codec_h264function codec_h264_can_recyclefunction codec_h264_recyclefunction codec_h264_startfunction codec_h264_stopfunction codec_h264_load_extended_firmwarefunction codec_h264_set_parfunction codec_h264_resumefunction amvdec_set_canvasesfunction codec_h264_src_changefunction get_offset_msbfunction codec_h264_frames_readyfunction codec_h264_threaded_isrfunction codec_h264_isr
Annotated Snippet
struct codec_h264 {
/* H.264 decoder requires an extended firmware */
void *ext_fw_vaddr;
dma_addr_t ext_fw_paddr;
/* Buffer for the H.264 Workspace */
void *workspace_vaddr;
dma_addr_t workspace_paddr;
/* Buffer for the H.264 references MV */
void *ref_vaddr;
dma_addr_t ref_paddr;
u32 ref_size;
/* Buffer for parsed SEI data */
void *sei_vaddr;
dma_addr_t sei_paddr;
u32 mb_width;
u32 mb_height;
u32 max_refs;
};
static int codec_h264_can_recycle(struct amvdec_core *core)
{
return !amvdec_read_dos(core, AV_SCRATCH_7) ||
!amvdec_read_dos(core, AV_SCRATCH_8);
}
static void codec_h264_recycle(struct amvdec_core *core, u32 buf_idx)
{
/*
* Tell the firmware it can recycle this buffer.
* AV_SCRATCH_8 serves the same purpose.
*/
if (!amvdec_read_dos(core, AV_SCRATCH_7))
amvdec_write_dos(core, AV_SCRATCH_7, buf_idx + 1);
else
amvdec_write_dos(core, AV_SCRATCH_8, buf_idx + 1);
}
static int codec_h264_start(struct amvdec_session *sess)
{
u32 workspace_offset;
struct amvdec_core *core = sess->core;
struct codec_h264 *h264 = sess->priv;
/* Allocate some memory for the H.264 decoder's state */
h264->workspace_vaddr =
dma_alloc_coherent(core->dev, SIZE_WORKSPACE,
&h264->workspace_paddr, GFP_KERNEL);
if (!h264->workspace_vaddr)
return -ENOMEM;
/* Allocate some memory for the H.264 SEI dump */
h264->sei_vaddr = dma_alloc_coherent(core->dev, SIZE_SEI,
&h264->sei_paddr, GFP_KERNEL);
if (!h264->sei_vaddr)
return -ENOMEM;
amvdec_write_dos_bits(core, POWER_CTL_VLD, BIT(9) | BIT(6));
workspace_offset = h264->workspace_paddr - WORKSPACE_BUF_OFFSET;
amvdec_write_dos(core, AV_SCRATCH_1, workspace_offset);
amvdec_write_dos(core, AV_SCRATCH_G, h264->ext_fw_paddr);
amvdec_write_dos(core, AV_SCRATCH_I, h264->sei_paddr -
workspace_offset);
/* Enable "error correction" */
amvdec_write_dos(core, AV_SCRATCH_F,
(amvdec_read_dos(core, AV_SCRATCH_F) & 0xffffffc3) |
BIT(4) | BIT(7));
amvdec_write_dos(core, MDEC_PIC_DC_THRESH, 0x404038aa);
return 0;
}
static int codec_h264_stop(struct amvdec_session *sess)
{
struct codec_h264 *h264 = sess->priv;
struct amvdec_core *core = sess->core;
if (h264->ext_fw_vaddr)
dma_free_coherent(core->dev, SIZE_EXT_FW,
h264->ext_fw_vaddr, h264->ext_fw_paddr);
if (h264->workspace_vaddr)
dma_free_coherent(core->dev, SIZE_WORKSPACE,
h264->workspace_vaddr, h264->workspace_paddr);
Annotation
- Immediate include surface: `media/v4l2-mem2mem.h`, `media/videobuf2-dma-contig.h`, `vdec_helpers.h`, `dos_regs.h`, `codec_h264.h`.
- Detected declarations: `struct codec_h264`, `function codec_h264_can_recycle`, `function codec_h264_recycle`, `function codec_h264_start`, `function codec_h264_stop`, `function codec_h264_load_extended_firmware`, `function codec_h264_set_par`, `function codec_h264_resume`, `function amvdec_set_canvases`, `function codec_h264_src_change`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.