drivers/media/platform/marvell/mcam-core.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/marvell/mcam-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/marvell/mcam-core.c- Extension
.c- Size
- 51578 bytes
- Lines
- 1988
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/module.hlinux/fs.hlinux/mm.hlinux/i2c.hlinux/interrupt.hlinux/spinlock.hlinux/slab.hlinux/device.hlinux/wait.hlinux/list.hlinux/dma-mapping.hlinux/delay.hlinux/vmalloc.hlinux/io.hlinux/clk.hlinux/clk-provider.hlinux/videodev2.hlinux/pm_runtime.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/v4l2-ctrls.hmedia/v4l2-event.hmedia/videobuf2-vmalloc.hmedia/videobuf2-dma-contig.hmedia/videobuf2-dma-sg.hmcam-core.h
Detected Declarations
struct mcam_dma_descstruct mcam_vb_bufferfunction mcam_buffer_donefunction mcam_reset_buffersfunction mcam_needs_configfunction mcam_set_config_neededfunction mcam_ctlr_startfunction mcam_ctlr_stopfunction mcam_enable_mipifunction mcam_disable_mipifunction mcam_fmt_is_planarfunction mcam_write_yuv_basesfunction mcam_alloc_dma_bufsfunction mcam_free_dma_bufsfunction mcam_ctlr_dma_vmallocfunction mcam_frame_workfunction mcam_check_dma_buffersfunction mcam_vmalloc_donefunction mcam_alloc_dma_bufsfunction mcam_free_dma_bufsfunction mcam_check_dma_buffersfunction mcam_set_contig_bufferfunction mcam_ctlr_dma_contigfunction mcam_dma_contig_donefunction mcam_sg_next_bufferfunction mcam_ctlr_dma_sgfunction mcam_dma_sg_donefunction mcam_sg_restartfunction mcam_sg_restartfunction mcam_ctlr_imagefunction mcam_ctlr_configurefunction mcam_ctlr_irq_enablefunction mcam_ctlr_irq_disablefunction mcam_ctlr_stop_dmafunction mcam_ctlr_power_upfunction mcam_ctlr_power_downfunction mclk_preparefunction mclk_unpreparefunction mclk_enablefunction mclk_disablefunction mclk_recalc_ratefunction __mcam_cam_resetfunction mcam_cam_initfunction mcam_cam_set_flipfunction mcam_cam_configurefunction mcam_read_setupfunction mcam_vb_queue_setupfunction mcam_vb_buf_queue
Annotated Snippet
struct mcam_dma_desc {
u32 dma_addr;
u32 segment_len;
};
/*
* Our buffer type for working with videobuf2. Note that the vb2
* developers have decreed that struct vb2_v4l2_buffer must be at the
* beginning of this structure.
*/
struct mcam_vb_buffer {
struct vb2_v4l2_buffer vb_buf;
struct list_head queue;
struct mcam_dma_desc *dma_desc; /* Descriptor virtual address */
dma_addr_t dma_desc_pa; /* Descriptor physical address */
};
static inline struct mcam_vb_buffer *vb_to_mvb(struct vb2_v4l2_buffer *vb)
{
return container_of(vb, struct mcam_vb_buffer, vb_buf);
}
/*
* Hand a completed buffer back to user space.
*/
static void mcam_buffer_done(struct mcam_camera *cam, int frame,
struct vb2_v4l2_buffer *vbuf)
{
vbuf->vb2_buf.planes[0].bytesused = cam->pix_format.sizeimage;
vbuf->sequence = cam->buf_seq[frame];
vbuf->field = V4L2_FIELD_NONE;
vbuf->vb2_buf.timestamp = ktime_get_ns();
vb2_set_plane_payload(&vbuf->vb2_buf, 0, cam->pix_format.sizeimage);
vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
}
/*
* Debugging and related.
*/
#define cam_err(cam, fmt, arg...) \
dev_err((cam)->dev, fmt, ##arg);
#define cam_warn(cam, fmt, arg...) \
dev_warn((cam)->dev, fmt, ##arg);
#define cam_dbg(cam, fmt, arg...) \
dev_dbg((cam)->dev, fmt, ##arg);
/*
* Flag manipulation helpers
*/
static void mcam_reset_buffers(struct mcam_camera *cam)
{
int i;
cam->next_buf = -1;
for (i = 0; i < cam->nbufs; i++) {
clear_bit(i, &cam->flags);
clear_bit(CF_FRAME_SOF0 + i, &cam->flags);
}
}
static inline int mcam_needs_config(struct mcam_camera *cam)
{
return test_bit(CF_CONFIG_NEEDED, &cam->flags);
}
static void mcam_set_config_needed(struct mcam_camera *cam, int needed)
{
if (needed)
set_bit(CF_CONFIG_NEEDED, &cam->flags);
else
clear_bit(CF_CONFIG_NEEDED, &cam->flags);
}
/* ------------------------------------------------------------------- */
/*
* Make the controller start grabbing images. Everything must
* be set up before doing this.
*/
static void mcam_ctlr_start(struct mcam_camera *cam)
{
/* set_bit performs a read, so no other barrier should be
needed here */
mcam_reg_set_bit(cam, REG_CTRL0, C0_ENABLE);
}
static void mcam_ctlr_stop(struct mcam_camera *cam)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/fs.h`, `linux/mm.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/spinlock.h`, `linux/slab.h`.
- Detected declarations: `struct mcam_dma_desc`, `struct mcam_vb_buffer`, `function mcam_buffer_done`, `function mcam_reset_buffers`, `function mcam_needs_config`, `function mcam_set_config_needed`, `function mcam_ctlr_start`, `function mcam_ctlr_stop`, `function mcam_enable_mipi`, `function mcam_disable_mipi`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.