blob: 869fae32e2bf61676b2ef9635af341a7b8512369 [file] [log] [blame]
Jiyoung Shinc15a6b02012-06-05 01:08:14 -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 MetadataConverter.cpp
21 * \brief source file for Metadata converter ( for camera hal2 implementation )
22 * \author Sungjoong Kang(sj3.kang@samsung.com)
23 * \date 2012/05/31
24 *
25 * <b>Revision History: </b>
26 * - 2012/05/31 : Sungjoong Kang(sj3.kang@samsung.com) \n
27 * Initial Release
28 */
29
Sungjoong Kangad378612012-08-17 12:34:33 -070030//#define LOG_NDEBUG 0
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070031#define LOG_TAG "MetadataConverter"
32#include <utils/Log.h>
33
34#include "MetadataConverter.h"
35
36namespace android {
37
38
39MetadataConverter::MetadataConverter()
40{
41 return;
42}
43
44
45MetadataConverter::~MetadataConverter()
46{
Sungjoong Kang15fd8232012-08-23 16:16:44 -070047 ALOGE("DEBUG(%s)destroy!!:", __FUNCTION__);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070048 return;
49}
50
51status_t MetadataConverter::CheckEntryTypeMismatch(camera_metadata_entry_t * entry,
52 uint8_t type)
53{
54 if (!(entry->type==type))
55 {
56 ALOGV("DEBUG(%s):Metadata Missmatch tag(%s) type (%d) count(%d)",
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +090057 __FUNCTION__, get_camera_metadata_tag_name(entry->tag), entry->type, entry->count);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070058 return BAD_VALUE;
59 }
60 return NO_ERROR;
61}
62
63status_t MetadataConverter::CheckEntryTypeMismatch(camera_metadata_entry_t * entry,
64 uint8_t type, size_t count)
65{
66 if (!((entry->type==type)&&(entry->count==count)))
67 {
68 ALOGV("DEBUG(%s):Metadata Missmatch tag(%s) type (%d) count(%d)",
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +090069 __FUNCTION__, get_camera_metadata_tag_name(entry->tag), entry->type, entry->count);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070070 return BAD_VALUE;
71 }
72 return NO_ERROR;
73}
74
Sungjoong Kangbe494d12012-08-04 15:36:56 -070075status_t MetadataConverter::ToInternalShot(camera_metadata_t * request, struct camera2_shot_ext * dst_ext)
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070076{
77 uint32_t num_entry = 0;
78 uint32_t index = 0;
79 uint32_t i = 0;
80 camera_metadata_entry_t curr_entry;
Sungjoong Kangbe494d12012-08-04 15:36:56 -070081 struct camera2_shot * dst = NULL;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070082
Sungjoong Kangbe494d12012-08-04 15:36:56 -070083 if (request == NULL || dst_ext == NULL)
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070084 return BAD_VALUE;
85
Sungjoong Kangb56dcc02012-08-08 13:38:09 -070086 memset((void*)dst_ext, 0, sizeof(struct camera2_shot_ext));
87 dst = &dst_ext->shot;
Sungjoong Kangbe494d12012-08-04 15:36:56 -070088
Sungjoong Kangb56dcc02012-08-08 13:38:09 -070089 dst->magicNumber = 0x23456789;
Sungjoong Kang2bdec062012-08-17 15:47:56 -070090 dst->ctl.aa.aeTargetFpsRange[0] = 15;
91 dst->ctl.aa.aeTargetFpsRange[1] = 30;
92 dst->ctl.aa.aeExpCompensation = 5;
93
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070094 num_entry = (uint32_t)get_camera_metadata_data_count(request);
95 for (index = 0 ; index < num_entry ; index++) {
96
97 if (get_camera_metadata_entry(request, index, &curr_entry)==0) {
Jiyoung Shinc15a6b02012-06-05 01:08:14 -070098 switch (curr_entry.tag) {
99
100 case ANDROID_LENS_FOCUS_DISTANCE:
101 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_FLOAT, 1))
102 break;
103 dst->ctl.lens.focusDistance = curr_entry.data.f[0];
104 break;
105
106 case ANDROID_LENS_APERTURE:
107 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_FLOAT, 1))
108 break;
109 dst->ctl.lens.aperture = curr_entry.data.f[0];
110 break;
111
112 case ANDROID_LENS_FOCAL_LENGTH:
113 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_FLOAT, 1))
114 break;
115 dst->ctl.lens.focalLength = curr_entry.data.f[0];
116 break;
117
118 case ANDROID_LENS_FILTER_DENSITY:
119 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_FLOAT, 1))
120 break;
121 dst->ctl.lens.filterDensity = curr_entry.data.f[0];
122 break;
123
124 case ANDROID_LENS_OPTICAL_STABILIZATION_MODE:
125 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
126 break;
127 dst->ctl.lens.opticalStabilizationMode =
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700128 (enum optical_stabilization_mode)curr_entry.data.u8[0];
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700129 break;
130
131
132
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700133
134 case ANDROID_FLASH_MODE:
135 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
136 break;
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700137 dst->ctl.flash.flashMode = (enum flash_mode)curr_entry.data.u8[0];
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700138 break;
139
140 case ANDROID_FLASH_FIRING_POWER:
141 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
142 break;
143 dst->ctl.flash.firingPower = curr_entry.data.u8[0];
144 break;
145
146 case ANDROID_FLASH_FIRING_TIME:
147 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT64, 1))
148 break;
149 dst->ctl.flash.firingTime = curr_entry.data.i64[0];
150 break;
151
152
153
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700154
155
156 case ANDROID_JPEG_QUALITY:
157 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 1))
158 break;
159 dst->ctl.jpeg.quality= curr_entry.data.i32[0];
160 break;
161
162 case ANDROID_JPEG_THUMBNAIL_SIZE:
163 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 2))
164 break;
165 for (i=0 ; i<curr_entry.count ; i++)
166 dst->ctl.jpeg.thumbnailSize[i] = curr_entry.data.i32[i];
167 break;
168
169 case ANDROID_JPEG_THUMBNAIL_QUALITY:
170 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 1))
171 break;
172 dst->ctl.jpeg.thumbnailQuality= curr_entry.data.i32[0];
173 break;
174
175 case ANDROID_JPEG_GPS_COORDINATES:
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700176 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_DOUBLE, 3))
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700177 break;
178 for (i=0 ; i<curr_entry.count ; i++)
179 dst->ctl.jpeg.gpsCoordinates[i] = curr_entry.data.d[i];
180 break;
181
182 case ANDROID_JPEG_GPS_PROCESSING_METHOD:
183 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 32))
184 break;
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700185 for (i=0 ; i<curr_entry.count ; i++)
186 dst_ext->gpsProcessingMethod[i] = curr_entry.data.u8[i];
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700187 break;
188
189 case ANDROID_JPEG_GPS_TIMESTAMP:
190 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT64, 1))
191 break;
192 dst->ctl.jpeg.gpsTimestamp = curr_entry.data.i64[0];
193 break;
194
195 case ANDROID_JPEG_ORIENTATION:
196 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 1))
197 break;
198 dst->ctl.jpeg.orientation = curr_entry.data.i32[0];
199 break;
200
201
202
203 case ANDROID_STATS_FACE_DETECT_MODE:
204 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
205 break;
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700206 dst->ctl.stats.faceDetectMode = (enum facedetect_mode)(curr_entry.data.u8[0] + 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700207 break;
208
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700209 case ANDROID_CONTROL_CAPTURE_INTENT:
210 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
211 break;
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700212 dst->ctl.aa.captureIntent = (enum aa_capture_intent)curr_entry.data.u8[0];
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900213 break;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700214
215 case ANDROID_CONTROL_MODE:
216 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
217 break;
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700218 dst->ctl.aa.mode = (enum aa_mode)curr_entry.data.u8[0];
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700219 break;
220
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700221
222 case ANDROID_CONTROL_VIDEO_STABILIZATION_MODE:
223 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
224 break;
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700225 dst->ctl.aa.videoStabilizationMode = curr_entry.data.u8[0];
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700226 break;
227
228 case ANDROID_CONTROL_AE_MODE:
229 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
230 break;
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700231 dst->ctl.aa.aeMode = (enum aa_aemode)(curr_entry.data.u8[0] + 1);
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700232 ALOGV("DEBUG(%s): ANDROID_CONTROL_AE_MODE (%d)", __FUNCTION__, dst->ctl.aa.aeMode);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700233 break;
234
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700235
236 case ANDROID_CONTROL_AE_EXP_COMPENSATION:
237 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 1))
238 break;
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700239 dst->ctl.aa.aeExpCompensation = curr_entry.data.i32[0] + 5;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700240 break;
241
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700242 case ANDROID_CONTROL_AWB_MODE:
243 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
244 break;
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700245 dst->ctl.aa.awbMode = (enum aa_awbmode)(curr_entry.data.u8[0] + 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700246 break;
247
248 case ANDROID_CONTROL_AWB_REGIONS:
249 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 5))
250 break;
251 for (i=0 ; i<curr_entry.count ; i++)
252 dst->ctl.aa.awbRegions[i] = curr_entry.data.i32[i];
253 break;
254
255 case ANDROID_CONTROL_AF_MODE:
256 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
257 break;
Sungjoong Kang0f26b202012-08-17 15:43:12 -0700258 dst->ctl.aa.afMode = (enum aa_afmode)(curr_entry.data.u8[0] + 1);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700259 break;
260
261 case ANDROID_CONTROL_AF_REGIONS:
262 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 5))
263 break;
264 for (i=0 ; i<curr_entry.count ; i++)
265 dst->ctl.aa.afRegions[i] = curr_entry.data.i32[i];
266 break;
267
268
269
270 case ANDROID_REQUEST_ID:
271 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 1))
272 break;
273 dst->ctl.request.id = curr_entry.data.i32[0];
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900274 ALOGV("DEBUG(%s): ANDROID_REQUEST_ID (%d)", __FUNCTION__, dst->ctl.request.id);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700275 break;
276
277 case ANDROID_REQUEST_METADATA_MODE:
278 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
279 break;
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700280 dst->ctl.request.metadataMode = (enum metadata_mode)curr_entry.data.u8[0];
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900281 ALOGV("DEBUG(%s): ANDROID_REQUEST_METADATA_MODE (%d)", __FUNCTION__, (int)( dst->ctl.request.metadataMode));
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700282 break;
283
284 case ANDROID_REQUEST_OUTPUT_STREAMS:
285 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE))
286 break;
Sungjoong Kangad378612012-08-17 12:34:33 -0700287
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900288 for (i=0 ; i<curr_entry.count ; i++) {
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700289 dst->ctl.request.outputStreams[i] = curr_entry.data.u8[i];
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900290 ALOGV("DEBUG(%s): OUTPUT_STREAM[%d] = %d ", __FUNCTION__, i, (int)(dst->ctl.request.outputStreams[i]));
291 }
Sungjoong Kangad378612012-08-17 12:34:33 -0700292
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700293 dst->ctl.request.outputStreams[15] = curr_entry.count;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700294 break;
295
296 case ANDROID_REQUEST_FRAME_COUNT:
297 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_INT32, 1))
298 break;
299 dst->ctl.request.frameCount = curr_entry.data.i32[0];
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900300 ALOGV("DEBUG(%s): ANDROID_REQUEST_FRAME_COUNT (%d)", __FUNCTION__, dst->ctl.request.frameCount);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700301 break;
302
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700303 case ANDROID_CONTROL_SCENE_MODE:
304 if (NO_ERROR != CheckEntryTypeMismatch(&curr_entry, TYPE_BYTE, 1))
305 break;
306 dst->ctl.aa.sceneMode = (enum aa_scene_mode)(curr_entry.data.u8[0] + 1);
307 ALOGV("DEBUG(%s): converted ANDROID_CONTROL_SCENE_MODE (%d)", __FUNCTION__, dst->ctl.aa.sceneMode);
308 break;
309
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700310 default:
Sungjoong Kangad378612012-08-17 12:34:33 -0700311 ALOGV("DEBUG(%s):Bad Metadata tag (%d)", __FUNCTION__, curr_entry.tag);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700312 break;
313 }
314 }
315 }
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700316 if (dst->ctl.aa.mode != ANDROID_CONTROL_USE_SCENE_MODE)
317 dst->ctl.aa.sceneMode = AA_SCENE_MODE_UNSUPPORTED;
318 ApplySceneModeParameters(request, dst_ext);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700319 return NO_ERROR;
320}
321
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700322status_t MetadataConverter::ApplySceneModeParameters(camera_metadata_t * request, struct camera2_shot_ext * dst_ext)
323{
324 camera_metadata_entry_t curr_entry;
325 struct camera2_shot * dst = NULL;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700326
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700327 ALOGV("DEBUG(%s):", __FUNCTION__);
328
329 dst = &(dst_ext->shot);
330
331 switch (dst->ctl.aa.sceneMode) {
332
333 case AA_SCENE_MODE_ACTION:
334 dst->ctl.aa.mode = AA_CONTROL_USE_SCENE_MODE;
335 if (dst->ctl.aa.aeMode != AA_AEMODE_LOCKED)
336 dst->ctl.aa.aeMode = AA_AEMODE_ON;
337 dst->ctl.aa.awbMode = AA_AWBMODE_WB_AUTO;
338 dst->ctl.aa.isoMode = AA_ISOMODE_AUTO;
339 dst->ctl.aa.isoValue = 0;
340 dst->ctl.aa.aeTargetFpsRange[0] = 30;
341 dst->ctl.aa.aeTargetFpsRange[1] = 30;
342
343 dst->ctl.noise.mode = PROCESSING_MODE_FAST;
344 dst->ctl.noise.strength = 0;
345 dst->ctl.edge.mode = PROCESSING_MODE_FAST;
346 dst->ctl.edge.strength = 0;
347
348 dst->ctl.color.saturation = 3; // means '0'
349 // FLASH
350 // METERING
351 break;
352
353 case AA_SCENE_MODE_PARTY:
354 dst->ctl.aa.mode = AA_CONTROL_USE_SCENE_MODE;
355 if (dst->ctl.aa.aeMode != AA_AEMODE_LOCKED)
356 dst->ctl.aa.aeMode = AA_AEMODE_ON;
357 dst->ctl.aa.awbMode = AA_AWBMODE_WB_AUTO;
358 dst->ctl.aa.isoMode = AA_ISOMODE_MANUAL;
359 dst->ctl.aa.isoValue = 200;
360 dst->ctl.aa.aeTargetFpsRange[0] = 15;
361 dst->ctl.aa.aeTargetFpsRange[1] = 30;
362
363 dst->ctl.noise.mode = PROCESSING_MODE_FAST;
364 dst->ctl.noise.strength = 0;
365 dst->ctl.edge.mode = PROCESSING_MODE_FAST;
366 dst->ctl.edge.strength = 0;
367
368 dst->ctl.color.saturation = 4; // means '+1'
369 // FLASH
370 // METERING
371 break;
372
373 case AA_SCENE_MODE_SUNSET:
374 dst->ctl.aa.mode = AA_CONTROL_USE_SCENE_MODE;
375 if (dst->ctl.aa.aeMode != AA_AEMODE_LOCKED)
376 dst->ctl.aa.aeMode = AA_AEMODE_ON;
377 dst->ctl.aa.awbMode = AA_AWBMODE_WB_DAYLIGHT;
378 dst->ctl.aa.isoMode = AA_ISOMODE_AUTO;
379 dst->ctl.aa.isoValue = 0;
380 dst->ctl.aa.aeTargetFpsRange[0] = 15;
381 dst->ctl.aa.aeTargetFpsRange[1] = 30;
382
383 dst->ctl.noise.mode = PROCESSING_MODE_FAST;
384 dst->ctl.noise.strength = 0;
385 dst->ctl.edge.mode = PROCESSING_MODE_FAST;
386 dst->ctl.edge.strength = 0;
387
388 dst->ctl.color.saturation = 3; // means '0'
389 // FLASH
390 // METERING
391 break;
392
393 case AA_SCENE_MODE_NIGHT:
394 dst->ctl.aa.mode = AA_CONTROL_USE_SCENE_MODE;
395 if (dst->ctl.aa.aeMode != AA_AEMODE_LOCKED)
396 dst->ctl.aa.aeMode = AA_AEMODE_ON;
397 dst->ctl.aa.awbMode = AA_AWBMODE_WB_AUTO;
398 dst->ctl.aa.isoMode = AA_ISOMODE_AUTO;
399 dst->ctl.aa.isoValue = 0;
400 dst->ctl.aa.aeTargetFpsRange[0] = 2;
401 dst->ctl.aa.aeTargetFpsRange[1] = 30;
402
403 dst->ctl.noise.mode = PROCESSING_MODE_FAST;
404 dst->ctl.noise.strength = 0;
405 dst->ctl.edge.mode = PROCESSING_MODE_FAST;
406 dst->ctl.edge.strength = 0;
407
408 dst->ctl.color.saturation = 3; // means '0'
409 // FLASH
410 // METERING
411 break;
412
413 default:
414 dst->ctl.aa.mode = AA_CONTROL_AUTO;
415 if (dst->ctl.aa.aeMode != AA_AEMODE_LOCKED)
416 dst->ctl.aa.aeMode = AA_AEMODE_ON;
417 dst->ctl.aa.sceneMode = AA_SCENE_MODE_UNSUPPORTED;
418 dst->ctl.aa.isoMode = AA_ISOMODE_AUTO;
419 dst->ctl.aa.isoValue = 0;
420 dst->ctl.noise.mode = PROCESSING_MODE_OFF;
421 dst->ctl.noise.strength = 0;
422 dst->ctl.edge.mode = PROCESSING_MODE_OFF;
423 dst->ctl.edge.strength = 0;
424 dst->ctl.color.saturation = 3; // means '0'
425 break;
426 }
427
428 return NO_ERROR;
429}
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700430
431
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700432status_t MetadataConverter::ToDynamicMetadata(struct camera2_shot_ext * metadata_ext, camera_metadata_t * dst)
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700433{
434 status_t res;
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700435 struct camera2_shot * metadata = &metadata_ext->shot;
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700436 uint8_t byteData;
437 uint32_t intData;
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700438
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700439 if (0 != add_camera_metadata_entry(dst, ANDROID_REQUEST_ID,
440 &(metadata->ctl.request.id), 1))
441 return NO_MEMORY;
442
443 if (0 != add_camera_metadata_entry(dst, ANDROID_REQUEST_METADATA_MODE,
444 &(metadata->ctl.request.metadataMode), 1))
445 return NO_MEMORY;
446
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700447 if (0 != add_camera_metadata_entry(dst, ANDROID_REQUEST_FRAME_COUNT,
448 &(metadata->ctl.request.frameCount), 1))
449 return NO_MEMORY;
450
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700451 if (0 != add_camera_metadata_entry(dst, ANDROID_SENSOR_TIMESTAMP,
452 &metadata->dm.sensor.timeStamp, 1))
453 return NO_MEMORY;
454
455 if (0 != add_camera_metadata_entry(dst, ANDROID_SENSOR_EXPOSURE_TIME,
456 &metadata->dm.sensor.exposureTime, 1))
457 return NO_MEMORY;
458
459 if (0 != add_camera_metadata_entry(dst, ANDROID_LENS_APERTURE,
460 &metadata->dm.lens.aperture, 1))
461 return NO_MEMORY;
462
463 ALOGV("(%s): ID(%d) METAMODE(%d) FrameCnt(%d) Timestamp(%lld) exposure(%lld) aper(%f)", __FUNCTION__,
464 metadata->ctl.request.id, metadata->ctl.request.metadataMode, metadata->ctl.request.frameCount,
465 metadata->dm.sensor.timeStamp, metadata->dm.sensor.exposureTime, metadata->dm.lens.aperture);
466
467
468 byteData = metadata->dm.aa.awbMode - 1;
469 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AWB_MODE,
470 &byteData, 1))
471 return NO_MEMORY;
472
473 byteData = metadata->dm.aa.aeMode - 1;
474 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AE_MODE,
475 &byteData, 1))
476 return NO_MEMORY;
477
478 byteData = metadata->ctl.aa.sceneMode - 1;
479 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_SCENE_MODE,
480 &byteData, 1))
481 return NO_MEMORY;
482
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700483 intData = metadata->ctl.aa.aeExpCompensation;
484 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AE_EXP_COMPENSATION,
485 &intData, 1))
486 return NO_MEMORY;
487
Sungjoong Kang15fd8232012-08-23 16:16:44 -0700488 byteData = ANDROID_STATS_FACE_DETECTION_OFF;
489 if (0 != add_camera_metadata_entry(dst, ANDROID_STATS_FACE_DETECT_MODE,
490 &byteData, 1))
491 return NO_MEMORY;
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700492
Sungjoong Kangad378612012-08-17 12:34:33 -0700493 ALOGV("(%s): AWB(%d) AE(%d) SCENE(%d) AEComp(%d)", __FUNCTION__,
494 metadata->dm.aa.awbMode - 1, metadata->dm.aa.aeMode - 1, metadata->ctl.aa.sceneMode - 1,
495 metadata->ctl.aa.aeExpCompensation );
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700496
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700497
Sungjoong Kangbe494d12012-08-04 15:36:56 -0700498 if (metadata->ctl.request.metadataMode == METADATA_MODE_NONE) {
Sungjoong Kang13d8c7b2012-07-14 10:20:39 +0900499 ALOGV("DEBUG(%s): METADATA_MODE_NONE", __FUNCTION__);
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700500 return NO_ERROR;
501 }
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700502 return NO_ERROR;
503
504
505}
506
507#if 0 // blocked for alpha version
508
509status_t MetadataConverter::ToDynamicMetadata(camera2_ctl_metadata_t * metadata, camera_metadata_t * dst)
510{
511 status_t res;
512
513 if (0 != add_camera_metadata_entry(dst, ANDROID_REQUEST_ID,
514 &(metadata->dm.request.id), 1))
515 return NO_MEMORY;
516
517 if (0 != add_camera_metadata_entry(dst, ANDROID_REQUEST_METADATA_MODE,
518 &(metadata->dm.request.metadataMode), 1))
519 return NO_MEMORY;
520
521 // needs check!
522 if (0 != add_camera_metadata_entry(dst, ANDROID_REQUEST_FRAME_COUNT,
523 &(metadata->dm.request.frameCount), 1))
524 return NO_MEMORY;
525
526
527 if (metadata->dm.request.metadataMode == METADATA_MODE_NONE) {
528 ALOGD("DEBUG(%s): METADATA_MODE_NONE", __func__);
529 return NO_ERROR;
530 }
531
532 ALOGD("DEBUG(%s): METADATA_MODE_FULL", __func__);
533
534 if (0 != add_camera_metadata_entry(dst, ANDROID_LENS_FOCUS_DISTANCE,
535 &(metadata->dm.lens.focusDistance), 1))
536 return NO_MEMORY;
537
538 if (0 != add_camera_metadata_entry(dst, ANDROID_LENS_APERTURE,
539 &(metadata->dm.lens.aperture), 1))
540 return NO_MEMORY;
541
542 if (0 != add_camera_metadata_entry(dst, ANDROID_LENS_FOCAL_LENGTH,
543 &(metadata->dm.lens.focalLength), 1))
544 return NO_MEMORY;
545
546 if (0 != add_camera_metadata_entry(dst, ANDROID_LENS_FILTER_DENSITY,
547 &(metadata->dm.lens.filterDensity), 1))
548 return NO_MEMORY;
549
550 if (0 != add_camera_metadata_entry(dst, ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
551 &(metadata->dm.lens.opticalStabilizationMode), 1))
552 return NO_MEMORY;
553
554 if (0 != add_camera_metadata_entry(dst, ANDROID_LENS_APERTURE,
555 &(metadata->dm.lens.aperture), 1))
556 return NO_MEMORY;
557
558 if (0 != add_camera_metadata_entry(dst, ANDROID_LENS_FOCUS_RANGE,
559 &(metadata->dm.lens.focusRange[0]), 2))
560 return NO_MEMORY;
561
562
563
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700564
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700565
566 if (0 != add_camera_metadata_entry(dst, ANDROID_SENSOR_FRAME_DURATION,
567 &(metadata->dm.sensor.frameDuration), 1))
568 return NO_MEMORY;
569
570 if (0 != add_camera_metadata_entry(dst, ANDROID_SENSOR_SENSITIVITY,
Sungjoong Kang2bdec062012-08-17 15:47:56 -0700571 &(metadata->dm.aa.isoValue), 1))
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700572 return NO_MEMORY;
573
574 if (0 != add_camera_metadata_entry(dst, ANDROID_SENSOR_TIMESTAMP,
575 &(metadata->dm.sensor.timeStamp), 1))
576 return NO_MEMORY;
577
578
579
580 if (0 != add_camera_metadata_entry(dst, ANDROID_FLASH_MODE,
581 &(metadata->dm.flash.flashMode), 1))
582 return NO_MEMORY;
583
584 if (0 != add_camera_metadata_entry(dst, ANDROID_FLASH_FIRING_POWER,
585 &(metadata->dm.flash.firingPower), 1))
586 return NO_MEMORY;
587
588 if (0 != add_camera_metadata_entry(dst, ANDROID_FLASH_FIRING_TIME,
589 &(metadata->dm.flash.firingPower), 1))
590 return NO_MEMORY;
591
592
593
594 if (0 != add_camera_metadata_entry(dst, ANDROID_HOT_PIXEL_MODE,
595 &(metadata->dm.hotpixel.mode), 1))
596 return NO_MEMORY;
597
598
599
600 if (0 != add_camera_metadata_entry(dst, ANDROID_DEMOSAIC_MODE,
601 &(metadata->dm.demosaic.mode), 1))
602 return NO_MEMORY;
603
604
605
606 if (0 != add_camera_metadata_entry(dst, ANDROID_NOISE_MODE,
607 &(metadata->dm.noise.mode), 1))
608 return NO_MEMORY;
609
610 if (0 != add_camera_metadata_entry(dst, ANDROID_NOISE_STRENGTH,
611 &(metadata->dm.noise.strength), 1))
612 return NO_MEMORY;
613
614
615 if (0 != add_camera_metadata_entry(dst, ANDROID_SHADING_MODE,
616 &(metadata->dm.shading.mode), 1))
617 return NO_MEMORY;
618
619
620
621 if (0 != add_camera_metadata_entry(dst, ANDROID_GEOMETRIC_MODE,
622 &(metadata->dm.geometric.mode), 1))
623 return NO_MEMORY;
624
625
626
627 if (0 != add_camera_metadata_entry(dst, ANDROID_COLOR_MODE,
628 &(metadata->dm.color.mode), 1))
629 return NO_MEMORY;
630
631 if (0 != add_camera_metadata_entry(dst, ANDROID_COLOR_TRANSFORM,
632 &(metadata->dm.color.transform), 9))
633 return NO_MEMORY;
634
635
636
637 if (0 != add_camera_metadata_entry(dst, ANDROID_TONEMAP_MODE,
638 &(metadata->dm.tonemap.mode), 1))
639 return NO_MEMORY;
640
641 if (0 != add_camera_metadata_entry(dst, ANDROID_TONEMAP_CURVE_RED,
642 &(metadata->dm.tonemap.curveRed), 32))
643 return NO_MEMORY;
644
645 if (0 != add_camera_metadata_entry(dst, ANDROID_TONEMAP_CURVE_GREEN,
646 &(metadata->dm.tonemap.curveGreen), 32))
647 return NO_MEMORY;
648
649 if (0 != add_camera_metadata_entry(dst, ANDROID_TONEMAP_CURVE_BLUE,
650 &(metadata->dm.tonemap.curveBlue), 32))
651 return NO_MEMORY;
652
653
654
655 if (0 != add_camera_metadata_entry(dst, ANDROID_EDGE_MODE,
656 &(metadata->dm.edge.mode), 1))
657 return NO_MEMORY;
658
659 if (0 != add_camera_metadata_entry(dst, ANDROID_EDGE_STRENGTH,
660 &(metadata->dm.edge.strength), 1))
661 return NO_MEMORY;
662
663
664
665 if (0 != add_camera_metadata_entry(dst, ANDROID_SCALER_CROP_REGION,
666 &(metadata->dm.scaler.cropRegion), 3))
667 return NO_MEMORY;
668
669
670
671 if (0 != add_camera_metadata_entry(dst, ANDROID_JPEG_QUALITY,
672 &(metadata->dm.jpeg.quality), 1))
673 return NO_MEMORY;
674
675 if (0 != add_camera_metadata_entry(dst, ANDROID_JPEG_THUMBNAIL_SIZE,
676 &(metadata->dm.jpeg.thumbnailSize), 2))
677 return NO_MEMORY;
678
679 if (0 != add_camera_metadata_entry(dst, ANDROID_JPEG_THUMBNAIL_QUALITY,
680 &(metadata->dm.jpeg.thumbnailQuality), 1))
681 return NO_MEMORY;
682
683 if (0 != add_camera_metadata_entry(dst, ANDROID_JPEG_GPS_COORDINATES,
684 &(metadata->dm.jpeg.gpsCoordinates), 2)) // needs check
685 return NO_MEMORY;
686
687 if (0 != add_camera_metadata_entry(dst, ANDROID_JPEG_GPS_PROCESSING_METHOD,
688 &(metadata->dm.jpeg.gpsProcessingMethod), 32))
689 return NO_MEMORY;
690
691 if (0 != add_camera_metadata_entry(dst, ANDROID_JPEG_GPS_TIMESTAMP,
692 &(metadata->dm.jpeg.gpsTimestamp), 1))
693 return NO_MEMORY;
694
695 if (0 != add_camera_metadata_entry(dst, ANDROID_JPEG_ORIENTATION,
696 &(metadata->dm.jpeg.orientation), 1))
697 return NO_MEMORY;
698
699
700
701 if (0 != add_camera_metadata_entry(dst, ANDROID_STATS_FACE_DETECT_MODE,
702 &(metadata->dm.stats.faceDetectMode), 1))
703 return NO_MEMORY;
704
705 // TODO : more stat entries
706
707
708
709 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_MODE,
710 &(metadata->dm.aa.mode), 1))
711 return NO_MEMORY;
712
713 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_CAPTURE_INTENT,
714 &(metadata->dm.aa.captureIntent), 1))
715 return NO_MEMORY;
716
717 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_EFFECT_MODE,
718 &(metadata->dm.aa.effect_mode), 1))
719 return NO_MEMORY;
720
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700721
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700722
723 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AE_REGIONS,
724 &(metadata->dm.aa.aeRegions), 5))
725 return NO_MEMORY;
726
Sungjoong Kangb56dcc02012-08-08 13:38:09 -0700727
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700728
729 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AE_STATE,
730 &(metadata->dm.aa.aeState), 1))
731 return NO_MEMORY;
732
Jiyoung Shinc15a6b02012-06-05 01:08:14 -0700733
734 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AWB_REGIONS,
735 &(metadata->dm.aa.awbRegions), 5))
736 return NO_MEMORY;
737
738 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AWB_STATE,
739 &(metadata->dm.aa.awbState), 1))
740 return NO_MEMORY;
741
742 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AF_MODE,
743 &(metadata->dm.aa.afMode), 1))
744 return NO_MEMORY;
745
746 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AF_REGIONS,
747 &(metadata->dm.aa.afRegions), 5))
748 return NO_MEMORY;
749
750 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_AF_STATE,
751 &(metadata->dm.aa.afState), 1))
752 return NO_MEMORY;
753
754 if (0 != add_camera_metadata_entry(dst, ANDROID_CONTROL_VIDEO_STABILIZATION_MODE,
755 &(metadata->dm.aa.videoStabilizationMode), 1))
756 return NO_MEMORY;
757
758
759 return NO_ERROR;
760
761/*
762typedef struct camera2_dm {
763 camera2_request_dm_t request;
764 camera2_lens_dm_t lens;
765 camera2_sensor_dm_t sensor;
766 camera2_flash_dm_t flash;
767 camera2_hotpixel_dm_t hotpixel;
768 camera2_demosaic_dm_t demosaic;
769 camera2_noisereduction_dm_t noise;
770 camera2_shading_dm_t shading;
771 camera2_geometric_dm_t geometric;
772 camera2_colorcorrection_dm_t color;
773 camera2_tonemap_dm_t tonemap;
774 camera2_edge_dm_t edge;
775 camera2_scaler_dm_t scaler;
776 camera2_jpeg_dm_t jpeg;
777 camera2_stats_dm_t stats;
778 camera2_aa_dm_t aa;
779} camera2_dm_t;
780*/
781
782}
783#endif
784
785
786}; // namespace android