drivers/gpu/drm/clients/drm_log.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/clients/drm_log.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/clients/drm_log.c- Extension
.c- Size
- 11229 bytes
- Lines
- 442
- 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/console.hlinux/font.hlinux/init.hlinux/iosys-map.hlinux/module.hlinux/types.hdrm/drm_client.hdrm/drm_drv.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_print.hdrm_client_internal.hdrm_draw_internal.hdrm_internal.h
Detected Declarations
struct drm_log_scanoutstruct drm_logfunction drm_log_blitfunction drm_log_clear_linefunction drm_log_draw_linefunction drm_log_draw_new_linefunction print_timefunction drm_log_find_usable_formatfunction drm_log_setup_modesetfunction drm_log_count_modesetfunction drm_log_init_clientfunction drm_log_free_scanoutfunction drm_log_client_freefunction drm_log_client_unregisterfunction drm_log_client_restorefunction drm_log_client_hotplugfunction drm_log_client_suspendfunction drm_log_client_resumefunction drm_log_write_threadfunction drm_log_lockfunction drm_log_unlockfunction drm_log_register_consolefunction drm_log_register
Annotated Snippet
struct drm_log_scanout {
struct drm_client_buffer *buffer;
const struct font_desc *font;
u32 rows;
u32 columns;
u32 scaled_font_h;
u32 scaled_font_w;
u32 line;
u32 format;
u32 px_width;
u32 front_color;
u32 prefix_color;
};
struct drm_log {
struct mutex lock;
struct drm_client_dev client;
struct console con;
bool probed;
u32 n_scanout;
struct drm_log_scanout *scanout;
};
static struct drm_log *client_to_drm_log(struct drm_client_dev *client)
{
return container_of(client, struct drm_log, client);
}
static struct drm_log *console_to_drm_log(struct console *con)
{
return container_of(con, struct drm_log, con);
}
static void drm_log_blit(struct iosys_map *dst, unsigned int dst_pitch,
const u8 *src, unsigned int src_pitch,
u32 height, u32 width, u32 px_width, u32 color)
{
switch (px_width) {
case 2:
drm_draw_blit16(dst, dst_pitch, src, src_pitch, height, width, scale, color);
break;
case 3:
drm_draw_blit24(dst, dst_pitch, src, src_pitch, height, width, scale, color);
break;
case 4:
drm_draw_blit32(dst, dst_pitch, src, src_pitch, height, width, scale, color);
break;
default:
WARN_ONCE(1, "Can't blit with pixel width %d\n", px_width);
}
}
static void drm_log_clear_line(struct drm_log_scanout *scanout, u32 line)
{
struct drm_framebuffer *fb = scanout->buffer->fb;
unsigned long height = scanout->scaled_font_h;
struct iosys_map map;
struct drm_rect r = DRM_RECT_INIT(0, line * height, fb->width, height);
if (drm_client_buffer_vmap_local(scanout->buffer, &map))
return;
iosys_map_memset(&map, r.y1 * fb->pitches[0], 0, height * fb->pitches[0]);
drm_client_buffer_vunmap_local(scanout->buffer);
drm_client_buffer_flush(scanout->buffer, &r);
}
static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s,
unsigned int len, unsigned int prefix_len)
{
struct drm_framebuffer *fb = scanout->buffer->fb;
struct iosys_map map;
const struct font_desc *font = scanout->font;
size_t font_pitch = DIV_ROUND_UP(font->width, 8);
const u8 *src;
u32 px_width = fb->format->cpp[0];
struct drm_rect r = DRM_RECT_INIT(0, scanout->line * scanout->scaled_font_h,
fb->width, (scanout->line + 1) * scanout->scaled_font_h);
u32 i;
if (drm_client_buffer_vmap_local(scanout->buffer, &map))
return;
iosys_map_incr(&map, r.y1 * fb->pitches[0]);
for (i = 0; i < len && i < scanout->columns; i++) {
u32 color = (i < prefix_len) ? scanout->prefix_color : scanout->front_color;
src = drm_draw_get_char_bitmap(font, s[i], font_pitch);
drm_log_blit(&map, fb->pitches[0], src, font_pitch,
scanout->scaled_font_h, scanout->scaled_font_w,
px_width, color);
iosys_map_incr(&map, scanout->scaled_font_w * px_width);
Annotation
- Immediate include surface: `linux/console.h`, `linux/font.h`, `linux/init.h`, `linux/iosys-map.h`, `linux/module.h`, `linux/types.h`, `drm/drm_client.h`, `drm/drm_drv.h`.
- Detected declarations: `struct drm_log_scanout`, `struct drm_log`, `function drm_log_blit`, `function drm_log_clear_line`, `function drm_log_draw_line`, `function drm_log_draw_new_line`, `function print_time`, `function drm_log_find_usable_format`, `function drm_log_setup_modeset`, `function drm_log_count_modeset`.
- 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.