drivers/gpu/drm/sysfb/ofdrm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sysfb/ofdrm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sysfb/ofdrm.c- Extension
.c- Size
- 31642 bytes
- Lines
- 1167
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/aperture.hlinux/of_address.hlinux/pci.hlinux/platform_device.hlinux/pm.hdrm/clients/drm_client_setup.hdrm/drm_atomic.hdrm/drm_atomic_state_helper.hdrm/drm_color_mgmt.hdrm/drm_connector.hdrm/drm_damage_helper.hdrm/drm_device.hdrm/drm_drv.hdrm/drm_edid.hdrm/drm_fbdev_shmem.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_gem_shmem_helper.hdrm/drm_managed.hdrm/drm_modeset_helper.hdrm/drm_modeset_helper_vtables.hdrm/drm_print.hdrm/drm_probe_helper.hdrm_sysfb_helper.h
Detected Declarations
struct ofdrm_devicestruct ofdrm_device_funcsstruct ofdrm_deviceenum ofdrm_modelfunction display_get_validated_intfunction display_get_validated_int0function display_read_u32_offunction display_get_big_endian_offunction display_get_width_offunction display_get_height_offunction display_get_depth_offunction display_get_linebytes_offunction display_get_address_offunction is_avivofunction display_get_model_offunction of_node_name_prefixfunction of_device_is_compatiblefunction ofdrm_pci_releasefunction ofdrm_device_init_pcifunction ofdrm_device_init_pcifunction ofdrm_mach64_cmap_writefunction ofdrm_rage128_cmap_writefunction ofdrm_rage_m3a_cmap_writefunction ofdrm_rage_m3b_cmap_writefunction ofdrm_gxt2000_cmap_writefunction ofdrm_avivo_cmap_writefunction ofdrm_qemu_cmap_writefunction ofdrm_set_gamma_lutfunction ofdrm_device_fill_gammafunction ofdrm_device_load_gammafunction ofdrm_crtc_helper_atomic_flushfunction ofdrm_pm_suspendfunction ofdrm_pm_resumefunction ofdrm_probefunction ofdrm_remove
Annotated Snippet
struct ofdrm_device_funcs {
void __iomem *(*cmap_ioremap)(struct ofdrm_device *odev,
struct device_node *of_node,
u64 fb_bas);
void (*cmap_write)(struct ofdrm_device *odev, unsigned char index,
unsigned char r, unsigned char g, unsigned char b);
};
struct ofdrm_device {
struct drm_sysfb_device sysfb;
const struct ofdrm_device_funcs *funcs;
/* colormap */
void __iomem *cmap_base;
u8 edid[EDID_LENGTH];
/* modesetting */
u32 formats[DRM_SYSFB_PLANE_NFORMATS(1)];
struct drm_plane primary_plane;
struct drm_crtc crtc;
struct drm_encoder encoder;
struct drm_connector connector;
};
static struct ofdrm_device *ofdrm_device_of_dev(struct drm_device *dev)
{
return container_of(to_drm_sysfb_device(dev), struct ofdrm_device, sysfb);
}
/*
* Hardware
*/
#if defined(CONFIG_PCI)
static struct pci_dev *display_get_pci_dev_of(struct drm_device *dev, struct device_node *of_node)
{
const __be32 *vendor_p, *device_p;
u32 vendor, device;
struct pci_dev *pcidev;
vendor_p = of_get_property(of_node, "vendor-id", NULL);
if (!vendor_p)
return ERR_PTR(-ENODEV);
vendor = be32_to_cpup(vendor_p);
device_p = of_get_property(of_node, "device-id", NULL);
if (!device_p)
return ERR_PTR(-ENODEV);
device = be32_to_cpup(device_p);
pcidev = pci_get_device(vendor, device, NULL);
if (!pcidev)
return ERR_PTR(-ENODEV);
return pcidev;
}
static void ofdrm_pci_release(void *data)
{
struct pci_dev *pcidev = data;
pci_disable_device(pcidev);
pci_dev_put(pcidev);
}
static int ofdrm_device_init_pci(struct ofdrm_device *odev)
{
struct drm_device *dev = &odev->sysfb.dev;
struct platform_device *pdev = to_platform_device(dev->dev);
struct device_node *of_node = pdev->dev.of_node;
struct pci_dev *pcidev;
int ret;
/*
* Never use pcim_ or other managed helpers on the returned PCI
* device. Otherwise, probing the native driver will fail for
* resource conflicts. PCI-device management has to be tied to
* the lifetime of the platform device until the native driver
* takes over.
*/
pcidev = display_get_pci_dev_of(dev, of_node);
if (IS_ERR(pcidev))
return 0; /* no PCI device found; ignore the error */
ret = pci_enable_device(pcidev);
if (ret) {
drm_err(dev, "pci_enable_device(%s) failed: %d\n",
dev_name(&pcidev->dev), ret);
Annotation
- Immediate include surface: `linux/aperture.h`, `linux/of_address.h`, `linux/pci.h`, `linux/platform_device.h`, `linux/pm.h`, `drm/clients/drm_client_setup.h`, `drm/drm_atomic.h`, `drm/drm_atomic_state_helper.h`.
- Detected declarations: `struct ofdrm_device`, `struct ofdrm_device_funcs`, `struct ofdrm_device`, `enum ofdrm_model`, `function display_get_validated_int`, `function display_get_validated_int0`, `function display_read_u32_of`, `function display_get_big_endian_of`, `function display_get_width_of`, `function display_get_height_of`.
- 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.