tree: fa0d7d3d76e7f250a703519040f398de683bafa4 [path history] [tgz]
  1. example/
  2. include/
  3. src/


BS DRM is a library to factor out most of the boilerplate found in programs written against DRM.


  • Clang or GCC with -std=gnu99
  • libgbm
  • libdrm


  • Opens DRM devices
  • Creates display pipelines
  • Allocates buffer objects with framebuffers
  • Dumb maps buffer objects


(in order of priority)

  • Useful
  • Consistent and guessable API
  • Easy to read
  • Code is documentation
  • 0 warnings from Clang or GCC
  • Make errors easy to debug
  • Fun

Code Philosophy

  • This library is meant to be consumed by applications, not other libraries
  • Applications usually can't recover from errors
  • Corollary: returning error codes to applications is a waste of programmer time
  • Badly behaving applications should fail fast
  • Asserts fail fast
  • Use asserts to make bad applications fail fast
  • Make code style consistent with clang-format

Naming Rules

  • File names: .c
  • Functions: start with bs__
  • Constructor functions: suffix with “new”
  • Destructor functions: suffix with “destroy”
  • Conversion functions: suffix with “create”
  • Functions that overload: put overload name at the very end

Build Example

Define CC CFLAGS and LDFLAGS for your device. Then run the following from the top level directory:

${CC} ${CFLAGS} -c src/drm_fb.c -o drm_fb.o || exit 1
${CC} ${CFLAGS} -c src/drm_open.c -o drm_open.o || exit 1
${CC} ${CFLAGS} -c src/drm_pipe.c -o drm_pipe.o || exit 1
${CC} ${CFLAGS} -c src/pipe.c -o pipe.o || exit 1
${CC} ${CFLAGS} -c example/stripe.c -o stripe.o || exit 1
${CC} ${LDFLAGS} \
    pipe.o \
    drm_pipe.o \
    drm_fb.o \
    drm_open.o \
    stripe.o -o bstest || exit 1

Clang Format Example

If you want to format gamma_test.c, first go to the drm-tests source directory and then run:

clang-format -style=file -i gamma_test.c

The -style=file argument will cause clang-format to search recursively upwards for the .clang-format style file, which is in drm-tests.

Upcoming Features

  • Vsync
  • Atomic Commit
  • Multi-card and multi-monitor
  • Keyboard/Mouse input for debugging
  • Dump buffer output for debugging

What does BS stand for?

BS does't stand for anything.