mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 15:26:09 +00:00
Add plane selection workaround for Spacemit driver bug
Expose plane bug workaround logic through new envvars: - DRM_MIN_PLANE_ZPOS - DRM_ALLOW_PRIMARY_PLANE
This commit is contained in:
parent
52583f5c71
commit
45ccd1a811
@ -449,7 +449,7 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
|
|
||||||
// Find the active plane (if any) on this CRTC with the highest zpos.
|
// Find the active plane (if any) on this CRTC with the highest zpos.
|
||||||
// We'll need to use a plane with a equal or greater zpos to be visible.
|
// We'll need to use a plane with a equal or greater zpos to be visible.
|
||||||
uint64_t maxActiveZpos = 0;
|
uint64_t maxActiveZpos = qEnvironmentVariableIntValue("DRM_MIN_PLANE_ZPOS");
|
||||||
for (uint32_t i = 0; i < planeRes->count_planes; i++) {
|
for (uint32_t i = 0; i < planeRes->count_planes; i++) {
|
||||||
drmModePlane* plane = drmModeGetPlane(m_DrmFd, planeRes->planes[i]);
|
drmModePlane* plane = drmModeGetPlane(m_DrmFd, planeRes->planes[i]);
|
||||||
if (plane != nullptr) {
|
if (plane != nullptr) {
|
||||||
@ -461,7 +461,7 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
|
|
||||||
drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(m_DrmFd, planeRes->planes[i], DRM_MODE_OBJECT_PLANE);
|
drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(m_DrmFd, planeRes->planes[i], DRM_MODE_OBJECT_PLANE);
|
||||||
if (props != nullptr) {
|
if (props != nullptr) {
|
||||||
// Only consider primary and overlay planes as valid render targets
|
// Don't consider cursor planes when searching for the highest active zpos
|
||||||
uint64_t type;
|
uint64_t type;
|
||||||
if (getPropertyByName(props, "type", &type) && (type == DRM_PLANE_TYPE_PRIMARY || type == DRM_PLANE_TYPE_OVERLAY)) {
|
if (getPropertyByName(props, "type", &type) && (type == DRM_PLANE_TYPE_PRIMARY || type == DRM_PLANE_TYPE_OVERLAY)) {
|
||||||
uint64_t zPos;
|
uint64_t zPos;
|
||||||
@ -478,6 +478,15 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The Spacemit K1 driver is broken and advertises support for NV12/P010
|
||||||
|
// formats with the linear modifier on all planes, but doesn't actually
|
||||||
|
// support raw YUV formats on the primary plane. Don't ever use primary
|
||||||
|
// planes on Spacemit hardware to avoid triggering this bug.
|
||||||
|
bool ok, allowPrimaryPlane = !!qEnvironmentVariableIntValue("DRM_ALLOW_PRIMARY_PLANE", &ok);
|
||||||
|
if (!ok) {
|
||||||
|
allowPrimaryPlane = strcmp(m_Version->name, "spacemit") != 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Find a plane with the required format to render on
|
// Find a plane with the required format to render on
|
||||||
//
|
//
|
||||||
// FIXME: We should check the actual DRM format in a real AVFrame rather
|
// FIXME: We should check the actual DRM format in a real AVFrame rather
|
||||||
@ -528,8 +537,9 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
uint64_t type;
|
uint64_t type;
|
||||||
uint64_t zPos;
|
uint64_t zPos;
|
||||||
|
|
||||||
// Only consider primary and overlay planes as valid render targets
|
// Only consider overlay and primary (if allowed) planes as valid render targets
|
||||||
if (!getPropertyByName(props, "type", &type) || (type != DRM_PLANE_TYPE_PRIMARY && type != DRM_PLANE_TYPE_OVERLAY)) {
|
if (!getPropertyByName(props, "type", &type) ||
|
||||||
|
(type != DRM_PLANE_TYPE_OVERLAY && (type != DRM_PLANE_TYPE_PRIMARY || !allowPrimaryPlane))) {
|
||||||
drmModeFreePlane(plane);
|
drmModeFreePlane(plane);
|
||||||
}
|
}
|
||||||
// If this plane has a zpos property and it's lower (further from user) than
|
// If this plane has a zpos property and it's lower (further from user) than
|
||||||
|
Loading…
x
Reference in New Issue
Block a user