diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index c1d5af4..ebb5586 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -114,6 +114,9 @@ void QEglFSWindow::create() // raster windows will not have their own native window, surface and context. Instead, // they will be composited onto the root window's surface. QEglFSScreen *screen = this->screen(); + + QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); +/* #ifndef QT_NO_OPENGL QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); if (screen->primarySurface() != EGL_NO_SURFACE) { @@ -129,6 +132,7 @@ void QEglFSWindow::create() return; } #endif // QT_NO_OPENGL +*/ m_flags |= HasNativeWindow; setGeometry(QRect()); // will become fullscreen diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp index b8f04cf978..678f399222 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_openwfd/qeglfsopenwfdintegration.cpp @@ -37,6 +37,9 @@ ** ****************************************************************************/ +#include +#include + #include "qeglfsopenwfdintegration.h" #include "wfd.h" @@ -78,11 +81,11 @@ void QEglFSOpenWFDIntegration::platformInit() // Create device WFDint dev_attribs[3] = {WFD_DEVICE_CLIENT_TYPE, - WFD_CLIENT_ID_CLUSTER, - WFD_NONE}; + 0x7810, + WFD_NONE}; bool ok; - WFDint clientType = qgetenv("QT_OPENWFD_CLIENT_ID").toInt(&ok, 16); + WFDint clientType = qgetenv("QT_OPENWFD_CLIENT1_ID").toInt(&ok, 16); if (ok) dev_attribs[1] = clientType; @@ -90,18 +93,29 @@ void QEglFSOpenWFDIntegration::platformInit() mDevice = wfdCreateDevice(WFD_DEFAULT_DEVICE_ID, dev_attribs); if (WFD_INVALID_HANDLE == mDevice) - qFatal( "Failed to create wfd device"); + qWarning( "Failed to create wfd device"); // Get port list WFDint portIds[MAX_NUM_OF_WFD_PORTS]; WFDint numPorts = wfdEnumeratePorts(mDevice, nullptr, 0, nullptr); wfdEnumeratePorts(mDevice, portIds, numPorts, nullptr); + qDebug() << "Available ports:" << numPorts; + + for (int i=0; i < numPorts; i++) { + qDebug() << "portId:" << portIds[i]; + } + // Create port - mPort = wfdCreatePort(mDevice, portIds[0], nullptr); + WFDint portIndex = qgetenv("QT_OPENWFD_PORT1_ID").toInt(&ok, 16); + + if (!ok) + portIndex = portIds[0]; + + mPort = wfdCreatePort(mDevice, portIndex, nullptr); if (WFD_INVALID_HANDLE == mPort) - qFatal("Failed to create wfd port"); + qWarning("Failed to create wfd port"); // Get port modes WFDint numPortModes = wfdGetPortModes(mDevice, mPort, nullptr, 0); @@ -116,13 +130,13 @@ void QEglFSOpenWFDIntegration::platformInit() wfdSetPortMode(mDevice, mPort, portModes[0]); WFDErrorCode eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) - qFatal("Failed to set wfd port mode"); + qWarning("Failed to set wfd port mode"); // Power on wfdSetPortAttribi(mDevice, mPort, WFD_PORT_POWER_MODE, WFD_POWER_MODE_ON); eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) - qFatal("Failed to power on wfd port"); + qWarning("Failed to power on wfd port"); } QSize QEglFSOpenWFDIntegration::screenSize() const @@ -139,41 +153,98 @@ EGLNativeWindowType QEglFSOpenWFDIntegration::createNativeWindow(QPlatformWindow const QSize &size, const QSurfaceFormat &format) { - Q_UNUSED(window); Q_UNUSED(format); + qDebug() << "Create native window for WinId:" << window->winId(); + + if (window->winId() == 2) { + WFDint dev_attribs[3] = {WFD_DEVICE_CLIENT_TYPE, + 0x7815, + WFD_NONE}; + + bool ok; + WFDint clientType = qgetenv("QT_OPENWFD_CLIENT2_ID").toInt(&ok, 16); + + if (ok) + dev_attribs[1] = clientType; + + mDevice = wfdCreateDevice(WFD_DEFAULT_DEVICE_ID, dev_attribs); + + WFDint portIds[MAX_NUM_OF_WFD_PORTS]; + WFDint numPorts = wfdEnumeratePorts(mDevice, nullptr, 0, nullptr); + wfdEnumeratePorts(mDevice, portIds, numPorts, nullptr); + + qDebug() << "Available ports:" << numPorts; + + for (int i=0; i < numPorts; i++) { + qDebug() << "portId:" << portIds[i]; + } + + WFDint portIndex = qgetenv("QT_OPENWFD_PORT2_ID").toInt(&ok, 16); + + if (!ok) + portIndex = portIds[0]; + + mPort = wfdCreatePort(mDevice, portIndex, nullptr); + WFDint numPortModes = wfdGetPortModes(mDevice, mPort, nullptr, 0); + WFDPortMode portModes[MAX_NUM_OF_WFD_PORT_MODES]; + wfdGetPortModes(mDevice, mPort, portModes, numPortModes); + wfdSetPortMode(mDevice, mPort, portModes[0]); + wfdSetPortAttribi(mDevice, mPort, WFD_PORT_POWER_MODE, WFD_POWER_MODE_ON); + } + // Get list of pipelines WFDint numPipelines = wfdEnumeratePipelines(mDevice, nullptr, 0, nullptr); WFDint pipelineIds[MAX_NUM_OF_WFD_PIPELINES]; wfdEnumeratePipelines(mDevice, pipelineIds, numPipelines, nullptr); + qDebug() << "Available pipelines:" << numPipelines; + + for (int i=0; i < numPipelines; i++) { + qDebug() << "pipelineId:" << pipelineIds[i]; + } + bool ok; - WFDint pipelineId = qgetenv("QT_OPENWFD_PIPELINE_ID").toInt(&ok); + WFDint pipelineId; + + if (window->winId() == 1) + pipelineId = qgetenv("QT_OPENWFD_PIPELINE1_ID").toInt(&ok); + + if (window->winId() == 2) + pipelineId = qgetenv("QT_OPENWFD_PIPELINE2_ID").toInt(&ok); if (!ok) pipelineId = pipelineIds[0]; WFDPipeline pipeline = wfdCreatePipeline(mDevice, pipelineId, nullptr); if (WFD_INVALID_HANDLE == pipeline) - qFatal("Failed to create wfd pipeline"); + qWarning("Failed to create wfd pipeline"); + + QList tmpIds; + for (int i = 0; i < numPipelines; i++) { + tmpIds << pipelineIds[i]; + } + + if (!tmpIds.contains(pipelineId)) + qWarning() << "Invalid pipeline id:" << pipelineId << ". Available pipeline ids are:" << tmpIds; wfdSetPipelineAttribi(mDevice, pipeline, WFD_PIPELINE_TRANSPARENCY_ENABLE, (WFD_TRANSPARENCY_SOURCE_ALPHA|WFD_TRANSPARENCY_GLOBAL_ALPHA)); WFDErrorCode eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) - qFatal("Failed to set WFD_PIPELINE_TRANSPARENCY_ENABLE"); + qWarning("Failed to set WFD_PIPELINE_TRANSPARENCY_ENABLE"); wfdSetPipelineAttribi(mDevice, pipeline, WFD_PIPELINE_GLOBAL_ALPHA, 255); eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) - qFatal("Failed to set WFD_PIPELINE_GLOBAL_ALPHA"); + qWarning("Failed to set WFD_PIPELINE_GLOBAL_ALPHA"); wfdBindPipelineToPort(mDevice, mPort, pipeline); eError = wfdGetError(mDevice); if (WFD_ERROR_NONE != eError) - qFatal("Failed to bind port to pipeline"); + qWarning("Failed to bind port to pipeline"); // Create buffers WFDSource source[MAX_NUM_OF_WFD_BUFFERS] = {WFD_INVALID_HANDLE, WFD_INVALID_HANDLE, @@ -188,23 +259,17 @@ EGLNativeWindowType QEglFSOpenWFDIntegration::createNativeWindow(QPlatformWindow wfdEglImages[i] = (WFD_EGLImageType *)(eglImageHandles[i]); if (WFD_INVALID_HANDLE == wfdEglImages[i]) - qFatal("Failed to create WDFEGLImages"); + qWarning("Failed to create WDFEGLImages"); source[i] = wfdCreateSourceFromImage(mDevice, pipeline, eglImageHandles[i], nullptr); if (WFD_INVALID_HANDLE == source[i]) - qFatal("Failed to create source from EGLImage"); + qWarning("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"); - // 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"); + qWarning("Failed to allocate memory for native window"); nativeWindow->dev = mDevice; nativeWindow->port = mPort; @@ -214,8 +279,20 @@ EGLNativeWindowType QEglFSOpenWFDIntegration::createNativeWindow(QPlatformWindow for (int i = 0; i < MAX_NUM_OF_WFD_BUFFERS; i++) { nativeWindow->buffers[i].image = wfdEglImages[i]; nativeWindow->buffers[i].source = source[i]; + + wfdBindSourceToPipeline(nativeWindow->dev, nativeWindow->pipeline, nativeWindow->buffers[i].source , WFD_TRANSITION_AT_VSYNC, nullptr); + eError = wfdGetError(nativeWindow->dev); + if (WFD_ERROR_NONE != eError) + { + qWarning("wfdBindSourceToPipeline eError=0x%08x", eError); + } } + // Commit port + wfdDeviceCommit(mDevice, WFD_COMMIT_ENTIRE_PORT, mPort); + eError = wfdGetError(mDevice); + if (WFD_ERROR_NONE != eError) + qWarning("Failed to commit port"); return (EGLNativeWindowType)nativeWindow; }