drivers/gpu/drm/drm_modeset_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_modeset_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_modeset_helper.c- Extension
.c- Size
- 7951 bytes
- Lines
- 263
- 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
linux/export.hdrm/drm_atomic_helper.hdrm/drm_client_event.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_modeset_helper.hdrm/drm_plane_helper.hdrm/drm_print.hdrm/drm_probe_helper.h
Detected Declarations
function Copyrightfunction drm_helper_mode_fill_fb_structfunction drm_crtc_initfunction drm_atomic_helper_suspendfunction drm_atomic_helper_resumeexport drm_helper_move_panel_connectors_to_headexport drm_helper_mode_fill_fb_structexport drm_crtc_initexport drm_mode_config_helper_suspendexport drm_mode_config_helper_resume
Annotated Snippet
#include <linux/export.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_client_event.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_modeset_helper.h>
#include <drm/drm_plane_helper.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
/**
* DOC: aux kms helpers
*
* This helper library contains various one-off functions which don't really fit
* anywhere else in the DRM modeset helper library.
*/
/**
* drm_helper_move_panel_connectors_to_head() - move panels to the front in the
* connector list
* @dev: drm device to operate on
*
* Some userspace presumes that the first connected connector is the main
* display, where it's supposed to display e.g. the login screen. For
* laptops, this should be the main panel. Use this function to sort all
* (eDP/LVDS/DSI) panels to the front of the connector list, instead of
* painstakingly trying to initialize them in the right order.
*/
void drm_helper_move_panel_connectors_to_head(struct drm_device *dev)
{
struct drm_connector *connector, *tmp;
struct list_head panel_list;
INIT_LIST_HEAD(&panel_list);
spin_lock_irq(&dev->mode_config.connector_list_lock);
list_for_each_entry_safe(connector, tmp,
&dev->mode_config.connector_list, head) {
if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
connector->connector_type == DRM_MODE_CONNECTOR_eDP ||
connector->connector_type == DRM_MODE_CONNECTOR_DSI)
list_move_tail(&connector->head, &panel_list);
}
list_splice(&panel_list, &dev->mode_config.connector_list);
spin_unlock_irq(&dev->mode_config.connector_list_lock);
}
EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head);
/**
* drm_helper_mode_fill_fb_struct - fill out framebuffer metadata
* @dev: DRM device
* @fb: drm_framebuffer object to fill out
* @info: pixel format information
* @mode_cmd: metadata from the userspace fb creation request
*
* This helper can be used in a drivers fb_create callback to pre-fill the fb's
* metadata fields.
*/
void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
struct drm_framebuffer *fb,
const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
int i;
fb->dev = dev;
fb->format = info;
fb->width = mode_cmd->width;
fb->height = mode_cmd->height;
for (i = 0; i < 4; i++) {
fb->pitches[i] = mode_cmd->pitches[i];
fb->offsets[i] = mode_cmd->offsets[i];
}
fb->modifier = mode_cmd->modifier[0];
fb->flags = mode_cmd->flags;
}
EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
/*
* This is the minimal list of formats that seem to be safe for modeset use
* with all current DRM drivers. Most hardware can actually support more
* formats than this and drivers may specify a more accurate list when
* creating the primary plane.
*/
static const uint32_t safe_modeset_formats[] = {
DRM_FORMAT_XRGB8888,
DRM_FORMAT_ARGB8888,
};
Annotation
- Immediate include surface: `linux/export.h`, `drm/drm_atomic_helper.h`, `drm/drm_client_event.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`, `drm/drm_modeset_helper.h`, `drm/drm_plane_helper.h`, `drm/drm_print.h`.
- Detected declarations: `function Copyright`, `function drm_helper_mode_fill_fb_struct`, `function drm_crtc_init`, `function drm_atomic_helper_suspend`, `function drm_atomic_helper_resume`, `export drm_helper_move_panel_connectors_to_head`, `export drm_helper_mode_fill_fb_struct`, `export drm_crtc_init`, `export drm_mode_config_helper_suspend`, `export drm_mode_config_helper_resume`.
- 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.