drivers/video/screen_info_generic.c
Source file repositories/reference/linux-study-clean/drivers/video/screen_info_generic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/screen_info_generic.c- Extension
.c- Size
- 6365 bytes
- Lines
- 238
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/ioport.hlinux/screen_info.hlinux/string.hvideo/pixel_format.h
Detected Declarations
function resource_init_namedfunction resource_init_io_namedfunction resource_init_mem_namedfunction __screen_info_has_ega_gfxfunction __screen_info_has_vga_gfxfunction screen_info_resourcesfunction __screen_info_lfb_bits_per_pixelfunction __screen_info_lfb_pixel_formatfunction screen_info_pixel_formatexport screen_info_resourcesexport __screen_info_lfb_bits_per_pixelexport screen_info_pixel_format
Annotated Snippet
if (num > 1) {
if (__screen_info_has_ega_gfx(si->orig_video_mode))
resource_init_mem_named(pos++, 0xa0000, 0x10000, "ega");
else
resource_init_mem_named(pos++, 0xb8000, 0x8000, "ega");
}
break;
case VIDEO_TYPE_VGAC:
if (num > 0)
resource_init_io_named(pos++, 0x3c0, 0x20, "vga+");
if (num > 1) {
if (__screen_info_has_vga_gfx(si->orig_video_mode))
resource_init_mem_named(pos++, 0xa0000, 0x10000, "vga+");
else
resource_init_mem_named(pos++, 0xb8000, 0x8000, "vga+");
}
break;
case VIDEO_TYPE_VLFB:
case VIDEO_TYPE_EFI:
base = __screen_info_lfb_base(si);
if (!base)
break;
size = __screen_info_lfb_size(si, type);
if (!size)
break;
if (num > 0)
resource_init_mem_named(pos++, base, size, "lfb");
break;
case VIDEO_TYPE_PICA_S3:
case VIDEO_TYPE_MIPS_G364:
case VIDEO_TYPE_SGI:
case VIDEO_TYPE_TGAC:
case VIDEO_TYPE_SUN:
case VIDEO_TYPE_SUNPCI:
case VIDEO_TYPE_PMAC:
default:
/* not supported */
return -EINVAL;
}
return pos - r;
}
EXPORT_SYMBOL(screen_info_resources);
/*
* The meaning of depth and bpp for direct-color formats is
* inconsistent:
*
* - DRM format info specifies depth as the number of color
* bits; including alpha, but not including filler bits.
* - Linux' EFI platform code computes lfb_depth from the
* individual color channels, including the reserved bits.
* - VBE 1.1 defines lfb_depth for XRGB1555 as 16, but later
* versions use 15.
* - On the kernel command line, 'bpp' of 32 is usually
* XRGB8888 including the filler bits, but 15 is XRGB1555
* not including the filler bit.
*
* It is not easily possible to fix this in struct screen_info,
* as this could break UAPI. The best solution is to compute
* bits_per_pixel from the color bits, reserved bits and
* reported lfb_depth, whichever is highest.
*/
u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si)
{
u32 bits_per_pixel = si->lfb_depth;
if (bits_per_pixel > 8) {
bits_per_pixel = max(max3(si->red_size + si->red_pos,
si->green_size + si->green_pos,
si->blue_size + si->blue_pos),
si->rsvd_size + si->rsvd_pos);
bits_per_pixel = max_t(u32, bits_per_pixel, si->lfb_depth);
}
return bits_per_pixel;
}
EXPORT_SYMBOL(__screen_info_lfb_bits_per_pixel);
static int __screen_info_lfb_pixel_format(const struct screen_info *si, struct pixel_format *f)
{
u32 bits_per_pixel = __screen_info_lfb_bits_per_pixel(si);
if (bits_per_pixel > U8_MAX)
return -EINVAL;
f->bits_per_pixel = bits_per_pixel;
if (si->lfb_depth > 8) {
Annotation
- Immediate include surface: `linux/export.h`, `linux/ioport.h`, `linux/screen_info.h`, `linux/string.h`, `video/pixel_format.h`.
- Detected declarations: `function resource_init_named`, `function resource_init_io_named`, `function resource_init_mem_named`, `function __screen_info_has_ega_gfx`, `function __screen_info_has_vga_gfx`, `function screen_info_resources`, `function __screen_info_lfb_bits_per_pixel`, `function __screen_info_lfb_pixel_format`, `function screen_info_pixel_format`, `export screen_info_resources`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: integration implementation candidate.
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.