drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c- Extension
.c- Size
- 10853 bytes
- Lines
- 365
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
uapi/drm/drm_fourcc.hdrm/drm_framebuffer.hdpu_kms.hdpu_formats.h
Detected Declarations
struct dpu_media_color_mapfunction _dpu_get_v_h_subsample_ratefunction _dpu_format_populate_plane_sizes_ubwcfunction _dpu_format_populate_plane_sizes_linearfunction dpu_format_populate_plane_sizesfunction _dpu_format_populate_addrs_ubwcfunction _dpu_format_populate_addrs_linearfunction dpu_format_populate_addrs
Annotated Snippet
struct dpu_media_color_map {
uint32_t format;
uint32_t color;
};
/* _dpu_get_v_h_subsample_rate - Get subsample rates for all formats we support
* Note: Not using the drm_format_*_subsampling since we have formats
*/
static void _dpu_get_v_h_subsample_rate(
enum mdp_chroma_samp_type chroma_sample,
uint32_t *v_sample,
uint32_t *h_sample)
{
if (!v_sample || !h_sample)
return;
switch (chroma_sample) {
case CHROMA_H2V1:
*v_sample = 1;
*h_sample = 2;
break;
case CHROMA_H1V2:
*v_sample = 2;
*h_sample = 1;
break;
case CHROMA_420:
*v_sample = 2;
*h_sample = 2;
break;
default:
*v_sample = 1;
*h_sample = 1;
break;
}
}
static int _dpu_format_populate_plane_sizes_ubwc(
const struct msm_format *fmt,
struct drm_framebuffer *fb,
struct dpu_hw_fmt_layout *layout)
{
bool meta = MSM_FORMAT_IS_UBWC(fmt);
if (MSM_FORMAT_IS_YUV(fmt)) {
unsigned int stride, y_sclines, uv_sclines;
unsigned int y_tile_width, y_tile_height;
unsigned int y_meta_stride, y_meta_scanlines;
unsigned int uv_meta_stride, uv_meta_scanlines;
if (MSM_FORMAT_IS_DX(fmt)) {
if (fmt->flags & MSM_FORMAT_FLAG_UNPACK_TIGHT) {
/* can't use round_up() here because 192 is NPoT */
stride = roundup(fb->width, 192);
stride = round_up(stride * 4 / 3, 256);
y_tile_width = 48;
} else {
stride = round_up(fb->width * 2, 256);
y_tile_width = 32;
}
y_sclines = round_up(fb->height, 16);
uv_sclines = round_up((fb->height+1)>>1, 16);
y_tile_height = 4;
} else {
stride = round_up(fb->width, 128);
y_tile_width = 32;
y_sclines = round_up(fb->height, 32);
uv_sclines = round_up((fb->height+1)>>1, 32);
y_tile_height = 8;
}
layout->plane_pitch[0] = stride;
layout->plane_size[0] = round_up(layout->plane_pitch[0] *
y_sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
layout->plane_pitch[1] = stride;
layout->plane_size[1] = round_up(layout->plane_pitch[1] *
uv_sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
if (!meta)
return 0;
y_meta_stride = DIV_ROUND_UP(fb->width, y_tile_width);
layout->plane_pitch[2] = round_up(y_meta_stride, 64);
y_meta_scanlines = DIV_ROUND_UP(fb->height, y_tile_height);
y_meta_scanlines = round_up(y_meta_scanlines, 16);
layout->plane_size[2] = round_up(layout->plane_pitch[2] *
y_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
Annotation
- Immediate include surface: `uapi/drm/drm_fourcc.h`, `drm/drm_framebuffer.h`, `dpu_kms.h`, `dpu_formats.h`.
- Detected declarations: `struct dpu_media_color_map`, `function _dpu_get_v_h_subsample_rate`, `function _dpu_format_populate_plane_sizes_ubwc`, `function _dpu_format_populate_plane_sizes_linear`, `function dpu_format_populate_plane_sizes`, `function _dpu_format_populate_addrs_ubwc`, `function _dpu_format_populate_addrs_linear`, `function dpu_format_populate_addrs`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.