drm_public int drmModeAddFB2(int fd, uint32_t width, uint32_t height, uint32_t pixel_format, const uint32_t bo_handles[4], const uint32_t pitches[4], const uint32_t offsets[4], uint32_t *buf_id, uint32_t flags) { return drmModeAddFB2WithModifiers(fd, width, height, pixel_format, bo_handles, pitches, offsets, NULL, buf_id, flags); }
void CRendererDRMPRIME::SetVideoPlane(CVideoBufferDRMPRIME* buffer) { buffer->m_drm_fd = m_DRM->GetFileDescriptor(); AVDRMFrameDescriptor* descriptor = buffer->GetDescriptor(); if (descriptor && descriptor->nb_layers) { uint32_t handles[4] = {0}, pitches[4] = {0}, offsets[4] = {0}; uint64_t modifier[4] = {0}; int ret; // convert Prime FD to GEM handle for (int object = 0; object < descriptor->nb_objects; object++) { ret = drmPrimeFDToHandle(m_DRM->GetFileDescriptor(), descriptor->objects[object].fd, &buffer->m_handles[object]); if (ret < 0) { CLog::Log(LOGERROR, "CRendererDRMPRIME::%s - failed to retrieve the GEM handle from prime fd %d, ret = %d", __FUNCTION__, descriptor->objects[object].fd, ret); return; } } AVDRMLayerDescriptor* layer = &descriptor->layers[0]; for (int plane = 0; plane < layer->nb_planes; plane++) { int object = layer->planes[plane].object_index; uint32_t handle = buffer->m_handles[object]; if (handle && layer->planes[plane].pitch) { handles[plane] = handle; pitches[plane] = layer->planes[plane].pitch; offsets[plane] = layer->planes[plane].offset; modifier[plane] = descriptor->objects[object].format_modifier; } } // add the video frame FB ret = drmModeAddFB2WithModifiers(m_DRM->GetFileDescriptor(), buffer->GetWidth(), buffer->GetHeight(), layer->format, handles, pitches, offsets, modifier, &buffer->m_fb_id, 0); if (ret < 0) { CLog::Log(LOGERROR, "CRendererDRMPRIME::%s - failed to add drm layer %d, ret = %d", __FUNCTION__, buffer->m_fb_id, ret); return; } int32_t crtc_x = static_cast<int32_t>(m_destRect.x1) & ~1; int32_t crtc_y = static_cast<int32_t>(m_destRect.y1) & ~1; uint32_t crtc_w = (static_cast<uint32_t>(m_destRect.Width()) + 1) & ~1; uint32_t crtc_h = (static_cast<uint32_t>(m_destRect.Height()) + 1) & ~1; uint32_t src_x = 0; uint32_t src_y = 0; uint32_t src_w = buffer->GetWidth() << 16; uint32_t src_h = buffer->GetHeight() << 16; m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "FB_ID", buffer->m_fb_id); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "CRTC_ID", m_DRM->GetCrtc()->crtc->crtc_id); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "SRC_X", src_x); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "SRC_Y", src_y); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "SRC_W", src_w); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "SRC_H", src_h); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "CRTC_X", crtc_x); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "CRTC_Y", crtc_y); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "CRTC_W", crtc_w); m_DRM->AddProperty(m_DRM->GetPrimaryPlane(), "CRTC_H", crtc_h); } }