轉載 註明 ;http://blog.csdn.net/u011046042/article/details/68066091
最簡單的代碼如下:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <errno.h>
static char *fbp = 0;
int fbfd = 0;
int main()
{
int i;
fbfd = open("/dev/fb0", O_RDWR);
fbp = (char *)mmap(0, 1920*1080*4, PROT_READ|PROT_WRITE, MAP_SHARED, fbfd, 0);
if (fbp == NULL)
{
printf("Error: failed to map framebuffer device to memory.\n");
return -1;
}
int *add;
add = (int *)fbp;
for(i=0; i< 1080*1920; i++)
{
*add = 0x000000ff;
add++;
}
munmap((void *)fbp,1920*1080*4);
return 0;
}
gcc fb.c -o fb 就好了。
直接執行就可以看到對應的顏色了 。
這個demo後面可以做一些驅動的驗證。
轉載 註明 ;http://blog.csdn.net/u011046042/article/details/68066091
---------------------
作者:道亦無名
來源:CSDN
原文:https://blog.csdn.net/u011046042/article/details/68066091
版權聲明:本文爲博主原創文章,轉載請附上博文鏈接!