From d9fc67ce3c1498a911df39675b61b96ec1364f08 Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Fri, 30 Jan 2015 10:47:22 -0800 Subject: Camera2: framework updates for HAL3.3 keys 1. Return new keys in legacy shim 2. Codegened doc update from the spec change 3. Remove DISABLED mode from available scene mode list to ensure DISABLED is listed iff scene mode is not supported Change-Id: If3dc74ea7e0fe6135722723f211024b604094f59 --- api/current.txt | 3 ++ api/system-current.txt | 3 ++ .../hardware/camera2/CameraCharacteristics.java | 38 ++++++++++++++ .../android/hardware/camera2/CaptureRequest.java | 13 +++-- .../android/hardware/camera2/CaptureResult.java | 13 +++-- .../camera2/legacy/LegacyMetadataMapper.java | 58 +++++++++++++++++++--- 6 files changed, 114 insertions(+), 14 deletions(-) diff --git a/api/current.txt b/api/current.txt index 2a6d33e..ce01a66 100644 --- a/api/current.txt +++ b/api/current.txt @@ -12697,11 +12697,14 @@ package android.hardware.camera2 { field public static final android.hardware.camera2.CameraCharacteristics.Key[]> CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES; field public static final android.hardware.camera2.CameraCharacteristics.Key> CONTROL_AE_COMPENSATION_RANGE; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AE_COMPENSATION_STEP; + field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AE_LOCK_AVAILABLE; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AF_AVAILABLE_MODES; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AVAILABLE_EFFECTS; + field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AVAILABLE_MODES; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AVAILABLE_SCENE_MODES; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AWB_AVAILABLE_MODES; + field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AWB_LOCK_AVAILABLE; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_MAX_REGIONS_AE; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_MAX_REGIONS_AF; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_MAX_REGIONS_AWB; diff --git a/api/system-current.txt b/api/system-current.txt index 5388ff3..dfe4298 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -12965,11 +12965,14 @@ package android.hardware.camera2 { field public static final android.hardware.camera2.CameraCharacteristics.Key[]> CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES; field public static final android.hardware.camera2.CameraCharacteristics.Key> CONTROL_AE_COMPENSATION_RANGE; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AE_COMPENSATION_STEP; + field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AE_LOCK_AVAILABLE; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AF_AVAILABLE_MODES; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AVAILABLE_EFFECTS; + field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AVAILABLE_MODES; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AVAILABLE_SCENE_MODES; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AWB_AVAILABLE_MODES; + field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_AWB_LOCK_AVAILABLE; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_MAX_REGIONS_AE; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_MAX_REGIONS_AF; field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_MAX_REGIONS_AWB; diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index 5310071..16bc6a4 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -422,6 +422,17 @@ public final class CameraCharacteristics extends CameraMetadata("android.control.aeCompensationStep", Rational.class); /** + *

Whether the camera device supports {@link CaptureRequest#CONTROL_AE_LOCK android.control.aeLock}

+ *

LIMITED or FULL devices will always list true

+ *

This key is available on all devices.

+ * + * @see CaptureRequest#CONTROL_AE_LOCK + */ + @PublicKey + public static final Key CONTROL_AE_LOCK_AVAILABLE = + new Key("android.control.aeLockAvailable", boolean.class); + + /** *

List of auto-focus (AF) modes for {@link CaptureRequest#CONTROL_AF_MODE android.control.afMode} that are * supported by this camera device.

*

Not all the auto-focus modes may be supported by a @@ -469,6 +480,22 @@ public final class CameraCharacteristics extends CameraMetadata("android.control.availableEffects", int[].class); /** + *

List of control modes for {@link CaptureRequest#CONTROL_MODE android.control.mode} that are supported by this camera + * device.

+ *

This list contains control modes that can be set for the camera device. + * LEGACY mode devices will always support AUTO mode. LIMITED and FULL + * devices will always support OFF, AUTO modes.

+ *

Range of valid values:
+ * Any value listed in {@link CaptureRequest#CONTROL_MODE android.control.mode}

+ *

This key is available on all devices.

+ * + * @see CaptureRequest#CONTROL_MODE + */ + @PublicKey + public static final Key CONTROL_AVAILABLE_MODES = + new Key("android.control.availableModes", int[].class); + + /** *

List of scene modes for {@link CaptureRequest#CONTROL_SCENE_MODE android.control.sceneMode} that are supported by this camera * device.

*

This list contains scene modes that can be set for the camera device. @@ -530,6 +557,17 @@ public final class CameraCharacteristics extends CameraMetadata("android.control.awbAvailableModes", int[].class); /** + *

Whether the camera device supports {@link CaptureRequest#CONTROL_AWB_LOCK android.control.awbLock}

+ *

LIMITED or FULL devices will always list true

+ *

This key is available on all devices.

+ * + * @see CaptureRequest#CONTROL_AWB_LOCK + */ + @PublicKey + public static final Key CONTROL_AWB_LOCK_AVAILABLE = + new Key("android.control.awbLockAvailable", boolean.class); + + /** *

List of the maximum number of regions that can be used for metering in * auto-exposure (AE), auto-white balance (AWB), and auto-focus (AF); * this corresponds to the the maximum number of elements in diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index fb37ae5..e1b14cc 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -552,6 +552,8 @@ public final class CaptureRequest extends CameraMetadata> * in this matrix result metadata. The transform should keep the magnitude * of the output color values within [0, 1.0] (assuming input color * values is within the normalized range [0, 1.0]), or clipping may occur.

+ *

The valid range of each matrix element varies on different devices, but + * values within [-1.5, 3.0] are guaranteed not to be clipped.

*

Units: Unitless scale factors

*

Optional - This value may be {@code null} on some devices.

*

Full capability - @@ -575,6 +577,10 @@ public final class CaptureRequest extends CameraMetadata> * TRANSFORM_MATRIX.

*

The gains in the result metadata are the gains actually * applied by the camera device to the current frame.

+ *

The valid range of gains varies on different devices, but gains + * between [1.0, 3.0] are guaranteed not to be clipped. Even if a given + * device allows gains below 1.0, this is usually not recommended because + * this can create color artifacts.

*

Units: Unitless gain factors

*

Optional - This value may be {@code null} on some devices.

*

Full capability - @@ -1239,10 +1245,6 @@ public final class CaptureRequest extends CameraMetadata> * update, as if this frame is never captured. This mode can be used in the scenario * where the application doesn't want a 3A manual control capture to affect * the subsequent auto 3A capture results.

- *

LEGACY mode devices will only support AUTO and USE_SCENE_MODE modes. - * LIMITED mode devices will only support OFF and OFF_KEEP_STATE if they - * support the MANUAL_SENSOR and MANUAL_POST_PROCSESING capabilities. - * FULL mode devices will always support OFF and OFF_KEEP_STATE.

*

Possible values: *

    *
  • {@link #CONTROL_MODE_OFF OFF}
  • @@ -1250,9 +1252,12 @@ public final class CaptureRequest extends CameraMetadata> *
  • {@link #CONTROL_MODE_USE_SCENE_MODE USE_SCENE_MODE}
  • *
  • {@link #CONTROL_MODE_OFF_KEEP_STATE OFF_KEEP_STATE}
  • *

+ *

Available values for this device:
+ * {@link CameraCharacteristics#CONTROL_AVAILABLE_MODES android.control.availableModes}

*

This key is available on all devices.

* * @see CaptureRequest#CONTROL_AF_MODE + * @see CameraCharacteristics#CONTROL_AVAILABLE_MODES * @see #CONTROL_MODE_OFF * @see #CONTROL_MODE_AUTO * @see #CONTROL_MODE_USE_SCENE_MODE diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index 5642f6f..5bf5b29 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -403,6 +403,8 @@ public class CaptureResult extends CameraMetadata> { * in this matrix result metadata. The transform should keep the magnitude * of the output color values within [0, 1.0] (assuming input color * values is within the normalized range [0, 1.0]), or clipping may occur.

+ *

The valid range of each matrix element varies on different devices, but + * values within [-1.5, 3.0] are guaranteed not to be clipped.

*

Units: Unitless scale factors

*

Optional - This value may be {@code null} on some devices.

*

Full capability - @@ -426,6 +428,10 @@ public class CaptureResult extends CameraMetadata> { * TRANSFORM_MATRIX.

*

The gains in the result metadata are the gains actually * applied by the camera device to the current frame.

+ *

The valid range of gains varies on different devices, but gains + * between [1.0, 3.0] are guaranteed not to be clipped. Even if a given + * device allows gains below 1.0, this is usually not recommended because + * this can create color artifacts.

*

Units: Unitless gain factors

*

Optional - This value may be {@code null} on some devices.

*

Full capability - @@ -1855,10 +1861,6 @@ public class CaptureResult extends CameraMetadata> { * update, as if this frame is never captured. This mode can be used in the scenario * where the application doesn't want a 3A manual control capture to affect * the subsequent auto 3A capture results.

- *

LEGACY mode devices will only support AUTO and USE_SCENE_MODE modes. - * LIMITED mode devices will only support OFF and OFF_KEEP_STATE if they - * support the MANUAL_SENSOR and MANUAL_POST_PROCSESING capabilities. - * FULL mode devices will always support OFF and OFF_KEEP_STATE.

*

Possible values: *

    *
  • {@link #CONTROL_MODE_OFF OFF}
  • @@ -1866,9 +1868,12 @@ public class CaptureResult extends CameraMetadata> { *
  • {@link #CONTROL_MODE_USE_SCENE_MODE USE_SCENE_MODE}
  • *
  • {@link #CONTROL_MODE_OFF_KEEP_STATE OFF_KEEP_STATE}
  • *

+ *

Available values for this device:
+ * {@link CameraCharacteristics#CONTROL_AVAILABLE_MODES android.control.availableModes}

*

This key is available on all devices.

* * @see CaptureRequest#CONTROL_AF_MODE + * @see CameraCharacteristics#CONTROL_AVAILABLE_MODES * @see #CONTROL_MODE_OFF * @see #CONTROL_MODE_AUTO * @see #CONTROL_MODE_USE_SCENE_MODE diff --git a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java index 347db05..802b938 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java +++ b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java @@ -474,6 +474,15 @@ public class LegacyMetadataMapper { m.set(CONTROL_AE_COMPENSATION_STEP, ParamsUtils.createRational(step)); } + + /* + * control.aeLockAvailable + */ + { + boolean aeLockAvailable = p.isAutoExposureLockSupported(); + + m.set(CONTROL_AE_LOCK_AVAILABLE, aeLockAvailable); + } } @@ -571,6 +580,16 @@ public class LegacyMetadataMapper { Log.v(TAG, "mapControlAwb - control.awbAvailableModes set to " + ListUtils.listToString(awbAvail)); } + + + /* + * control.awbLockAvailable + */ + { + boolean awbLockAvailable = p.isAutoWhiteBalanceLockSupported(); + + m.set(CONTROL_AWB_LOCK_AVAILABLE, awbLockAvailable); + } } } @@ -618,17 +637,44 @@ public class LegacyMetadataMapper { /* * android.control.availableSceneModes */ + int maxNumDetectedFaces = p.getMaxNumDetectedFaces(); List sceneModes = p.getSupportedSceneModes(); List supportedSceneModes = ArrayUtils.convertStringListToIntList(sceneModes, sLegacySceneModes, sSceneModes); - if (supportedSceneModes == null) { // camera1 doesn't support scene mode settings - supportedSceneModes = new ArrayList(); - supportedSceneModes.add(CONTROL_SCENE_MODE_DISABLED); // disabled is always available + + // Special case where the only scene mode listed is AUTO => no scene mode + if (sceneModes != null && sceneModes.size() == 1 && + sceneModes.get(0) == Parameters.SCENE_MODE_AUTO) { + supportedSceneModes = null; } - if (p.getMaxNumDetectedFaces() > 0) { // always supports FACE_PRIORITY when face detecting - supportedSceneModes.add(CONTROL_SCENE_MODE_FACE_PRIORITY); + + boolean sceneModeSupported = true; + if (supportedSceneModes == null && maxNumDetectedFaces == 0) { + sceneModeSupported = false; } - m.set(CONTROL_AVAILABLE_SCENE_MODES, ArrayUtils.toIntArray(supportedSceneModes)); + + if (sceneModeSupported) { + if (supportedSceneModes == null) { + supportedSceneModes = new ArrayList(); + } + if (maxNumDetectedFaces > 0) { // always supports FACE_PRIORITY when face detecting + supportedSceneModes.add(CONTROL_SCENE_MODE_FACE_PRIORITY); + } + // Remove all DISABLED occurrences + if (supportedSceneModes.contains(CONTROL_SCENE_MODE_DISABLED)) { + while(supportedSceneModes.remove(new Integer(CONTROL_SCENE_MODE_DISABLED))) {} + } + m.set(CONTROL_AVAILABLE_SCENE_MODES, ArrayUtils.toIntArray(supportedSceneModes)); + } else { + m.set(CONTROL_AVAILABLE_SCENE_MODES, new int[] {CONTROL_SCENE_MODE_DISABLED}); + } + + /* + * android.control.availableModes + */ + m.set(CONTROL_AVAILABLE_MODES, sceneModeSupported ? + new int[] { CONTROL_MODE_AUTO, CONTROL_MODE_USE_SCENE_MODE } : + new int[] { CONTROL_MODE_AUTO }); } private static void mapLens(CameraMetadataNative m, Camera.Parameters p) { -- cgit v1.1