drivers/gpu/drm/drm_fb_dma_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_fb_dma_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_fb_dma_helper.c- Extension
.c- Size
- 5746 bytes
- Lines
- 198
- 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
drm/drm_damage_helper.hdrm/drm_fb_dma_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_dma_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_panic.hdrm/drm_plane.hlinux/dma-mapping.hlinux/export.hlinux/module.h
Detected Declarations
function Copyrightfunction drm_fb_dma_get_gem_addrfunction drm_fb_dma_sync_non_coherentfunction drm_atomic_for_each_plane_damagefunction get_scanout_bufferexport drm_fb_dma_get_gem_objexport drm_fb_dma_get_gem_addrexport drm_fb_dma_sync_non_coherentexport drm_fb_dma_get_scanout_buffer
Annotated Snippet
drm_atomic_for_each_plane_damage(&iter, &clip) {
/* Ignore x1/x2 values, invalidate complete lines */
offset = clip.y1 * state->fb->pitches[i];
nb_bytes = (clip.y2 - clip.y1) * state->fb->pitches[i];
dma_sync_single_for_device(drm->dev, daddr + offset,
nb_bytes, DMA_TO_DEVICE);
}
}
}
EXPORT_SYMBOL_GPL(drm_fb_dma_sync_non_coherent);
/**
* drm_fb_dma_get_scanout_buffer - Provide a scanout buffer in case of panic
* @plane: DRM primary plane
* @sb: scanout buffer for the panic handler
* Returns: 0 or negative error code
*
* Generic get_scanout_buffer() implementation, for drivers that uses the
* drm_fb_dma_helper. It won't call vmap in the panic context, so the driver
* should make sure the primary plane is vmapped, otherwise the panic screen
* won't get displayed.
*/
int drm_fb_dma_get_scanout_buffer(struct drm_plane *plane,
struct drm_scanout_buffer *sb)
{
struct drm_gem_dma_object *dma_obj;
struct drm_framebuffer *fb;
if (!plane->state || !plane->state->fb)
return -EINVAL;
fb = plane->state->fb;
/* Only support linear modifier */
if (fb->modifier != DRM_FORMAT_MOD_LINEAR)
return -ENODEV;
dma_obj = drm_fb_dma_get_gem_obj(fb, 0);
/* Buffer should be accessible from the CPU */
if (drm_gem_is_imported(&dma_obj->base))
return -ENODEV;
/* Buffer should be already mapped to CPU */
if (!dma_obj->vaddr)
return -ENODEV;
iosys_map_set_vaddr(&sb->map[0], dma_obj->vaddr);
sb->format = fb->format;
sb->height = fb->height;
sb->width = fb->width;
sb->pitch[0] = fb->pitches[0];
return 0;
}
EXPORT_SYMBOL(drm_fb_dma_get_scanout_buffer);
Annotation
- Immediate include surface: `drm/drm_damage_helper.h`, `drm/drm_fb_dma_helper.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`, `drm/drm_gem_dma_helper.h`, `drm/drm_gem_framebuffer_helper.h`, `drm/drm_panic.h`, `drm/drm_plane.h`.
- Detected declarations: `function Copyright`, `function drm_fb_dma_get_gem_addr`, `function drm_fb_dma_sync_non_coherent`, `function drm_atomic_for_each_plane_damage`, `function get_scanout_buffer`, `export drm_fb_dma_get_gem_obj`, `export drm_fb_dma_get_gem_addr`, `export drm_fb_dma_sync_non_coherent`, `export drm_fb_dma_get_scanout_buffer`.
- 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.