drivers/gpu/drm/drm_fb_helper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_fb_helper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_fb_helper.c- Extension
.c- Size
- 53511 bytes
- Lines
- 1806
- 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/console.hlinux/export.hdrm/drm_atomic.hdrm/drm_drv.hdrm/drm_fb_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_framebuffer_helper.hdrm/drm_modeset_helper_vtables.hdrm/drm_print.hdrm/drm_vblank.hdrm_internal.hdrm_crtc_internal.h
Detected Declarations
function drm_mode_config_helper_resumefunction drm_fb_helper_restore_fbdev_mode_unlockedfunction drm_fb_helper_dpmsfunction drm_fb_helper_blankfunction drm_fb_helper_resume_workerfunction drm_fb_helper_fb_dirtyfunction drm_fb_helper_damage_workfunction drm_fb_helper_preparefunction drm_fb_helper_unpreparefunction drm_fb_helper_preparefunction drm_fb_helper_release_infofunction drm_fb_helper_unregister_infofunction drm_fb_helper_finifunction drm_fb_helper_add_damage_clipfunction drm_fb_helper_damagefunction drm_fb_helper_memory_range_to_clipfunction drm_fb_helper_damage_rangefunction drm_fb_helper_damage_areafunction drm_fb_helper_deferred_iofunction drm_fb_helper_set_suspend_unlockedfunction fb_set_suspendfunction setcmap_pseudo_palettefunction setcmap_legacyfunction setcmap_atomicfunction drm_client_for_each_modesetfunction drm_fb_helper_setcmapfunction drm_fb_helper_ioctlfunction drm_fb_pixel_format_equalfunction drm_fb_helper_fill_pixel_fmtfunction __fill_varfunction drm_fb_helper_check_varfunction drm_fb_helper_set_parfunction pan_setfunction pan_display_atomicfunction pan_display_legacyfunction drm_fb_helper_pan_displayfunction drm_fb_helper_find_formatfunction __drm_fb_helper_find_sizesfunction drm_client_for_each_modesetfunction drm_client_for_each_connector_iterfunction drm_fb_helper_find_sizesfunction drm_fb_helper_single_fb_probefunction drm_fb_helper_fill_fixfunction drm_fb_helper_fill_varfunction thisfunction drm_setup_crtcsfunction __drm_fb_helper_initial_config_and_unlockfunction drm_fb_helper_initial_config
Annotated Snippet
if (!console_trylock()) {
schedule_work(&fb_helper->resume_work);
return;
}
}
drm_fb_helper_set_suspend(fb_helper, suspend);
console_unlock();
}
EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked);
static int setcmap_pseudo_palette(struct fb_cmap *cmap, struct fb_info *info)
{
u32 *palette = (u32 *)info->pseudo_palette;
int i;
if (cmap->start + cmap->len > 16)
return -EINVAL;
for (i = 0; i < cmap->len; ++i) {
u16 red = cmap->red[i];
u16 green = cmap->green[i];
u16 blue = cmap->blue[i];
u32 value;
red >>= 16 - info->var.red.length;
green >>= 16 - info->var.green.length;
blue >>= 16 - info->var.blue.length;
value = (red << info->var.red.offset) |
(green << info->var.green.offset) |
(blue << info->var.blue.offset);
if (info->var.transp.length > 0) {
u32 mask = (1 << info->var.transp.length) - 1;
mask <<= info->var.transp.offset;
value |= mask;
}
palette[cmap->start + i] = value;
}
return 0;
}
static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info)
{
struct drm_fb_helper *fb_helper = info->par;
struct drm_mode_set *modeset;
struct drm_crtc *crtc;
u16 *r, *g, *b;
int ret = 0;
drm_modeset_lock_all(fb_helper->dev);
drm_client_for_each_modeset(modeset, &fb_helper->client) {
crtc = modeset->crtc;
if (!crtc->funcs->gamma_set || !crtc->gamma_size) {
ret = -EINVAL;
goto out;
}
if (cmap->start + cmap->len > crtc->gamma_size) {
ret = -EINVAL;
goto out;
}
r = crtc->gamma_store;
g = r + crtc->gamma_size;
b = g + crtc->gamma_size;
memcpy(r + cmap->start, cmap->red, cmap->len * sizeof(*r));
memcpy(g + cmap->start, cmap->green, cmap->len * sizeof(*g));
memcpy(b + cmap->start, cmap->blue, cmap->len * sizeof(*b));
ret = crtc->funcs->gamma_set(crtc, r, g, b,
crtc->gamma_size, NULL);
if (ret)
goto out;
}
out:
drm_modeset_unlock_all(fb_helper->dev);
return ret;
}
static struct drm_property_blob *setcmap_new_gamma_lut(struct drm_crtc *crtc,
struct fb_cmap *cmap)
{
struct drm_device *dev = crtc->dev;
struct drm_property_blob *gamma_lut;
struct drm_color_lut *lut;
int size = crtc->gamma_size;
Annotation
- Immediate include surface: `linux/console.h`, `linux/export.h`, `drm/drm_atomic.h`, `drm/drm_drv.h`, `drm/drm_fb_helper.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`, `drm/drm_gem_framebuffer_helper.h`.
- Detected declarations: `function drm_mode_config_helper_resume`, `function drm_fb_helper_restore_fbdev_mode_unlocked`, `function drm_fb_helper_dpms`, `function drm_fb_helper_blank`, `function drm_fb_helper_resume_worker`, `function drm_fb_helper_fb_dirty`, `function drm_fb_helper_damage_work`, `function drm_fb_helper_prepare`, `function drm_fb_helper_unprepare`, `function drm_fb_helper_prepare`.
- 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.