Handy PS3 Linux Framebuffer Utilities

While the documentation within Sony's vsync example should be enough to get you started with writing to the framebuffer, here's a couple of handy functions to test the framebuffer settings, open the virtual terminal and get access the the frame buffer.
Open the virtual terminal:
cp_vt.h
cp_vt.c

Open the framebuffer:
cp_fb.h
cp_fb.c

Dump framebuffer info:
fb_info.c

Files should be compiled with:
ppu-gcc -std=c99 -pedantic -W -Wall -O3
fb_info
fb_info dumps the current settings for the framebuffer setup on the PS3.

For example - for 480i the output should look something like this:
FBIOGET_VBLANK:
flags:
FB_VBLANK_VBLANKING : FALSE
FB_VBLANK_HBLANKING : FALSE
FB_VBLANK_HAVE_VBLANK : FALSE
FB_VBLANK_HAVE_HBLANK : FALSE
FB_VBLANK_HAVE_COUNT : FALSE
FB_VBLANK_HAVE_VCOUNT : FALSE
FB_VBLANK_HAVE_HCOUNT : FALSE
FB_VBLANK_VSYNCING : FALSE
FB_VBLANK_HAVE_VSYNC : TRUE
count : 0
vcount : 1
hcount : 0
-------------------------------------
FBIOGET_FSCREENINFO:
id : "PS3 FB"
smem_start : 0x00000000
smem_len : 18874368
type : FB_TYPE_PACKED_PIXELS (0)
type_aux : N/A
visual : FB_VISUAL_TRUECOLOR (2)
xpanstep : 1
ypanstep : 1
ywrapstep : 1
line_length : 2880
mmio_start : 0x00000000
mmio_len : 0
accel : FB_ACCEL_NONE (0)
-------------------------------------
PS3FB_IOCTL_SCREENINFO:
xres : 720
yres : 480
xoff : 72
yoff : 48
num_frames : 2
-------------------------------------
Using cp_vt and cp_fb
These functions are very simple to use. The user running them should have read/write access to the framebufer (/dev/fb0) and the main console (/dev/console).
{
cp_vt vt;
cp_fb fb;

cp_vt_open_graphics(&vt);
cp_fb_open(&fb);

uint32_t frame_ndx = 0;

while (1)
{
uint32_t* const restrict frame_top = (uint32_t*)fb.draw_addr[ frame_ndx ];

// Write pixel to the frame buffer ...
// x and y are image position
// rgb24 is 32bit pixel value (where top 8 bits are unused)

frame_top[ ( y * fb.stride ) + x ] = rgb24;

// At the vsync, the previous frame is finished sending to the CRT
cp_fb_wait_vsync( &fb );

// Send the frame just drawn to the CRT by the next vblank
cp_fb_flip( &fb, frame_ndx );

frame_ndx = frame_ndx ^ 0x01;
}

cp_vt_close(&vt);
cp_fb_close(&fb);
}
A more complete example: fb_test.c