
Raw graphics output in Linux: Part 2 - ingve
http://orangejuiceliberationfront.com/raw-graphics-output-in-linux-part-2/
======
Jasper_
Instead of using the deprecated /dev/fb interface, you should be using DRM/KMS
instead, which has support for modesetting, page flipping, cursors,
overlays/planes (including YUV planes), and plenty more.

I have a simple toy app that shows how to use the API here:
[https://github.com/magcius/drmdemo](https://github.com/magcius/drmdemo)

~~~
voltagex_
is KMS going to work in VirtualBox without the extensions?

~~~
Jasper_
In VirtualBox without the extensions, I believe we will currently fall back to
either VESA or EFI GOP modesetting, neither of which indeed have KMS support
yet.

There was a patchset to support KMS for simple fb fallbacks, but it hasn't
been merged yet.

[http://cgit.freedesktop.org/~dvdhrm/linux/log/?h=simpledrm](http://cgit.freedesktop.org/~dvdhrm/linux/log/?h=simpledrm)

However, I definitely wouldn't throw out KMS just to support VESA / GOP. They
don't support page flipping, so you get lots of tearing.

With the extensions, vboxdrv supplies a KMS driver.

[https://www.virtualbox.org/svn/vbox/trunk/src/VBox/Additions...](https://www.virtualbox.org/svn/vbox/trunk/src/VBox/Additions/linux/drm/vboxvideo_drm.c)

------
nitrogen
I'd like to see a trend toward increasing use of raw framebuffers along with
the embedded mini-PCs like the RPi, CHIP, Beagle*, etc. At one point in time I
worked almost exclusively through the framebuffer console while developing a
long-abandoned library to simplify framebuffer development. There are image
viewers, PDF viewers, and web browsers that can use the raw framebuffer. I
even wrote a basic framebuffer driver for an old HDTV tuner card.

There's something very satisfying about building up one's digital reality
pixel by pixel, working with graphics as raw arrays of pixels, learning
Bresenham's line drawing algorithm, etc. I highly recommend it.

~~~
voltagex_
Hold on, was the framebuffer for the tuner used for input or output? I'm also
very interested in being able to push pixels to the screen "manually".

~~~
nitrogen
Output. The tuner was from the era when PCs and GPUs didn't have the
horsepower to decode 1080i MPEG-2, so the tuner had to have its own MPEG-2
decoder chip and display driver, with 16MB of RAM.

It supported a basic OSD (sort of like hardware sprites) and arbitrary output
resolutions, so IIRC I set up the OSD to stretch one of the OSD overlays to
the full screen size, and pointed the framebuffer driver at the section of the
card's memory assigned to that overlay. Here's an old demo:
[https://www.youtube.com/watch?v=cDWH7d8pbH0](https://www.youtube.com/watch?v=cDWH7d8pbH0)

I never finished getting video input to work, and eventually my reference card
was stolen so I never will.

Working with the framebuffer is almost as easy as calling _mmap()_ on /dev/fb0
and just writing data. There are _ioctl_ s for switching resolutions on
drivers that supported it. But it sounds like DRM/KMS is the way to go these
days if you aren't running a proprietary GPU driver.

------
voltagex_
Part 1 is at [http://orangejuiceliberationfront.com/raw-graphics-output-
on...](http://orangejuiceliberationfront.com/raw-graphics-output-on-linux-
part-1/) but mostly covers setting up a VM.

