summaryrefslogtreecommitdiff
path: root/common/hal/google_camera_hal/vendor_tags.cc
blob: f1f0641d8cb2653853f940a17e5ea89a5b3f00c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "GCH_HalVendorTags"
#include <log/log.h>

#include "vendor_tag_defs.h"
#include "vendor_tag_utils.h"
#include "vendor_tags.h"

namespace android {
namespace google_camera_hal {
namespace hal_vendor_tag_utils {

status_t ModifyDefaultRequestSettings(RequestTemplate /*type*/,
                                      HalCameraMetadata* /*default_settings*/) {
  // Placeholder to modify default request settings with HAL vendor tag
  // default values
  return OK;
}

status_t ModifyCharacteristicsKeys(HalCameraMetadata* metadata) {
  if (metadata == nullptr) {
    ALOGE("%s: metadata is nullptr", __FUNCTION__);
    return BAD_VALUE;
  }

  camera_metadata_ro_entry entry;
  status_t res;
  // Get the request keys
  res = metadata->Get(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, &entry);
  if (res != OK) {
    ALOGE("%s: failed to get ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS",
          __FUNCTION__);
    return res;
  }
  std::vector<int32_t> request_keys(entry.data.i32,
                                    entry.data.i32 + entry.count);

  // Get the result keys
  res = metadata->Get(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, &entry);
  if (res != OK) {
    ALOGE("%s: failed to get ANDROID_REQUEST_AVAILABLE_RESULT_KEYS",
          __FUNCTION__);
    return res;
  }
  std::vector<int32_t> result_keys(entry.data.i32, entry.data.i32 + entry.count);

  // Get the session keys
  std::vector<int32_t> session_keys;
  res = metadata->Get(ANDROID_REQUEST_AVAILABLE_SESSION_KEYS, &entry);
  if (res == OK) {
    session_keys.insert(session_keys.end(), entry.data.i32, entry.data.i32 + entry.count);
  } else {
    ALOGW("%s: failed to get ANDROID_REQUEST_AVAILABLE_SESSION_KEYS",
          __FUNCTION__);
  }

  // Get the characteristic keys
  res = metadata->Get(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, &entry);
  if (res != OK) {
    ALOGE("%s: failed to get ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS",
          __FUNCTION__);
    return res;
  }
  std::vector<int32_t> characteristics_keys(entry.data.i32,
                                            entry.data.i32 + entry.count);

  // VendorTagIds::kLogicalCamDefaultPhysicalId
  res = metadata->Get(ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS, &entry);
  if (res == OK) {
    characteristics_keys.push_back(VendorTagIds::kLogicalCamDefaultPhysicalId);
  }
  // VendorTagIds::kHybridAeEnabled
  request_keys.push_back(VendorTagIds::kHybridAeEnabled);
  result_keys.push_back(VendorTagIds::kHybridAeEnabled);
  // VendorTagIds::kHdrPlusDisabled
  request_keys.push_back(VendorTagIds::kHdrPlusDisabled);
  result_keys.push_back(VendorTagIds::kHdrPlusDisabled);
  session_keys.push_back(VendorTagIds::kHdrPlusDisabled);
  // VendorTagIds::kHdrplusPayloadFrames
  characteristics_keys.push_back(VendorTagIds::kHdrplusPayloadFrames);
  // VendorTagIds::kHdrUsageMode
  characteristics_keys.push_back(VendorTagIds::kHdrUsageMode);
  // VendorTagIds::kProcessingMode
  request_keys.push_back(VendorTagIds::kProcessingMode);
  // VendorTagIds::kThermalThrottling
  request_keys.push_back(VendorTagIds::kThermalThrottling);
  // VendorTagIds::kOutputIntent
  request_keys.push_back(VendorTagIds::kOutputIntent);
  // VendorTagIds::kSensorModeFullFov
  request_keys.push_back(VendorTagIds::kSensorModeFullFov);
  result_keys.push_back(VendorTagIds::kSensorModeFullFov);
  session_keys.push_back(VendorTagIds::kSensorModeFullFov);
  // VendorTagIds::kVideo60to30FPSThermalThrottle
  session_keys.push_back(VendorTagIds::kVideo60to30FPSThermalThrottle);
  request_keys.push_back(VendorTagIds::kVideo60to30FPSThermalThrottle);

  // Update the static metadata with the new set of keys
  if (metadata->Set(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, request_keys.data(),
                    request_keys.size()) != OK ||
      metadata->Set(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, result_keys.data(),
                    result_keys.size()) != OK ||
      metadata->Set(ANDROID_REQUEST_AVAILABLE_SESSION_KEYS, session_keys.data(),
                    session_keys.size()) != OK ||
      metadata->Set(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,
                    characteristics_keys.data(),
                    characteristics_keys.size()) != OK) {
    ALOGE("%s Updating static metadata failed", __FUNCTION__);
    return UNKNOWN_ERROR;
  }

  return OK;
}
}  // namespace hal_vendor_tag_utils
}  // namespace google_camera_hal
}  // namespace android