Toybrick

DRM RGA 方式做图形转换,mmap 报非法参数 22, 请指教。

qinchun2000

新手上路

积分
23
发表于 2021-12-22 23:43:06    查看: 1287|回复: 0 | [复制链接]    打印 | 显示全部楼层

复制代码
  1. int main(int argc, char **argv)
  2. {
  3.     std::cout << "     ------->1" << std::endl;
  4.     int fd;
  5.     drmModeConnector *conn;
  6.     drmModeRes *res;
  7.     uint32_t conn_id;
  8.     uint32_t crtc_id;

  9.     fd = open("/dev/dri/card0", O_RDWR | O_CLOEXEC);
  10.     std::cout << "     ------->2" << std::endl;
复制代码


  1. struct drm_mode_create_dumb create = {};
  2. struct drm_mode_map_dumb map = {};

  3. /* create a dumb-buffer, the pixel format is XRGB888 */
  4. create.width = bo->width;
  5. create.height = bo->height;
  6. create.bpp = 32;
  7. drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
  8. std::cout << " ------->b" << std::endl;

  9. /* bind the dumb-buffer to an FB object */
  10. bo->pitch = create.pitch;
  11. bo->size = create.size;
  12. bo->handle = create.handle;
  13. drmModeAddFB(fd, bo->width, bo->height, 24, 32, bo->pitch,
  14. bo->handle, &bo->fb_id);

  15. std::cout << " ------->a" << std::endl;
  16. /* map the dumb-buffer to userspace */
  17. map.handle = create.handle;
  18. drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &map);

  19. std::cout << " ------->size..." << create.size <<std::endl;

  20. bo->vaddr = (unsigned char* )mmap(0, create.size, PROT_READ | PROT_WRITE,
  21. MAP_PRIVATE, fd, map.offset);

  22. if(bo->vaddr == MAP_FAILED) {
  23. std::cout << " ------->c fail..." << errno <<std::endl;
  24. }

  25. std::cout << " ------->c" << std::endl;

复制代码




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表