drivers/video/screen_info_pci.c
Source file repositories/reference/linux-study-clean/drivers/video/screen_info_pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/screen_info_pci.c- Extension
.c- Size
- 4088 bytes
- Lines
- 159
- 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/pci.hlinux/printk.hlinux/screen_info.hlinux/string.hlinux/sysfb.h
Detected Declarations
function __screen_info_relocation_is_validfunction screen_info_apply_fixupsfunction __screen_info_lfb_pci_bus_regionfunction screen_info_fixup_lfbfunction screen_info_pci_devexport screen_info_pci_dev
Annotated Snippet
if (pr->start != screen_info_lfb_res_start) {
if (__screen_info_relocation_is_valid(si, pr)) {
/*
* Only update base if we have an actual
* relocation to a valid I/O range.
*/
__screen_info_set_lfb_base(si, pr->start + screen_info_lfb_offset);
pr_info("Relocating firmware framebuffer to offset %pa[d] within %pr\n",
&screen_info_lfb_offset, pr);
} else {
pr_warn("Invalid relocating, disabling firmware framebuffer\n");
}
}
}
}
static int __screen_info_lfb_pci_bus_region(const struct screen_info *si, unsigned int type,
struct pci_bus_region *r)
{
u64 base, size;
base = __screen_info_lfb_base(si);
if (!base)
return -EINVAL;
size = __screen_info_lfb_size(si, type);
if (!size)
return -EINVAL;
r->start = base;
r->end = base + size - 1;
return 0;
}
static void screen_info_fixup_lfb(struct pci_dev *pdev)
{
unsigned int type;
struct pci_bus_region bus_region;
int ret;
struct resource r = {
.flags = IORESOURCE_MEM,
};
const struct resource *pr;
const struct screen_info *si = &sysfb_primary_display.screen;
if (screen_info_lfb_pdev)
return; // already found
type = screen_info_video_type(si);
if (!__screen_info_has_lfb(type))
return; // only applies to EFI; maybe VESA
ret = __screen_info_lfb_pci_bus_region(si, type, &bus_region);
if (ret < 0)
return;
/*
* Translate the PCI bus address to resource. Account
* for an offset if the framebuffer is behind a PCI host
* bridge.
*/
pcibios_bus_to_resource(pdev->bus, &r, &bus_region);
pr = pci_find_resource(pdev, &r);
if (!pr)
return;
/*
* We've found a PCI device with the framebuffer
* resource. Store away the parameters to track
* relocation of the framebuffer aperture.
*/
screen_info_lfb_pdev = pdev;
screen_info_lfb_bar = pr - pdev->resource;
screen_info_lfb_offset = r.start - pr->start;
screen_info_lfb_res_start = bus_region.start;
}
DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY, 16,
screen_info_fixup_lfb);
static struct pci_dev *__screen_info_pci_dev(struct resource *res)
{
struct pci_dev *pdev = NULL;
const struct resource *r = NULL;
if (!(res->flags & IORESOURCE_MEM))
return NULL;
while (!r && (pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
Annotation
- Immediate include surface: `linux/pci.h`, `linux/printk.h`, `linux/screen_info.h`, `linux/string.h`, `linux/sysfb.h`.
- Detected declarations: `function __screen_info_relocation_is_valid`, `function screen_info_apply_fixups`, `function __screen_info_lfb_pci_bus_region`, `function screen_info_fixup_lfb`, `function screen_info_pci_dev`, `export screen_info_pci_dev`.
- 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.