blob: 35bb9f518d6f772a492c07662ef31e72d71a0725 [file] [log] [blame]
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -07001/*
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 Shinc15a6b02012-06-05 01:08:14 -070030
31//#define LOG_NDEBUG 0
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -070032#define LOG_TAG "ExynosCamera2"
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070033#include <utils/Log.h>
34
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -070035#include "ExynosCamera2.h"
36
37#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070038
39namespace android {
40
Ruben Brunk17071e42014-10-01 17:00:21 -070041int32_t SUPPORT_THUMBNAIL_REAR_SIZE[3][2] =
42{
43 {160, 120},
44 {160, 90},
45 {144, 96}
46};
47
48int32_t SUPPORT_THUMBNAIL_FRONT_SIZE[4][2] =
49{
50 {160, 120},
51 {160, 160},
52 {160, 90},
53 {144, 96}
54};
55
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070056class Sensor {
57public:
58 /**
59 * Static sensor characteristics
60 */
Sungjoong Kang9dd63e12012-07-24 00:25:51 +090061 static const unsigned int kResolution[2][2];
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070062
63 static const nsecs_t kExposureTimeRange[2];
64 static const nsecs_t kFrameDurationRange[2];
65 static const nsecs_t kMinVerticalBlank;
66
67 static const uint8_t kColorFilterArrangement;
68
69 // Output image data characteristics
70 static const uint32_t kMaxRawValue;
71 static const uint32_t kBlackLevel;
72 // Sensor sensitivity, approximate
73
74 static const float kSaturationVoltage;
75 static const uint32_t kSaturationElectrons;
76 static const float kVoltsPerLuxSecond;
77 static const float kElectronsPerLuxSecond;
78
79 static const float kBaseGainFactor;
80
81 static const float kReadNoiseStddevBeforeGain; // In electrons
82 static const float kReadNoiseStddevAfterGain; // In raw digital units
83 static const float kReadNoiseVarBeforeGain;
84 static const float kReadNoiseVarAfterGain;
85
86 // While each row has to read out, reset, and then expose, the (reset +
87 // expose) sequence can be overlapped by other row readouts, so the final
88 // minimum frame duration is purely a function of row readout time, at least
89 // if there's a reasonable number of rows.
90 static const nsecs_t kRowReadoutTime;
91
Zhijun He4eb2f242013-07-17 18:06:25 -070092 static const int32_t kSensitivityRange[2];
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070093 static const uint32_t kDefaultSensitivity;
94
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070095};
96
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070097
Sungjoong Kang9dd63e12012-07-24 00:25:51 +090098
Zhijun He4eb2f242013-07-17 18:06:25 -070099const int32_t Sensor::kSensitivityRange[2] = {100, 1600};
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700100const nsecs_t Sensor::kExposureTimeRange[2] =
101 {1000L, 30000000000L} ; // 1 us - 30 sec
102const nsecs_t Sensor::kFrameDurationRange[2] =
103 {33331760L, 30000000000L}; // ~1/30 s - 30 sec
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700104
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800105const uint8_t Sensor::kColorFilterArrangement = ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGGB;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700106
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900107const uint32_t kAvailableFormats[5] = {
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700108 HAL_PIXEL_FORMAT_RAW_SENSOR,
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900109 HAL_PIXEL_FORMAT_BLOB,
110 HAL_PIXEL_FORMAT_RGBA_8888,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700111 HAL_PIXEL_FORMAT_YV12,
112 HAL_PIXEL_FORMAT_YCrCb_420_SP
113};
114
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700115// Output image data characteristics
116const uint32_t Sensor::kMaxRawValue = 4000;
117const uint32_t Sensor::kBlackLevel = 1000;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700118
119const uint64_t kAvailableRawMinDurations[1] = {
120 Sensor::kFrameDurationRange[0]
121};
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900122
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700123const uint64_t kAvailableProcessedMinDurations[1] = {
124 Sensor::kFrameDurationRange[0]
125};
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700126const uint64_t kAvailableJpegMinDurations[1] = {
127 Sensor::kFrameDurationRange[0]
128};
129
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700130const int32_t scalerResolutionS5K4E5[] =
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900131{
hyeonmyeong Choi0b7b7572012-09-06 12:45:44 -0700132 1920, 1080, // 16:9
133 1440, 1080, // 4:3
134 1440, 960, // 3:2
135 1280, 1024, // 5:4
136 1280, 720, // 16:9
137 960, 720, // 4:3
138 800, 480, // 5:3
139 768, 576, // 4:3
140 720, 576, // 5:4
141 720, 480, // 3:2
142 640, 480, // 4:3
143 352, 288, // 11:9
144 320, 240, // 4:3
145 240, 160, // 3:2
146 176, 144, // 6:5
147 128, 96, // 4:3
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700148};
149
150const int32_t jpegResolutionS5K4E5[] =
151{
152 2560, 1920,
Sungjoong Kange4657e32012-08-28 15:02:19 -0700153 2560, 1440,
hyeonmyeong Choia44c3362012-08-30 19:01:25 -0700154 2160, 1440,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700155 2048, 1536,
156 1600, 1200,
157 1280, 1024,
158 1280, 960,
159 1152, 864,
160 640, 480,
161 320, 240,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700162};
163
Sungjoong Kang73c63372012-10-04 21:51:47 -0700164const uint8_t availableAfModesS5K4E5[] =
165{
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800166 ANDROID_CONTROL_AF_MODE_OFF,
167 ANDROID_CONTROL_AF_MODE_AUTO,
168 ANDROID_CONTROL_AF_MODE_MACRO,
169 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
170 ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO
Sungjoong Kang73c63372012-10-04 21:51:47 -0700171};
172
173const uint8_t sceneModeOverridesS5K4E5[] =
174{
175 // ANDROID_CONTROL_SCENE_MODE_ACTION
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800176 ANDROID_CONTROL_AE_MODE_ON,
177 ANDROID_CONTROL_AWB_MODE_AUTO,
178 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700179 // ANDROID_CONTROL_SCENE_MODE_NIGHT
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800180 ANDROID_CONTROL_AE_MODE_ON,
181 ANDROID_CONTROL_AWB_MODE_AUTO,
182 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700183 // ANDROID_CONTROL_SCENE_MODE_SUNSET
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800184 ANDROID_CONTROL_AE_MODE_ON,
185 ANDROID_CONTROL_AWB_MODE_DAYLIGHT,
186 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700187 // ANDROID_CONTROL_SCENE_MODE_PARTY
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800188 ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH,
189 ANDROID_CONTROL_AWB_MODE_AUTO,
190 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
Sungjoong Kang73c63372012-10-04 21:51:47 -0700191};
192
193const uint8_t availableAeModesS5K4E5[] =
194{
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800195 ANDROID_CONTROL_AE_MODE_OFF,
196 ANDROID_CONTROL_AE_MODE_ON,
197 ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH
Sungjoong Kang73c63372012-10-04 21:51:47 -0700198};
199
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700200ExynosCamera2InfoS5K4E5::ExynosCamera2InfoS5K4E5()
201{
202 sensorW = 2560;
203 sensorH = 1920;
204 sensorRawW = (2560 + 16);
205 sensorRawH = (1920 + 10);
206 numScalerResolution = ARRAY_SIZE(scalerResolutionS5K4E5)/2;
207 scalerResolutions = scalerResolutionS5K4E5;
208 numJpegResolution = ARRAY_SIZE(jpegResolutionS5K4E5)/2;
209 jpegResolutions = jpegResolutionS5K4E5;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700210 minFocusDistance = 0.1f;
211 focalLength = 3.43f;
212 aperture = 2.7f;
Sungjoong Kange00f6592012-09-07 19:05:31 -0700213 fnumber = 2.7f;
Sungjoong Kang73c63372012-10-04 21:51:47 -0700214 availableAfModes = availableAfModesS5K4E5;
215 numAvailableAfModes = ARRAY_SIZE(availableAfModesS5K4E5);
216 sceneModeOverrides = sceneModeOverridesS5K4E5;
217 numSceneModeOverrides = ARRAY_SIZE(sceneModeOverridesS5K4E5);
218 availableAeModes = availableAeModesS5K4E5;
219 numAvailableAeModes = ARRAY_SIZE(availableAeModesS5K4E5);
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700220}
221
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700222ExynosCamera2InfoS5K4E5::~ExynosCamera2InfoS5K4E5()
223{
224 ALOGV("%s", __FUNCTION__);
225}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700226const int32_t scalerResolutionS5K6A3[] =
227{
hyeonmyeong Choi0b7b7572012-09-06 12:45:44 -0700228 1344, 896, // 3:2
229 1280, 1024, // 5:4
Sungjoong Kang9c046e32012-10-09 12:00:51 -0700230 1024, 1024, // 1:1
hyeonmyeong Choi0b7b7572012-09-06 12:45:44 -0700231 1280, 960, // 4:3
232 1280, 720, // 16:9
233 960, 720, // 4:3
234 800, 480, // 5:3
235 768, 576, // 4:3
236 720, 576, // 5:4
237 720, 480, // 3:2
238 640, 480, // 4:3
239 352, 288, // 11:9
240 320, 240, // 4:3
241 240, 160, // 3:2
242 176, 144, // 6:5
243 128, 96, // 4:3
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700244};
245
246const int32_t jpegResolutionS5K6A3[] =
247{
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700248 1392, 1392,
249 1392, 1040,
hyeonmyeong Choia44c3362012-08-30 19:01:25 -0700250 1392, 928,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700251 1392, 784,
252 1280, 1024,
Sungjoong Kangad378612012-08-17 12:34:33 -0700253 1280, 960,
Sungjoong Kange4657e32012-08-28 15:02:19 -0700254 1280, 720,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700255 1152, 864,
256 640, 480,
257 320, 240,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700258};
259
Sungjoong Kang73c63372012-10-04 21:51:47 -0700260const uint8_t availableAfModesS5K6A3[] =
261{
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800262 ANDROID_CONTROL_AF_MODE_OFF
Sungjoong Kang73c63372012-10-04 21:51:47 -0700263};
264
265const uint8_t sceneModeOverridesS5K6A3[] =
266{
267 // ANDROID_CONTROL_SCENE_MODE_ACTION
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800268 ANDROID_CONTROL_AE_MODE_ON,
269 ANDROID_CONTROL_AWB_MODE_AUTO,
270 ANDROID_CONTROL_AF_MODE_OFF,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700271 // ANDROID_CONTROL_SCENE_MODE_NIGHT
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800272 ANDROID_CONTROL_AE_MODE_ON,
273 ANDROID_CONTROL_AWB_MODE_AUTO,
274 ANDROID_CONTROL_AF_MODE_OFF,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700275 // ANDROID_CONTROL_SCENE_MODE_SUNSET
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800276 ANDROID_CONTROL_AE_MODE_ON,
277 ANDROID_CONTROL_AWB_MODE_DAYLIGHT,
278 ANDROID_CONTROL_AF_MODE_OFF,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700279 // ANDROID_CONTROL_SCENE_MODE_PARTY
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800280 ANDROID_CONTROL_AE_MODE_ON,
281 ANDROID_CONTROL_AWB_MODE_AUTO,
282 ANDROID_CONTROL_AF_MODE_OFF
Sungjoong Kang73c63372012-10-04 21:51:47 -0700283};
284
285const uint8_t availableAeModesS5K6A3[] =
286{
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800287 ANDROID_CONTROL_AE_MODE_OFF,
288 ANDROID_CONTROL_AE_MODE_ON
Sungjoong Kang73c63372012-10-04 21:51:47 -0700289};
290
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700291ExynosCamera2InfoS5K6A3::ExynosCamera2InfoS5K6A3()
292{
293 sensorW = 1392;
294 sensorH = 1392;
295 sensorRawW = (1392 + 16);
296 sensorRawH = (1392 + 10);
297 numScalerResolution = ARRAY_SIZE(scalerResolutionS5K6A3)/2;
298 scalerResolutions = scalerResolutionS5K6A3;
299 numJpegResolution = ARRAY_SIZE(jpegResolutionS5K6A3)/2;
300 jpegResolutions = jpegResolutionS5K6A3;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700301 minFocusDistance = 0.0f;
302 focalLength = 2.73f;
303 aperture = 2.8f;
Sungjoong Kange00f6592012-09-07 19:05:31 -0700304 fnumber = 2.8f;
Sungjoong Kang73c63372012-10-04 21:51:47 -0700305 availableAfModes = availableAfModesS5K6A3;
306 numAvailableAfModes = ARRAY_SIZE(availableAfModesS5K6A3);
307 sceneModeOverrides = sceneModeOverridesS5K6A3;
308 numSceneModeOverrides = ARRAY_SIZE(sceneModeOverridesS5K6A3);
309 availableAeModes = availableAeModesS5K6A3;
310 numAvailableAeModes = ARRAY_SIZE(availableAeModesS5K6A3);
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700311}
312
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700313ExynosCamera2InfoS5K6A3::~ExynosCamera2InfoS5K6A3()
314{
315 ALOGV("%s", __FUNCTION__);
316}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700317ExynosCamera2::ExynosCamera2(int cameraId):
318 m_cameraId(cameraId)
319{
320 if (cameraId == 0)
321 m_curCameraInfo = new ExynosCamera2InfoS5K4E5;
322 else
323 m_curCameraInfo = new ExynosCamera2InfoS5K6A3;
324}
325
326ExynosCamera2::~ExynosCamera2()
327{
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700328 ALOGV("%s", __FUNCTION__);
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700329 delete m_curCameraInfo;
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700330 m_curCameraInfo = NULL;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700331}
332
333int32_t ExynosCamera2::getSensorW()
334{
335 return m_curCameraInfo->sensorW;
336}
337
338int32_t ExynosCamera2::getSensorH()
339{
340 return m_curCameraInfo->sensorH;
341}
342
343int32_t ExynosCamera2::getSensorRawW()
344{
345 return m_curCameraInfo->sensorRawW;
346}
347
348int32_t ExynosCamera2::getSensorRawH()
349{
350 return m_curCameraInfo->sensorRawH;
351}
352
353bool ExynosCamera2::isSupportedResolution(int width, int height)
354{
355 int i;
356 for (i = 0 ; i < m_curCameraInfo->numScalerResolution ; i++) {
357 if (m_curCameraInfo->scalerResolutions[2*i] == width
358 && m_curCameraInfo->scalerResolutions[2*i+1] == height) {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900359 return true;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700360 }
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900361 }
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700362 return false;
363}
364
365bool ExynosCamera2::isSupportedJpegResolution(int width, int height)
366{
367 int i;
368 for (i = 0 ; i < m_curCameraInfo->numJpegResolution ; i++) {
369 if (m_curCameraInfo->jpegResolutions[2*i] == width
370 && m_curCameraInfo->jpegResolutions[2*i+1] == height) {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900371 return true;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700372 }
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900373 }
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700374 return false;
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900375}
376
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700377status_t addOrSize(camera_metadata_t *request,
378 bool sizeRequest,
379 size_t *entryCount,
380 size_t *dataCount,
381 uint32_t tag,
382 const void *entryData,
383 size_t entryDataCount) {
384 status_t res;
385 if (!sizeRequest) {
386 return add_camera_metadata_entry(request, tag, entryData,
387 entryDataCount);
388 } else {
389 int type = get_camera_metadata_tag_type(tag);
390 if (type < 0 ) return BAD_VALUE;
391 (*entryCount)++;
392 (*dataCount) += calculate_camera_metadata_entry_data_size(type,
393 entryDataCount);
394 return OK;
395 }
396}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700397
398status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info,
399 int cameraId, bool sizeRequest) {
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700400
401 size_t entryCount = 0;
402 size_t dataCount = 0;
403 status_t ret;
404
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700405#define ADD_OR_SIZE( tag, data, count ) \
406 if ( ( ret = addOrSize(*info, sizeRequest, &entryCount, &dataCount, \
407 tag, data, count) ) != OK ) return ret
408
Alex Ray05c0c1a2013-06-03 13:23:34 -0700409 // android.info
410
Zhijun Hea4863a22013-09-23 10:03:03 -0700411 int32_t hardwareLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;
Alex Ray05c0c1a2013-06-03 13:23:34 -0700412 ADD_OR_SIZE(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL,
413 &hardwareLevel, 1);
414
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700415 // android.lens
416
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800417 ADD_OR_SIZE(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700418 &(m_curCameraInfo->minFocusDistance), 1);
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800419 ADD_OR_SIZE(ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700420 &(m_curCameraInfo->minFocusDistance), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700421
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800422 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700423 &m_curCameraInfo->focalLength, 1);
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800424 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_APERTURES,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700425 &m_curCameraInfo->aperture, 1);
426
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700427 static const float filterDensity = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800428 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700429 &filterDensity, 1);
430 static const uint8_t availableOpticalStabilization =
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800431 ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;
432 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700433 &availableOpticalStabilization, 1);
434
435 static const int32_t lensShadingMapSize[] = {1, 1};
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800436 ADD_OR_SIZE(ANDROID_LENS_INFO_SHADING_MAP_SIZE, lensShadingMapSize,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700437 sizeof(lensShadingMapSize)/sizeof(int32_t));
438
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900439 int32_t lensFacing = cameraId ?
440 ANDROID_LENS_FACING_FRONT : ANDROID_LENS_FACING_BACK;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700441 ADD_OR_SIZE(ANDROID_LENS_FACING, &lensFacing, 1);
442
Alex Ray1b2236e2013-09-26 14:06:42 -0700443 // android.request
444 static const int32_t maxNumOutputStreams[] = {1, 3, 1};
445 ADD_OR_SIZE(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, maxNumOutputStreams,
446 sizeof(maxNumOutputStreams)/sizeof(int32_t));
447
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700448 // android.sensor
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800449 ADD_OR_SIZE(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700450 Sensor::kExposureTimeRange, 2);
451
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800452 ADD_OR_SIZE(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700453 &Sensor::kFrameDurationRange[1], 1);
454
Zhijun He4eb2f242013-07-17 18:06:25 -0700455 ADD_OR_SIZE(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE,
456 Sensor::kSensitivityRange,
457 sizeof(Sensor::kSensitivityRange)
458 /sizeof(int32_t));
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700459
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800460 ADD_OR_SIZE(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700461 &Sensor::kColorFilterArrangement, 1);
462
Eino-Ville Talvalaa7fe0492013-04-30 13:32:53 -0700463 // Empirically derived to get correct FOV measurements
464 static const float sensorPhysicalSize[2] = {3.50f, 2.625f}; // mm
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800465 ADD_OR_SIZE(ANDROID_SENSOR_INFO_PHYSICAL_SIZE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700466 sensorPhysicalSize, 2);
467
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700468 int32_t pixelArraySize[2] = {
469 m_curCameraInfo->sensorW, m_curCameraInfo->sensorH
470 };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800471 ADD_OR_SIZE(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, pixelArraySize, 2);
Alex Ray1b2236e2013-09-26 14:06:42 -0700472
473 int32_t activeArraySize[4] = { 0, 0, pixelArraySize[0], pixelArraySize[1]};
474 ADD_OR_SIZE(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, activeArraySize,4);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700475
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800476 ADD_OR_SIZE(ANDROID_SENSOR_INFO_WHITE_LEVEL,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700477 &Sensor::kMaxRawValue, 1);
478
479 static const int32_t blackLevelPattern[4] = {
480 Sensor::kBlackLevel, Sensor::kBlackLevel,
481 Sensor::kBlackLevel, Sensor::kBlackLevel
482 };
483 ADD_OR_SIZE(ANDROID_SENSOR_BLACK_LEVEL_PATTERN,
484 blackLevelPattern, sizeof(blackLevelPattern)/sizeof(int32_t));
485
Alex Ray1b2236e2013-09-26 14:06:42 -0700486 static const int32_t orientation[1] = {0};
487 ADD_OR_SIZE(ANDROID_SENSOR_ORIENTATION,
488 orientation, 1);
489
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700490 //TODO: sensor color calibration fields
491
492 // android.flash
Younghwan Joo9a710a42012-09-05 17:52:08 -0700493 uint8_t flashAvailable;
494 if (cameraId == 0)
495 flashAvailable = 1;
496 else
497 flashAvailable = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800498 ADD_OR_SIZE(ANDROID_FLASH_INFO_AVAILABLE, &flashAvailable, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700499
500 static const int64_t flashChargeDuration = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800501 ADD_OR_SIZE(ANDROID_FLASH_INFO_CHARGE_DURATION, &flashChargeDuration, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700502
503 // android.tonemap
504
505 static const int32_t tonemapCurvePoints = 128;
506 ADD_OR_SIZE(ANDROID_TONEMAP_MAX_CURVE_POINTS, &tonemapCurvePoints, 1);
507
508 // android.scaler
509
510 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_FORMATS,
511 kAvailableFormats,
512 sizeof(kAvailableFormats)/sizeof(uint32_t));
513
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700514 int32_t availableRawSizes[2] = {
515 m_curCameraInfo->sensorRawW, m_curCameraInfo->sensorRawH
516 };
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700517 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_SIZES,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700518 availableRawSizes, 2);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700519
520 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS,
521 kAvailableRawMinDurations,
522 sizeof(kAvailableRawMinDurations)/sizeof(uint64_t));
523
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700524
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700525 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES,
526 m_curCameraInfo->scalerResolutions,
527 (m_curCameraInfo->numScalerResolution)*2);
528 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES,
529 m_curCameraInfo->jpegResolutions,
530 (m_curCameraInfo->numJpegResolution)*2);
531
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700532 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS,
533 kAvailableProcessedMinDurations,
534 sizeof(kAvailableProcessedMinDurations)/sizeof(uint64_t));
535
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700536 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS,
537 kAvailableJpegMinDurations,
538 sizeof(kAvailableJpegMinDurations)/sizeof(uint64_t));
539
Sungjoong Kange4657e32012-08-28 15:02:19 -0700540 static const float maxZoom = 4;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800541 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, &maxZoom, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700542
543 // android.jpeg
544
Ruben Brunk17071e42014-10-01 17:00:21 -0700545 size_t sizeOfThumbnailList = (cameraId) ? sizeof(SUPPORT_THUMBNAIL_FRONT_SIZE) /
546 sizeof(int32_t) : sizeof(SUPPORT_THUMBNAIL_REAR_SIZE) / sizeof(int32_t);
547
548 // Copy sizes from front or back camera
549 int32_t jpegThumbnailSizes[sizeOfThumbnailList + 2];
550
551 if (cameraId) {
552 memcpy(jpegThumbnailSizes, SUPPORT_THUMBNAIL_FRONT_SIZE,
553 sizeof(int32_t) * sizeOfThumbnailList);
554 } else {
555 memcpy(jpegThumbnailSizes, SUPPORT_THUMBNAIL_REAR_SIZE,
556 sizeof(int32_t) * sizeOfThumbnailList);
557 }
558
559 // Always include 0,0 size in list
560 jpegThumbnailSizes[sizeOfThumbnailList] = 0;
561 jpegThumbnailSizes[sizeOfThumbnailList + 1] = 0;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700562
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700563 ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
564 jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t));
565
Sungjoong Kang3c006f82012-09-27 16:02:40 -0700566 static const int32_t jpegMaxSize = 10 * 1024 * 1024;
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900567 ADD_OR_SIZE(ANDROID_JPEG_MAX_SIZE, &jpegMaxSize, 1);
568
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700569 // android.stats
570
571 static const uint8_t availableFaceDetectModes[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800572 ANDROID_STATISTICS_FACE_DETECT_MODE_OFF,
573 ANDROID_STATISTICS_FACE_DETECT_MODE_FULL
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700574 };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800575 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700576 availableFaceDetectModes,
577 sizeof(availableFaceDetectModes));
578
Younghwan Joof3312f82012-09-20 13:56:59 -0700579 m_curCameraInfo->maxFaceCount = CAMERA2_MAX_FACES;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800580 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
Sungjoong Kangfd2d78a2012-08-26 17:44:25 -0700581 &(m_curCameraInfo->maxFaceCount), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700582
583 static const int32_t histogramSize = 64;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800584 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700585 &histogramSize, 1);
586
587 static const int32_t maxHistogramCount = 1000;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800588 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700589 &maxHistogramCount, 1);
590
591 static const int32_t sharpnessMapSize[2] = {64, 64};
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800592 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700593 sharpnessMapSize, sizeof(sharpnessMapSize)/sizeof(int32_t));
594
595 static const int32_t maxSharpnessMapValue = 1000;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800596 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700597 &maxSharpnessMapValue, 1);
598
599 // android.control
600
601 static const uint8_t availableSceneModes[] = {
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700602 ANDROID_CONTROL_SCENE_MODE_ACTION,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700603 ANDROID_CONTROL_SCENE_MODE_NIGHT,
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700604 ANDROID_CONTROL_SCENE_MODE_SUNSET,
605 ANDROID_CONTROL_SCENE_MODE_PARTY
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700606 };
607 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
608 availableSceneModes, sizeof(availableSceneModes));
609
610 static const uint8_t availableEffects[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800611 ANDROID_CONTROL_EFFECT_MODE_OFF
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700612 };
613 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_EFFECTS,
614 availableEffects, sizeof(availableEffects));
615
Ruben Brunk11939de2014-01-23 18:21:46 -0800616 static const int32_t max3aRegions[] = {/*AE*/ 1,/*AWB*/ 1,/*AF*/ 1};
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700617 ADD_OR_SIZE(ANDROID_CONTROL_MAX_REGIONS,
Ruben Brunk11939de2014-01-23 18:21:46 -0800618 max3aRegions, sizeof(max3aRegions)/sizeof(max3aRegions[0]));
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700619
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700620 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_MODES,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700621 m_curCameraInfo->availableAeModes, m_curCameraInfo->numAvailableAeModes);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700622
623 static const camera_metadata_rational exposureCompensationStep = {
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700624 1, 1
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700625 };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800626 ADD_OR_SIZE(ANDROID_CONTROL_AE_COMPENSATION_STEP,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700627 &exposureCompensationStep, 1);
628
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700629 int32_t exposureCompensationRange[] = {-3, 3};
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800630 ADD_OR_SIZE(ANDROID_CONTROL_AE_COMPENSATION_RANGE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700631 exposureCompensationRange,
632 sizeof(exposureCompensationRange)/sizeof(int32_t));
633
634 static const int32_t availableTargetFpsRanges[] = {
Sungjoong Kang3c17a3f2012-10-22 14:39:49 -0700635 15, 15, 24, 24, 25, 25, 15, 30, 30, 30
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700636 };
637 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
638 availableTargetFpsRanges,
639 sizeof(availableTargetFpsRanges)/sizeof(int32_t));
640
641 static const uint8_t availableAntibandingModes[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800642 ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF,
643 ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700644 };
645 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
646 availableAntibandingModes, sizeof(availableAntibandingModes));
647
648 static const uint8_t availableAwbModes[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800649 ANDROID_CONTROL_AWB_MODE_OFF,
650 ANDROID_CONTROL_AWB_MODE_AUTO,
651 ANDROID_CONTROL_AWB_MODE_INCANDESCENT,
652 ANDROID_CONTROL_AWB_MODE_FLUORESCENT,
653 ANDROID_CONTROL_AWB_MODE_DAYLIGHT,
654 ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700655 };
656 ADD_OR_SIZE(ANDROID_CONTROL_AWB_AVAILABLE_MODES,
657 availableAwbModes, sizeof(availableAwbModes));
658
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700659 ADD_OR_SIZE(ANDROID_CONTROL_AF_AVAILABLE_MODES,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700660 m_curCameraInfo->availableAfModes, m_curCameraInfo->numAvailableAfModes);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700661
662 static const uint8_t availableVstabModes[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800663 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF,
664 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700665 };
666 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
667 availableVstabModes, sizeof(availableVstabModes));
668
Sungjoong Kangc68cd002012-10-01 21:50:09 -0700669 ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE_OVERRIDES,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700670 m_curCameraInfo->sceneModeOverrides, m_curCameraInfo->numSceneModeOverrides);
Sungjoong Kangc68cd002012-10-01 21:50:09 -0700671
672 static const uint8_t quirkTriggerAuto = 1;
673 ADD_OR_SIZE(ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO,
674 &quirkTriggerAuto, 1);
675
676 static const uint8_t quirkUseZslFormat = 1;
677 ADD_OR_SIZE(ANDROID_QUIRKS_USE_ZSL_FORMAT,
678 &quirkUseZslFormat, 1);
679
Sungjoong Kangc6053422012-10-03 16:10:53 -0700680 static const uint8_t quirkMeteringCropRegion = 1;
681 ADD_OR_SIZE(ANDROID_QUIRKS_METERING_CROP_REGION,
682 &quirkMeteringCropRegion, 1);
683
684
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700685#undef ADD_OR_SIZE
686 /** Allocate metadata if sizing */
687 if (sizeRequest) {
688 ALOGV("Allocating %d entries, %d extra bytes for "
689 "static camera info",
690 entryCount, dataCount);
691 *info = allocate_camera_metadata(entryCount, dataCount);
692 if (*info == NULL) {
693 ALOGE("Unable to allocate camera static info"
694 "(%d entries, %d bytes extra data)",
695 entryCount, dataCount);
696 return NO_MEMORY;
697 }
698 }
699 return OK;
700}
701
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700702status_t ExynosCamera2::constructDefaultRequest(
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700703 int request_template,
704 camera_metadata_t **request,
705 bool sizeRequest) {
706
707 size_t entryCount = 0;
708 size_t dataCount = 0;
709 status_t ret;
710
711#define ADD_OR_SIZE( tag, data, count ) \
712 if ( ( ret = addOrSize(*request, sizeRequest, &entryCount, &dataCount, \
713 tag, data, count) ) != OK ) return ret
714
715 static const int64_t USEC = 1000LL;
716 static const int64_t MSEC = USEC * 1000LL;
717 static const int64_t SEC = MSEC * 1000LL;
718
719 /** android.request */
720
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800721 static const uint8_t metadataMode = ANDROID_REQUEST_METADATA_MODE_NONE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700722 ADD_OR_SIZE(ANDROID_REQUEST_METADATA_MODE, &metadataMode, 1);
723
724 static const int32_t id = 0;
725 ADD_OR_SIZE(ANDROID_REQUEST_ID, &id, 1);
726
727 static const int32_t frameCount = 0;
728 ADD_OR_SIZE(ANDROID_REQUEST_FRAME_COUNT, &frameCount, 1);
729
730 // OUTPUT_STREAMS set by user
731 entryCount += 1;
732 dataCount += 5; // TODO: Should be maximum stream number
733
734 /** android.lens */
735
736 static const float focusDistance = 0;
737 ADD_OR_SIZE(ANDROID_LENS_FOCUS_DISTANCE, &focusDistance, 1);
738
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700739 ADD_OR_SIZE(ANDROID_LENS_APERTURE, &m_curCameraInfo->aperture, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700740
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700741 ADD_OR_SIZE(ANDROID_LENS_FOCAL_LENGTH, &m_curCameraInfo->focalLength, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700742
743 static const float filterDensity = 0;
744 ADD_OR_SIZE(ANDROID_LENS_FILTER_DENSITY, &filterDensity, 1);
745
746 static const uint8_t opticalStabilizationMode =
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800747 ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700748 ADD_OR_SIZE(ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
749 &opticalStabilizationMode, 1);
750
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700751
752 /** android.sensor */
753
Alex Ray30f3ec92013-09-30 10:19:21 -0700754 static const int64_t defaultExposureTime = 8000000LL; // 1/125 s
755 ADD_OR_SIZE(ANDROID_SENSOR_EXPOSURE_TIME, &defaultExposureTime, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700756
757 static const int64_t frameDuration = 33333333L; // 1/30 s
758 ADD_OR_SIZE(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1);
759
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700760
761 /** android.flash */
762
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800763 static const uint8_t flashMode = ANDROID_FLASH_MODE_OFF;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700764 ADD_OR_SIZE(ANDROID_FLASH_MODE, &flashMode, 1);
765
766 static const uint8_t flashPower = 10;
767 ADD_OR_SIZE(ANDROID_FLASH_FIRING_POWER, &flashPower, 1);
768
769 static const int64_t firingTime = 0;
770 ADD_OR_SIZE(ANDROID_FLASH_FIRING_TIME, &firingTime, 1);
771
772 /** Processing block modes */
773 uint8_t hotPixelMode = 0;
774 uint8_t demosaicMode = 0;
775 uint8_t noiseMode = 0;
776 uint8_t shadingMode = 0;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700777 uint8_t colorMode = 0;
778 uint8_t tonemapMode = 0;
779 uint8_t edgeMode = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800780 uint8_t vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF;
Sungjoong Kangfac627c2012-09-18 23:44:00 -0700781
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700782 switch (request_template) {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800783 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
784 vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON;
785 // fall-through
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700786 case CAMERA2_TEMPLATE_STILL_CAPTURE:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800787 // fall-through
788 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
789 hotPixelMode = ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY;
790 demosaicMode = ANDROID_DEMOSAIC_MODE_HIGH_QUALITY;
791 noiseMode = ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY;
792 shadingMode = ANDROID_SHADING_MODE_HIGH_QUALITY;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800793 colorMode = ANDROID_COLOR_CORRECTION_MODE_HIGH_QUALITY;
794 tonemapMode = ANDROID_TONEMAP_MODE_HIGH_QUALITY;
795 edgeMode = ANDROID_EDGE_MODE_HIGH_QUALITY;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700796 break;
797 case CAMERA2_TEMPLATE_VIDEO_RECORD:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800798 vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON;
799 // fall-through
800 case CAMERA2_TEMPLATE_PREVIEW:
801 // fall-through
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700802 default:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800803 hotPixelMode = ANDROID_HOT_PIXEL_MODE_FAST;
804 demosaicMode = ANDROID_DEMOSAIC_MODE_FAST;
805 noiseMode = ANDROID_NOISE_REDUCTION_MODE_FAST;
806 shadingMode = ANDROID_SHADING_MODE_FAST;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800807 colorMode = ANDROID_COLOR_CORRECTION_MODE_FAST;
808 tonemapMode = ANDROID_TONEMAP_MODE_FAST;
809 edgeMode = ANDROID_EDGE_MODE_FAST;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700810 break;
811 }
812 ADD_OR_SIZE(ANDROID_HOT_PIXEL_MODE, &hotPixelMode, 1);
813 ADD_OR_SIZE(ANDROID_DEMOSAIC_MODE, &demosaicMode, 1);
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800814 ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_MODE, &noiseMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700815 ADD_OR_SIZE(ANDROID_SHADING_MODE, &shadingMode, 1);
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800816 ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_MODE, &colorMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700817 ADD_OR_SIZE(ANDROID_TONEMAP_MODE, &tonemapMode, 1);
818 ADD_OR_SIZE(ANDROID_EDGE_MODE, &edgeMode, 1);
Sungjoong Kangfac627c2012-09-18 23:44:00 -0700819 ADD_OR_SIZE(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, &vstabMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700820
821 /** android.noise */
822 static const uint8_t noiseStrength = 5;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800823 ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_STRENGTH, &noiseStrength, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700824
825 /** android.color */
826 static const float colorTransform[9] = {
827 1.0f, 0.f, 0.f,
828 0.f, 1.f, 0.f,
829 0.f, 0.f, 1.f
830 };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800831 ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_TRANSFORM, colorTransform, 9);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700832
833 /** android.tonemap */
834 static const float tonemapCurve[4] = {
835 0.f, 0.f,
836 1.f, 1.f
837 };
838 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_RED, tonemapCurve, 32); // sungjoong
839 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_GREEN, tonemapCurve, 32);
840 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_BLUE, tonemapCurve, 32);
841
842 /** android.edge */
843 static const uint8_t edgeStrength = 5;
844 ADD_OR_SIZE(ANDROID_EDGE_STRENGTH, &edgeStrength, 1);
845
846 /** android.scaler */
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700847 int32_t cropRegion[3] = {
848 0, 0, m_curCameraInfo->sensorW
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700849 };
850 ADD_OR_SIZE(ANDROID_SCALER_CROP_REGION, cropRegion, 3);
851
852 /** android.jpeg */
Hyeonmyeong Choi87423e52012-10-04 16:34:55 +0900853 static const int32_t jpegQuality = 100;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700854 ADD_OR_SIZE(ANDROID_JPEG_QUALITY, &jpegQuality, 1);
855
856 static const int32_t thumbnailSize[2] = {
Sungjoong Kang2d5e6ec2012-08-30 15:14:17 +0900857 160, 120
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700858 };
859 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_SIZE, thumbnailSize, 2);
860
Hyeonmyeong Choi87423e52012-10-04 16:34:55 +0900861 static const int32_t thumbnailQuality = 100;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700862 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_QUALITY, &thumbnailQuality, 1);
863
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700864 static const double gpsCoordinates[3] = {
865 0, 0, 0
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700866 };
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700867 ADD_OR_SIZE(ANDROID_JPEG_GPS_COORDINATES, gpsCoordinates, 3);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700868
869 static const uint8_t gpsProcessingMethod[32] = "None";
870 ADD_OR_SIZE(ANDROID_JPEG_GPS_PROCESSING_METHOD, gpsProcessingMethod, 32);
871
872 static const int64_t gpsTimestamp = 0;
873 ADD_OR_SIZE(ANDROID_JPEG_GPS_TIMESTAMP, &gpsTimestamp, 1);
874
875 static const int32_t jpegOrientation = 0;
876 ADD_OR_SIZE(ANDROID_JPEG_ORIENTATION, &jpegOrientation, 1);
877
878 /** android.stats */
879
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800880 static const uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_FULL;
881 ADD_OR_SIZE(ANDROID_STATISTICS_FACE_DETECT_MODE, &faceDetectMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700882
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800883 static const uint8_t histogramMode = ANDROID_STATISTICS_HISTOGRAM_MODE_OFF;
884 ADD_OR_SIZE(ANDROID_STATISTICS_HISTOGRAM_MODE, &histogramMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700885
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800886 static const uint8_t sharpnessMapMode = ANDROID_STATISTICS_HISTOGRAM_MODE_OFF;
887 ADD_OR_SIZE(ANDROID_STATISTICS_SHARPNESS_MAP_MODE, &sharpnessMapMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700888
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700889
890 /** android.control */
891
892 uint8_t controlIntent = 0;
893 switch (request_template) {
894 case CAMERA2_TEMPLATE_PREVIEW:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800895 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700896 break;
897 case CAMERA2_TEMPLATE_STILL_CAPTURE:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800898 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700899 break;
900 case CAMERA2_TEMPLATE_VIDEO_RECORD:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800901 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700902 break;
903 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800904 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700905 break;
906 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800907 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700908 break;
909 default:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800910 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_CUSTOM;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700911 break;
912 }
913 ADD_OR_SIZE(ANDROID_CONTROL_CAPTURE_INTENT, &controlIntent, 1);
914
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800915 static const uint8_t controlMode = ANDROID_CONTROL_MODE_AUTO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700916 ADD_OR_SIZE(ANDROID_CONTROL_MODE, &controlMode, 1);
917
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800918 static const uint8_t effectMode = ANDROID_CONTROL_EFFECT_MODE_OFF;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700919 ADD_OR_SIZE(ANDROID_CONTROL_EFFECT_MODE, &effectMode, 1);
920
Ruben Brunk7b21d942014-01-17 17:17:01 -0800921 static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_DISABLED;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700922 ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE, &sceneMode, 1);
923
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800924 static const uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700925 ADD_OR_SIZE(ANDROID_CONTROL_AE_MODE, &aeMode, 1);
926
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700927 int32_t controlRegions[5] = {
928 0, 0, m_curCameraInfo->sensorW, m_curCameraInfo->sensorH, 1000
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700929 };
930 ADD_OR_SIZE(ANDROID_CONTROL_AE_REGIONS, controlRegions, 5);
931
932 static const int32_t aeExpCompensation = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800933 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, &aeExpCompensation, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700934
935 static const int32_t aeTargetFpsRange[2] = {
Sungjoong Kangb8146872012-10-01 13:01:11 -0700936 15, 30
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700937 };
938 ADD_OR_SIZE(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, aeTargetFpsRange, 2);
939
940 static const uint8_t aeAntibandingMode =
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800941 ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700942 ADD_OR_SIZE(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &aeAntibandingMode, 1);
943
944 static const uint8_t awbMode =
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800945 ANDROID_CONTROL_AWB_MODE_AUTO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700946 ADD_OR_SIZE(ANDROID_CONTROL_AWB_MODE, &awbMode, 1);
947
948 ADD_OR_SIZE(ANDROID_CONTROL_AWB_REGIONS, controlRegions, 5);
949
950 uint8_t afMode = 0;
951 switch (request_template) {
952 case CAMERA2_TEMPLATE_PREVIEW:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800953 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700954 break;
955 case CAMERA2_TEMPLATE_STILL_CAPTURE:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800956 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700957 break;
958 case CAMERA2_TEMPLATE_VIDEO_RECORD:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800959 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700960 break;
961 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800962 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700963 break;
964 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800965 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700966 break;
967 default:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800968 afMode = ANDROID_CONTROL_AF_MODE_AUTO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700969 break;
970 }
971 ADD_OR_SIZE(ANDROID_CONTROL_AF_MODE, &afMode, 1);
972
973 ADD_OR_SIZE(ANDROID_CONTROL_AF_REGIONS, controlRegions, 5);
974
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700975 if (sizeRequest) {
976 ALOGV("Allocating %d entries, %d extra bytes for "
977 "request template type %d",
978 entryCount, dataCount, request_template);
979 *request = allocate_camera_metadata(entryCount, dataCount);
980 if (*request == NULL) {
981 ALOGE("Unable to allocate new request template type %d "
982 "(%d entries, %d bytes extra data)", request_template,
983 entryCount, dataCount);
984 return NO_MEMORY;
985 }
986 }
987 return OK;
988#undef ADD_OR_SIZE
989}
990
991}