User Tools

Site Tools


framebuffer

Framebuffer

Graphics go to /dev/fb0, an 800×480 32-bit framebuffer with a 3200-byte stride and B, G, R, X byte order. It is the background plane of the display controller:

device name mode virtual stride
/dev/fb0 DISP3 BG 800x480p-57 800×480 3200
/dev/fb1 DISP3 FG 240x320p-57 240×960 960

/dev/fb1 is the foreground plane of the same controller, above fb0. sysfs reports 2-layer-fb-bg for fb0 and 2-layer-fb-fg for fb1. Its 240×960 virtual size is three 320-line pages. nx does not open it. video16 and video17 are registered by mxc_v4l2_output; they are V4L2 output nodes, not extra framebuffers.

There is no touchscreen. /dev/input does not exist, no touch driver loads, and nx opens only fb0, ttymxc2, ttymxc3, and ttyUSB0. Input is NFC taps, barcode scans, and the power button.

Driver

The framebuffer driver is mxc_sdc_fb, registered against a parallel RGB LCD. The device tree node is fb@0 with disp_dev = "lcd", interface_pix_fmt = "RGB24", mode_str = "CLAA-WVGA", and default_bpp = 32. The panel link is 24-bit RGB, so the fourth byte in memory is padding. Source: mxc_ipuv3_fb.c (the unit runs 4.9; this is the current NXP tree, and the ioctl interface is the same).

The kernel command line sets imx-fbdev.legacyfb_depth=32, matching the DTB's default_bpp of 32.

Two private ioctls are worth knowing:

  • 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)) looks like a triple-buffer layout switch. There is no usable documentation for it.

Backlight

There is no /sys/class/backlight entry and no pwm-backlight node. The PIC32 owns the backlight. It reads the ambient sensor and maps the reading onto a min/max range:

key meaning
0x500b ambient light, 0..10000
0x4030 brightness at ambient 0
0x4031 brightness at ambient 10000

LCD brightness is 0..10000. A max above 10000 reaches full brightness before the ambient reading hits 10000. Equal values hold a fixed brightness. Max above min follows the light. Writes take effect immediately.

Power-on values are 200/12000. nx sets 100/15000 at startup via BackLightStartup() in /init/efad/pgm/opscript.nxs, overwriting manual values. The script's presets are off 0/0, low 100/100, half 2000/2000, full 10000/10000, auto half 100/5000, and auto full 200/20000.

Write max first, then min:

stty -F /dev/ttymxc2 115200 cs8 -cstopb -parenb raw -echo

# fixed half
printf '\274\001\000\004\000\004\110\100\061\023\210' > /dev/ttymxc2
printf '\274\001\000\004\000\004\110\100\060\023\210' > /dev/ttymxc2

# back to auto
printf '\274\001\000\004\000\004\110\100\061\072\230' > /dev/ttymxc2
printf '\274\001\000\004\000\004\110\100\060\000\144' > /dev/ttymxc2

Each frame is a PIC32 ValueWrite: message type 0x04, payload key then value, both big-endian. See pic32 for the frame layout.

Read the values and the sensor with ValueRead, type 0x02:

exec 3<>/dev/ttymxc2
printf '\274\001\000\002\000\002\104\120\013' >&3
timeout -t 1 dd if=/dev/ttymxc2 bs=1 count=10 2>/dev/null | hexdump -C

The reply is BC seq 01 03 00 04 crc 50 0b <value>. Indoor light reads about 35; a flashlight pointed at the sensor reaches about 3300.

Blanking

The kernel command line includes consoleblank=0, so the console never blanks on its own. To clear the screen, write zeros and stop the fbcon cursor from repainting:

echo 0 > /sys/class/graphics/fbcon/cursor_blink
dd if=/dev/zero of=/dev/fb0 bs=3200 count=480

Those two commands are the whole blanking operation. The cursor setting matters: with the cursor blinking, it draws itself back onto the black frame.

If nx is running, it owns the same buffer and will draw over the black frame on its next update. Stop it first.

Capturing the screen

ssh root@<unit-ip> 'cat /dev/fb0' > fb.raw

Read fb.raw as 800×480, stride 3200, byte order B, G, R, X. One frame is 1,536,000 bytes.

Video output

Animations work by writing raw BGRA frames to the framebuffer. Export them with ffmpeg:

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

The crop centres a taller input and throws away the rest. Raw frames are 1.5 MB each, so a minute at 30 fps is well over 2 GB. Short clips are the practical limit.

Play them on the unit:

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

A static armhf ffmpeg can play the video directly, no frame dump:

/init/efad/mp_sd/ffmpeg -re -i file.mp4 -map 0:v -c:v rawvideo -pix_fmt bgra \
  -f fbdev /dev/fb0

A prebuilt 6.1 armhf build is at ffbinaries.

Video plus audio needs the input already cropped to 800×480 and ALSA up. The speaker amp has to be enabled first; see alsa.

/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 -

The audio side is mono 44.1 kHz. Drop -re to write frames as fast as the CPU decodes them. MXCFB_WAIT_FOR_VSYNC is the only sync primitive the driver offers.

framebuffer.txt · Last modified: by qkb