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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/clk.hlinux/delay.hlinux/device.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of.hlinux/of_device.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hlinux/videodev2.hmedia/mipi-csi2.hmedia/v4l2-async.hmedia/v4l2-common.hmedia/v4l2-dev.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-ioctl.hmedia/v4l2-fwnode.hmedia/v4l2-mc.hmedia/v4l2-subdev.hmedia/videobuf2-dma-contig.hbcm2835-unicam-regs.h
Detected Declarations
struct unicam_format_infostruct unicam_bufferstruct unicam_nodestruct unicam_deviceenum unicam_padenum unicam_node_typefunction notifier_to_unicam_devicefunction sd_to_unicam_devicefunction unicam_releasefunction unicam_putfunction unicam_sd_pad_is_sourcefunction is_metadata_nodefunction is_image_nodefunction unicam_find_format_by_codefunction unicam_find_format_by_fourccfunction unicam_calc_image_size_bplfunction unicam_calc_meta_size_bplfunction unicam_clk_writefunction unicam_reg_readfunction unicam_reg_writefunction unicam_get_fieldfunction unicam_set_fieldfunction unicam_reg_write_fieldfunction unicam_wr_dma_addrfunction unicam_get_lines_donefunction unicam_schedule_next_bufferfunction unicam_schedule_dummy_bufferfunction unicam_process_buffer_completefunction unicam_queue_event_soffunction unicam_isrfunction simultaneouslyfunction unicam_set_packing_configfunction unicam_cfg_image_idfunction unicam_enable_edfunction unicam_get_image_vc_dtfunction unicam_start_rxfunction unicam_start_metadatafunction unicam_disablefunction __unicam_subdev_set_routingfunction for_each_active_routefunction unicam_subdev_init_statefunction unicam_subdev_enum_mbus_codefunction unicam_subdev_enum_frame_sizefunction unicam_subdev_set_formatfunction unicam_subdev_set_routingfunction unicam_sd_enable_streamsfunction unicam_sd_disable_streamsfunction unicam_subdev_init
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
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `struct unicam_format_info`, `struct unicam_buffer`, `struct unicam_node`, `struct unicam_device`, `enum unicam_pad`, `enum unicam_node_type`, `function notifier_to_unicam_device`, `function sd_to_unicam_device`, `function unicam_release`, `function unicam_put`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.