drivers/gpu/drm/drm_writeback.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_writeback.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_writeback.c- Extension
.c- Size
- 19979 bytes
- Lines
- 594
- 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/dma-fence.hlinux/export.hdrm/drm_crtc.hdrm/drm_device.hdrm/drm_drv.hdrm/drm_framebuffer.hdrm/drm_managed.hdrm/drm_modeset_helper_vtables.hdrm/drm_property.hdrm/drm_writeback.h
Detected Declarations
function commitfunction drm_writeback_fence_get_timeline_namefunction create_writeback_propertiesfunction drm_connector_initfunction delete_writeback_propertiesfunction __drm_writeback_connector_initfunction drm_connector_initfunction drm_writeback_connector_cleanupfunction drmm_writeback_connector_initfunction drm_writeback_set_fbfunction drm_writeback_prepare_jobfunction hardwarefunction drm_writeback_cleanup_jobfunction cleanup_workfunction drm_writeback_signal_completionfunction drm_writeback_get_out_fenceexport drm_writeback_connector_initexport drm_writeback_connector_init_with_encoderexport drmm_writeback_connector_initexport drm_writeback_prepare_jobexport drm_writeback_queue_jobexport drm_writeback_cleanup_jobexport drm_writeback_signal_completionexport drm_writeback_get_out_fence
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* (C) COPYRIGHT 2016 ARM Limited. All rights reserved.
* Author: Brian Starkey <brian.starkey@arm.com>
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*/
#include <linux/dma-fence.h>
#include <linux/export.h>
#include <drm/drm_crtc.h>
#include <drm/drm_device.h>
#include <drm/drm_drv.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_managed.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_property.h>
#include <drm/drm_writeback.h>
/**
* DOC: overview
*
* Writeback connectors are used to expose hardware which can write the output
* from a CRTC to a memory buffer. They are used and act similarly to other
* types of connectors, with some important differences:
*
* * Writeback connectors don't provide a way to output visually to the user.
*
* * Writeback connectors are visible to userspace only when the client sets
* DRM_CLIENT_CAP_WRITEBACK_CONNECTORS.
*
* * Writeback connectors don't have EDID.
*
* A framebuffer may only be attached to a writeback connector when the
* connector is attached to a CRTC. The WRITEBACK_FB_ID property which sets the
* framebuffer applies only to a single commit (see below). A framebuffer may
* not be attached while the CRTC is off.
*
* Unlike with planes, when a writeback framebuffer is removed by userspace DRM
* makes no attempt to remove it from active use by the connector. This is
* because no method is provided to abort a writeback operation, and in any
* case making a new commit whilst a writeback is ongoing is undefined (see
* WRITEBACK_OUT_FENCE_PTR below). As soon as the current writeback is finished,
* the framebuffer will automatically no longer be in active use. As it will
* also have already been removed from the framebuffer list, there will be no
* way for any userspace application to retrieve a reference to it in the
* intervening period.
*
* Writeback connectors have some additional properties, which userspace
* can use to query and control them:
*
* "WRITEBACK_FB_ID":
* Write-only object property storing a DRM_MODE_OBJECT_FB: it stores the
* framebuffer to be written by the writeback connector. This property is
* similar to the FB_ID property on planes, but will always read as zero
* and is not preserved across commits.
* Userspace must set this property to an output buffer every time it
* wishes the buffer to get filled.
*
* "WRITEBACK_PIXEL_FORMATS":
* Immutable blob property to store the supported pixel formats table. The
* data is an array of u32 DRM_FORMAT_* fourcc values.
* Userspace can use this blob to find out what pixel formats are supported
* by the connector's writeback engine.
*
* "WRITEBACK_OUT_FENCE_PTR":
* Userspace can use this property to provide a pointer for the kernel to
* fill with a sync_file file descriptor, which will signal once the
* writeback is finished. The value should be the address of a 32-bit
* signed integer, cast to a u64.
* Userspace should wait for this fence to signal before making another
* commit affecting any of the same CRTCs, Planes or Connectors.
* **Failure to do so will result in undefined behaviour.**
* For this reason it is strongly recommended that all userspace
* applications making use of writeback connectors *always* retrieve an
* out-fence for the commit and use it appropriately.
* From userspace, this property will always read as zero.
*/
#define fence_to_wb_connector(x) container_of(x->extern_lock, \
struct drm_writeback_connector, \
fence_lock)
static const char *drm_writeback_fence_get_driver_name(struct dma_fence *fence)
{
struct drm_writeback_connector *wb_connector =
Annotation
- Immediate include surface: `linux/dma-fence.h`, `linux/export.h`, `drm/drm_crtc.h`, `drm/drm_device.h`, `drm/drm_drv.h`, `drm/drm_framebuffer.h`, `drm/drm_managed.h`, `drm/drm_modeset_helper_vtables.h`.
- Detected declarations: `function commit`, `function drm_writeback_fence_get_timeline_name`, `function create_writeback_properties`, `function drm_connector_init`, `function delete_writeback_properties`, `function __drm_writeback_connector_init`, `function drm_connector_init`, `function drm_writeback_connector_cleanup`, `function drmm_writeback_connector_init`, `function drm_writeback_set_fb`.
- 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.