drivers/media/platform/amphion/vpu_cmds.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/amphion/vpu_cmds.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/amphion/vpu_cmds.c- Extension
.c- Size
- 9928 bytes
- Lines
- 453
- 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/init.hlinux/interconnect.hlinux/ioctl.hlinux/list.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/slab.hlinux/types.hlinux/delay.hvpu.hvpu_defs.hvpu_cmds.hvpu_rpc.hvpu_mbox.h
Detected Declarations
struct vpu_cmd_requeststruct vpu_cmd_tfunction vpu_cmd_sendfunction vpu_free_cmdfunction vpu_session_process_cmdfunction vpu_process_cmd_requestfunction list_for_each_entry_safefunction vpu_request_cmdfunction vpu_clear_pendingfunction vpu_check_responsefunction vpu_response_cmdfunction vpu_clear_requestfunction list_for_each_entry_safefunction check_is_responsedfunction sync_session_responsefunction vpu_core_keep_activefunction vpu_session_send_cmdfunction vpu_session_configure_codecfunction vpu_session_startfunction vpu_session_stopfunction vpu_session_encode_framefunction vpu_session_alloc_fsfunction vpu_session_release_fsfunction vpu_session_abortfunction vpu_session_rst_buffunction vpu_session_fill_timestampfunction vpu_session_update_parametersfunction vpu_session_debugfunction vpu_core_snapshotfunction vpu_core_sw_reset
Annotated Snippet
struct vpu_cmd_request {
u32 request;
u32 response;
u32 handled;
};
struct vpu_cmd_t {
struct list_head list;
u32 id;
struct vpu_cmd_request *request;
struct vpu_rpc_event *pkt;
unsigned long key;
atomic_long_t *last_response_cmd;
};
static struct vpu_cmd_request vpu_cmd_requests[] = {
{
.request = VPU_CMD_ID_CONFIGURE_CODEC,
.response = VPU_MSG_ID_MEM_REQUEST,
.handled = 1,
},
{
.request = VPU_CMD_ID_START,
.response = VPU_MSG_ID_START_DONE,
.handled = 0,
},
{
.request = VPU_CMD_ID_STOP,
.response = VPU_MSG_ID_STOP_DONE,
.handled = 0,
},
{
.request = VPU_CMD_ID_ABORT,
.response = VPU_MSG_ID_ABORT_DONE,
.handled = 0,
},
{
.request = VPU_CMD_ID_RST_BUF,
.response = VPU_MSG_ID_BUF_RST,
.handled = 1,
},
};
static int vpu_cmd_send(struct vpu_core *core, struct vpu_rpc_event *pkt)
{
int ret = 0;
ret = vpu_iface_send_cmd(core, pkt);
if (ret)
return ret;
/*write cmd data to cmd buffer before trigger a cmd interrupt*/
mb();
vpu_mbox_send_type(core, COMMAND);
return ret;
}
static struct vpu_cmd_t *vpu_alloc_cmd(struct vpu_inst *inst, u32 id, void *data)
{
struct vpu_cmd_t *cmd;
int i;
int ret;
cmd = kzalloc_obj(*cmd);
if (!cmd)
return NULL;
cmd->pkt = kzalloc_obj(*cmd->pkt);
if (!cmd->pkt) {
kfree(cmd);
return NULL;
}
cmd->id = id;
ret = vpu_iface_pack_cmd(inst->core, cmd->pkt, inst->id, id, data);
if (ret) {
dev_err(inst->dev, "iface pack cmd %s fail\n", vpu_id_name(id));
kfree(cmd->pkt);
kfree(cmd);
return NULL;
}
for (i = 0; i < ARRAY_SIZE(vpu_cmd_requests); i++) {
if (vpu_cmd_requests[i].request == id) {
cmd->request = &vpu_cmd_requests[i];
break;
}
}
return cmd;
Annotation
- Immediate include surface: `linux/init.h`, `linux/interconnect.h`, `linux/ioctl.h`, `linux/list.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/slab.h`.
- Detected declarations: `struct vpu_cmd_request`, `struct vpu_cmd_t`, `function vpu_cmd_send`, `function vpu_free_cmd`, `function vpu_session_process_cmd`, `function vpu_process_cmd_request`, `function list_for_each_entry_safe`, `function vpu_request_cmd`, `function vpu_clear_pending`, `function vpu_check_response`.
- 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.