~emersion/go-drm

7088ebfe24cbd5cd133486c883e4e00b6e19795b — Simon Ser 2 months ago 8e5be5e master
Add support for Amlogic format modifiers
3 files changed, 52 insertions(+), 2 deletions(-)

M fourcc.go
M fourcc.py
M fourcc_generated.go
M fourcc.go => fourcc.go +35 -0
@@ 42,6 42,8 @@ func (mod Modifier) Name() string {
		name = modifierNameNVIDIA(uint64(mod))
	case ModifierVendorARM:
		name = modifierNameARM(uint64(mod))
	case ModifierVendorAmlogic:
		name = modifierNameAmlogic(uint64(mod))
	}
	if name != "" {
		return name


@@ 142,3 144,36 @@ func armAFBCBlockSizeStr(blockSize armAFBC) string {
		return "unknown"
	}
}

type (
	amlogicFBCLayout uint64
	amlogicFBCOption uint64
)

func modifierNameAmlogic(mod uint64) string {
	layout := amlogicFBCLayout(mod & 0xFF)
	options := amlogicFBCOption((mod >> 8) & 0xFF)

	return fmt.Sprintf("AMLOGIC_FBC(layout = %v, options = %v)", amlogicFBCLayoutStr(layout), amlogicFBCOptionsStr(options))
}

func amlogicFBCLayoutStr(layout amlogicFBCLayout) string {
	switch layout {
	case amlogicFBCLayoutBASIC:
		return "BASIC"
	case amlogicFBCLayoutSCATTER:
		return "SCATTER"
	default:
		return "unknown"
	}
}

func amlogicFBCOptionsStr(options amlogicFBCOption) string {
	if options == 0 {
		return "0"
	}
	if options == amlogicFBCOptionMEM_SAVING {
		return "MEM_SAVING"
	}
	return "unknown"
}

M fourcc.py => fourcc.py +8 -2
@@ 24,7 24,7 @@ for flag in cflags:
if not found:
	raise Exception("Failed to find drm_fourcc.h in libdrm -I cflags")

prefixes = ["DRM_FORMAT_", "I915_FORMAT_", "AFBC_FORMAT_MOD_"]
prefixes = ["DRM_FORMAT_", "I915_FORMAT_", "AFBC_FORMAT_MOD_", "AMLOGIC_FBC_"]

ident_list = []
with open(fourcc_include) as input_file:


@@ 70,7 70,7 @@ with tempfile.TemporaryDirectory() as work_dir:
	for (i, l) in enumerate(output.splitlines()):
		idents[ident_list[i]] = l

types = ["Format", "ModifierVendor", "Modifier", "armModifierType", "armAFBC"]
types = ["Format", "ModifierVendor", "Modifier", "armModifierType", "armAFBC", "amlogicFBCLayout", "amlogicFBCOption"]
words = ["none", "invalid", "linear"]
initialisms = ["AMD", "NVIDIA", "ARM"]



@@ 107,6 107,12 @@ for (ident, val) in idents.items():
		ident = ident[len("DRM_FORMAT_"):]
		if ident in ["BIG_ENDIAN", "RESERVED"]:
			continue
	elif ident.startswith("AMLOGIC_FBC_LAYOUT_"):
		t = "amlogicFBCLayout"
		ident = ident[len("AMLOGIC_FBC_LAYOUT_"):]
	elif ident.startswith("AMLOGIC_FBC_OPTION_"):
		t = "amlogicFBCOption"
		ident = ident[len("AMLOGIC_FBC_OPTION_"):]
	else:
		assert(False)


M fourcc_generated.go => fourcc_generated.go +9 -0
@@ 492,3 492,12 @@ const (
	armAFBC_BCH                  armAFBC = 0x800
	armAFBC_USM                  armAFBC = 0x1000
)

const (
	amlogicFBCLayoutBASIC   amlogicFBCLayout = 0x1
	amlogicFBCLayoutSCATTER amlogicFBCLayout = 0x2
)

const (
	amlogicFBCOptionMEM_SAVING amlogicFBCOption = 0x1
)