Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5a33928 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

we now correctly set-up connected screens during boot

Change-Id: Ie8b1a3b97ad1821cc970e43abe96c8cec7135b66
parent 148994e5
Loading
Loading
Loading
Loading
+7 −6
Original line number Original line Diff line number Diff line
@@ -46,8 +46,9 @@ namespace android {
 *
 *
 */
 */


FramebufferSurface::FramebufferSurface(HWComposer& hwc) :
FramebufferSurface::FramebufferSurface(HWComposer& hwc, int disp) :
    ConsumerBase(new BufferQueue(true, new GraphicBufferAlloc())),
    ConsumerBase(new BufferQueue(true, new GraphicBufferAlloc())),
    mDisplayType(disp),
    mCurrentBufferSlot(-1),
    mCurrentBufferSlot(-1),
    mCurrentBuffer(0),
    mCurrentBuffer(0),
    mHwc(hwc)
    mHwc(hwc)
@@ -55,10 +56,10 @@ FramebufferSurface::FramebufferSurface(HWComposer& hwc) :
    mName = "FramebufferSurface";
    mName = "FramebufferSurface";
    mBufferQueue->setConsumerName(mName);
    mBufferQueue->setConsumerName(mName);
    mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_HW_FB |
    mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_HW_FB |
                                       GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER);
                                       GRALLOC_USAGE_HW_RENDER |
    mBufferQueue->setDefaultBufferFormat(mHwc.getFormat(HWC_DISPLAY_PRIMARY));
                                       GRALLOC_USAGE_HW_COMPOSER);
    mBufferQueue->setDefaultBufferSize(mHwc.getWidth(HWC_DISPLAY_PRIMARY),
    mBufferQueue->setDefaultBufferFormat(mHwc.getFormat(disp));
                                       mHwc.getHeight(HWC_DISPLAY_PRIMARY));
    mBufferQueue->setDefaultBufferSize(mHwc.getWidth(disp),  mHwc.getHeight(disp));
    mBufferQueue->setSynchronousMode(true);
    mBufferQueue->setSynchronousMode(true);
    mBufferQueue->setDefaultMaxBufferCount(NUM_FRAME_BUFFERS);
    mBufferQueue->setDefaultMaxBufferCount(NUM_FRAME_BUFFERS);
}
}
@@ -111,7 +112,7 @@ void FramebufferSurface::onFrameAvailable() {
                strerror(-err), err);
                strerror(-err), err);
        return;
        return;
    }
    }
    err = mHwc.fbPost(0, acquireFence, buf); // FIXME: use real display id
    err = mHwc.fbPost(mDisplayType, acquireFence, buf);
    if (err != NO_ERROR) {
    if (err != NO_ERROR) {
        ALOGE("error posting framebuffer: %d", err);
        ALOGE("error posting framebuffer: %d", err);
    }
    }
+4 −1
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@ class HWComposer;


class FramebufferSurface : public ConsumerBase {
class FramebufferSurface : public ConsumerBase {
public:
public:
    FramebufferSurface(HWComposer& hwc);
    FramebufferSurface(HWComposer& hwc, int disp);


    bool isUpdateOnDemand() const { return false; }
    bool isUpdateOnDemand() const { return false; }
    status_t setUpdateRectangle(const Rect& updateRect);
    status_t setUpdateRectangle(const Rect& updateRect);
@@ -63,6 +63,9 @@ private:
    // BufferQueue.  The new buffer is returned in the 'buffer' argument.
    // BufferQueue.  The new buffer is returned in the 'buffer' argument.
    status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);
    status_t nextBuffer(sp<GraphicBuffer>& outBuffer, sp<Fence>& outFence);


    // mDisplayType must match one of the HWC display types
    int mDisplayType;

    // mCurrentBufferIndex is the slot index of the current buffer or
    // mCurrentBufferIndex is the slot index of the current buffer or
    // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
    // INVALID_BUFFER_SLOT to indicate that either there is no current buffer
    // or the buffer is not associated with a slot.
    // or the buffer is not associated with a slot.
+12 −7
Original line number Original line Diff line number Diff line
@@ -301,10 +301,7 @@ void HWComposer::hotplug(int disp, int connected) {
                disp, connected);
                disp, connected);
        return;
        return;
    }
    }

    if (connected)
    queryDisplayProperties(disp);
    queryDisplayProperties(disp);

    mEventHandler.onHotplugReceived(disp, bool(connected));
    mEventHandler.onHotplugReceived(disp, bool(connected));
}
}


@@ -335,6 +332,7 @@ status_t HWComposer::queryDisplayProperties(int disp) {
    status_t err = mHwc->getDisplayConfigs(mHwc, disp, &config, &numConfigs);
    status_t err = mHwc->getDisplayConfigs(mHwc, disp, &config, &numConfigs);
    if (err != NO_ERROR) {
    if (err != NO_ERROR) {
        // this can happen if an unpluggable display is not connected
        // this can happen if an unpluggable display is not connected
        mDisplayData[disp].connected = false;
        return err;
        return err;
    }
    }


@@ -365,6 +363,9 @@ status_t HWComposer::queryDisplayProperties(int disp) {
        }
        }
    }
    }


    // FIXME: what should we set the format to?
    mDisplayData[disp].format = HAL_PIXEL_FORMAT_RGBA_8888;
    mDisplayData[disp].connected = true;
    if (mDisplayData[disp].xdpi == 0.0f || mDisplayData[disp].ydpi == 0.0f) {
    if (mDisplayData[disp].xdpi == 0.0f || mDisplayData[disp].ydpi == 0.0f) {
        // is there anything smarter we can do?
        // is there anything smarter we can do?
        if (h >= 1080) {
        if (h >= 1080) {
@@ -432,6 +433,10 @@ float HWComposer::getDpiY(int disp) const {
    return mDisplayData[disp].ydpi;
    return mDisplayData[disp].ydpi;
}
}


bool HWComposer::isConnected(int disp) const {
    return mDisplayData[disp].connected;
}

void HWComposer::eventControl(int event, int enabled) {
void HWComposer::eventControl(int event, int enabled) {
    status_t err = NO_ERROR;
    status_t err = NO_ERROR;
    if (mHwc) {
    if (mHwc) {
@@ -503,9 +508,9 @@ status_t HWComposer::setFramebufferTarget(int32_t id,
        // triggers a SurfaceTextureClient::queueBuffer()  on some
        // triggers a SurfaceTextureClient::queueBuffer()  on some
        // devices (!?) -- log and ignore.
        // devices (!?) -- log and ignore.
        ALOGE("HWComposer: framebufferTarget is null");
        ALOGE("HWComposer: framebufferTarget is null");
        CallStack stack;
//        CallStack stack;
        stack.update();
//        stack.update();
        stack.dump("");
//        stack.dump("");
        return NO_ERROR;
        return NO_ERROR;
    }
    }


+3 −1
Original line number Original line Diff line number Diff line
@@ -234,6 +234,7 @@ public:
    uint32_t getFormat(int disp) const;
    uint32_t getFormat(int disp) const;
    float getDpiX(int disp) const;
    float getDpiX(int disp) const;
    float getDpiY(int disp) const;
    float getDpiY(int disp) const;
    bool isConnected(int disp) const;


    // this class is only used to fake the VSync event on systems that don't
    // this class is only used to fake the VSync event on systems that don't
    // have it.
    // have it.
@@ -283,7 +284,7 @@ private:


    struct DisplayData {
    struct DisplayData {
        DisplayData() : xdpi(0), ydpi(0), refresh(0),
        DisplayData() : xdpi(0), ydpi(0), refresh(0),
            hasFbComp(false), hasOvComp(false),
            connected(false), hasFbComp(false), hasOvComp(false),
            capacity(0), list(NULL),
            capacity(0), list(NULL),
            framebufferTarget(NULL), fbTargetHandle(NULL) { }
            framebufferTarget(NULL), fbTargetHandle(NULL) { }
        ~DisplayData() {
        ~DisplayData() {
@@ -295,6 +296,7 @@ private:
        float xdpi;
        float xdpi;
        float ydpi;
        float ydpi;
        nsecs_t refresh;
        nsecs_t refresh;
        bool connected;
        bool hasFbComp;
        bool hasFbComp;
        bool hasOvComp;
        bool hasOvComp;
        size_t capacity;
        size_t capacity;
+28 −27
Original line number Original line Diff line number Diff line
@@ -405,34 +405,35 @@ status_t SurfaceFlinger::readyToRun()


    // initialize our non-virtual displays
    // initialize our non-virtual displays
    for (size_t i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) {
    for (size_t i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) {
        DisplayDevice::DisplayType type((DisplayDevice::DisplayType)i);
        mDefaultDisplays[i] = new BBinder();
        mDefaultDisplays[i] = new BBinder();
        mCurrentState.displays.add(mDefaultDisplays[i],
        wp<IBinder> token = mDefaultDisplays[i];
                DisplayDeviceState(DisplayDevice::DisplayType(i)));
        mCurrentState.displays.add(token, DisplayDeviceState(type));
    }

    // The main display is a bit special and always exists
    //
    // if we didn't add it here, it would be added automatically during the
    // first transaction, however this would also create some difficulties:
    //
    // - there would be a race where a client could call getDisplayInfo(),
    //   for instance before the DisplayDevice is created.
    //
    // - we need a GL context current in a few places, when initializing
    //   OpenGL ES (see below), or creating a layer,
    //   or when a texture is (asynchronously) destroyed, and for that
    //   we need a valid surface, so it's conveniant to use the main display
    //   for that.


    sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc);
        // set-up the displays that are already connected
        if (mHwc->isConnected(i)) {
            sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i);
            sp<SurfaceTextureClient> stc = new SurfaceTextureClient(
            sp<SurfaceTextureClient> stc = new SurfaceTextureClient(
                        static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));
                        static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));
            sp<DisplayDevice> hw = new DisplayDevice(this,
            sp<DisplayDevice> hw = new DisplayDevice(this,
            DisplayDevice::DISPLAY_PRIMARY,
                    type, token, stc, fbs, mEGLConfig);
            mDefaultDisplays[DisplayDevice::DISPLAY_PRIMARY],
            stc, fbs, mEGLConfig);
    mDisplays.add(mDefaultDisplays[DisplayDevice::DISPLAY_PRIMARY], hw);


            if (i > DisplayDevice::DISPLAY_PRIMARY) {
                // FIXME: currently we don't really handle blank/unblank
                // for displays other than the main display, so we always
                // assume a connected display is unblanked.
                hw->acquireScreen();
            }
            mDisplays.add(token, hw);
        }
    }

    //  we need a GL context current in a few places, when initializing
    //  OpenGL ES (see below), or creating a layer,
    //  or when a texture is (asynchronously) destroyed, and for that
    //  we need a valid surface, so it's convenient to use the main display
    //  for that.
    sp<const DisplayDevice> hw = getDefaultDisplayDevice();


    //  initialize OpenGL ES
    //  initialize OpenGL ES
    DisplayDevice::makeCurrent(mEGLDisplay, hw, mEGLContext);
    DisplayDevice::makeCurrent(mEGLDisplay, hw, mEGLContext);
@@ -1076,7 +1077,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)


                        // for supported (by hwc) displays we provide our
                        // for supported (by hwc) displays we provide our
                        // own rendering surface
                        // own rendering surface
                        fbs = new FramebufferSurface(*mHwc);
                        fbs = new FramebufferSurface(*mHwc, state.type);
                        stc = new SurfaceTextureClient(
                        stc = new SurfaceTextureClient(
                                static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));
                                static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));
                    } else {
                    } else {