forked from NeowayLabs/drm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcap.go
47 lines (40 loc) · 738 Bytes
/
cap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package drm
import (
"os"
"unsafe"
"github.com/NeowayLabs/drm/ioctl"
)
type (
capability struct {
id uint64
val uint64
}
)
const (
CapDumbBuffer uint64 = iota + 1
CapVBlankHighCRTC
CapDumbPreferredDepth
CapDumbPreferShadow
CapPrime
CapTimestampMonotonic
CapAsyncPageFlip
CapCursorWidth
CapCursorHeight
CapAddFB2Modifiers = 0x10
)
func HasDumbBuffer(file *os.File) bool {
cap, err := GetCap(file, CapDumbBuffer)
if err != nil {
return false
}
return cap != 0
}
func GetCap(file *os.File, capid uint64) (uint64, error) {
cap := &capability{}
cap.id = capid
err := ioctl.Do(uintptr(file.Fd()), uintptr(IOCTLGetCap), uintptr(unsafe.Pointer(cap)))
if err != nil {
return 0, err
}
return cap.val, nil
}