Skip to content

v4l2导出的dmabuf可以导入mpp缓存池吗 #767

Open
@cht851

Description

我把v4l2 expbuf得到的dmabuf导入的缓存池报错:
mpp[3436]: mpp_log: allocator_ext_dma_import The ext_dma is not used for userptr
mpp[3436]: mpp_buffer: mpp_buffer_create failed to create buffer with size 3133440
是我的代码有问题吗?
image
BufInfo保存了v4l2导出dmabuf的信息

Activity

cht851

cht851 commented on Jan 20, 2025

@cht851
Author

要把外部缓冲区导入mpp缓存池,外部缓冲区只能是drm申请的buffer吗

HermanChen

HermanChen commented on Jan 20, 2025

@HermanChen
Collaborator

看 camera_source.c 里的例子,要加加一个 export fd 的过程

cht851

cht851 commented on Jan 20, 2025

@cht851
Author

看 camera_source.c 里的例子,要加加一个 export fd 的过程

我加了也报错
mpp[3436]: mpp_log: allocator_ext_dma_import The ext_dma is not used for userptr
mpp[3436]: mpp_buffer: mpp_buffer_create failed to create buffer with size 3133440
是为什么呢?导出fd代码如下:
` struct v4l2_buffer buf;
struct v4l2_plane planes;
memset(&buf, 0, sizeof(struct v4l2_buffer));
memset(&planes, 0, sizeof(struct v4l2_plane));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
buf.memory = V4L2_MEMORY_MMAP;
buf.m.planes = &planes;
buf.length = 1;
struct v4l2_exportbuffer expbuf;
memset(&expbuf, 0, sizeof(expbuf));
expbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;

for(int i = 0; i < VI_BUFF_NUM; i++){
    expbuf.index = i;
    ret = ioctl(fd, VIDIOC_EXPBUF, &expbuf);
    if(ret < 0)
    {
        perror("export buf error\n");
        return -1;
    }
    bufferInfo[i].fd = expbuf.fd;
    bufferInfo[i].index = i;
    // 查询缓冲区长度
    buf.index = i;
    ret = ioctl(fd, VIDIOC_QUERYBUF, &buf);
    if(ret < 0)
    {
        perror("query buffer length error\n");
        return -1;
    }
    bufferInfo[i].length = buf.m.planes[0].length;
    // 将内核内存映射到用户空间
    bufferInfo[i].addr = (uint8_t*)mmap(NULL, buf.m.planes[0].length, PROT_READ | PROT_WRITE, MAP_SHARED, 
                                fd, buf.m.planes[0].m.mem_offset);
    if(!bufferInfo[i].addr)
    {
        perror("mmap buffers error\n");
        return -1;
    }
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      v4l2导出的dmabuf可以导入mpp缓存池吗 · Issue #767 · rockchip-linux/mpp