drivers/media/platform/samsung/s5p-g2d/g2d.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/samsung/s5p-g2d/g2d.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/samsung/s5p-g2d/g2d.c- Extension
.c- Size
- 18722 bytes
- Lines
- 788
- 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/videobuf2-v4l2.hmedia/videobuf2-dma-contig.hg2d.hg2d-regs.h
Detected Declarations
function Copyrightfunction g2d_queue_setupfunction g2d_buf_preparefunction g2d_buf_queuefunction queue_initfunction g2d_s_ctrlfunction g2d_setup_ctrlsfunction g2d_openfunction g2d_releasefunction vidioc_querycapfunction vidioc_enum_fmtfunction vidioc_g_fmtfunction vidioc_try_fmtfunction vidioc_s_fmtfunction vidioc_g_selectionfunction vidioc_try_selectionfunction vidioc_s_selectionfunction device_runfunction g2d_isrfunction g2d_probefunction g2d_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Samsung S5P G2D - 2D Graphics Accelerator Driver
*
* 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/videobuf2-v4l2.h>
#include <media/videobuf2-dma-contig.h>
#include "g2d.h"
#include "g2d-regs.h"
static inline struct g2d_ctx *file2ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct g2d_ctx, fh);
}
static struct g2d_fmt formats[] = {
{
.fourcc = V4L2_PIX_FMT_RGB32,
.depth = 32,
.hw = COLOR_MODE(ORDER_XRGB, MODE_XRGB_8888),
},
{
.fourcc = V4L2_PIX_FMT_RGB565X,
.depth = 16,
.hw = COLOR_MODE(ORDER_XRGB, MODE_RGB_565),
},
{
.fourcc = V4L2_PIX_FMT_RGB555X,
.depth = 16,
.hw = COLOR_MODE(ORDER_XRGB, MODE_XRGB_1555),
},
{
.fourcc = V4L2_PIX_FMT_RGB444,
.depth = 16,
.hw = COLOR_MODE(ORDER_XRGB, MODE_XRGB_4444),
},
{
.fourcc = V4L2_PIX_FMT_RGB24,
.depth = 24,
.hw = COLOR_MODE(ORDER_XRGB, MODE_PACKED_RGB_888),
},
};
#define NUM_FORMATS ARRAY_SIZE(formats)
static struct g2d_frame def_frame = {
.width = DEFAULT_WIDTH,
.height = DEFAULT_HEIGHT,
.c_width = DEFAULT_WIDTH,
.c_height = DEFAULT_HEIGHT,
.o_width = 0,
.o_height = 0,
.fmt = &formats[0],
.right = DEFAULT_WIDTH,
.bottom = DEFAULT_HEIGHT,
};
static struct g2d_fmt *find_fmt(struct v4l2_format *f)
{
unsigned int i;
for (i = 0; i < NUM_FORMATS; i++) {
if (formats[i].fourcc == f->fmt.pix.pixelformat)
return &formats[i];
}
return NULL;
}
static struct g2d_frame *get_frame(struct g2d_ctx *ctx,
enum v4l2_buf_type type)
{
switch (type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
return &ctx->in;
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 g2d_queue_setup`, `function g2d_buf_prepare`, `function g2d_buf_queue`, `function queue_init`, `function g2d_s_ctrl`, `function g2d_setup_ctrls`, `function g2d_open`, `function g2d_release`, `function vidioc_querycap`.
- 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.