Created
January 30, 2013 18:55
-
-
Save ssvb/4675708 to your computer and use it in GitHub Desktop.
VSYNC test for Allwinner A10 display controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <stdio.h> | |
#include <fcntl.h> | |
#include <sys/mman.h> | |
#include <assert.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <sys/ioctl.h> | |
#include <linux/fb.h> | |
/* fill left half of the framebuffer with white, and right with black */ | |
void fill_framebuffer(char *buf, int pitch, int height, int bw_split_pos) | |
{ | |
while (height--) { | |
memset(buf, 0xFF, bw_split_pos); | |
memset(buf + bw_split_pos, 0x00, pitch - bw_split_pos); | |
buf += pitch; | |
} | |
} | |
int main(int argc, char *argv[]) | |
{ | |
struct fb_fix_screeninfo finfo; | |
char *buf = 0; | |
int fd, pos = 0; | |
if ((fd = open("/dev/fb0", O_RDWR)) < 0) { | |
printf("can't open /dev/fb0"); | |
return 1; | |
} | |
ioctl(fd, FBIOGET_FSCREENINFO, &finfo); | |
buf = mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); | |
while (1) { | |
pos = (pos + 128) % (finfo.line_length * 2); | |
ioctl(fd, FBIO_WAITFORVSYNC, 0); | |
fill_framebuffer(buf, finfo.line_length, | |
finfo.smem_len / finfo.line_length, | |
pos < finfo.line_length ? | |
pos : 2 * finfo.line_length - pos); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment