간단하게 작성해 보았습니다.
320x240 16bpp를 target으로 했는데, 제 동작할지는 의문이네요......ㅎㅎ
실제로 잘 동작하던 소스에서 발췌만 한 겁니다. 혹 컴파일 안되더라도 몇가지만 수정하시면 될겁니다.
raw format으로 capture가 되니, display쪽은 따로 작성해 주셔야 할겁니다.
s3c24x0 자료실의 logodisp 라는 프로그램이 아마도 있을텐데, 그거 참조하시면 도움이 될겁니다.
그럼....
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <stdio.h>
#include <sys/mman.h>
#include <errno.h>
#include <math.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/videodev.h>
#if 1
#define gprintf(fmt, x... ) printf( "%s: " fmt, __FUNCTION__ , ## x)
#else
#define gprintf(x...) do { } while (0)
#endif
#define VID_WIDTH 320 /* Default Width */
#define VID_HEIGHT 240 /* Default Height */
#define FB_DEV0 "/dev/fb0" /* Device Name */
//#define FB_DEV2 "/dev/fb2" /* Device Name */
char fb_device[] = FB_DEV0;
int main (int argc, char *argv[])
{
int fd_fb;
struct fb_var_screeninfo fbvar;
struct fb_fix_screeninfo fbfix;
char *frame_buffer;
int y, format;
int captured = 0;
fd_fb = open(fb_device, O_RDWR);
if (fd_fb < 0)
{
perror("fbdev open");
return 0;
}
memset(&fbvar, 0, sizeof(fbvar));
memset(&fbfix, 0, sizeof(fbfix));
ioctl(fd_fb, FBIOGET_VSCREENINFO, &fbvar);
ioctl(fd_fb, FBIOGET_FSCREENINFO, &fbfix);
frame_buffer = (char *) mmap(0, fbfix.smem_len, PROT_READ | PROT_WRITE,MAP_SHARED, fd_fb, 0);
{
unsigned char r, g, b;
unsigned short *ghc, data;
FILE *out;
int i, j;
out = fopen("./320x240_16bpp.raw", "wb");
if( out == NULL )
{
printf("fopen errorn");
exit(1);
}
fwrite(frame_buffer, 320*240*2, 1, out);
fclose(out);
}
return 0;
}