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

Commit 2295df70 authored by Emilian Peev's avatar Emilian Peev Committed by Jayant Chowdhary
Browse files

Camera: Add 10-bit dynamic range support

Check for supported 10-bit dynamic range profiles during
stream configuration.
When needed, verify incoming process requests for unsupported
dynamic range profile combinations.
Propagate HDR metadata to corresponding registered native windows.

Bug: 195946346
Test: Camera CTS
Change-Id: I3d47418e8186959d7d1772d037755c20f8f37e74
parent 0eb0f136
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -112,6 +112,12 @@ status_t CameraStreamStats::readFromParcel(const android::Parcel* parcel) {
        return err;
    }

    int dynamicRangeProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD;
    if ((err = parcel->readInt32(&dynamicRangeProfile)) != OK) {
        ALOGE("%s: Failed to read dynamic range profile type from parcel", __FUNCTION__);
        return err;
    }

    mWidth = width;
    mHeight = height;
    mFormat = format;
@@ -125,6 +131,7 @@ status_t CameraStreamStats::readFromParcel(const android::Parcel* parcel) {
    mHistogramType = histogramType;
    mHistogramBins = std::move(histogramBins);
    mHistogramCounts = std::move(histogramCounts);
    mDynamicRangeProfile = dynamicRangeProfile;

    return OK;
}
@@ -202,6 +209,11 @@ status_t CameraStreamStats::writeToParcel(android::Parcel* parcel) const {
        return err;
    }

    if ((err = parcel->writeInt32(mDynamicRangeProfile)) != OK) {
        ALOGE("%s: Failed to write dynamic range profile type", __FUNCTION__);
        return err;
    }

    return OK;
}

+20 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <camera/camera2/OutputConfiguration.h>
#include <binder/Parcel.h>
#include <gui/view/Surface.h>
#include <system/camera_metadata.h>
#include <utils/String8.h>

namespace android {
@@ -76,6 +77,10 @@ const std::vector<int32_t> &OutputConfiguration::getSensorPixelModesUsed() const
    return mSensorPixelModesUsed;
}

int OutputConfiguration::getDynamicRangeProfile() const {
    return mDynamicRangeProfile;
}

OutputConfiguration::OutputConfiguration() :
        mRotation(INVALID_ROTATION),
        mSurfaceSetID(INVALID_SET_ID),
@@ -84,7 +89,8 @@ OutputConfiguration::OutputConfiguration() :
        mHeight(0),
        mIsDeferred(false),
        mIsShared(false),
        mIsMultiResolution(false) {
        mIsMultiResolution(false),
        mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD) {
}

OutputConfiguration::OutputConfiguration(const android::Parcel& parcel) :
@@ -165,6 +171,12 @@ status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
        ALOGE("%s: Failed to read sensor pixel mode(s) from parcel", __FUNCTION__);
        return err;
    }
    int dynamicProfile;
    if ((err = parcel->readInt32(&dynamicProfile)) != OK) {
        ALOGE("%s: Failed to read surface dynamic range profile flag from parcel", __FUNCTION__);
        return err;
    }

    mRotation = rotation;
    mSurfaceSetID = setID;
    mSurfaceType = surfaceType;
@@ -181,6 +193,7 @@ status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
    }

    mSensorPixelModesUsed = std::move(sensorPixelModesUsed);
    mDynamicRangeProfile = dynamicProfile;

    ALOGV("%s: OutputConfiguration: rotation = %d, setId = %d, surfaceType = %d,"
          " physicalCameraId = %s, isMultiResolution = %d", __FUNCTION__, mRotation,
@@ -199,6 +212,7 @@ OutputConfiguration::OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int ro
    mIsShared = isShared;
    mPhysicalCameraId = physicalId;
    mIsMultiResolution = false;
    mDynamicRangeProfile = ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD;
}

OutputConfiguration::OutputConfiguration(
@@ -207,7 +221,8 @@ OutputConfiguration::OutputConfiguration(
    int width, int height, bool isShared)
  : mGbps(gbps), mRotation(rotation), mSurfaceSetID(surfaceSetID), mSurfaceType(surfaceType),
    mWidth(width), mHeight(height), mIsDeferred(false), mIsShared(isShared),
    mPhysicalCameraId(physicalCameraId), mIsMultiResolution(false) { }
    mPhysicalCameraId(physicalCameraId), mIsMultiResolution(false),
    mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD) { }

status_t OutputConfiguration::writeToParcel(android::Parcel* parcel) const {

@@ -254,6 +269,9 @@ status_t OutputConfiguration::writeToParcel(android::Parcel* parcel) const {
    err = parcel->writeParcelableVector(mSensorPixelModesUsed);
    if (err != OK) return err;

    err = parcel->writeInt32(mDynamicRangeProfile ? 1 : 0);
    if (err != OK) return err;

    return OK;
}

+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ cc_binary {
        "android.hardware.camera.device@1.0",
        "android.hardware.camera.device@3.2",
        "android.hardware.camera.device@3.4",
        "android.hardware.camera.device@3.8",
    ],
    compile_multilib: "first",
    cflags: [
+10 −3
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@

#include <binder/Parcelable.h>

#include <camera/CameraMetadata.h>

namespace android {
namespace hardware {

@@ -60,16 +62,21 @@ public:
    // size(mHistogramBins) + 1 = size(mHistogramCounts)
    std::vector<int64_t> mHistogramCounts;

    // Dynamic range profile
    int mDynamicRangeProfile;

    CameraStreamStats() :
            mWidth(0), mHeight(0), mFormat(0), mDataSpace(0), mUsage(0),
            mRequestCount(0), mErrorCount(0), mStartLatencyMs(0),
            mMaxHalBuffers(0), mMaxAppBuffers(0), mHistogramType(HISTOGRAM_TYPE_UNKNOWN) {}
            mMaxHalBuffers(0), mMaxAppBuffers(0), mHistogramType(HISTOGRAM_TYPE_UNKNOWN),
            mDynamicRangeProfile(ANDROID_REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD) {}
    CameraStreamStats(int width, int height, int format, int dataSpace, int64_t usage,
            int maxHalBuffers, int maxAppBuffers)
            int maxHalBuffers, int maxAppBuffers, int dynamicRangeProfile)
            : mWidth(width), mHeight(height), mFormat(format), mDataSpace(dataSpace),
              mUsage(usage), mRequestCount(0), mErrorCount(0), mStartLatencyMs(0),
              mMaxHalBuffers(maxHalBuffers), mMaxAppBuffers(maxAppBuffers),
              mHistogramType(HISTOGRAM_TYPE_UNKNOWN) {}
              mHistogramType(HISTOGRAM_TYPE_UNKNOWN),
              mDynamicRangeProfile(dynamicRangeProfile) {}

    virtual status_t readFromParcel(const android::Parcel* parcel) override;
    virtual status_t writeToParcel(android::Parcel* parcel) const override;
+7 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public:
    int                        getSurfaceType() const;
    int                        getWidth() const;
    int                        getHeight() const;
    int                        getDynamicRangeProfile() const;
    bool                       isDeferred() const;
    bool                       isShared() const;
    String16                   getPhysicalCameraId() const;
@@ -89,7 +90,8 @@ public:
                gbpsEqual(other) &&
                mPhysicalCameraId == other.mPhysicalCameraId &&
                mIsMultiResolution == other.mIsMultiResolution &&
                sensorPixelModesUsedEqual(other));
                sensorPixelModesUsedEqual(other) &&
                mDynamicRangeProfile == other.mDynamicRangeProfile);
    }
    bool operator != (const OutputConfiguration& other) const {
        return !(*this == other);
@@ -126,6 +128,9 @@ public:
        if (!sensorPixelModesUsedEqual(other)) {
            return sensorPixelModesUsedLessThan(other);
        }
        if (mDynamicRangeProfile != other.mDynamicRangeProfile) {
            return mDynamicRangeProfile < other.mDynamicRangeProfile;
        }
        return gbpsLessThan(other);
    }

@@ -150,6 +155,7 @@ private:
    String16                   mPhysicalCameraId;
    bool                       mIsMultiResolution;
    std::vector<int32_t>       mSensorPixelModesUsed;
    int                        mDynamicRangeProfile;
};
} // namespace params
} // namespace camera2
Loading