~emersion/go-drm

2fc5fd8f18101b1e924cb6082803ac1f7f84614a — Simon Ser 9 days ago c0c2450
Parse NVIDIA modifiers
1 files changed, 23 insertions(+), 1 deletions(-)

M fourcc.go
M fourcc.go => fourcc.go +23 -1
@@ 36,7 36,15 @@ func (mod Modifier) Vendor() ModifierVendor {
}

func (mod Modifier) Name() string {
	// TODO: parse complicated modifiers
	var name string
	switch mod.Vendor() {
	case ModifierVendorNVIDIA:
		name = modifierNameNVIDIA(uint64(mod))
	}
	if name != "" {
		return name
	}

	if name := mod.str(); name != "" {
		return name
	}


@@ 49,3 57,17 @@ func (mod Modifier) Name() string {
func (mod Modifier) String() string {
	return fmt.Sprintf("%s (0x%X)", mod.Name(), uint64(mod))
}

func modifierNameNVIDIA(mod uint64) string {
	if mod & 0x10 == 0 {
		return ""
	}

	h := mod & 0xF
	k := (mod >> 12) & 0xFF
	g := (mod >> 20) & 0x3
	s := (mod >> 22) & 0x1
	c := (mod >> 23) & 0x7

	return fmt.Sprintf("NVIDIA_BLOCK_LINEAR_2D(h=%v, k=%v, g=%v, s=%v, c=%v)", h, k, g, s, c)
}