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

Commit 4c060997 authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

Camera: derive post RAW sensitivity keys for BC

Derive post RAW sensitivity keys for devices
earlier than HAL3.4.

Bug: 27950762
Change-Id: Icc2232cb722c61a5878a81706885303b15ddee3e
parent 0115a8bf
Loading
Loading
Loading
Loading
+29 −8
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ void CameraModule::deriveCameraCharacteristicsKeys(
    ATRACE_CALL();

    Vector<int32_t> derivedCharKeys;
    Vector<int32_t> derivedRequestKeys;
    Vector<int32_t> derivedResultKeys;
    // Keys added in HAL3.3
    if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_3) {
        Vector<uint8_t> controlModes;
@@ -180,6 +182,9 @@ void CameraModule::deriveCameraCharacteristicsKeys(
                        ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE,
                        defaultRange, 2);
                derivedCharKeys.push(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE);
                // Actual request/results will be derived by camera device.
                derivedRequestKeys.push(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST);
                derivedResultKeys.push(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST);
            }
        }
    }
@@ -196,19 +201,35 @@ void CameraModule::deriveCameraCharacteristicsKeys(

    // Add those newly added keys to AVAILABLE_CHARACTERISTICS_KEYS
    // This has to be done at this end of this function.
    entry = chars.find(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS);
    Vector<int32_t> availableCharsKeys;
    availableCharsKeys.setCapacity(entry.count + derivedCharKeys.size());
    for (size_t i = 0; i < entry.count; i++) {
        availableCharsKeys.push(entry.data.i32[i]);
    if (derivedCharKeys.size() > 0) {
        appendAvailableKeys(
                chars, ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, derivedCharKeys);
    }
    if (derivedRequestKeys.size() > 0) {
        appendAvailableKeys(
                chars, ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, derivedRequestKeys);
    }
    for (size_t i = 0; i < derivedCharKeys.size(); i++) {
        availableCharsKeys.push(derivedCharKeys[i]);
    if (derivedResultKeys.size() > 0) {
        appendAvailableKeys(
                chars, ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, derivedResultKeys);
    }
    chars.update(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, availableCharsKeys);
    return;
}

void CameraModule::appendAvailableKeys(CameraMetadata &chars,
        int32_t keyTag, const Vector<int32_t>& appendKeys) {
    camera_metadata_entry entry = chars.find(keyTag);
    Vector<int32_t> availableKeys;
    availableKeys.setCapacity(entry.count + appendKeys.size());
    for (size_t i = 0; i < entry.count; i++) {
        availableKeys.push(entry.data.i32[i]);
    }
    for (size_t i = 0; i < appendKeys.size(); i++) {
        availableKeys.push(appendKeys[i]);
    }
    chars.update(keyTag, availableKeys);
}

CameraModule::CameraModule(camera_module_t *module) {
    if (module == NULL) {
        ALOGE("%s: camera hardware module must not be null", __FUNCTION__);
+3 −1
Original line number Diff line number Diff line
@@ -57,8 +57,10 @@ public:
private:
    // Derive camera characteristics keys defined after HAL device version
    static void deriveCameraCharacteristicsKeys(uint32_t deviceVersion, CameraMetadata &chars);
    // Helper function to append available[request|result|chars]Keys
    static void appendAvailableKeys(CameraMetadata &chars,
            int32_t keyTag, const Vector<int32_t>& appendKeys);
    status_t filterOpenErrorCode(status_t err);

    camera_module_t *mModule;
    KeyedVector<int, camera_info> mCameraInfoMap;
    Mutex mCameraInfoLock;
+28 −1
Original line number Diff line number Diff line
@@ -200,6 +200,14 @@ status_t Camera3Device::initialize(CameraModule *module)
    mDeviceInfo = info.static_camera_characteristics;
    mHal3Device = device;

    // Determine whether we need to derive sensitivity boost values for older devices.
    // If post-RAW sensitivity boost range is listed, so should post-raw sensitivity control
    // be listed (as the default value 100)
    if (mDeviceVersion < CAMERA_DEVICE_API_VERSION_3_4 &&
            mDeviceInfo.exists(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE)) {
        mDerivePostRawSensKey = true;
    }

    internalUpdateStatusLocked(STATUS_UNCONFIGURED);
    mNextStreamId = 0;
    mDummyStreamId = NO_STREAM;
@@ -1310,9 +1318,19 @@ status_t Camera3Device::createDefaultRequest(int templateId,
              __FUNCTION__, templateId);
        return BAD_VALUE;
    }
    *request = rawRequest;

    mRequestTemplateCache[templateId] = rawRequest;

    // Derive some new keys for backward compatibility
    if (mDerivePostRawSensKey && !mRequestTemplateCache[templateId].exists(
            ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST)) {
        int32_t defaultBoost[1] = {100};
        mRequestTemplateCache[templateId].update(
                ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST,
                defaultBoost, 1);
    }

    *request = mRequestTemplateCache[templateId];
    return OK;
}

@@ -2256,6 +2274,15 @@ void Camera3Device::sendCaptureResult(CameraMetadata &pendingMetadata,
        captureResult.mMetadata.append(collectedPartialResult);
    }

    // Derive some new keys for backward compaibility
    if (mDerivePostRawSensKey && !captureResult.mMetadata.exists(
            ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST)) {
        int32_t defaultBoost[1] = {100};
        captureResult.mMetadata.update(
                ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST,
                defaultBoost, 1);
    }

    captureResult.mMetadata.sort();

    // Check that there's a timestamp in the result metadata
+4 −0
Original line number Diff line number Diff line
@@ -203,6 +203,10 @@ class Camera3Device :

    uint32_t                   mDeviceVersion;

    // whether Camera3Device should derive ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST for
    // backward compatibility. Should not be changed after initialization.
    bool                       mDerivePostRawSensKey = false;

    struct Size {
        uint32_t width;
        uint32_t height;