drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c- Extension
.c- Size
- 2082 bytes
- Lines
- 75
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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/limits.hlinux/minmax.hlinux/screen_info.hdrm/drm_fourcc.hdrm/drm_print.hdrm_sysfb_helper.h
Detected Declarations
function drm_sysfb_get_validated_size0function drm_sysfb_get_width_sifunction drm_sysfb_get_height_sifunction drm_sysfb_get_stride_sifunction drm_sysfb_get_visible_size_siexport drm_sysfb_get_width_siexport drm_sysfb_get_height_siexport drm_sysfb_get_memory_siexport drm_sysfb_get_stride_siexport drm_sysfb_get_visible_size_si
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/export.h>
#include <linux/limits.h>
#include <linux/minmax.h>
#include <linux/screen_info.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_print.h>
#include "drm_sysfb_helper.h"
static s64 drm_sysfb_get_validated_size0(struct drm_device *dev, const char *name,
u64 value, u64 max)
{
if (!value) {
drm_warn(dev, "%s of 0 not allowed\n", name);
return -EINVAL;
} else if (value > min(max, S64_MAX)) {
drm_warn(dev, "%s of %llu exceeds maximum of %llu\n", name, value, max);
return -EINVAL;
}
return value;
}
int drm_sysfb_get_width_si(struct drm_device *dev, const struct screen_info *si)
{
return drm_sysfb_get_validated_int0(dev, "width", si->lfb_width, U16_MAX);
}
EXPORT_SYMBOL(drm_sysfb_get_width_si);
int drm_sysfb_get_height_si(struct drm_device *dev, const struct screen_info *si)
{
return drm_sysfb_get_validated_int0(dev, "height", si->lfb_height, U16_MAX);
}
EXPORT_SYMBOL(drm_sysfb_get_height_si);
struct resource *drm_sysfb_get_memory_si(struct drm_device *dev,
const struct screen_info *si,
struct resource *res)
{
ssize_t num;
num = screen_info_resources(si, res, 1);
if (!num) {
drm_warn(dev, "memory resource not found\n");
return NULL;
}
return res;
}
EXPORT_SYMBOL(drm_sysfb_get_memory_si);
int drm_sysfb_get_stride_si(struct drm_device *dev, const struct screen_info *si,
const struct drm_format_info *format,
unsigned int width, unsigned int height, u64 size)
{
u64 lfb_linelength = si->lfb_linelength;
if (!lfb_linelength)
lfb_linelength = drm_format_info_min_pitch(format, 0, width);
return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength, div64_u64(size, height));
}
EXPORT_SYMBOL(drm_sysfb_get_stride_si);
u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si,
unsigned int height, unsigned int stride, u64 size)
{
u64 vsize = PAGE_ALIGN(height * stride);
return drm_sysfb_get_validated_size0(dev, "visible size", vsize, size);
}
EXPORT_SYMBOL(drm_sysfb_get_visible_size_si);
Annotation
- Immediate include surface: `linux/export.h`, `linux/limits.h`, `linux/minmax.h`, `linux/screen_info.h`, `drm/drm_fourcc.h`, `drm/drm_print.h`, `drm_sysfb_helper.h`.
- Detected declarations: `function drm_sysfb_get_validated_size0`, `function drm_sysfb_get_width_si`, `function drm_sysfb_get_height_si`, `function drm_sysfb_get_stride_si`, `function drm_sysfb_get_visible_size_si`, `export drm_sysfb_get_width_si`, `export drm_sysfb_get_height_si`, `export drm_sysfb_get_memory_si`, `export drm_sysfb_get_stride_si`, `export drm_sysfb_get_visible_size_si`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.