drivers/staging/media/meson/vdec/vdec_helpers.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/meson/vdec/vdec_helpers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/meson/vdec/vdec_helpers.c- Extension
.c- Size
- 12656 bytes
- Lines
- 481
- Domain
- Driver Families
- Bucket
- drivers/staging
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/gcd.hmedia/v4l2-mem2mem.hmedia/v4l2-event.hmedia/videobuf2-dma-contig.hvdec_helpers.h
Detected Declarations
function Copyrightfunction amvdec_write_dosfunction amvdec_write_dos_bitsfunction amvdec_clear_dos_bitsfunction amvdec_read_parserfunction amvdec_write_parserfunction amvdec_am21c_body_sizefunction amvdec_am21c_head_sizefunction amvdec_am21c_sizefunction canvas_allocfunction set_canvas_yuv420mfunction set_canvas_nv12mfunction amvdec_set_canvasesfunction v4l2_m2m_for_each_dst_buffunction amvdec_add_tsfunction amvdec_remove_tsfunction dst_buf_donefunction amvdec_dst_buf_donefunction amvdec_dst_buf_done_offsetfunction amvdec_dst_buf_done_idxfunction amvdec_set_par_from_darfunction amvdec_src_changefunction amvdec_abortexport amvdec_read_dosexport amvdec_write_dosexport amvdec_write_dos_bitsexport amvdec_clear_dos_bitsexport amvdec_read_parserexport amvdec_write_parserexport amvdec_am21c_body_sizeexport amvdec_am21c_head_sizeexport amvdec_am21c_sizeexport amvdec_set_canvasesexport amvdec_add_tsexport amvdec_remove_tsexport amvdec_dst_buf_doneexport amvdec_dst_buf_done_offsetexport amvdec_dst_buf_done_idxexport amvdec_set_par_from_darexport amvdec_src_changeexport amvdec_abort
Annotated Snippet
switch (pixfmt) {
case V4L2_PIX_FMT_NV12M:
ret = set_canvas_nv12m(sess, &buf->vb.vb2_buf, width,
height, reg_cur);
if (ret)
return ret;
break;
case V4L2_PIX_FMT_YUV420M:
ret = set_canvas_yuv420m(sess, &buf->vb.vb2_buf, width,
height, reg_cur);
if (ret)
return ret;
break;
default:
dev_err(sess->core->dev, "Unsupported pixfmt %08X\n",
pixfmt);
return -EINVAL;
}
reg_num_cur++;
if (reg_num_cur >= reg_num[reg_base_cur]) {
reg_base_cur++;
reg_num_cur = 0;
}
sess->fw_idx_to_vb2_idx[i++] = buf->vb.vb2_buf.index;
}
return 0;
}
EXPORT_SYMBOL_GPL(amvdec_set_canvases);
int amvdec_add_ts(struct amvdec_session *sess, u64 ts,
struct v4l2_timecode tc, u32 offset, u32 vbuf_flags)
{
struct amvdec_timestamp *new_ts;
unsigned long flags;
new_ts = kzalloc_obj(*new_ts);
if (!new_ts)
return -ENOMEM;
new_ts->ts = ts;
new_ts->tc = tc;
new_ts->offset = offset;
new_ts->flags = vbuf_flags;
spin_lock_irqsave(&sess->ts_spinlock, flags);
list_add_tail(&new_ts->list, &sess->timestamps);
spin_unlock_irqrestore(&sess->ts_spinlock, flags);
return 0;
}
EXPORT_SYMBOL_GPL(amvdec_add_ts);
void amvdec_remove_ts(struct amvdec_session *sess, u64 ts)
{
struct amvdec_timestamp *tmp;
unsigned long flags;
spin_lock_irqsave(&sess->ts_spinlock, flags);
list_for_each_entry(tmp, &sess->timestamps, list) {
if (tmp->ts == ts) {
list_del(&tmp->list);
kfree(tmp);
goto unlock;
}
}
dev_warn(sess->core->dev_dec,
"Couldn't remove buffer with timestamp %llu from list\n", ts);
unlock:
spin_unlock_irqrestore(&sess->ts_spinlock, flags);
}
EXPORT_SYMBOL_GPL(amvdec_remove_ts);
static void dst_buf_done(struct amvdec_session *sess,
struct vb2_v4l2_buffer *vbuf,
u32 field, u64 timestamp,
struct v4l2_timecode timecode, u32 flags)
{
struct device *dev = sess->core->dev_dec;
u32 output_size = amvdec_get_output_size(sess);
switch (sess->pixfmt_cap) {
case V4L2_PIX_FMT_NV12M:
vb2_set_plane_payload(&vbuf->vb2_buf, 0, output_size);
vb2_set_plane_payload(&vbuf->vb2_buf, 1, output_size / 2);
break;
case V4L2_PIX_FMT_YUV420M:
vb2_set_plane_payload(&vbuf->vb2_buf, 0, output_size);
Annotation
- Immediate include surface: `linux/gcd.h`, `media/v4l2-mem2mem.h`, `media/v4l2-event.h`, `media/videobuf2-dma-contig.h`, `vdec_helpers.h`.
- Detected declarations: `function Copyright`, `function amvdec_write_dos`, `function amvdec_write_dos_bits`, `function amvdec_clear_dos_bits`, `function amvdec_read_parser`, `function amvdec_write_parser`, `function amvdec_am21c_body_size`, `function amvdec_am21c_head_size`, `function amvdec_am21c_size`, `function canvas_alloc`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: integration 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.