直接访问linux framebuffer – copyarea

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

解决方法

这是一个初始化和关闭FrameBuffer的代码
class CFrameBuffer
{

void*   m_FrameBuffer;
struct  fb_fix_screeninfo m_FixInfo;
struct  fb_var_screeninfo m_VarInfo;
int     m_FBFD;

int InitFB()
{
    int iFrameBufferSize;
    /* Open the framebuffer device in read write */
    m_FBFD = open(FB_NAME,O_RDWR);
    if (m_FBFD < 0) {
        printf("Unable to open %s.\n",FB_NAME);
        return 1;
    }
    /* Do Ioctl. Retrieve fixed screen info. */
    if (ioctl(m_FBFD,FBIOGET_FSCREENINFO,&m_FixInfo) < 0) {
        printf("get fixed screen info Failed: %s\n",strerror(errno));
        close(m_FBFD);
        return 1;
    }
    /* Do Ioctl. Get the variable screen info. */
    if (ioctl(m_FBFD,FBIOGET_VSCREENINFO,&m_VarInfo) < 0) {
        printf("Unable to retrieve variable screen info: %s\n",strerror(errno));
        close(m_FBFD);
        return 1;
    }

    /* Calculate the size to mmap */
    iFrameBufferSize = m_FixInfo.line_length * m_VarInfo.yres;
    printf("Line length %d\n",m_FixInfo.line_length);
    /* Now mmap the framebuffer. */
    m_FrameBuffer = mmap(NULL,iFrameBufferSize,PROT_READ | PROT_WRITE,MAP_SHARED,m_FBFD,0);
    if (m_FrameBuffer == NULL) {
        printf("mmap Failed:\n");
        close(m_FBFD);
        return 1;
    }
    return 0;
}

void CloseFB()
{
    munmap(m_FrameBuffer,0);
    close(m_FBFD);
}

};
原文链接:https://www.f2er.com/linux/393062.html

猜你在找的Linux相关文章