blob: 960a5e238b783a34e0b5db83b775a32eb46ecfb4 [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
41class Sensor {
42public:
43 /**
44 * Static sensor characteristics
45 */
Sungjoong Kang9dd63e12012-07-24 00:25:51 +090046 static const unsigned int kResolution[2][2];
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070047
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 Shinc15a6b02012-06-05 01:08:14 -070080};
81
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070082
Sungjoong Kang9dd63e12012-07-24 00:25:51 +090083
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -070084const uint32_t Sensor::kAvailableSensitivities[5] =
85 {100, 200, 400, 800, 1600};
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070086const nsecs_t Sensor::kExposureTimeRange[2] =
87 {1000L, 30000000000L} ; // 1 us - 30 sec
88const nsecs_t Sensor::kFrameDurationRange[2] =
89 {33331760L, 30000000000L}; // ~1/30 s - 30 sec
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070090
Igor Murashkinfd1276b2012-11-27 16:24:58 -080091const uint8_t Sensor::kColorFilterArrangement = ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGGB;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070092
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +090093const uint32_t kAvailableFormats[5] = {
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070094 HAL_PIXEL_FORMAT_RAW_SENSOR,
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +090095 HAL_PIXEL_FORMAT_BLOB,
96 HAL_PIXEL_FORMAT_RGBA_8888,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070097 HAL_PIXEL_FORMAT_YV12,
98 HAL_PIXEL_FORMAT_YCrCb_420_SP
99};
100
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700101// Output image data characteristics
102const uint32_t Sensor::kMaxRawValue = 4000;
103const uint32_t Sensor::kBlackLevel = 1000;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700104
105const uint64_t kAvailableRawMinDurations[1] = {
106 Sensor::kFrameDurationRange[0]
107};
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900108
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700109const uint64_t kAvailableProcessedMinDurations[1] = {
110 Sensor::kFrameDurationRange[0]
111};
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700112const uint64_t kAvailableJpegMinDurations[1] = {
113 Sensor::kFrameDurationRange[0]
114};
115
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700116const int32_t scalerResolutionS5K4E5[] =
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900117{
hyeonmyeong Choi0b7b7572012-09-06 12:45:44 -0700118 1920, 1080, // 16:9
119 1440, 1080, // 4:3
120 1440, 960, // 3:2
121 1280, 1024, // 5:4
122 1280, 720, // 16:9
123 960, 720, // 4:3
124 800, 480, // 5:3
125 768, 576, // 4:3
126 720, 576, // 5:4
127 720, 480, // 3:2
128 640, 480, // 4:3
129 352, 288, // 11:9
130 320, 240, // 4:3
131 240, 160, // 3:2
132 176, 144, // 6:5
133 128, 96, // 4:3
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700134};
135
136const int32_t jpegResolutionS5K4E5[] =
137{
138 2560, 1920,
Sungjoong Kange4657e32012-08-28 15:02:19 -0700139 2560, 1440,
hyeonmyeong Choia44c3362012-08-30 19:01:25 -0700140 2160, 1440,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700141 2048, 1536,
142 1600, 1200,
143 1280, 1024,
144 1280, 960,
145 1152, 864,
146 640, 480,
147 320, 240,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700148};
149
Sungjoong Kang73c63372012-10-04 21:51:47 -0700150const uint8_t availableAfModesS5K4E5[] =
151{
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800152 ANDROID_CONTROL_AF_MODE_OFF,
153 ANDROID_CONTROL_AF_MODE_AUTO,
154 ANDROID_CONTROL_AF_MODE_MACRO,
155 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
156 ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO
Sungjoong Kang73c63372012-10-04 21:51:47 -0700157};
158
159const uint8_t sceneModeOverridesS5K4E5[] =
160{
161 // ANDROID_CONTROL_SCENE_MODE_ACTION
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800162 ANDROID_CONTROL_AE_MODE_ON,
163 ANDROID_CONTROL_AWB_MODE_AUTO,
164 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700165 // ANDROID_CONTROL_SCENE_MODE_NIGHT
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800166 ANDROID_CONTROL_AE_MODE_ON,
167 ANDROID_CONTROL_AWB_MODE_AUTO,
168 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700169 // ANDROID_CONTROL_SCENE_MODE_SUNSET
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800170 ANDROID_CONTROL_AE_MODE_ON,
171 ANDROID_CONTROL_AWB_MODE_DAYLIGHT,
172 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700173 // ANDROID_CONTROL_SCENE_MODE_PARTY
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800174 ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH,
175 ANDROID_CONTROL_AWB_MODE_AUTO,
176 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
Sungjoong Kang73c63372012-10-04 21:51:47 -0700177};
178
179const uint8_t availableAeModesS5K4E5[] =
180{
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800181 ANDROID_CONTROL_AE_MODE_OFF,
182 ANDROID_CONTROL_AE_MODE_ON,
183 ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH
Sungjoong Kang73c63372012-10-04 21:51:47 -0700184};
185
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700186ExynosCamera2InfoS5K4E5::ExynosCamera2InfoS5K4E5()
187{
188 sensorW = 2560;
189 sensorH = 1920;
190 sensorRawW = (2560 + 16);
191 sensorRawH = (1920 + 10);
192 numScalerResolution = ARRAY_SIZE(scalerResolutionS5K4E5)/2;
193 scalerResolutions = scalerResolutionS5K4E5;
194 numJpegResolution = ARRAY_SIZE(jpegResolutionS5K4E5)/2;
195 jpegResolutions = jpegResolutionS5K4E5;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700196 minFocusDistance = 0.1f;
197 focalLength = 3.43f;
198 aperture = 2.7f;
Sungjoong Kange00f6592012-09-07 19:05:31 -0700199 fnumber = 2.7f;
Sungjoong Kang73c63372012-10-04 21:51:47 -0700200 availableAfModes = availableAfModesS5K4E5;
201 numAvailableAfModes = ARRAY_SIZE(availableAfModesS5K4E5);
202 sceneModeOverrides = sceneModeOverridesS5K4E5;
203 numSceneModeOverrides = ARRAY_SIZE(sceneModeOverridesS5K4E5);
204 availableAeModes = availableAeModesS5K4E5;
205 numAvailableAeModes = ARRAY_SIZE(availableAeModesS5K4E5);
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700206}
207
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700208ExynosCamera2InfoS5K4E5::~ExynosCamera2InfoS5K4E5()
209{
210 ALOGV("%s", __FUNCTION__);
211}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700212const int32_t scalerResolutionS5K6A3[] =
213{
hyeonmyeong Choi0b7b7572012-09-06 12:45:44 -0700214 1344, 896, // 3:2
215 1280, 1024, // 5:4
Sungjoong Kang9c046e32012-10-09 12:00:51 -0700216 1024, 1024, // 1:1
hyeonmyeong Choi0b7b7572012-09-06 12:45:44 -0700217 1280, 960, // 4:3
218 1280, 720, // 16:9
219 960, 720, // 4:3
220 800, 480, // 5:3
221 768, 576, // 4:3
222 720, 576, // 5:4
223 720, 480, // 3:2
224 640, 480, // 4:3
225 352, 288, // 11:9
226 320, 240, // 4:3
227 240, 160, // 3:2
228 176, 144, // 6:5
229 128, 96, // 4:3
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700230};
231
232const int32_t jpegResolutionS5K6A3[] =
233{
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700234 1392, 1392,
235 1392, 1040,
hyeonmyeong Choia44c3362012-08-30 19:01:25 -0700236 1392, 928,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700237 1392, 784,
238 1280, 1024,
Sungjoong Kangad378612012-08-17 12:34:33 -0700239 1280, 960,
Sungjoong Kange4657e32012-08-28 15:02:19 -0700240 1280, 720,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700241 1152, 864,
242 640, 480,
243 320, 240,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700244};
245
Sungjoong Kang73c63372012-10-04 21:51:47 -0700246const uint8_t availableAfModesS5K6A3[] =
247{
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800248 ANDROID_CONTROL_AF_MODE_OFF
Sungjoong Kang73c63372012-10-04 21:51:47 -0700249};
250
251const uint8_t sceneModeOverridesS5K6A3[] =
252{
253 // ANDROID_CONTROL_SCENE_MODE_ACTION
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800254 ANDROID_CONTROL_AE_MODE_ON,
255 ANDROID_CONTROL_AWB_MODE_AUTO,
256 ANDROID_CONTROL_AF_MODE_OFF,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700257 // ANDROID_CONTROL_SCENE_MODE_NIGHT
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800258 ANDROID_CONTROL_AE_MODE_ON,
259 ANDROID_CONTROL_AWB_MODE_AUTO,
260 ANDROID_CONTROL_AF_MODE_OFF,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700261 // ANDROID_CONTROL_SCENE_MODE_SUNSET
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800262 ANDROID_CONTROL_AE_MODE_ON,
263 ANDROID_CONTROL_AWB_MODE_DAYLIGHT,
264 ANDROID_CONTROL_AF_MODE_OFF,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700265 // ANDROID_CONTROL_SCENE_MODE_PARTY
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800266 ANDROID_CONTROL_AE_MODE_ON,
267 ANDROID_CONTROL_AWB_MODE_AUTO,
268 ANDROID_CONTROL_AF_MODE_OFF
Sungjoong Kang73c63372012-10-04 21:51:47 -0700269};
270
271const uint8_t availableAeModesS5K6A3[] =
272{
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800273 ANDROID_CONTROL_AE_MODE_OFF,
274 ANDROID_CONTROL_AE_MODE_ON
Sungjoong Kang73c63372012-10-04 21:51:47 -0700275};
276
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700277ExynosCamera2InfoS5K6A3::ExynosCamera2InfoS5K6A3()
278{
279 sensorW = 1392;
280 sensorH = 1392;
281 sensorRawW = (1392 + 16);
282 sensorRawH = (1392 + 10);
283 numScalerResolution = ARRAY_SIZE(scalerResolutionS5K6A3)/2;
284 scalerResolutions = scalerResolutionS5K6A3;
285 numJpegResolution = ARRAY_SIZE(jpegResolutionS5K6A3)/2;
286 jpegResolutions = jpegResolutionS5K6A3;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700287 minFocusDistance = 0.0f;
288 focalLength = 2.73f;
289 aperture = 2.8f;
Sungjoong Kange00f6592012-09-07 19:05:31 -0700290 fnumber = 2.8f;
Sungjoong Kang73c63372012-10-04 21:51:47 -0700291 availableAfModes = availableAfModesS5K6A3;
292 numAvailableAfModes = ARRAY_SIZE(availableAfModesS5K6A3);
293 sceneModeOverrides = sceneModeOverridesS5K6A3;
294 numSceneModeOverrides = ARRAY_SIZE(sceneModeOverridesS5K6A3);
295 availableAeModes = availableAeModesS5K6A3;
296 numAvailableAeModes = ARRAY_SIZE(availableAeModesS5K6A3);
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700297}
298
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700299ExynosCamera2InfoS5K6A3::~ExynosCamera2InfoS5K6A3()
300{
301 ALOGV("%s", __FUNCTION__);
302}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700303ExynosCamera2::ExynosCamera2(int cameraId):
304 m_cameraId(cameraId)
305{
306 if (cameraId == 0)
307 m_curCameraInfo = new ExynosCamera2InfoS5K4E5;
308 else
309 m_curCameraInfo = new ExynosCamera2InfoS5K6A3;
310}
311
312ExynosCamera2::~ExynosCamera2()
313{
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700314 ALOGV("%s", __FUNCTION__);
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700315 delete m_curCameraInfo;
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700316 m_curCameraInfo = NULL;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700317}
318
319int32_t ExynosCamera2::getSensorW()
320{
321 return m_curCameraInfo->sensorW;
322}
323
324int32_t ExynosCamera2::getSensorH()
325{
326 return m_curCameraInfo->sensorH;
327}
328
329int32_t ExynosCamera2::getSensorRawW()
330{
331 return m_curCameraInfo->sensorRawW;
332}
333
334int32_t ExynosCamera2::getSensorRawH()
335{
336 return m_curCameraInfo->sensorRawH;
337}
338
339bool ExynosCamera2::isSupportedResolution(int width, int height)
340{
341 int i;
342 for (i = 0 ; i < m_curCameraInfo->numScalerResolution ; i++) {
343 if (m_curCameraInfo->scalerResolutions[2*i] == width
344 && m_curCameraInfo->scalerResolutions[2*i+1] == height) {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900345 return true;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700346 }
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900347 }
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700348 return false;
349}
350
351bool ExynosCamera2::isSupportedJpegResolution(int width, int height)
352{
353 int i;
354 for (i = 0 ; i < m_curCameraInfo->numJpegResolution ; i++) {
355 if (m_curCameraInfo->jpegResolutions[2*i] == width
356 && m_curCameraInfo->jpegResolutions[2*i+1] == height) {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900357 return true;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700358 }
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900359 }
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700360 return false;
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900361}
362
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700363status_t addOrSize(camera_metadata_t *request,
364 bool sizeRequest,
365 size_t *entryCount,
366 size_t *dataCount,
367 uint32_t tag,
368 const void *entryData,
369 size_t entryDataCount) {
370 status_t res;
371 if (!sizeRequest) {
372 return add_camera_metadata_entry(request, tag, entryData,
373 entryDataCount);
374 } else {
375 int type = get_camera_metadata_tag_type(tag);
376 if (type < 0 ) return BAD_VALUE;
377 (*entryCount)++;
378 (*dataCount) += calculate_camera_metadata_entry_data_size(type,
379 entryDataCount);
380 return OK;
381 }
382}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700383
384status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info,
385 int cameraId, bool sizeRequest) {
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700386
387 size_t entryCount = 0;
388 size_t dataCount = 0;
389 status_t ret;
390
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700391#define ADD_OR_SIZE( tag, data, count ) \
392 if ( ( ret = addOrSize(*info, sizeRequest, &entryCount, &dataCount, \
393 tag, data, count) ) != OK ) return ret
394
395 // android.lens
396
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800397 ADD_OR_SIZE(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700398 &(m_curCameraInfo->minFocusDistance), 1);
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800399 ADD_OR_SIZE(ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700400 &(m_curCameraInfo->minFocusDistance), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700401
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800402 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700403 &m_curCameraInfo->focalLength, 1);
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800404 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_APERTURES,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700405 &m_curCameraInfo->aperture, 1);
406
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700407 static const float filterDensity = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800408 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700409 &filterDensity, 1);
410 static const uint8_t availableOpticalStabilization =
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800411 ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;
412 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700413 &availableOpticalStabilization, 1);
414
415 static const int32_t lensShadingMapSize[] = {1, 1};
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800416 ADD_OR_SIZE(ANDROID_LENS_INFO_SHADING_MAP_SIZE, lensShadingMapSize,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700417 sizeof(lensShadingMapSize)/sizeof(int32_t));
418
419 static const float lensShadingMap[3 * 1 * 1 ] =
420 { 1.f, 1.f, 1.f };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800421 ADD_OR_SIZE(ANDROID_LENS_INFO_SHADING_MAP, lensShadingMap,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700422 sizeof(lensShadingMap)/sizeof(float));
423
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900424 int32_t lensFacing = cameraId ?
425 ANDROID_LENS_FACING_FRONT : ANDROID_LENS_FACING_BACK;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700426 ADD_OR_SIZE(ANDROID_LENS_FACING, &lensFacing, 1);
427
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700428 // android.sensor
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800429 ADD_OR_SIZE(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700430 Sensor::kExposureTimeRange, 2);
431
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800432 ADD_OR_SIZE(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700433 &Sensor::kFrameDurationRange[1], 1);
434
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800435 ADD_OR_SIZE(ANDROID_SENSOR_INFO_AVAILABLE_SENSITIVITIES,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700436 Sensor::kAvailableSensitivities,
437 sizeof(Sensor::kAvailableSensitivities)
438 /sizeof(uint32_t));
439
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800440 ADD_OR_SIZE(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700441 &Sensor::kColorFilterArrangement, 1);
442
443 static const float sensorPhysicalSize[2] = {3.20f, 2.40f}; // mm
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800444 ADD_OR_SIZE(ANDROID_SENSOR_INFO_PHYSICAL_SIZE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700445 sensorPhysicalSize, 2);
446
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700447 int32_t pixelArraySize[2] = {
448 m_curCameraInfo->sensorW, m_curCameraInfo->sensorH
449 };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800450 ADD_OR_SIZE(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, pixelArraySize, 2);
451 ADD_OR_SIZE(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, pixelArraySize,2);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700452
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800453 ADD_OR_SIZE(ANDROID_SENSOR_INFO_WHITE_LEVEL,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700454 &Sensor::kMaxRawValue, 1);
455
456 static const int32_t blackLevelPattern[4] = {
457 Sensor::kBlackLevel, Sensor::kBlackLevel,
458 Sensor::kBlackLevel, Sensor::kBlackLevel
459 };
460 ADD_OR_SIZE(ANDROID_SENSOR_BLACK_LEVEL_PATTERN,
461 blackLevelPattern, sizeof(blackLevelPattern)/sizeof(int32_t));
462
463 //TODO: sensor color calibration fields
464
465 // android.flash
Younghwan Joo9a710a42012-09-05 17:52:08 -0700466 uint8_t flashAvailable;
467 if (cameraId == 0)
468 flashAvailable = 1;
469 else
470 flashAvailable = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800471 ADD_OR_SIZE(ANDROID_FLASH_INFO_AVAILABLE, &flashAvailable, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700472
473 static const int64_t flashChargeDuration = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800474 ADD_OR_SIZE(ANDROID_FLASH_INFO_CHARGE_DURATION, &flashChargeDuration, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700475
476 // android.tonemap
477
478 static const int32_t tonemapCurvePoints = 128;
479 ADD_OR_SIZE(ANDROID_TONEMAP_MAX_CURVE_POINTS, &tonemapCurvePoints, 1);
480
481 // android.scaler
482
483 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_FORMATS,
484 kAvailableFormats,
485 sizeof(kAvailableFormats)/sizeof(uint32_t));
486
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700487 int32_t availableRawSizes[2] = {
488 m_curCameraInfo->sensorRawW, m_curCameraInfo->sensorRawH
489 };
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700490 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_SIZES,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700491 availableRawSizes, 2);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700492
493 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS,
494 kAvailableRawMinDurations,
495 sizeof(kAvailableRawMinDurations)/sizeof(uint64_t));
496
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700497
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700498 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES,
499 m_curCameraInfo->scalerResolutions,
500 (m_curCameraInfo->numScalerResolution)*2);
501 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES,
502 m_curCameraInfo->jpegResolutions,
503 (m_curCameraInfo->numJpegResolution)*2);
504
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700505 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS,
506 kAvailableProcessedMinDurations,
507 sizeof(kAvailableProcessedMinDurations)/sizeof(uint64_t));
508
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700509 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS,
510 kAvailableJpegMinDurations,
511 sizeof(kAvailableJpegMinDurations)/sizeof(uint64_t));
512
Sungjoong Kange4657e32012-08-28 15:02:19 -0700513 static const float maxZoom = 4;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800514 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, &maxZoom, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700515
516 // android.jpeg
517
518 static const int32_t jpegThumbnailSizes[] = {
519 160, 120,
Sungjoong Kang2d5e6ec2012-08-30 15:14:17 +0900520 160, 160,
521 160, 90,
Sungjoong Kang4017b082012-09-21 15:44:48 -0700522 144, 96,
523 0, 0
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700524 };
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700525
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700526 ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
527 jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t));
528
Sungjoong Kang3c006f82012-09-27 16:02:40 -0700529 static const int32_t jpegMaxSize = 10 * 1024 * 1024;
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900530 ADD_OR_SIZE(ANDROID_JPEG_MAX_SIZE, &jpegMaxSize, 1);
531
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700532 // android.stats
533
534 static const uint8_t availableFaceDetectModes[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800535 ANDROID_STATISTICS_FACE_DETECT_MODE_OFF,
536 ANDROID_STATISTICS_FACE_DETECT_MODE_FULL
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700537 };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800538 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700539 availableFaceDetectModes,
540 sizeof(availableFaceDetectModes));
541
Younghwan Joof3312f82012-09-20 13:56:59 -0700542 m_curCameraInfo->maxFaceCount = CAMERA2_MAX_FACES;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800543 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
Sungjoong Kangfd2d78a2012-08-26 17:44:25 -0700544 &(m_curCameraInfo->maxFaceCount), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700545
546 static const int32_t histogramSize = 64;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800547 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700548 &histogramSize, 1);
549
550 static const int32_t maxHistogramCount = 1000;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800551 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700552 &maxHistogramCount, 1);
553
554 static const int32_t sharpnessMapSize[2] = {64, 64};
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800555 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700556 sharpnessMapSize, sizeof(sharpnessMapSize)/sizeof(int32_t));
557
558 static const int32_t maxSharpnessMapValue = 1000;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800559 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700560 &maxSharpnessMapValue, 1);
561
562 // android.control
563
564 static const uint8_t availableSceneModes[] = {
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700565 ANDROID_CONTROL_SCENE_MODE_ACTION,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700566 ANDROID_CONTROL_SCENE_MODE_NIGHT,
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700567 ANDROID_CONTROL_SCENE_MODE_SUNSET,
568 ANDROID_CONTROL_SCENE_MODE_PARTY
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700569 };
570 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
571 availableSceneModes, sizeof(availableSceneModes));
572
573 static const uint8_t availableEffects[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800574 ANDROID_CONTROL_EFFECT_MODE_OFF
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700575 };
576 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_EFFECTS,
577 availableEffects, sizeof(availableEffects));
578
Sungjoong Kang8e2c2fd2012-08-27 00:02:22 -0700579 int32_t max3aRegions = 1;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700580 ADD_OR_SIZE(ANDROID_CONTROL_MAX_REGIONS,
581 &max3aRegions, 1);
582
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700583 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_MODES,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700584 m_curCameraInfo->availableAeModes, m_curCameraInfo->numAvailableAeModes);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700585
586 static const camera_metadata_rational exposureCompensationStep = {
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700587 1, 1
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700588 };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800589 ADD_OR_SIZE(ANDROID_CONTROL_AE_COMPENSATION_STEP,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700590 &exposureCompensationStep, 1);
591
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700592 int32_t exposureCompensationRange[] = {-3, 3};
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800593 ADD_OR_SIZE(ANDROID_CONTROL_AE_COMPENSATION_RANGE,
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700594 exposureCompensationRange,
595 sizeof(exposureCompensationRange)/sizeof(int32_t));
596
597 static const int32_t availableTargetFpsRanges[] = {
Sungjoong Kang3c17a3f2012-10-22 14:39:49 -0700598 15, 15, 24, 24, 25, 25, 15, 30, 30, 30
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700599 };
600 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
601 availableTargetFpsRanges,
602 sizeof(availableTargetFpsRanges)/sizeof(int32_t));
603
604 static const uint8_t availableAntibandingModes[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800605 ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF,
606 ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700607 };
608 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
609 availableAntibandingModes, sizeof(availableAntibandingModes));
610
611 static const uint8_t availableAwbModes[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800612 ANDROID_CONTROL_AWB_MODE_OFF,
613 ANDROID_CONTROL_AWB_MODE_AUTO,
614 ANDROID_CONTROL_AWB_MODE_INCANDESCENT,
615 ANDROID_CONTROL_AWB_MODE_FLUORESCENT,
616 ANDROID_CONTROL_AWB_MODE_DAYLIGHT,
617 ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700618 };
619 ADD_OR_SIZE(ANDROID_CONTROL_AWB_AVAILABLE_MODES,
620 availableAwbModes, sizeof(availableAwbModes));
621
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700622 ADD_OR_SIZE(ANDROID_CONTROL_AF_AVAILABLE_MODES,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700623 m_curCameraInfo->availableAfModes, m_curCameraInfo->numAvailableAfModes);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700624
625 static const uint8_t availableVstabModes[] = {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800626 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF,
627 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700628 };
629 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
630 availableVstabModes, sizeof(availableVstabModes));
631
Sungjoong Kangc68cd002012-10-01 21:50:09 -0700632 ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE_OVERRIDES,
Sungjoong Kang73c63372012-10-04 21:51:47 -0700633 m_curCameraInfo->sceneModeOverrides, m_curCameraInfo->numSceneModeOverrides);
Sungjoong Kangc68cd002012-10-01 21:50:09 -0700634
635 static const uint8_t quirkTriggerAuto = 1;
636 ADD_OR_SIZE(ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO,
637 &quirkTriggerAuto, 1);
638
639 static const uint8_t quirkUseZslFormat = 1;
640 ADD_OR_SIZE(ANDROID_QUIRKS_USE_ZSL_FORMAT,
641 &quirkUseZslFormat, 1);
642
Sungjoong Kangc6053422012-10-03 16:10:53 -0700643 static const uint8_t quirkMeteringCropRegion = 1;
644 ADD_OR_SIZE(ANDROID_QUIRKS_METERING_CROP_REGION,
645 &quirkMeteringCropRegion, 1);
646
647
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700648#undef ADD_OR_SIZE
649 /** Allocate metadata if sizing */
650 if (sizeRequest) {
651 ALOGV("Allocating %d entries, %d extra bytes for "
652 "static camera info",
653 entryCount, dataCount);
654 *info = allocate_camera_metadata(entryCount, dataCount);
655 if (*info == NULL) {
656 ALOGE("Unable to allocate camera static info"
657 "(%d entries, %d bytes extra data)",
658 entryCount, dataCount);
659 return NO_MEMORY;
660 }
661 }
662 return OK;
663}
664
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700665status_t ExynosCamera2::constructDefaultRequest(
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700666 int request_template,
667 camera_metadata_t **request,
668 bool sizeRequest) {
669
670 size_t entryCount = 0;
671 size_t dataCount = 0;
672 status_t ret;
673
674#define ADD_OR_SIZE( tag, data, count ) \
675 if ( ( ret = addOrSize(*request, sizeRequest, &entryCount, &dataCount, \
676 tag, data, count) ) != OK ) return ret
677
678 static const int64_t USEC = 1000LL;
679 static const int64_t MSEC = USEC * 1000LL;
680 static const int64_t SEC = MSEC * 1000LL;
681
682 /** android.request */
683
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800684 static const uint8_t metadataMode = ANDROID_REQUEST_METADATA_MODE_NONE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700685 ADD_OR_SIZE(ANDROID_REQUEST_METADATA_MODE, &metadataMode, 1);
686
687 static const int32_t id = 0;
688 ADD_OR_SIZE(ANDROID_REQUEST_ID, &id, 1);
689
690 static const int32_t frameCount = 0;
691 ADD_OR_SIZE(ANDROID_REQUEST_FRAME_COUNT, &frameCount, 1);
692
693 // OUTPUT_STREAMS set by user
694 entryCount += 1;
695 dataCount += 5; // TODO: Should be maximum stream number
696
697 /** android.lens */
698
699 static const float focusDistance = 0;
700 ADD_OR_SIZE(ANDROID_LENS_FOCUS_DISTANCE, &focusDistance, 1);
701
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700702 ADD_OR_SIZE(ANDROID_LENS_APERTURE, &m_curCameraInfo->aperture, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700703
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700704 ADD_OR_SIZE(ANDROID_LENS_FOCAL_LENGTH, &m_curCameraInfo->focalLength, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700705
706 static const float filterDensity = 0;
707 ADD_OR_SIZE(ANDROID_LENS_FILTER_DENSITY, &filterDensity, 1);
708
709 static const uint8_t opticalStabilizationMode =
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800710 ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700711 ADD_OR_SIZE(ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
712 &opticalStabilizationMode, 1);
713
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700714
715 /** android.sensor */
716
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700717
718 static const int64_t frameDuration = 33333333L; // 1/30 s
719 ADD_OR_SIZE(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1);
720
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700721
722 /** android.flash */
723
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800724 static const uint8_t flashMode = ANDROID_FLASH_MODE_OFF;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700725 ADD_OR_SIZE(ANDROID_FLASH_MODE, &flashMode, 1);
726
727 static const uint8_t flashPower = 10;
728 ADD_OR_SIZE(ANDROID_FLASH_FIRING_POWER, &flashPower, 1);
729
730 static const int64_t firingTime = 0;
731 ADD_OR_SIZE(ANDROID_FLASH_FIRING_TIME, &firingTime, 1);
732
733 /** Processing block modes */
734 uint8_t hotPixelMode = 0;
735 uint8_t demosaicMode = 0;
736 uint8_t noiseMode = 0;
737 uint8_t shadingMode = 0;
738 uint8_t geometricMode = 0;
739 uint8_t colorMode = 0;
740 uint8_t tonemapMode = 0;
741 uint8_t edgeMode = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800742 uint8_t vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF;
Sungjoong Kangfac627c2012-09-18 23:44:00 -0700743
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700744 switch (request_template) {
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800745 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
746 vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON;
747 // fall-through
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700748 case CAMERA2_TEMPLATE_STILL_CAPTURE:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800749 // fall-through
750 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
751 hotPixelMode = ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY;
752 demosaicMode = ANDROID_DEMOSAIC_MODE_HIGH_QUALITY;
753 noiseMode = ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY;
754 shadingMode = ANDROID_SHADING_MODE_HIGH_QUALITY;
755 geometricMode = ANDROID_GEOMETRIC_MODE_HIGH_QUALITY;
756 colorMode = ANDROID_COLOR_CORRECTION_MODE_HIGH_QUALITY;
757 tonemapMode = ANDROID_TONEMAP_MODE_HIGH_QUALITY;
758 edgeMode = ANDROID_EDGE_MODE_HIGH_QUALITY;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700759 break;
760 case CAMERA2_TEMPLATE_VIDEO_RECORD:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800761 vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON;
762 // fall-through
763 case CAMERA2_TEMPLATE_PREVIEW:
764 // fall-through
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700765 default:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800766 hotPixelMode = ANDROID_HOT_PIXEL_MODE_FAST;
767 demosaicMode = ANDROID_DEMOSAIC_MODE_FAST;
768 noiseMode = ANDROID_NOISE_REDUCTION_MODE_FAST;
769 shadingMode = ANDROID_SHADING_MODE_FAST;
770 geometricMode = ANDROID_GEOMETRIC_MODE_FAST;
771 colorMode = ANDROID_COLOR_CORRECTION_MODE_FAST;
772 tonemapMode = ANDROID_TONEMAP_MODE_FAST;
773 edgeMode = ANDROID_EDGE_MODE_FAST;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700774 break;
775 }
776 ADD_OR_SIZE(ANDROID_HOT_PIXEL_MODE, &hotPixelMode, 1);
777 ADD_OR_SIZE(ANDROID_DEMOSAIC_MODE, &demosaicMode, 1);
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800778 ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_MODE, &noiseMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700779 ADD_OR_SIZE(ANDROID_SHADING_MODE, &shadingMode, 1);
780 ADD_OR_SIZE(ANDROID_GEOMETRIC_MODE, &geometricMode, 1);
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800781 ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_MODE, &colorMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700782 ADD_OR_SIZE(ANDROID_TONEMAP_MODE, &tonemapMode, 1);
783 ADD_OR_SIZE(ANDROID_EDGE_MODE, &edgeMode, 1);
Sungjoong Kangfac627c2012-09-18 23:44:00 -0700784 ADD_OR_SIZE(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, &vstabMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700785
786 /** android.noise */
787 static const uint8_t noiseStrength = 5;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800788 ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_STRENGTH, &noiseStrength, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700789
790 /** android.color */
791 static const float colorTransform[9] = {
792 1.0f, 0.f, 0.f,
793 0.f, 1.f, 0.f,
794 0.f, 0.f, 1.f
795 };
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800796 ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_TRANSFORM, colorTransform, 9);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700797
798 /** android.tonemap */
799 static const float tonemapCurve[4] = {
800 0.f, 0.f,
801 1.f, 1.f
802 };
803 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_RED, tonemapCurve, 32); // sungjoong
804 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_GREEN, tonemapCurve, 32);
805 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_BLUE, tonemapCurve, 32);
806
807 /** android.edge */
808 static const uint8_t edgeStrength = 5;
809 ADD_OR_SIZE(ANDROID_EDGE_STRENGTH, &edgeStrength, 1);
810
811 /** android.scaler */
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700812 int32_t cropRegion[3] = {
813 0, 0, m_curCameraInfo->sensorW
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700814 };
815 ADD_OR_SIZE(ANDROID_SCALER_CROP_REGION, cropRegion, 3);
816
817 /** android.jpeg */
Hyeonmyeong Choi87423e52012-10-04 16:34:55 +0900818 static const int32_t jpegQuality = 100;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700819 ADD_OR_SIZE(ANDROID_JPEG_QUALITY, &jpegQuality, 1);
820
821 static const int32_t thumbnailSize[2] = {
Sungjoong Kang2d5e6ec2012-08-30 15:14:17 +0900822 160, 120
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700823 };
824 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_SIZE, thumbnailSize, 2);
825
Hyeonmyeong Choi87423e52012-10-04 16:34:55 +0900826 static const int32_t thumbnailQuality = 100;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700827 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_QUALITY, &thumbnailQuality, 1);
828
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700829 static const double gpsCoordinates[3] = {
830 0, 0, 0
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700831 };
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700832 ADD_OR_SIZE(ANDROID_JPEG_GPS_COORDINATES, gpsCoordinates, 3);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700833
834 static const uint8_t gpsProcessingMethod[32] = "None";
835 ADD_OR_SIZE(ANDROID_JPEG_GPS_PROCESSING_METHOD, gpsProcessingMethod, 32);
836
837 static const int64_t gpsTimestamp = 0;
838 ADD_OR_SIZE(ANDROID_JPEG_GPS_TIMESTAMP, &gpsTimestamp, 1);
839
840 static const int32_t jpegOrientation = 0;
841 ADD_OR_SIZE(ANDROID_JPEG_ORIENTATION, &jpegOrientation, 1);
842
843 /** android.stats */
844
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800845 static const uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_FULL;
846 ADD_OR_SIZE(ANDROID_STATISTICS_FACE_DETECT_MODE, &faceDetectMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700847
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800848 static const uint8_t histogramMode = ANDROID_STATISTICS_HISTOGRAM_MODE_OFF;
849 ADD_OR_SIZE(ANDROID_STATISTICS_HISTOGRAM_MODE, &histogramMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700850
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800851 static const uint8_t sharpnessMapMode = ANDROID_STATISTICS_HISTOGRAM_MODE_OFF;
852 ADD_OR_SIZE(ANDROID_STATISTICS_SHARPNESS_MAP_MODE, &sharpnessMapMode, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700853
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700854
855 /** android.control */
856
857 uint8_t controlIntent = 0;
858 switch (request_template) {
859 case CAMERA2_TEMPLATE_PREVIEW:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800860 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700861 break;
862 case CAMERA2_TEMPLATE_STILL_CAPTURE:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800863 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700864 break;
865 case CAMERA2_TEMPLATE_VIDEO_RECORD:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800866 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700867 break;
868 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800869 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700870 break;
871 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800872 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700873 break;
874 default:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800875 controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_CUSTOM;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700876 break;
877 }
878 ADD_OR_SIZE(ANDROID_CONTROL_CAPTURE_INTENT, &controlIntent, 1);
879
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800880 static const uint8_t controlMode = ANDROID_CONTROL_MODE_AUTO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700881 ADD_OR_SIZE(ANDROID_CONTROL_MODE, &controlMode, 1);
882
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800883 static const uint8_t effectMode = ANDROID_CONTROL_EFFECT_MODE_OFF;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700884 ADD_OR_SIZE(ANDROID_CONTROL_EFFECT_MODE, &effectMode, 1);
885
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700886 static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700887 ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE, &sceneMode, 1);
888
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800889 static const uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700890 ADD_OR_SIZE(ANDROID_CONTROL_AE_MODE, &aeMode, 1);
891
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700892 int32_t controlRegions[5] = {
893 0, 0, m_curCameraInfo->sensorW, m_curCameraInfo->sensorH, 1000
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700894 };
895 ADD_OR_SIZE(ANDROID_CONTROL_AE_REGIONS, controlRegions, 5);
896
897 static const int32_t aeExpCompensation = 0;
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800898 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, &aeExpCompensation, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700899
900 static const int32_t aeTargetFpsRange[2] = {
Sungjoong Kangb8146872012-10-01 13:01:11 -0700901 15, 30
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700902 };
903 ADD_OR_SIZE(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, aeTargetFpsRange, 2);
904
905 static const uint8_t aeAntibandingMode =
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800906 ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700907 ADD_OR_SIZE(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &aeAntibandingMode, 1);
908
909 static const uint8_t awbMode =
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800910 ANDROID_CONTROL_AWB_MODE_AUTO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700911 ADD_OR_SIZE(ANDROID_CONTROL_AWB_MODE, &awbMode, 1);
912
913 ADD_OR_SIZE(ANDROID_CONTROL_AWB_REGIONS, controlRegions, 5);
914
915 uint8_t afMode = 0;
916 switch (request_template) {
917 case CAMERA2_TEMPLATE_PREVIEW:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800918 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700919 break;
920 case CAMERA2_TEMPLATE_STILL_CAPTURE:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800921 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700922 break;
923 case CAMERA2_TEMPLATE_VIDEO_RECORD:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800924 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700925 break;
926 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800927 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700928 break;
929 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800930 afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700931 break;
932 default:
Igor Murashkinfd1276b2012-11-27 16:24:58 -0800933 afMode = ANDROID_CONTROL_AF_MODE_AUTO;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700934 break;
935 }
936 ADD_OR_SIZE(ANDROID_CONTROL_AF_MODE, &afMode, 1);
937
938 ADD_OR_SIZE(ANDROID_CONTROL_AF_REGIONS, controlRegions, 5);
939
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700940 if (sizeRequest) {
941 ALOGV("Allocating %d entries, %d extra bytes for "
942 "request template type %d",
943 entryCount, dataCount, request_template);
944 *request = allocate_camera_metadata(entryCount, dataCount);
945 if (*request == NULL) {
946 ALOGE("Unable to allocate new request template type %d "
947 "(%d entries, %d bytes extra data)", request_template,
948 entryCount, dataCount);
949 return NO_MEMORY;
950 }
951 }
952 return OK;
953#undef ADD_OR_SIZE
954}
955
956}