drivers/media/platform/st/stm32/dma2d/dma2d.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/st/stm32/dma2d/dma2d.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/st/stm32/dma2d/dma2d.c- Extension
.c- Size
- 18016 bytes
- Lines
- 728
- 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/module.hlinux/fs.hlinux/timer.hlinux/sched.hlinux/slab.hlinux/clk.hlinux/interrupt.hlinux/of.hlinux/platform_device.hmedia/v4l2-mem2mem.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/v4l2-event.hmedia/videobuf2-v4l2.hmedia/videobuf2-dma-contig.hdma2d.hdma2d-regs.h
Detected Declarations
function Copyrightfunction dma2d_queue_setupfunction dma2d_buf_out_validatefunction dma2d_buf_preparefunction dma2d_buf_queuefunction dma2d_start_streamingfunction dma2d_stop_streamingfunction queue_initfunction dma2d_s_ctrlfunction dma2d_setup_ctrlsfunction dma2d_openfunction dma2d_releasefunction vidioc_querycapfunction vidioc_enum_fmtfunction vidioc_g_fmtfunction vidioc_try_fmtfunction vidioc_s_fmtfunction device_runfunction dma2d_isrfunction dma2d_probefunction dma2d_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* STM32 DMA2D - 2D Graphics Accelerator Driver
*
* Copyright (c) 2021 Dillon Min
* Dillon Min, <dillon.minfei@gmail.com>
*
* based on s5p-g2d
*
* Copyright (c) 2011 Samsung Electronics Co., Ltd.
* Kamil Debski, <k.debski@samsung.com>
*/
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/timer.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <media/v4l2-mem2mem.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-event.h>
#include <media/videobuf2-v4l2.h>
#include <media/videobuf2-dma-contig.h>
#include "dma2d.h"
#include "dma2d-regs.h"
/*
* This V4L2 subdev m2m driver enables Chrom-Art Accelerator unit
* of STMicroelectronics STM32 SoC series.
*
* Currently support r2m, m2m, m2m_pfc.
*
* - r2m, Filling a part or the whole of a destination image with a specific
* color.
* - m2m, Copying a part or the whole of a source image into a part or the
* whole of a destination.
* - m2m_pfc, Copying a part or the whole of a source image into a part or the
* whole of a destination image with a pixel format conversion.
*/
static inline struct dma2d_ctx *file2ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct dma2d_ctx, fh);
}
static const struct dma2d_fmt formats[] = {
{
.fourcc = V4L2_PIX_FMT_ARGB32,
.cmode = DMA2D_CMODE_ARGB8888,
.depth = 32,
},
{
.fourcc = V4L2_PIX_FMT_RGB24,
.cmode = DMA2D_CMODE_RGB888,
.depth = 24,
},
{
.fourcc = V4L2_PIX_FMT_RGB565,
.cmode = DMA2D_CMODE_RGB565,
.depth = 16,
},
{
.fourcc = V4L2_PIX_FMT_ARGB555,
.cmode = DMA2D_CMODE_ARGB1555,
.depth = 16,
},
{
.fourcc = V4L2_PIX_FMT_ARGB444,
.cmode = DMA2D_CMODE_ARGB4444,
.depth = 16,
},
};
#define NUM_FORMATS ARRAY_SIZE(formats)
static const struct dma2d_frame def_frame = {
.width = DEFAULT_WIDTH,
.height = DEFAULT_HEIGHT,
.line_offset = 0,
.a_rgb = {0x00, 0x00, 0x00, 0xff},
.a_mode = DMA2D_ALPHA_MODE_NO_MODIF,
.fmt = (struct dma2d_fmt *)&formats[0],
.size = DEFAULT_SIZE,
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/timer.h`, `linux/sched.h`, `linux/slab.h`, `linux/clk.h`, `linux/interrupt.h`, `linux/of.h`.
- Detected declarations: `function Copyright`, `function dma2d_queue_setup`, `function dma2d_buf_out_validate`, `function dma2d_buf_prepare`, `function dma2d_buf_queue`, `function dma2d_start_streaming`, `function dma2d_stop_streaming`, `function queue_init`, `function dma2d_s_ctrl`, `function dma2d_setup_ctrls`.
- 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.