Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2008, The Android Open Source Project |
| 4 | ** Copyright 2012, Samsung Electronics Co. LTD |
| 5 | ** |
| 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | ** you may not use this file except in compliance with the License. |
| 8 | ** You may obtain a copy of the License at |
| 9 | ** |
| 10 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | ** |
| 12 | ** Unless required by applicable law or agreed to in writing, software |
| 13 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | ** See the License for the specific language governing permissions and |
| 16 | ** limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | /*! |
| 20 | * \file ExynosCamera2.cpp |
| 21 | * \brief source file for static information of camera2 |
| 22 | * \author Sungjoong Kang(sj3.kang@samsung.com) |
| 23 | * \date 2012/08/06 |
| 24 | * |
| 25 | * <b>Revision History: </b> |
| 26 | * - 2012/08/06 : Sungjoong Kang(sj3.kang@samsung.com) \n |
| 27 | * Initial Release |
| 28 | * |
| 29 | */ |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 30 | |
| 31 | //#define LOG_NDEBUG 0 |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 32 | #define LOG_TAG "ExynosCamera2" |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 33 | #include <utils/Log.h> |
| 34 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 35 | #include "ExynosCamera2.h" |
| 36 | |
| 37 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 38 | |
| 39 | namespace android { |
| 40 | |
| 41 | class Sensor { |
| 42 | public: |
| 43 | /** |
| 44 | * Static sensor characteristics |
| 45 | */ |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 46 | static const unsigned int kResolution[2][2]; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 47 | |
| 48 | static const nsecs_t kExposureTimeRange[2]; |
| 49 | static const nsecs_t kFrameDurationRange[2]; |
| 50 | static const nsecs_t kMinVerticalBlank; |
| 51 | |
| 52 | static const uint8_t kColorFilterArrangement; |
| 53 | |
| 54 | // Output image data characteristics |
| 55 | static const uint32_t kMaxRawValue; |
| 56 | static const uint32_t kBlackLevel; |
| 57 | // Sensor sensitivity, approximate |
| 58 | |
| 59 | static const float kSaturationVoltage; |
| 60 | static const uint32_t kSaturationElectrons; |
| 61 | static const float kVoltsPerLuxSecond; |
| 62 | static const float kElectronsPerLuxSecond; |
| 63 | |
| 64 | static const float kBaseGainFactor; |
| 65 | |
| 66 | static const float kReadNoiseStddevBeforeGain; // In electrons |
| 67 | static const float kReadNoiseStddevAfterGain; // In raw digital units |
| 68 | static const float kReadNoiseVarBeforeGain; |
| 69 | static const float kReadNoiseVarAfterGain; |
| 70 | |
| 71 | // While each row has to read out, reset, and then expose, the (reset + |
| 72 | // expose) sequence can be overlapped by other row readouts, so the final |
| 73 | // minimum frame duration is purely a function of row readout time, at least |
| 74 | // if there's a reasonable number of rows. |
| 75 | static const nsecs_t kRowReadoutTime; |
| 76 | |
| 77 | static const uint32_t kAvailableSensitivities[5]; |
| 78 | static const uint32_t kDefaultSensitivity; |
| 79 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 82 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 83 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 84 | const uint32_t Sensor::kAvailableSensitivities[5] = |
| 85 | {100, 200, 400, 800, 1600}; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 86 | const nsecs_t Sensor::kExposureTimeRange[2] = |
| 87 | {1000L, 30000000000L} ; // 1 us - 30 sec |
| 88 | const nsecs_t Sensor::kFrameDurationRange[2] = |
| 89 | {33331760L, 30000000000L}; // ~1/30 s - 30 sec |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 90 | |
| 91 | const uint8_t Sensor::kColorFilterArrangement = ANDROID_SENSOR_RGGB; |
| 92 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 93 | const uint32_t kAvailableFormats[5] = { |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 94 | HAL_PIXEL_FORMAT_RAW_SENSOR, |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 95 | HAL_PIXEL_FORMAT_BLOB, |
| 96 | HAL_PIXEL_FORMAT_RGBA_8888, |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 97 | HAL_PIXEL_FORMAT_YV12, |
| 98 | HAL_PIXEL_FORMAT_YCrCb_420_SP |
| 99 | }; |
| 100 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 101 | // Output image data characteristics |
| 102 | const uint32_t Sensor::kMaxRawValue = 4000; |
| 103 | const uint32_t Sensor::kBlackLevel = 1000; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 104 | |
| 105 | const uint64_t kAvailableRawMinDurations[1] = { |
| 106 | Sensor::kFrameDurationRange[0] |
| 107 | }; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 108 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 109 | const uint64_t kAvailableProcessedMinDurations[1] = { |
| 110 | Sensor::kFrameDurationRange[0] |
| 111 | }; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 112 | const uint64_t kAvailableJpegMinDurations[1] = { |
| 113 | Sensor::kFrameDurationRange[0] |
| 114 | }; |
| 115 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 116 | const int32_t scalerResolutionS5K4E5[] = |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 117 | { |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 118 | 1920, 1080, |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame^] | 119 | 1440, 1080, |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 120 | 1280, 720, |
| 121 | }; |
| 122 | |
| 123 | const int32_t jpegResolutionS5K4E5[] = |
| 124 | { |
| 125 | 2560, 1920, |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame^] | 126 | 2560, 1440, |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 127 | 1280, 720, |
| 128 | }; |
| 129 | |
| 130 | ExynosCamera2InfoS5K4E5::ExynosCamera2InfoS5K4E5() |
| 131 | { |
| 132 | sensorW = 2560; |
| 133 | sensorH = 1920; |
| 134 | sensorRawW = (2560 + 16); |
| 135 | sensorRawH = (1920 + 10); |
| 136 | numScalerResolution = ARRAY_SIZE(scalerResolutionS5K4E5)/2; |
| 137 | scalerResolutions = scalerResolutionS5K4E5; |
| 138 | numJpegResolution = ARRAY_SIZE(jpegResolutionS5K4E5)/2; |
| 139 | jpegResolutions = jpegResolutionS5K4E5; |
| 140 | } |
| 141 | |
| 142 | const int32_t scalerResolutionS5K6A3[] = |
| 143 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame^] | 144 | 1280, 960, |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 145 | 1280, 720, |
| 146 | }; |
| 147 | |
| 148 | const int32_t jpegResolutionS5K6A3[] = |
| 149 | { |
Sungjoong Kang | ad37861 | 2012-08-17 12:34:33 -0700 | [diff] [blame^] | 150 | 1280, 960, |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 151 | 1280, 720, |
| 152 | }; |
| 153 | |
| 154 | ExynosCamera2InfoS5K6A3::ExynosCamera2InfoS5K6A3() |
| 155 | { |
| 156 | sensorW = 1392; |
| 157 | sensorH = 1392; |
| 158 | sensorRawW = (1392 + 16); |
| 159 | sensorRawH = (1392 + 10); |
| 160 | numScalerResolution = ARRAY_SIZE(scalerResolutionS5K6A3)/2; |
| 161 | scalerResolutions = scalerResolutionS5K6A3; |
| 162 | numJpegResolution = ARRAY_SIZE(jpegResolutionS5K6A3)/2; |
| 163 | jpegResolutions = jpegResolutionS5K6A3; |
| 164 | } |
| 165 | |
| 166 | ExynosCamera2::ExynosCamera2(int cameraId): |
| 167 | m_cameraId(cameraId) |
| 168 | { |
| 169 | if (cameraId == 0) |
| 170 | m_curCameraInfo = new ExynosCamera2InfoS5K4E5; |
| 171 | else |
| 172 | m_curCameraInfo = new ExynosCamera2InfoS5K6A3; |
| 173 | } |
| 174 | |
| 175 | ExynosCamera2::~ExynosCamera2() |
| 176 | { |
| 177 | delete m_curCameraInfo; |
| 178 | } |
| 179 | |
| 180 | int32_t ExynosCamera2::getSensorW() |
| 181 | { |
| 182 | return m_curCameraInfo->sensorW; |
| 183 | } |
| 184 | |
| 185 | int32_t ExynosCamera2::getSensorH() |
| 186 | { |
| 187 | return m_curCameraInfo->sensorH; |
| 188 | } |
| 189 | |
| 190 | int32_t ExynosCamera2::getSensorRawW() |
| 191 | { |
| 192 | return m_curCameraInfo->sensorRawW; |
| 193 | } |
| 194 | |
| 195 | int32_t ExynosCamera2::getSensorRawH() |
| 196 | { |
| 197 | return m_curCameraInfo->sensorRawH; |
| 198 | } |
| 199 | |
| 200 | bool ExynosCamera2::isSupportedResolution(int width, int height) |
| 201 | { |
| 202 | int i; |
| 203 | for (i = 0 ; i < m_curCameraInfo->numScalerResolution ; i++) { |
| 204 | if (m_curCameraInfo->scalerResolutions[2*i] == width |
| 205 | && m_curCameraInfo->scalerResolutions[2*i+1] == height) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 206 | return true; |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 207 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 208 | } |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 209 | return false; |
| 210 | } |
| 211 | |
| 212 | bool ExynosCamera2::isSupportedJpegResolution(int width, int height) |
| 213 | { |
| 214 | int i; |
| 215 | for (i = 0 ; i < m_curCameraInfo->numJpegResolution ; i++) { |
| 216 | if (m_curCameraInfo->jpegResolutions[2*i] == width |
| 217 | && m_curCameraInfo->jpegResolutions[2*i+1] == height) { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 218 | return true; |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 219 | } |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 220 | } |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 221 | return false; |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 222 | } |
| 223 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 224 | status_t addOrSize(camera_metadata_t *request, |
| 225 | bool sizeRequest, |
| 226 | size_t *entryCount, |
| 227 | size_t *dataCount, |
| 228 | uint32_t tag, |
| 229 | const void *entryData, |
| 230 | size_t entryDataCount) { |
| 231 | status_t res; |
| 232 | if (!sizeRequest) { |
| 233 | return add_camera_metadata_entry(request, tag, entryData, |
| 234 | entryDataCount); |
| 235 | } else { |
| 236 | int type = get_camera_metadata_tag_type(tag); |
| 237 | if (type < 0 ) return BAD_VALUE; |
| 238 | (*entryCount)++; |
| 239 | (*dataCount) += calculate_camera_metadata_entry_data_size(type, |
| 240 | entryDataCount); |
| 241 | return OK; |
| 242 | } |
| 243 | } |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 244 | |
| 245 | status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info, |
| 246 | int cameraId, bool sizeRequest) { |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 247 | |
| 248 | size_t entryCount = 0; |
| 249 | size_t dataCount = 0; |
| 250 | status_t ret; |
| 251 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 252 | #define ADD_OR_SIZE( tag, data, count ) \ |
| 253 | if ( ( ret = addOrSize(*info, sizeRequest, &entryCount, &dataCount, \ |
| 254 | tag, data, count) ) != OK ) return ret |
| 255 | |
| 256 | // android.lens |
| 257 | |
| 258 | static const float minFocusDistance = 0; |
| 259 | ADD_OR_SIZE(ANDROID_LENS_MINIMUM_FOCUS_DISTANCE, |
| 260 | &minFocusDistance, 1); |
| 261 | ADD_OR_SIZE(ANDROID_LENS_HYPERFOCAL_DISTANCE, |
| 262 | &minFocusDistance, 1); |
| 263 | |
| 264 | static const float focalLength = 3.30f; // mm |
| 265 | ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_FOCAL_LENGTHS, |
| 266 | &focalLength, 1); |
| 267 | static const float aperture = 2.8f; |
| 268 | ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_APERTURES, |
| 269 | &aperture, 1); |
| 270 | static const float filterDensity = 0; |
| 271 | ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_FILTER_DENSITY, |
| 272 | &filterDensity, 1); |
| 273 | static const uint8_t availableOpticalStabilization = |
| 274 | ANDROID_LENS_OPTICAL_STABILIZATION_OFF; |
| 275 | ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_OPTICAL_STABILIZATION, |
| 276 | &availableOpticalStabilization, 1); |
| 277 | |
| 278 | static const int32_t lensShadingMapSize[] = {1, 1}; |
| 279 | ADD_OR_SIZE(ANDROID_LENS_SHADING_MAP_SIZE, lensShadingMapSize, |
| 280 | sizeof(lensShadingMapSize)/sizeof(int32_t)); |
| 281 | |
| 282 | static const float lensShadingMap[3 * 1 * 1 ] = |
| 283 | { 1.f, 1.f, 1.f }; |
| 284 | ADD_OR_SIZE(ANDROID_LENS_SHADING_MAP, lensShadingMap, |
| 285 | sizeof(lensShadingMap)/sizeof(float)); |
| 286 | |
| 287 | // Identity transform |
| 288 | static const int32_t geometricCorrectionMapSize[] = {2, 2}; |
| 289 | ADD_OR_SIZE(ANDROID_LENS_GEOMETRIC_CORRECTION_MAP_SIZE, |
| 290 | geometricCorrectionMapSize, |
| 291 | sizeof(geometricCorrectionMapSize)/sizeof(int32_t)); |
| 292 | |
| 293 | static const float geometricCorrectionMap[2 * 3 * 2 * 2] = { |
| 294 | 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, |
| 295 | 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, |
| 296 | 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, |
| 297 | 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; |
| 298 | ADD_OR_SIZE(ANDROID_LENS_GEOMETRIC_CORRECTION_MAP, |
| 299 | geometricCorrectionMap, |
| 300 | sizeof(geometricCorrectionMap)/sizeof(float)); |
| 301 | |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 302 | int32_t lensFacing = cameraId ? |
| 303 | ANDROID_LENS_FACING_FRONT : ANDROID_LENS_FACING_BACK; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 304 | ADD_OR_SIZE(ANDROID_LENS_FACING, &lensFacing, 1); |
| 305 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 306 | // android.sensor |
| 307 | ADD_OR_SIZE(ANDROID_SENSOR_EXPOSURE_TIME_RANGE, |
| 308 | Sensor::kExposureTimeRange, 2); |
| 309 | |
| 310 | ADD_OR_SIZE(ANDROID_SENSOR_MAX_FRAME_DURATION, |
| 311 | &Sensor::kFrameDurationRange[1], 1); |
| 312 | |
| 313 | ADD_OR_SIZE(ANDROID_SENSOR_AVAILABLE_SENSITIVITIES, |
| 314 | Sensor::kAvailableSensitivities, |
| 315 | sizeof(Sensor::kAvailableSensitivities) |
| 316 | /sizeof(uint32_t)); |
| 317 | |
| 318 | ADD_OR_SIZE(ANDROID_SENSOR_COLOR_FILTER_ARRANGEMENT, |
| 319 | &Sensor::kColorFilterArrangement, 1); |
| 320 | |
| 321 | static const float sensorPhysicalSize[2] = {3.20f, 2.40f}; // mm |
| 322 | ADD_OR_SIZE(ANDROID_SENSOR_PHYSICAL_SIZE, |
| 323 | sensorPhysicalSize, 2); |
| 324 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 325 | int32_t pixelArraySize[2] = { |
| 326 | m_curCameraInfo->sensorW, m_curCameraInfo->sensorH |
| 327 | }; |
| 328 | ADD_OR_SIZE(ANDROID_SENSOR_PIXEL_ARRAY_SIZE, pixelArraySize, 2); |
| 329 | ADD_OR_SIZE(ANDROID_SENSOR_ACTIVE_ARRAY_SIZE, pixelArraySize,2); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 330 | |
| 331 | ADD_OR_SIZE(ANDROID_SENSOR_WHITE_LEVEL, |
| 332 | &Sensor::kMaxRawValue, 1); |
| 333 | |
| 334 | static const int32_t blackLevelPattern[4] = { |
| 335 | Sensor::kBlackLevel, Sensor::kBlackLevel, |
| 336 | Sensor::kBlackLevel, Sensor::kBlackLevel |
| 337 | }; |
| 338 | ADD_OR_SIZE(ANDROID_SENSOR_BLACK_LEVEL_PATTERN, |
| 339 | blackLevelPattern, sizeof(blackLevelPattern)/sizeof(int32_t)); |
| 340 | |
| 341 | //TODO: sensor color calibration fields |
| 342 | |
| 343 | // android.flash |
| 344 | static const uint8_t flashAvailable = 0; |
| 345 | ADD_OR_SIZE(ANDROID_FLASH_AVAILABLE, &flashAvailable, 1); |
| 346 | |
| 347 | static const int64_t flashChargeDuration = 0; |
| 348 | ADD_OR_SIZE(ANDROID_FLASH_CHARGE_DURATION, &flashChargeDuration, 1); |
| 349 | |
| 350 | // android.tonemap |
| 351 | |
| 352 | static const int32_t tonemapCurvePoints = 128; |
| 353 | ADD_OR_SIZE(ANDROID_TONEMAP_MAX_CURVE_POINTS, &tonemapCurvePoints, 1); |
| 354 | |
| 355 | // android.scaler |
| 356 | |
| 357 | ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_FORMATS, |
| 358 | kAvailableFormats, |
| 359 | sizeof(kAvailableFormats)/sizeof(uint32_t)); |
| 360 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 361 | int32_t availableRawSizes[2] = { |
| 362 | m_curCameraInfo->sensorRawW, m_curCameraInfo->sensorRawH |
| 363 | }; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 364 | ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_SIZES, |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 365 | availableRawSizes, 2); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 366 | |
| 367 | ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS, |
| 368 | kAvailableRawMinDurations, |
| 369 | sizeof(kAvailableRawMinDurations)/sizeof(uint64_t)); |
| 370 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 371 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 372 | ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, |
| 373 | m_curCameraInfo->scalerResolutions, |
| 374 | (m_curCameraInfo->numScalerResolution)*2); |
| 375 | ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES, |
| 376 | m_curCameraInfo->jpegResolutions, |
| 377 | (m_curCameraInfo->numJpegResolution)*2); |
| 378 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 379 | ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS, |
| 380 | kAvailableProcessedMinDurations, |
| 381 | sizeof(kAvailableProcessedMinDurations)/sizeof(uint64_t)); |
| 382 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 383 | ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS, |
| 384 | kAvailableJpegMinDurations, |
| 385 | sizeof(kAvailableJpegMinDurations)/sizeof(uint64_t)); |
| 386 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 387 | static const float maxZoom = 3.5; |
| 388 | ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_MAX_ZOOM, &maxZoom, 1); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 389 | |
| 390 | // android.jpeg |
| 391 | |
| 392 | static const int32_t jpegThumbnailSizes[] = { |
| 393 | 160, 120, |
| 394 | 320, 240, |
| 395 | 640, 480 |
| 396 | }; |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 397 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 398 | ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, |
| 399 | jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t)); |
| 400 | |
Sungjoong Kang | 13d8c7b | 2012-07-14 10:20:39 +0900 | [diff] [blame] | 401 | static const int32_t jpegMaxSize = 5*1024*1024; |
| 402 | ADD_OR_SIZE(ANDROID_JPEG_MAX_SIZE, &jpegMaxSize, 1); |
| 403 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 404 | // android.stats |
| 405 | |
| 406 | static const uint8_t availableFaceDetectModes[] = { |
| 407 | ANDROID_STATS_FACE_DETECTION_OFF |
| 408 | }; |
| 409 | ADD_OR_SIZE(ANDROID_STATS_AVAILABLE_FACE_DETECT_MODES, |
| 410 | availableFaceDetectModes, |
| 411 | sizeof(availableFaceDetectModes)); |
| 412 | |
| 413 | static const int32_t maxFaceCount = 0; |
| 414 | ADD_OR_SIZE(ANDROID_STATS_MAX_FACE_COUNT, |
| 415 | &maxFaceCount, 1); |
| 416 | |
| 417 | static const int32_t histogramSize = 64; |
| 418 | ADD_OR_SIZE(ANDROID_STATS_HISTOGRAM_BUCKET_COUNT, |
| 419 | &histogramSize, 1); |
| 420 | |
| 421 | static const int32_t maxHistogramCount = 1000; |
| 422 | ADD_OR_SIZE(ANDROID_STATS_MAX_HISTOGRAM_COUNT, |
| 423 | &maxHistogramCount, 1); |
| 424 | |
| 425 | static const int32_t sharpnessMapSize[2] = {64, 64}; |
| 426 | ADD_OR_SIZE(ANDROID_STATS_SHARPNESS_MAP_SIZE, |
| 427 | sharpnessMapSize, sizeof(sharpnessMapSize)/sizeof(int32_t)); |
| 428 | |
| 429 | static const int32_t maxSharpnessMapValue = 1000; |
| 430 | ADD_OR_SIZE(ANDROID_STATS_MAX_SHARPNESS_MAP_VALUE, |
| 431 | &maxSharpnessMapValue, 1); |
| 432 | |
| 433 | // android.control |
| 434 | |
| 435 | static const uint8_t availableSceneModes[] = { |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 436 | ANDROID_CONTROL_SCENE_MODE_PARTY, |
| 437 | ANDROID_CONTROL_SCENE_MODE_SPORTS, |
| 438 | ANDROID_CONTROL_SCENE_MODE_NIGHT, |
| 439 | ANDROID_CONTROL_SCENE_MODE_BEACH |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 440 | }; |
| 441 | ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_SCENE_MODES, |
| 442 | availableSceneModes, sizeof(availableSceneModes)); |
| 443 | |
| 444 | static const uint8_t availableEffects[] = { |
| 445 | ANDROID_CONTROL_EFFECT_OFF |
| 446 | }; |
| 447 | ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_EFFECTS, |
| 448 | availableEffects, sizeof(availableEffects)); |
| 449 | |
| 450 | int32_t max3aRegions = 0; |
| 451 | ADD_OR_SIZE(ANDROID_CONTROL_MAX_REGIONS, |
| 452 | &max3aRegions, 1); |
| 453 | |
| 454 | static const uint8_t availableAeModes[] = { |
| 455 | ANDROID_CONTROL_AE_OFF, |
| 456 | ANDROID_CONTROL_AE_ON |
| 457 | }; |
| 458 | ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_MODES, |
| 459 | availableAeModes, sizeof(availableAeModes)); |
| 460 | |
| 461 | static const camera_metadata_rational exposureCompensationStep = { |
| 462 | 1, 3 |
| 463 | }; |
| 464 | ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION_STEP, |
| 465 | &exposureCompensationStep, 1); |
| 466 | |
| 467 | int32_t exposureCompensationRange[] = {-9, 9}; |
| 468 | ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION_RANGE, |
| 469 | exposureCompensationRange, |
| 470 | sizeof(exposureCompensationRange)/sizeof(int32_t)); |
| 471 | |
| 472 | static const int32_t availableTargetFpsRanges[] = { |
Sungjoong Kang | 9dd63e1 | 2012-07-24 00:25:51 +0900 | [diff] [blame] | 473 | 5, 30, 30, 30 |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 474 | }; |
| 475 | ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, |
| 476 | availableTargetFpsRanges, |
| 477 | sizeof(availableTargetFpsRanges)/sizeof(int32_t)); |
| 478 | |
| 479 | static const uint8_t availableAntibandingModes[] = { |
| 480 | ANDROID_CONTROL_AE_ANTIBANDING_OFF, |
| 481 | ANDROID_CONTROL_AE_ANTIBANDING_AUTO |
| 482 | }; |
| 483 | ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, |
| 484 | availableAntibandingModes, sizeof(availableAntibandingModes)); |
| 485 | |
| 486 | static const uint8_t availableAwbModes[] = { |
| 487 | ANDROID_CONTROL_AWB_OFF, |
| 488 | ANDROID_CONTROL_AWB_AUTO, |
| 489 | ANDROID_CONTROL_AWB_INCANDESCENT, |
| 490 | ANDROID_CONTROL_AWB_FLUORESCENT, |
| 491 | ANDROID_CONTROL_AWB_DAYLIGHT, |
| 492 | ANDROID_CONTROL_AWB_SHADE |
| 493 | }; |
| 494 | ADD_OR_SIZE(ANDROID_CONTROL_AWB_AVAILABLE_MODES, |
| 495 | availableAwbModes, sizeof(availableAwbModes)); |
| 496 | |
| 497 | static const uint8_t availableAfModes[] = { |
| 498 | ANDROID_CONTROL_AF_OFF |
| 499 | }; |
| 500 | ADD_OR_SIZE(ANDROID_CONTROL_AF_AVAILABLE_MODES, |
| 501 | availableAfModes, sizeof(availableAfModes)); |
| 502 | |
| 503 | static const uint8_t availableVstabModes[] = { |
| 504 | ANDROID_CONTROL_VIDEO_STABILIZATION_OFF |
| 505 | }; |
| 506 | ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, |
| 507 | availableVstabModes, sizeof(availableVstabModes)); |
| 508 | |
| 509 | #undef ADD_OR_SIZE |
| 510 | /** Allocate metadata if sizing */ |
| 511 | if (sizeRequest) { |
| 512 | ALOGV("Allocating %d entries, %d extra bytes for " |
| 513 | "static camera info", |
| 514 | entryCount, dataCount); |
| 515 | *info = allocate_camera_metadata(entryCount, dataCount); |
| 516 | if (*info == NULL) { |
| 517 | ALOGE("Unable to allocate camera static info" |
| 518 | "(%d entries, %d bytes extra data)", |
| 519 | entryCount, dataCount); |
| 520 | return NO_MEMORY; |
| 521 | } |
| 522 | } |
| 523 | return OK; |
| 524 | } |
| 525 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 526 | status_t ExynosCamera2::constructDefaultRequest( |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 527 | int request_template, |
| 528 | camera_metadata_t **request, |
| 529 | bool sizeRequest) { |
| 530 | |
| 531 | size_t entryCount = 0; |
| 532 | size_t dataCount = 0; |
| 533 | status_t ret; |
| 534 | |
| 535 | #define ADD_OR_SIZE( tag, data, count ) \ |
| 536 | if ( ( ret = addOrSize(*request, sizeRequest, &entryCount, &dataCount, \ |
| 537 | tag, data, count) ) != OK ) return ret |
| 538 | |
| 539 | static const int64_t USEC = 1000LL; |
| 540 | static const int64_t MSEC = USEC * 1000LL; |
| 541 | static const int64_t SEC = MSEC * 1000LL; |
| 542 | |
| 543 | /** android.request */ |
| 544 | |
| 545 | static const uint8_t metadataMode = ANDROID_REQUEST_METADATA_NONE; |
| 546 | ADD_OR_SIZE(ANDROID_REQUEST_METADATA_MODE, &metadataMode, 1); |
| 547 | |
| 548 | static const int32_t id = 0; |
| 549 | ADD_OR_SIZE(ANDROID_REQUEST_ID, &id, 1); |
| 550 | |
| 551 | static const int32_t frameCount = 0; |
| 552 | ADD_OR_SIZE(ANDROID_REQUEST_FRAME_COUNT, &frameCount, 1); |
| 553 | |
| 554 | // OUTPUT_STREAMS set by user |
| 555 | entryCount += 1; |
| 556 | dataCount += 5; // TODO: Should be maximum stream number |
| 557 | |
| 558 | /** android.lens */ |
| 559 | |
| 560 | static const float focusDistance = 0; |
| 561 | ADD_OR_SIZE(ANDROID_LENS_FOCUS_DISTANCE, &focusDistance, 1); |
| 562 | |
| 563 | static const float aperture = 2.8f; |
| 564 | ADD_OR_SIZE(ANDROID_LENS_APERTURE, &aperture, 1); |
| 565 | |
| 566 | static const float focalLength = 5.0f; |
| 567 | ADD_OR_SIZE(ANDROID_LENS_FOCAL_LENGTH, &focalLength, 1); |
| 568 | |
| 569 | static const float filterDensity = 0; |
| 570 | ADD_OR_SIZE(ANDROID_LENS_FILTER_DENSITY, &filterDensity, 1); |
| 571 | |
| 572 | static const uint8_t opticalStabilizationMode = |
| 573 | ANDROID_LENS_OPTICAL_STABILIZATION_OFF; |
| 574 | ADD_OR_SIZE(ANDROID_LENS_OPTICAL_STABILIZATION_MODE, |
| 575 | &opticalStabilizationMode, 1); |
| 576 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 577 | |
| 578 | /** android.sensor */ |
| 579 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 580 | |
| 581 | static const int64_t frameDuration = 33333333L; // 1/30 s |
| 582 | ADD_OR_SIZE(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1); |
| 583 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 584 | |
| 585 | /** android.flash */ |
| 586 | |
| 587 | static const uint8_t flashMode = ANDROID_FLASH_OFF; |
| 588 | ADD_OR_SIZE(ANDROID_FLASH_MODE, &flashMode, 1); |
| 589 | |
| 590 | static const uint8_t flashPower = 10; |
| 591 | ADD_OR_SIZE(ANDROID_FLASH_FIRING_POWER, &flashPower, 1); |
| 592 | |
| 593 | static const int64_t firingTime = 0; |
| 594 | ADD_OR_SIZE(ANDROID_FLASH_FIRING_TIME, &firingTime, 1); |
| 595 | |
| 596 | /** Processing block modes */ |
| 597 | uint8_t hotPixelMode = 0; |
| 598 | uint8_t demosaicMode = 0; |
| 599 | uint8_t noiseMode = 0; |
| 600 | uint8_t shadingMode = 0; |
| 601 | uint8_t geometricMode = 0; |
| 602 | uint8_t colorMode = 0; |
| 603 | uint8_t tonemapMode = 0; |
| 604 | uint8_t edgeMode = 0; |
| 605 | switch (request_template) { |
| 606 | case CAMERA2_TEMPLATE_PREVIEW: |
| 607 | hotPixelMode = ANDROID_PROCESSING_FAST; |
| 608 | demosaicMode = ANDROID_PROCESSING_FAST; |
| 609 | noiseMode = ANDROID_PROCESSING_FAST; |
| 610 | shadingMode = ANDROID_PROCESSING_FAST; |
| 611 | geometricMode = ANDROID_PROCESSING_FAST; |
| 612 | colorMode = ANDROID_PROCESSING_FAST; |
| 613 | tonemapMode = ANDROID_PROCESSING_FAST; |
| 614 | edgeMode = ANDROID_PROCESSING_FAST; |
| 615 | break; |
| 616 | case CAMERA2_TEMPLATE_STILL_CAPTURE: |
| 617 | hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 618 | demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 619 | noiseMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 620 | shadingMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 621 | geometricMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 622 | colorMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 623 | tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 624 | edgeMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 625 | break; |
| 626 | case CAMERA2_TEMPLATE_VIDEO_RECORD: |
| 627 | hotPixelMode = ANDROID_PROCESSING_FAST; |
| 628 | demosaicMode = ANDROID_PROCESSING_FAST; |
| 629 | noiseMode = ANDROID_PROCESSING_FAST; |
| 630 | shadingMode = ANDROID_PROCESSING_FAST; |
| 631 | geometricMode = ANDROID_PROCESSING_FAST; |
| 632 | colorMode = ANDROID_PROCESSING_FAST; |
| 633 | tonemapMode = ANDROID_PROCESSING_FAST; |
| 634 | edgeMode = ANDROID_PROCESSING_FAST; |
| 635 | break; |
| 636 | case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT: |
| 637 | hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 638 | demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 639 | noiseMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 640 | shadingMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 641 | geometricMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 642 | colorMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 643 | tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 644 | edgeMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 645 | break; |
| 646 | case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG: |
| 647 | hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 648 | demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 649 | noiseMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 650 | shadingMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 651 | geometricMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 652 | colorMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 653 | tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 654 | edgeMode = ANDROID_PROCESSING_HIGH_QUALITY; |
| 655 | break; |
| 656 | default: |
| 657 | hotPixelMode = ANDROID_PROCESSING_FAST; |
| 658 | demosaicMode = ANDROID_PROCESSING_FAST; |
| 659 | noiseMode = ANDROID_PROCESSING_FAST; |
| 660 | shadingMode = ANDROID_PROCESSING_FAST; |
| 661 | geometricMode = ANDROID_PROCESSING_FAST; |
| 662 | colorMode = ANDROID_PROCESSING_FAST; |
| 663 | tonemapMode = ANDROID_PROCESSING_FAST; |
| 664 | edgeMode = ANDROID_PROCESSING_FAST; |
| 665 | break; |
| 666 | } |
| 667 | ADD_OR_SIZE(ANDROID_HOT_PIXEL_MODE, &hotPixelMode, 1); |
| 668 | ADD_OR_SIZE(ANDROID_DEMOSAIC_MODE, &demosaicMode, 1); |
| 669 | ADD_OR_SIZE(ANDROID_NOISE_MODE, &noiseMode, 1); |
| 670 | ADD_OR_SIZE(ANDROID_SHADING_MODE, &shadingMode, 1); |
| 671 | ADD_OR_SIZE(ANDROID_GEOMETRIC_MODE, &geometricMode, 1); |
| 672 | ADD_OR_SIZE(ANDROID_COLOR_MODE, &colorMode, 1); |
| 673 | ADD_OR_SIZE(ANDROID_TONEMAP_MODE, &tonemapMode, 1); |
| 674 | ADD_OR_SIZE(ANDROID_EDGE_MODE, &edgeMode, 1); |
| 675 | |
| 676 | /** android.noise */ |
| 677 | static const uint8_t noiseStrength = 5; |
| 678 | ADD_OR_SIZE(ANDROID_NOISE_STRENGTH, &noiseStrength, 1); |
| 679 | |
| 680 | /** android.color */ |
| 681 | static const float colorTransform[9] = { |
| 682 | 1.0f, 0.f, 0.f, |
| 683 | 0.f, 1.f, 0.f, |
| 684 | 0.f, 0.f, 1.f |
| 685 | }; |
| 686 | ADD_OR_SIZE(ANDROID_COLOR_TRANSFORM, colorTransform, 9); |
| 687 | |
| 688 | /** android.tonemap */ |
| 689 | static const float tonemapCurve[4] = { |
| 690 | 0.f, 0.f, |
| 691 | 1.f, 1.f |
| 692 | }; |
| 693 | ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_RED, tonemapCurve, 32); // sungjoong |
| 694 | ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_GREEN, tonemapCurve, 32); |
| 695 | ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_BLUE, tonemapCurve, 32); |
| 696 | |
| 697 | /** android.edge */ |
| 698 | static const uint8_t edgeStrength = 5; |
| 699 | ADD_OR_SIZE(ANDROID_EDGE_STRENGTH, &edgeStrength, 1); |
| 700 | |
| 701 | /** android.scaler */ |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 702 | int32_t cropRegion[3] = { |
| 703 | 0, 0, m_curCameraInfo->sensorW |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 704 | }; |
| 705 | ADD_OR_SIZE(ANDROID_SCALER_CROP_REGION, cropRegion, 3); |
| 706 | |
| 707 | /** android.jpeg */ |
| 708 | static const int32_t jpegQuality = 80; |
| 709 | ADD_OR_SIZE(ANDROID_JPEG_QUALITY, &jpegQuality, 1); |
| 710 | |
| 711 | static const int32_t thumbnailSize[2] = { |
| 712 | 640, 480 |
| 713 | }; |
| 714 | ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_SIZE, thumbnailSize, 2); |
| 715 | |
| 716 | static const int32_t thumbnailQuality = 80; |
| 717 | ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_QUALITY, &thumbnailQuality, 1); |
| 718 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 719 | static const double gpsCoordinates[3] = { |
| 720 | 0, 0, 0 |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 721 | }; |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 722 | ADD_OR_SIZE(ANDROID_JPEG_GPS_COORDINATES, gpsCoordinates, 3); |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 723 | |
| 724 | static const uint8_t gpsProcessingMethod[32] = "None"; |
| 725 | ADD_OR_SIZE(ANDROID_JPEG_GPS_PROCESSING_METHOD, gpsProcessingMethod, 32); |
| 726 | |
| 727 | static const int64_t gpsTimestamp = 0; |
| 728 | ADD_OR_SIZE(ANDROID_JPEG_GPS_TIMESTAMP, &gpsTimestamp, 1); |
| 729 | |
| 730 | static const int32_t jpegOrientation = 0; |
| 731 | ADD_OR_SIZE(ANDROID_JPEG_ORIENTATION, &jpegOrientation, 1); |
| 732 | |
| 733 | /** android.stats */ |
| 734 | |
| 735 | static const uint8_t faceDetectMode = ANDROID_STATS_FACE_DETECTION_OFF; |
| 736 | ADD_OR_SIZE(ANDROID_STATS_FACE_DETECT_MODE, &faceDetectMode, 1); |
| 737 | |
| 738 | static const uint8_t histogramMode = ANDROID_STATS_OFF; |
| 739 | ADD_OR_SIZE(ANDROID_STATS_HISTOGRAM_MODE, &histogramMode, 1); |
| 740 | |
| 741 | static const uint8_t sharpnessMapMode = ANDROID_STATS_OFF; |
| 742 | ADD_OR_SIZE(ANDROID_STATS_SHARPNESS_MAP_MODE, &sharpnessMapMode, 1); |
| 743 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 744 | |
| 745 | /** android.control */ |
| 746 | |
| 747 | uint8_t controlIntent = 0; |
| 748 | switch (request_template) { |
| 749 | case CAMERA2_TEMPLATE_PREVIEW: |
| 750 | controlIntent = ANDROID_CONTROL_INTENT_PREVIEW; |
| 751 | break; |
| 752 | case CAMERA2_TEMPLATE_STILL_CAPTURE: |
| 753 | controlIntent = ANDROID_CONTROL_INTENT_STILL_CAPTURE; |
| 754 | break; |
| 755 | case CAMERA2_TEMPLATE_VIDEO_RECORD: |
| 756 | controlIntent = ANDROID_CONTROL_INTENT_VIDEO_RECORD; |
| 757 | break; |
| 758 | case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT: |
| 759 | controlIntent = ANDROID_CONTROL_INTENT_VIDEO_SNAPSHOT; |
| 760 | break; |
| 761 | case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG: |
| 762 | controlIntent = ANDROID_CONTROL_INTENT_ZERO_SHUTTER_LAG; |
| 763 | break; |
| 764 | default: |
| 765 | controlIntent = ANDROID_CONTROL_INTENT_CUSTOM; |
| 766 | break; |
| 767 | } |
| 768 | ADD_OR_SIZE(ANDROID_CONTROL_CAPTURE_INTENT, &controlIntent, 1); |
| 769 | |
| 770 | static const uint8_t controlMode = ANDROID_CONTROL_AUTO; |
| 771 | ADD_OR_SIZE(ANDROID_CONTROL_MODE, &controlMode, 1); |
| 772 | |
| 773 | static const uint8_t effectMode = ANDROID_CONTROL_EFFECT_OFF; |
| 774 | ADD_OR_SIZE(ANDROID_CONTROL_EFFECT_MODE, &effectMode, 1); |
| 775 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 776 | static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 777 | ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE, &sceneMode, 1); |
| 778 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 779 | static const uint8_t aeMode = ANDROID_CONTROL_AE_ON; |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 780 | ADD_OR_SIZE(ANDROID_CONTROL_AE_MODE, &aeMode, 1); |
| 781 | |
Sungjoong Kang | daa1fcd | 2012-08-08 11:49:43 -0700 | [diff] [blame] | 782 | int32_t controlRegions[5] = { |
| 783 | 0, 0, m_curCameraInfo->sensorW, m_curCameraInfo->sensorH, 1000 |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 784 | }; |
| 785 | ADD_OR_SIZE(ANDROID_CONTROL_AE_REGIONS, controlRegions, 5); |
| 786 | |
| 787 | static const int32_t aeExpCompensation = 0; |
| 788 | ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION, &aeExpCompensation, 1); |
| 789 | |
| 790 | static const int32_t aeTargetFpsRange[2] = { |
| 791 | 10, 30 |
| 792 | }; |
| 793 | ADD_OR_SIZE(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, aeTargetFpsRange, 2); |
| 794 | |
| 795 | static const uint8_t aeAntibandingMode = |
| 796 | ANDROID_CONTROL_AE_ANTIBANDING_AUTO; |
| 797 | ADD_OR_SIZE(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &aeAntibandingMode, 1); |
| 798 | |
| 799 | static const uint8_t awbMode = |
| 800 | ANDROID_CONTROL_AWB_AUTO; |
| 801 | ADD_OR_SIZE(ANDROID_CONTROL_AWB_MODE, &awbMode, 1); |
| 802 | |
| 803 | ADD_OR_SIZE(ANDROID_CONTROL_AWB_REGIONS, controlRegions, 5); |
| 804 | |
| 805 | uint8_t afMode = 0; |
| 806 | switch (request_template) { |
| 807 | case CAMERA2_TEMPLATE_PREVIEW: |
| 808 | afMode = ANDROID_CONTROL_AF_AUTO; |
| 809 | break; |
| 810 | case CAMERA2_TEMPLATE_STILL_CAPTURE: |
| 811 | afMode = ANDROID_CONTROL_AF_AUTO; |
| 812 | break; |
| 813 | case CAMERA2_TEMPLATE_VIDEO_RECORD: |
| 814 | afMode = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO; |
| 815 | break; |
| 816 | case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT: |
| 817 | afMode = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO; |
| 818 | break; |
| 819 | case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG: |
| 820 | afMode = ANDROID_CONTROL_AF_CONTINUOUS_PICTURE; |
| 821 | break; |
| 822 | default: |
| 823 | afMode = ANDROID_CONTROL_AF_AUTO; |
| 824 | break; |
| 825 | } |
| 826 | ADD_OR_SIZE(ANDROID_CONTROL_AF_MODE, &afMode, 1); |
| 827 | |
| 828 | ADD_OR_SIZE(ANDROID_CONTROL_AF_REGIONS, controlRegions, 5); |
| 829 | |
| 830 | static const uint8_t vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_OFF; |
| 831 | ADD_OR_SIZE(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, &vstabMode, 1); |
| 832 | |
Jiyoung Shin | c15a6b0 | 2012-06-05 01:08:14 -0700 | [diff] [blame] | 833 | if (sizeRequest) { |
| 834 | ALOGV("Allocating %d entries, %d extra bytes for " |
| 835 | "request template type %d", |
| 836 | entryCount, dataCount, request_template); |
| 837 | *request = allocate_camera_metadata(entryCount, dataCount); |
| 838 | if (*request == NULL) { |
| 839 | ALOGE("Unable to allocate new request template type %d " |
| 840 | "(%d entries, %d bytes extra data)", request_template, |
| 841 | entryCount, dataCount); |
| 842 | return NO_MEMORY; |
| 843 | } |
| 844 | } |
| 845 | return OK; |
| 846 | #undef ADD_OR_SIZE |
| 847 | } |
| 848 | |
| 849 | } |