blob: b29c82f36b4bf4543aadf1047fcc2718511dc616 [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
91const uint8_t Sensor::kColorFilterArrangement = ANDROID_SENSOR_RGGB;
92
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{
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700118 1920, 1080,
Sungjoong Kangad378612012-08-17 12:34:33 -0700119 1440, 1080,
Sungjoong Kange4657e32012-08-28 15:02:19 -0700120 1280, 1024,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700121 1280, 720,
hyeonmyeong Choia44c3362012-08-30 19:01:25 -0700122 720, 480,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700123 640, 480,
124 320, 240,
125 176, 144,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700126};
127
128const int32_t jpegResolutionS5K4E5[] =
129{
130 2560, 1920,
Sungjoong Kange4657e32012-08-28 15:02:19 -0700131 2560, 1440,
hyeonmyeong Choia44c3362012-08-30 19:01:25 -0700132 2160, 1440,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700133 2048, 1536,
134 1600, 1200,
135 1280, 1024,
136 1280, 960,
137 1152, 864,
138 640, 480,
139 320, 240,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700140};
141
142ExynosCamera2InfoS5K4E5::ExynosCamera2InfoS5K4E5()
143{
144 sensorW = 2560;
145 sensorH = 1920;
146 sensorRawW = (2560 + 16);
147 sensorRawH = (1920 + 10);
148 numScalerResolution = ARRAY_SIZE(scalerResolutionS5K4E5)/2;
149 scalerResolutions = scalerResolutionS5K4E5;
150 numJpegResolution = ARRAY_SIZE(jpegResolutionS5K4E5)/2;
151 jpegResolutions = jpegResolutionS5K4E5;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700152 minFocusDistance = 0.1f;
153 focalLength = 3.43f;
154 aperture = 2.7f;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700155}
156
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700157ExynosCamera2InfoS5K4E5::~ExynosCamera2InfoS5K4E5()
158{
159 ALOGV("%s", __FUNCTION__);
160}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700161const int32_t scalerResolutionS5K6A3[] =
162{
Sungjoong Kange4657e32012-08-28 15:02:19 -0700163 1392, 1392,
164 1280, 1024,
Sungjoong Kangad378612012-08-17 12:34:33 -0700165 1280, 960,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700166 1280, 720,
hyeonmyeong Choia44c3362012-08-30 19:01:25 -0700167 720, 480,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700168 640, 480,
169 176, 144,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700170};
171
172const int32_t jpegResolutionS5K6A3[] =
173{
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700174 1392, 1392,
175 1392, 1040,
hyeonmyeong Choia44c3362012-08-30 19:01:25 -0700176 1392, 928,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700177 1392, 784,
178 1280, 1024,
Sungjoong Kangad378612012-08-17 12:34:33 -0700179 1280, 960,
Sungjoong Kange4657e32012-08-28 15:02:19 -0700180 1280, 720,
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700181 1152, 864,
182 640, 480,
183 320, 240,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700184};
185
186ExynosCamera2InfoS5K6A3::ExynosCamera2InfoS5K6A3()
187{
188 sensorW = 1392;
189 sensorH = 1392;
190 sensorRawW = (1392 + 16);
191 sensorRawH = (1392 + 10);
192 numScalerResolution = ARRAY_SIZE(scalerResolutionS5K6A3)/2;
193 scalerResolutions = scalerResolutionS5K6A3;
194 numJpegResolution = ARRAY_SIZE(jpegResolutionS5K6A3)/2;
195 jpegResolutions = jpegResolutionS5K6A3;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700196 minFocusDistance = 0.0f;
197 focalLength = 2.73f;
198 aperture = 2.8f;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700199}
200
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700201ExynosCamera2InfoS5K6A3::~ExynosCamera2InfoS5K6A3()
202{
203 ALOGV("%s", __FUNCTION__);
204}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700205ExynosCamera2::ExynosCamera2(int cameraId):
206 m_cameraId(cameraId)
207{
208 if (cameraId == 0)
209 m_curCameraInfo = new ExynosCamera2InfoS5K4E5;
210 else
211 m_curCameraInfo = new ExynosCamera2InfoS5K6A3;
212}
213
214ExynosCamera2::~ExynosCamera2()
215{
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700216 ALOGV("%s", __FUNCTION__);
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700217 delete m_curCameraInfo;
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700218 m_curCameraInfo = NULL;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700219}
220
221int32_t ExynosCamera2::getSensorW()
222{
223 return m_curCameraInfo->sensorW;
224}
225
226int32_t ExynosCamera2::getSensorH()
227{
228 return m_curCameraInfo->sensorH;
229}
230
231int32_t ExynosCamera2::getSensorRawW()
232{
233 return m_curCameraInfo->sensorRawW;
234}
235
236int32_t ExynosCamera2::getSensorRawH()
237{
238 return m_curCameraInfo->sensorRawH;
239}
240
241bool ExynosCamera2::isSupportedResolution(int width, int height)
242{
243 int i;
244 for (i = 0 ; i < m_curCameraInfo->numScalerResolution ; i++) {
245 if (m_curCameraInfo->scalerResolutions[2*i] == width
246 && m_curCameraInfo->scalerResolutions[2*i+1] == height) {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900247 return true;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700248 }
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900249 }
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700250 return false;
251}
252
253bool ExynosCamera2::isSupportedJpegResolution(int width, int height)
254{
255 int i;
256 for (i = 0 ; i < m_curCameraInfo->numJpegResolution ; i++) {
257 if (m_curCameraInfo->jpegResolutions[2*i] == width
258 && m_curCameraInfo->jpegResolutions[2*i+1] == height) {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900259 return true;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700260 }
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900261 }
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700262 return false;
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900263}
264
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700265status_t addOrSize(camera_metadata_t *request,
266 bool sizeRequest,
267 size_t *entryCount,
268 size_t *dataCount,
269 uint32_t tag,
270 const void *entryData,
271 size_t entryDataCount) {
272 status_t res;
273 if (!sizeRequest) {
274 return add_camera_metadata_entry(request, tag, entryData,
275 entryDataCount);
276 } else {
277 int type = get_camera_metadata_tag_type(tag);
278 if (type < 0 ) return BAD_VALUE;
279 (*entryCount)++;
280 (*dataCount) += calculate_camera_metadata_entry_data_size(type,
281 entryDataCount);
282 return OK;
283 }
284}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700285
286status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info,
287 int cameraId, bool sizeRequest) {
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700288
289 size_t entryCount = 0;
290 size_t dataCount = 0;
291 status_t ret;
292
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700293#define ADD_OR_SIZE( tag, data, count ) \
294 if ( ( ret = addOrSize(*info, sizeRequest, &entryCount, &dataCount, \
295 tag, data, count) ) != OK ) return ret
296
297 // android.lens
298
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700299 ADD_OR_SIZE(ANDROID_LENS_MINIMUM_FOCUS_DISTANCE,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700300 &(m_curCameraInfo->minFocusDistance), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700301 ADD_OR_SIZE(ANDROID_LENS_HYPERFOCAL_DISTANCE,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700302 &(m_curCameraInfo->minFocusDistance), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700303
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700304 ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_FOCAL_LENGTHS,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700305 &m_curCameraInfo->focalLength, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700306 ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_APERTURES,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700307 &m_curCameraInfo->aperture, 1);
308
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700309 static const float filterDensity = 0;
310 ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_FILTER_DENSITY,
311 &filterDensity, 1);
312 static const uint8_t availableOpticalStabilization =
313 ANDROID_LENS_OPTICAL_STABILIZATION_OFF;
314 ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_OPTICAL_STABILIZATION,
315 &availableOpticalStabilization, 1);
316
317 static const int32_t lensShadingMapSize[] = {1, 1};
318 ADD_OR_SIZE(ANDROID_LENS_SHADING_MAP_SIZE, lensShadingMapSize,
319 sizeof(lensShadingMapSize)/sizeof(int32_t));
320
321 static const float lensShadingMap[3 * 1 * 1 ] =
322 { 1.f, 1.f, 1.f };
323 ADD_OR_SIZE(ANDROID_LENS_SHADING_MAP, lensShadingMap,
324 sizeof(lensShadingMap)/sizeof(float));
325
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900326 int32_t lensFacing = cameraId ?
327 ANDROID_LENS_FACING_FRONT : ANDROID_LENS_FACING_BACK;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700328 ADD_OR_SIZE(ANDROID_LENS_FACING, &lensFacing, 1);
329
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700330 // android.sensor
331 ADD_OR_SIZE(ANDROID_SENSOR_EXPOSURE_TIME_RANGE,
332 Sensor::kExposureTimeRange, 2);
333
334 ADD_OR_SIZE(ANDROID_SENSOR_MAX_FRAME_DURATION,
335 &Sensor::kFrameDurationRange[1], 1);
336
337 ADD_OR_SIZE(ANDROID_SENSOR_AVAILABLE_SENSITIVITIES,
338 Sensor::kAvailableSensitivities,
339 sizeof(Sensor::kAvailableSensitivities)
340 /sizeof(uint32_t));
341
342 ADD_OR_SIZE(ANDROID_SENSOR_COLOR_FILTER_ARRANGEMENT,
343 &Sensor::kColorFilterArrangement, 1);
344
345 static const float sensorPhysicalSize[2] = {3.20f, 2.40f}; // mm
346 ADD_OR_SIZE(ANDROID_SENSOR_PHYSICAL_SIZE,
347 sensorPhysicalSize, 2);
348
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700349 int32_t pixelArraySize[2] = {
350 m_curCameraInfo->sensorW, m_curCameraInfo->sensorH
351 };
352 ADD_OR_SIZE(ANDROID_SENSOR_PIXEL_ARRAY_SIZE, pixelArraySize, 2);
353 ADD_OR_SIZE(ANDROID_SENSOR_ACTIVE_ARRAY_SIZE, pixelArraySize,2);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700354
355 ADD_OR_SIZE(ANDROID_SENSOR_WHITE_LEVEL,
356 &Sensor::kMaxRawValue, 1);
357
358 static const int32_t blackLevelPattern[4] = {
359 Sensor::kBlackLevel, Sensor::kBlackLevel,
360 Sensor::kBlackLevel, Sensor::kBlackLevel
361 };
362 ADD_OR_SIZE(ANDROID_SENSOR_BLACK_LEVEL_PATTERN,
363 blackLevelPattern, sizeof(blackLevelPattern)/sizeof(int32_t));
364
365 //TODO: sensor color calibration fields
366
367 // android.flash
Sungjoong Kangfd2d78a2012-08-26 17:44:25 -0700368 static const uint8_t flashAvailable = 1;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700369 ADD_OR_SIZE(ANDROID_FLASH_AVAILABLE, &flashAvailable, 1);
370
371 static const int64_t flashChargeDuration = 0;
372 ADD_OR_SIZE(ANDROID_FLASH_CHARGE_DURATION, &flashChargeDuration, 1);
373
374 // android.tonemap
375
376 static const int32_t tonemapCurvePoints = 128;
377 ADD_OR_SIZE(ANDROID_TONEMAP_MAX_CURVE_POINTS, &tonemapCurvePoints, 1);
378
379 // android.scaler
380
381 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_FORMATS,
382 kAvailableFormats,
383 sizeof(kAvailableFormats)/sizeof(uint32_t));
384
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700385 int32_t availableRawSizes[2] = {
386 m_curCameraInfo->sensorRawW, m_curCameraInfo->sensorRawH
387 };
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700388 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_SIZES,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700389 availableRawSizes, 2);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700390
391 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS,
392 kAvailableRawMinDurations,
393 sizeof(kAvailableRawMinDurations)/sizeof(uint64_t));
394
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700395
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700396 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES,
397 m_curCameraInfo->scalerResolutions,
398 (m_curCameraInfo->numScalerResolution)*2);
399 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES,
400 m_curCameraInfo->jpegResolutions,
401 (m_curCameraInfo->numJpegResolution)*2);
402
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700403 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS,
404 kAvailableProcessedMinDurations,
405 sizeof(kAvailableProcessedMinDurations)/sizeof(uint64_t));
406
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700407 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS,
408 kAvailableJpegMinDurations,
409 sizeof(kAvailableJpegMinDurations)/sizeof(uint64_t));
410
Sungjoong Kange4657e32012-08-28 15:02:19 -0700411 static const float maxZoom = 4;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700412 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_MAX_ZOOM, &maxZoom, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700413
414 // android.jpeg
415
416 static const int32_t jpegThumbnailSizes[] = {
417 160, 120,
Sungjoong Kang2d5e6ec2012-08-30 15:14:17 +0900418 160, 160,
419 160, 90,
420 144, 96
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700421 };
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700422
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700423 ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
424 jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t));
425
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900426 static const int32_t jpegMaxSize = 5*1024*1024;
427 ADD_OR_SIZE(ANDROID_JPEG_MAX_SIZE, &jpegMaxSize, 1);
428
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700429 // android.stats
430
431 static const uint8_t availableFaceDetectModes[] = {
Sungjoong Kangfd2d78a2012-08-26 17:44:25 -0700432 ANDROID_STATS_FACE_DETECTION_OFF,
433 ANDROID_STATS_FACE_DETECTION_FULL
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700434 };
435 ADD_OR_SIZE(ANDROID_STATS_AVAILABLE_FACE_DETECT_MODES,
436 availableFaceDetectModes,
437 sizeof(availableFaceDetectModes));
438
Sungjoong Kangb55ed662012-08-31 21:31:34 -0700439 m_curCameraInfo->maxFaceCount = 3;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700440 ADD_OR_SIZE(ANDROID_STATS_MAX_FACE_COUNT,
Sungjoong Kangfd2d78a2012-08-26 17:44:25 -0700441 &(m_curCameraInfo->maxFaceCount), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700442
443 static const int32_t histogramSize = 64;
444 ADD_OR_SIZE(ANDROID_STATS_HISTOGRAM_BUCKET_COUNT,
445 &histogramSize, 1);
446
447 static const int32_t maxHistogramCount = 1000;
448 ADD_OR_SIZE(ANDROID_STATS_MAX_HISTOGRAM_COUNT,
449 &maxHistogramCount, 1);
450
451 static const int32_t sharpnessMapSize[2] = {64, 64};
452 ADD_OR_SIZE(ANDROID_STATS_SHARPNESS_MAP_SIZE,
453 sharpnessMapSize, sizeof(sharpnessMapSize)/sizeof(int32_t));
454
455 static const int32_t maxSharpnessMapValue = 1000;
456 ADD_OR_SIZE(ANDROID_STATS_MAX_SHARPNESS_MAP_VALUE,
457 &maxSharpnessMapValue, 1);
458
459 // android.control
460
461 static const uint8_t availableSceneModes[] = {
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700462 ANDROID_CONTROL_SCENE_MODE_ACTION,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700463 ANDROID_CONTROL_SCENE_MODE_NIGHT,
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700464 ANDROID_CONTROL_SCENE_MODE_SUNSET,
465 ANDROID_CONTROL_SCENE_MODE_PARTY
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700466 };
467 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
468 availableSceneModes, sizeof(availableSceneModes));
469
470 static const uint8_t availableEffects[] = {
471 ANDROID_CONTROL_EFFECT_OFF
472 };
473 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_EFFECTS,
474 availableEffects, sizeof(availableEffects));
475
Sungjoong Kang8e2c2fd2012-08-27 00:02:22 -0700476 int32_t max3aRegions = 1;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700477 ADD_OR_SIZE(ANDROID_CONTROL_MAX_REGIONS,
478 &max3aRegions, 1);
479
480 static const uint8_t availableAeModes[] = {
481 ANDROID_CONTROL_AE_OFF,
Sungjoong Kangfd2d78a2012-08-26 17:44:25 -0700482 ANDROID_CONTROL_AE_ON,
483 ANDROID_CONTROL_AE_ON_AUTO_FLASH
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700484 };
485 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_MODES,
486 availableAeModes, sizeof(availableAeModes));
487
488 static const camera_metadata_rational exposureCompensationStep = {
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700489 1, 1
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700490 };
491 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION_STEP,
492 &exposureCompensationStep, 1);
493
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700494 int32_t exposureCompensationRange[] = {-3, 3};
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700495 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION_RANGE,
496 exposureCompensationRange,
497 sizeof(exposureCompensationRange)/sizeof(int32_t));
498
499 static const int32_t availableTargetFpsRanges[] = {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900500 5, 30, 30, 30
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700501 };
502 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
503 availableTargetFpsRanges,
504 sizeof(availableTargetFpsRanges)/sizeof(int32_t));
505
506 static const uint8_t availableAntibandingModes[] = {
507 ANDROID_CONTROL_AE_ANTIBANDING_OFF,
508 ANDROID_CONTROL_AE_ANTIBANDING_AUTO
509 };
510 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
511 availableAntibandingModes, sizeof(availableAntibandingModes));
512
513 static const uint8_t availableAwbModes[] = {
514 ANDROID_CONTROL_AWB_OFF,
515 ANDROID_CONTROL_AWB_AUTO,
516 ANDROID_CONTROL_AWB_INCANDESCENT,
517 ANDROID_CONTROL_AWB_FLUORESCENT,
518 ANDROID_CONTROL_AWB_DAYLIGHT,
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700519 ANDROID_CONTROL_AWB_CLOUDY_DAYLIGHT
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700520 };
521 ADD_OR_SIZE(ANDROID_CONTROL_AWB_AVAILABLE_MODES,
522 availableAwbModes, sizeof(availableAwbModes));
523
524 static const uint8_t availableAfModes[] = {
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700525 ANDROID_CONTROL_AF_OFF,
526 ANDROID_CONTROL_AF_AUTO,
527 ANDROID_CONTROL_AF_MACRO,
528 ANDROID_CONTROL_AF_CONTINUOUS_PICTURE,
529 ANDROID_CONTROL_AF_CONTINUOUS_VIDEO
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700530 };
531 ADD_OR_SIZE(ANDROID_CONTROL_AF_AVAILABLE_MODES,
532 availableAfModes, sizeof(availableAfModes));
533
534 static const uint8_t availableVstabModes[] = {
535 ANDROID_CONTROL_VIDEO_STABILIZATION_OFF
536 };
537 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
538 availableVstabModes, sizeof(availableVstabModes));
539
540#undef ADD_OR_SIZE
541 /** Allocate metadata if sizing */
542 if (sizeRequest) {
543 ALOGV("Allocating %d entries, %d extra bytes for "
544 "static camera info",
545 entryCount, dataCount);
546 *info = allocate_camera_metadata(entryCount, dataCount);
547 if (*info == NULL) {
548 ALOGE("Unable to allocate camera static info"
549 "(%d entries, %d bytes extra data)",
550 entryCount, dataCount);
551 return NO_MEMORY;
552 }
553 }
554 return OK;
555}
556
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700557status_t ExynosCamera2::constructDefaultRequest(
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700558 int request_template,
559 camera_metadata_t **request,
560 bool sizeRequest) {
561
562 size_t entryCount = 0;
563 size_t dataCount = 0;
564 status_t ret;
565
566#define ADD_OR_SIZE( tag, data, count ) \
567 if ( ( ret = addOrSize(*request, sizeRequest, &entryCount, &dataCount, \
568 tag, data, count) ) != OK ) return ret
569
570 static const int64_t USEC = 1000LL;
571 static const int64_t MSEC = USEC * 1000LL;
572 static const int64_t SEC = MSEC * 1000LL;
573
574 /** android.request */
575
576 static const uint8_t metadataMode = ANDROID_REQUEST_METADATA_NONE;
577 ADD_OR_SIZE(ANDROID_REQUEST_METADATA_MODE, &metadataMode, 1);
578
579 static const int32_t id = 0;
580 ADD_OR_SIZE(ANDROID_REQUEST_ID, &id, 1);
581
582 static const int32_t frameCount = 0;
583 ADD_OR_SIZE(ANDROID_REQUEST_FRAME_COUNT, &frameCount, 1);
584
585 // OUTPUT_STREAMS set by user
586 entryCount += 1;
587 dataCount += 5; // TODO: Should be maximum stream number
588
589 /** android.lens */
590
591 static const float focusDistance = 0;
592 ADD_OR_SIZE(ANDROID_LENS_FOCUS_DISTANCE, &focusDistance, 1);
593
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700594 ADD_OR_SIZE(ANDROID_LENS_APERTURE, &m_curCameraInfo->aperture, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700595
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700596 ADD_OR_SIZE(ANDROID_LENS_FOCAL_LENGTH, &m_curCameraInfo->focalLength, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700597
598 static const float filterDensity = 0;
599 ADD_OR_SIZE(ANDROID_LENS_FILTER_DENSITY, &filterDensity, 1);
600
601 static const uint8_t opticalStabilizationMode =
602 ANDROID_LENS_OPTICAL_STABILIZATION_OFF;
603 ADD_OR_SIZE(ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
604 &opticalStabilizationMode, 1);
605
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700606
607 /** android.sensor */
608
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700609
610 static const int64_t frameDuration = 33333333L; // 1/30 s
611 ADD_OR_SIZE(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1);
612
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700613
614 /** android.flash */
615
616 static const uint8_t flashMode = ANDROID_FLASH_OFF;
617 ADD_OR_SIZE(ANDROID_FLASH_MODE, &flashMode, 1);
618
619 static const uint8_t flashPower = 10;
620 ADD_OR_SIZE(ANDROID_FLASH_FIRING_POWER, &flashPower, 1);
621
622 static const int64_t firingTime = 0;
623 ADD_OR_SIZE(ANDROID_FLASH_FIRING_TIME, &firingTime, 1);
624
625 /** Processing block modes */
626 uint8_t hotPixelMode = 0;
627 uint8_t demosaicMode = 0;
628 uint8_t noiseMode = 0;
629 uint8_t shadingMode = 0;
630 uint8_t geometricMode = 0;
631 uint8_t colorMode = 0;
632 uint8_t tonemapMode = 0;
633 uint8_t edgeMode = 0;
634 switch (request_template) {
635 case CAMERA2_TEMPLATE_PREVIEW:
636 hotPixelMode = ANDROID_PROCESSING_FAST;
637 demosaicMode = ANDROID_PROCESSING_FAST;
638 noiseMode = ANDROID_PROCESSING_FAST;
639 shadingMode = ANDROID_PROCESSING_FAST;
640 geometricMode = ANDROID_PROCESSING_FAST;
641 colorMode = ANDROID_PROCESSING_FAST;
642 tonemapMode = ANDROID_PROCESSING_FAST;
643 edgeMode = ANDROID_PROCESSING_FAST;
644 break;
645 case CAMERA2_TEMPLATE_STILL_CAPTURE:
646 hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY;
647 demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY;
648 noiseMode = ANDROID_PROCESSING_HIGH_QUALITY;
649 shadingMode = ANDROID_PROCESSING_HIGH_QUALITY;
650 geometricMode = ANDROID_PROCESSING_HIGH_QUALITY;
651 colorMode = ANDROID_PROCESSING_HIGH_QUALITY;
652 tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY;
653 edgeMode = ANDROID_PROCESSING_HIGH_QUALITY;
654 break;
655 case CAMERA2_TEMPLATE_VIDEO_RECORD:
656 hotPixelMode = ANDROID_PROCESSING_FAST;
657 demosaicMode = ANDROID_PROCESSING_FAST;
658 noiseMode = ANDROID_PROCESSING_FAST;
659 shadingMode = ANDROID_PROCESSING_FAST;
660 geometricMode = ANDROID_PROCESSING_FAST;
661 colorMode = ANDROID_PROCESSING_FAST;
662 tonemapMode = ANDROID_PROCESSING_FAST;
663 edgeMode = ANDROID_PROCESSING_FAST;
664 break;
665 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
666 hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY;
667 demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY;
668 noiseMode = ANDROID_PROCESSING_HIGH_QUALITY;
669 shadingMode = ANDROID_PROCESSING_HIGH_QUALITY;
670 geometricMode = ANDROID_PROCESSING_HIGH_QUALITY;
671 colorMode = ANDROID_PROCESSING_HIGH_QUALITY;
672 tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY;
673 edgeMode = ANDROID_PROCESSING_HIGH_QUALITY;
674 break;
675 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
676 hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY;
677 demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY;
678 noiseMode = ANDROID_PROCESSING_HIGH_QUALITY;
679 shadingMode = ANDROID_PROCESSING_HIGH_QUALITY;
680 geometricMode = ANDROID_PROCESSING_HIGH_QUALITY;
681 colorMode = ANDROID_PROCESSING_HIGH_QUALITY;
682 tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY;
683 edgeMode = ANDROID_PROCESSING_HIGH_QUALITY;
684 break;
685 default:
686 hotPixelMode = ANDROID_PROCESSING_FAST;
687 demosaicMode = ANDROID_PROCESSING_FAST;
688 noiseMode = ANDROID_PROCESSING_FAST;
689 shadingMode = ANDROID_PROCESSING_FAST;
690 geometricMode = ANDROID_PROCESSING_FAST;
691 colorMode = ANDROID_PROCESSING_FAST;
692 tonemapMode = ANDROID_PROCESSING_FAST;
693 edgeMode = ANDROID_PROCESSING_FAST;
694 break;
695 }
696 ADD_OR_SIZE(ANDROID_HOT_PIXEL_MODE, &hotPixelMode, 1);
697 ADD_OR_SIZE(ANDROID_DEMOSAIC_MODE, &demosaicMode, 1);
698 ADD_OR_SIZE(ANDROID_NOISE_MODE, &noiseMode, 1);
699 ADD_OR_SIZE(ANDROID_SHADING_MODE, &shadingMode, 1);
700 ADD_OR_SIZE(ANDROID_GEOMETRIC_MODE, &geometricMode, 1);
701 ADD_OR_SIZE(ANDROID_COLOR_MODE, &colorMode, 1);
702 ADD_OR_SIZE(ANDROID_TONEMAP_MODE, &tonemapMode, 1);
703 ADD_OR_SIZE(ANDROID_EDGE_MODE, &edgeMode, 1);
704
705 /** android.noise */
706 static const uint8_t noiseStrength = 5;
707 ADD_OR_SIZE(ANDROID_NOISE_STRENGTH, &noiseStrength, 1);
708
709 /** android.color */
710 static const float colorTransform[9] = {
711 1.0f, 0.f, 0.f,
712 0.f, 1.f, 0.f,
713 0.f, 0.f, 1.f
714 };
715 ADD_OR_SIZE(ANDROID_COLOR_TRANSFORM, colorTransform, 9);
716
717 /** android.tonemap */
718 static const float tonemapCurve[4] = {
719 0.f, 0.f,
720 1.f, 1.f
721 };
722 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_RED, tonemapCurve, 32); // sungjoong
723 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_GREEN, tonemapCurve, 32);
724 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_BLUE, tonemapCurve, 32);
725
726 /** android.edge */
727 static const uint8_t edgeStrength = 5;
728 ADD_OR_SIZE(ANDROID_EDGE_STRENGTH, &edgeStrength, 1);
729
730 /** android.scaler */
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700731 int32_t cropRegion[3] = {
732 0, 0, m_curCameraInfo->sensorW
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700733 };
734 ADD_OR_SIZE(ANDROID_SCALER_CROP_REGION, cropRegion, 3);
735
736 /** android.jpeg */
737 static const int32_t jpegQuality = 80;
738 ADD_OR_SIZE(ANDROID_JPEG_QUALITY, &jpegQuality, 1);
739
740 static const int32_t thumbnailSize[2] = {
Sungjoong Kang2d5e6ec2012-08-30 15:14:17 +0900741 160, 120
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700742 };
743 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_SIZE, thumbnailSize, 2);
744
745 static const int32_t thumbnailQuality = 80;
746 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_QUALITY, &thumbnailQuality, 1);
747
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700748 static const double gpsCoordinates[3] = {
749 0, 0, 0
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700750 };
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700751 ADD_OR_SIZE(ANDROID_JPEG_GPS_COORDINATES, gpsCoordinates, 3);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700752
753 static const uint8_t gpsProcessingMethod[32] = "None";
754 ADD_OR_SIZE(ANDROID_JPEG_GPS_PROCESSING_METHOD, gpsProcessingMethod, 32);
755
756 static const int64_t gpsTimestamp = 0;
757 ADD_OR_SIZE(ANDROID_JPEG_GPS_TIMESTAMP, &gpsTimestamp, 1);
758
759 static const int32_t jpegOrientation = 0;
760 ADD_OR_SIZE(ANDROID_JPEG_ORIENTATION, &jpegOrientation, 1);
761
762 /** android.stats */
763
Sungjoong Kangfd2d78a2012-08-26 17:44:25 -0700764 static const uint8_t faceDetectMode = ANDROID_STATS_FACE_DETECTION_FULL;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700765 ADD_OR_SIZE(ANDROID_STATS_FACE_DETECT_MODE, &faceDetectMode, 1);
766
767 static const uint8_t histogramMode = ANDROID_STATS_OFF;
768 ADD_OR_SIZE(ANDROID_STATS_HISTOGRAM_MODE, &histogramMode, 1);
769
770 static const uint8_t sharpnessMapMode = ANDROID_STATS_OFF;
771 ADD_OR_SIZE(ANDROID_STATS_SHARPNESS_MAP_MODE, &sharpnessMapMode, 1);
772
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700773
774 /** android.control */
775
776 uint8_t controlIntent = 0;
777 switch (request_template) {
778 case CAMERA2_TEMPLATE_PREVIEW:
779 controlIntent = ANDROID_CONTROL_INTENT_PREVIEW;
780 break;
781 case CAMERA2_TEMPLATE_STILL_CAPTURE:
782 controlIntent = ANDROID_CONTROL_INTENT_STILL_CAPTURE;
783 break;
784 case CAMERA2_TEMPLATE_VIDEO_RECORD:
785 controlIntent = ANDROID_CONTROL_INTENT_VIDEO_RECORD;
786 break;
787 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
788 controlIntent = ANDROID_CONTROL_INTENT_VIDEO_SNAPSHOT;
789 break;
790 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
791 controlIntent = ANDROID_CONTROL_INTENT_ZERO_SHUTTER_LAG;
792 break;
793 default:
794 controlIntent = ANDROID_CONTROL_INTENT_CUSTOM;
795 break;
796 }
797 ADD_OR_SIZE(ANDROID_CONTROL_CAPTURE_INTENT, &controlIntent, 1);
798
799 static const uint8_t controlMode = ANDROID_CONTROL_AUTO;
800 ADD_OR_SIZE(ANDROID_CONTROL_MODE, &controlMode, 1);
801
802 static const uint8_t effectMode = ANDROID_CONTROL_EFFECT_OFF;
803 ADD_OR_SIZE(ANDROID_CONTROL_EFFECT_MODE, &effectMode, 1);
804
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700805 static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700806 ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE, &sceneMode, 1);
807
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700808 static const uint8_t aeMode = ANDROID_CONTROL_AE_ON;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700809 ADD_OR_SIZE(ANDROID_CONTROL_AE_MODE, &aeMode, 1);
810
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700811 int32_t controlRegions[5] = {
812 0, 0, m_curCameraInfo->sensorW, m_curCameraInfo->sensorH, 1000
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700813 };
814 ADD_OR_SIZE(ANDROID_CONTROL_AE_REGIONS, controlRegions, 5);
815
816 static const int32_t aeExpCompensation = 0;
817 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION, &aeExpCompensation, 1);
818
819 static const int32_t aeTargetFpsRange[2] = {
820 10, 30
821 };
822 ADD_OR_SIZE(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, aeTargetFpsRange, 2);
823
824 static const uint8_t aeAntibandingMode =
825 ANDROID_CONTROL_AE_ANTIBANDING_AUTO;
826 ADD_OR_SIZE(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &aeAntibandingMode, 1);
827
828 static const uint8_t awbMode =
829 ANDROID_CONTROL_AWB_AUTO;
830 ADD_OR_SIZE(ANDROID_CONTROL_AWB_MODE, &awbMode, 1);
831
832 ADD_OR_SIZE(ANDROID_CONTROL_AWB_REGIONS, controlRegions, 5);
833
834 uint8_t afMode = 0;
835 switch (request_template) {
836 case CAMERA2_TEMPLATE_PREVIEW:
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700837 afMode = ANDROID_CONTROL_AF_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700838 break;
839 case CAMERA2_TEMPLATE_STILL_CAPTURE:
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700840 afMode = ANDROID_CONTROL_AF_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700841 break;
842 case CAMERA2_TEMPLATE_VIDEO_RECORD:
843 afMode = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO;
844 break;
845 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
846 afMode = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO;
847 break;
848 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
849 afMode = ANDROID_CONTROL_AF_CONTINUOUS_PICTURE;
850 break;
851 default:
852 afMode = ANDROID_CONTROL_AF_AUTO;
853 break;
854 }
855 ADD_OR_SIZE(ANDROID_CONTROL_AF_MODE, &afMode, 1);
856
857 ADD_OR_SIZE(ANDROID_CONTROL_AF_REGIONS, controlRegions, 5);
858
859 static const uint8_t vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_OFF;
860 ADD_OR_SIZE(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, &vstabMode, 1);
861
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700862 if (sizeRequest) {
863 ALOGV("Allocating %d entries, %d extra bytes for "
864 "request template type %d",
865 entryCount, dataCount, request_template);
866 *request = allocate_camera_metadata(entryCount, dataCount);
867 if (*request == NULL) {
868 ALOGE("Unable to allocate new request template type %d "
869 "(%d entries, %d bytes extra data)", request_template,
870 entryCount, dataCount);
871 return NO_MEMORY;
872 }
873 }
874 return OK;
875#undef ADD_OR_SIZE
876}
877
878}