drivers/gpu/drm/drm_client.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_client.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_client.c- Extension
.c- Size
- 12700 bytes
- Lines
- 466
- 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/iosys-map.hlinux/list.hlinux/mutex.hlinux/seq_file.hlinux/slab.hdrm/drm_client.hdrm/drm_client_event.hdrm/drm_device.hdrm/drm_drv.hdrm/drm_file.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem.hdrm/drm_gem_framebuffer_helper.hdrm/drm_mode.hdrm/drm_print.hdrm_crtc_internal.hdrm_internal.h
Detected Declarations
function drm_client_openfunction drm_client_closefunction drm_client_registerfunction drm_client_registerfunction drm_client_releasefunction drm_client_buffer_deletefunction drm_client_buffer_createfunction drm_client_buffer_vmap_localfunction drm_client_buffer_vunmap_localfunction drm_client_buffer_vmapfunction drm_client_buffer_vunmapfunction drm_client_buffer_deletefunction drm_client_buffer_flushexport drm_client_initexport drm_client_registerexport drm_client_releaseexport drm_client_buffer_deleteexport drm_client_buffer_createexport drm_client_buffer_vmap_localexport drm_client_buffer_vunmap_localexport drm_client_buffer_vmapexport drm_client_buffer_vunmapexport drm_client_buffer_create_dumbexport drm_client_buffer_flush
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 or MIT
/*
* Copyright 2018 Noralf Trønnes
*/
#include <linux/export.h>
#include <linux/iosys-map.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <drm/drm_client.h>
#include <drm/drm_client_event.h>
#include <drm/drm_device.h>
#include <drm/drm_drv.h>
#include <drm/drm_file.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_mode.h>
#include <drm/drm_print.h>
#include "drm_crtc_internal.h"
#include "drm_internal.h"
/**
* DOC: overview
*
* This library provides support for clients running in the kernel like fbdev and bootsplash.
*
* GEM drivers which provide a GEM based dumb buffer with a virtual address are supported.
*/
static int drm_client_open(struct drm_client_dev *client)
{
struct drm_device *dev = client->dev;
struct drm_file *file;
file = drm_file_alloc(dev->primary);
if (IS_ERR(file))
return PTR_ERR(file);
mutex_lock(&dev->filelist_mutex);
list_add(&file->lhead, &dev->filelist_internal);
mutex_unlock(&dev->filelist_mutex);
client->file = file;
return 0;
}
static void drm_client_close(struct drm_client_dev *client)
{
struct drm_device *dev = client->dev;
mutex_lock(&dev->filelist_mutex);
list_del(&client->file->lhead);
mutex_unlock(&dev->filelist_mutex);
drm_file_free(client->file);
}
/**
* drm_client_init - Initialise a DRM client
* @dev: DRM device
* @client: DRM client
* @name: Client name
* @funcs: DRM client functions (optional)
*
* This initialises the client and opens a &drm_file.
* Use drm_client_register() to complete the process.
* The caller needs to hold a reference on @dev before calling this function.
* The client is freed when the &drm_device is unregistered. See drm_client_release().
*
* Returns:
* Zero on success or negative error code on failure.
*/
int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,
const char *name, const struct drm_client_funcs *funcs)
{
int ret;
if (!drm_core_check_feature(dev, DRIVER_MODESET) || !dev->driver->dumb_create)
return -EOPNOTSUPP;
client->dev = dev;
client->name = name;
client->funcs = funcs;
Annotation
- Immediate include surface: `linux/export.h`, `linux/iosys-map.h`, `linux/list.h`, `linux/mutex.h`, `linux/seq_file.h`, `linux/slab.h`, `drm/drm_client.h`, `drm/drm_client_event.h`.
- Detected declarations: `function drm_client_open`, `function drm_client_close`, `function drm_client_register`, `function drm_client_register`, `function drm_client_release`, `function drm_client_buffer_delete`, `function drm_client_buffer_create`, `function drm_client_buffer_vmap_local`, `function drm_client_buffer_vunmap_local`, `function drm_client_buffer_vmap`.
- 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.