README

go-drm

GoDoc

libdrm for Go.

Disclaimer: this project is silly, you most certainly shouldn't use it.

License

MIT

Documentation

Overview

    Package drm implements a userspace library for the Direct Rendering Manager.

    Index

    Constants

    View Source
    const (
    	CapPrimeImport = 0x1
    	CapPrimeExport = 0x2
    )
    View Source
    const (
    	DirName            = "/dev/dri"
    	NodePatternPrimary = "/dev/dri/card*"
    	NodePatternControl = "/dev/dri/controlD*"
    	NodePatternRender  = "/dev/dri/renderD*"
    )

    Variables

    This section is empty.

    Functions

    func ParsePath

    func ParsePath(b []byte) (string, error)

    Types

    type AnyID

    type AnyID interface {
    	Type() ObjectType
    	Object() ObjectID
    }

    func NewAnyID

    func NewAnyID(id ObjectID, t ObjectType) AnyID

    type BlobID

    type BlobID ObjectID

    func (BlobID) Object

    func (id BlobID) Object() ObjectID

    func (BlobID) Type

    func (id BlobID) Type() ObjectType

    type BusType

    type BusType int
    const (
    	BusPCI      BusType = 0
    	BusUSB      BusType = 1
    	BusPlatform BusType = 2
    	BusHost1x   BusType = 3
    )

    func (BusType) String

    func (t BusType) String() string

    type CRTCID

    type CRTCID ObjectID

    func (CRTCID) Object

    func (id CRTCID) Object() ObjectID

    func (CRTCID) Type

    func (id CRTCID) Type() ObjectType

    type Cap

    type Cap uint64
    const (
    	CapDumbBuffer          Cap = 0x1
    	CapVblankHighCRTC      Cap = 0x2
    	CapDumbPreferredDepth  Cap = 0x3
    	CapDumbPreferredShadow Cap = 0x4
    	CapPrime               Cap = 0x5
    	CapTimestampMonotonic  Cap = 0x6
    	CapAsyncPageFlip       Cap = 0x7
    	CapCursorWidth         Cap = 0x8
    	CapCursorHeight        Cap = 0x9
    	CapAddFB2Modifiers     Cap = 0x10
    	CapPageFlipTarget      Cap = 0x11
    	CapCRTCInVBlankEvent   Cap = 0x12
    	CapSyncObj             Cap = 0x13
    	CapSyncObjTimeline     Cap = 0x14
    )

    func (Cap) String

    func (c Cap) String() string

    type ClientCap

    type ClientCap uint64
    const (
    	ClientCapStereo3D            ClientCap = 1
    	ClientCapUniversalPlanes     ClientCap = 2
    	ClientCapAtomic              ClientCap = 3
    	ClientCapAspectRatio         ClientCap = 4
    	ClientCapWritebackConnectors ClientCap = 5
    )

    func (ClientCap) String

    func (c ClientCap) String() string

    type ConnectorID

    type ConnectorID ObjectID

    func (ConnectorID) Object

    func (id ConnectorID) Object() ObjectID

    func (ConnectorID) Type

    func (id ConnectorID) Type() ObjectType

    type ConnectorStatus

    type ConnectorStatus uint32
    const (
    	ConnectorStatusConnected    ConnectorStatus = 1
    	ConnectorStatusDisconnected ConnectorStatus = 2
    	ConnectorStatusUnknown      ConnectorStatus = 3
    )

    func (ConnectorStatus) String

    func (s ConnectorStatus) String() string

    type ConnectorType

    type ConnectorType uint32
    const (
    	ConnectorUnknown     ConnectorType = 0
    	ConnectorVGA         ConnectorType = 1
    	ConnectorDVII        ConnectorType = 2
    	ConnectorDVID        ConnectorType = 3
    	ConnectorDVIA        ConnectorType = 4
    	ConnectorComposite   ConnectorType = 5
    	ConnectorSVideo      ConnectorType = 6
    	ConnectorLVDS        ConnectorType = 7
    	ConnectorComponent   ConnectorType = 8
    	Connector9PinDIN     ConnectorType = 9
    	ConnectorDisplayPort ConnectorType = 10
    	ConnectorHDMIA       ConnectorType = 11
    	ConnectorHDMIB       ConnectorType = 12
    	ConnectorTV          ConnectorType = 13
    	ConnectorEDP         ConnectorType = 14
    	ConnectorVirtual     ConnectorType = 15
    	ConnectorDSI         ConnectorType = 16
    	ConnectorDPI         ConnectorType = 17
    	ConnectorWriteback   ConnectorType = 18
    )

    func (ConnectorType) String

    func (t ConnectorType) String() string

    type Device

    type Device interface {
    	BusType() BusType
    }

    type EncoderID

    type EncoderID ObjectID

    func (EncoderID) Object

    func (id EncoderID) Object() ObjectID

    func (EncoderID) Type

    func (id EncoderID) Type() ObjectType

    type EncoderType

    type EncoderType uint32
    const (
    	EncoderNone    EncoderType = 0
    	EncoderDAC     EncoderType = 1
    	EncoderTMDS    EncoderType = 2
    	EncoderLVDS    EncoderType = 3
    	EncoderTVDAC   EncoderType = 4
    	EncoderVirtual EncoderType = 5
    	EncoderDSI     EncoderType = 6
    	EncoderDPMST   EncoderType = 7
    	EncoderDPI     EncoderType = 8
    )

    func (EncoderType) String

    func (t EncoderType) String() string

    type FBID

    type FBID ObjectID

    func (FBID) Object

    func (id FBID) Object() ObjectID

    func (FBID) Type

    func (id FBID) Type() ObjectType

    type Format

    type Format uint32
    const (
    	FormatInvalid              Format = 0x0
    	FormatC8                   Format = 0x20203843
    	FormatR8                   Format = 0x20203852
    	FormatR16                  Format = 0x20363152
    	FormatRG88                 Format = 0x38384752
    	FormatGR88                 Format = 0x38385247
    	FormatRG1616               Format = 0x32334752
    	FormatGR1616               Format = 0x32335247
    	FormatRGB332               Format = 0x38424752
    	FormatBGR233               Format = 0x38524742
    	FormatXRGB4444             Format = 0x32315258
    	FormatXBGR4444             Format = 0x32314258
    	FormatRGBX4444             Format = 0x32315852
    	FormatBGRX4444             Format = 0x32315842
    	FormatARGB4444             Format = 0x32315241
    	FormatABGR4444             Format = 0x32314241
    	FormatRGBA4444             Format = 0x32314152
    	FormatBGRA4444             Format = 0x32314142
    	FormatXRGB1555             Format = 0x35315258
    	FormatXBGR1555             Format = 0x35314258
    	FormatRGBX5551             Format = 0x35315852
    	FormatBGRX5551             Format = 0x35315842
    	FormatARGB1555             Format = 0x35315241
    	FormatABGR1555             Format = 0x35314241
    	FormatRGBA5551             Format = 0x35314152
    	FormatBGRA5551             Format = 0x35314142
    	FormatRGB565               Format = 0x36314752
    	FormatBGR565               Format = 0x36314742
    	FormatRGB888               Format = 0x34324752
    	FormatBGR888               Format = 0x34324742
    	FormatXRGB8888             Format = 0x34325258
    	FormatXBGR8888             Format = 0x34324258
    	FormatRGBX8888             Format = 0x34325852
    	FormatBGRX8888             Format = 0x34325842
    	FormatARGB8888             Format = 0x34325241
    	FormatABGR8888             Format = 0x34324241
    	FormatRGBA8888             Format = 0x34324152
    	FormatBGRA8888             Format = 0x34324142
    	FormatXRGB2101010          Format = 0x30335258
    	FormatXBGR2101010          Format = 0x30334258
    	FormatRGBX1010102          Format = 0x30335852
    	FormatBGRX1010102          Format = 0x30335842
    	FormatARGB2101010          Format = 0x30335241
    	FormatABGR2101010          Format = 0x30334241
    	FormatRGBA1010102          Format = 0x30334152
    	FormatBGRA1010102          Format = 0x30334142
    	FormatXRGB16161616F        Format = 0x48345258
    	FormatXBGR16161616F        Format = 0x48344258
    	FormatARGB16161616F        Format = 0x48345241
    	FormatABGR16161616F        Format = 0x48344241
    	FormatAXBXGXRX106106106106 Format = 0x30314241
    	FormatYUYV                 Format = 0x56595559
    	FormatYVYU                 Format = 0x55595659
    	FormatUYVY                 Format = 0x59565955
    	FormatVYUY                 Format = 0x59555956
    	FormatAYUV                 Format = 0x56555941
    	FormatXYUV8888             Format = 0x56555958
    	FormatVUY888               Format = 0x34325556
    	FormatVUY101010            Format = 0x30335556
    	FormatY210                 Format = 0x30313259
    	FormatY212                 Format = 0x32313259
    	FormatY216                 Format = 0x36313259
    	FormatY410                 Format = 0x30313459
    	FormatY412                 Format = 0x32313459
    	FormatY416                 Format = 0x36313459
    	FormatXVYU2101010          Format = 0x30335658
    	FormatXVYU12_16161616      Format = 0x36335658
    	FormatXVYU16161616         Format = 0x38345658
    	FormatY0L0                 Format = 0x304C3059
    	FormatX0L0                 Format = 0x304C3058
    	FormatY0L2                 Format = 0x324C3059
    	FormatX0L2                 Format = 0x324C3058
    	FormatYUV420_8BIT          Format = 0x38305559
    	FormatYUV420_10BIT         Format = 0x30315559
    	FormatXRGB8888_A8          Format = 0x38415258
    	FormatXBGR8888_A8          Format = 0x38414258
    	FormatRGBX8888_A8          Format = 0x38415852
    	FormatBGRX8888_A8          Format = 0x38415842
    	FormatRGB888_A8            Format = 0x38413852
    	FormatBGR888_A8            Format = 0x38413842
    	FormatRGB565_A8            Format = 0x38413552
    	FormatBGR565_A8            Format = 0x38413542
    	FormatNV12                 Format = 0x3231564E
    	FormatNV21                 Format = 0x3132564E
    	FormatNV16                 Format = 0x3631564E
    	FormatNV61                 Format = 0x3136564E
    	FormatNV24                 Format = 0x3432564E
    	FormatNV42                 Format = 0x3234564E
    	FormatNV15                 Format = 0x3531564E
    	FormatP210                 Format = 0x30313250
    	FormatP010                 Format = 0x30313050
    	FormatP012                 Format = 0x32313050
    	FormatP016                 Format = 0x36313050
    	FormatQ410                 Format = 0x30313451
    	FormatQ401                 Format = 0x31303451
    	FormatYUV410               Format = 0x39565559
    	FormatYVU410               Format = 0x39555659
    	FormatYUV411               Format = 0x31315559
    	FormatYVU411               Format = 0x31315659
    	FormatYUV420               Format = 0x32315559
    	FormatYVU420               Format = 0x32315659
    	FormatYUV422               Format = 0x36315559
    	FormatYVU422               Format = 0x36315659
    	FormatYUV444               Format = 0x34325559
    	FormatYVU444               Format = 0x34325659
    )

    func ParseFormats

    func ParseFormats(b []byte) ([]Format, error)

    func (Format) Name

    func (f Format) Name() string

    func (Format) String

    func (f Format) String() string

    type FormatModifierSet

    type FormatModifierSet struct {
    	// contains filtered or unexported fields
    }

    func ParseFormatModifierSet

    func ParseFormatModifierSet(b []byte) (*FormatModifierSet, error)

    func (*FormatModifierSet) Map

    func (set *FormatModifierSet) Map() map[Modifier][]Format

    type ModeCRTC

    type ModeCRTC struct {
    	ID        CRTCID
    	FB        FBID
    	X, Y      uint32
    	GammaSize uint32
    	Mode      *ModeModeInfo
    }

    type ModeCard

    type ModeCard struct {
    	FBs                                      []FBID
    	CRTCs                                    []CRTCID
    	Connectors                               []ConnectorID
    	Encoders                                 []EncoderID
    	MinWidth, MaxWidth, MinHeight, MaxHeight uint32
    }

    type ModeConnector

    type ModeConnector struct {
    	PossibleEncoders []EncoderID
    	Modes            []ModeModeInfo
    
    	Encoder EncoderID
    	ID      ConnectorID
    	Type    ConnectorType
    
    	Status              ConnectorStatus
    	PhyWidth, PhyHeight uint32 // mm
    	Subpixel            Subpixel
    }

    type ModeEncoder

    type ModeEncoder struct {
    	ID                            EncoderID
    	Type                          EncoderType
    	CRTC                          CRTCID
    	PossibleCRTCs, PossibleClones uint32
    }

    type ModeID

    type ModeID ObjectID

    func (ModeID) Object

    func (id ModeID) Object() ObjectID

    func (ModeID) Type

    func (id ModeID) Type() ObjectType

    type ModeModeInfo

    type ModeModeInfo struct {
    	Clock                                         uint32
    	HDisplay, HSyncStart, HSyncEnd, HTotal, HSkew uint16
    	VDisplay, VSyncStart, VSyncEnd, VTotal, VScan uint16
    
    	VRefresh uint32
    
    	Flags uint32
    	Type  uint32
    	Name  string
    }

    func ParseModeModeInfo

    func ParseModeModeInfo(b []byte) (*ModeModeInfo, error)

    type ModePlane

    type ModePlane struct {
    	ID PlaneID
    
    	CRTC CRTCID
    	FB   FBID
    
    	PossibleCRTCs uint32
    	GammaSize     uint32
    
    	Formats []Format
    }

    type ModeProperty

    type ModeProperty struct {
    	ID   PropertyID
    	Name string
    	// contains filtered or unexported fields
    }

    func (*ModeProperty) Atomic

    func (prop *ModeProperty) Atomic() bool

    func (*ModeProperty) Blobs

    func (prop *ModeProperty) Blobs() ([]ModePropertyBlob, bool)

    func (*ModeProperty) Enums

    func (prop *ModeProperty) Enums() ([]ModePropertyEnum, bool)

    func (*ModeProperty) Immutable

    func (prop *ModeProperty) Immutable() bool

    func (*ModeProperty) ObjectType

    func (prop *ModeProperty) ObjectType() (ObjectType, bool)

    func (*ModeProperty) Range

    func (prop *ModeProperty) Range() (low, high uint64, ok bool)

    func (*ModeProperty) SignedRange

    func (prop *ModeProperty) SignedRange() (low, high int64, ok bool)

    func (*ModeProperty) Type

    func (prop *ModeProperty) Type() PropertyType

    type ModePropertyBlob

    type ModePropertyBlob struct {
    	ID   BlobID
    	Size uint32
    }

    type ModePropertyEnum

    type ModePropertyEnum struct {
    	Name  string
    	Value uint64
    }

    type Modifier

    type Modifier uint64
    const (
    	ModifierGENERIC_16_16_TILE               Modifier = 0x400000000000002
    	ModifierInvalid                          Modifier = 0xFFFFFFFFFFFFFF
    	ModifierLinear                           Modifier = 0x0
    	ModifierI915_X_TILED                     Modifier = 0x100000000000001
    	ModifierI915_Y_TILED                     Modifier = 0x100000000000002
    	ModifierI915_Yf_TILED                    Modifier = 0x100000000000003
    	ModifierI915_Y_TILED_CCS                 Modifier = 0x100000000000004
    	ModifierI915_Yf_TILED_CCS                Modifier = 0x100000000000005
    	ModifierI915_Y_TILED_GEN12_RC_CCS        Modifier = 0x100000000000006
    	ModifierI915_Y_TILED_GEN12_MC_CCS        Modifier = 0x100000000000007
    	ModifierSAMSUNG_64_32_TILE               Modifier = 0x400000000000001
    	ModifierQCOM_COMPRESSED                  Modifier = 0x500000000000001
    	ModifierVIVANTE_TILED                    Modifier = 0x600000000000001
    	ModifierVIVANTE_SUPER_TILED              Modifier = 0x600000000000002
    	ModifierVIVANTE_SPLIT_TILED              Modifier = 0x600000000000003
    	ModifierVIVANTE_SPLIT_SUPER_TILED        Modifier = 0x600000000000004
    	ModifierNVIDIA_TEGRA_TILED               Modifier = 0x300000000000001
    	ModifierNVIDIA_16BX2_BLOCK_ONE_GOB       Modifier = 0x300000000000010
    	ModifierNVIDIA_16BX2_BLOCK_TWO_GOB       Modifier = 0x300000000000011
    	ModifierNVIDIA_16BX2_BLOCK_FOUR_GOB      Modifier = 0x300000000000012
    	ModifierNVIDIA_16BX2_BLOCK_EIGHT_GOB     Modifier = 0x300000000000013
    	ModifierNVIDIA_16BX2_BLOCK_SIXTEEN_GOB   Modifier = 0x300000000000014
    	ModifierNVIDIA_16BX2_BLOCK_THIRTYTWO_GOB Modifier = 0x300000000000015
    	ModifierBROADCOM_VC4_T_TILED             Modifier = 0x700000000000001
    	ModifierBROADCOM_SAND32                  Modifier = 0x700000000000002
    	ModifierBROADCOM_SAND64                  Modifier = 0x700000000000003
    	ModifierBROADCOM_SAND128                 Modifier = 0x700000000000004
    	ModifierBROADCOM_SAND256                 Modifier = 0x700000000000005
    	ModifierBROADCOM_UIF                     Modifier = 0x700000000000006
    	ModifierARM_16X16_BLOCK_U_INTERLEAVED    Modifier = 0x810000000000001
    	ModifierALLWINNER_TILED                  Modifier = 0x900000000000001
    )

    func (Modifier) Name

    func (mod Modifier) Name() string

    func (Modifier) String

    func (mod Modifier) String() string

    func (Modifier) Vendor

    func (mod Modifier) Vendor() ModifierVendor

    type ModifierVendor

    type ModifierVendor uint8
    const (
    	ModifierVendorIntel     ModifierVendor = 0x1
    	ModifierVendorAMD       ModifierVendor = 0x2
    	ModifierVendorNVIDIA    ModifierVendor = 0x3
    	ModifierVendorSamsung   ModifierVendor = 0x4
    	ModifierVendorQcom      ModifierVendor = 0x5
    	ModifierVendorVivante   ModifierVendor = 0x6
    	ModifierVendorBroadcom  ModifierVendor = 0x7
    	ModifierVendorARM       ModifierVendor = 0x8
    	ModifierVendorAllwinner ModifierVendor = 0x9
    	ModifierVendorAmlogic   ModifierVendor = 0xA
    )

    func (ModifierVendor) String

    func (vendor ModifierVendor) String() string

    type Node

    type Node struct {
    	// contains filtered or unexported fields
    }

    func NewNode

    func NewNode(fd uintptr) *Node

    func (*Node) GetCap

    func (n *Node) GetCap(cap Cap) (uint64, error)

    func (*Node) GetDevice

    func (n *Node) GetDevice() (Device, error)

    func (*Node) ModeGetBlob

    func (n *Node) ModeGetBlob(id BlobID) ([]byte, error)

    func (*Node) ModeGetCRTC

    func (n *Node) ModeGetCRTC(id CRTCID) (*ModeCRTC, error)

    func (*Node) ModeGetConnector

    func (n *Node) ModeGetConnector(id ConnectorID) (*ModeConnector, error)

    func (*Node) ModeGetEncoder

    func (n *Node) ModeGetEncoder(id EncoderID) (*ModeEncoder, error)

    func (*Node) ModeGetPlane

    func (n *Node) ModeGetPlane(id PlaneID) (*ModePlane, error)

    func (*Node) ModeGetPlaneResources

    func (n *Node) ModeGetPlaneResources() ([]PlaneID, error)

    func (*Node) ModeGetProperty

    func (n *Node) ModeGetProperty(id PropertyID) (*ModeProperty, error)

    func (*Node) ModeGetResources

    func (n *Node) ModeGetResources() (*ModeCard, error)

    func (*Node) ModeObjectGetProperties

    func (n *Node) ModeObjectGetProperties(id AnyID) (map[PropertyID]uint64, error)

    func (*Node) SetClientCap

    func (n *Node) SetClientCap(cap ClientCap, val uint64) error

    func (*Node) Version

    func (n *Node) Version() (*Version, error)

    type NodeType

    type NodeType int
    const (
    	NodePrimary NodeType = 0
    	NodeControl NodeType = 1
    	NodeRender  NodeType = 2
    )

    func (NodeType) String

    func (t NodeType) String() string

    type ObjectID

    type ObjectID uint32

    func (ObjectID) Object

    func (id ObjectID) Object() ObjectID

    func (ObjectID) Type

    func (id ObjectID) Type() ObjectType

    type ObjectType

    type ObjectType uint32
    const (
    	ObjectAny       ObjectType = 0
    	ObjectCRTC      ObjectType = 0xCCCCCCCC
    	ObjectConnector ObjectType = 0xC0C0C0C0
    	ObjectEncoder   ObjectType = 0xE0E0E0E0
    	ObjectMode      ObjectType = 0xDEDEDEDE
    	ObjectProperty  ObjectType = 0xB0B0B0B0
    	ObjectFB        ObjectType = 0xFBFBFBFB
    	ObjectBlob      ObjectType = 0xBBBBBBBB
    	ObjectPlane     ObjectType = 0xEEEEEEEE
    )

    func (ObjectType) String

    func (t ObjectType) String() string

    type PCIDevice

    type PCIDevice struct {
    	Vendor, Device       uint32
    	SubVendor, SubDevice uint32
    }

    func (*PCIDevice) BusType

    func (d *PCIDevice) BusType() BusType

    type PlaneID

    type PlaneID ObjectID

    func (PlaneID) Object

    func (id PlaneID) Object() ObjectID

    func (PlaneID) Type

    func (id PlaneID) Type() ObjectType

    type PlaneType

    type PlaneType uint32
    const (
    	PlaneOverlay PlaneType = 0
    	PlanePrimary PlaneType = 1
    	PlaneCursor  PlaneType = 2
    )

    func (PlaneType) String

    func (t PlaneType) String() string

    type PropertyID

    type PropertyID ObjectID

    func (PropertyID) Object

    func (id PropertyID) Object() ObjectID

    func (PropertyID) Type

    func (id PropertyID) Type() ObjectType

    type PropertyType

    type PropertyType uint32
    const (
    	// Legacy types
    	PropertyRange   PropertyType = 1 << 1
    	PropertyEnum    PropertyType = 1 << 3
    	PropertyBlob    PropertyType = 1 << 4
    	PropertyBitmask PropertyType = 1 << 5
    
    	// Extended types
    	PropertyObject      PropertyType = 1 << 6
    	PropertySignedRange PropertyType = 2 << 6
    )

    func (PropertyType) String

    func (t PropertyType) String() string

    type Subpixel

    type Subpixel uint32
    const (
    	SubpixelUnknown       Subpixel = 0
    	SubpixelHorizontalRGB Subpixel = 1
    	SubpixelHorizontalBGR Subpixel = 3
    	SubpixelVerticalRGB   Subpixel = 4
    	SubpixelVerticalBGR   Subpixel = 5
    	SubpixelNone          Subpixel = 6
    )

    func (Subpixel) String

    func (s Subpixel) String() string

    type Version

    type Version struct {
    	Major, Minor, Patch int32
    	Name, Date, Desc    string
    }