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.

Dependency Surface

Detected Declarations

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

Implementation Notes