drivers/media/platform/amphion/vpu_dbg.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/amphion/vpu_dbg.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/amphion/vpu_dbg.c
Extension
.c
Size
12773 bytes
Lines
522
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations vpu_dbg_inst_fops = {
	.owner = THIS_MODULE,
	.open = vpu_dbg_inst_open,
	.release = single_release,
	.read = seq_read,
	.write = vpu_dbg_inst_write,
};

static const struct file_operations vpu_dbg_core_fops = {
	.owner = THIS_MODULE,
	.open = vpu_dbg_core_open,
	.release = single_release,
	.read = seq_read,
	.write = vpu_dbg_core_write,
};

static const struct file_operations vpu_dbg_fwlog_fops = {
	.owner = THIS_MODULE,
	.open = vpu_dbg_fwlog_open,
	.release = single_release,
	.read = seq_read,
};

int vpu_inst_create_dbgfs_file(struct vpu_inst *inst)
{
	struct vpu_dev *vpu;
	char name[64];

	if (!inst || !inst->core || !inst->core->vpu)
		return -EINVAL;

	vpu = inst->core->vpu;
	if (!vpu->debugfs)
		return -EINVAL;

	if (inst->debugfs)
		return 0;

	scnprintf(name, sizeof(name), "instance.%d.%d", inst->core->id, inst->id);
	inst->debugfs = debugfs_create_file((const char *)name,
					    VERIFY_OCTAL_PERMISSIONS(0644),
					    vpu->debugfs,
					    inst,
					    &vpu_dbg_inst_fops);

	return 0;
}

int vpu_inst_remove_dbgfs_file(struct vpu_inst *inst)
{
	if (!inst)
		return 0;

	debugfs_remove(inst->debugfs);
	inst->debugfs = NULL;

	return 0;
}

int vpu_core_create_dbgfs_file(struct vpu_core *core)
{
	struct vpu_dev *vpu;
	char name[64];

	if (!core || !core->vpu)
		return -EINVAL;

	vpu = core->vpu;
	if (!vpu->debugfs)
		return -EINVAL;

	if (!core->debugfs) {
		scnprintf(name, sizeof(name), "core.%d", core->id);
		core->debugfs = debugfs_create_file((const char *)name,
						    VERIFY_OCTAL_PERMISSIONS(0644),
						    vpu->debugfs,
						    core,
						    &vpu_dbg_core_fops);
	}
	if (!core->debugfs_fwlog) {
		scnprintf(name, sizeof(name), "fwlog.%d", core->id);
		core->debugfs_fwlog = debugfs_create_file((const char *)name,
							  VERIFY_OCTAL_PERMISSIONS(0444),
							  vpu->debugfs,
							  core,
							  &vpu_dbg_fwlog_fops);
	}

	return 0;
}

Annotation

Implementation Notes