drivers/media/pci/intel/ivsc/mei_csi.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/intel/ivsc/mei_csi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/intel/ivsc/mei_csi.c- Extension
.c- Size
- 19627 bytes
- Lines
- 792
- 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/completion.hlinux/delay.hlinux/kernel.hlinux/math64.hlinux/mei_cl_bus.hlinux/module.hlinux/mutex.hlinux/pci.hlinux/pm_runtime.hlinux/slab.hlinux/units.hlinux/uuid.hlinux/workqueue.hmedia/ipu-bridge.hmedia/ipu6-pci-table.hmedia/v4l2-async.hmedia/v4l2-ctrls.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.h
Detected Declarations
struct csi_link_cfgstruct csi_cmdstruct csi_notifstruct mei_csienum csi_cmd_idenum csi_link_ownerenum ivsc_privacy_statusenum csi_padsfunction mei_csi_sendfunction csi_set_link_ownerfunction csi_set_link_cfgfunction mei_csi_rxfunction mei_csi_set_streamfunction mei_csi_init_statefunction mei_csi_set_fmtfunction mei_csi_get_mbus_configfunction mei_csi_notify_boundfunction mei_csi_notify_unbindfunction mei_csi_init_controlsfunction mei_csi_parse_firmwarefunction mei_csi_probefunction mei_csi_remove
Annotated Snippet
struct csi_link_cfg {
/* number of data lanes used on the CSI-2 link */
u32 nr_of_lanes;
/* frequency of the CSI-2 link */
u32 link_freq;
/* for future use */
u32 rsvd[2];
} __packed;
/* CSI command structure */
struct csi_cmd {
u32 cmd_id;
union _cmd_param {
u32 param;
struct csi_link_cfg conf;
} param;
} __packed;
/* CSI notification structure */
struct csi_notif {
u32 cmd_id;
int status;
union _resp_cont {
u32 cont;
struct csi_link_cfg conf;
} cont;
} __packed;
struct mei_csi {
struct mei_cl_device *cldev;
/* command response */
struct csi_notif cmd_response;
/* used to wait for command response from firmware */
struct completion cmd_completion;
/* protect command download */
struct mutex lock;
struct v4l2_subdev subdev;
struct media_pad *remote;
struct v4l2_async_notifier notifier;
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_ctrl *freq_ctrl;
struct v4l2_ctrl *privacy_ctrl;
/* lock for v4l2 controls */
struct mutex ctrl_lock;
/* start streaming or not */
int streaming;
struct media_pad pads[CSI_NUM_PADS];
/* number of data lanes used on the CSI-2 link */
u32 nr_of_lanes;
/* frequency of the CSI-2 link */
u64 link_freq;
};
static const struct v4l2_mbus_framefmt mei_csi_format_mbus_default = {
.width = 1,
.height = 1,
.code = MEDIA_BUS_FMT_Y8_1X8,
.field = V4L2_FIELD_NONE,
};
static inline struct mei_csi *notifier_to_csi(struct v4l2_async_notifier *n)
{
return container_of(n, struct mei_csi, notifier);
}
static inline struct mei_csi *sd_to_csi(struct v4l2_subdev *sd)
{
return container_of(sd, struct mei_csi, subdev);
}
/* send a command to firmware and mutex must be held by caller */
static int mei_csi_send(struct mei_csi *csi, u8 *buf, size_t len)
{
struct csi_cmd *cmd = (struct csi_cmd *)buf;
int ret;
reinit_completion(&csi->cmd_completion);
ret = mei_cldev_send(csi->cldev, buf, len);
if (ret < 0)
goto out;
ret = wait_for_completion_killable_timeout(&csi->cmd_completion,
CSI_CMD_TIMEOUT);
Annotation
- Immediate include surface: `linux/completion.h`, `linux/delay.h`, `linux/kernel.h`, `linux/math64.h`, `linux/mei_cl_bus.h`, `linux/module.h`, `linux/mutex.h`, `linux/pci.h`.
- Detected declarations: `struct csi_link_cfg`, `struct csi_cmd`, `struct csi_notif`, `struct mei_csi`, `enum csi_cmd_id`, `enum csi_link_owner`, `enum ivsc_privacy_status`, `enum csi_pads`, `function mei_csi_send`, `function csi_set_link_owner`.
- 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.