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

Commit 91f4d303 authored by Shuzhen Wang's avatar Shuzhen Wang Committed by Android (Google) Code Review
Browse files

Merge "Camera: Add flag for zoom method metadata tag" into main

parents 0e95e7c2 ae987e14
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -218,3 +218,11 @@ flag {
    description: "Indicates when to activate Night Mode Camera Extension"
    bug: "335902696"
}

flag {
    namespace: "camera_platform"
    name: "zoom_method"
    is_exported: true
    description: "Gives apps explicit control on reflects zoom via ZOOM_RATIO capture result"
    bug: "298899993"
}
+1 −0
Original line number Diff line number Diff line
@@ -562,6 +562,7 @@ ACameraMetadata::isCaptureRequestTag(const uint32_t tag) {
        case ACAMERA_CONTROL_ZOOM_RATIO:
        case ACAMERA_CONTROL_SETTINGS_OVERRIDE:
        case ACAMERA_CONTROL_AUTOFRAMING:
        case ACAMERA_CONTROL_ZOOM_METHOD:
        case ACAMERA_EDGE_MODE:
        case ACAMERA_FLASH_MODE:
        case ACAMERA_FLASH_STRENGTH_LEVEL:
+34 −0
Original line number Diff line number Diff line
@@ -2401,6 +2401,40 @@ typedef enum acamera_metadata_tag {
     */
    ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE =                     // byte (acamera_metadata_enum_android_control_low_light_boost_state_t)
            ACAMERA_CONTROL_START + 59,
    /**
     * <p>Whether the application uses ACAMERA_SCALER_CROP_REGION or ACAMERA_CONTROL_ZOOM_RATIO
     * to control zoom levels.</p>
     *
     * @see ACAMERA_CONTROL_ZOOM_RATIO
     * @see ACAMERA_SCALER_CROP_REGION
     *
     * <p>Type: byte (acamera_metadata_enum_android_control_zoom_method_t)</p>
     *
     * <p>This tag may appear in:
     * <ul>
     *   <li>ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks</li>
     *   <li>ACaptureRequest</li>
     * </ul></p>
     *
     * <p>If set to AUTO, the camera device detects which capture request key the application uses
     * to do zoom, ACAMERA_SCALER_CROP_REGION or ACAMERA_CONTROL_ZOOM_RATIO. If
     * the application doesn't set android.scaler.zoomRatio or sets it to 1.0 in the capture
     * request, the effective zoom level is reflected in ACAMERA_SCALER_CROP_REGION in capture
     * results. If ACAMERA_CONTROL_ZOOM_RATIO is set to values other than 1.0, the effective
     * zoom level is reflected in ACAMERA_CONTROL_ZOOM_RATIO. AUTO is the default value
     * for this control, and also the behavior of the OS before Android version
     * <a href="https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#BAKLAVA">BAKLAVA</a>.</p>
     * <p>If set to ZOOM_RATIO, the application explicitly specifies zoom level be controlled
     * by ACAMERA_CONTROL_ZOOM_RATIO, and the effective zoom level is reflected in
     * ACAMERA_CONTROL_ZOOM_RATIO in capture results. This addresses an ambiguity with AUTO,
     * with which the camera device cannot know if the application is using cropRegion or
     * zoomRatio at 1.0x.</p>
     *
     * @see ACAMERA_CONTROL_ZOOM_RATIO
     * @see ACAMERA_SCALER_CROP_REGION
     */
    ACAMERA_CONTROL_ZOOM_METHOD =                               // byte (acamera_metadata_enum_android_control_zoom_method_t)
            ACAMERA_CONTROL_START + 60,
    ACAMERA_CONTROL_END,
    /**
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ std::map<int, std::vector<camera_metadata_tag>> dynamic_api_level_to_keys{
      {36, {
          ANDROID_COLOR_CORRECTION_COLOR_TEMPERATURE,
          ANDROID_COLOR_CORRECTION_COLOR_TINT,
          ANDROID_CONTROL_ZOOM_METHOD,
          ANDROID_EXTENSION_NIGHT_MODE_INDICATOR,
        }  },
};
+12 −3
Original line number Diff line number Diff line
@@ -2885,7 +2885,7 @@ status_t Camera3Device::registerInFlight(uint32_t frameNumber,
        bool hasAppCallback, nsecs_t minExpectedDuration, nsecs_t maxExpectedDuration,
        bool isFixedFps, const std::set<std::set<std::string>>& physicalCameraIds,
        bool isStillCapture, bool isZslCapture, bool rotateAndCropAuto, bool autoframingAuto,
        const std::set<std::string>& cameraIdsWithZoom,
        const std::set<std::string>& cameraIdsWithZoom, bool useZoomRatio,
        const SurfaceMap& outputSurfaces, nsecs_t requestTimeNs) {
    ATRACE_CALL();
    std::lock_guard<std::mutex> l(mInFlightLock);
@@ -2894,7 +2894,7 @@ status_t Camera3Device::registerInFlight(uint32_t frameNumber,
    res = mInFlightMap.add(frameNumber, InFlightRequest(numBuffers, resultExtras, hasInput,
            hasAppCallback, minExpectedDuration, maxExpectedDuration, isFixedFps, physicalCameraIds,
            isStillCapture, isZslCapture, rotateAndCropAuto, autoframingAuto, cameraIdsWithZoom,
            requestTimeNs, outputSurfaces));
            useZoomRatio, requestTimeNs, outputSurfaces));
    if (res < 0) return res;

    if (mInFlightMap.size() == 1) {
@@ -4182,6 +4182,7 @@ status_t Camera3Device::RequestThread::prepareHalRequests() {
        }
        bool isStillCapture = false;
        bool isZslCapture = false;
        bool useZoomRatio = false;
        const camera_metadata_t* settings = halRequest->settings;
        bool shouldUnlockSettings = false;
        if (settings == nullptr) {
@@ -4201,6 +4202,14 @@ status_t Camera3Device::RequestThread::prepareHalRequests() {
            if ((e.count > 0) && (e.data.u8[0] == ANDROID_CONTROL_ENABLE_ZSL_TRUE)) {
                isZslCapture = true;
            }

            if (flags::zoom_method()) {
                e = camera_metadata_ro_entry_t();
                find_camera_metadata_ro_entry(settings, ANDROID_CONTROL_ZOOM_METHOD, &e);
                if ((e.count > 0) && (e.data.u8[0] == ANDROID_CONTROL_ZOOM_METHOD_ZOOM_RATIO)) {
                    useZoomRatio = true;
                }
            }
        }
        bool passSurfaceMap =
                mUseHalBufManager || containsHalBufferManagedStream;
@@ -4214,7 +4223,7 @@ status_t Camera3Device::RequestThread::prepareHalRequests() {
                expectedDurationInfo.isFixedFps,
                requestedPhysicalCameras, isStillCapture, isZslCapture,
                captureRequest->mRotateAndCropAuto, captureRequest->mAutoframingAuto,
                mPrevCameraIdsWithZoom,
                mPrevCameraIdsWithZoom, useZoomRatio,
                passSurfaceMap ? uniqueSurfaceIdMap :
                                      SurfaceMap{}, captureRequest->mRequestTimeNs);
        ALOGVV("%s: registered in flight requestId = %" PRId32 ", frameNumber = %" PRId64
Loading