SurfaceFlinger: Add support for V4L2 based wfd solution.

This change add support for V4L2 based Wi-Fi display.

Change-Id: Ib3f3868eb0b7fa2bf7e58246fb2c5cd0ddceb7e1
This commit is contained in:
Baldev Sahu 2015-08-12 16:25:05 +05:30 committed by Linux Build Service Account
parent bd170ee5b6
commit 3652b23865
3 changed files with 76 additions and 16 deletions

View File

@ -33,8 +33,11 @@
#include <utils/Errors.h> #include <utils/Errors.h>
#include <utils/Log.h> #include <utils/Log.h>
#include <gui/Surface.h>
#include <ui/GraphicBuffer.h> #include <ui/GraphicBuffer.h>
#include "RenderEngine/RenderEngine.h"
#include "DisplayHardware/FramebufferSurface.h"
#include "DisplayUtils.h" #include "DisplayUtils.h"
#include <ExSurfaceFlinger.h> #include <ExSurfaceFlinger.h>
#include <ExLayer.h> #include <ExLayer.h>
@ -88,19 +91,71 @@ HWComposer* DisplayUtils::getHWCInstance(
} }
} }
VirtualDisplaySurface* DisplayUtils::getVDSInstance(HWComposer* hwc, int32_t hwcDisplayId, void DisplayUtils::initVDSInstance(HWComposer* hwc, int32_t hwcDisplayId,
sp<IGraphicBufferProducer> currentStateSurface, sp<IGraphicBufferProducer> bqProducer, sp<IGraphicBufferProducer> currentStateSurface, sp<DisplaySurface> &dispSurface,
sp<IGraphicBufferProducer> &producer, sp<IGraphicBufferProducer> bqProducer,
sp<IGraphicBufferConsumer> bqConsumer, String8 currentStateDisplayName, sp<IGraphicBufferConsumer> bqConsumer, String8 currentStateDisplayName,
bool currentStateIsSecure) bool currentStateIsSecure, int currentStateType)
{ {
if(sUseExtendedImpls) { if(sUseExtendedImpls) {
return new ExVirtualDisplaySurface(*hwc, hwcDisplayId, currentStateSurface, bqProducer, if(hwc->isVDSEnabled()) {
bqConsumer, currentStateDisplayName, currentStateIsSecure); 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 { } else {
return new VirtualDisplaySurface(*hwc, hwcDisplayId, currentStateSurface, bqProducer, VirtualDisplaySurface* vds = new VirtualDisplaySurface(*hwc, hwcDisplayId,
bqConsumer, currentStateDisplayName); 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 }; // namespace android

View File

@ -56,14 +56,21 @@ class DisplayUtils {
uint32_t, uint32_t); uint32_t, uint32_t);
HWComposer* getHWCInstance(const sp<SurfaceFlinger>& flinger, HWComposer* getHWCInstance(const sp<SurfaceFlinger>& flinger,
HWComposer::EventHandler& handler); HWComposer::EventHandler& handler);
VirtualDisplaySurface* getVDSInstance(HWComposer* hwc, int32_t hwcDisplayId, void initVDSInstance(HWComposer* hwc, int32_t hwcDisplayId,
sp<IGraphicBufferProducer> currentStateSurface, sp<IGraphicBufferProducer> bqProducer, sp<IGraphicBufferProducer> currentStateSurface, sp<DisplaySurface> &dispSurface,
sp<IGraphicBufferProducer> &producer, sp<IGraphicBufferProducer> bqProducer,
sp<IGraphicBufferConsumer> bqConsumer, String8 currentStateDisplayName, sp<IGraphicBufferConsumer> bqConsumer, String8 currentStateDisplayName,
bool currentStateIsSecure); bool currentStateIsSecure, int currentStateType);
DisplayUtils(); DisplayUtils();
private: private:
static DisplayUtils* sDisplayUtils; static DisplayUtils* sDisplayUtils;
static bool sUseExtendedImpls; static bool sUseExtendedImpls;
bool createV4L2BasedVirtualDisplay(HWComposer* hwc, int32_t &hwcDisplayId,
sp<DisplaySurface> &dispSurface, sp<IGraphicBufferProducer> &producer,
sp<IGraphicBufferProducer> currentStateSurface,
sp<IGraphicBufferProducer> bqProducer,
sp<IGraphicBufferConsumer> bqConsumer, int currentStateType);
}; };
}; // namespace android }; // namespace android

View File

@ -1445,12 +1445,10 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
hwcDisplayId = allocateHwcDisplayId(state.type); hwcDisplayId = allocateHwcDisplayId(state.type);
} }
sp<VirtualDisplaySurface> vds = DisplayUtils::getInstance()->getVDSInstance( DisplayUtils::getInstance()->initVDSInstance(mHwc, hwcDisplayId,
mHwc, hwcDisplayId, state.surface, state.surface, dispSurface, producer, bqProducer, bqConsumer,
bqProducer, bqConsumer, state.displayName, state.isSecure); state.displayName, state.isSecure, state.type);
dispSurface = vds;
producer = vds;
} }
} else { } else {
ALOGE_IF(state.surface!=NULL, ALOGE_IF(state.surface!=NULL,
@ -1466,7 +1464,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
} }
const wp<IBinder>& display(curr.keyAt(i)); const wp<IBinder>& display(curr.keyAt(i));
if (dispSurface != NULL) { if (dispSurface != NULL && producer != NULL) {
sp<DisplayDevice> hw = new DisplayDevice(this, sp<DisplayDevice> hw = new DisplayDevice(this,
state.type, hwcDisplayId, state.type, hwcDisplayId,
mHwc->getFormat(hwcDisplayId), state.isSecure, mHwc->getFormat(hwcDisplayId), state.isSecure,