复制代码
- int main(int argc, char **argv)
- {
- std::cout << " ------->1" << std::endl;
- int fd;
- drmModeConnector *conn;
- drmModeRes *res;
- uint32_t conn_id;
- uint32_t crtc_id;
- fd = open("/dev/dri/card0", O_RDWR | O_CLOEXEC);
- std::cout << " ------->2" << std::endl;
复制代码
- struct drm_mode_create_dumb create = {};
- struct drm_mode_map_dumb map = {};
- /* create a dumb-buffer, the pixel format is XRGB888 */
- create.width = bo->width;
- create.height = bo->height;
- create.bpp = 32;
- drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
- std::cout << " ------->b" << std::endl;
- /* bind the dumb-buffer to an FB object */
- bo->pitch = create.pitch;
- bo->size = create.size;
- bo->handle = create.handle;
- drmModeAddFB(fd, bo->width, bo->height, 24, 32, bo->pitch,
- bo->handle, &bo->fb_id);
- std::cout << " ------->a" << std::endl;
- /* map the dumb-buffer to userspace */
- map.handle = create.handle;
- drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &map);
- std::cout << " ------->size..." << create.size <<std::endl;
- bo->vaddr = (unsigned char* )mmap(0, create.size, PROT_READ | PROT_WRITE,
- MAP_PRIVATE, fd, map.offset);
- if(bo->vaddr == MAP_FAILED) {
- std::cout << " ------->c fail..." << errno <<std::endl;
- }
- std::cout << " ------->c" << std::endl;
复制代码
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |