From 389f727744245c0d0943fe78957c6cfbc536265e Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 29 Feb 2024 19:16:53 +1100 Subject: [PATCH 1/2] Remove unused finish_drm --- src/drm.cpp | 119 ---------------------------------------------------- 1 file changed, 119 deletions(-) diff --git a/src/drm.cpp b/src/drm.cpp index 9420ccbe4b..9fa7fc41ea 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -1237,125 +1237,6 @@ bool init_drm(struct drm_t *drm, int width, int height, int refresh) return true; } -void finish_drm(struct drm_t *drm) -{ - // Disable all connectors, CRTCs and planes. This is necessary to leave a - // clean KMS state behind. Some other KMS clients might not support all of - // the properties we use, e.g. "rotation" and Xorg don't play well - // together. - - drmModeAtomicReq *req = drmModeAtomicAlloc(); - - for ( auto &iter : drm->connectors ) - { - gamescope::CDRMConnector *pConnector = &iter.second; - - pConnector->GetProperties().CRTC_ID->SetPendingValue( req, 0, true ); - - if ( pConnector->GetProperties().Colorspace ) - pConnector->GetProperties().Colorspace->SetPendingValue( req, 0, true ); - - if ( pConnector->GetProperties().HDR_OUTPUT_METADATA ) - { - if ( drm->sdr_static_metadata && pConnector->GetHDRInfo().IsHDR10() ) - pConnector->GetProperties().HDR_OUTPUT_METADATA->SetPendingValue( req, drm->sdr_static_metadata->GetBlobValue(), true ); - else - pConnector->GetProperties().HDR_OUTPUT_METADATA->SetPendingValue( req, 0, true ); - } - - if ( pConnector->GetProperties().content_type ) - pConnector->GetProperties().content_type->SetPendingValue( req, 0, true ); - } - - for ( std::unique_ptr< gamescope::CDRMCRTC > &pCRTC : drm->crtcs ) - { - pCRTC->GetProperties().ACTIVE->SetPendingValue( req, 0, true ); - pCRTC->GetProperties().MODE_ID->SetPendingValue( req, 0, true ); - - if ( pCRTC->GetProperties().GAMMA_LUT ) - pCRTC->GetProperties().GAMMA_LUT->SetPendingValue( req, 0, true ); - - if ( pCRTC->GetProperties().DEGAMMA_LUT ) - pCRTC->GetProperties().DEGAMMA_LUT->SetPendingValue( req, 0, true ); - - if ( pCRTC->GetProperties().CTM ) - pCRTC->GetProperties().CTM->SetPendingValue( req, 0, true ); - - if ( pCRTC->GetProperties().VRR_ENABLED ) - pCRTC->GetProperties().VRR_ENABLED->SetPendingValue( req, 0, true ); - - if ( pCRTC->GetProperties().OUT_FENCE_PTR ) - pCRTC->GetProperties().OUT_FENCE_PTR->SetPendingValue( req, 0, true ); - - if ( pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF ) - pCRTC->GetProperties().VALVE1_CRTC_REGAMMA_TF->SetPendingValue( req, 0, true ); - } - - for ( std::unique_ptr< gamescope::CDRMPlane > &pPlane : drm->planes ) - { - pPlane->GetProperties().FB_ID->SetPendingValue( req, 0, true ); - pPlane->GetProperties().CRTC_ID->SetPendingValue( req, 0, true ); - pPlane->GetProperties().SRC_X->SetPendingValue( req, 0, true ); - pPlane->GetProperties().SRC_Y->SetPendingValue( req, 0, true ); - pPlane->GetProperties().SRC_W->SetPendingValue( req, 0, true ); - pPlane->GetProperties().SRC_H->SetPendingValue( req, 0, true ); - pPlane->GetProperties().CRTC_X->SetPendingValue( req, 0, true ); - pPlane->GetProperties().CRTC_Y->SetPendingValue( req, 0, true ); - pPlane->GetProperties().CRTC_W->SetPendingValue( req, 0, true ); - pPlane->GetProperties().CRTC_H->SetPendingValue( req, 0, true ); - - if ( pPlane->GetProperties().rotation ) - pPlane->GetProperties().rotation->SetPendingValue( req, DRM_MODE_ROTATE_0, true ); - - if ( pPlane->GetProperties().alpha ) - pPlane->GetProperties().alpha->SetPendingValue( req, 0xFFFF, true ); - - //if ( pPlane->GetProperties().zpos ) - // pPlane->GetProperties().zpos->SetPendingValue( req, , true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_DEGAMMA_TF ) - pPlane->GetProperties().VALVE1_PLANE_DEGAMMA_TF->SetPendingValue( req, DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT, true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_DEGAMMA_LUT ) - pPlane->GetProperties().VALVE1_PLANE_DEGAMMA_LUT->SetPendingValue( req, 0, true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_CTM ) - pPlane->GetProperties().VALVE1_PLANE_CTM->SetPendingValue( req, 0, true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_HDR_MULT ) - pPlane->GetProperties().VALVE1_PLANE_HDR_MULT->SetPendingValue( req, 0x100000000ULL, true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_SHAPER_TF ) - pPlane->GetProperties().VALVE1_PLANE_SHAPER_TF->SetPendingValue( req, DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT, true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_SHAPER_LUT ) - pPlane->GetProperties().VALVE1_PLANE_SHAPER_LUT->SetPendingValue( req, 0, true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_LUT3D ) - pPlane->GetProperties().VALVE1_PLANE_LUT3D->SetPendingValue( req, 0, true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_BLEND_TF ) - pPlane->GetProperties().VALVE1_PLANE_BLEND_TF->SetPendingValue( req, DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT, true ); - - if ( pPlane->GetProperties().VALVE1_PLANE_BLEND_LUT ) - pPlane->GetProperties().VALVE1_PLANE_BLEND_LUT->SetPendingValue( req, 0, true ); - } - - // We can't do a non-blocking commit here or else risk EBUSY in case the - // previous page-flip is still in flight. - uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET; - int ret = drmModeAtomicCommit( drm->fd, req, flags, nullptr ); - if ( ret != 0 ) { - drm_log.errorf_errno( "finish_drm: drmModeAtomicCommit failed" ); - } - drmModeAtomicFree(req); - - free(drm->device_name); - - // We can't close the DRM FD here, it might still be in use by the - // page-flip handler thread. -} - uint32_t drm_fbid_from_dmabuf( struct drm_t *drm, struct wlr_buffer *buf, struct wlr_dmabuf_attributes *dma_buf ) { uint32_t fb_id = 0; From 4143167d37daaa63e291653ff78d8d50c2697224 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 29 Feb 2024 19:18:24 +1100 Subject: [PATCH 2/2] Remove unused plane properties libliftoff is now used to set plane properties, although we can't read plane properties with libliftoff --- src/drm.cpp | 49 +------------------------------------------------ 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/src/drm.cpp b/src/drm.cpp index 9fa7fc41ea..f72ced21a0 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -127,36 +127,13 @@ namespace gamescope struct PlaneProperties { - std::optional *begin() { return &FB_ID; } + std::optional *begin() { return &type; } std::optional *end() { return &DUMMY_END; } std::optional type; // Immutable std::optional IN_FORMATS; // Immutable - std::optional FB_ID; - std::optional CRTC_ID; - std::optional SRC_X; - std::optional SRC_Y; - std::optional SRC_W; - std::optional SRC_H; - std::optional CRTC_X; - std::optional CRTC_Y; - std::optional CRTC_W; - std::optional CRTC_H; - std::optional zpos; - std::optional alpha; - std::optional rotation; - std::optional COLOR_ENCODING; - std::optional COLOR_RANGE; - std::optional VALVE1_PLANE_DEGAMMA_TF; - std::optional VALVE1_PLANE_DEGAMMA_LUT; std::optional VALVE1_PLANE_CTM; - std::optional VALVE1_PLANE_HDR_MULT; - std::optional VALVE1_PLANE_SHAPER_LUT; - std::optional VALVE1_PLANE_SHAPER_TF; - std::optional VALVE1_PLANE_LUT3D; - std::optional VALVE1_PLANE_BLEND_TF; - std::optional VALVE1_PLANE_BLEND_LUT; std::optional DUMMY_END; }; PlaneProperties &GetProperties() { return m_Props; } @@ -1745,31 +1722,7 @@ namespace gamescope { m_Props.type = CDRMAtomicProperty::Instantiate( "type", this, *rawProperties ); m_Props.IN_FORMATS = CDRMAtomicProperty::Instantiate( "IN_FORMATS", this, *rawProperties ); - - m_Props.FB_ID = CDRMAtomicProperty::Instantiate( "FB_ID", this, *rawProperties ); - m_Props.CRTC_ID = CDRMAtomicProperty::Instantiate( "CRTC_ID", this, *rawProperties ); - m_Props.SRC_X = CDRMAtomicProperty::Instantiate( "SRC_X", this, *rawProperties ); - m_Props.SRC_Y = CDRMAtomicProperty::Instantiate( "SRC_Y", this, *rawProperties ); - m_Props.SRC_W = CDRMAtomicProperty::Instantiate( "SRC_W", this, *rawProperties ); - m_Props.SRC_H = CDRMAtomicProperty::Instantiate( "SRC_H", this, *rawProperties ); - m_Props.CRTC_X = CDRMAtomicProperty::Instantiate( "CRTC_X", this, *rawProperties ); - m_Props.CRTC_Y = CDRMAtomicProperty::Instantiate( "CRTC_Y", this, *rawProperties ); - m_Props.CRTC_W = CDRMAtomicProperty::Instantiate( "CRTC_W", this, *rawProperties ); - m_Props.CRTC_H = CDRMAtomicProperty::Instantiate( "CRTC_H", this, *rawProperties ); - m_Props.zpos = CDRMAtomicProperty::Instantiate( "zpos", this, *rawProperties ); - m_Props.alpha = CDRMAtomicProperty::Instantiate( "alpha", this, *rawProperties ); - m_Props.rotation = CDRMAtomicProperty::Instantiate( "rotation", this, *rawProperties ); - m_Props.COLOR_ENCODING = CDRMAtomicProperty::Instantiate( "COLOR_ENCODING", this, *rawProperties ); - m_Props.COLOR_RANGE = CDRMAtomicProperty::Instantiate( "COLOR_RANGE", this, *rawProperties ); - m_Props.VALVE1_PLANE_DEGAMMA_TF = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_DEGAMMA_TF", this, *rawProperties ); - m_Props.VALVE1_PLANE_DEGAMMA_LUT = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_DEGAMMA_LUT", this, *rawProperties ); m_Props.VALVE1_PLANE_CTM = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_CTM", this, *rawProperties ); - m_Props.VALVE1_PLANE_HDR_MULT = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_HDR_MULT", this, *rawProperties ); - m_Props.VALVE1_PLANE_SHAPER_LUT = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_SHAPER_LUT", this, *rawProperties ); - m_Props.VALVE1_PLANE_SHAPER_TF = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_SHAPER_TF", this, *rawProperties ); - m_Props.VALVE1_PLANE_LUT3D = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_LUT3D", this, *rawProperties ); - m_Props.VALVE1_PLANE_BLEND_TF = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_BLEND_TF", this, *rawProperties ); - m_Props.VALVE1_PLANE_BLEND_LUT = CDRMAtomicProperty::Instantiate( "VALVE1_PLANE_BLEND_LUT", this, *rawProperties ); } }