drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c- Extension
.c- Size
- 6764 bytes
- Lines
- 232
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/debugfs.hmtk_vcodec_dbgfs.h../decoder/mtk_vcodec_dec_drv.h../encoder/mtk_vcodec_enc_drv.hmtk_vcodec_util.h
Detected Declarations
function Copyrightfunction mtk_vdec_dbgfs_get_helpfunction mtk_vdec_dbgfs_writefunction mtk_vdec_dbgfs_readfunction mtk_vcodec_dbgfs_createfunction mtk_vcodec_dbgfs_removefunction list_for_each_entryfunction mtk_vcodec_dbgfs_vdec_initfunction mtk_vcodec_dbgfs_venc_initfunction mtk_vcodec_dbgfs_initfunction mtk_vcodec_dbgfs_deinitexport mtk_vcodec_dbgfs_createexport mtk_vcodec_dbgfs_removeexport mtk_vcodec_dbgfs_initexport mtk_vcodec_dbgfs_deinit
Annotated Snippet
static const struct file_operations vdec_fops = {
.open = simple_open,
.write = mtk_vdec_dbgfs_write,
.read = mtk_vdec_dbgfs_read,
};
void mtk_vcodec_dbgfs_create(struct mtk_vcodec_dec_ctx *ctx)
{
struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
struct mtk_vcodec_dec_dev *vcodec_dev = ctx->dev;
dbgfs_inst = kzalloc_obj(*dbgfs_inst);
if (!dbgfs_inst)
return;
list_add_tail(&dbgfs_inst->node, &vcodec_dev->dbgfs.dbgfs_head);
vcodec_dev->dbgfs.inst_count++;
dbgfs_inst->inst_id = ctx->id;
dbgfs_inst->vcodec_ctx = ctx;
}
EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_create);
void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dec_dev *vcodec_dev, int ctx_id)
{
struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
list_for_each_entry(dbgfs_inst, &vcodec_dev->dbgfs.dbgfs_head, node) {
if (dbgfs_inst->inst_id == ctx_id) {
vcodec_dev->dbgfs.inst_count--;
list_del(&dbgfs_inst->node);
kfree(dbgfs_inst);
return;
}
}
}
EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_remove);
static void mtk_vcodec_dbgfs_vdec_init(struct mtk_vcodec_dec_dev *vcodec_dev)
{
struct dentry *vcodec_root;
vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL);
if (IS_ERR(vcodec_dev->dbgfs.vcodec_root))
dev_err(&vcodec_dev->plat_dev->dev, "create vcodec dir err:%pe\n",
vcodec_dev->dbgfs.vcodec_root);
vcodec_root = vcodec_dev->dbgfs.vcodec_root;
debugfs_create_x32("mtk_v4l2_dbg_level", 0644, vcodec_root, &mtk_v4l2_dbg_level);
debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root, &mtk_vcodec_dbg);
vcodec_dev->dbgfs.inst_count = 0;
INIT_LIST_HEAD(&vcodec_dev->dbgfs.dbgfs_head);
debugfs_create_file("vdec", 0200, vcodec_root, vcodec_dev, &vdec_fops);
mutex_init(&vcodec_dev->dbgfs.dbgfs_lock);
}
static void mtk_vcodec_dbgfs_venc_init(struct mtk_vcodec_enc_dev *vcodec_dev)
{
struct dentry *vcodec_root;
vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-enc", NULL);
if (IS_ERR(vcodec_dev->dbgfs.vcodec_root))
dev_err(&vcodec_dev->plat_dev->dev, "create venc dir err:%d\n",
IS_ERR(vcodec_dev->dbgfs.vcodec_root));
vcodec_root = vcodec_dev->dbgfs.vcodec_root;
debugfs_create_x32("mtk_v4l2_dbg_level", 0644, vcodec_root, &mtk_v4l2_dbg_level);
debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root, &mtk_vcodec_dbg);
vcodec_dev->dbgfs.inst_count = 0;
}
void mtk_vcodec_dbgfs_init(void *vcodec_dev, bool is_encode)
{
if (is_encode)
mtk_vcodec_dbgfs_venc_init(vcodec_dev);
else
mtk_vcodec_dbgfs_vdec_init(vcodec_dev);
}
EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_init);
void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dbgfs *dbgfs)
{
debugfs_remove_recursive(dbgfs->vcodec_root);
}
EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_deinit);
MODULE_LICENSE("GPL v2");
Annotation
- Immediate include surface: `linux/debugfs.h`, `mtk_vcodec_dbgfs.h`, `../decoder/mtk_vcodec_dec_drv.h`, `../encoder/mtk_vcodec_enc_drv.h`, `mtk_vcodec_util.h`.
- Detected declarations: `function Copyright`, `function mtk_vdec_dbgfs_get_help`, `function mtk_vdec_dbgfs_write`, `function mtk_vdec_dbgfs_read`, `function mtk_vcodec_dbgfs_create`, `function mtk_vcodec_dbgfs_remove`, `function list_for_each_entry`, `function mtk_vcodec_dbgfs_vdec_init`, `function mtk_vcodec_dbgfs_venc_init`, `function mtk_vcodec_dbgfs_init`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: pattern 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.