drivers/media/platform/amphion/vpu_mbox.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/amphion/vpu_mbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/amphion/vpu_mbox.c- Extension
.c- Size
- 2508 bytes
- Lines
- 112
- 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.
- 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.hvpu.hvpu_mbox.hvpu_msgs.h
Detected Declarations
function vpu_mbox_rx_callbackfunction vpu_mbox_request_channelfunction vpu_mbox_initfunction vpu_mbox_requestfunction vpu_mbox_freefunction vpu_mbox_send_typefunction vpu_mbox_send_msg
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright 2020-2021 NXP
*/
#include <linux/init.h>
#include <linux/interconnect.h>
#include <linux/ioctl.h>
#include <linux/list.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include "vpu.h"
#include "vpu_mbox.h"
#include "vpu_msgs.h"
static void vpu_mbox_rx_callback(struct mbox_client *cl, void *msg)
{
struct vpu_mbox *rx = container_of(cl, struct vpu_mbox, cl);
struct vpu_core *core = container_of(rx, struct vpu_core, rx);
vpu_isr(core, *(u32 *)msg);
}
static int vpu_mbox_request_channel(struct device *dev, struct vpu_mbox *mbox)
{
struct mbox_chan *ch;
struct mbox_client *cl;
if (!dev || !mbox)
return -EINVAL;
if (mbox->ch)
return 0;
cl = &mbox->cl;
cl->dev = dev;
if (mbox->block) {
cl->tx_block = true;
cl->tx_tout = 1000;
} else {
cl->tx_block = false;
}
cl->knows_txdone = false;
cl->rx_callback = vpu_mbox_rx_callback;
ch = mbox_request_channel_byname(cl, mbox->name);
if (IS_ERR(ch))
return dev_err_probe(dev, PTR_ERR(ch),
"Failed to request mbox chan %s\n",
mbox->name);
mbox->ch = ch;
return 0;
}
int vpu_mbox_init(struct vpu_core *core)
{
scnprintf(core->tx_type.name, sizeof(core->tx_type.name) - 1, "tx0");
core->tx_type.block = true;
scnprintf(core->tx_data.name, sizeof(core->tx_data.name) - 1, "tx1");
core->tx_data.block = false;
scnprintf(core->rx.name, sizeof(core->rx.name) - 1, "rx");
core->rx.block = true;
return 0;
}
int vpu_mbox_request(struct vpu_core *core)
{
int ret;
ret = vpu_mbox_request_channel(core->dev, &core->tx_type);
if (ret)
goto error;
ret = vpu_mbox_request_channel(core->dev, &core->tx_data);
if (ret)
goto error;
ret = vpu_mbox_request_channel(core->dev, &core->rx);
if (ret)
goto error;
dev_dbg(core->dev, "%s request mbox\n", vpu_core_type_desc(core->type));
return 0;
error:
vpu_mbox_free(core);
return ret;
}
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`, `vpu.h`.
- Detected declarations: `function vpu_mbox_rx_callback`, `function vpu_mbox_request_channel`, `function vpu_mbox_init`, `function vpu_mbox_request`, `function vpu_mbox_free`, `function vpu_mbox_send_type`, `function vpu_mbox_send_msg`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.