drivers/gpu/drm/vkms/vkms_composer.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vkms/vkms_composer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vkms/vkms_composer.c- Extension
.c- Size
- 23069 bytes
- Lines
- 736
- 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.
- 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/crc32.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_blend.hdrm/drm_colorop.hdrm/drm_fourcc.hdrm/drm_fixed.hdrm/drm_gem_framebuffer_helper.hdrm/drm_print.hdrm/drm_vblank.hlinux/minmax.hkunit/visibility.hvkms_composer.hvkms_luts.h
Detected Declarations
function pre_mul_blend_channelfunction drm_plane_create_blend_mode_propertyfunction fill_backgroundfunction lerp_u16function get_lut_indexfunction apply_lut_to_channel_valuefunction apply_lutfunction apply_3x4_matrixfunction apply_coloropfunction pre_blend_color_transformfunction direction_for_rotationfunction clamp_line_coordinatesfunction blend_linefunction pixelsfunction check_format_funcsfunction check_iosys_mapfunction compose_active_planesfunction vkms_vblank_simulatefunction vkms_crc_parse_sourcefunction vkms_verify_crc_sourcefunction vkms_set_composerfunction vkms_set_crc_source
Annotated Snippet
switch (colorop_state->curve_1d_type) {
case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF:
pixel->r = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->r, LUT_RED);
pixel->g = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->g, LUT_GREEN);
pixel->b = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->b, LUT_BLUE);
break;
case DRM_COLOROP_1D_CURVE_SRGB_EOTF:
pixel->r = apply_lut_to_channel_value(&srgb_eotf, pixel->r, LUT_RED);
pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN);
pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE);
break;
default:
drm_WARN_ONCE(dev, true,
"unknown colorop 1D curve type %d\n",
colorop_state->curve_1d_type);
break;
}
} else if (colorop->type == DRM_COLOROP_CTM_3X4) {
if (colorop_state->data)
apply_3x4_matrix(pixel,
(struct drm_color_ctm_3x4 *)colorop_state->data->data);
}
}
static void pre_blend_color_transform(const struct vkms_plane_state *plane_state,
struct line_buffer *output_buffer)
{
struct pixel_argb_s32 pixel;
for (size_t x = 0; x < output_buffer->n_pixels; x++) {
struct drm_colorop *colorop = plane_state->base.base.color_pipeline;
/*
* Some operations, such as applying a BT709 encoding matrix,
* followed by a decoding matrix, require that we preserve
* values above 1.0 and below 0.0 until the end of the pipeline.
*
* Pack the 16-bit UNORM values into s32 to give us head-room to
* avoid clipping until we're at the end of the pipeline. Clip
* intentionally at the end of the pipeline before packing
* UNORM values back into u16.
*/
pixel.a = output_buffer->pixels[x].a;
pixel.r = output_buffer->pixels[x].r;
pixel.g = output_buffer->pixels[x].g;
pixel.b = output_buffer->pixels[x].b;
while (colorop) {
struct drm_colorop_state *colorop_state;
colorop_state = colorop->state;
if (!colorop_state)
return;
if (!colorop_state->bypass)
apply_colorop(&pixel, colorop);
colorop = colorop->next;
}
/* clamp values */
output_buffer->pixels[x].a = clamp_val(pixel.a, 0, 0xffff);
output_buffer->pixels[x].r = clamp_val(pixel.r, 0, 0xffff);
output_buffer->pixels[x].g = clamp_val(pixel.g, 0, 0xffff);
output_buffer->pixels[x].b = clamp_val(pixel.b, 0, 0xffff);
}
}
/**
* direction_for_rotation() - Get the correct reading direction for a given rotation
*
* @rotation: Rotation to analyze. It correspond the field @frame_info.rotation.
*
* This function will use the @rotation setting of a source plane to compute the reading
* direction in this plane which correspond to a "left to right writing" in the CRTC.
* For example, if the buffer is reflected on X axis, the pixel must be read from right to left
* to be written from left to right on the CRTC.
*/
static enum pixel_read_direction direction_for_rotation(unsigned int rotation)
{
struct drm_rect tmp_a, tmp_b;
int x, y;
/*
* Points A and B are depicted as zero-size rectangles on the CRTC.
* The CRTC writing direction is from A to B. The plane reading direction
* is discovered by inverse-transforming A and B.
* The reading direction is computed by rotating the vector AB (top-left to top-right) in a
* 1x1 square.
Annotation
- Immediate include surface: `linux/crc32.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_blend.h`, `drm/drm_colorop.h`, `drm/drm_fourcc.h`, `drm/drm_fixed.h`, `drm/drm_gem_framebuffer_helper.h`.
- Detected declarations: `function pre_mul_blend_channel`, `function drm_plane_create_blend_mode_property`, `function fill_background`, `function lerp_u16`, `function get_lut_index`, `function apply_lut_to_channel_value`, `function apply_lut`, `function apply_3x4_matrix`, `function apply_colorop`, `function pre_blend_color_transform`.
- 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.