2
ioctl을 사용하여 프레임 버퍼에 쓰기가 잘되고 있습니다.frambuffer가 끝나면 어떻게 콘솔 테스트를 복원합니까?
그러나 이미지를 닫으면 이미지가 화면에 나타납니다. 내가 버퍼에 쓴 전에 어떻게 콘솔 텍스트를 복원하고 싶습니다. 누구든지이 작업을 수행하는 방법을 알고 있습니까? 아래 코드는 내가 사용하고있는 코드입니다.
struct fb_var_screeninfo vinfo;
fbfd = open("/dev/fb0", O_RDWR);
if (!fbfd) {
printf("Error: cannot open framebuffer device.\n");
return(1);
}
// Get variable screen information
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
printf("Error reading variable information.\n");
}
printf("Original %dx%d, %dbpp\n", vinfo.xres, vinfo.yres,
vinfo.bits_per_pixel);
// map fb to user mem
screensize = finfo.smem_len;
fbp = (char*)mmap(0,
screensize,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fbfd,
0);
if ((int)fbp == -1) {
printf("Failed to mmap.\n");
}
else {
// draw...some lines
int x, y;
unsigned int pix_offset;
for (y = 0; y < (vinfo.yres/2); y++) {
for (x = 0; x < vinfo.xres; x++) {
// calculate the pixel's byte offset inside the buffer
// see the image above in the blog...
pix_offset = x + y * finfo.line_length;
// now this is about the same as fbp[pix_offset] = value
*((char*)(fbp + pix_offset)) = 16 * x/vinfo.xres;
}
}
sleep(5);
}
// cleanup
munmap(fbp, screensize);
if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_vinfo)) {
printf("Error re-setting variable information.\n");
}
close(fbfd);
return 0;
}