summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJayant Chowdhary <jchowdhary@google.com>2022-05-05 19:21:25 +0000
committerJayant Chowdhary <jchowdhary@google.com>2022-05-10 18:47:00 +0000
commiteca91ca443e8902342758a138ced62a4ab4256da (patch)
tree41461545c426949a93f04f8acf97a17941a4462d
parenta3e89fa14b09be005658e3bd8d6407aa8bfb4ddf (diff)
downloadmedia-eca91ca443e8902342758a138ced62a4ab4256da.tar.gz
camera: Generate vndk version to tag mapping.
This helps us filter tags out of CameraCharacteristics and CaptureResults for vendor clients, depending on the vndk version being used on the vendor partition. Bug: 231517902 Test: ./metadata-generate; inspect generated vndk file Change-Id: I57098710a61d7be649138bd3132af64c9fa6b71a Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
-rwxr-xr-xcamera/docs/metadata-generate4
-rw-r--r--camera/docs/metadata_helpers.py49
-rw-r--r--camera/docs/vndk_camera_metadata_tags.mako54
3 files changed, 107 insertions, 0 deletions
diff --git a/camera/docs/metadata-generate b/camera/docs/metadata-generate
index ed892f21..3a2a0004 100755
--- a/camera/docs/metadata-generate
+++ b/camera/docs/metadata-generate
@@ -42,6 +42,7 @@ ctsdir="$ANDROID_BUILD_TOP/cts/tests/camera/src/android/hardware/camera2/cts"
outdir="$ANDROID_PRODUCT_OUT/obj/ETC/system-media-camera-docs_intermediates"
ndk_header_dir="$ANDROID_BUILD_TOP/frameworks/av/camera/ndk/include/camera"
ndk_impl_dir="$ANDROID_BUILD_TOP/frameworks/av/camera/ndk/impl"
+libcameraservice_hidl_dir="$ANDROID_BUILD_TOP/frameworks/av/services/camera/libcameraservice/hidl"
device_info_dir="$ANDROID_BUILD_TOP/cts/tools/cts-device-info/"`
`"src/com/android/cts/deviceinfo"
out_files=()
@@ -233,6 +234,9 @@ gen_file camera_metadata_tag_info.mako ../src/camera_metadata_tag_info.c || exit
gen_file camera_metadata_tags.mako ../include/system/camera_metadata_tags.h || exit 1
gen_file camera_metadata_asserts.mako ../src/camera_metadata_asserts.cpp || exit 1
+#Generate tags with vndk versions for filtering
+gen_file_abs vndk_camera_metadata_tags.mako "$libcameraservice_hidl_dir/VndkVersionMetadataTags.h" yes || exit 1
+
#Generate NDK header
gen_file_abs ndk_camera_metadata_tags.mako "$ndk_header_dir/NdkCameraMetadataTags.h" yes || exit 1
diff --git a/camera/docs/metadata_helpers.py b/camera/docs/metadata_helpers.py
index 5e3fdda1..e3034f3e 100644
--- a/camera/docs/metadata_helpers.py
+++ b/camera/docs/metadata_helpers.py
@@ -36,6 +36,11 @@ IMAGE_SRC_METADATA="images/camera2/metadata/"
JAVADOC_IMAGE_SRC_METADATA="/reference/" + IMAGE_SRC_METADATA
NDKDOC_IMAGE_SRC_METADATA="../" + IMAGE_SRC_METADATA
+#Corresponds to Android Q, where the camera VNDK was added (minor version 4 and vndk version 29).
+# Minor version and vndk version must correspond to the same release
+FRAMEWORK_CAMERA_VNDK_HAL_MINOR_VERSION = 4
+FRAMEWORK_CAMERA_VNDK_STARTING_VERSION = 29
+
_context_buf = None
_enum = None
@@ -1360,6 +1365,50 @@ def remove_synthetic_or_fwk_only(entries):
"""
return (e for e in entries if not (e.synthetic or e.visibility == 'fwk_only'))
+"""
+ Return the vndk version for a given hal minor version. The major version is assumed to be 3
+
+ Args:
+ hal_minor_version : minor version to retrieve the vndk version for
+
+ Yields:
+ int representing the vndk version
+ """
+def get_vndk_version(hal_minor_version):
+ if hal_minor_version <= FRAMEWORK_CAMERA_VNDK_HAL_MINOR_VERSION:
+ return 0
+ return hal_minor_version - FRAMEWORK_CAMERA_VNDK_HAL_MINOR_VERSION \
+ + FRAMEWORK_CAMERA_VNDK_STARTING_VERSION
+
+"""
+ Returns an api level -> dict of metadata tags corresponding to the api level
+
+ Args:
+ sections : metadata sections to create the mapping for
+ metadata: the metadata structure to be used to create the mapping
+ kind : kind of entries to create a mapping for : 'static' or 'dynamic'
+
+ Yields:
+ A dictionary mapping api level to a dictionary of metadata tags for the particular key (api level)
+ """
+def get_api_level_to_keys(sections, metadata, kind):
+ api_level_to_keys = {}
+ for sec in sections:
+ for idx,entry in enumerate(remove_synthetic(find_unique_entries(sec))):
+ if entry._hal_minor_version > FRAMEWORK_CAMERA_VNDK_HAL_MINOR_VERSION and \
+ metadata.is_entry_this_kind(entry, kind):
+ api_level = get_vndk_version(entry._hal_minor_version)
+ try:
+ api_level_to_keys[api_level].add(entry.name)
+ except KeyError:
+ api_level_to_keys[api_level] = {entry.name}
+ #Insert the keys in sorted order since dicts in python (< 3.7, even OrderedDicts don't actually
+ # sort keys)
+ api_level_to_keys_ordered = OrderedDict()
+ for api_level_ordered in sorted(api_level_to_keys.keys()):
+ api_level_to_keys_ordered[api_level_ordered] = api_level_to_keys[api_level_ordered]
+ return api_level_to_keys_ordered
+
def remove_synthetic(entries):
"""
Filter the given entries by removing those that are synthetic.
diff --git a/camera/docs/vndk_camera_metadata_tags.mako b/camera/docs/vndk_camera_metadata_tags.mako
new file mode 100644
index 00000000..625e9b08
--- /dev/null
+++ b/camera/docs/vndk_camera_metadata_tags.mako
@@ -0,0 +1,54 @@
+## -*- coding: utf-8 -*-
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include <map>
+#include <vector>
+#pragma once
+/**
+ * ! Do not edit this file directly !
+ *
+ * Generated automatically from vndk_camera_metadata_tags.mako. To be included in libcameraservice
+ * only by hidl/Utils.cpp.
+ */
+
+/**
+ * API level to static keys mapping. To be used for filtering out keys depending on vndk version
+ * used by vendor clients.
+ */
+std::map<int, std::vector<camera_metadata_tag>> static_api_level_to_keys{
+ %for api_level, keys in get_api_level_to_keys(find_all_sections(metadata), metadata, 'static').items():
+ {${api_level}, {
+ %for idx, key in enumerate(keys):
+ ${key |csym},
+ %endfor
+ } },
+ %endfor
+};
+
+/**
+ * API level to dynamic keys mapping. To be used for filtering out keys depending on vndk version
+ * used by vendor clients.
+ */
+std::map<int, std::vector<camera_metadata_tag>> dynamic_api_level_to_keys{
+ %for api_level, keys in get_api_level_to_keys(find_all_sections(metadata), metadata, 'dynamic').items():
+ {${api_level}, {
+ %for idx, key in enumerate(keys):
+ ${key |csym},
+ %endfor
+ } },
+ %endfor
+};