ARM보드 - 프레임버퍼(FrameBuffer)
프로그래밍/Embedded System 2009. 3. 23. 15:29 |
framebuffer.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <sys/mman.h>
int fd;
struct fb_var_screeninfo fbvar;
int width;
int height;
int bpp;
int byte_total;
unsigned short *vbase;
int main( void ) {
if(access( "/dev/fb0",F_OK)) {
printf("error");
}
fd = open("/dev/fb0", O_RDWR);
if(fd < 0 ) { printf("error"); }
if( ioctl( fd, FBIOGET_VSCREENINFO, &fbvar ) < 0 ) { printf("error"); }
width = fbvar.xres;
height = fbvar.yres;
bpp = fbvar.bits_per_pixel;
byte_total = width*height*(bpp/8);
//IOCTL을 통해 읽어온값 확인하기
vbase = (unsigned short * ) mmap(0, byte_total, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0 );
//주소값 찍어보기
printf("wdith : %d height : %d bpp : %d byte_total : %d\n", width, height, bpp, byte_total);
printf("vbase : 0x%x\n", vbase);
}
컴파일
arm-linux-gcc framebuffer.c
ARM보드 상에서 실행
# rx a.out
# chmod 777 a.out
# ./a.out