std::array< std::uint32_t, 4u > pitches{ creq.pitch, 0u, 0u, 0u }; std::array< std::uint32_t, 4u > offsets{ 0u, 0u, 0u, 0u }; if( drmModeAddFB2( fd, width, height, format, handles.data(), pitches.data(), offsets.data(), &fb, 0u ) ) { ... } for ( int i = 0; i < res->count_connectors; ++i ) { drmModeConnectorPtr candidate = drmModeGetConnectorCurrent( fd, res->connectors[ i ] ); if( !candidate ) continue; for( int j = 0; j < candidate->count_modes; ++j ) { if( candidate->modes[ j ].hdisplay == creq.width && candidate->modes[ j ].vdisplay == creq.height ) { connector = candidate; mode_index = j; i = res->count_connectors; j = candidate->count_modes; } } if( i != res->count_connectors ) drmModeFreeConnector( candidate ); } if( connector == nullptr ) { ... } encoder = drmModeGetEncoder( fd, connector->encoder_id ); if ( encoder == nullptr ) { ... } crtc = drmModeGetCrtc( fd, encoder->crtc_id ); if ( crtc == nullptr ) { ... } mreq.handle = creq.handle; if( drmIoctl( fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq ) ) { ... } pixels = mmap( 0, creq.size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, mreq.offset ); if( pixels == MAP_FAILED ) { ... } drmSetMaster( fd ); drmModeSetCrtc( fd, crtc->crtc_id, 0, 0, 0, nullptr, 0, nullptr ); drmModeSetCrtc( fd, crtc->crtc_id, fb, 0, 0, &connector->connector_id, 1, &connector->modes[ mode_index ] ); ͜ͷmmap͞ΕͨྖҬʹ ॻ͍ͨ༰͕ը໘ʹૹΒΕΔ dumb-bufferΛ࡞Δ