Ari Hausman-Cohen | cd9fef6 | 2016-07-15 15:54:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "v4l2_metadata.h" |
| 18 | |
| 19 | #include <camera/CameraMetadata.h> |
| 20 | |
| 21 | #include "common.h" |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 22 | #include "metadata/fixed_property.h" |
Ari Hausman-Cohen | 183ffc3 | 2016-08-02 12:35:36 -0700 | [diff] [blame] | 23 | #include "metadata/ignored_control.h" |
Ari Hausman-Cohen | c7abfe7 | 2016-08-08 16:03:40 -0700 | [diff] [blame^] | 24 | #include "metadata/v4l2_enum_control.h" |
Ari Hausman-Cohen | cd9fef6 | 2016-07-15 15:54:13 -0700 | [diff] [blame] | 25 | |
| 26 | namespace v4l2_camera_hal { |
| 27 | |
Ari Hausman-Cohen | c7abfe7 | 2016-08-08 16:03:40 -0700 | [diff] [blame^] | 28 | V4L2Metadata::V4L2Metadata(std::shared_ptr<V4L2Wrapper> device) |
| 29 | : device_(std::move(device)) { |
Ari Hausman-Cohen | cd9fef6 | 2016-07-15 15:54:13 -0700 | [diff] [blame] | 30 | HAL_LOG_ENTER(); |
| 31 | |
Ari Hausman-Cohen | c7abfe7 | 2016-08-08 16:03:40 -0700 | [diff] [blame^] | 32 | // TODO: Temporarily connect to the device so that V4L2-specific components |
| 33 | // can make any necessary queries. |
| 34 | |
Ari Hausman-Cohen | 10481a3 | 2016-08-02 10:41:27 -0700 | [diff] [blame] | 35 | // TODO(b/30140438): Add all metadata components used by V4L2Camera here. |
Ari Hausman-Cohen | c7abfe7 | 2016-08-08 16:03:40 -0700 | [diff] [blame^] | 36 | // Currently these are all the fixed properties, ignored controls, and |
| 37 | // V4L2 enum controls. Will add the other properties as more PartialMetadata |
| 38 | // subclasses get implemented. |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 39 | |
Ari Hausman-Cohen | 183ffc3 | 2016-08-02 12:35:36 -0700 | [diff] [blame] | 40 | AddComponent( |
| 41 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 42 | ANDROID_COLOR_CORRECTION_ABERRATION_MODE, |
| 43 | ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, |
| 44 | {ANDROID_COLOR_CORRECTION_ABERRATION_MODE_FAST, |
| 45 | ANDROID_COLOR_CORRECTION_ABERRATION_MODE_HIGH_QUALITY}, |
| 46 | ANDROID_COLOR_CORRECTION_ABERRATION_MODE_FAST))); |
| 47 | |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 48 | // TODO(b/30510395): subcomponents of 3A. |
Ari Hausman-Cohen | c7abfe7 | 2016-08-08 16:03:40 -0700 | [diff] [blame^] | 49 | // In general, default to ON/AUTO since they imply pretty much nothing, |
| 50 | // while OFF implies guarantees about not hindering performance. |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 51 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 52 | new FixedProperty<std::array<int32_t, 3>>( |
| 53 | ANDROID_CONTROL_MAX_REGIONS, {{/*AE*/ 0, /*AWB*/ 0, /*AF*/ 0}}))); |
Ari Hausman-Cohen | c7abfe7 | 2016-08-08 16:03:40 -0700 | [diff] [blame^] | 54 | AddEnumControlOrDefault(V4L2_CID_EXPOSURE_AUTO, ANDROID_CONTROL_AE_MODE, |
| 55 | ANDROID_CONTROL_AE_AVAILABLE_MODES, |
| 56 | {{V4L2_EXPOSURE_AUTO, ANDROID_CONTROL_AE_MODE_ON}, |
| 57 | {V4L2_EXPOSURE_MANUAL, ANDROID_CONTROL_AE_MODE_OFF}}, |
| 58 | ANDROID_CONTROL_AE_MODE_ON); |
| 59 | AddEnumControlOrDefault(V4L2_CID_POWER_LINE_FREQUENCY, |
| 60 | ANDROID_CONTROL_AE_ANTIBANDING_MODE, |
| 61 | ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, |
| 62 | {{V4L2_CID_POWER_LINE_FREQUENCY_DISABLED, |
| 63 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF}, |
| 64 | {V4L2_CID_POWER_LINE_FREQUENCY_50HZ, |
| 65 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ}, |
| 66 | {V4L2_CID_POWER_LINE_FREQUENCY_60HZ, |
| 67 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ}, |
| 68 | {V4L2_CID_POWER_LINE_FREQUENCY_AUTO, |
| 69 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO}}, |
| 70 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO); |
| 71 | // V4L2 offers multiple white balance interfaces. Try the advanced one before |
| 72 | // falling |
| 73 | // back to the simpler version. |
| 74 | // Modes from each API that don't match up: |
| 75 | // Android: WARM_FLUORESCENT, TWILIGHT. |
| 76 | // V4L2: FLUORESCENT_H, HORIZON, FLASH. |
| 77 | std::unique_ptr<PartialMetadataInterface> awb( |
| 78 | V4L2EnumControl::NewV4L2EnumControl( |
| 79 | device_, V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE, |
| 80 | ANDROID_CONTROL_AWB_MODE, ANDROID_CONTROL_AWB_AVAILABLE_MODES, |
| 81 | {{V4L2_WHITE_BALANCE_MANUAL, ANDROID_CONTROL_AWB_MODE_OFF}, |
| 82 | {V4L2_WHITE_BALANCE_AUTO, ANDROID_CONTROL_AWB_MODE_AUTO}, |
| 83 | {V4L2_WHITE_BALANCE_INCANDESCENT, |
| 84 | ANDROID_CONTROL_AWB_MODE_INCANDESCENT}, |
| 85 | {V4L2_WHITE_BALANCE_FLUORESCENT, |
| 86 | ANDROID_CONTROL_AWB_MODE_FLUORESCENT}, |
| 87 | {V4L2_WHITE_BALANCE_DAYLIGHT, ANDROID_CONTROL_AWB_MODE_DAYLIGHT}, |
| 88 | {V4L2_WHITE_BALANCE_CLOUDY, |
| 89 | ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT}, |
| 90 | {V4L2_WHITE_BALANCE_SHADE, ANDROID_CONTROL_AWB_MODE_SHADE}})); |
| 91 | if (awb) { |
| 92 | AddComponent(std::move(awb)); |
| 93 | } else { |
| 94 | // Fall back to simpler AWB or even just an ignored control. |
| 95 | AddEnumControlOrDefault( |
| 96 | V4L2_CID_AUTO_WHITE_BALANCE, ANDROID_CONTROL_AWB_MODE, |
| 97 | ANDROID_CONTROL_AWB_AVAILABLE_MODES, |
| 98 | {{0, ANDROID_CONTROL_AWB_MODE_OFF}, {1, ANDROID_CONTROL_AWB_MODE_AUTO}}, |
| 99 | ANDROID_CONTROL_AWB_MODE_AUTO); |
| 100 | } |
| 101 | // TODO(b/30510395): subcomponents of scene modes |
| 102 | // (may itself be a subcomponent of 3A). |
| 103 | // Modes from each API that don't match up: |
| 104 | // Android: FACE_PRIORITY, ACTION, NIGHT_PORTRAIT, THEATRE, STEADYPHOTO, |
| 105 | // BARCODE, HIGH_SPEED_VIDEO, SNOW (combined with BEACH in V4L2. Only BEACH |
| 106 | // is reported to avoid ambiguity). |
| 107 | // V4L2: BACKLIGHT, DAWN_DUSK, FALL_COLORS, TEXT. |
| 108 | AddEnumControlOrDefault( |
| 109 | V4L2_CID_SCENE_MODE, ANDROID_CONTROL_SCENE_MODE, |
| 110 | ANDROID_CONTROL_AVAILABLE_SCENE_MODES, |
| 111 | {{V4L2_SCENE_MODE_NONE, ANDROID_CONTROL_SCENE_MODE_DISABLED}, |
| 112 | {V4L2_SCENE_MODE_BEACH_SNOW, ANDROID_CONTROL_SCENE_MODE_BEACH}, |
| 113 | {V4L2_SCENE_MODE_CANDLE_LIGHT, ANDROID_CONTROL_SCENE_MODE_CANDLELIGHT}, |
| 114 | {V4L2_SCENE_MODE_FIREWORKS, ANDROID_CONTROL_SCENE_MODE_FIREWORKS}, |
| 115 | {V4L2_SCENE_MODE_LANDSCAPE, ANDROID_CONTROL_SCENE_MODE_LANDSCAPE}, |
| 116 | {V4L2_SCENE_MODE_NIGHT, ANDROID_CONTROL_SCENE_MODE_NIGHT}, |
| 117 | {V4L2_SCENE_MODE_PARTY_INDOOR, ANDROID_CONTROL_SCENE_MODE_PARTY}, |
| 118 | {V4L2_SCENE_MODE_SPORTS, ANDROID_CONTROL_SCENE_MODE_SPORTS}, |
| 119 | {V4L2_SCENE_MODE_SUNSET, ANDROID_CONTROL_SCENE_MODE_SUNSET}}, |
| 120 | ANDROID_CONTROL_SCENE_MODE_DISABLED); |
| 121 | // Modes from each API that don't match up: |
| 122 | // Android: POSTERIZE, WHITEBOARD, BLACKBOARD. |
| 123 | // V4L2: ANTIQUE, ART_FREEZE, EMBOSS, GRASS_GREEN, SKETCH, SKIN_WHITEN, |
| 124 | // SKY_BLUE, SILHOUETTE, VIVID, SET_CBCR. |
| 125 | AddEnumControlOrDefault( |
| 126 | V4L2_CID_COLORFX, ANDROID_CONTROL_EFFECT_MODE, |
| 127 | ANDROID_CONTROL_AVAILABLE_EFFECTS, |
| 128 | {{V4L2_COLORFX_NONE, ANDROID_CONTROL_EFFECT_MODE_OFF}, |
| 129 | {V4L2_COLORFX_BW, ANDROID_CONTROL_EFFECT_MODE_MONO}, |
| 130 | {V4L2_COLORFX_NEGATIVE, ANDROID_CONTROL_EFFECT_MODE_NEGATIVE}, |
| 131 | {V4L2_COLORFX_SOLARIZATION, ANDROID_CONTROL_EFFECT_MODE_SOLARIZE}, |
| 132 | {V4L2_COLORFX_SEPIA, ANDROID_CONTROL_EFFECT_MODE_SEPIA}, |
| 133 | {V4L2_COLORFX_AQUA, ANDROID_CONTROL_EFFECT_MODE_AQUA}}, |
| 134 | ANDROID_CONTROL_EFFECT_MODE_OFF); |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 135 | |
Ari Hausman-Cohen | 183ffc3 | 2016-08-02 12:35:36 -0700 | [diff] [blame] | 136 | // Not sure if V4L2 does or doesn't do this, but HAL documentation says |
| 137 | // all devices must support FAST, and FAST can be equivalent to OFF, so |
| 138 | // either way it's fine to list. |
| 139 | AddComponent( |
| 140 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 141 | ANDROID_EDGE_MODE, ANDROID_EDGE_AVAILABLE_EDGE_MODES, |
| 142 | {ANDROID_EDGE_MODE_FAST}, ANDROID_EDGE_MODE_FAST))); |
| 143 | |
| 144 | // TODO(30510395): subcomponents of hotpixel. |
| 145 | // No known V4L2 hot pixel correction. But it might be happening, |
| 146 | // so we report FAST/HIGH_QUALITY. |
| 147 | AddComponent( |
| 148 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 149 | ANDROID_HOT_PIXEL_MODE, ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES, |
| 150 | {ANDROID_HOT_PIXEL_MODE_FAST, ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY}, |
| 151 | ANDROID_HOT_PIXEL_MODE_FAST))); |
| 152 | // ON only needs to be supported for RAW capable devices. |
| 153 | AddComponent( |
| 154 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 155 | ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE, |
| 156 | ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES, |
| 157 | {ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF}, |
| 158 | ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF))); |
| 159 | |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 160 | // TODO(30510395): subcomponents focus/lens. |
Ari Hausman-Cohen | 183ffc3 | 2016-08-02 12:35:36 -0700 | [diff] [blame] | 161 | // No way to actually get the aperture and focal length |
| 162 | // in V4L2, but they're required keys, so fake them. |
| 163 | AddComponent( |
| 164 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<float>( |
| 165 | ANDROID_LENS_APERTURE, ANDROID_LENS_INFO_AVAILABLE_APERTURES, {2.0}, |
| 166 | 2.0))); // RPi camera v2 is f/2.0. |
| 167 | AddComponent( |
| 168 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<float>( |
| 169 | ANDROID_LENS_FOCAL_LENGTH, ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, |
| 170 | {3.04}, 3.04))); // RPi camera v2 is 3.04mm. |
| 171 | // No known way to get filter densities from V4L2, |
| 172 | // report 0 to indicate this control is not supported. |
| 173 | AddComponent( |
| 174 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<float>( |
| 175 | ANDROID_LENS_FILTER_DENSITY, |
| 176 | ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES, {0.0}, 0.0))); |
| 177 | // V4L2 focal units do not correspond to a particular physical unit. |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 178 | AddComponent( |
| 179 | std::unique_ptr<PartialMetadataInterface>(new FixedProperty<uint8_t>( |
| 180 | ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION, |
| 181 | ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED))); |
Ari Hausman-Cohen | 183ffc3 | 2016-08-02 12:35:36 -0700 | [diff] [blame] | 182 | // info.hyperfocalDistance not required for UNCALIBRATED. |
| 183 | // No known V4L2 lens shading. But it might be happening, |
| 184 | // so report FAST/HIGH_QUALITY. |
| 185 | AddComponent( |
| 186 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 187 | ANDROID_SHADING_MODE, ANDROID_SHADING_AVAILABLE_MODES, |
| 188 | {ANDROID_SHADING_MODE_FAST, ANDROID_SHADING_MODE_HIGH_QUALITY}, |
| 189 | ANDROID_SHADING_MODE_FAST))); |
| 190 | // ON only needs to be supported for RAW capable devices. |
| 191 | AddComponent( |
| 192 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 193 | ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, |
| 194 | ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES, |
| 195 | {ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF}, |
| 196 | ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF))); |
Ari Hausman-Cohen | c7abfe7 | 2016-08-08 16:03:40 -0700 | [diff] [blame^] | 197 | // V4L2 doesn't differentiate between OPTICAL and VIDEO stabilization, |
| 198 | // so only report one (and report the other as OFF). |
| 199 | AddEnumControlOrDefault(V4L2_CID_IMAGE_STABILIZATION, |
| 200 | ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, |
| 201 | ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, |
| 202 | {{0, ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF}, |
| 203 | {1, ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON}}, |
| 204 | ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF); |
| 205 | AddComponent( |
| 206 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 207 | ANDROID_LENS_OPTICAL_STABILIZATION_MODE, |
| 208 | ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, |
| 209 | {ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF}, |
| 210 | ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF))); |
Ari Hausman-Cohen | 183ffc3 | 2016-08-02 12:35:36 -0700 | [diff] [blame] | 211 | |
| 212 | // Unable to control noise reduction in V4L2 devices, |
| 213 | // but FAST is allowed to be the same as OFF. |
| 214 | AddComponent( |
| 215 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 216 | ANDROID_NOISE_REDUCTION_MODE, |
| 217 | ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, |
| 218 | {ANDROID_NOISE_REDUCTION_MODE_FAST}, |
| 219 | ANDROID_NOISE_REDUCTION_MODE_FAST))); |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 220 | |
| 221 | // TODO(30510395): subcomponents of formats/streams. |
Ari Hausman-Cohen | 183ffc3 | 2016-08-02 12:35:36 -0700 | [diff] [blame] | 222 | // For now, no thumbnails available (only [0,0], the "no thumbnail" size). |
| 223 | // TODO(b/29580107): Could end up with a mismatch between request & result, |
| 224 | // since V4L2 doesn't actually allow for thumbnail size control. |
| 225 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 226 | new IgnoredControl<std::array<int32_t, 2>>( |
| 227 | ANDROID_JPEG_THUMBNAIL_SIZE, ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, |
| 228 | {{{0, 0}}}, {{0, 0}}))); |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 229 | // TODO(b/29939583): V4L2 can only support 1 stream at a time. |
| 230 | // For now, just reporting minimum allowable for LIMITED devices. |
| 231 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 232 | new FixedProperty<std::array<int32_t, 3>>( |
| 233 | ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, |
| 234 | {{/* Raw */ 0, /* Non-stalling */ 2, /* Stalling */ 1}}))); |
| 235 | // Reprocessing not supported. |
| 236 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 237 | new FixedProperty<int32_t>(ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, 0))); |
| 238 | // No way to know pipeline depth for V4L2, so fake with max allowable latency. |
| 239 | // Doesn't mean much without per-frame controls anyways. |
| 240 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 241 | new FixedProperty<uint8_t>(ANDROID_REQUEST_PIPELINE_MAX_DEPTH, 4))); |
| 242 | // "LIMITED devices are strongly encouraged to use a non-negative value. |
| 243 | // If UNKNOWN is used here then app developers do not have a way to know |
| 244 | // when sensor settings have been applied." - Unfortunately, V4L2 doesn't |
| 245 | // really help here either. Could even be that adjusting settings mid-stream |
| 246 | // blocks in V4L2, and should be avoided. |
| 247 | AddComponent( |
| 248 | std::unique_ptr<PartialMetadataInterface>(new FixedProperty<int32_t>( |
| 249 | ANDROID_SYNC_MAX_LATENCY, ANDROID_SYNC_MAX_LATENCY_UNKNOWN))); |
| 250 | |
| 251 | // TODO(30510395): subcomponents of cropping/sensors. |
| 252 | // V4L2 VIDIOC_CROPCAP doesn't give a way to query this; |
| 253 | // it's driver dependent. For now, assume freeform, and |
| 254 | // some cameras may just behave badly. |
| 255 | // TODO(b/29579652): Figure out a way to determine this. |
| 256 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 257 | new FixedProperty<uint8_t>(ANDROID_SCALER_CROPPING_TYPE, |
| 258 | ANDROID_SCALER_CROPPING_TYPE_FREEFORM))); |
| 259 | // No way to get in V4L2, so faked. RPi camera v2 is 3.674 x 2.760 mm. |
| 260 | // Physical size is used in framework calculations (field of view, |
| 261 | // pixel pitch, etc.), so faking it may have unexpected results. |
| 262 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 263 | new FixedProperty<std::array<float, 2>>(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, |
| 264 | {{3.674, 2.760}}))); |
| 265 | // HAL uses BOOTTIME timestamps. |
| 266 | // TODO(b/29457051): make sure timestamps are consistent throughout the HAL. |
| 267 | AddComponent( |
| 268 | std::unique_ptr<PartialMetadataInterface>(new FixedProperty<uint8_t>( |
| 269 | ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, |
| 270 | ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN))); |
| 271 | // Noo way to actually get orientation from V4L2. |
| 272 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 273 | new FixedProperty<int32_t>(ANDROID_SENSOR_ORIENTATION, 0))); |
| 274 | |
| 275 | // TODO(30510395): subcomponents of face detection. |
| 276 | // Face detection not supported. |
Ari Hausman-Cohen | 183ffc3 | 2016-08-02 12:35:36 -0700 | [diff] [blame] | 277 | AddComponent( |
| 278 | std::unique_ptr<PartialMetadataInterface>(new IgnoredControl<uint8_t>( |
| 279 | ANDROID_STATISTICS_FACE_DETECT_MODE, |
| 280 | ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, |
| 281 | {ANDROID_STATISTICS_FACE_DETECT_MODE_OFF}, |
| 282 | ANDROID_STATISTICS_FACE_DETECT_MODE_OFF))); |
Ari Hausman-Cohen | ab3a0a4 | 2016-08-02 11:10:56 -0700 | [diff] [blame] | 283 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 284 | new FixedProperty<int32_t>(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, 0))); |
| 285 | |
| 286 | /* Capabilities. */ |
| 287 | // The V4L2Metadata pretends to at least meet the |
| 288 | // "LIMITED" and "BACKWARD_COMPATIBLE" functionality requirements. |
| 289 | AddComponent( |
| 290 | std::unique_ptr<PartialMetadataInterface>(new FixedProperty<uint8_t>( |
| 291 | ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, |
| 292 | ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED))); |
| 293 | AddComponent(std::unique_ptr<PartialMetadataInterface>( |
| 294 | new FixedProperty<std::vector<uint8_t>>( |
| 295 | ANDROID_REQUEST_AVAILABLE_CAPABILITIES, |
| 296 | {ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE}))); |
Ari Hausman-Cohen | cd9fef6 | 2016-07-15 15:54:13 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | V4L2Metadata::~V4L2Metadata() { HAL_LOG_ENTER(); } |
| 300 | |
Ari Hausman-Cohen | c7abfe7 | 2016-08-08 16:03:40 -0700 | [diff] [blame^] | 301 | void V4L2Metadata::AddEnumControlOrDefault( |
| 302 | int v4l2_control, int32_t control_tag, int32_t options_tag, |
| 303 | const std::map<int32_t, uint8_t>& v4l2_to_metadata, uint8_t default_value) { |
| 304 | HAL_LOG_ENTER(); |
| 305 | |
| 306 | std::unique_ptr<PartialMetadataInterface> control( |
| 307 | V4L2EnumControl::NewV4L2EnumControl(device_, v4l2_control, control_tag, |
| 308 | options_tag, v4l2_to_metadata)); |
| 309 | |
| 310 | if (!control) { |
| 311 | control.reset(new IgnoredControl<uint8_t>(control_tag, options_tag, |
| 312 | {default_value}, default_value)); |
| 313 | } |
| 314 | |
| 315 | AddComponent(std::move(control)); |
| 316 | } |
| 317 | |
Ari Hausman-Cohen | cd9fef6 | 2016-07-15 15:54:13 -0700 | [diff] [blame] | 318 | } // namespace v4l2_camera_hal |