drivers/gpu/drm/vkms/vkms_formats.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vkms/vkms_formats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vkms/vkms_formats.c- Extension
.c- Size
- 34174 bytes
- Lines
- 972
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/minmax.hdrm/drm_blend.hdrm/drm_rect.hdrm/drm_fixed.hkunit/visibility.hvkms_formats.h
Detected Declarations
function packed_pixels_offsetfunction packed_pixels_addrfunction get_block_step_bytesfunction packed_pixels_addr_1x1function get_subsamplingfunction get_subsampling_offsetfunction datafunction argb_u16_from_u16161616function argb_u16_from_le16161616function argb_u16_from_RGB565function argb_u16_from_gray8function argb_u16_from_grayu16function argb_u16_from_BGR565function argb_u16_from_yuv161616function READ_LINE_ARGB8888function R1_read_linefunction R2_read_linefunction R4_read_linefunction planefunction vkms_writeback_rowfunction argb_u16_to_XRGB8888function argb_u16_to_ABGR8888function argb_u16_to_ARGB16161616function argb_u16_to_XRGB16161616function argb_u16_to_RGB565function vkms_writeback_rowfunction get_pixel_read_line_functionfunction swap_uv_columnsfunction get_conversion_matrix_to_argb_u16function get_pixel_write_functionexport get_conversion_matrix_to_argb_u16
Annotated Snippet
if (direction == READ_LEFT_TO_RIGHT) {
restart_bit_offset = 8 - bits_per_pixel;
step_bit_offset = -bits_per_pixel;
} else {
restart_bit_offset = 0;
step_bit_offset = bits_per_pixel;
}
while (out_pixel < end) {
u8 val = ((*src_pixels) >> bit_offset) & mask;
*out_pixel = argb_u16_from_grayu16((int)val * lum_per_level);
bit_offset += step_bit_offset;
if (bit_offset < 0 || 8 <= bit_offset) {
bit_offset = restart_bit_offset;
src_pixels += step;
}
out_pixel += 1;
}
} else if (direction == READ_TOP_TO_BOTTOM || direction == READ_BOTTOM_TO_TOP) {
while (out_pixel < end) {
u8 val = (*src_pixels >> bit_offset) & mask;
*out_pixel = argb_u16_from_grayu16((int)val * lum_per_level);
src_pixels += step;
out_pixel += 1;
}
}
}
static void R1_read_line(const struct vkms_plane_state *plane, int x_start,
int y_start, enum pixel_read_direction direction, int count,
struct pixel_argb_u16 out_pixel[])
{
Rx_read_line(plane, x_start, y_start, direction, count, out_pixel);
}
static void R2_read_line(const struct vkms_plane_state *plane, int x_start,
int y_start, enum pixel_read_direction direction, int count,
struct pixel_argb_u16 out_pixel[])
{
Rx_read_line(plane, x_start, y_start, direction, count, out_pixel);
}
static void R4_read_line(const struct vkms_plane_state *plane, int x_start,
int y_start, enum pixel_read_direction direction, int count,
struct pixel_argb_u16 out_pixel[])
{
Rx_read_line(plane, x_start, y_start, direction, count, out_pixel);
}
READ_LINE_ARGB8888(XRGB8888_read_line, px, 0xFF, px[2], px[1], px[0])
READ_LINE_ARGB8888(XBGR8888_read_line, px, 0xFF, px[0], px[1], px[2])
READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0])
READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2])
READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1])
READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3])
READ_LINE_ARGB8888(RGB888_read_line, px, 0xFF, px[2], px[1], px[0])
READ_LINE_ARGB8888(BGR888_read_line, px, 0xFF, px[0], px[1], px[2])
READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0])
READ_LINE_le16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2])
READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0])
READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2])
READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px)
READ_LINE(BGR565_read_line, px, __le16, argb_u16_from_BGR565, px)
READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px)
/*
* This callback can be used for YUV formats where U and V values are
* stored in the same plane (often called semi-planar formats). It will
* correctly handle subsampling as described in the drm_format_info of the plane.
*
* The conversion matrix stored in the @plane is used to:
* - Apply the correct color range and encoding
* - Convert YUV and YVU with the same function (a column swap is needed when setting up
* plane->conversion_matrix)
*/
/**
* READ_LINE_YUV_SEMIPLANAR() - Generic generator for a read_line function which can be used for yuv
* formats with two planes and block_w == block_h == 1.
*
* @function_name: Function name to generate
* @pixel_1_name: temporary pixel name for the first plane used in the @__VA_ARGS__ parameters
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/minmax.h`, `drm/drm_blend.h`, `drm/drm_rect.h`, `drm/drm_fixed.h`, `kunit/visibility.h`, `vkms_formats.h`.
- Detected declarations: `function packed_pixels_offset`, `function packed_pixels_addr`, `function get_block_step_bytes`, `function packed_pixels_addr_1x1`, `function get_subsampling`, `function get_subsampling_offset`, `function data`, `function argb_u16_from_u16161616`, `function argb_u16_from_le16161616`, `function argb_u16_from_RGB565`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.