drivers/gpu/drm/drm_blend.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_blend.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_blend.c- Extension
.c- Size
- 23190 bytes
- Lines
- 655
- 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/export.hlinux/slab.hlinux/sort.hdrm/drm_atomic.hdrm/drm_blend.hdrm/drm_device.hdrm/drm_print.hdrm_crtc_internal.h
Detected Declarations
function Copyrightfunction drm_rotation_simplifyfunction drm_rotation_simplifyfunction drm_atomic_normalize_zposfunction hardwarefunction drm_atomic_commit_zpos_cmpfunction drm_atomic_helper_crtc_normalize_zposfunction drm_atomic_normalize_zposfunction for_each_oldnew_plane_in_statefunction for_each_oldnew_crtc_in_statefunction BITfunction drm_crtc_attach_background_color_propertyexport drm_plane_create_alpha_propertyexport drm_plane_create_rotation_propertyexport drm_rotation_simplifyexport drm_plane_create_zpos_propertyexport drm_plane_create_zpos_immutable_propertyexport drm_atomic_normalize_zposexport drm_plane_create_blend_mode_propertyexport drm_crtc_attach_background_color_property
Annotated Snippet
if (IS_ERR(plane_state)) {
ret = PTR_ERR(plane_state);
goto done;
}
states[n++] = plane_state;
drm_dbg_atomic(dev, "[PLANE:%d:%s] processing zpos value %d\n",
plane->base.id, plane->name, plane_state->zpos);
}
sort(states, n, sizeof(*states), drm_atomic_commit_zpos_cmp, NULL);
for (i = 0; i < n; i++) {
plane = states[i]->plane;
states[i]->normalized_zpos = i;
drm_dbg_atomic(dev, "[PLANE:%d:%s] normalized zpos value %d\n",
plane->base.id, plane->name, i);
}
crtc_state->zpos_changed = true;
done:
kfree(states);
return ret;
}
/**
* drm_atomic_normalize_zpos - calculate normalized zpos values for all crtcs
* @dev: DRM device
* @state: atomic state of DRM device
*
* This function calculates normalized zpos value for all modified planes in
* the provided atomic state of DRM device.
*
* For every CRTC this function checks new states of all planes assigned to
* it and calculates normalized zpos value for these planes. Planes are compared
* first by their zpos values, then by plane id (if zpos is equal). The plane
* with lowest zpos value is at the bottom. The &drm_plane_state.normalized_zpos
* is then filled with unique values from 0 to number of active planes in crtc
* minus one.
*
* RETURNS
* Zero for success or -errno
*/
int drm_atomic_normalize_zpos(struct drm_device *dev,
struct drm_atomic_commit *state)
{
struct drm_crtc *crtc;
struct drm_crtc_state *old_crtc_state, *new_crtc_state;
struct drm_plane *plane;
struct drm_plane_state *old_plane_state, *new_plane_state;
int i, ret = 0;
for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
crtc = new_plane_state->crtc;
if (!crtc)
continue;
if (old_plane_state->zpos != new_plane_state->zpos) {
new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
new_crtc_state->zpos_changed = true;
}
}
for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
if (old_crtc_state->plane_mask != new_crtc_state->plane_mask ||
new_crtc_state->zpos_changed) {
ret = drm_atomic_helper_crtc_normalize_zpos(crtc,
new_crtc_state);
if (ret)
return ret;
}
}
return 0;
}
EXPORT_SYMBOL(drm_atomic_normalize_zpos);
/**
* drm_plane_create_blend_mode_property - create a new blend mode property
* @plane: drm plane
* @supported_modes: bitmask of supported modes, must include
* BIT(DRM_MODE_BLEND_PREMULTI). Current DRM assumption is
* that alpha is premultiplied, and old userspace can break if
* the property defaults to anything else.
*
* This creates a new property describing the blend mode.
*
* The property exposed to userspace is an enumeration property (see
* drm_property_create_enum()) called "pixel blend mode" and has the
* following enumeration values:
*
* "None":
Annotation
- Immediate include surface: `linux/export.h`, `linux/slab.h`, `linux/sort.h`, `drm/drm_atomic.h`, `drm/drm_blend.h`, `drm/drm_device.h`, `drm/drm_print.h`, `drm_crtc_internal.h`.
- Detected declarations: `function Copyright`, `function drm_rotation_simplify`, `function drm_rotation_simplify`, `function drm_atomic_normalize_zpos`, `function hardware`, `function drm_atomic_commit_zpos_cmp`, `function drm_atomic_helper_crtc_normalize_zpos`, `function drm_atomic_normalize_zpos`, `function for_each_oldnew_plane_in_state`, `function for_each_oldnew_crtc_in_state`.
- 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.