drivers/staging/media/meson/vdec/vdec.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/meson/vdec/vdec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/meson/vdec/vdec.c- Extension
.c- Size
- 29563 bytes
- Lines
- 1124
- 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.
- 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
linux/of.hlinux/clk.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/mfd/syscon.hlinux/slab.hlinux/interrupt.hlinux/kthread.hmedia/v4l2-ioctl.hmedia/v4l2-event.hmedia/v4l2-ctrls.hmedia/v4l2-mem2mem.hmedia/v4l2-dev.hmedia/videobuf2-dma-contig.hvdec.hesparser.hvdec_helpers.h
Detected Declarations
struct dummy_buffunction get_output_sizefunction amvdec_get_output_sizefunction vdec_codec_needs_recyclefunction vdec_recycle_threadfunction list_for_each_entry_safefunction vdec_poweronfunction vdec_wait_inactivefunction vdec_powerofffunction vdec_queue_recyclefunction vdec_m2m_device_runfunction vdec_m2m_job_abortfunction process_num_buffersfunction vdec_queue_setupfunction vdec_vb2_buf_queuefunction vdec_start_streamingfunction vdec_free_canvasfunction vdec_reset_timestampsfunction list_for_each_entry_safefunction vdec_reset_bufs_recyclefunction list_for_each_entry_safefunction vdec_stop_streamingfunction vdec_vb2_buf_preparefunction vdec_querycapfunction find_formatfunction vdec_supports_pixfmt_capfunction vdec_try_fmt_commonfunction vdec_try_fmtfunction vdec_g_fmtfunction vdec_s_fmtfunction vdec_enum_fmtfunction vdec_enum_framesizesfunction vdec_decoder_cmdfunction vdec_subscribe_eventfunction vdec_g_pixelaspectfunction m2m_queue_initfunction vdec_init_ctrlsfunction vdec_openfunction vdec_closefunction vdec_isrfunction vdec_threaded_isrfunction vdec_probefunction vdec_removeexport amvdec_get_output_size
Annotated Snippet
struct dummy_buf {
struct vb2_v4l2_buffer vb;
struct list_head list;
};
/* 16 MiB for parsed bitstream swap exchange */
#define SIZE_VIFIFO SZ_16M
static u32 get_output_size(u32 width, u32 height)
{
return ALIGN(width * height, SZ_64K);
}
u32 amvdec_get_output_size(struct amvdec_session *sess)
{
return get_output_size(sess->width, sess->height);
}
EXPORT_SYMBOL_GPL(amvdec_get_output_size);
static int vdec_codec_needs_recycle(struct amvdec_session *sess)
{
struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops;
return codec_ops->can_recycle && codec_ops->recycle;
}
static int vdec_recycle_thread(void *data)
{
struct amvdec_session *sess = data;
struct amvdec_core *core = sess->core;
struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops;
struct amvdec_buffer *tmp, *n;
while (!kthread_should_stop()) {
mutex_lock(&sess->bufs_recycle_lock);
list_for_each_entry_safe(tmp, n, &sess->bufs_recycle, list) {
if (!codec_ops->can_recycle(core))
break;
codec_ops->recycle(core, tmp->vb->index);
list_del(&tmp->list);
kfree(tmp);
}
mutex_unlock(&sess->bufs_recycle_lock);
usleep_range(5000, 10000);
}
return 0;
}
static int vdec_poweron(struct amvdec_session *sess)
{
int ret;
struct amvdec_ops *vdec_ops = sess->fmt_out->vdec_ops;
ret = clk_prepare_enable(sess->core->dos_parser_clk);
if (ret)
return ret;
ret = clk_prepare_enable(sess->core->dos_clk);
if (ret)
goto disable_dos_parser;
ret = vdec_ops->start(sess);
if (ret)
goto disable_dos;
esparser_power_up(sess);
return 0;
disable_dos:
clk_disable_unprepare(sess->core->dos_clk);
disable_dos_parser:
clk_disable_unprepare(sess->core->dos_parser_clk);
return ret;
}
static void vdec_wait_inactive(struct amvdec_session *sess)
{
/* We consider 50ms with no IRQ to be inactive. */
while (time_is_after_jiffies64(sess->last_irq_jiffies +
msecs_to_jiffies(50)))
msleep(25);
}
static void vdec_poweroff(struct amvdec_session *sess)
{
Annotation
- Immediate include surface: `linux/of.h`, `linux/clk.h`, `linux/io.h`, `linux/module.h`, `linux/platform_device.h`, `linux/mfd/syscon.h`, `linux/slab.h`, `linux/interrupt.h`.
- Detected declarations: `struct dummy_buf`, `function get_output_size`, `function amvdec_get_output_size`, `function vdec_codec_needs_recycle`, `function vdec_recycle_thread`, `function list_for_each_entry_safe`, `function vdec_poweron`, `function vdec_wait_inactive`, `function vdec_poweroff`, `function vdec_queue_recycle`.
- 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.
- 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.