Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused plane properties #1165

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 1 addition & 167 deletions src/drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,36 +127,13 @@ namespace gamescope

struct PlaneProperties
{
std::optional<CDRMAtomicProperty> *begin() { return &FB_ID; }
std::optional<CDRMAtomicProperty> *begin() { return &type; }
std::optional<CDRMAtomicProperty> *end() { return &DUMMY_END; }

std::optional<CDRMAtomicProperty> type; // Immutable
std::optional<CDRMAtomicProperty> IN_FORMATS; // Immutable

std::optional<CDRMAtomicProperty> FB_ID;
std::optional<CDRMAtomicProperty> CRTC_ID;
std::optional<CDRMAtomicProperty> SRC_X;
std::optional<CDRMAtomicProperty> SRC_Y;
std::optional<CDRMAtomicProperty> SRC_W;
std::optional<CDRMAtomicProperty> SRC_H;
std::optional<CDRMAtomicProperty> CRTC_X;
std::optional<CDRMAtomicProperty> CRTC_Y;
std::optional<CDRMAtomicProperty> CRTC_W;
std::optional<CDRMAtomicProperty> CRTC_H;
std::optional<CDRMAtomicProperty> zpos;
std::optional<CDRMAtomicProperty> alpha;
std::optional<CDRMAtomicProperty> rotation;
std::optional<CDRMAtomicProperty> COLOR_ENCODING;
std::optional<CDRMAtomicProperty> COLOR_RANGE;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_DEGAMMA_TF;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_DEGAMMA_LUT;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_CTM;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_HDR_MULT;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_SHAPER_LUT;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_SHAPER_TF;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_LUT3D;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_BLEND_TF;
std::optional<CDRMAtomicProperty> VALVE1_PLANE_BLEND_LUT;
std::optional<CDRMAtomicProperty> DUMMY_END;
};
PlaneProperties &GetProperties() { return m_Props; }
Expand Down Expand Up @@ -1237,125 +1214,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;
Expand Down Expand Up @@ -1864,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 );
}
}

Expand Down
Loading