drivers/media/test-drivers/visl/visl-debugfs.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/visl/visl-debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/visl/visl-debugfs.c- Extension
.c- Size
- 2672 bytes
- Lines
- 113
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- 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.hlinux/list.hlinux/mutex.hmedia/v4l2-mem2mem.hvisl-debugfs.h
Detected Declarations
function visl_debugfs_initfunction visl_debugfs_bitstream_initfunction visl_trace_bitstreamfunction visl_debugfs_clear_bitstreamfunction list_for_each_entry_safefunction visl_debugfs_bitstream_deinitfunction visl_debugfs_deinit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Debugfs tracing for bitstream buffers. This is similar to VA-API's
* LIBVA_TRACE_BUFDATA in that the raw bitstream can be dumped as a debugging
* aid.
*
* Produces one file per OUTPUT buffer. Files are automatically cleared on
* STREAMOFF unless the module parameter "keep_bitstream_buffers" is set.
*/
#include <linux/debugfs.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <media/v4l2-mem2mem.h>
#include "visl-debugfs.h"
int visl_debugfs_init(struct visl_dev *dev)
{
dev->debugfs_root = debugfs_create_dir("visl", NULL);
INIT_LIST_HEAD(&dev->bitstream_blobs);
mutex_init(&dev->bitstream_lock);
if (IS_ERR(dev->debugfs_root))
return PTR_ERR(dev->debugfs_root);
return visl_debugfs_bitstream_init(dev);
}
int visl_debugfs_bitstream_init(struct visl_dev *dev)
{
dev->bitstream_debugfs = debugfs_create_dir("bitstream",
dev->debugfs_root);
if (IS_ERR(dev->bitstream_debugfs))
return PTR_ERR(dev->bitstream_debugfs);
return 0;
}
void visl_trace_bitstream(struct visl_ctx *ctx, struct visl_run *run)
{
u8 *vaddr = vb2_plane_vaddr(&run->src->vb2_buf, 0);
struct visl_blob *blob;
size_t data_sz = vb2_get_plane_payload(&run->src->vb2_buf, 0);
struct dentry *dentry;
char name[32];
blob = kzalloc_obj(*blob);
if (!blob)
return;
blob->blob.data = vzalloc(data_sz);
if (!blob->blob.data)
goto err_vmalloc;
blob->blob.size = data_sz;
snprintf(name, 32, "bitstream%d", run->src->sequence);
memcpy(blob->blob.data, vaddr, data_sz);
dentry = debugfs_create_blob(name, 0444, ctx->dev->bitstream_debugfs,
&blob->blob);
if (IS_ERR(dentry))
goto err_debugfs;
blob->dentry = dentry;
mutex_lock(&ctx->dev->bitstream_lock);
list_add_tail(&blob->list, &ctx->dev->bitstream_blobs);
mutex_unlock(&ctx->dev->bitstream_lock);
return;
err_debugfs:
vfree(blob->blob.data);
err_vmalloc:
kfree(blob);
}
void visl_debugfs_clear_bitstream(struct visl_dev *dev)
{
struct visl_blob *blob;
struct visl_blob *tmp;
mutex_lock(&dev->bitstream_lock);
if (list_empty(&dev->bitstream_blobs))
goto unlock;
list_for_each_entry_safe(blob, tmp, &dev->bitstream_blobs, list) {
list_del(&blob->list);
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/list.h`, `linux/mutex.h`, `media/v4l2-mem2mem.h`, `visl-debugfs.h`.
- Detected declarations: `function visl_debugfs_init`, `function visl_debugfs_bitstream_init`, `function visl_trace_bitstream`, `function visl_debugfs_clear_bitstream`, `function list_for_each_entry_safe`, `function visl_debugfs_bitstream_deinit`, `function visl_debugfs_deinit`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.