1 /* Copyright (c) 2014-2016, 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 #define LOG_TAG "QCamera3VendorTags"
31
32 // Camera dependencies
33 #include "QCamera3HWI.h"
34 #include "QCamera3VendorTags.h"
35
36 extern "C" {
37 #include "mm_camera_dbg.h"
38 }
39
40 using namespace android;
41
42 namespace qcamera {
43
44 enum qcamera3_ext_tags qcamera3_ext3_section_bounds[QCAMERA3_SECTIONS_END -
45 VENDOR_SECTION] = {
46 QCAMERA3_PRIVATEDATA_END,
47 QCAMERA3_CDS_END,
48 QCAMERA3_OPAQUE_RAW_END,
49 QCAMERA3_CROP_END,
50 QCAMERA3_TUNING_META_DATA_END,
51 QCAMERA3_TEMPORAL_DENOISE_END,
52 QCAMERA3_AV_TIMER_END,
53 QCAMERA3_SENSOR_META_DATA_END,
54 NEXUS_EXPERIMENTAL_2016_END,
55 QCAMERA3_DUALCAM_LINK_META_DATA_END,
56 QCAMERA3_DUALCAM_CALIB_META_DATA_END
57 } ;
58
59 typedef struct vendor_tag_info {
60 const char *tag_name;
61 uint8_t tag_type;
62 } vendor_tag_info_t;
63
64 const char *qcamera3_ext_section_names[QCAMERA3_SECTIONS_END -
65 VENDOR_SECTION] = {
66 "org.codeaurora.qcamera3.privatedata",
67 "org.codeaurora.qcamera3.CDS",
68 "org.codeaurora.qcamera3.opaque_raw",
69 "org.codeaurora.qcamera3.crop",
70 "org.codeaurora.qcamera3.tuning_meta_data",
71 "org.codeaurora.qcamera3.temporal_denoise",
72 "org.codeaurora.qcamera3.av_timer",
73 "org.codeaurora.qcamera3.sensor_meta_data",
74 "com.google.nexus.experimental2016",
75 "org.codeaurora.qcamera3.dualcam_link_meta_data",
76 "org.codeaurora.qcamera3.dualcam_calib_meta_data"
77 };
78
79 vendor_tag_info_t qcamera3_privatedata[QCAMERA3_PRIVATEDATA_END - QCAMERA3_PRIVATEDATA_START] = {
80 { "privatedata_reprocess", TYPE_INT32 }
81 };
82
83 vendor_tag_info_t qcamera3_cds[QCAMERA3_CDS_END - QCAMERA3_CDS_START] = {
84 { "cds_mode", TYPE_INT32 },
85 { "cds_info", TYPE_BYTE }
86 };
87
88 vendor_tag_info_t qcamera3_opaque_raw[QCAMERA3_OPAQUE_RAW_END -
89 QCAMERA3_OPAQUE_RAW_START] = {
90 { "opaque_raw_strides", TYPE_INT32 },
91 { "opaque_raw_format", TYPE_BYTE }
92 };
93
94 vendor_tag_info_t qcamera3_crop[QCAMERA3_CROP_END- QCAMERA3_CROP_START] = {
95 { "count", TYPE_INT32 },
96 { "data", TYPE_INT32},
97 { "roimap", TYPE_INT32 }
98 };
99
100 vendor_tag_info_t qcamera3_tuning_meta_data[QCAMERA3_TUNING_META_DATA_END -
101 QCAMERA3_TUNING_META_DATA_START] = {
102 { "tuning_meta_data_blob", TYPE_INT32 }
103 };
104
105 vendor_tag_info_t qcamera3_temporal_denoise[QCAMERA3_TEMPORAL_DENOISE_END -
106 QCAMERA3_TEMPORAL_DENOISE_START] = {
107 { "enable", TYPE_BYTE },
108 { "process_type", TYPE_INT32 }
109 };
110
111 vendor_tag_info qcamera3_av_timer[QCAMERA3_AV_TIMER_END -
112 QCAMERA3_AV_TIMER_START] = {
113 {"use_av_timer", TYPE_BYTE }
114 };
115
116 vendor_tag_info qcamera3_sensor_meta_data[QCAMERA3_SENSOR_META_DATA_END -
117 QCAMERA3_SENSOR_META_DATA_START] = {
118 {"dynamic_black_level_pattern", TYPE_FLOAT },
119 {"is_mono_only", TYPE_BYTE }
120 };
121
122 vendor_tag_info_t nexus_experimental_2016[NEXUS_EXPERIMENTAL_2016_END -
123 NEXUS_EXPERIMENTAL_2016_START] = {
124 {"3a.hybrid_ae_enable", TYPE_BYTE },
125 {"control.af_scene_change", TYPE_BYTE },
126 // DevCamDebug vendor tag
127 { "devcamdebug_meta_enable", TYPE_BYTE },
128 // DevCamDebug vendor tag AF
129 { "devcamdebug_af_lens_position", TYPE_INT32 },
130 { "devcamdebug_af_tof_confidence", TYPE_INT32 },
131 { "devcamdebug_af_tof_distance", TYPE_INT32 },
132 { "devcamdebug_af_luma", TYPE_INT32 },
133 { "devcamdebug_af_haf_state", TYPE_INT32 },
134 { "devcamdebug_af_monitor_pdaf_target_pos", TYPE_INT32 },
135 { "devcamdebug_af_monitor_pdaf_confidence", TYPE_INT32 },
136 { "devcamdebug_af_monitor_pdaf_refocus", TYPE_INT32 },
137 { "devcamdebug_af_monitor_tof_target_pos", TYPE_INT32 },
138 { "devcamdebug_af_monitor_tof_confidence", TYPE_INT32 },
139 { "devcamdebug_af_monitor_tof_refocus", TYPE_INT32 },
140 { "devcamdebug_af_monitor_type_select", TYPE_INT32 },
141 { "devcamdebug_af_monitor_refocus", TYPE_INT32 },
142 { "devcamdebug_af_monitor_target_pos", TYPE_INT32 },
143 { "devcamdebug_af_search_pdaf_target_pos", TYPE_INT32 },
144 { "devcamdebug_af_search_pdaf_next_pos", TYPE_INT32 },
145 { "devcamdebug_af_search_pdaf_near_pos", TYPE_INT32 },
146 { "devcamdebug_af_search_pdaf_far_pos", TYPE_INT32 },
147 { "devcamdebug_af_search_pdaf_confidence", TYPE_INT32 },
148 { "devcamdebug_af_search_tof_target_pos", TYPE_INT32 },
149 { "devcamdebug_af_search_tof_next_pos", TYPE_INT32 },
150 { "devcamdebug_af_search_tof_near_pos", TYPE_INT32 },
151 { "devcamdebug_af_search_tof_far_pos", TYPE_INT32 },
152 { "devcamdebug_af_search_tof_confidence", TYPE_INT32 },
153 { "devcamdebug_af_search_type_select", TYPE_INT32 },
154 { "devcamdebug_af_search_next_pos", TYPE_INT32 },
155 { "devcamdebug_af_search_target_pos", TYPE_INT32 },
156 // DevCamDebug vendor tag AEC
157 { "devcamdebug_aec_target_luma", TYPE_INT32 },
158 { "devcamdebug_aec_comp_luma", TYPE_INT32 },
159 { "devcamdebug_aec_avg_luma", TYPE_INT32 },
160 { "devcamdebug_aec_cur_luma", TYPE_INT32 },
161 { "devcamdebug_aec_linecount", TYPE_INT32 },
162 { "devcamdebug_aec_real_gain", TYPE_FLOAT },
163 { "devcamdebug_aec_exp_index", TYPE_INT32 },
164 { "devcamdebug_aec_lux_idx", TYPE_FLOAT },
165 // DevCamDebug vendor tag AWB
166 { "devcamdebug_awb_r_gain", TYPE_FLOAT },
167 { "devcamdebug_awb_g_gain", TYPE_FLOAT },
168 { "devcamdebug_awb_b_gain", TYPE_FLOAT },
169 { "devcamdebug_awb_cct", TYPE_INT32 },
170 { "devcamdebug_awb_decision", TYPE_INT32 },
171 };
172
173 vendor_tag_info_t
174 qcamera3_dualcam_link_meta_data[QCAMERA3_DUALCAM_LINK_META_DATA_END -
175 QCAMERA3_DUALCAM_LINK_META_DATA_START] = {
176 { "enable", TYPE_BYTE },
177 { "is_main", TYPE_BYTE },
178 { "related_camera_id", TYPE_BYTE }
179 };
180
181 vendor_tag_info_t
182 qcamera3_dualcam_calib_meta_data[QCAMERA3_DUALCAM_CALIB_META_DATA_END -
183 QCAMERA3_DUALCAM_CALIB_META_DATA_START] = {
184 { "dualcam_calib_meta_data_blob", TYPE_BYTE }
185 };
186
187 vendor_tag_info_t *qcamera3_tag_info[QCAMERA3_SECTIONS_END -
188 VENDOR_SECTION] = {
189 qcamera3_privatedata,
190 qcamera3_cds,
191 qcamera3_opaque_raw,
192 qcamera3_crop,
193 qcamera3_tuning_meta_data,
194 qcamera3_temporal_denoise,
195 qcamera3_av_timer,
196 qcamera3_sensor_meta_data,
197 nexus_experimental_2016,
198 qcamera3_dualcam_link_meta_data,
199 qcamera3_dualcam_calib_meta_data
200 };
201
202 uint32_t qcamera3_all_tags[] = {
203 // QCAMERA3_PRIVATEDATA
204 (uint32_t)QCAMERA3_PRIVATEDATA_REPROCESS,
205
206 // QCAMERA3_CDS
207 (uint32_t)QCAMERA3_CDS_MODE,
208 (uint32_t)QCAMERA3_CDS_INFO,
209
210 // QCAMERA3_OPAQUE_RAW
211 (uint32_t)QCAMERA3_OPAQUE_RAW_STRIDES,
212 (uint32_t)QCAMERA3_OPAQUE_RAW_FORMAT,
213
214 // QCAMERA3_CROP
215 (uint32_t)QCAMERA3_CROP_COUNT_REPROCESS,
216 (uint32_t)QCAMERA3_CROP_REPROCESS,
217 (uint32_t)QCAMERA3_CROP_ROI_MAP_REPROCESS,
218
219 // QCAMERA3_TUNING_META_DATA
220 (uint32_t)QCAMERA3_TUNING_META_DATA_BLOB,
221
222 // QCAMERA3_TEMPORAL_DENOISE
223 (uint32_t)QCAMERA3_TEMPORAL_DENOISE_ENABLE,
224 (uint32_t)QCAMERA3_TEMPORAL_DENOISE_PROCESS_TYPE,
225 //QCAMERA3_AVTIMER
226 (uint32_t)QCAMERA3_USE_AV_TIMER,
227
228 //QCAMERA3_SENSOR_META_DATA
229 (uint32_t)QCAMERA3_SENSOR_DYNAMIC_BLACK_LEVEL_PATTERN,
230 (uint32_t)QCAMERA3_SENSOR_IS_MONO_ONLY,
231
232 //NEXUS_EXPERIMENTAL_2016
233 (uint32_t)NEXUS_EXPERIMENTAL_2016_HYBRID_AE_ENABLE,
234 (uint32_t)NEXUS_EXPERIMENTAL_2016_AF_SCENE_CHANGE,
235 // DEVCAMDEBUG
236 (uint32_t)DEVCAMDEBUG_META_ENABLE,
237 // DEVCAMDEBUG AF
238 (uint32_t)DEVCAMDEBUG_AF_LENS_POSITION,
239 (uint32_t)DEVCAMDEBUG_AF_TOF_CONFIDENCE,
240 (uint32_t)DEVCAMDEBUG_AF_TOF_DISTANCE,
241 (uint32_t)DEVCAMDEBUG_AF_LUMA,
242 (uint32_t)DEVCAMDEBUG_AF_HAF_STATE,
243 (uint32_t)DEVCAMDEBUG_AF_MONITOR_PDAF_TARGET_POS,
244 (uint32_t)DEVCAMDEBUG_AF_MONITOR_PDAF_CONFIDENCE,
245 (uint32_t)DEVCAMDEBUG_AF_MONITOR_PDAF_REFOCUS,
246 (uint32_t)DEVCAMDEBUG_AF_MONITOR_TOF_TARGET_POS,
247 (uint32_t)DEVCAMDEBUG_AF_MONITOR_TOF_CONFIDENCE,
248 (uint32_t)DEVCAMDEBUG_AF_MONITOR_TOF_REFOCUS,
249 (uint32_t)DEVCAMDEBUG_AF_MONITOR_TYPE_SELECT,
250 (uint32_t)DEVCAMDEBUG_AF_MONITOR_REFOCUS,
251 (uint32_t)DEVCAMDEBUG_AF_MONITOR_TARGET_POS,
252 (uint32_t)DEVCAMDEBUG_AF_SEARCH_PDAF_TARGET_POS,
253 (uint32_t)DEVCAMDEBUG_AF_SEARCH_PDAF_NEXT_POS,
254 (uint32_t)DEVCAMDEBUG_AF_SEARCH_PDAF_NEAR_POS,
255 (uint32_t)DEVCAMDEBUG_AF_SEARCH_PDAF_FAR_POS,
256 (uint32_t)DEVCAMDEBUG_AF_SEARCH_PDAF_CONFIDENCE,
257 (uint32_t)DEVCAMDEBUG_AF_SEARCH_TOF_TARGET_POS,
258 (uint32_t)DEVCAMDEBUG_AF_SEARCH_TOF_NEXT_POS,
259 (uint32_t)DEVCAMDEBUG_AF_SEARCH_TOF_NEAR_POS,
260 (uint32_t)DEVCAMDEBUG_AF_SEARCH_TOF_FAR_POS,
261 (uint32_t)DEVCAMDEBUG_AF_SEARCH_TOF_CONFIDENCE,
262 (uint32_t)DEVCAMDEBUG_AF_SEARCH_TYPE_SELECT,
263 (uint32_t)DEVCAMDEBUG_AF_SEARCH_NEXT_POS,
264 (uint32_t)DEVCAMDEBUG_AF_SEARCH_TARGET_POS,
265 // DEVCAMDEBUG AEC
266 (uint32_t)DEVCAMDEBUG_AEC_TARGET_LUMA,
267 (uint32_t)DEVCAMDEBUG_AEC_COMP_LUMA,
268 (uint32_t)DEVCAMDEBUG_AEC_AVG_LUMA,
269 (uint32_t)DEVCAMDEBUG_AEC_CUR_LUMA,
270 (uint32_t)DEVCAMDEBUG_AEC_LINECOUNT,
271 (uint32_t)DEVCAMDEBUG_AEC_REAL_GAIN,
272 (uint32_t)DEVCAMDEBUG_AEC_EXP_INDEX,
273 (uint32_t)DEVCAMDEBUG_AEC_LUX_IDX,
274 // DEVCAMDEBUG AWB
275 (uint32_t)DEVCAMDEBUG_AWB_R_GAIN,
276 (uint32_t)DEVCAMDEBUG_AWB_G_GAIN,
277 (uint32_t)DEVCAMDEBUG_AWB_B_GAIN,
278 (uint32_t)DEVCAMDEBUG_AWB_CCT,
279 (uint32_t)DEVCAMDEBUG_AWB_DECISION,
280 // DEVCAMDEBUG END
281
282 // QCAMERA3_DUALCAM_LINK_META_DATA
283 (uint32_t)QCAMERA3_DUALCAM_LINK_ENABLE,
284 (uint32_t)QCAMERA3_DUALCAM_LINK_IS_MAIN,
285 (uint32_t)QCAMERA3_DUALCAM_LINK_RELATED_CAMERA_ID,
286
287 // QCAMERA3_DUALCAM_CALIB_META_DATA
288 (uint32_t)QCAMERA3_DUALCAM_CALIB_META_DATA_BLOB,
289 };
290
291 const vendor_tag_ops_t* QCamera3VendorTags::Ops = NULL;
292
293 /*===========================================================================
294 * FUNCTION : get_vendor_tag_ops
295 *
296 * DESCRIPTION: Get the metadata vendor tag function pointers
297 *
298 * PARAMETERS :
299 * @ops : function pointer table to be filled by HAL
300 *
301 *
302 * RETURN : NONE
303 *==========================================================================*/
get_vendor_tag_ops(vendor_tag_ops_t * ops)304 void QCamera3VendorTags::get_vendor_tag_ops(
305 vendor_tag_ops_t* ops)
306 {
307 LOGL("E");
308
309 Ops = ops;
310
311 ops->get_tag_count = get_tag_count;
312 ops->get_all_tags = get_all_tags;
313 ops->get_section_name = get_section_name;
314 ops->get_tag_name = get_tag_name;
315 ops->get_tag_type = get_tag_type;
316 ops->reserved[0] = NULL;
317
318 LOGL("X");
319 return;
320 }
321
322 /*===========================================================================
323 * FUNCTION : get_tag_count
324 *
325 * DESCRIPTION: Get number of vendor tags supported
326 *
327 * PARAMETERS :
328 * @ops : Vendor tag ops data structure
329 *
330 *
331 * RETURN : Number of vendor tags supported
332 *==========================================================================*/
333
get_tag_count(const vendor_tag_ops_t * ops)334 int QCamera3VendorTags::get_tag_count(
335 const vendor_tag_ops_t * ops)
336 {
337 size_t count = 0;
338 if (ops == Ops)
339 count = sizeof(qcamera3_all_tags)/sizeof(qcamera3_all_tags[0]);
340
341 LOGL("count is %d", count);
342 return (int)count;
343 }
344
345 /*===========================================================================
346 * FUNCTION : get_all_tags
347 *
348 * DESCRIPTION: Fill array with all supported vendor tags
349 *
350 * PARAMETERS :
351 * @ops : Vendor tag ops data structure
352 * @tag_array: array of metadata tags
353 *
354 * RETURN : Success: the section name of the specific tag
355 * Failure: NULL
356 *==========================================================================*/
get_all_tags(const vendor_tag_ops_t * ops,uint32_t * g_array)357 void QCamera3VendorTags::get_all_tags(
358 const vendor_tag_ops_t * ops,
359 uint32_t *g_array)
360 {
361 if (ops != Ops)
362 return;
363
364 for (size_t i = 0;
365 i < sizeof(qcamera3_all_tags)/sizeof(qcamera3_all_tags[0]);
366 i++) {
367 g_array[i] = qcamera3_all_tags[i];
368 LOGD("g_array[%d] is %d", i, g_array[i]);
369 }
370 }
371
372 /*===========================================================================
373 * FUNCTION : get_section_name
374 *
375 * DESCRIPTION: Get section name for vendor tag
376 *
377 * PARAMETERS :
378 * @ops : Vendor tag ops structure
379 * @tag : Vendor specific tag
380 *
381 *
382 * RETURN : Success: the section name of the specific tag
383 * Failure: NULL
384 *==========================================================================*/
385
get_section_name(const vendor_tag_ops_t * ops,uint32_t tag)386 const char* QCamera3VendorTags::get_section_name(
387 const vendor_tag_ops_t * ops,
388 uint32_t tag)
389 {
390 LOGL("E");
391 if (ops != Ops)
392 return NULL;
393
394 const char *ret;
395 uint32_t section = tag >> 16;
396
397 if (section < VENDOR_SECTION || section >= QCAMERA3_SECTIONS_END)
398 ret = NULL;
399 else
400 ret = qcamera3_ext_section_names[section - VENDOR_SECTION];
401
402 if (ret)
403 LOGL("section_name[%d] is %s", tag, ret);
404 LOGL("X");
405 return ret;
406 }
407
408 /*===========================================================================
409 * FUNCTION : get_tag_name
410 *
411 * DESCRIPTION: Get name of a vendor specific tag
412 *
413 * PARAMETERS :
414 * @tag : Vendor specific tag
415 *
416 *
417 * RETURN : Success: the name of the specific tag
418 * Failure: NULL
419 *==========================================================================*/
get_tag_name(const vendor_tag_ops_t * ops,uint32_t tag)420 const char* QCamera3VendorTags::get_tag_name(
421 const vendor_tag_ops_t * ops,
422 uint32_t tag)
423 {
424 LOGL("E");
425 const char *ret;
426 uint32_t section = tag >> 16;
427 uint32_t section_index = section - VENDOR_SECTION;
428 uint32_t tag_index = tag & 0xFFFF;
429
430 if (ops != Ops) {
431 ret = NULL;
432 goto done;
433 }
434
435 if (section < VENDOR_SECTION || section >= QCAMERA3_SECTIONS_END)
436 ret = NULL;
437 else if (tag >= (uint32_t)qcamera3_ext3_section_bounds[section_index])
438 ret = NULL;
439 else
440 ret = qcamera3_tag_info[section_index][tag_index].tag_name;
441
442 if (ret)
443 LOGL("tag name for tag %d is %s", tag, ret);
444 LOGL("X");
445
446 done:
447 return ret;
448 }
449
450 /*===========================================================================
451 * FUNCTION : get_tag_type
452 *
453 * DESCRIPTION: Get type of a vendor specific tag
454 *
455 * PARAMETERS :
456 * @tag : Vendor specific tag
457 *
458 *
459 * RETURN : Success: the type of the specific tag
460 * Failure: -1
461 *==========================================================================*/
get_tag_type(const vendor_tag_ops_t * ops,uint32_t tag)462 int QCamera3VendorTags::get_tag_type(
463 const vendor_tag_ops_t *ops,
464 uint32_t tag)
465 {
466 LOGL("E");
467 int ret;
468 uint32_t section = tag >> 16;
469 uint32_t section_index = section - VENDOR_SECTION;
470 uint32_t tag_index = tag & 0xFFFF;
471
472 if (ops != Ops) {
473 ret = -1;
474 goto done;
475 }
476 if (section < VENDOR_SECTION || section >= QCAMERA3_SECTIONS_END)
477 ret = -1;
478 else if (tag >= (uint32_t )qcamera3_ext3_section_bounds[section_index])
479 ret = -1;
480 else
481 ret = qcamera3_tag_info[section_index][tag_index].tag_type;
482
483 LOGL("tag type for tag %d is %d", tag, ret);
484 LOGL("X");
485 done:
486 return ret;
487 }
488
489 }; //end namespace qcamera
490