drivers/gpu/drm/drm_fbdev_ttm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_fbdev_ttm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_fbdev_ttm.c- Extension
.c- Size
- 6003 bytes
- Lines
- 235
- 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/moduleparam.hlinux/vmalloc.hdrm/drm_crtc_helper.hdrm/drm_drv.hdrm/drm_fb_helper.hdrm/drm_framebuffer.hdrm/drm_gem.hdrm/drm_print.hdrm/drm_fbdev_ttm.h
Detected Declarations
function drm_fbdev_ttm_fb_openfunction drm_fbdev_ttm_fb_releasefunction drm_fbdev_ttm_fb_destroyfunction drm_fbdev_ttm_damage_blit_realfunction drm_fbdev_ttm_damage_blitfunction drm_fbdev_ttm_helper_fb_dirtyfunction drm_fbdev_ttm_driver_fbdev_probeexport drm_fbdev_ttm_driver_fbdev_probe
Annotated Snippet
// SPDX-License-Identifier: MIT
#include <linux/export.h>
#include <linux/moduleparam.h>
#include <linux/vmalloc.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem.h>
#include <drm/drm_print.h>
#include <drm/drm_fbdev_ttm.h>
/* @user: 1=userspace, 0=fbcon */
static int drm_fbdev_ttm_fb_open(struct fb_info *info, int user)
{
struct drm_fb_helper *fb_helper = info->par;
/* No need to take a ref for fbcon because it unbinds on unregister */
if (user && !try_module_get(fb_helper->dev->driver->fops->owner))
return -ENODEV;
return 0;
}
static int drm_fbdev_ttm_fb_release(struct fb_info *info, int user)
{
struct drm_fb_helper *fb_helper = info->par;
if (user)
module_put(fb_helper->dev->driver->fops->owner);
return 0;
}
FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(drm_fbdev_ttm,
drm_fb_helper_damage_range,
drm_fb_helper_damage_area);
static void drm_fbdev_ttm_fb_destroy(struct fb_info *info)
{
struct drm_fb_helper *fb_helper = info->par;
void *shadow = info->screen_buffer;
if (!fb_helper->dev)
return;
fb_deferred_io_cleanup(info);
drm_fb_helper_fini(fb_helper);
vfree(shadow);
drm_client_buffer_delete(fb_helper->buffer);
drm_client_release(&fb_helper->client);
}
static const struct fb_ops drm_fbdev_ttm_fb_ops = {
.owner = THIS_MODULE,
.fb_open = drm_fbdev_ttm_fb_open,
.fb_release = drm_fbdev_ttm_fb_release,
FB_DEFAULT_DEFERRED_OPS(drm_fbdev_ttm),
DRM_FB_HELPER_DEFAULT_OPS,
.fb_destroy = drm_fbdev_ttm_fb_destroy,
};
static void drm_fbdev_ttm_damage_blit_real(struct drm_fb_helper *fb_helper,
struct drm_clip_rect *clip,
struct iosys_map *dst)
{
struct drm_framebuffer *fb = fb_helper->fb;
size_t offset = clip->y1 * fb->pitches[0];
size_t len = clip->x2 - clip->x1;
unsigned int y;
void *src;
switch (drm_format_info_bpp(fb->format, 0)) {
case 1:
offset += clip->x1 / 8;
len = DIV_ROUND_UP(len + clip->x1 % 8, 8);
break;
case 2:
offset += clip->x1 / 4;
len = DIV_ROUND_UP(len + clip->x1 % 4, 4);
break;
case 4:
offset += clip->x1 / 2;
len = DIV_ROUND_UP(len + clip->x1 % 2, 2);
break;
default:
Annotation
- Immediate include surface: `linux/export.h`, `linux/moduleparam.h`, `linux/vmalloc.h`, `drm/drm_crtc_helper.h`, `drm/drm_drv.h`, `drm/drm_fb_helper.h`, `drm/drm_framebuffer.h`, `drm/drm_gem.h`.
- Detected declarations: `function drm_fbdev_ttm_fb_open`, `function drm_fbdev_ttm_fb_release`, `function drm_fbdev_ttm_fb_destroy`, `function drm_fbdev_ttm_damage_blit_real`, `function drm_fbdev_ttm_damage_blit`, `function drm_fbdev_ttm_helper_fb_dirty`, `function drm_fbdev_ttm_driver_fbdev_probe`, `export drm_fbdev_ttm_driver_fbdev_probe`.
- 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.