.arm
.title openpandora vsync
.globl _start
.include "macro.mac"
.text
with_vsync = 1 @ the option to use vsync or not
vsync_ioctl_cmd = ioc_write | (4<<16) | ('F'<<8) | 0X20
screensize=480*800*2*2 @ double buffer
fbio_getvscreeninfo = 0x4600
fbio_putvscreeninfo = 0x4601
fbio_pandisplay = 0x4606
_start:
bl fbinit
cmp r0,#0
bne fbokay
print "fb was not initialized\n"
exit 255
fbokay:
@ plot two pixels pixel on the center of 2nd screen
ldr r1,=800*2*720+400*2
mvn r2,#0
@ r0 points to the doubled frame buffer
str r2,[r0,r1]
@ scroll loop
mov r8,#480 @ from virtual line 480, it's the 1st line of the 2nd screen
ldr r6,=fbfd
scroll_loop:
.if with_vsync
ldr r1,=vsync_ioctl_cmd
ldr r2,=vsync_data @ ED mentioned earlier that the OP vsync routine needs a zero as the 1st parameter
ldr r0,[r6] @ get fbfd
invoke sys_ioctl
.endif
@ update yoffset
str r8,[r6,#yoffset-fbfd]
ldr r1,=fbio_pandisplay
add r2,r6,#fb_vscreeninfo-fbfd @ get address of the fb virtual screen info structure
ldr r0,[r6] @ fbfd
invoke sys_ioctl
subs r8,#1
bpl scroll_loop
bl fbclose
exit 0
fbinit:
push {r1-r5,lr}
open "/dev/fb0", o_rdwr
subs r4,r0,#0
clr r0
bmi fbinitret
mov r1,#fbio_getvscreeninfo
ldr r2,=fb_vscreeninfo
mov r0,r4 @ fbfd
invoke sys_ioctl
@ double buffer init
ldr r3,[r2,#yres-fb_vscreeninfo]
inc r1 @ fbio_putvscreeninfo
add r3,r3,r3
mov r0,r4 @ fbfd
str r3,[r2,#yres_virtual-fb_vscreeninfo]
invoke sys_ioctl
@ r4=fbfd
@ r0 if 0 after a successful ioctl call. I assume everything was okay
ldr r1,=screensize
mov r2,#prot_read | prot_write
mov r3,#map_shared
mov r5,r0
invoke sys_mmap2
ldr r1,=fbp
cmp r0,#0
beq fbinitret
str r0,[r1] @store fbp
str r4,[r1,#4] @store fbfd
fbinitret:
@ if r0 eq 0 then some error happened
pop {r1-r5,pc}
fbclose:
push {r1,r2,lr}
ldr r2,=fbp
ldr r0,[r2]
ldr r1,=screensize
invoke sys_munmap
ldr r0,[r2,#4]
invoke sys_close
pop {r1,r2,pc}
.data
vsync_data: .word 0
.bss
fbp: .word 0
fbfd: .word 0
@ the fb vscreeninfo structure. copied from fb,inc
fb_vscreeninfo:
xres: .word 0
yres: .word 0
xres_virtual: .word 0
yres_virtual: .word 0
xoffset: .word 0
yoffset: .word 0
bpp: .word 0
grayscale: .word 0
@ fb_bitfield struc
@ offset: .word 0
@ length: .word 0
@ msb_right: .word 0
@ ends
bitfield_red: .word 0,0,0
bitfield_green: .word 0,0,0
bitfield_blue: .word 0,0,0
bitfield_transp:.word 0,0,0
nonstd: .word 0
activate: .word 0
height: .word 0
width: .word 0
accel_flags: .word 0
pixclock: .word 0
left_margin: .word 0
right_margin: .word 0
upper_margin: .word 0
lower_margin: .word 0
hsync_len: .word 0
vsync_len: .word 0
sync: .word 0
vmode: .word 0
rotate: .word 0
colorspace: .word 0
.fill 4,4,0 @reserved
.end