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

Commit 0e177a2a authored by Manoj Kumar AVM's avatar Manoj Kumar AVM Committed by Linux Build Service Account
Browse files

sf: Do not allow hardware acceleration for VDS

Do not allow hardware acceleration for Virtual display if Platform
doesn't support writeback.

CRs-Fixed: 1031674
Change-Id: I343ae97adc552b6f2f8c08967f5768babb4abd70
parent 81f91ce4
Loading
Loading
Loading
Loading
+43 −3
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ bool DisplayUtils::sUseExtendedImpls = false;
DisplayUtils::DisplayUtils() {
#ifdef QTI_BSP
    sUseExtendedImpls = true;
    hasWbNode();
#endif
}

@@ -172,11 +173,50 @@ bool DisplayUtils::canAllocateHwcDisplayIdForVDS(int usage) {
    int allowHwcForVDS = atoi(value);

#if QTI_BSP
    // Reserve hardware acceleration for WFD use-case
    flag_mask = GRALLOC_USAGE_PRIVATE_WFD;
    // Do not allow hardware acceleration
    flag_mask = 0;
#endif

    return allowHwcForVDS || (usage & flag_mask);
    return mHasWbNode && (allowHwcForVDS || (usage & flag_mask));
}

int DisplayUtils::getNumFbNodes() {
    int i = 0;
    while (hasFbNode(i)) i++;
    return i;
}

bool DisplayUtils::hasFbNode(int index) {
    char filename[kMaxStringLength];
    snprintf(filename, kMaxStringLength, "/dev/graphics/fb%d", index);
    int fd = open(filename, O_RDONLY);
    if (fd < 0) {
        return false;
    }
    close(fd);
    return true;
}

bool DisplayUtils::hasWbNode() {
    int fbNum = getNumFbNodes();
    char msmFbType [kMaxStringLength];
    char fbType [kMaxStringLength];
    FILE *displayPanelFP = NULL;
    mHasWbNode = false;

    for (int i = 0; i < fbNum; i++) {
        snprintf (msmFbType,MAX_FRAME_BUFFER_NAME_SIZE, "/sys/class/graphics/fb%d/msm_fb_type", i);
        displayPanelFP = fopen(msmFbType, "r");
        if(displayPanelFP) {
            fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE, displayPanelFP);
            fclose(displayPanelFP);
            if(strncmp(fbType, "writeback panel", strlen("writeback panel")) == 0) {
                mHasWbNode = true;
                break;
            }
        }
    }
    return mHasWbNode;
}

}; // namespace android
+7 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ class IGraphicBufferConsumer;
class DisplaySurface;

/* Factory Classes */
#define kMaxStringLength (1024)
#define MAX_FRAME_BUFFER_NAME_SIZE (80)

class DisplayUtils {
  public:
@@ -66,12 +68,17 @@ class DisplayUtils {
  private:
    static DisplayUtils* sDisplayUtils;
    static bool sUseExtendedImpls;
    bool mHasWbNode;

    bool createV4L2BasedVirtualDisplay(HWComposer* hwc, int32_t &hwcDisplayId,
                   sp<DisplaySurface> &dispSurface, sp<IGraphicBufferProducer> &producer,
                   sp<IGraphicBufferProducer> currentStateSurface,
                   sp<IGraphicBufferProducer> bqProducer,
                   sp<IGraphicBufferConsumer> bqConsumer, int currentStateType);

    bool hasWbNode();
    bool hasFbNode(int index);
    int getNumFbNodes();
};

}; // namespace android