blob: cbdea7e967a476ebb24f03f72cf1e600789aaf43 [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 Kangdaa1fcd2012-08-08 11:49:43 -0700120 1280, 720,
121};
122
123const int32_t jpegResolutionS5K4E5[] =
124{
125 2560, 1920,
Sungjoong Kangad378612012-08-17 12:34:33 -0700126 2560, 1440,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700127 1280, 720,
128};
129
130ExynosCamera2InfoS5K4E5::ExynosCamera2InfoS5K4E5()
131{
132 sensorW = 2560;
133 sensorH = 1920;
134 sensorRawW = (2560 + 16);
135 sensorRawH = (1920 + 10);
136 numScalerResolution = ARRAY_SIZE(scalerResolutionS5K4E5)/2;
137 scalerResolutions = scalerResolutionS5K4E5;
138 numJpegResolution = ARRAY_SIZE(jpegResolutionS5K4E5)/2;
139 jpegResolutions = jpegResolutionS5K4E5;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700140 minFocusDistance = 0.1f;
141 focalLength = 3.43f;
142 aperture = 2.7f;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700143}
144
145const int32_t scalerResolutionS5K6A3[] =
146{
Sungjoong Kangad378612012-08-17 12:34:33 -0700147 1280, 960,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700148 1280, 720,
149};
150
151const int32_t jpegResolutionS5K6A3[] =
152{
Sungjoong Kangad378612012-08-17 12:34:33 -0700153 1280, 960,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700154 1280, 720,
155};
156
157ExynosCamera2InfoS5K6A3::ExynosCamera2InfoS5K6A3()
158{
159 sensorW = 1392;
160 sensorH = 1392;
161 sensorRawW = (1392 + 16);
162 sensorRawH = (1392 + 10);
163 numScalerResolution = ARRAY_SIZE(scalerResolutionS5K6A3)/2;
164 scalerResolutions = scalerResolutionS5K6A3;
165 numJpegResolution = ARRAY_SIZE(jpegResolutionS5K6A3)/2;
166 jpegResolutions = jpegResolutionS5K6A3;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700167 minFocusDistance = 0.0f;
168 focalLength = 2.73f;
169 aperture = 2.8f;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700170}
171
172ExynosCamera2::ExynosCamera2(int cameraId):
173 m_cameraId(cameraId)
174{
175 if (cameraId == 0)
176 m_curCameraInfo = new ExynosCamera2InfoS5K4E5;
177 else
178 m_curCameraInfo = new ExynosCamera2InfoS5K6A3;
179}
180
181ExynosCamera2::~ExynosCamera2()
182{
183 delete m_curCameraInfo;
184}
185
186int32_t ExynosCamera2::getSensorW()
187{
188 return m_curCameraInfo->sensorW;
189}
190
191int32_t ExynosCamera2::getSensorH()
192{
193 return m_curCameraInfo->sensorH;
194}
195
196int32_t ExynosCamera2::getSensorRawW()
197{
198 return m_curCameraInfo->sensorRawW;
199}
200
201int32_t ExynosCamera2::getSensorRawH()
202{
203 return m_curCameraInfo->sensorRawH;
204}
205
206bool ExynosCamera2::isSupportedResolution(int width, int height)
207{
208 int i;
209 for (i = 0 ; i < m_curCameraInfo->numScalerResolution ; i++) {
210 if (m_curCameraInfo->scalerResolutions[2*i] == width
211 && m_curCameraInfo->scalerResolutions[2*i+1] == height) {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900212 return true;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700213 }
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900214 }
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700215 return false;
216}
217
218bool ExynosCamera2::isSupportedJpegResolution(int width, int height)
219{
220 int i;
221 for (i = 0 ; i < m_curCameraInfo->numJpegResolution ; i++) {
222 if (m_curCameraInfo->jpegResolutions[2*i] == width
223 && m_curCameraInfo->jpegResolutions[2*i+1] == height) {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900224 return true;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700225 }
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900226 }
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700227 return false;
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900228}
229
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700230status_t addOrSize(camera_metadata_t *request,
231 bool sizeRequest,
232 size_t *entryCount,
233 size_t *dataCount,
234 uint32_t tag,
235 const void *entryData,
236 size_t entryDataCount) {
237 status_t res;
238 if (!sizeRequest) {
239 return add_camera_metadata_entry(request, tag, entryData,
240 entryDataCount);
241 } else {
242 int type = get_camera_metadata_tag_type(tag);
243 if (type < 0 ) return BAD_VALUE;
244 (*entryCount)++;
245 (*dataCount) += calculate_camera_metadata_entry_data_size(type,
246 entryDataCount);
247 return OK;
248 }
249}
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700250
251status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info,
252 int cameraId, bool sizeRequest) {
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700253
254 size_t entryCount = 0;
255 size_t dataCount = 0;
256 status_t ret;
257
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700258#define ADD_OR_SIZE( tag, data, count ) \
259 if ( ( ret = addOrSize(*info, sizeRequest, &entryCount, &dataCount, \
260 tag, data, count) ) != OK ) return ret
261
262 // android.lens
263
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700264 ADD_OR_SIZE(ANDROID_LENS_MINIMUM_FOCUS_DISTANCE,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700265 &(m_curCameraInfo->minFocusDistance), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700266 ADD_OR_SIZE(ANDROID_LENS_HYPERFOCAL_DISTANCE,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700267 &(m_curCameraInfo->minFocusDistance), 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700268
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700269 ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_FOCAL_LENGTHS,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700270 &m_curCameraInfo->focalLength, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700271 ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_APERTURES,
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700272 &m_curCameraInfo->aperture, 1);
273
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700274 static const float filterDensity = 0;
275 ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_FILTER_DENSITY,
276 &filterDensity, 1);
277 static const uint8_t availableOpticalStabilization =
278 ANDROID_LENS_OPTICAL_STABILIZATION_OFF;
279 ADD_OR_SIZE(ANDROID_LENS_AVAILABLE_OPTICAL_STABILIZATION,
280 &availableOpticalStabilization, 1);
281
282 static const int32_t lensShadingMapSize[] = {1, 1};
283 ADD_OR_SIZE(ANDROID_LENS_SHADING_MAP_SIZE, lensShadingMapSize,
284 sizeof(lensShadingMapSize)/sizeof(int32_t));
285
286 static const float lensShadingMap[3 * 1 * 1 ] =
287 { 1.f, 1.f, 1.f };
288 ADD_OR_SIZE(ANDROID_LENS_SHADING_MAP, lensShadingMap,
289 sizeof(lensShadingMap)/sizeof(float));
290
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900291 int32_t lensFacing = cameraId ?
292 ANDROID_LENS_FACING_FRONT : ANDROID_LENS_FACING_BACK;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700293 ADD_OR_SIZE(ANDROID_LENS_FACING, &lensFacing, 1);
294
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700295 // android.sensor
296 ADD_OR_SIZE(ANDROID_SENSOR_EXPOSURE_TIME_RANGE,
297 Sensor::kExposureTimeRange, 2);
298
299 ADD_OR_SIZE(ANDROID_SENSOR_MAX_FRAME_DURATION,
300 &Sensor::kFrameDurationRange[1], 1);
301
302 ADD_OR_SIZE(ANDROID_SENSOR_AVAILABLE_SENSITIVITIES,
303 Sensor::kAvailableSensitivities,
304 sizeof(Sensor::kAvailableSensitivities)
305 /sizeof(uint32_t));
306
307 ADD_OR_SIZE(ANDROID_SENSOR_COLOR_FILTER_ARRANGEMENT,
308 &Sensor::kColorFilterArrangement, 1);
309
310 static const float sensorPhysicalSize[2] = {3.20f, 2.40f}; // mm
311 ADD_OR_SIZE(ANDROID_SENSOR_PHYSICAL_SIZE,
312 sensorPhysicalSize, 2);
313
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700314 int32_t pixelArraySize[2] = {
315 m_curCameraInfo->sensorW, m_curCameraInfo->sensorH
316 };
317 ADD_OR_SIZE(ANDROID_SENSOR_PIXEL_ARRAY_SIZE, pixelArraySize, 2);
318 ADD_OR_SIZE(ANDROID_SENSOR_ACTIVE_ARRAY_SIZE, pixelArraySize,2);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700319
320 ADD_OR_SIZE(ANDROID_SENSOR_WHITE_LEVEL,
321 &Sensor::kMaxRawValue, 1);
322
323 static const int32_t blackLevelPattern[4] = {
324 Sensor::kBlackLevel, Sensor::kBlackLevel,
325 Sensor::kBlackLevel, Sensor::kBlackLevel
326 };
327 ADD_OR_SIZE(ANDROID_SENSOR_BLACK_LEVEL_PATTERN,
328 blackLevelPattern, sizeof(blackLevelPattern)/sizeof(int32_t));
329
330 //TODO: sensor color calibration fields
331
332 // android.flash
333 static const uint8_t flashAvailable = 0;
334 ADD_OR_SIZE(ANDROID_FLASH_AVAILABLE, &flashAvailable, 1);
335
336 static const int64_t flashChargeDuration = 0;
337 ADD_OR_SIZE(ANDROID_FLASH_CHARGE_DURATION, &flashChargeDuration, 1);
338
339 // android.tonemap
340
341 static const int32_t tonemapCurvePoints = 128;
342 ADD_OR_SIZE(ANDROID_TONEMAP_MAX_CURVE_POINTS, &tonemapCurvePoints, 1);
343
344 // android.scaler
345
346 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_FORMATS,
347 kAvailableFormats,
348 sizeof(kAvailableFormats)/sizeof(uint32_t));
349
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700350 int32_t availableRawSizes[2] = {
351 m_curCameraInfo->sensorRawW, m_curCameraInfo->sensorRawH
352 };
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700353 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_SIZES,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700354 availableRawSizes, 2);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700355
356 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS,
357 kAvailableRawMinDurations,
358 sizeof(kAvailableRawMinDurations)/sizeof(uint64_t));
359
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700360
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700361 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES,
362 m_curCameraInfo->scalerResolutions,
363 (m_curCameraInfo->numScalerResolution)*2);
364 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES,
365 m_curCameraInfo->jpegResolutions,
366 (m_curCameraInfo->numJpegResolution)*2);
367
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700368 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS,
369 kAvailableProcessedMinDurations,
370 sizeof(kAvailableProcessedMinDurations)/sizeof(uint64_t));
371
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700372 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS,
373 kAvailableJpegMinDurations,
374 sizeof(kAvailableJpegMinDurations)/sizeof(uint64_t));
375
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700376 static const float maxZoom = 1;
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700377 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_MAX_ZOOM, &maxZoom, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700378
379 // android.jpeg
380
381 static const int32_t jpegThumbnailSizes[] = {
382 160, 120,
383 320, 240,
384 640, 480
385 };
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700386
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700387 ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
388 jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t));
389
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900390 static const int32_t jpegMaxSize = 5*1024*1024;
391 ADD_OR_SIZE(ANDROID_JPEG_MAX_SIZE, &jpegMaxSize, 1);
392
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700393 // android.stats
394
395 static const uint8_t availableFaceDetectModes[] = {
396 ANDROID_STATS_FACE_DETECTION_OFF
397 };
398 ADD_OR_SIZE(ANDROID_STATS_AVAILABLE_FACE_DETECT_MODES,
399 availableFaceDetectModes,
400 sizeof(availableFaceDetectModes));
401
402 static const int32_t maxFaceCount = 0;
403 ADD_OR_SIZE(ANDROID_STATS_MAX_FACE_COUNT,
404 &maxFaceCount, 1);
405
406 static const int32_t histogramSize = 64;
407 ADD_OR_SIZE(ANDROID_STATS_HISTOGRAM_BUCKET_COUNT,
408 &histogramSize, 1);
409
410 static const int32_t maxHistogramCount = 1000;
411 ADD_OR_SIZE(ANDROID_STATS_MAX_HISTOGRAM_COUNT,
412 &maxHistogramCount, 1);
413
414 static const int32_t sharpnessMapSize[2] = {64, 64};
415 ADD_OR_SIZE(ANDROID_STATS_SHARPNESS_MAP_SIZE,
416 sharpnessMapSize, sizeof(sharpnessMapSize)/sizeof(int32_t));
417
418 static const int32_t maxSharpnessMapValue = 1000;
419 ADD_OR_SIZE(ANDROID_STATS_MAX_SHARPNESS_MAP_VALUE,
420 &maxSharpnessMapValue, 1);
421
422 // android.control
423
424 static const uint8_t availableSceneModes[] = {
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700425 ANDROID_CONTROL_SCENE_MODE_ACTION,
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700426 ANDROID_CONTROL_SCENE_MODE_NIGHT,
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700427 ANDROID_CONTROL_SCENE_MODE_SUNSET,
428 ANDROID_CONTROL_SCENE_MODE_PARTY
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700429 };
430 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
431 availableSceneModes, sizeof(availableSceneModes));
432
433 static const uint8_t availableEffects[] = {
434 ANDROID_CONTROL_EFFECT_OFF
435 };
436 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_EFFECTS,
437 availableEffects, sizeof(availableEffects));
438
439 int32_t max3aRegions = 0;
440 ADD_OR_SIZE(ANDROID_CONTROL_MAX_REGIONS,
441 &max3aRegions, 1);
442
443 static const uint8_t availableAeModes[] = {
444 ANDROID_CONTROL_AE_OFF,
445 ANDROID_CONTROL_AE_ON
446 };
447 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_MODES,
448 availableAeModes, sizeof(availableAeModes));
449
450 static const camera_metadata_rational exposureCompensationStep = {
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700451 1, 1
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700452 };
453 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION_STEP,
454 &exposureCompensationStep, 1);
455
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700456 int32_t exposureCompensationRange[] = {-3, 3};
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700457 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION_RANGE,
458 exposureCompensationRange,
459 sizeof(exposureCompensationRange)/sizeof(int32_t));
460
461 static const int32_t availableTargetFpsRanges[] = {
Sungjoong Kang9dd63e12012-07-24 00:25:51 +0900462 5, 30, 30, 30
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700463 };
464 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
465 availableTargetFpsRanges,
466 sizeof(availableTargetFpsRanges)/sizeof(int32_t));
467
468 static const uint8_t availableAntibandingModes[] = {
469 ANDROID_CONTROL_AE_ANTIBANDING_OFF,
470 ANDROID_CONTROL_AE_ANTIBANDING_AUTO
471 };
472 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
473 availableAntibandingModes, sizeof(availableAntibandingModes));
474
475 static const uint8_t availableAwbModes[] = {
476 ANDROID_CONTROL_AWB_OFF,
477 ANDROID_CONTROL_AWB_AUTO,
478 ANDROID_CONTROL_AWB_INCANDESCENT,
479 ANDROID_CONTROL_AWB_FLUORESCENT,
480 ANDROID_CONTROL_AWB_DAYLIGHT,
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700481 ANDROID_CONTROL_AWB_CLOUDY_DAYLIGHT
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700482 };
483 ADD_OR_SIZE(ANDROID_CONTROL_AWB_AVAILABLE_MODES,
484 availableAwbModes, sizeof(availableAwbModes));
485
486 static const uint8_t availableAfModes[] = {
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700487 ANDROID_CONTROL_AF_OFF,
488 ANDROID_CONTROL_AF_AUTO,
489 ANDROID_CONTROL_AF_MACRO,
490 ANDROID_CONTROL_AF_CONTINUOUS_PICTURE,
491 ANDROID_CONTROL_AF_CONTINUOUS_VIDEO
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700492 };
493 ADD_OR_SIZE(ANDROID_CONTROL_AF_AVAILABLE_MODES,
494 availableAfModes, sizeof(availableAfModes));
495
496 static const uint8_t availableVstabModes[] = {
497 ANDROID_CONTROL_VIDEO_STABILIZATION_OFF
498 };
499 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
500 availableVstabModes, sizeof(availableVstabModes));
501
502#undef ADD_OR_SIZE
503 /** Allocate metadata if sizing */
504 if (sizeRequest) {
505 ALOGV("Allocating %d entries, %d extra bytes for "
506 "static camera info",
507 entryCount, dataCount);
508 *info = allocate_camera_metadata(entryCount, dataCount);
509 if (*info == NULL) {
510 ALOGE("Unable to allocate camera static info"
511 "(%d entries, %d bytes extra data)",
512 entryCount, dataCount);
513 return NO_MEMORY;
514 }
515 }
516 return OK;
517}
518
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700519status_t ExynosCamera2::constructDefaultRequest(
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700520 int request_template,
521 camera_metadata_t **request,
522 bool sizeRequest) {
523
524 size_t entryCount = 0;
525 size_t dataCount = 0;
526 status_t ret;
527
528#define ADD_OR_SIZE( tag, data, count ) \
529 if ( ( ret = addOrSize(*request, sizeRequest, &entryCount, &dataCount, \
530 tag, data, count) ) != OK ) return ret
531
532 static const int64_t USEC = 1000LL;
533 static const int64_t MSEC = USEC * 1000LL;
534 static const int64_t SEC = MSEC * 1000LL;
535
536 /** android.request */
537
538 static const uint8_t metadataMode = ANDROID_REQUEST_METADATA_NONE;
539 ADD_OR_SIZE(ANDROID_REQUEST_METADATA_MODE, &metadataMode, 1);
540
541 static const int32_t id = 0;
542 ADD_OR_SIZE(ANDROID_REQUEST_ID, &id, 1);
543
544 static const int32_t frameCount = 0;
545 ADD_OR_SIZE(ANDROID_REQUEST_FRAME_COUNT, &frameCount, 1);
546
547 // OUTPUT_STREAMS set by user
548 entryCount += 1;
549 dataCount += 5; // TODO: Should be maximum stream number
550
551 /** android.lens */
552
553 static const float focusDistance = 0;
554 ADD_OR_SIZE(ANDROID_LENS_FOCUS_DISTANCE, &focusDistance, 1);
555
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700556 ADD_OR_SIZE(ANDROID_LENS_APERTURE, &m_curCameraInfo->aperture, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700557
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700558 ADD_OR_SIZE(ANDROID_LENS_FOCAL_LENGTH, &m_curCameraInfo->focalLength, 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700559
560 static const float filterDensity = 0;
561 ADD_OR_SIZE(ANDROID_LENS_FILTER_DENSITY, &filterDensity, 1);
562
563 static const uint8_t opticalStabilizationMode =
564 ANDROID_LENS_OPTICAL_STABILIZATION_OFF;
565 ADD_OR_SIZE(ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
566 &opticalStabilizationMode, 1);
567
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700568
569 /** android.sensor */
570
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700571
572 static const int64_t frameDuration = 33333333L; // 1/30 s
573 ADD_OR_SIZE(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1);
574
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700575
576 /** android.flash */
577
578 static const uint8_t flashMode = ANDROID_FLASH_OFF;
579 ADD_OR_SIZE(ANDROID_FLASH_MODE, &flashMode, 1);
580
581 static const uint8_t flashPower = 10;
582 ADD_OR_SIZE(ANDROID_FLASH_FIRING_POWER, &flashPower, 1);
583
584 static const int64_t firingTime = 0;
585 ADD_OR_SIZE(ANDROID_FLASH_FIRING_TIME, &firingTime, 1);
586
587 /** Processing block modes */
588 uint8_t hotPixelMode = 0;
589 uint8_t demosaicMode = 0;
590 uint8_t noiseMode = 0;
591 uint8_t shadingMode = 0;
592 uint8_t geometricMode = 0;
593 uint8_t colorMode = 0;
594 uint8_t tonemapMode = 0;
595 uint8_t edgeMode = 0;
596 switch (request_template) {
597 case CAMERA2_TEMPLATE_PREVIEW:
598 hotPixelMode = ANDROID_PROCESSING_FAST;
599 demosaicMode = ANDROID_PROCESSING_FAST;
600 noiseMode = ANDROID_PROCESSING_FAST;
601 shadingMode = ANDROID_PROCESSING_FAST;
602 geometricMode = ANDROID_PROCESSING_FAST;
603 colorMode = ANDROID_PROCESSING_FAST;
604 tonemapMode = ANDROID_PROCESSING_FAST;
605 edgeMode = ANDROID_PROCESSING_FAST;
606 break;
607 case CAMERA2_TEMPLATE_STILL_CAPTURE:
608 hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY;
609 demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY;
610 noiseMode = ANDROID_PROCESSING_HIGH_QUALITY;
611 shadingMode = ANDROID_PROCESSING_HIGH_QUALITY;
612 geometricMode = ANDROID_PROCESSING_HIGH_QUALITY;
613 colorMode = ANDROID_PROCESSING_HIGH_QUALITY;
614 tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY;
615 edgeMode = ANDROID_PROCESSING_HIGH_QUALITY;
616 break;
617 case CAMERA2_TEMPLATE_VIDEO_RECORD:
618 hotPixelMode = ANDROID_PROCESSING_FAST;
619 demosaicMode = ANDROID_PROCESSING_FAST;
620 noiseMode = ANDROID_PROCESSING_FAST;
621 shadingMode = ANDROID_PROCESSING_FAST;
622 geometricMode = ANDROID_PROCESSING_FAST;
623 colorMode = ANDROID_PROCESSING_FAST;
624 tonemapMode = ANDROID_PROCESSING_FAST;
625 edgeMode = ANDROID_PROCESSING_FAST;
626 break;
627 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
628 hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY;
629 demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY;
630 noiseMode = ANDROID_PROCESSING_HIGH_QUALITY;
631 shadingMode = ANDROID_PROCESSING_HIGH_QUALITY;
632 geometricMode = ANDROID_PROCESSING_HIGH_QUALITY;
633 colorMode = ANDROID_PROCESSING_HIGH_QUALITY;
634 tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY;
635 edgeMode = ANDROID_PROCESSING_HIGH_QUALITY;
636 break;
637 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
638 hotPixelMode = ANDROID_PROCESSING_HIGH_QUALITY;
639 demosaicMode = ANDROID_PROCESSING_HIGH_QUALITY;
640 noiseMode = ANDROID_PROCESSING_HIGH_QUALITY;
641 shadingMode = ANDROID_PROCESSING_HIGH_QUALITY;
642 geometricMode = ANDROID_PROCESSING_HIGH_QUALITY;
643 colorMode = ANDROID_PROCESSING_HIGH_QUALITY;
644 tonemapMode = ANDROID_PROCESSING_HIGH_QUALITY;
645 edgeMode = ANDROID_PROCESSING_HIGH_QUALITY;
646 break;
647 default:
648 hotPixelMode = ANDROID_PROCESSING_FAST;
649 demosaicMode = ANDROID_PROCESSING_FAST;
650 noiseMode = ANDROID_PROCESSING_FAST;
651 shadingMode = ANDROID_PROCESSING_FAST;
652 geometricMode = ANDROID_PROCESSING_FAST;
653 colorMode = ANDROID_PROCESSING_FAST;
654 tonemapMode = ANDROID_PROCESSING_FAST;
655 edgeMode = ANDROID_PROCESSING_FAST;
656 break;
657 }
658 ADD_OR_SIZE(ANDROID_HOT_PIXEL_MODE, &hotPixelMode, 1);
659 ADD_OR_SIZE(ANDROID_DEMOSAIC_MODE, &demosaicMode, 1);
660 ADD_OR_SIZE(ANDROID_NOISE_MODE, &noiseMode, 1);
661 ADD_OR_SIZE(ANDROID_SHADING_MODE, &shadingMode, 1);
662 ADD_OR_SIZE(ANDROID_GEOMETRIC_MODE, &geometricMode, 1);
663 ADD_OR_SIZE(ANDROID_COLOR_MODE, &colorMode, 1);
664 ADD_OR_SIZE(ANDROID_TONEMAP_MODE, &tonemapMode, 1);
665 ADD_OR_SIZE(ANDROID_EDGE_MODE, &edgeMode, 1);
666
667 /** android.noise */
668 static const uint8_t noiseStrength = 5;
669 ADD_OR_SIZE(ANDROID_NOISE_STRENGTH, &noiseStrength, 1);
670
671 /** android.color */
672 static const float colorTransform[9] = {
673 1.0f, 0.f, 0.f,
674 0.f, 1.f, 0.f,
675 0.f, 0.f, 1.f
676 };
677 ADD_OR_SIZE(ANDROID_COLOR_TRANSFORM, colorTransform, 9);
678
679 /** android.tonemap */
680 static const float tonemapCurve[4] = {
681 0.f, 0.f,
682 1.f, 1.f
683 };
684 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_RED, tonemapCurve, 32); // sungjoong
685 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_GREEN, tonemapCurve, 32);
686 ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_BLUE, tonemapCurve, 32);
687
688 /** android.edge */
689 static const uint8_t edgeStrength = 5;
690 ADD_OR_SIZE(ANDROID_EDGE_STRENGTH, &edgeStrength, 1);
691
692 /** android.scaler */
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700693 int32_t cropRegion[3] = {
694 0, 0, m_curCameraInfo->sensorW
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700695 };
696 ADD_OR_SIZE(ANDROID_SCALER_CROP_REGION, cropRegion, 3);
697
698 /** android.jpeg */
699 static const int32_t jpegQuality = 80;
700 ADD_OR_SIZE(ANDROID_JPEG_QUALITY, &jpegQuality, 1);
701
702 static const int32_t thumbnailSize[2] = {
703 640, 480
704 };
705 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_SIZE, thumbnailSize, 2);
706
707 static const int32_t thumbnailQuality = 80;
708 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_QUALITY, &thumbnailQuality, 1);
709
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700710 static const double gpsCoordinates[3] = {
711 0, 0, 0
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700712 };
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700713 ADD_OR_SIZE(ANDROID_JPEG_GPS_COORDINATES, gpsCoordinates, 3);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700714
715 static const uint8_t gpsProcessingMethod[32] = "None";
716 ADD_OR_SIZE(ANDROID_JPEG_GPS_PROCESSING_METHOD, gpsProcessingMethod, 32);
717
718 static const int64_t gpsTimestamp = 0;
719 ADD_OR_SIZE(ANDROID_JPEG_GPS_TIMESTAMP, &gpsTimestamp, 1);
720
721 static const int32_t jpegOrientation = 0;
722 ADD_OR_SIZE(ANDROID_JPEG_ORIENTATION, &jpegOrientation, 1);
723
724 /** android.stats */
725
726 static const uint8_t faceDetectMode = ANDROID_STATS_FACE_DETECTION_OFF;
727 ADD_OR_SIZE(ANDROID_STATS_FACE_DETECT_MODE, &faceDetectMode, 1);
728
729 static const uint8_t histogramMode = ANDROID_STATS_OFF;
730 ADD_OR_SIZE(ANDROID_STATS_HISTOGRAM_MODE, &histogramMode, 1);
731
732 static const uint8_t sharpnessMapMode = ANDROID_STATS_OFF;
733 ADD_OR_SIZE(ANDROID_STATS_SHARPNESS_MAP_MODE, &sharpnessMapMode, 1);
734
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700735
736 /** android.control */
737
738 uint8_t controlIntent = 0;
739 switch (request_template) {
740 case CAMERA2_TEMPLATE_PREVIEW:
741 controlIntent = ANDROID_CONTROL_INTENT_PREVIEW;
742 break;
743 case CAMERA2_TEMPLATE_STILL_CAPTURE:
744 controlIntent = ANDROID_CONTROL_INTENT_STILL_CAPTURE;
745 break;
746 case CAMERA2_TEMPLATE_VIDEO_RECORD:
747 controlIntent = ANDROID_CONTROL_INTENT_VIDEO_RECORD;
748 break;
749 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
750 controlIntent = ANDROID_CONTROL_INTENT_VIDEO_SNAPSHOT;
751 break;
752 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
753 controlIntent = ANDROID_CONTROL_INTENT_ZERO_SHUTTER_LAG;
754 break;
755 default:
756 controlIntent = ANDROID_CONTROL_INTENT_CUSTOM;
757 break;
758 }
759 ADD_OR_SIZE(ANDROID_CONTROL_CAPTURE_INTENT, &controlIntent, 1);
760
761 static const uint8_t controlMode = ANDROID_CONTROL_AUTO;
762 ADD_OR_SIZE(ANDROID_CONTROL_MODE, &controlMode, 1);
763
764 static const uint8_t effectMode = ANDROID_CONTROL_EFFECT_OFF;
765 ADD_OR_SIZE(ANDROID_CONTROL_EFFECT_MODE, &effectMode, 1);
766
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700767 static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700768 ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE, &sceneMode, 1);
769
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700770 static const uint8_t aeMode = ANDROID_CONTROL_AE_ON;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700771 ADD_OR_SIZE(ANDROID_CONTROL_AE_MODE, &aeMode, 1);
772
Sungjoong Kangdaa1fcd2012-08-08 11:49:43 -0700773 int32_t controlRegions[5] = {
774 0, 0, m_curCameraInfo->sensorW, m_curCameraInfo->sensorH, 1000
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700775 };
776 ADD_OR_SIZE(ANDROID_CONTROL_AE_REGIONS, controlRegions, 5);
777
778 static const int32_t aeExpCompensation = 0;
779 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXP_COMPENSATION, &aeExpCompensation, 1);
780
781 static const int32_t aeTargetFpsRange[2] = {
782 10, 30
783 };
784 ADD_OR_SIZE(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, aeTargetFpsRange, 2);
785
786 static const uint8_t aeAntibandingMode =
787 ANDROID_CONTROL_AE_ANTIBANDING_AUTO;
788 ADD_OR_SIZE(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &aeAntibandingMode, 1);
789
790 static const uint8_t awbMode =
791 ANDROID_CONTROL_AWB_AUTO;
792 ADD_OR_SIZE(ANDROID_CONTROL_AWB_MODE, &awbMode, 1);
793
794 ADD_OR_SIZE(ANDROID_CONTROL_AWB_REGIONS, controlRegions, 5);
795
796 uint8_t afMode = 0;
797 switch (request_template) {
798 case CAMERA2_TEMPLATE_PREVIEW:
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700799 afMode = ANDROID_CONTROL_AF_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700800 break;
801 case CAMERA2_TEMPLATE_STILL_CAPTURE:
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700802 afMode = ANDROID_CONTROL_AF_CONTINUOUS_PICTURE;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700803 break;
804 case CAMERA2_TEMPLATE_VIDEO_RECORD:
805 afMode = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO;
806 break;
807 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT:
808 afMode = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO;
809 break;
810 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG:
811 afMode = ANDROID_CONTROL_AF_CONTINUOUS_PICTURE;
812 break;
813 default:
814 afMode = ANDROID_CONTROL_AF_AUTO;
815 break;
816 }
817 ADD_OR_SIZE(ANDROID_CONTROL_AF_MODE, &afMode, 1);
818
819 ADD_OR_SIZE(ANDROID_CONTROL_AF_REGIONS, controlRegions, 5);
820
821 static const uint8_t vstabMode = ANDROID_CONTROL_VIDEO_STABILIZATION_OFF;
822 ADD_OR_SIZE(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, &vstabMode, 1);
823
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700824 if (sizeRequest) {
825 ALOGV("Allocating %d entries, %d extra bytes for "
826 "request template type %d",
827 entryCount, dataCount, request_template);
828 *request = allocate_camera_metadata(entryCount, dataCount);
829 if (*request == NULL) {
830 ALOGE("Unable to allocate new request template type %d "
831 "(%d entries, %d bytes extra data)", request_template,
832 entryCount, dataCount);
833 return NO_MEMORY;
834 }
835 }
836 return OK;
837#undef ADD_OR_SIZE
838}
839
840}