drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
Extension
.c
Size
3641 bytes
Lines
153
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
 * Author: James.Qian.Wang <james.qian.wang@arm.com>
 *
 */

#include <linux/slab.h>
#include "komeda_format_caps.h"
#include "malidp_utils.h"

const struct komeda_format_caps *
komeda_get_format_caps(struct komeda_format_caps_table *table,
		       u32 fourcc, u64 modifier)
{
	const struct komeda_format_caps *caps;
	u64 afbc_features = modifier & ~(AFBC_FORMAT_MOD_BLOCK_SIZE_MASK);
	u32 afbc_layout = modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK;
	int id;

	for (id = 0; id < table->n_formats; id++) {
		caps = &table->format_caps[id];

		if (fourcc != caps->fourcc)
			continue;

		if ((modifier == 0ULL) && (caps->supported_afbc_layouts == 0))
			return caps;

		if (has_bits(afbc_features, caps->supported_afbc_features) &&
		    has_bit(afbc_layout, caps->supported_afbc_layouts))
			return caps;
	}

	return NULL;
}

u32 komeda_get_afbc_format_bpp(const struct drm_format_info *info, u64 modifier)
{
	u32 bpp;

	switch (info->format) {
	case DRM_FORMAT_YUV420_8BIT:
		bpp = 12;
		break;
	case DRM_FORMAT_YUV420_10BIT:
		bpp = 15;
		break;
	default:
		bpp = info->cpp[0] * 8;
		break;
	}

	return bpp;
}

/* Two assumptions
 * 1. RGB always has YTR
 * 2. Tiled RGB always has SC
 */
u64 komeda_supported_modifiers[] = {
	/* AFBC_16x16 + features: YUV+RGB both */
	AFBC_16x16(0),
	/* SPARSE */
	AFBC_16x16(_SPARSE),
	/* YTR + (SPARSE) */
	AFBC_16x16(_YTR | _SPARSE),
	AFBC_16x16(_YTR),
	/* SPLIT + SPARSE + YTR RGB only */
	/* split mode is only allowed for sparse mode */
	AFBC_16x16(_SPLIT | _SPARSE | _YTR),
	/* TILED + (SPARSE) */
	/* TILED YUV format only */
	AFBC_16x16(_TILED | _SPARSE),
	AFBC_16x16(_TILED),
	/* TILED + SC + (SPLIT+SPARSE | SPARSE) + (YTR) */
	AFBC_16x16(_TILED | _SC | _SPLIT | _SPARSE | _YTR),
	AFBC_16x16(_TILED | _SC | _SPARSE | _YTR),
	AFBC_16x16(_TILED | _SC | _YTR),
	/* AFBC_32x8 + features: which are RGB formats only */
	/* YTR + (SPARSE) */
	AFBC_32x8(_YTR | _SPARSE),
	AFBC_32x8(_YTR),
	/* SPLIT + SPARSE + (YTR) */
	/* split mode is only allowed for sparse mode */
	AFBC_32x8(_SPLIT | _SPARSE | _YTR),
	/* TILED + SC + (SPLIT+SPARSE | SPARSE) + YTR */
	AFBC_32x8(_TILED | _SC | _SPLIT | _SPARSE | _YTR),
	AFBC_32x8(_TILED | _SC | _SPARSE | _YTR),
	AFBC_32x8(_TILED | _SC | _YTR),

Annotation

Implementation Notes