直接访问linux framebuffer – copyarea

前端之家收集整理的这篇文章主要介绍了直接访问linux framebuffer – copyarea前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在嵌入式 Linux应用程序中快速移动一个矩形到帧缓冲区.我发现cfb_copyarea函数可能很有用.但我无法在/ dev / fb设备上找到任何ioctl来调用函数.或者可以直接调用函数吗?

解决方法

这是一个初始化和关闭FrameBuffer的代码
  1. class CFrameBuffer
  2. {
  3.  
  4. void* m_FrameBuffer;
  5. struct fb_fix_screeninfo m_FixInfo;
  6. struct fb_var_screeninfo m_VarInfo;
  7. int m_FBFD;
  8.  
  9. int InitFB()
  10. {
  11. int iFrameBufferSize;
  12. /* Open the framebuffer device in read write */
  13. m_FBFD = open(FB_NAME,O_RDWR);
  14. if (m_FBFD < 0) {
  15. printf("Unable to open %s.\n",FB_NAME);
  16. return 1;
  17. }
  18. /* Do Ioctl. Retrieve fixed screen info. */
  19. if (ioctl(m_FBFD,FBIOGET_FSCREENINFO,&m_FixInfo) < 0) {
  20. printf("get fixed screen info Failed: %s\n",strerror(errno));
  21. close(m_FBFD);
  22. return 1;
  23. }
  24. /* Do Ioctl. Get the variable screen info. */
  25. if (ioctl(m_FBFD,FBIOGET_VSCREENINFO,&m_VarInfo) < 0) {
  26. printf("Unable to retrieve variable screen info: %s\n",strerror(errno));
  27. close(m_FBFD);
  28. return 1;
  29. }
  30.  
  31. /* Calculate the size to mmap */
  32. iFrameBufferSize = m_FixInfo.line_length * m_VarInfo.yres;
  33. printf("Line length %d\n",m_FixInfo.line_length);
  34. /* Now mmap the framebuffer. */
  35. m_FrameBuffer = mmap(NULL,iFrameBufferSize,PROT_READ | PROT_WRITE,MAP_SHARED,m_FBFD,0);
  36. if (m_FrameBuffer == NULL) {
  37. printf("mmap Failed:\n");
  38. close(m_FBFD);
  39. return 1;
  40. }
  41. return 0;
  42. }
  43.  
  44. void CloseFB()
  45. {
  46. munmap(m_FrameBuffer,0);
  47. close(m_FBFD);
  48. }
  49.  
  50. };

猜你在找的Linux相关文章