drivers/gpu/drm/sysfb/simpledrm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sysfb/simpledrm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sysfb/simpledrm.c- Extension
.c- Size
- 24203 bytes
- Lines
- 907
- 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/aperture.hlinux/clk.hlinux/minmax.hlinux/of_address.hlinux/of_clk.hlinux/of_reserved_mem.hlinux/platform_data/simplefb.hlinux/platform_device.hlinux/pm.hlinux/pm_domain.hlinux/regulator/consumer.hdrm/clients/drm_client_setup.hdrm/drm_atomic.hdrm/drm_atomic_state_helper.hdrm/drm_connector.hdrm/drm_damage_helper.hdrm/drm_device.hdrm/drm_drv.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 simpledrm_devicefunction simplefb_get_validated_intfunction simplefb_get_validated_int0function simplefb_get_validated_formatfunction simplefb_get_width_pdfunction simplefb_get_height_pdfunction simplefb_get_stride_pdfunction simplefb_get_format_pdfunction simplefb_read_u32_offunction simplefb_read_string_offunction simplefb_get_width_offunction simplefb_get_height_offunction simplefb_get_stride_offunction simplefb_get_format_offunction simplefb_get_memory_offunction usfunction simpledrm_device_init_clocksfunction simpledrm_device_init_clocksfunction usfunction simpledrm_device_init_regulatorsfunction for_each_property_of_nodefunction simpledrm_device_init_regulatorsfunction simpledrm_device_detach_genpdfunction simpledrm_device_attach_genpdfunction simpledrm_device_attach_genpdfunction simpledrm_pm_suspendfunction simpledrm_pm_resumefunction simpledrm_probefunction simpledrm_remove
Annotated Snippet
struct simpledrm_device {
struct drm_sysfb_device sysfb;
/* clocks */
#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
unsigned int clk_count;
struct clk **clks;
#endif
/* regulators */
#if defined CONFIG_OF && defined CONFIG_REGULATOR
unsigned int regulator_count;
struct regulator **regulators;
#endif
/* power-domains */
#if defined CONFIG_OF && defined CONFIG_PM_GENERIC_DOMAINS
int pwr_dom_count;
struct device **pwr_dom_devs;
struct device_link **pwr_dom_links;
#endif
/* 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;
};
/*
* Hardware
*/
#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
/*
* Clock handling code.
*
* Here we handle the clocks property of our "simple-framebuffer" dt node.
* This is necessary so that we can make sure that any clocks needed by
* the display engine that the bootloader set up for us (and for which it
* provided a simplefb dt node), stay up, for the life of the simplefb
* driver.
*
* When the driver unloads, we cleanly disable, and then release the clocks.
*
* We only complain about errors here, no action is taken as the most likely
* error can only happen due to a mismatch between the bootloader which set
* up simplefb, and the clock definitions in the device tree. Chances are
* that there are no adverse effects, and if there are, a clean teardown of
* the fb probe will not help us much either. So just complain and carry on,
* and hope that the user actually gets a working fb at the end of things.
*/
static void simpledrm_device_release_clocks(void *res)
{
struct simpledrm_device *sdev = res;
unsigned int i;
for (i = 0; i < sdev->clk_count; ++i) {
if (sdev->clks[i]) {
clk_disable_unprepare(sdev->clks[i]);
clk_put(sdev->clks[i]);
}
}
}
static int simpledrm_device_init_clocks(struct simpledrm_device *sdev)
{
struct drm_device *dev = &sdev->sysfb.dev;
struct platform_device *pdev = to_platform_device(dev->dev);
struct device_node *of_node = pdev->dev.of_node;
struct clk *clock;
unsigned int i;
int ret;
if (dev_get_platdata(&pdev->dev) || !of_node)
return 0;
sdev->clk_count = of_clk_get_parent_count(of_node);
if (!sdev->clk_count)
return 0;
sdev->clks = drmm_kzalloc(dev, sdev->clk_count * sizeof(sdev->clks[0]),
GFP_KERNEL);
if (!sdev->clks)
return -ENOMEM;
for (i = 0; i < sdev->clk_count; ++i) {
clock = of_clk_get(of_node, i);
if (IS_ERR(clock)) {
ret = PTR_ERR(clock);
Annotation
- Immediate include surface: `linux/aperture.h`, `linux/clk.h`, `linux/minmax.h`, `linux/of_address.h`, `linux/of_clk.h`, `linux/of_reserved_mem.h`, `linux/platform_data/simplefb.h`, `linux/platform_device.h`.
- Detected declarations: `struct simpledrm_device`, `function simplefb_get_validated_int`, `function simplefb_get_validated_int0`, `function simplefb_get_validated_format`, `function simplefb_get_width_pd`, `function simplefb_get_height_pd`, `function simplefb_get_stride_pd`, `function simplefb_get_format_pd`, `function simplefb_read_u32_of`, `function simplefb_read_string_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.