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

Commit 525b3906 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Camera: Add support for single plane stride queries" into sc-dev am: b0f1a16f

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/14706911

Change-Id: I3fb4ac0f5f43daa18803cf5c9857f990c49b2453
parents dee60af8 b0f1a16f
Loading
Loading
Loading
Loading
+46 −13
Original line number Original line Diff line number Diff line
@@ -123,6 +123,24 @@ YCbCrLayout HandleImporter::lockYCbCrInternal(const sp<M> mapper, buffer_handle_
    return layout;
    return layout;
}
}


std::vector<PlaneLayout> getPlaneLayouts(const sp<IMapperV4> mapper, buffer_handle_t& buf) {
    auto buffer = const_cast<native_handle_t*>(buf);
    std::vector<PlaneLayout> planeLayouts;
    hidl_vec<uint8_t> encodedPlaneLayouts;
    mapper->get(buffer, gralloc4::MetadataType_PlaneLayouts,
                [&](const auto& tmpError, const auto& tmpEncodedPlaneLayouts) {
                    if (tmpError == MapperErrorV4::NONE) {
                        encodedPlaneLayouts = tmpEncodedPlaneLayouts;
                    } else {
                        ALOGE("%s: failed to get plane layouts %d!", __FUNCTION__, tmpError);
                    }
                });

    gralloc4::decodePlaneLayouts(encodedPlaneLayouts, &planeLayouts);

    return planeLayouts;
}

template <>
template <>
YCbCrLayout HandleImporter::lockYCbCrInternal<IMapperV4, MapperErrorV4>(
YCbCrLayout HandleImporter::lockYCbCrInternal<IMapperV4, MapperErrorV4>(
        const sp<IMapperV4> mapper, buffer_handle_t& buf, uint64_t cpuUsage,
        const sp<IMapperV4> mapper, buffer_handle_t& buf, uint64_t cpuUsage,
@@ -147,19 +165,7 @@ YCbCrLayout HandleImporter::lockYCbCrInternal<IMapperV4, MapperErrorV4>(
        return layout;
        return layout;
    }
    }


    hidl_vec<uint8_t> encodedPlaneLayouts;
    std::vector<PlaneLayout> planeLayouts = getPlaneLayouts(mapper, buf);
    mapper->get(buffer, gralloc4::MetadataType_PlaneLayouts,
                [&](const auto& tmpError, const auto& tmpEncodedPlaneLayouts) {
                    if (tmpError == MapperErrorV4::NONE) {
                        encodedPlaneLayouts = tmpEncodedPlaneLayouts;
                    } else {
                        ALOGE("%s: failed to get plane layouts %d!", __FUNCTION__, tmpError);
                    }
                });

    std::vector<PlaneLayout> planeLayouts;
    gralloc4::decodePlaneLayouts(encodedPlaneLayouts, &planeLayouts);

    for (const auto& planeLayout : planeLayouts) {
    for (const auto& planeLayout : planeLayouts) {
        for (const auto& planeLayoutComponent : planeLayout.components) {
        for (const auto& planeLayoutComponent : planeLayout.components) {
            const auto& type = planeLayoutComponent.type;
            const auto& type = planeLayoutComponent.type;
@@ -401,6 +407,33 @@ YCbCrLayout HandleImporter::lockYCbCr(
    return {};
    return {};
}
}


status_t HandleImporter::getMonoPlanarStrideBytes(buffer_handle_t &buf, uint32_t *stride /*out*/) {
    if (stride == nullptr) {
        return BAD_VALUE;
    }

    Mutex::Autolock lock(mLock);

    if (!mInitialized) {
        initializeLocked();
    }

    if (mMapperV4 != nullptr) {
        std::vector<PlaneLayout> planeLayouts = getPlaneLayouts(mMapperV4, buf);
        if (planeLayouts.size() != 1) {
            ALOGE("%s: Unexpected number of planes %zu!",  __FUNCTION__, planeLayouts.size());
            return BAD_VALUE;
        }

        *stride = planeLayouts[0].strideInBytes;
    } else {
        ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
        return NO_INIT;
    }

    return OK;
}

int HandleImporter::unlock(buffer_handle_t& buf) {
int HandleImporter::unlock(buffer_handle_t& buf) {
    if (mMapperV4 != nullptr) {
    if (mMapperV4 != nullptr) {
        return unlockInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf);
        return unlockInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf);
+3 −0
Original line number Original line Diff line number Diff line
@@ -56,6 +56,9 @@ public:
    YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage,
    YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage,
                          const IMapper::Rect& accessRegion);
                          const IMapper::Rect& accessRegion);


    // Query the stride of the first plane in bytes.
    status_t getMonoPlanarStrideBytes(buffer_handle_t& buf, uint32_t* stride /*out*/);

    int unlock(buffer_handle_t& buf); // returns release fence
    int unlock(buffer_handle_t& buf); // returns release fence


private:
private: