drivers/gpu/drm/vkms/vkms_writeback.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vkms/vkms_writeback.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vkms/vkms_writeback.c- Extension
.c- Size
- 5419 bytes
- Lines
- 189
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/iosys-map.hdrm/drm_atomic.hdrm/drm_edid.hdrm/drm_fourcc.hdrm/drm_writeback.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_atomic_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_gem_shmem_helper.hvkms_drv.hvkms_formats.h
Detected Declarations
function vkms_wb_atomic_checkfunction vkms_wb_connector_get_modesfunction vkms_wb_prepare_jobfunction vkms_wb_cleanup_jobfunction vkms_wb_atomic_commitfunction vkms_enable_writeback_connector
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include <linux/iosys-map.h>
#include <drm/drm_atomic.h>
#include <drm/drm_edid.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_writeback.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_gem_shmem_helper.h>
#include "vkms_drv.h"
#include "vkms_formats.h"
static const u32 vkms_wb_formats[] = {
DRM_FORMAT_ARGB8888,
DRM_FORMAT_XRGB8888,
DRM_FORMAT_ABGR8888,
DRM_FORMAT_XRGB16161616,
DRM_FORMAT_ARGB16161616,
DRM_FORMAT_RGB565
};
static const struct drm_connector_funcs vkms_wb_connector_funcs = {
.fill_modes = drm_helper_probe_single_connector_modes,
.reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
};
static int vkms_wb_atomic_check(struct drm_connector *connector,
struct drm_atomic_commit *state)
{
struct drm_connector_state *conn_state =
drm_atomic_get_new_connector_state(state, connector);
struct drm_crtc_state *crtc_state;
struct drm_framebuffer *fb;
const struct drm_display_mode *mode;
int ret;
if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
return 0;
if (!conn_state->crtc)
return 0;
crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
mode = &crtc_state->mode;
fb = conn_state->writeback_job->fb;
if (fb->width != mode->hdisplay || fb->height != mode->vdisplay) {
DRM_DEBUG_KMS("Invalid framebuffer size %ux%u\n",
fb->width, fb->height);
return -EINVAL;
}
ret = drm_atomic_helper_check_wb_connector_state(connector, state);
if (ret < 0)
return ret;
return 0;
}
static int vkms_wb_connector_get_modes(struct drm_connector *connector)
{
struct drm_device *dev = connector->dev;
return drm_add_modes_noedid(connector, dev->mode_config.max_width,
dev->mode_config.max_height);
}
static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector,
struct drm_writeback_job *job)
{
struct vkms_writeback_job *vkmsjob;
int ret;
if (!job->fb)
return 0;
vkmsjob = kzalloc_obj(*vkmsjob);
if (!vkmsjob)
return -ENOMEM;
ret = drm_gem_fb_vmap(job->fb, vkmsjob->wb_frame_info.map, vkmsjob->data);
if (ret) {
DRM_ERROR("vmap failed: %d\n", ret);
Annotation
- Immediate include surface: `linux/iosys-map.h`, `drm/drm_atomic.h`, `drm/drm_edid.h`, `drm/drm_fourcc.h`, `drm/drm_writeback.h`, `drm/drm_print.h`, `drm/drm_probe_helper.h`, `drm/drm_atomic_helper.h`.
- Detected declarations: `function vkms_wb_atomic_check`, `function vkms_wb_connector_get_modes`, `function vkms_wb_prepare_job`, `function vkms_wb_cleanup_job`, `function vkms_wb_atomic_commit`, `function vkms_enable_writeback_connector`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.