User Tools

Site Tools


framebuffer

This is an old revision of the document!


Framebuffer

Graphics can be rendered using the linux framebuffer device, /dev/fb0. By default the framebuffer is 800×480 with a B8G8R8A8 pixel order.

The framebuffer driver implements some special ioctls, its source is available here. Some notable ones:

  • MXCFB_WAIT_FOR_VSYNC (_IOW('F', 0x20, u_int32_t)) blocks until vblank. The argument is ignored.
  • MXCFB_SET_GPU_SPLIT_FMT (_IOW('F', 0x2F, struct mxcfb_gpu_split_fmt)) seems to be used to setup triple-buffering (but how to use it properly?)

Video output

People have made simple animations by exporting raw BGRA images and writing them to the framebuffer device. You can do this in ffmpeg for example:

ffmpeg -i .\input.mp4 -map 0:v -vf "scale=800:-1,crop=800:480:0:(in_h-480)/2" -c:v rawvideo -pix_fmt bgra -f image2 frame_%06d.raw   

Beware that these files get very large, to the point that reading them out can max out USB bandwidth. And then on the pm3, the animation can be played back with a fairly simple:

for file in *.raw; do cat $file > /dev/fb0; usleep 30000; done

Alternatively, you can get a statically compiled ffmpeg binary and use that.

# video only
/init/efad/mp_sd/ffmpeg -re -i file.mp4 -map 0:v -c:v rawvideo -pix_fmt bgra -f fbdev /dev/fb0
# video + audio (janky)
/init/efad/mp_sd/ffmpeg -re -i file.mp4 -map 0:v -c:v rawvideo -pix_fmt bgra -f fbdev /dev/fb0 -map 0:a -ac 1 -c:a pcm_s16le -f s16le - | aplay -c 1 -f S16_LE -r 44100 -

This assumes your input video is already cropped to exactly 800×480. The audio example is also set to use a single channel.

framebuffer.1795304753.txt.gz · Last modified: by jazzy