drivers/gpu/drm/omapdrm/omap_fb.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/omapdrm/omap_fb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/omapdrm/omap_fb.c- Extension
.c- Size
- 10972 bytes
- Lines
- 458
- 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/dma-mapping.hlinux/seq_file.hdrm/drm_blend.hdrm/drm_modeset_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_framebuffer_helper.hdrm/drm_print.homap_dmm_tiler.homap_drv.h
Detected Declarations
struct planestruct omap_framebufferfunction omap_framebuffer_dirtyfunction get_linear_addrfunction omap_framebuffer_supports_rotationfunction drm_rotation_to_tilerfunction omap_framebuffer_update_scanoutfunction omap_gem_rotated_paddrfunction omap_framebuffer_pinfunction omap_framebuffer_unpinfunction omap_framebuffer_describe
Annotated Snippet
struct plane {
dma_addr_t dma_addr;
};
#define to_omap_framebuffer(x) container_of(x, struct omap_framebuffer, base)
struct omap_framebuffer {
struct drm_framebuffer base;
int pin_count;
const struct drm_format_info *format;
struct plane planes[2];
/* lock for pinning (pin_count and planes.dma_addr) */
struct mutex lock;
};
static int omap_framebuffer_dirty(struct drm_framebuffer *fb,
struct drm_file *file_priv,
unsigned flags, unsigned color,
struct drm_clip_rect *clips,
unsigned num_clips)
{
struct drm_crtc *crtc;
drm_modeset_lock_all(fb->dev);
drm_for_each_crtc(crtc, fb->dev)
omap_crtc_flush(crtc);
drm_modeset_unlock_all(fb->dev);
return 0;
}
static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
.create_handle = drm_gem_fb_create_handle,
.dirty = omap_framebuffer_dirty,
.destroy = drm_gem_fb_destroy,
};
static u32 get_linear_addr(struct drm_framebuffer *fb,
const struct drm_format_info *format, int n, int x, int y)
{
struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
struct plane *plane = &omap_fb->planes[n];
u32 offset;
offset = fb->offsets[n]
+ (x * format->cpp[n] / (n == 0 ? 1 : format->hsub))
+ (y * fb->pitches[n] / (n == 0 ? 1 : format->vsub));
return plane->dma_addr + offset;
}
bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
{
return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED_MASK;
}
/* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */
static u32 drm_rotation_to_tiler(unsigned int drm_rot)
{
u32 orient;
switch (drm_rot & DRM_MODE_ROTATE_MASK) {
default:
case DRM_MODE_ROTATE_0:
orient = 0;
break;
case DRM_MODE_ROTATE_90:
orient = MASK_XY_FLIP | MASK_X_INVERT;
break;
case DRM_MODE_ROTATE_180:
orient = MASK_X_INVERT | MASK_Y_INVERT;
break;
case DRM_MODE_ROTATE_270:
orient = MASK_XY_FLIP | MASK_Y_INVERT;
break;
}
if (drm_rot & DRM_MODE_REFLECT_X)
orient ^= MASK_X_INVERT;
if (drm_rot & DRM_MODE_REFLECT_Y)
orient ^= MASK_Y_INVERT;
return orient;
}
/* update ovl info for scanout, handles cases of multi-planar fb's, etc.
*/
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/seq_file.h`, `drm/drm_blend.h`, `drm/drm_modeset_helper.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`, `drm/drm_gem_framebuffer_helper.h`, `drm/drm_print.h`.
- Detected declarations: `struct plane`, `struct omap_framebuffer`, `function omap_framebuffer_dirty`, `function get_linear_addr`, `function omap_framebuffer_supports_rotation`, `function drm_rotation_to_tiler`, `function omap_framebuffer_update_scanout`, `function omap_gem_rotated_paddr`, `function omap_framebuffer_pin`, `function omap_framebuffer_unpin`.
- 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.