drm

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2023 License: MIT Imports: 7 Imported by: 0

README

GoDoc

drm

The Direct Rendering Manager (DRM) is a kernel framework to manage Graphical Processing Units (GPU). It's a kernel abstractions to GPU drivers and a userspace API designed to support the needs of complex graphics devices.

DRM was first implemented on Linux but ported to FreeBSD, NetBSD and Solaris (others?). It's the lower level interface between opengl and the graphics card. With this Go library, theoretically, now it's possible to create a X server or a pure OpenGL library in Go (no bindings).

Rationale

Enables the creation of a graphics stack in Go, avoiding the overhead of the existing C bindings. Another possibility is using Go to make GPGPU (like opencl).

Examples

See the examples directory.

Documentation

Overview

Package drm provides a library to interact with DRM (Direct Rendering Manager) and KMS (Kernel Mode Setting) interfaces. DRM is a low level interface for the graphics card (gpu) and this package enables the creation of graphics library on top of the kernel drm/kms subsystem.

Index

Examples

Constants

View Source
const (
	CapDumbBuffer uint64 = iota + 1
	CapVBlankHighCRTC
	CapDumbPreferredDepth
	CapDumbPreferShadow
	CapPrime
	CapTimestampMonotonic
	CapAsyncPageFlip
	CapCursorWidth
	CapCursorHeight

	CapAddFB2Modifiers = 0x10
)

Variables

This section is empty.

Functions

func GetCap

func GetCap(f *os.File, id uint64) (uint64, error)

func HasDumbBuffer

func HasDumbBuffer(f *os.File) bool
Example
package main

import (
	"fmt"

	"github.com/JesterSks/drm"
)

func main() {
	// This example shows how to test if your graphics card
	// supports 'dumb buffers' capability. With this capability
	// you can create simple memory-mapped buffers without any
	// driver-dependent code.

	file, err := drm.OpenCard(0)
	if err != nil {
		fmt.Printf("error: %s", err.Error())
		return
	}
	defer file.Close()
	if !drm.HasDumbBuffer(file) {
		fmt.Printf("drm device does not support dumb buffers")
		return
	}
	fmt.Printf("ok")

}
Output:

ok

func OpenCard

func OpenCard(n int) (*os.File, error)

func OpenControlDev

func OpenControlDev(n int) (*os.File, error)

func OpenRenderDev

func OpenRenderDev(n int) (*os.File, error)

Types

type Version

type Version struct {
	internal.SysVersion

	Major int32
	Minor int32
	Patch int32
	Name  string // Name of the driver (eg.: i915)
	Date  string
	Desc  string
}

Version of DRM driver

func Available

func Available() (Version, error)

func GetVersion

func GetVersion(f *os.File) (Version, error)

func ListDevices

func ListDevices() []Version
Example
package main

import (
	"fmt"

	"github.com/JesterSks/drm"
)

func main() {
	// Shows how to enumerate the available dri devices
	for _, dev := range drm.ListDevices() {
		fmt.Printf("Driver name: %s\n", dev.Name)
	}

}
Output:

Driver name: i915

Directories

Path Synopsis
_examples
modeset
Port of modeset.c example to Go Source: https://github.com/dvdhrm/docs/blob/master/drm-howto/modeset-double-buffered.c
Port of modeset.c example to Go Source: https://github.com/dvdhrm/docs/blob/master/drm-howto/modeset-double-buffered.c

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL