1 /* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30 #include <pthread.h>
31 #include "mm_jpeg_dbg.h"
32 #include "mm_jpeg.h"
33 #include <errno.h>
34 #include <math.h>
35
36
37 #define LOWER(a) ((a) & 0xFFFF)
38 #define UPPER(a) (((a)>>16) & 0xFFFF)
39 #define CHANGE_ENDIAN_16(a) ((0x00FF & ((a)>>8)) | (0xFF00 & ((a)<<8)))
40 #define ROUND(a) \
41 ((a >= 0) ? (uint32_t)(a + 0.5) : (uint32_t)(a - 0.5))
42
43
44 /** addExifEntry:
45 *
46 * Arguments:
47 * @exif_info : Exif info struct
48 * @p_session: job session
49 * @tagid : exif tag ID
50 * @type : data type
51 * @count : number of data in uint of its type
52 * @data : input data ptr
53 *
54 * Retrun : int32_t type of status
55 * 0 -- success
56 * none-zero failure code
57 *
58 * Description:
59 * Function to add an entry to exif data
60 *
61 **/
addExifEntry(QOMX_EXIF_INFO * p_exif_info,exif_tag_id_t tagid,exif_tag_type_t type,uint32_t count,void * data)62 int32_t addExifEntry(QOMX_EXIF_INFO *p_exif_info, exif_tag_id_t tagid,
63 exif_tag_type_t type, uint32_t count, void *data)
64 {
65 int32_t rc = 0;
66 uint32_t numOfEntries = (uint32_t)p_exif_info->numOfEntries;
67 QEXIF_INFO_DATA *p_info_data = p_exif_info->exif_data;
68 if(numOfEntries >= MAX_EXIF_TABLE_ENTRIES) {
69 ALOGE("%s: Number of entries exceeded limit", __func__);
70 return -1;
71 }
72
73 p_info_data[numOfEntries].tag_id = tagid;
74 p_info_data[numOfEntries].tag_entry.type = type;
75 p_info_data[numOfEntries].tag_entry.count = count;
76 p_info_data[numOfEntries].tag_entry.copy = 1;
77 switch (type) {
78 case EXIF_BYTE: {
79 if (count > 1) {
80 uint8_t *values = (uint8_t *)malloc(count);
81 if (values == NULL) {
82 ALOGE("%s: No memory for byte array", __func__);
83 rc = -1;
84 } else {
85 memcpy(values, data, count);
86 p_info_data[numOfEntries].tag_entry.data._bytes = values;
87 }
88 } else {
89 p_info_data[numOfEntries].tag_entry.data._byte = *(uint8_t *)data;
90 }
91 }
92 break;
93 case EXIF_ASCII: {
94 char *str = NULL;
95 str = (char *)malloc(count + 1);
96 if (str == NULL) {
97 ALOGE("%s: No memory for ascii string", __func__);
98 rc = -1;
99 } else {
100 memset(str, 0, count + 1);
101 memcpy(str, data, count);
102 p_info_data[numOfEntries].tag_entry.data._ascii = str;
103 }
104 }
105 break;
106 case EXIF_SHORT: {
107 if (count > 1) {
108 uint16_t *values = (uint16_t *)malloc(count * sizeof(uint16_t));
109 if (values == NULL) {
110 ALOGE("%s: No memory for short array", __func__);
111 rc = -1;
112 } else {
113 memcpy(values, data, count * sizeof(uint16_t));
114 p_info_data[numOfEntries].tag_entry.data._shorts = values;
115 }
116 } else {
117 p_info_data[numOfEntries].tag_entry.data._short = *(uint16_t *)data;
118 }
119 }
120 break;
121 case EXIF_LONG: {
122 if (count > 1) {
123 uint32_t *values = (uint32_t *)malloc(count * sizeof(uint32_t));
124 if (values == NULL) {
125 ALOGE("%s: No memory for long array", __func__);
126 rc = -1;
127 } else {
128 memcpy(values, data, count * sizeof(uint32_t));
129 p_info_data[numOfEntries].tag_entry.data._longs = values;
130 }
131 } else {
132 p_info_data[numOfEntries].tag_entry.data._long = *(uint32_t *)data;
133 }
134 }
135 break;
136 case EXIF_RATIONAL: {
137 if (count > 1) {
138 rat_t *values = (rat_t *)malloc(count * sizeof(rat_t));
139 if (values == NULL) {
140 ALOGE("%s: No memory for rational array", __func__);
141 rc = -1;
142 } else {
143 memcpy(values, data, count * sizeof(rat_t));
144 p_info_data[numOfEntries].tag_entry.data._rats = values;
145 }
146 } else {
147 p_info_data[numOfEntries].tag_entry.data._rat = *(rat_t *)data;
148 }
149 }
150 break;
151 case EXIF_UNDEFINED: {
152 uint8_t *values = (uint8_t *)malloc(count);
153 if (values == NULL) {
154 ALOGE("%s: No memory for undefined array", __func__);
155 rc = -1;
156 } else {
157 memcpy(values, data, count);
158 p_info_data[numOfEntries].tag_entry.data._undefined = values;
159 }
160 }
161 break;
162 case EXIF_SLONG: {
163 if (count > 1) {
164 int32_t *values = (int32_t *)malloc(count * sizeof(int32_t));
165 if (values == NULL) {
166 ALOGE("%s: No memory for signed long array", __func__);
167 rc = -1;
168 } else {
169 memcpy(values, data, count * sizeof(int32_t));
170 p_info_data[numOfEntries].tag_entry.data._slongs = values;
171 }
172 } else {
173 p_info_data[numOfEntries].tag_entry.data._slong = *(int32_t *)data;
174 }
175 }
176 break;
177 case EXIF_SRATIONAL: {
178 if (count > 1) {
179 srat_t *values = (srat_t *)malloc(count * sizeof(srat_t));
180 if (values == NULL) {
181 ALOGE("%s: No memory for signed rational array", __func__);
182 rc = -1;
183 } else {
184 memcpy(values, data, count * sizeof(srat_t));
185 p_info_data[numOfEntries].tag_entry.data._srats = values;
186 }
187 } else {
188 p_info_data[numOfEntries].tag_entry.data._srat = *(srat_t *)data;
189 }
190 }
191 break;
192 }
193
194 // Increase number of entries
195 p_exif_info->numOfEntries++;
196 return rc;
197 }
198
199 /** releaseExifEntry
200 *
201 * Arguments:
202 * @p_exif_data : Exif info struct
203 *
204 * Retrun : int32_t type of status
205 * 0 -- success
206 * none-zero failure code
207 *
208 * Description:
209 * Function to release an entry from exif data
210 *
211 **/
releaseExifEntry(QEXIF_INFO_DATA * p_exif_data)212 int32_t releaseExifEntry(QEXIF_INFO_DATA *p_exif_data)
213 {
214 switch (p_exif_data->tag_entry.type) {
215 case EXIF_BYTE: {
216 if (p_exif_data->tag_entry.count > 1 &&
217 p_exif_data->tag_entry.data._bytes != NULL) {
218 free(p_exif_data->tag_entry.data._bytes);
219 p_exif_data->tag_entry.data._bytes = NULL;
220 }
221 }
222 break;
223 case EXIF_ASCII: {
224 if (p_exif_data->tag_entry.data._ascii != NULL) {
225 free(p_exif_data->tag_entry.data._ascii);
226 p_exif_data->tag_entry.data._ascii = NULL;
227 }
228 }
229 break;
230 case EXIF_SHORT: {
231 if (p_exif_data->tag_entry.count > 1 &&
232 p_exif_data->tag_entry.data._shorts != NULL) {
233 free(p_exif_data->tag_entry.data._shorts);
234 p_exif_data->tag_entry.data._shorts = NULL;
235 }
236 }
237 break;
238 case EXIF_LONG: {
239 if (p_exif_data->tag_entry.count > 1 &&
240 p_exif_data->tag_entry.data._longs != NULL) {
241 free(p_exif_data->tag_entry.data._longs);
242 p_exif_data->tag_entry.data._longs = NULL;
243 }
244 }
245 break;
246 case EXIF_RATIONAL: {
247 if (p_exif_data->tag_entry.count > 1 &&
248 p_exif_data->tag_entry.data._rats != NULL) {
249 free(p_exif_data->tag_entry.data._rats);
250 p_exif_data->tag_entry.data._rats = NULL;
251 }
252 }
253 break;
254 case EXIF_UNDEFINED: {
255 if (p_exif_data->tag_entry.data._undefined != NULL) {
256 free(p_exif_data->tag_entry.data._undefined);
257 p_exif_data->tag_entry.data._undefined = NULL;
258 }
259 }
260 break;
261 case EXIF_SLONG: {
262 if (p_exif_data->tag_entry.count > 1 &&
263 p_exif_data->tag_entry.data._slongs != NULL) {
264 free(p_exif_data->tag_entry.data._slongs);
265 p_exif_data->tag_entry.data._slongs = NULL;
266 }
267 }
268 break;
269 case EXIF_SRATIONAL: {
270 if (p_exif_data->tag_entry.count > 1 &&
271 p_exif_data->tag_entry.data._srats != NULL) {
272 free(p_exif_data->tag_entry.data._srats);
273 p_exif_data->tag_entry.data._srats = NULL;
274 }
275 }
276 break;
277 } /*end of switch*/
278
279 return 0;
280 }
281
282 /** process_sensor_data:
283 *
284 * Arguments:
285 * @p_sensor_params : ptr to sensor data
286 *
287 * Return : int32_t type of status
288 * NO_ERROR -- success
289 * none-zero failure code
290 *
291 * Description:
292 * process sensor data
293 *
294 * Notes: this needs to be filled for the metadata
295 **/
process_sensor_data(cam_sensor_params_t * p_sensor_params,QOMX_EXIF_INFO * exif_info)296 int process_sensor_data(cam_sensor_params_t *p_sensor_params,
297 QOMX_EXIF_INFO *exif_info)
298 {
299 int rc = 0;
300 rat_t val_rat;
301
302 if (NULL == p_sensor_params) {
303 ALOGE("%s %d: Sensor params are null", __func__, __LINE__);
304 return 0;
305 }
306
307 CDBG("%s:%d] From metadata aperture = %f ", __func__, __LINE__,
308 p_sensor_params->aperture_value );
309
310 if (p_sensor_params->aperture_value >= 1.0) {
311 double apex_value;
312 apex_value = (double)2.0 * log(p_sensor_params->aperture_value) / log(2.0);
313 val_rat.num = (uint32_t)(apex_value * 100);
314 val_rat.denom = 100;
315 rc = addExifEntry(exif_info, EXIFTAGID_APERTURE, EXIF_RATIONAL, 1, &val_rat);
316 if (rc) {
317 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
318 }
319
320 val_rat.num = (uint32_t)(p_sensor_params->aperture_value * 100);
321 val_rat.denom = 100;
322 rc = addExifEntry(exif_info, EXIFTAGID_F_NUMBER, EXIF_RATIONAL, 1, &val_rat);
323 if (rc) {
324 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
325 }
326 }
327
328 /*Flash*/
329 short val_short;
330 int flash_mode_exif, flash_fired;
331 if (p_sensor_params->flash_state == CAM_FLASH_STATE_FIRED) {
332 flash_fired = 1;
333 } else {
334 flash_fired = 0;
335 }
336 CDBG("%s: Flash value %d flash mode %d flash state %d", __func__, val_short,
337 p_sensor_params->flash_mode, p_sensor_params->flash_state);
338
339 switch(p_sensor_params->flash_mode) {
340 case CAM_FLASH_MODE_OFF:
341 flash_mode_exif = MM_JPEG_EXIF_FLASH_MODE_OFF;
342 break;
343 case CAM_FLASH_MODE_ON:
344 flash_mode_exif = MM_JPEG_EXIF_FLASH_MODE_ON;
345 break;
346 case CAM_FLASH_MODE_AUTO:
347 flash_mode_exif = MM_JPEG_EXIF_FLASH_MODE_AUTO;
348 break;
349 default:
350 flash_mode_exif = MM_JPEG_EXIF_FLASH_MODE_AUTO;
351 ALOGE("%s:%d]: Unsupported flash mode", __func__, __LINE__);
352 }
353 val_short = (short)(flash_fired | (flash_mode_exif << 3));
354
355 rc = addExifEntry(exif_info, EXIFTAGID_FLASH, EXIF_SHORT, 1, &val_short);
356 if (rc) {
357 ALOGE("%s %d]: Error adding flash exif entry", __func__, __LINE__);
358 }
359 /* Sensing Method */
360 val_short = (short) p_sensor_params->sensing_method;
361 rc = addExifEntry(exif_info, EXIFTAGID_SENSING_METHOD, EXIF_SHORT,
362 sizeof(val_short)/2, &val_short);
363 if (rc) {
364 ALOGE("%s:%d]: Error adding flash Exif Entry", __func__, __LINE__);
365 }
366
367 /* Focal Length in 35 MM Film */
368 val_short = (short)
369 ((p_sensor_params->focal_length * p_sensor_params->crop_factor) + 0.5f);
370 rc = addExifEntry(exif_info, EXIFTAGID_FOCAL_LENGTH_35MM, EXIF_SHORT,
371 1, &val_short);
372 if (rc) {
373 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
374 }
375
376 /* F Number */
377 val_rat.num = (uint32_t)(p_sensor_params->f_number * 100);
378 val_rat.denom = 100;
379 rc = addExifEntry(exif_info, EXIFTAGTYPE_F_NUMBER, EXIF_RATIONAL, 1, &val_rat);
380 if (rc) {
381 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
382 }
383 return rc;
384 }
385
386
387 /** process_3a_data:
388 *
389 * Arguments:
390 * @p_3a_params : ptr to 3a data
391 *
392 * Return : int32_t type of status
393 * NO_ERROR -- success
394 * none-zero failure code
395 *
396 * Description:
397 * process 3a data
398 *
399 * Notes: this needs to be filled for the metadata
400 **/
process_3a_data(cam_3a_params_t * p_3a_params,QOMX_EXIF_INFO * exif_info)401 int process_3a_data(cam_3a_params_t *p_3a_params, QOMX_EXIF_INFO *exif_info)
402 {
403 int rc = 0;
404 srat_t val_srat;
405 rat_t val_rat;
406 double shutter_speed_value;
407
408 if (NULL == p_3a_params) {
409 ALOGE("%s %d: 3A params are null", __func__, __LINE__);
410 return 0;
411 }
412
413 CDBG("%s:%d] exp_time %f, iso_value %d, wb_mode %d", __func__, __LINE__,
414 p_3a_params->exp_time, p_3a_params->iso_value, p_3a_params->wb_mode);
415
416 /*Exposure time*/
417 if (0.0f >= p_3a_params->exp_time) {
418 val_rat.num = 0;
419 val_rat.denom = 0;
420 } else {
421 val_rat.num = 1;
422 val_rat.denom = ROUND(1.0/p_3a_params->exp_time);
423 }
424 CDBG("%s: numer %d denom %d %zd", __func__, val_rat.num, val_rat.denom,
425 sizeof(val_rat) / (8));
426
427 rc = addExifEntry(exif_info, EXIFTAGID_EXPOSURE_TIME, EXIF_RATIONAL,
428 (sizeof(val_rat)/(8)), &val_rat);
429 if (rc) {
430 ALOGE("%s:%d]: Error adding Exif Entry Exposure time",
431 __func__, __LINE__);
432 }
433
434 /* Shutter Speed*/
435 if (p_3a_params->exp_time > 0) {
436 shutter_speed_value = log10(1/p_3a_params->exp_time)/log10(2);
437 val_srat.num = (int32_t)(shutter_speed_value * 1000);
438 val_srat.denom = 1000;
439 } else {
440 val_srat.num = 0;
441 val_srat.denom = 0;
442 }
443 rc = addExifEntry(exif_info, EXIFTAGID_SHUTTER_SPEED, EXIF_SRATIONAL,
444 (sizeof(val_srat)/(8)), &val_srat);
445 if (rc) {
446 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
447 }
448
449 /*ISO*/
450 short val_short;
451 val_short = (short)p_3a_params->iso_value;
452 rc = addExifEntry(exif_info, EXIFTAGID_ISO_SPEED_RATING, EXIF_SHORT,
453 sizeof(val_short)/2, &val_short);
454 if (rc) {
455 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
456 }
457
458 /*WB mode*/
459 if (p_3a_params->wb_mode == CAM_WB_MODE_AUTO)
460 val_short = 0;
461 else
462 val_short = 1;
463 rc = addExifEntry(exif_info, EXIFTAGID_WHITE_BALANCE, EXIF_SHORT,
464 sizeof(val_short)/2, &val_short);
465 if (rc) {
466 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
467 }
468
469 /* Metering Mode */
470 val_short = (short) p_3a_params->metering_mode;
471 rc = addExifEntry(exif_info,EXIFTAGID_METERING_MODE, EXIF_SHORT,
472 sizeof(val_short)/2, &val_short);
473 if (rc) {
474 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
475 }
476
477 /*Exposure Program*/
478 val_short = (short) p_3a_params->exposure_program;
479 rc = addExifEntry(exif_info,EXIFTAGID_EXPOSURE_PROGRAM, EXIF_SHORT,
480 sizeof(val_short)/2, &val_short);
481 if (rc) {
482 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
483 }
484
485 /*Exposure Mode */
486 val_short = (short) p_3a_params->exposure_mode;
487 rc = addExifEntry(exif_info,EXIFTAGID_EXPOSURE_MODE, EXIF_SHORT,
488 sizeof(val_short)/2, &val_short);
489 if (rc) {
490 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
491 }
492
493 /*Scenetype*/
494 uint8_t val_undef;
495 val_undef = (uint8_t) p_3a_params->scenetype;
496 rc = addExifEntry(exif_info,EXIFTAGID_SCENE_TYPE, EXIF_UNDEFINED,
497 sizeof(val_undef), &val_undef);
498 if (rc) {
499 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
500 }
501
502 CDBG("%s:%d] brightness %f", __func__, __LINE__,
503 p_3a_params->brightness);
504
505 /* Brightness Value*/
506 val_srat.num = (int32_t) (p_3a_params->brightness * 100.0f);
507 val_srat.denom = 100;
508 rc = addExifEntry(exif_info,EXIFTAGID_BRIGHTNESS, EXIF_SRATIONAL,
509 (sizeof(val_srat)/(8)), &val_srat);
510 if (rc) {
511 ALOGE("%s:%d]: Error adding Exif Entry", __func__, __LINE__);
512 }
513
514 return rc;
515 }
516
517 /** process_meta_data
518 *
519 * Arguments:
520 * @p_meta : ptr to metadata
521 * @exif_info: Exif info struct
522 * @mm_jpeg_exif_params: exif params
523 *
524 * Return : int32_t type of status
525 * NO_ERROR -- success
526 * none-zero failure code
527 *
528 * Description:
529 * Extract exif data from the metadata
530 **/
process_meta_data(metadata_buffer_t * p_meta,QOMX_EXIF_INFO * exif_info,mm_jpeg_exif_params_t * p_cam_exif_params,cam_hal_version_t hal_version)531 int process_meta_data(metadata_buffer_t *p_meta, QOMX_EXIF_INFO *exif_info,
532 mm_jpeg_exif_params_t *p_cam_exif_params, cam_hal_version_t hal_version)
533 {
534 int rc = 0;
535 cam_sensor_params_t p_sensor_params;
536 cam_3a_params_t p_3a_params;
537
538 memset(&p_3a_params, 0, sizeof(cam_3a_params_t));
539 memset(&p_sensor_params, 0, sizeof(cam_sensor_params_t));
540
541 if (hal_version == CAM_HAL_V1) {
542 IF_META_AVAILABLE(cam_3a_params_t, l_3a_params, CAM_INTF_META_AEC_INFO,
543 p_meta) {
544 p_3a_params = *l_3a_params;
545 } else if (p_cam_exif_params) {
546 p_3a_params = p_cam_exif_params->cam_3a_params;
547 } else {
548 p_3a_params.exp_time = 0.0;
549 p_3a_params.iso_value = 0;
550 p_3a_params.metering_mode = CAM_METERING_MODE_UNKNOWN;
551 p_3a_params.exposure_program = 0;
552 p_3a_params.exposure_mode = 255;
553 p_3a_params.scenetype = 1;
554 p_3a_params.brightness = 0.0;
555 }
556
557 IF_META_AVAILABLE(int32_t, wb_mode, CAM_INTF_PARM_WHITE_BALANCE, p_meta) {
558 p_3a_params.wb_mode = *wb_mode;
559 }
560
561 IF_META_AVAILABLE(cam_sensor_params_t, l_sensor_params,
562 CAM_INTF_META_SENSOR_INFO, p_meta) {
563 p_sensor_params = *l_sensor_params;
564 } else if (p_cam_exif_params) {
565 p_sensor_params = p_cam_exif_params->sensor_params;
566 } else {
567 p_sensor_params.focal_length = 0;
568 p_sensor_params.f_number = 0;
569 p_sensor_params.sensing_method = 2;
570 p_sensor_params.crop_factor = 0;
571 }
572 } else {
573
574 /* Process 3a data */
575 IF_META_AVAILABLE(int32_t, iso, CAM_INTF_META_SENSOR_SENSITIVITY, p_meta) {
576 p_3a_params.iso_value= *iso;
577 } else {
578 ALOGE("%s: Cannot extract Iso value", __func__);
579 }
580
581 IF_META_AVAILABLE(int64_t, sensor_exposure_time,
582 CAM_INTF_META_SENSOR_EXPOSURE_TIME, p_meta) {
583 p_3a_params.exp_time =
584 (float)((double)(*sensor_exposure_time) / 1000000000.0);
585 } else {
586 ALOGE("%s: Cannot extract Exp time value", __func__);
587 }
588
589 IF_META_AVAILABLE(int32_t, wb_mode, CAM_INTF_PARM_WHITE_BALANCE, p_meta) {
590 p_3a_params.wb_mode = *wb_mode;
591 } else {
592 ALOGE("%s: Cannot extract white balance mode", __func__);
593 }
594
595 /* Process sensor data */
596 IF_META_AVAILABLE(float, aperture, CAM_INTF_META_LENS_APERTURE, p_meta) {
597 p_sensor_params.aperture_value = *aperture;
598 } else {
599 ALOGE("%s: Cannot extract Aperture value", __func__);
600 }
601
602 IF_META_AVAILABLE(uint32_t, flash_mode, CAM_INTF_META_FLASH_MODE, p_meta) {
603 p_sensor_params.flash_mode = *flash_mode;
604 } else {
605 ALOGE("%s: Cannot extract flash mode value", __func__);
606 }
607
608 IF_META_AVAILABLE(int32_t, flash_state, CAM_INTF_META_FLASH_STATE, p_meta) {
609 p_sensor_params.flash_state = (cam_flash_state_t) *flash_state;
610 } else {
611 ALOGE("%s: Cannot extract flash state value", __func__);
612 }
613 }
614 if ((hal_version != CAM_HAL_V1) || (p_sensor_params.sens_type != CAM_SENSOR_YUV)) {
615 rc = process_3a_data(&p_3a_params, exif_info);
616 if (rc) {
617 ALOGE("%s %d: Failed to add 3a exif params", __func__, __LINE__);
618 }
619 }
620
621 rc = process_sensor_data(&p_sensor_params, exif_info);
622 if (rc) {
623 ALOGE("%s %d: Failed to extract sensor params", __func__, __LINE__);
624 }
625
626 if (p_meta) {
627 short val_short = 0;
628
629 IF_META_AVAILABLE(cam_auto_scene_t, scene_cap_type,
630 CAM_INTF_META_ASD_SCENE_CAPTURE_TYPE, p_meta) {
631 val_short = (short) *scene_cap_type;
632 }
633
634 rc = addExifEntry(exif_info, EXIFTAGID_SCENE_CAPTURE_TYPE, EXIF_SHORT,
635 sizeof(val_short)/2, &val_short);
636 if (rc) {
637 ALOGE("%s:%d]: Error adding ASD Exif Entry", __func__, __LINE__);
638 }
639 } else {
640 ALOGE("%s:%d]: Error adding ASD Exif Entry, no meta", __func__, __LINE__);
641 }
642 return rc;
643 }
644