drivers/gpu/drm/vc4/vc4_drv.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vc4/vc4_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vc4/vc4_drv.c- Extension
.c- Size
- 12761 bytes
- Lines
- 518
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/aperture.hlinux/clk.hlinux/component.hlinux/device.hlinux/dma-mapping.hlinux/io.hlinux/module.hlinux/of_device.hlinux/platform_device.hlinux/pm_runtime.hdrm/clients/drm_client_setup.hdrm/drm_atomic_helper.hdrm/drm_drv.hdrm/drm_fbdev_dma.hdrm/drm_fourcc.hdrm/drm_print.hdrm/drm_vblank.hsoc/bcm2835/raspberrypi-firmware.hvc4_drv.hvc4_regs.h
Detected Declarations
function Copyrightfunction vc4_dumb_fixup_argsfunction vc5_dumb_createfunction vc4_get_param_ioctlfunction vc4_openfunction vc4_closefunction vc4_match_add_driversfunction vc4_component_unbind_allfunction vc4_drm_bindfunction vc4_drm_unbindfunction vc4_platform_drm_probefunction vc4_platform_drm_removefunction vc4_platform_drm_shutdownfunction vc4_drm_registerfunction vc4_drm_unregistermodule init vc4_drm_register
Annotated Snippet
struct device_driver *drv = &drivers[i]->driver;
struct device *p = NULL, *d;
while ((d = platform_find_device_by_driver(p, drv))) {
put_device(p);
component_match_add(dev, match, component_compare_dev, d);
p = d;
}
put_device(p);
}
}
static void vc4_component_unbind_all(void *ptr)
{
struct vc4_dev *vc4 = ptr;
component_unbind_all(vc4->dev, &vc4->base);
}
static const struct of_device_id vc4_dma_range_matches[] = {
{ .compatible = "brcm,bcm2711-hvs" },
{ .compatible = "brcm,bcm2712-hvs" },
{ .compatible = "brcm,bcm2835-hvs" },
{ .compatible = "brcm,bcm2835-v3d" },
{ .compatible = "brcm,cygnus-v3d" },
{ .compatible = "brcm,vc4-v3d" },
{}
};
static int vc4_drm_bind(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
const struct drm_driver *driver;
struct rpi_firmware *firmware = NULL;
struct drm_device *drm;
struct vc4_dev *vc4;
struct device_node *node;
struct drm_crtc *crtc;
enum vc4_gen gen;
int ret = 0;
dev->coherent_dma_mask = DMA_BIT_MASK(32);
gen = (enum vc4_gen)of_device_get_match_data(dev);
if (gen > VC4_GEN_4)
driver = &vc5_drm_driver;
else
driver = &vc4_drm_driver;
if (gen >= VC4_GEN_6_C)
dma_set_mask_and_coherent(dev, DMA_BIT_MASK(36));
else
dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
node = of_find_matching_node_and_match(NULL, vc4_dma_range_matches,
NULL);
if (node) {
ret = of_dma_configure(dev, node, true);
of_node_put(node);
if (ret)
return ret;
}
vc4 = devm_drm_dev_alloc(dev, driver, struct vc4_dev, base);
if (IS_ERR(vc4))
return PTR_ERR(vc4);
vc4->gen = gen;
vc4->dev = dev;
drm = &vc4->base;
platform_set_drvdata(pdev, drm);
if (gen == VC4_GEN_4) {
ret = drmm_mutex_init(drm, &vc4->bin_bo_lock);
if (ret)
goto err;
ret = vc4_bo_cache_init(drm);
if (ret)
goto err;
}
ret = drmm_mode_config_init(drm);
if (ret)
goto err;
if (gen == VC4_GEN_4) {
ret = vc4_gem_init(drm);
Annotation
- Immediate include surface: `linux/aperture.h`, `linux/clk.h`, `linux/component.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/io.h`, `linux/module.h`, `linux/of_device.h`.
- Detected declarations: `function Copyright`, `function vc4_dumb_fixup_args`, `function vc5_dumb_create`, `function vc4_get_param_ioctl`, `function vc4_open`, `function vc4_close`, `function vc4_match_add_drivers`, `function vc4_component_unbind_all`, `function vc4_drm_bind`, `function vc4_drm_unbind`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern 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.