diff options
author | Liang Qi <liang.qi@qt.io> | 2018-02-16 08:07:08 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2018-02-16 22:31:50 +0000 |
commit | 048d8dee52545a9b0a548b4c56958a75a99d9aee (patch) | |
tree | c549685860a49e71809e06e90cc0fa6031a2def1 /src/plugins/platforms/eglfs/deviceintegration | |
parent | 6ffb358822db2e0d30fb34853c3222cd866d57c5 (diff) | |
parent | 942ab490724fcc9544e786e5783718e1a07aa50b (diff) |
Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev
Diffstat (limited to 'src/plugins/platforms/eglfs/deviceintegration')
4 files changed, 42 insertions, 8 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp index 88b401c920..475d9d55dd 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp @@ -141,10 +141,15 @@ void QEglFSKmsVsp2Screen::initDumbFrameBuffers() void QEglFSKmsVsp2Screen::initVsp2() { qCDebug(qLcEglfsKmsDebug, "Initializing Vsp2 hardware"); - const QSize screenSize = rawGeometry().size(); - m_blendDevice.reset(new QVsp2BlendingDevice(screenSize)); + m_blendDevice.reset(new QVsp2BlendingDevice(rawGeometry().size())); // Enable input for main buffer drawn by the compositor (always on) + initQtLayer(); +} + +void QEglFSKmsVsp2Screen::initQtLayer() +{ + const QSize screenSize = rawGeometry().size(); const uint bytesPerLine = uint(screenSize.width()) * 4; //TODO: is this ok? bool formatSet = m_blendDevice->enableInput(m_qtLayer, QRect(QPoint(), screenSize), m_output.drm_format, bytesPerLine); if (!formatSet) { @@ -298,8 +303,13 @@ void QEglFSKmsVsp2Screen::blendAndFlipDrm() vBlank.request.signal = 0; drmWaitVBlank(driFd, &vBlank); - if (!m_blendDevice->blend(backBuffer.dmabufFd)) - qWarning() << "Vsp2: blending failed"; + if (!m_blendDevice->blend(backBuffer.dmabufFd)) { + qWarning() << "Vsp2: Blending failed"; + + // For some reason, a failed blend may often mess up the qt layer, so reinitialize it here + m_blendDevice->disableInput(m_qtLayer); + initQtLayer(); + } for (auto cb : m_blendFinishedCallbacks) cb(); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h index fa03e36785..7618510333 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h @@ -60,6 +60,7 @@ public: void initDumbFrameBuffers(); void initVsp2(); + void initQtLayer(); //TODO: use a fixed index API instead of auto increment? int addLayer(int dmabufFd, const QSize &size, const QPoint &position, uint drmPixelFormat, uint bytesPerLine); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qvsp2blendingdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qvsp2blendingdevice.cpp index 879d312341..132806a2e3 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qvsp2blendingdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qvsp2blendingdevice.cpp @@ -219,11 +219,12 @@ bool QVsp2BlendingDevice::blend(int outputDmabufFd) if (!m_dirty) qWarning("Blending without being dirty, should not be necessary"); - if (!m_inputs[0].enabled) { - qWarning("Vsp2: Can't blend with layer 0 disabled"); + if (!hasContinuousLayers()) { + qWarning("Vsp2: Can't blend when layers are not enabled in order from 0 without gaps."); return false; } + bool queueingFailed = false; // Queue dma input buffers for (int i=0; i < m_inputs.size(); ++i) { auto &input = m_inputs[i]; @@ -233,12 +234,22 @@ bool QVsp2BlendingDevice::blend(int outputDmabufFd) << "with dmabuf" << input.dmabuf.fd << "and size" << input.geometry.size(); - if (!disableInput(i)) - qWarning() << "Vsp2: Failed to disable input" << i; + queueingFailed = true; } } } + if (queueingFailed) { + qWarning() << "Vsp2: Trying to clean up queued buffers"; + for (auto &input : qAsConst(m_inputs)) { + if (input.enabled) { + if (!input.rpfInput->clearBuffers()) + qWarning() << "Vsp2: Failed to remove buffers after an aborted blend"; + } + } + return false; + } + if (!m_wpfOutput->queueBuffer(outputDmabufFd, m_screenSize)) { qWarning() << "Vsp2: Failed to queue blending output buffer" << outputDmabufFd << m_screenSize; return false; @@ -270,6 +281,17 @@ int QVsp2BlendingDevice::numInputs() const return m_inputs.size(); } +bool QVsp2BlendingDevice::hasContinuousLayers() const +{ + bool seenDisabled = false; + for (auto &input : qAsConst(m_inputs)) { + if (seenDisabled && input.enabled) + return false; + seenDisabled |= !input.enabled; + } + return m_inputs[0].enabled; +} + bool QVsp2BlendingDevice::streamOn() { for (auto &input : m_inputs) { diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qvsp2blendingdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qvsp2blendingdevice.h index be48954f47..ee34ae654a 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qvsp2blendingdevice.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qvsp2blendingdevice.h @@ -63,6 +63,7 @@ public: bool blend(int outputDmabufFd); int numInputs() const; bool isDirty() const { return m_dirty; } + bool hasContinuousLayers() const; private: bool streamOn(); bool streamOff(); |