drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c- Extension
.c- Size
- 29183 bytes
- Lines
- 1127
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/delay.hlinux/pm_runtime.hmedia/mipi-csi2.hmedia/v4l2-ioctl.hmedia/videobuf2-dma-contig.hrzg2l-cru.hrzg2l-cru-regs.h
Detected Declarations
struct rzg2l_cru_bufferfunction rzg2l_cru_slot_nextfunction __rzg2l_cru_writefunction __rzg2l_cru_readfunction __rzg2l_cru_write_constantfunction __rzg2l_cru_read_constantfunction __rzg2l_cru_write_constantfunction scoped_guardfunction for_each_cru_slot_fromfunction list_for_each_entry_safefunction rzg2l_cru_queue_setupfunction rzg2l_cru_buffer_preparefunction rzg2l_cru_buffer_queuefunction rzg2l_cru_set_slot_addrfunction rzg2l_cru_fill_hw_slotfunction scoped_guardfunction rzg2l_cru_initialize_axifunction rzg2l_cru_csi2_setupfunction rzg2l_cru_initialize_image_convfunction rzg3e_fifo_emptyfunction rzg2l_fifo_emptyfunction rzg2l_cru_stop_image_processingfunction scoped_guardfunction rzg2l_cru_get_virtual_channelfunction rzg3e_cru_enable_interruptsfunction rzg3e_cru_disable_interruptsfunction rzg2l_cru_enable_interruptsfunction rzg2l_cru_disable_interruptsfunction rzg2l_cru_start_image_processingfunction rzg2l_cru_set_streamfunction rzg2l_cru_stop_streamingfunction rzg2l_cru_irqfunction rzg3e_cru_irqfunction rzg2l_cru_start_streaming_vqfunction rzg2l_cru_stop_streaming_vqfunction rzg2l_cru_dma_unregisterfunction rzg2l_cru_dma_registerfunction rzg2l_cru_format_alignfunction rzg2l_cru_try_formatfunction rzg2l_cru_querycapfunction rzg2l_cru_try_fmt_vid_capfunction rzg2l_cru_s_fmt_vid_capfunction rzg2l_cru_g_fmt_vid_capfunction rzg2l_cru_enum_fmt_vid_capfunction rzg2l_cru_enum_framesizesfunction rzg2l_cru_openfunction rzg2l_cru_releasefunction rzg2l_cru_video_link_validate
Annotated Snippet
struct rzg2l_cru_buffer {
struct vb2_v4l2_buffer vb;
struct list_head list;
};
#define to_buf_list(vb2_buffer) \
(&container_of(vb2_buffer, struct rzg2l_cru_buffer, vb)->list)
/*
* The CRU hardware cycles over its slots when transferring frames. All drivers
* structure that contains programming data for the slots, such as the memory
* destination addresses have to be iterated as they were circular buffers.
*
* Provide here utilities to iterate over slots and the associated data.
*/
static inline unsigned int rzg2l_cru_slot_next(struct rzg2l_cru_dev *cru,
unsigned int slot)
{
return (slot + 1) % cru->num_buf;
}
/* Start cycling on cru slots from the one after 'start'. */
#define for_each_cru_slot_from(cru, slot, start) \
for ((slot) = rzg2l_cru_slot_next((cru), (start)); \
(slot) != (start); (slot) = rzg2l_cru_slot_next((cru), (slot)))
/* -----------------------------------------------------------------------------
* DMA operations
*/
static void __rzg2l_cru_write(struct rzg2l_cru_dev *cru, u32 offset, u32 value)
{
const u16 *regs = cru->info->regs;
/*
* CRUnCTRL is a first register on all CRU supported SoCs so validate
* rest of the registers have valid offset being set in cru->info->regs.
*/
if (WARN_ON(offset >= RZG2L_CRU_MAX_REG) ||
WARN_ON(offset != CRUnCTRL && regs[offset] == 0))
return;
iowrite32(value, cru->base + regs[offset]);
}
static u32 __rzg2l_cru_read(struct rzg2l_cru_dev *cru, u32 offset)
{
const u16 *regs = cru->info->regs;
/*
* CRUnCTRL is a first register on all CRU supported SoCs so validate
* rest of the registers have valid offset being set in cru->info->regs.
*/
if (WARN_ON(offset >= RZG2L_CRU_MAX_REG) ||
WARN_ON(offset != CRUnCTRL && regs[offset] == 0))
return 0;
return ioread32(cru->base + regs[offset]);
}
static __always_inline void
__rzg2l_cru_write_constant(struct rzg2l_cru_dev *cru, u32 offset, u32 value)
{
const u16 *regs = cru->info->regs;
BUILD_BUG_ON(offset >= RZG2L_CRU_MAX_REG);
iowrite32(value, cru->base + regs[offset]);
}
static __always_inline u32
__rzg2l_cru_read_constant(struct rzg2l_cru_dev *cru, u32 offset)
{
const u16 *regs = cru->info->regs;
BUILD_BUG_ON(offset >= RZG2L_CRU_MAX_REG);
return ioread32(cru->base + regs[offset]);
}
#define rzg2l_cru_write(cru, offset, value) \
(__builtin_constant_p(offset) ? \
__rzg2l_cru_write_constant(cru, offset, value) : \
__rzg2l_cru_write(cru, offset, value))
#define rzg2l_cru_read(cru, offset) \
(__builtin_constant_p(offset) ? \
__rzg2l_cru_read_constant(cru, offset) : \
__rzg2l_cru_read(cru, offset))
static void rzg2l_cru_return_buffers(struct rzg2l_cru_dev *cru,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/pm_runtime.h`, `media/mipi-csi2.h`, `media/v4l2-ioctl.h`, `media/videobuf2-dma-contig.h`, `rzg2l-cru.h`, `rzg2l-cru-regs.h`.
- Detected declarations: `struct rzg2l_cru_buffer`, `function rzg2l_cru_slot_next`, `function __rzg2l_cru_write`, `function __rzg2l_cru_read`, `function __rzg2l_cru_write_constant`, `function __rzg2l_cru_read_constant`, `function __rzg2l_cru_write_constant`, `function scoped_guard`, `function for_each_cru_slot_from`, `function list_for_each_entry_safe`.
- 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.