drivers/gpu/drm/drm_fourcc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_fourcc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_fourcc.c- Extension
.c- Size
- 27972 bytes
- Lines
- 543
- 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/bug.hlinux/ctype.hlinux/export.hlinux/kernel.hdrm/drm_device.hdrm/drm_fourcc.h
Detected Declarations
function Copyrightfunction drm_mode_legacy_fb_formatfunction drm_driver_color_modefunction drm_format_infofunction drm_get_format_infofunction drm_format_info_block_widthfunction drm_format_info_block_heightfunction drm_format_info_bppfunction drm_format_info_min_pitchexport drm_mode_legacy_fb_formatexport drm_driver_legacy_fb_formatexport drm_driver_color_mode_formatexport drm_format_infoexport drm_get_format_infoexport drm_format_info_block_widthexport drm_format_info_block_heightexport drm_format_info_bppexport drm_format_info_min_pitch
Annotated Snippet
switch (depth) {
case 15:
fmt = DRM_FORMAT_XRGB1555;
break;
case 16:
fmt = DRM_FORMAT_RGB565;
break;
default:
break;
}
break;
case 24:
if (depth == 24)
fmt = DRM_FORMAT_RGB888;
break;
case 32:
switch (depth) {
case 24:
fmt = DRM_FORMAT_XRGB8888;
break;
case 30:
fmt = DRM_FORMAT_XRGB2101010;
break;
case 32:
fmt = DRM_FORMAT_ARGB8888;
break;
default:
break;
}
break;
default:
break;
}
return fmt;
}
EXPORT_SYMBOL(drm_mode_legacy_fb_format);
/**
* drm_driver_legacy_fb_format - compute drm fourcc code from legacy description
* @dev: DRM device
* @bpp: bits per pixels
* @depth: bit depth per pixel
*
* Computes a drm fourcc pixel format code for the given @bpp/@depth values.
* Unlike drm_mode_legacy_fb_format() this looks at the drivers mode_config,
* and depending on the &drm_mode_config.quirk_addfb_prefer_host_byte_order flag
* it returns little endian byte order or host byte order framebuffer formats.
*/
uint32_t drm_driver_legacy_fb_format(struct drm_device *dev,
uint32_t bpp, uint32_t depth)
{
uint32_t fmt = drm_mode_legacy_fb_format(bpp, depth);
if (dev->mode_config.quirk_addfb_prefer_host_byte_order) {
if (fmt == DRM_FORMAT_XRGB8888)
fmt = DRM_FORMAT_HOST_XRGB8888;
if (fmt == DRM_FORMAT_ARGB8888)
fmt = DRM_FORMAT_HOST_ARGB8888;
if (fmt == DRM_FORMAT_RGB565)
fmt = DRM_FORMAT_HOST_RGB565;
if (fmt == DRM_FORMAT_XRGB1555)
fmt = DRM_FORMAT_HOST_XRGB1555;
}
if (dev->mode_config.quirk_addfb_prefer_xbgr_30bpp &&
fmt == DRM_FORMAT_XRGB2101010)
fmt = DRM_FORMAT_XBGR2101010;
return fmt;
}
EXPORT_SYMBOL(drm_driver_legacy_fb_format);
/**
* drm_driver_color_mode_format - Compute DRM 4CC code from color mode
* @dev: DRM device
* @color_mode: command-line color mode
*
* Computes a DRM 4CC pixel format code for the given color mode using
* drm_driver_color_mode(). The color mode is in the format used and the
* kernel command line. It specifies the number of bits per pixel
* and color depth in a single value.
*
* Useful in fbdev emulation code, since that deals in those values. The
* helper does not consider YUV or other complicated formats. This means
* only legacy formats are supported (fmt->depth is a legacy field), but
* the framebuffer emulation can only deal with such formats, specifically
Annotation
- Immediate include surface: `linux/bug.h`, `linux/ctype.h`, `linux/export.h`, `linux/kernel.h`, `drm/drm_device.h`, `drm/drm_fourcc.h`.
- Detected declarations: `function Copyright`, `function drm_mode_legacy_fb_format`, `function drm_driver_color_mode`, `function drm_format_info`, `function drm_get_format_info`, `function drm_format_info_block_width`, `function drm_format_info_block_height`, `function drm_format_info_bpp`, `function drm_format_info_min_pitch`, `export drm_mode_legacy_fb_format`.
- 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.