summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/DisplayUtils.cpp
diff options
context:
space:
mode:
authorBaldev Sahu <bsahu@codeaurora.org>2015-08-12 16:25:05 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:22:26 -0600
commit3652b2386511917de05beefcbc4bf1521450a1bf (patch)
tree51d630fb1ea973078f4aca39620ad6ac5a659877 /services/surfaceflinger/DisplayUtils.cpp
parentbd170ee5b6f210cfa8db72d6bfbe0cff5ed08594 (diff)
downloadframeworks_native-3652b2386511917de05beefcbc4bf1521450a1bf.zip
frameworks_native-3652b2386511917de05beefcbc4bf1521450a1bf.tar.gz
frameworks_native-3652b2386511917de05beefcbc4bf1521450a1bf.tar.bz2
SurfaceFlinger: Add support for V4L2 based wfd solution.
This change add support for V4L2 based Wi-Fi display. Change-Id: Ib3f3868eb0b7fa2bf7e58246fb2c5cd0ddceb7e1
Diffstat (limited to 'services/surfaceflinger/DisplayUtils.cpp')
-rw-r--r--services/surfaceflinger/DisplayUtils.cpp69
1 files changed, 62 insertions, 7 deletions
diff --git a/services/surfaceflinger/DisplayUtils.cpp b/services/surfaceflinger/DisplayUtils.cpp
index 3937df0..e4e2183 100644
--- a/services/surfaceflinger/DisplayUtils.cpp
+++ b/services/surfaceflinger/DisplayUtils.cpp
@@ -33,8 +33,11 @@
#include <utils/Errors.h>
#include <utils/Log.h>
+#include <gui/Surface.h>
#include <ui/GraphicBuffer.h>
+#include "RenderEngine/RenderEngine.h"
+#include "DisplayHardware/FramebufferSurface.h"
#include "DisplayUtils.h"
#include <ExSurfaceFlinger.h>
#include <ExLayer.h>
@@ -88,19 +91,71 @@ HWComposer* DisplayUtils::getHWCInstance(
}
}
-VirtualDisplaySurface* DisplayUtils::getVDSInstance(HWComposer* hwc, int32_t hwcDisplayId,
- sp<IGraphicBufferProducer> currentStateSurface, sp<IGraphicBufferProducer> bqProducer,
+void DisplayUtils::initVDSInstance(HWComposer* hwc, int32_t hwcDisplayId,
+ sp<IGraphicBufferProducer> currentStateSurface, sp<DisplaySurface> &dispSurface,
+ sp<IGraphicBufferProducer> &producer, sp<IGraphicBufferProducer> bqProducer,
sp<IGraphicBufferConsumer> bqConsumer, String8 currentStateDisplayName,
- bool currentStateIsSecure)
+ bool currentStateIsSecure, int currentStateType)
{
if(sUseExtendedImpls) {
- return new ExVirtualDisplaySurface(*hwc, hwcDisplayId, currentStateSurface, bqProducer,
- bqConsumer, currentStateDisplayName, currentStateIsSecure);
+ if(hwc->isVDSEnabled()) {
+ VirtualDisplaySurface* vds = new ExVirtualDisplaySurface(*hwc, hwcDisplayId,
+ currentStateSurface, bqProducer, bqConsumer, currentStateDisplayName,
+ currentStateIsSecure);
+ dispSurface = vds;
+ producer = vds;
+ } else if(!createV4L2BasedVirtualDisplay(hwc, hwcDisplayId, dispSurface, producer,
+ currentStateSurface, bqProducer, bqConsumer, currentStateType)) {
+ VirtualDisplaySurface* vds = new VirtualDisplaySurface(*hwc, hwcDisplayId,
+ currentStateSurface, bqProducer, bqConsumer, currentStateDisplayName);
+ dispSurface = vds;
+ producer = vds;
+ }
} else {
- return new VirtualDisplaySurface(*hwc, hwcDisplayId, currentStateSurface, bqProducer,
- bqConsumer, currentStateDisplayName);
+ VirtualDisplaySurface* vds = new VirtualDisplaySurface(*hwc, hwcDisplayId,
+ currentStateSurface, bqProducer, bqConsumer, currentStateDisplayName);
+ dispSurface = vds;
+ producer = vds;
}
}
+bool DisplayUtils::createV4L2BasedVirtualDisplay(HWComposer* hwc, int32_t &hwcDisplayId,
+ sp<DisplaySurface> &dispSurface, sp<IGraphicBufferProducer> &producer,
+ sp<IGraphicBufferProducer> currentStateSurface,
+ sp<IGraphicBufferProducer> bqProducer, sp<IGraphicBufferConsumer> bqConsumer,
+ int currentStateType) {
+ char value[PROPERTY_VALUE_MAX];
+ property_get("persist.sys.wfd.virtual", value, "0");
+ int wfdVirtual = atoi(value);
+ if(wfdVirtual && hwcDisplayId > 0) {
+ //Read virtual display properties and create a
+ //rendering surface for it inorder to be handled
+ //by hwc.
+
+ sp<ANativeWindow> mNativeWindow = new Surface(currentStateSurface);
+ ANativeWindow* const window = mNativeWindow.get();
+
+ int format;
+ window->query(window, NATIVE_WINDOW_FORMAT, &format);
+ EGLSurface surface;
+ EGLint w, h;
+ EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ // In M AOSP getEGLConfig() always returns EGL_NO_CONFIG as
+ // EGL_ANDROIDX_no_config_context active now.
+ EGLConfig config = RenderEngine::chooseEglConfig(display, format);
+
+ surface = eglCreateWindowSurface(display, config, window, NULL);
+ eglQuerySurface(display, surface, EGL_WIDTH, &w);
+ eglQuerySurface(display, surface, EGL_HEIGHT, &h);
+ if(hwc->setVirtualDisplayProperties(hwcDisplayId, w, h, format) != NO_ERROR)
+ return false;
+
+ dispSurface = new FramebufferSurface(*hwc, currentStateType, bqConsumer);
+ producer = bqProducer;
+ return true;
+ }
+ return false;
+}
+
}; // namespace android