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

Commit 5c2a840d authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

camera2: Add fwk-only tags for SCALER_CROP_REGION and metering regions.



Default sensor mode capture requests would have their scaler crop
regions set to the default active / pre-correction array coordinate
system. Cameraserver needs to correct this for max res sensor pixel mode CaptureRequests.
In order to facilitate the correction, we add fwk-only CaptureRequest tags which are set when camera
clients set SCALER_CROP_REGION / metering regions.

Bug: 194143991

Test: CTS

Change-Id: I66393a1e6310f149138be4799f20ced377b11eb4
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 53be09b2
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
@@ -2307,6 +2307,51 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>>
    public static final Key<Float> CONTROL_ZOOM_RATIO =
            new Key<Float>("android.control.zoomRatio", float.class);

    /**
     * <p>Framework-only private key which informs camera fwk that the AF regions has been set
     * by the client and those regions need not be corrected when {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is
     * set to MAXIMUM_RESOLUTION.</p>
     * <p>This must be set to TRUE by the camera2 java fwk when the camera client sets
     * {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     *
     * @see CaptureRequest#CONTROL_AF_REGIONS
     * @see CaptureRequest#SENSOR_PIXEL_MODE
     * @hide
     */
    public static final Key<Boolean> CONTROL_AF_REGIONS_SET =
            new Key<Boolean>("android.control.afRegionsSet", boolean.class);

    /**
     * <p>Framework-only private key which informs camera fwk that the AE regions has been set
     * by the client and those regions need not be corrected when {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is
     * set to MAXIMUM_RESOLUTION.</p>
     * <p>This must be set to TRUE by the camera2 java fwk when the camera client sets
     * {@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     *
     * @see CaptureRequest#CONTROL_AE_REGIONS
     * @see CaptureRequest#SENSOR_PIXEL_MODE
     * @hide
     */
    public static final Key<Boolean> CONTROL_AE_REGIONS_SET =
            new Key<Boolean>("android.control.aeRegionsSet", boolean.class);

    /**
     * <p>Framework-only private key which informs camera fwk that the AF regions has been set
     * by the client and those regions need not be corrected when {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is
     * set to MAXIMUM_RESOLUTION.</p>
     * <p>This must be set to TRUE by the camera2 java fwk when the camera client sets
     * {@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions}.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     *
     * @see CaptureRequest#CONTROL_AWB_REGIONS
     * @see CaptureRequest#SENSOR_PIXEL_MODE
     * @hide
     */
    public static final Key<Boolean> CONTROL_AWB_REGIONS_SET =
            new Key<Boolean>("android.control.awbRegionsSet", boolean.class);

    /**
     * <p>Operation mode for edge
     * enhancement.</p>
@@ -3046,6 +3091,21 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>>
    public static final Key<Integer> SCALER_ROTATE_AND_CROP =
            new Key<Integer>("android.scaler.rotateAndCrop", int.class);

    /**
     * <p>Framework-only private key which informs camera fwk that the scaler crop region
     * ({@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}) has been set by the client and it need
     * not be corrected when {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is set to MAXIMUM_RESOLUTION.</p>
     * <p>This must be set to TRUE by the camera2 java fwk when the camera client sets
     * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     *
     * @see CaptureRequest#SCALER_CROP_REGION
     * @see CaptureRequest#SENSOR_PIXEL_MODE
     * @hide
     */
    public static final Key<Boolean> SCALER_CROP_REGION_SET =
            new Key<Boolean>("android.scaler.cropRegionSet", boolean.class);

    /**
     * <p>Duration each pixel is exposed to
     * light.</p>
+65 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.hardware.camera2.params.Capability;
import android.hardware.camera2.params.Face;
import android.hardware.camera2.params.HighSpeedVideoConfiguration;
import android.hardware.camera2.params.LensShadingMap;
import android.hardware.camera2.params.MeteringRectangle;
import android.hardware.camera2.params.MandatoryStreamCombination;
import android.hardware.camera2.params.MultiResolutionStreamConfigurationMap;
import android.hardware.camera2.params.OisSample;
@@ -1708,6 +1709,34 @@ public class CameraMetadataNative implements Parcelable {
                metadata.setGpsLocation((Location) value);
            }
        });
        sSetCommandMap.put(CaptureRequest.SCALER_CROP_REGION.getNativeKey(),
                new SetCommand() {
            @Override
            public <T> void setValue(CameraMetadataNative metadata, T value) {
                metadata.setScalerCropRegion((Rect) value);
            }
        });
        sSetCommandMap.put(CaptureRequest.CONTROL_AWB_REGIONS.getNativeKey(),
                new SetCommand() {
            @Override
            public <T> void setValue(CameraMetadataNative metadata, T value) {
                metadata.setAWBRegions((MeteringRectangle[]) value);
            }
        });
        sSetCommandMap.put(CaptureRequest.CONTROL_AF_REGIONS.getNativeKey(),
                new SetCommand() {
            @Override
            public <T> void setValue(CameraMetadataNative metadata, T value) {
                metadata.setAFRegions((MeteringRectangle[]) value);
            }
        });
        sSetCommandMap.put(CaptureRequest.CONTROL_AE_REGIONS.getNativeKey(),
                new SetCommand() {
            @Override
            public <T> void setValue(CameraMetadataNative metadata, T value) {
                metadata.setAERegions((MeteringRectangle[]) value);
            }
        });
    }

    private boolean setAvailableFormats(int[] value) {
@@ -1777,6 +1806,42 @@ public class CameraMetadataNative implements Parcelable {
        return true;
    }

    private <T> boolean setScalerCropRegion(Rect cropRegion) {
        if (cropRegion == null) {
            return false;
        }
        setBase(CaptureRequest.SCALER_CROP_REGION_SET, true);
        setBase(CaptureRequest.SCALER_CROP_REGION, cropRegion);
        return true;
    }

    private <T> boolean setAFRegions(MeteringRectangle[] afRegions) {
        if (afRegions == null) {
            return false;
        }
        setBase(CaptureRequest.CONTROL_AF_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AF_REGIONS, afRegions);
        return true;
    }

    private <T> boolean setAERegions(MeteringRectangle[] aeRegions) {
        if (aeRegions == null) {
            return false;
        }
        setBase(CaptureRequest.CONTROL_AE_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AE_REGIONS, aeRegions);
        return true;
    }

    private <T> boolean setAWBRegions(MeteringRectangle[] awbRegions) {
        if (awbRegions == null) {
            return false;
        }
        setBase(CaptureRequest.CONTROL_AWB_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AWB_REGIONS, awbRegions);
        return true;
    }

    private void updateNativeAllocation() {
        long currentBufferSize = nativeGetBufferSize(mMetadataPtr);