1 /*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #define LOG_TAG "GCH_HalVendorTags"
18 #include <log/log.h>
19
20 #include "vendor_tag_defs.h"
21 #include "vendor_tag_utils.h"
22 #include "vendor_tags.h"
23
24 namespace android {
25 namespace google_camera_hal {
26 namespace hal_vendor_tag_utils {
27
ModifyDefaultRequestSettings(RequestTemplate,HalCameraMetadata *)28 status_t ModifyDefaultRequestSettings(RequestTemplate /*type*/,
29 HalCameraMetadata* /*default_settings*/) {
30 // Placeholder to modify default request settings with HAL vendor tag
31 // default values
32 return OK;
33 }
34
ModifyCharacteristicsKeys(HalCameraMetadata * metadata)35 status_t ModifyCharacteristicsKeys(HalCameraMetadata* metadata) {
36 if (metadata == nullptr) {
37 ALOGE("%s: metadata is nullptr", __FUNCTION__);
38 return BAD_VALUE;
39 }
40
41 camera_metadata_ro_entry entry;
42 status_t res;
43 // Get the request keys
44 res = metadata->Get(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, &entry);
45 if (res != OK) {
46 ALOGE("%s: failed to get ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS",
47 __FUNCTION__);
48 return res;
49 }
50 std::vector<int32_t> request_keys(entry.data.i32,
51 entry.data.i32 + entry.count);
52
53 // Get the result keys
54 res = metadata->Get(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, &entry);
55 if (res != OK) {
56 ALOGE("%s: failed to get ANDROID_REQUEST_AVAILABLE_RESULT_KEYS",
57 __FUNCTION__);
58 return res;
59 }
60 std::vector<int32_t> result_keys(entry.data.i32, entry.data.i32 + entry.count);
61
62 // Get the session keys
63 std::vector<int32_t> session_keys;
64 res = metadata->Get(ANDROID_REQUEST_AVAILABLE_SESSION_KEYS, &entry);
65 if (res == OK) {
66 session_keys.insert(session_keys.end(), entry.data.i32, entry.data.i32 + entry.count);
67 } else {
68 ALOGW("%s: failed to get ANDROID_REQUEST_AVAILABLE_SESSION_KEYS",
69 __FUNCTION__);
70 }
71
72 // Get the characteristic keys
73 res = metadata->Get(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, &entry);
74 if (res != OK) {
75 ALOGE("%s: failed to get ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS",
76 __FUNCTION__);
77 return res;
78 }
79 std::vector<int32_t> characteristics_keys(entry.data.i32,
80 entry.data.i32 + entry.count);
81
82 // VendorTagIds::kLogicalCamDefaultPhysicalId
83 res = metadata->Get(ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS, &entry);
84 if (res == OK) {
85 characteristics_keys.push_back(VendorTagIds::kLogicalCamDefaultPhysicalId);
86 }
87 // VendorTagIds::kHybridAeEnabled
88 request_keys.push_back(VendorTagIds::kHybridAeEnabled);
89 result_keys.push_back(VendorTagIds::kHybridAeEnabled);
90 // VendorTagIds::kHdrPlusDisabled
91 request_keys.push_back(VendorTagIds::kHdrPlusDisabled);
92 result_keys.push_back(VendorTagIds::kHdrPlusDisabled);
93 session_keys.push_back(VendorTagIds::kHdrPlusDisabled);
94 // VendorTagIds::kHdrplusPayloadFrames
95 characteristics_keys.push_back(VendorTagIds::kHdrplusPayloadFrames);
96 // VendorTagIds::kHdrUsageMode
97 characteristics_keys.push_back(VendorTagIds::kHdrUsageMode);
98 // VendorTagIds::kProcessingMode
99 request_keys.push_back(VendorTagIds::kProcessingMode);
100 // VendorTagIds::kThermalThrottling
101 request_keys.push_back(VendorTagIds::kThermalThrottling);
102 // VendorTagIds::kOutputIntent
103 request_keys.push_back(VendorTagIds::kOutputIntent);
104 // VendorTagIds::kSensorModeFullFov
105 request_keys.push_back(VendorTagIds::kSensorModeFullFov);
106 result_keys.push_back(VendorTagIds::kSensorModeFullFov);
107 session_keys.push_back(VendorTagIds::kSensorModeFullFov);
108
109 // Update the static metadata with the new set of keys
110 if (metadata->Set(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, request_keys.data(),
111 request_keys.size()) != OK ||
112 metadata->Set(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, result_keys.data(),
113 result_keys.size()) != OK ||
114 metadata->Set(ANDROID_REQUEST_AVAILABLE_SESSION_KEYS, session_keys.data(),
115 session_keys.size()) != OK ||
116 metadata->Set(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,
117 characteristics_keys.data(),
118 characteristics_keys.size()) != OK) {
119 ALOGE("%s Updating static metadata failed", __FUNCTION__);
120 return UNKNOWN_ERROR;
121 }
122
123 return OK;
124 }
125 } // namespace hal_vendor_tag_utils
126 } // namespace google_camera_hal
127 } // namespace android
128