drivers/gpu/drm/drm_format_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_format_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_format_helper.c- Extension
.c- Size
- 50823 bytes
- Lines
- 1382
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- 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/export.hlinux/io.hlinux/iosys-map.hlinux/module.hlinux/slab.hdrm/drm_device.hdrm/drm_format_helper.hdrm/drm_framebuffer.hdrm/drm_fourcc.hdrm/drm_print.hdrm/drm_rect.hdrm_format_internal.h
Detected Declarations
function drm_format_conv_state_initfunction drm_format_conv_state_copyfunction drm_format_conv_state_initfunction clip_offsetfunction drm_fb_clip_offsetfunction __drm_fb_xfrmfunction __drm_fb_xfrm_toiofunction drm_fb_xfrmfunction drm_fb_xfrm_line_32to8function drm_fb_xfrm_line_32to16function drm_fb_xfrm_line_32to24function drm_fb_xfrm_line_32to32function drm_fb_memcpyfunction drm_fb_swab16_linefunction drm_fb_swab32_linefunction drm_fb_swabfunction drm_fb_xrgb8888_to_rgb332_linefunction drm_fb_xrgb8888_to_rgb332function drm_fb_xrgb8888_to_rgb565_linefunction drm_fb_xrgb8888_to_rgb565function drm_fb_xrgb8888_to_rgb565be_linefunction drm_fb_xrgb8888_to_rgb565befunction drm_fb_xrgb8888_to_xrgb1555_linefunction drm_fb_xrgb8888_to_xrgb1555function drm_fb_xrgb8888_to_argb1555_linefunction drm_fb_xrgb8888_to_argb1555function drm_fb_xrgb8888_to_rgba5551_linefunction drm_fb_xrgb8888_to_rgba5551function drm_fb_xrgb8888_to_rgb888_linefunction drm_fb_xrgb8888_to_rgb888function drm_fb_xrgb8888_to_bgr888_linefunction drm_fb_xrgb8888_to_bgr888function drm_fb_xrgb8888_to_argb8888_linefunction drm_fb_xrgb8888_to_argb8888function drm_fb_xrgb8888_to_abgr8888_linefunction drm_fb_xrgb8888_to_abgr8888function drm_fb_xrgb8888_to_xbgr8888_linefunction drm_fb_xrgb8888_to_xbgr8888function drm_fb_xrgb8888_to_bgrx8888_linefunction drm_fb_xrgb8888_to_bgrx8888function drm_fb_xrgb8888_to_xrgb2101010_linefunction drm_fb_xrgb8888_to_xrgb2101010function drm_fb_xrgb8888_to_argb2101010_linefunction drm_fb_xrgb8888_to_argb2101010function drm_fb_xrgb8888_to_gray8_linefunction drm_fb_xrgb8888_to_gray8function drm_fb_argb8888_to_argb4444_linefunction drm_fb_argb8888_to_argb4444
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 or MIT
/*
* Copyright (C) 2016 Noralf Trønnes
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/export.h>
#include <linux/io.h>
#include <linux/iosys-map.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <drm/drm_device.h>
#include <drm/drm_format_helper.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_print.h>
#include <drm/drm_rect.h>
#include "drm_format_internal.h"
/**
* drm_format_conv_state_init - Initialize format-conversion state
* @state: The state to initialize
*
* Clears all fields in struct drm_format_conv_state. The state will
* be empty with no preallocated resources.
*/
void drm_format_conv_state_init(struct drm_format_conv_state *state)
{
state->tmp.mem = NULL;
state->tmp.size = 0;
state->tmp.preallocated = false;
}
EXPORT_SYMBOL(drm_format_conv_state_init);
/**
* drm_format_conv_state_copy - Copy format-conversion state
* @state: Destination state
* @old_state: Source state
*
* Copies format-conversion state from @old_state to @state; except for
* temporary storage.
*/
void drm_format_conv_state_copy(struct drm_format_conv_state *state,
const struct drm_format_conv_state *old_state)
{
/*
* So far, there's only temporary storage here, which we don't
* duplicate. Just clear the fields.
*/
state->tmp.mem = NULL;
state->tmp.size = 0;
state->tmp.preallocated = false;
}
EXPORT_SYMBOL(drm_format_conv_state_copy);
/**
* drm_format_conv_state_reserve - Allocates storage for format conversion
* @state: The format-conversion state
* @new_size: The minimum allocation size
* @flags: Flags for kmalloc()
*
* Allocates at least @new_size bytes and returns a pointer to the memory
* range. After calling this function, previously returned memory blocks
* are invalid. It's best to collect all memory requirements of a format
* conversion and call this function once to allocate the range.
*
* Returns:
* A pointer to the allocated memory range, or NULL otherwise.
*/
void *drm_format_conv_state_reserve(struct drm_format_conv_state *state,
size_t new_size, gfp_t flags)
{
void *mem;
if (new_size <= state->tmp.size)
goto out;
else if (state->tmp.preallocated)
return NULL;
mem = krealloc(state->tmp.mem, new_size, flags);
if (!mem)
return NULL;
state->tmp.mem = mem;
Annotation
- Immediate include surface: `linux/export.h`, `linux/io.h`, `linux/iosys-map.h`, `linux/module.h`, `linux/slab.h`, `drm/drm_device.h`, `drm/drm_format_helper.h`, `drm/drm_framebuffer.h`.
- Detected declarations: `function drm_format_conv_state_init`, `function drm_format_conv_state_copy`, `function drm_format_conv_state_init`, `function clip_offset`, `function drm_fb_clip_offset`, `function __drm_fb_xfrm`, `function __drm_fb_xfrm_toio`, `function drm_fb_xfrm`, `function drm_fb_xfrm_line_32to8`, `function drm_fb_xfrm_line_32to16`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
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.