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.

Dependency Surface

Detected Declarations

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

Implementation Notes