3 ** Copyright 2008, The Android Open Source Project
4 ** Copyright 2012, Samsung Electronics Co. LTD
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
10 ** http://www.apache.org/licenses/LICENSE-2.0
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.
20 * \file ExynosCamera2.cpp
21 * \brief source file for static information of camera2
22 * \author Sungjoong Kang(sj3.kang@samsung.com)
25 * <b>Revision History: </b>
26 * - 2012/08/06 : Sungjoong Kang(sj3.kang@samsung.com) \n
31 //#define LOG_NDEBUG 0
32 #define LOG_TAG "ExynosCamera2"
33 #include <utils/Log.h>
35 #include "ExynosCamera2.h"
37 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
44 * Static sensor characteristics
46 static const unsigned int kResolution
[2][2];
48 static const nsecs_t kExposureTimeRange
[2];
49 static const nsecs_t kFrameDurationRange
[2];
50 static const nsecs_t kMinVerticalBlank
;
52 static const uint8_t kColorFilterArrangement
;
54 // Output image data characteristics
55 static const uint32_t kMaxRawValue
;
56 static const uint32_t kBlackLevel
;
57 // Sensor sensitivity, approximate
59 static const float kSaturationVoltage
;
60 static const uint32_t kSaturationElectrons
;
61 static const float kVoltsPerLuxSecond
;
62 static const float kElectronsPerLuxSecond
;
64 static const float kBaseGainFactor
;
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
;
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
;
77 static const uint32_t kAvailableSensitivities
[5];
78 static const uint32_t kDefaultSensitivity
;
84 const uint32_t Sensor::kAvailableSensitivities
[5] =
85 {100, 200, 400, 800, 1600};
86 const nsecs_t
Sensor::kExposureTimeRange
[2] =
87 {1000L, 30000000000L} ; // 1 us - 30 sec
88 const nsecs_t
Sensor::kFrameDurationRange
[2] =
89 {33331760L, 30000000000L}; // ~1/30 s - 30 sec
91 const uint8_t Sensor::kColorFilterArrangement
= ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGGB
;
93 const uint32_t kAvailableFormats
[5] = {
94 HAL_PIXEL_FORMAT_RAW_SENSOR
,
95 HAL_PIXEL_FORMAT_BLOB
,
96 HAL_PIXEL_FORMAT_RGBA_8888
,
97 HAL_PIXEL_FORMAT_YV12
,
98 HAL_PIXEL_FORMAT_YCrCb_420_SP
101 // Output image data characteristics
102 const uint32_t Sensor::kMaxRawValue
= 4000;
103 const uint32_t Sensor::kBlackLevel
= 1000;
105 const uint64_t kAvailableRawMinDurations
[1] = {
106 Sensor::kFrameDurationRange
[0]
109 const uint64_t kAvailableProcessedMinDurations
[1] = {
110 Sensor::kFrameDurationRange
[0]
112 const uint64_t kAvailableJpegMinDurations
[1] = {
113 Sensor::kFrameDurationRange
[0]
116 const int32_t scalerResolutionS5K4E5
[] =
136 const int32_t jpegResolutionS5K4E5
[] =
150 const uint8_t availableAfModesS5K4E5
[] =
152 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
159 const uint8_t sceneModeOverridesS5K4E5
[] =
161 // ANDROID_CONTROL_SCENE_MODE_ACTION
162 ANDROID_CONTROL_AE_MODE_ON
,
163 ANDROID_CONTROL_AWB_MODE_AUTO
,
164 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
,
165 // ANDROID_CONTROL_SCENE_MODE_NIGHT
166 ANDROID_CONTROL_AE_MODE_ON
,
167 ANDROID_CONTROL_AWB_MODE_AUTO
,
168 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
,
169 // ANDROID_CONTROL_SCENE_MODE_SUNSET
170 ANDROID_CONTROL_AE_MODE_ON
,
171 ANDROID_CONTROL_AWB_MODE_DAYLIGHT
,
172 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
,
173 // ANDROID_CONTROL_SCENE_MODE_PARTY
174 ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH
,
175 ANDROID_CONTROL_AWB_MODE_AUTO
,
176 ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
179 const uint8_t availableAeModesS5K4E5
[] =
181 ANDROID_CONTROL_AE_MODE_OFF
,
182 ANDROID_CONTROL_AE_MODE_ON
,
183 ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH
186 ExynosCamera2InfoS5K4E5::ExynosCamera2InfoS5K4E5()
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
;
196 minFocusDistance
= 0.1f
;
200 availableAfModes
= availableAfModesS5K4E5
;
201 numAvailableAfModes
= ARRAY_SIZE(availableAfModesS5K4E5
);
202 sceneModeOverrides
= sceneModeOverridesS5K4E5
;
203 numSceneModeOverrides
= ARRAY_SIZE(sceneModeOverridesS5K4E5
);
204 availableAeModes
= availableAeModesS5K4E5
;
205 numAvailableAeModes
= ARRAY_SIZE(availableAeModesS5K4E5
);
208 ExynosCamera2InfoS5K4E5::~ExynosCamera2InfoS5K4E5()
210 ALOGV("%s", __FUNCTION__
);
212 const int32_t scalerResolutionS5K6A3
[] =
232 const int32_t jpegResolutionS5K6A3
[] =
246 const uint8_t availableAfModesS5K6A3
[] =
248 ANDROID_CONTROL_AF_MODE_OFF
251 const uint8_t sceneModeOverridesS5K6A3
[] =
253 // ANDROID_CONTROL_SCENE_MODE_ACTION
254 ANDROID_CONTROL_AE_MODE_ON
,
255 ANDROID_CONTROL_AWB_MODE_AUTO
,
256 ANDROID_CONTROL_AF_MODE_OFF
,
257 // ANDROID_CONTROL_SCENE_MODE_NIGHT
258 ANDROID_CONTROL_AE_MODE_ON
,
259 ANDROID_CONTROL_AWB_MODE_AUTO
,
260 ANDROID_CONTROL_AF_MODE_OFF
,
261 // ANDROID_CONTROL_SCENE_MODE_SUNSET
262 ANDROID_CONTROL_AE_MODE_ON
,
263 ANDROID_CONTROL_AWB_MODE_DAYLIGHT
,
264 ANDROID_CONTROL_AF_MODE_OFF
,
265 // ANDROID_CONTROL_SCENE_MODE_PARTY
266 ANDROID_CONTROL_AE_MODE_ON
,
267 ANDROID_CONTROL_AWB_MODE_AUTO
,
268 ANDROID_CONTROL_AF_MODE_OFF
271 const uint8_t availableAeModesS5K6A3
[] =
273 ANDROID_CONTROL_AE_MODE_OFF
,
274 ANDROID_CONTROL_AE_MODE_ON
277 ExynosCamera2InfoS5K6A3::ExynosCamera2InfoS5K6A3()
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
;
287 minFocusDistance
= 0.0f
;
291 availableAfModes
= availableAfModesS5K6A3
;
292 numAvailableAfModes
= ARRAY_SIZE(availableAfModesS5K6A3
);
293 sceneModeOverrides
= sceneModeOverridesS5K6A3
;
294 numSceneModeOverrides
= ARRAY_SIZE(sceneModeOverridesS5K6A3
);
295 availableAeModes
= availableAeModesS5K6A3
;
296 numAvailableAeModes
= ARRAY_SIZE(availableAeModesS5K6A3
);
299 ExynosCamera2InfoS5K6A3::~ExynosCamera2InfoS5K6A3()
301 ALOGV("%s", __FUNCTION__
);
303 ExynosCamera2::ExynosCamera2(int cameraId
):
307 m_curCameraInfo
= new ExynosCamera2InfoS5K4E5
;
309 m_curCameraInfo
= new ExynosCamera2InfoS5K6A3
;
312 ExynosCamera2::~ExynosCamera2()
314 ALOGV("%s", __FUNCTION__
);
315 delete m_curCameraInfo
;
316 m_curCameraInfo
= NULL
;
319 int32_t ExynosCamera2::getSensorW()
321 return m_curCameraInfo
->sensorW
;
324 int32_t ExynosCamera2::getSensorH()
326 return m_curCameraInfo
->sensorH
;
329 int32_t ExynosCamera2::getSensorRawW()
331 return m_curCameraInfo
->sensorRawW
;
334 int32_t ExynosCamera2::getSensorRawH()
336 return m_curCameraInfo
->sensorRawH
;
339 bool ExynosCamera2::isSupportedResolution(int width
, int height
)
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
) {
351 bool ExynosCamera2::isSupportedJpegResolution(int width
, int height
)
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
) {
363 status_t
addOrSize(camera_metadata_t
*request
,
368 const void *entryData
,
369 size_t entryDataCount
) {
372 return add_camera_metadata_entry(request
, tag
, entryData
,
375 int type
= get_camera_metadata_tag_type(tag
);
376 if (type
< 0 ) return BAD_VALUE
;
378 (*dataCount
) += calculate_camera_metadata_entry_data_size(type
,
384 status_t
ExynosCamera2::constructStaticInfo(camera_metadata_t
**info
,
385 int cameraId
, bool sizeRequest
) {
387 size_t entryCount
= 0;
388 size_t dataCount
= 0;
391 #define ADD_OR_SIZE( tag, data, count ) \
392 if ( ( ret = addOrSize(*info, sizeRequest, &entryCount, &dataCount, \
393 tag, data, count) ) != OK ) return ret
397 ADD_OR_SIZE(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE
,
398 &(m_curCameraInfo
->minFocusDistance
), 1);
399 ADD_OR_SIZE(ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE
,
400 &(m_curCameraInfo
->minFocusDistance
), 1);
402 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS
,
403 &m_curCameraInfo
->focalLength
, 1);
404 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_APERTURES
,
405 &m_curCameraInfo
->aperture
, 1);
407 static const float filterDensity
= 0;
408 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES
,
410 static const uint8_t availableOpticalStabilization
=
411 ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF
;
412 ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION
,
413 &availableOpticalStabilization
, 1);
415 static const int32_t lensShadingMapSize
[] = {1, 1};
416 ADD_OR_SIZE(ANDROID_LENS_INFO_SHADING_MAP_SIZE
, lensShadingMapSize
,
417 sizeof(lensShadingMapSize
)/sizeof(int32_t));
419 static const float lensShadingMap
[3 * 1 * 1 ] =
421 ADD_OR_SIZE(ANDROID_LENS_INFO_SHADING_MAP
, lensShadingMap
,
422 sizeof(lensShadingMap
)/sizeof(float));
424 int32_t lensFacing
= cameraId
?
425 ANDROID_LENS_FACING_FRONT
: ANDROID_LENS_FACING_BACK
;
426 ADD_OR_SIZE(ANDROID_LENS_FACING
, &lensFacing
, 1);
429 ADD_OR_SIZE(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE
,
430 Sensor::kExposureTimeRange
, 2);
432 ADD_OR_SIZE(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION
,
433 &Sensor::kFrameDurationRange
[1], 1);
435 ADD_OR_SIZE(ANDROID_SENSOR_INFO_AVAILABLE_SENSITIVITIES
,
436 Sensor::kAvailableSensitivities
,
437 sizeof(Sensor::kAvailableSensitivities
)
440 ADD_OR_SIZE(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT
,
441 &Sensor::kColorFilterArrangement
, 1);
443 static const float sensorPhysicalSize
[2] = {3.20f
, 2.40f
}; // mm
444 ADD_OR_SIZE(ANDROID_SENSOR_INFO_PHYSICAL_SIZE
,
445 sensorPhysicalSize
, 2);
447 int32_t pixelArraySize
[2] = {
448 m_curCameraInfo
->sensorW
, m_curCameraInfo
->sensorH
450 ADD_OR_SIZE(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE
, pixelArraySize
, 2);
451 ADD_OR_SIZE(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE
, pixelArraySize
,2);
453 ADD_OR_SIZE(ANDROID_SENSOR_INFO_WHITE_LEVEL
,
454 &Sensor::kMaxRawValue
, 1);
456 static const int32_t blackLevelPattern
[4] = {
457 Sensor::kBlackLevel
, Sensor::kBlackLevel
,
458 Sensor::kBlackLevel
, Sensor::kBlackLevel
460 ADD_OR_SIZE(ANDROID_SENSOR_BLACK_LEVEL_PATTERN
,
461 blackLevelPattern
, sizeof(blackLevelPattern
)/sizeof(int32_t));
463 //TODO: sensor color calibration fields
466 uint8_t flashAvailable
;
471 ADD_OR_SIZE(ANDROID_FLASH_INFO_AVAILABLE
, &flashAvailable
, 1);
473 static const int64_t flashChargeDuration
= 0;
474 ADD_OR_SIZE(ANDROID_FLASH_INFO_CHARGE_DURATION
, &flashChargeDuration
, 1);
478 static const int32_t tonemapCurvePoints
= 128;
479 ADD_OR_SIZE(ANDROID_TONEMAP_MAX_CURVE_POINTS
, &tonemapCurvePoints
, 1);
483 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_FORMATS
,
485 sizeof(kAvailableFormats
)/sizeof(uint32_t));
487 int32_t availableRawSizes
[2] = {
488 m_curCameraInfo
->sensorRawW
, m_curCameraInfo
->sensorRawH
490 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_SIZES
,
491 availableRawSizes
, 2);
493 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS
,
494 kAvailableRawMinDurations
,
495 sizeof(kAvailableRawMinDurations
)/sizeof(uint64_t));
498 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);
505 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS
,
506 kAvailableProcessedMinDurations
,
507 sizeof(kAvailableProcessedMinDurations
)/sizeof(uint64_t));
509 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS
,
510 kAvailableJpegMinDurations
,
511 sizeof(kAvailableJpegMinDurations
)/sizeof(uint64_t));
513 static const float maxZoom
= 4;
514 ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM
, &maxZoom
, 1);
518 static const int32_t jpegThumbnailSizes
[] = {
526 ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES
,
527 jpegThumbnailSizes
, sizeof(jpegThumbnailSizes
)/sizeof(int32_t));
529 static const int32_t jpegMaxSize
= 10 * 1024 * 1024;
530 ADD_OR_SIZE(ANDROID_JPEG_MAX_SIZE
, &jpegMaxSize
, 1);
534 static const uint8_t availableFaceDetectModes
[] = {
535 ANDROID_STATISTICS_FACE_DETECT_MODE_OFF
,
536 ANDROID_STATISTICS_FACE_DETECT_MODE_FULL
538 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES
,
539 availableFaceDetectModes
,
540 sizeof(availableFaceDetectModes
));
542 m_curCameraInfo
->maxFaceCount
= CAMERA2_MAX_FACES
;
543 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT
,
544 &(m_curCameraInfo
->maxFaceCount
), 1);
546 static const int32_t histogramSize
= 64;
547 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT
,
550 static const int32_t maxHistogramCount
= 1000;
551 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT
,
552 &maxHistogramCount
, 1);
554 static const int32_t sharpnessMapSize
[2] = {64, 64};
555 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE
,
556 sharpnessMapSize
, sizeof(sharpnessMapSize
)/sizeof(int32_t));
558 static const int32_t maxSharpnessMapValue
= 1000;
559 ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE
,
560 &maxSharpnessMapValue
, 1);
564 static const uint8_t availableSceneModes
[] = {
565 ANDROID_CONTROL_SCENE_MODE_ACTION
,
566 ANDROID_CONTROL_SCENE_MODE_NIGHT
,
567 ANDROID_CONTROL_SCENE_MODE_SUNSET
,
568 ANDROID_CONTROL_SCENE_MODE_PARTY
570 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_SCENE_MODES
,
571 availableSceneModes
, sizeof(availableSceneModes
));
573 static const uint8_t availableEffects
[] = {
574 ANDROID_CONTROL_EFFECT_MODE_OFF
576 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_EFFECTS
,
577 availableEffects
, sizeof(availableEffects
));
579 int32_t max3aRegions
= 1;
580 ADD_OR_SIZE(ANDROID_CONTROL_MAX_REGIONS
,
583 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_MODES
,
584 m_curCameraInfo
->availableAeModes
, m_curCameraInfo
->numAvailableAeModes
);
586 static const camera_metadata_rational exposureCompensationStep
= {
589 ADD_OR_SIZE(ANDROID_CONTROL_AE_COMPENSATION_STEP
,
590 &exposureCompensationStep
, 1);
592 int32_t exposureCompensationRange
[] = {-3, 3};
593 ADD_OR_SIZE(ANDROID_CONTROL_AE_COMPENSATION_RANGE
,
594 exposureCompensationRange
,
595 sizeof(exposureCompensationRange
)/sizeof(int32_t));
597 static const int32_t availableTargetFpsRanges
[] = {
598 15, 15, 24, 24, 25, 25, 15, 30, 30, 30
600 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
,
601 availableTargetFpsRanges
,
602 sizeof(availableTargetFpsRanges
)/sizeof(int32_t));
604 static const uint8_t availableAntibandingModes
[] = {
605 ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF
,
606 ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO
608 ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES
,
609 availableAntibandingModes
, sizeof(availableAntibandingModes
));
611 static const uint8_t availableAwbModes
[] = {
612 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
619 ADD_OR_SIZE(ANDROID_CONTROL_AWB_AVAILABLE_MODES
,
620 availableAwbModes
, sizeof(availableAwbModes
));
622 ADD_OR_SIZE(ANDROID_CONTROL_AF_AVAILABLE_MODES
,
623 m_curCameraInfo
->availableAfModes
, m_curCameraInfo
->numAvailableAfModes
);
625 static const uint8_t availableVstabModes
[] = {
626 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF
,
627 ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON
629 ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES
,
630 availableVstabModes
, sizeof(availableVstabModes
));
632 ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE_OVERRIDES
,
633 m_curCameraInfo
->sceneModeOverrides
, m_curCameraInfo
->numSceneModeOverrides
);
635 static const uint8_t quirkTriggerAuto
= 1;
636 ADD_OR_SIZE(ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO
,
637 &quirkTriggerAuto
, 1);
639 static const uint8_t quirkUseZslFormat
= 1;
640 ADD_OR_SIZE(ANDROID_QUIRKS_USE_ZSL_FORMAT
,
641 &quirkUseZslFormat
, 1);
643 static const uint8_t quirkMeteringCropRegion
= 1;
644 ADD_OR_SIZE(ANDROID_QUIRKS_METERING_CROP_REGION
,
645 &quirkMeteringCropRegion
, 1);
649 /** Allocate metadata if sizing */
651 ALOGV("Allocating %d entries, %d extra bytes for "
652 "static camera info",
653 entryCount
, dataCount
);
654 *info
= allocate_camera_metadata(entryCount
, dataCount
);
656 ALOGE("Unable to allocate camera static info"
657 "(%d entries, %d bytes extra data)",
658 entryCount
, dataCount
);
665 status_t
ExynosCamera2::constructDefaultRequest(
666 int request_template
,
667 camera_metadata_t
**request
,
670 size_t entryCount
= 0;
671 size_t dataCount
= 0;
674 #define ADD_OR_SIZE( tag, data, count ) \
675 if ( ( ret = addOrSize(*request, sizeRequest, &entryCount, &dataCount, \
676 tag, data, count) ) != OK ) return ret
678 static const int64_t USEC
= 1000LL;
679 static const int64_t MSEC
= USEC
* 1000LL;
680 static const int64_t SEC
= MSEC
* 1000LL;
682 /** android.request */
684 static const uint8_t metadataMode
= ANDROID_REQUEST_METADATA_MODE_NONE
;
685 ADD_OR_SIZE(ANDROID_REQUEST_METADATA_MODE
, &metadataMode
, 1);
687 static const int32_t id
= 0;
688 ADD_OR_SIZE(ANDROID_REQUEST_ID
, &id
, 1);
690 static const int32_t frameCount
= 0;
691 ADD_OR_SIZE(ANDROID_REQUEST_FRAME_COUNT
, &frameCount
, 1);
693 // OUTPUT_STREAMS set by user
695 dataCount
+= 5; // TODO: Should be maximum stream number
699 static const float focusDistance
= 0;
700 ADD_OR_SIZE(ANDROID_LENS_FOCUS_DISTANCE
, &focusDistance
, 1);
702 ADD_OR_SIZE(ANDROID_LENS_APERTURE
, &m_curCameraInfo
->aperture
, 1);
704 ADD_OR_SIZE(ANDROID_LENS_FOCAL_LENGTH
, &m_curCameraInfo
->focalLength
, 1);
706 static const float filterDensity
= 0;
707 ADD_OR_SIZE(ANDROID_LENS_FILTER_DENSITY
, &filterDensity
, 1);
709 static const uint8_t opticalStabilizationMode
=
710 ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF
;
711 ADD_OR_SIZE(ANDROID_LENS_OPTICAL_STABILIZATION_MODE
,
712 &opticalStabilizationMode
, 1);
715 /** android.sensor */
718 static const int64_t frameDuration
= 33333333L; // 1/30 s
719 ADD_OR_SIZE(ANDROID_SENSOR_FRAME_DURATION
, &frameDuration
, 1);
724 static const uint8_t flashMode
= ANDROID_FLASH_MODE_OFF
;
725 ADD_OR_SIZE(ANDROID_FLASH_MODE
, &flashMode
, 1);
727 static const uint8_t flashPower
= 10;
728 ADD_OR_SIZE(ANDROID_FLASH_FIRING_POWER
, &flashPower
, 1);
730 static const int64_t firingTime
= 0;
731 ADD_OR_SIZE(ANDROID_FLASH_FIRING_TIME
, &firingTime
, 1);
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;
742 uint8_t vstabMode
= ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF
;
744 switch (request_template
) {
745 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT
:
746 vstabMode
= ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON
;
748 case CAMERA2_TEMPLATE_STILL_CAPTURE
:
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
;
760 case CAMERA2_TEMPLATE_VIDEO_RECORD
:
761 vstabMode
= ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON
;
763 case CAMERA2_TEMPLATE_PREVIEW
:
766 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
;
776 ADD_OR_SIZE(ANDROID_HOT_PIXEL_MODE
, &hotPixelMode
, 1);
777 ADD_OR_SIZE(ANDROID_DEMOSAIC_MODE
, &demosaicMode
, 1);
778 ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_MODE
, &noiseMode
, 1);
779 ADD_OR_SIZE(ANDROID_SHADING_MODE
, &shadingMode
, 1);
780 ADD_OR_SIZE(ANDROID_GEOMETRIC_MODE
, &geometricMode
, 1);
781 ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_MODE
, &colorMode
, 1);
782 ADD_OR_SIZE(ANDROID_TONEMAP_MODE
, &tonemapMode
, 1);
783 ADD_OR_SIZE(ANDROID_EDGE_MODE
, &edgeMode
, 1);
784 ADD_OR_SIZE(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE
, &vstabMode
, 1);
787 static const uint8_t noiseStrength
= 5;
788 ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_STRENGTH
, &noiseStrength
, 1);
791 static const float colorTransform
[9] = {
796 ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_TRANSFORM
, colorTransform
, 9);
798 /** android.tonemap */
799 static const float tonemapCurve
[4] = {
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);
808 static const uint8_t edgeStrength
= 5;
809 ADD_OR_SIZE(ANDROID_EDGE_STRENGTH
, &edgeStrength
, 1);
811 /** android.scaler */
812 int32_t cropRegion
[3] = {
813 0, 0, m_curCameraInfo
->sensorW
815 ADD_OR_SIZE(ANDROID_SCALER_CROP_REGION
, cropRegion
, 3);
818 static const int32_t jpegQuality
= 100;
819 ADD_OR_SIZE(ANDROID_JPEG_QUALITY
, &jpegQuality
, 1);
821 static const int32_t thumbnailSize
[2] = {
824 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_SIZE
, thumbnailSize
, 2);
826 static const int32_t thumbnailQuality
= 100;
827 ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_QUALITY
, &thumbnailQuality
, 1);
829 static const double gpsCoordinates
[3] = {
832 ADD_OR_SIZE(ANDROID_JPEG_GPS_COORDINATES
, gpsCoordinates
, 3);
834 static const uint8_t gpsProcessingMethod
[32] = "None";
835 ADD_OR_SIZE(ANDROID_JPEG_GPS_PROCESSING_METHOD
, gpsProcessingMethod
, 32);
837 static const int64_t gpsTimestamp
= 0;
838 ADD_OR_SIZE(ANDROID_JPEG_GPS_TIMESTAMP
, &gpsTimestamp
, 1);
840 static const int32_t jpegOrientation
= 0;
841 ADD_OR_SIZE(ANDROID_JPEG_ORIENTATION
, &jpegOrientation
, 1);
845 static const uint8_t faceDetectMode
= ANDROID_STATISTICS_FACE_DETECT_MODE_FULL
;
846 ADD_OR_SIZE(ANDROID_STATISTICS_FACE_DETECT_MODE
, &faceDetectMode
, 1);
848 static const uint8_t histogramMode
= ANDROID_STATISTICS_HISTOGRAM_MODE_OFF
;
849 ADD_OR_SIZE(ANDROID_STATISTICS_HISTOGRAM_MODE
, &histogramMode
, 1);
851 static const uint8_t sharpnessMapMode
= ANDROID_STATISTICS_HISTOGRAM_MODE_OFF
;
852 ADD_OR_SIZE(ANDROID_STATISTICS_SHARPNESS_MAP_MODE
, &sharpnessMapMode
, 1);
855 /** android.control */
857 uint8_t controlIntent
= 0;
858 switch (request_template
) {
859 case CAMERA2_TEMPLATE_PREVIEW
:
860 controlIntent
= ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW
;
862 case CAMERA2_TEMPLATE_STILL_CAPTURE
:
863 controlIntent
= ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE
;
865 case CAMERA2_TEMPLATE_VIDEO_RECORD
:
866 controlIntent
= ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD
;
868 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT
:
869 controlIntent
= ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT
;
871 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG
:
872 controlIntent
= ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG
;
875 controlIntent
= ANDROID_CONTROL_CAPTURE_INTENT_CUSTOM
;
878 ADD_OR_SIZE(ANDROID_CONTROL_CAPTURE_INTENT
, &controlIntent
, 1);
880 static const uint8_t controlMode
= ANDROID_CONTROL_MODE_AUTO
;
881 ADD_OR_SIZE(ANDROID_CONTROL_MODE
, &controlMode
, 1);
883 static const uint8_t effectMode
= ANDROID_CONTROL_EFFECT_MODE_OFF
;
884 ADD_OR_SIZE(ANDROID_CONTROL_EFFECT_MODE
, &effectMode
, 1);
886 static const uint8_t sceneMode
= ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED
;
887 ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE
, &sceneMode
, 1);
889 static const uint8_t aeMode
= ANDROID_CONTROL_AE_MODE_ON
;
890 ADD_OR_SIZE(ANDROID_CONTROL_AE_MODE
, &aeMode
, 1);
892 int32_t controlRegions
[5] = {
893 0, 0, m_curCameraInfo
->sensorW
, m_curCameraInfo
->sensorH
, 1000
895 ADD_OR_SIZE(ANDROID_CONTROL_AE_REGIONS
, controlRegions
, 5);
897 static const int32_t aeExpCompensation
= 0;
898 ADD_OR_SIZE(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION
, &aeExpCompensation
, 1);
900 static const int32_t aeTargetFpsRange
[2] = {
903 ADD_OR_SIZE(ANDROID_CONTROL_AE_TARGET_FPS_RANGE
, aeTargetFpsRange
, 2);
905 static const uint8_t aeAntibandingMode
=
906 ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO
;
907 ADD_OR_SIZE(ANDROID_CONTROL_AE_ANTIBANDING_MODE
, &aeAntibandingMode
, 1);
909 static const uint8_t awbMode
=
910 ANDROID_CONTROL_AWB_MODE_AUTO
;
911 ADD_OR_SIZE(ANDROID_CONTROL_AWB_MODE
, &awbMode
, 1);
913 ADD_OR_SIZE(ANDROID_CONTROL_AWB_REGIONS
, controlRegions
, 5);
916 switch (request_template
) {
917 case CAMERA2_TEMPLATE_PREVIEW
:
918 afMode
= ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
;
920 case CAMERA2_TEMPLATE_STILL_CAPTURE
:
921 afMode
= ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
;
923 case CAMERA2_TEMPLATE_VIDEO_RECORD
:
924 afMode
= ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO
;
926 case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT
:
927 afMode
= ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO
;
929 case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG
:
930 afMode
= ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE
;
933 afMode
= ANDROID_CONTROL_AF_MODE_AUTO
;
936 ADD_OR_SIZE(ANDROID_CONTROL_AF_MODE
, &afMode
, 1);
938 ADD_OR_SIZE(ANDROID_CONTROL_AF_REGIONS
, controlRegions
, 5);
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
);