drivers/media/platform/broadcom/bcm2835-unicam.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/broadcom/bcm2835-unicam.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/broadcom/bcm2835-unicam.c
Extension
.c
Size
75239 bytes
Lines
2777
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 unicam_format_info {
	u32	fourcc;
	u32	unpacked_fourcc;
	u32	code;
	u8	depth;
	u8	csi_dt;
	u8	unpack;
};

struct unicam_buffer {
	struct vb2_v4l2_buffer vb;
	struct list_head list;
	dma_addr_t dma_addr;
	unsigned int size;
};

static inline struct unicam_buffer *to_unicam_buffer(struct vb2_buffer *vb)
{
	return container_of(vb, struct unicam_buffer, vb.vb2_buf);
}

struct unicam_node {
	bool registered;
	unsigned int id;

	/* Pointer to the current v4l2_buffer */
	struct unicam_buffer *cur_frm;
	/* Pointer to the next v4l2_buffer */
	struct unicam_buffer *next_frm;
	/* Used to store current pixel format */
	struct v4l2_format fmt;
	/* Buffer queue used in video-buf */
	struct vb2_queue buffer_queue;
	/* Queue of filled frames */
	struct list_head dma_queue;
	/* IRQ lock for DMA queue */
	spinlock_t dma_queue_lock;
	/* Identifies video device for this channel */
	struct video_device video_dev;
	/* Pointer to the parent handle */
	struct unicam_device *dev;
	struct media_pad pad;
	/*
	 * Dummy buffer intended to be used by unicam
	 * if we have no other queued buffers to swap to.
	 */
	struct unicam_buffer dummy_buf;
	void *dummy_buf_cpu_addr;
};

struct unicam_device {
	struct kref kref;

	/* peripheral base address */
	void __iomem *base;
	/* clock gating base address */
	void __iomem *clk_gate_base;
	/* lp clock handle */
	struct clk *clock;
	/* vpu clock handle */
	struct clk *vpu_clock;
	/* V4l2 device */
	struct v4l2_device v4l2_dev;
	struct media_device mdev;

	/* parent device */
	struct device *dev;
	/* subdevice async notifier */
	struct v4l2_async_notifier notifier;
	unsigned int sequence;
	bool frame_started;

	/* Sensor node */
	struct {
		struct v4l2_subdev *subdev;
		struct media_pad *pad;
	} sensor;

	/* Internal subdev */
	struct {
		struct v4l2_subdev sd;
		struct media_pad pads[UNICAM_SD_NUM_PADS];
		unsigned int enabled_streams;
	} subdev;

	enum v4l2_mbus_type bus_type;
	/*
	 * Stores bus.mipi_csi2.flags for CSI2 sensors, or
	 * bus.mipi_csi1.strobe for CCP2.
	 */

Annotation

Implementation Notes