diff options
author | Kimmo Ollila <kimmo.ollila@qt.io> | 2019-06-04 14:40:40 +0300 |
---|---|---|
committer | Kimmo Ollila <kimmo.ollila@qt.io> | 2020-04-14 11:45:13 +0300 |
commit | edf5c7a3466b7e8082c90473183e5da9afa80504 (patch) | |
tree | 8522e034a9f81e42135686e00776605399a4c15d | |
parent | 2161414cdf2790d39eeb25fc35e26c966708d4b8 (diff) |
Refactor OpenWFD QPA plugin for INTEGRITY Snapdragon 820 ADP
Add wfdBindSourceToPipeline call to enable vsync and also call
OpenWFD resource cleanup APIs in destroyNativeWindow.
Change-Id: I5dd5cbf66c0863624ec848f11a32c232fbe32cff
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2 files changed, 65 insertions, 53 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp index b8f04cf978..2d3f3ff25a 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp @@ -44,12 +44,6 @@ QT_BEGIN_NAMESPACE -#define MAX_NUM_OF_WFD_BUFFERS 3 -#define MAX_NUM_OF_WFD_DEVICES 4 -#define MAX_NUM_OF_WFD_PIPELINES 16 -#define MAX_NUM_OF_WFD_PORT_MODES 64 -#define MAX_NUM_OF_WFD_PORTS 4 - typedef struct wfd_buffer { WFD_EGLImageType* image; WFDSource source; @@ -78,8 +72,8 @@ void QEglFSOpenWFDIntegration::platformInit() // Create device WFDint dev_attribs[3] = {WFD_DEVICE_CLIENT_TYPE, - WFD_CLIENT_ID_CLUSTER, - WFD_NONE}; + WFD_CLIENT_ID_CLUSTER, + WFD_NONE}; bool ok; WFDint clientType = qgetenv("QT_OPENWFD_CLIENT_ID").toInt(&ok, 16); @@ -123,99 +117,100 @@ void QEglFSOpenWFDIntegration::platformInit() eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) qFatal("Failed to power on wfd port"); -} - -QSize QEglFSOpenWFDIntegration::screenSize() const -{ - return mScreenSize; -} - -EGLNativeDisplayType QEglFSOpenWFDIntegration::platformDisplay() const -{ - return mNativeDisplay; -} - -EGLNativeWindowType QEglFSOpenWFDIntegration::createNativeWindow(QPlatformWindow *window, - const QSize &size, - const QSurfaceFormat &format) -{ - Q_UNUSED(window); - Q_UNUSED(format); // Get list of pipelines WFDint numPipelines = wfdEnumeratePipelines(mDevice, nullptr, 0, nullptr); - WFDint pipelineIds[MAX_NUM_OF_WFD_PIPELINES]; wfdEnumeratePipelines(mDevice, pipelineIds, numPipelines, nullptr); - bool ok; WFDint pipelineId = qgetenv("QT_OPENWFD_PIPELINE_ID").toInt(&ok); if (!ok) pipelineId = pipelineIds[0]; - WFDPipeline pipeline = wfdCreatePipeline(mDevice, pipelineId, nullptr); - if (WFD_INVALID_HANDLE == pipeline) + mPipeline = wfdCreatePipeline(mDevice, pipelineId, nullptr); + if (WFD_INVALID_HANDLE == mPipeline) qFatal("Failed to create wfd pipeline"); - wfdSetPipelineAttribi(mDevice, pipeline, WFD_PIPELINE_TRANSPARENCY_ENABLE, + wfdSetPipelineAttribi(mDevice, mPipeline, WFD_PIPELINE_TRANSPARENCY_ENABLE, (WFD_TRANSPARENCY_SOURCE_ALPHA|WFD_TRANSPARENCY_GLOBAL_ALPHA)); - WFDErrorCode eError = wfdGetError(mDevice); + eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) qFatal("Failed to set WFD_PIPELINE_TRANSPARENCY_ENABLE"); - wfdSetPipelineAttribi(mDevice, pipeline, WFD_PIPELINE_GLOBAL_ALPHA, 255); + wfdSetPipelineAttribi(mDevice, mPipeline, WFD_PIPELINE_GLOBAL_ALPHA, 255); eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) qFatal("Failed to set WFD_PIPELINE_GLOBAL_ALPHA"); - wfdBindPipelineToPort(mDevice, mPort, pipeline); + wfdBindPipelineToPort(mDevice, mPort, mPipeline); eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) qFatal("Failed to bind port to pipeline"); - // Create buffers - WFDSource source[MAX_NUM_OF_WFD_BUFFERS] = {WFD_INVALID_HANDLE, WFD_INVALID_HANDLE, - WFD_INVALID_HANDLE}; - WFDEGLImage eglImageHandles[MAX_NUM_OF_WFD_BUFFERS]; - WFD_EGLImageType* wfdEglImages[MAX_NUM_OF_WFD_BUFFERS]; for (int i = 0; i < MAX_NUM_OF_WFD_BUFFERS; i++) { wfdCreateWFDEGLImages(mDevice, mScreenSize.width(), mScreenSize.height(), WFD_FORMAT_RGBA8888, WFD_USAGE_OPENGL_ES2 | WFD_USAGE_DISPLAY, - 1, &(eglImageHandles[i]), 0); + 1, &(mEGLImageHandles[i]), 0); - wfdEglImages[i] = (WFD_EGLImageType *)(eglImageHandles[i]); - if (WFD_INVALID_HANDLE == wfdEglImages[i]) + mWFDEglImages[i] = (WFD_EGLImageType *)(mEGLImageHandles[i]); + if (WFD_INVALID_HANDLE == mWFDEglImages[i]) qFatal("Failed to create WDFEGLImages"); - source[i] = wfdCreateSourceFromImage(mDevice, pipeline, eglImageHandles[i], nullptr); - if (WFD_INVALID_HANDLE == source[i]) + mSources[i] = wfdCreateSourceFromImage(mDevice, mPipeline, mEGLImageHandles[i], nullptr); + if (WFD_INVALID_HANDLE == mSources[i]) qFatal("Failed to create source from EGLImage"); } +} - // Commit port - wfdDeviceCommit(mDevice, WFD_COMMIT_ENTIRE_PORT, mPort); - eError = wfdGetError(mDevice); - if (WFD_ERROR_NONE != eError) - qFatal("Failed to commit port"); +QSize QEglFSOpenWFDIntegration::screenSize() const +{ + return mScreenSize; +} + +EGLNativeDisplayType QEglFSOpenWFDIntegration::platformDisplay() const +{ + return mNativeDisplay; +} + +EGLNativeWindowType QEglFSOpenWFDIntegration::createNativeWindow(QPlatformWindow *window, + const QSize &size, + const QSurfaceFormat &format) +{ + Q_UNUSED(window); + Q_UNUSED(format); // Create native window wfd_window_t* nativeWindow = (wfd_window_t*)malloc(sizeof(wfd_window_t)); if (nullptr == nativeWindow) - qFatal("Failed to allocate memory for native window"); + qFatal("Failed to allocate memory for native window"); nativeWindow->dev = mDevice; nativeWindow->port = mPort; - nativeWindow->pipeline = pipeline; + nativeWindow->pipeline = mPipeline; nativeWindow->numBuffers = MAX_NUM_OF_WFD_BUFFERS; + WFDErrorCode eError; + for (int i = 0; i < MAX_NUM_OF_WFD_BUFFERS; i++) { - nativeWindow->buffers[i].image = wfdEglImages[i]; - nativeWindow->buffers[i].source = source[i]; + nativeWindow->buffers[i].image = mWFDEglImages[i]; + nativeWindow->buffers[i].source = mSources[i]; + wfdBindSourceToPipeline(nativeWindow->dev, nativeWindow->pipeline, nativeWindow->buffers[i].source , WFD_TRANSITION_AT_VSYNC, nullptr); + eError = wfdGetError(nativeWindow->dev); + if (WFD_ERROR_NONE != eError) + { + qFatal("wfdBindSourceToPipeline eError=0x%08x", eError); + } } + // Commit port + wfdDeviceCommit(mDevice, WFD_COMMIT_ENTIRE_PORT, mPort); + eError = wfdGetError(mDevice); + if (WFD_ERROR_NONE != eError) + qFatal("Failed to commit port"); + return (EGLNativeWindowType)nativeWindow; } @@ -231,6 +226,13 @@ QSurfaceFormat QEglFSOpenWFDIntegration::surfaceFormatFor(const QSurfaceFormat & void QEglFSOpenWFDIntegration::destroyNativeWindow(EGLNativeWindowType window) { + wfdBindSourceToPipeline(mDevice, ((wfd_window_t*)window)->pipeline, nullptr, WFD_TRANSITION_IMMEDIATE, nullptr); + + for (int i = 0; i < MAX_NUM_OF_WFD_BUFFERS; i++) { + wfdDestroySource(mDevice, mSources[i]); + wfdDestroyWFDEGLImages(mDevice, 1, &mEGLImageHandles[i]); + } + free((void*)window); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.h index 189ddd4d7a..53d9cffaf2 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.h @@ -47,6 +47,12 @@ QT_BEGIN_NAMESPACE +#define MAX_NUM_OF_WFD_BUFFERS 3 +#define MAX_NUM_OF_WFD_DEVICES 4 +#define MAX_NUM_OF_WFD_PIPELINES 16 +#define MAX_NUM_OF_WFD_PORT_MODES 64 +#define MAX_NUM_OF_WFD_PORTS 4 + class QEglFSOpenWFDIntegration : public QEglFSDeviceIntegration { public: @@ -62,6 +68,10 @@ private: EGLNativeDisplayType mNativeDisplay; WFDDevice mDevice; WFDPort mPort; + WFDPipeline mPipeline; + WFDSource mSources[MAX_NUM_OF_WFD_BUFFERS] = {WFD_INVALID_HANDLE, WFD_INVALID_HANDLE, WFD_INVALID_HANDLE}; + WFD_EGLImageType* mWFDEglImages[MAX_NUM_OF_WFD_BUFFERS]; + WFDEGLImage mEGLImageHandles[MAX_NUM_OF_WFD_BUFFERS]; }; QT_END_NAMESPACE |