OSDN Git Service

4a307cb9067cec63798ed19cf0718b33474b84c8
[android-x86/system-media.git] / camera / docs / HidlMetadata.mako
1 ## -*- coding: utf-8 -*-
2 /*
3  * Copyright (C) 2017 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 <%!
18   def annotated_type(entry):
19     if entry.enum:
20        type = 'enum'
21     else:
22        type = entry.type
23     if entry.container == 'array':
24        type += '[]'
25
26     return type
27 %>\
28
29 /*
30  * Autogenerated from camera metadata definitions in
31  * /system/media/camera/docs/metadata_definitions.xml
32  * *** DO NOT EDIT BY HAND ***
33  */
34
35 package android.hardware.camera.metadata@${hal_major_version()}.${hal_minor_version()};
36
37 % if first_hal_minor_version(hal_major_version()) != hal_minor_version():
38 /* Include definitions from all prior minor HAL metadata revisions */
39   % for i in range(first_hal_minor_version(hal_major_version()),hal_minor_version()):
40 import android.hardware.camera.metadata@${hal_major_version()}.${i};
41   % endfor
42
43 % endif
44 <%    gotSections = False %>\
45 % for idx, section in enumerate(find_all_sections_added_in_hal(metadata, hal_major_version(), hal_minor_version())):
46   % if idx == 0:
47 <%    gotSections = True %>\
48 /**
49  * Top level hierarchy definitions for camera metadata. *_INFO sections are for
50  * the static metadata that can be retrived without opening the camera device.
51  */
52 enum CameraMetadataSection : ${'uint32_t' if first_hal_minor_version(hal_major_version()) == hal_minor_version() else '@%d.%d::CameraMetadataSection' % (hal_major_version(), hal_minor_version()-1)} {
53   % endif
54   % if first_hal_minor_version(hal_major_version()) != hal_minor_version():
55     ${path_name(section) | csym} =
56         android.hardware.camera.metadata@${hal_major_version()}.${hal_minor_version()-1}::CameraMetadataSection:ANDROID_SECTION_COUNT,
57   % else:
58     ${path_name(section) | csym},
59   % endif
60
61 % endfor
62 % if gotSections:
63     ANDROID_SECTION_COUNT${'' if first_hal_minor_version(hal_major_version()) == hal_minor_version() else '_%d_%d' % (hal_major_version(),hal_minor_version())},
64
65     VENDOR_SECTION${'' if first_hal_minor_version(hal_major_version()) == hal_minor_version() else '_%d_%d' % (hal_major_version(),hal_minor_version())} = 0x8000,
66
67 };
68
69 /**
70  * Hierarchy positions in enum space. All vendor extension sections must be
71  * defined with tag >= VENDOR_SECTION_START
72  */
73 enum CameraMetadataSectionStart : ${'uint32_t' if first_hal_minor_version(hal_major_version()) == hal_minor_version() else 'android.hardware.camera.metadata@%d.%d::CameraMetadataSectionStart' % (hal_major_version(), hal_minor_version()-1)} {
74   % for i in find_all_sections_added_in_hal(metadata, hal_major_version(), hal_minor_version()):
75     ${path_name(i) + '.start' | csym} = CameraMetadataSection:${path_name(i) | csym} << 16,
76
77   % endfor
78   % if first_hal_minor_version(hal_major_version()) != hal_minor_version() :
79     VENDOR_SECTION_START${'_%d_%d' % (hal_major_version(),hal_minor_version())} = CameraMetadataSection:VENDOR_SECTION${'_%d_%d' % (hal_major_version(),hal_minor_version())} << 16,
80   % else:
81     VENDOR_SECTION_START = CameraMetadataSection:VENDOR_SECTION << 16,
82   % endif
83
84 };
85
86 % else:
87 // No new metadata sections added in this revision
88
89 % endif
90 /**
91  * Main enumeration for defining camera metadata tags added in this revision
92  *
93  * <p>Partial documentation is included for each tag; for complete documentation, reference
94  * '/system/media/camera/docs/docs.html' in the corresponding Android source tree.</p>
95  */
96 enum CameraMetadataTag : ${'uint32_t' if first_hal_minor_version(hal_major_version()) == hal_minor_version() else '@%d.%d::CameraMetadataTag' % (hal_major_version(), hal_minor_version()-1)} {
97     % for sec in find_all_sections(metadata):
98 <%    gotEntries = False %>\
99       % for idx,entry in enumerate(filter_added_in_hal_version(remove_synthetic(find_unique_entries(sec)), hal_major_version(), hal_minor_version())):
100 <%      gotEntries = True %>\
101     /** ${entry.name} [${entry.kind}, ${annotated_type(entry)}, ${entry.applied_visibility}]
102         % if entry.description:
103      *
104 ${entry.description | hidldoc(metadata)}\
105         % endif
106      */
107         % if idx == 0:
108           % if find_first_older_used_hal_version(sec, hal_major_version(), hal_minor_version()) == (0, 0):
109     ${entry.name + " =" | csym} CameraMetadataSectionStart:${path_name(find_parent_section(entry)) | csym}_START,
110           % else:
111 <%      prevVersion = find_first_older_used_hal_version(sec, hal_major_version(), hal_minor_version()) %>\
112     ${entry.name + " =" | csym} ${'android.hardware.camera.metadata@%d.%d' % prevVersion}::CameraMetadataTag:${path_name(find_parent_section(entry)) | csym}${'_END' if find_first_older_used_hal_version(sec, prevVersion[0], prevVersion[1]) == (0,0) else '_END_%d_%d' % prevVersion},
113           % endif
114         % else:
115     ${entry.name + "," | csym}
116         % endif
117
118       % endfor
119       % if gotEntries:
120     ${path_name(sec) | csym}${'_END' if first_hal_minor_version(hal_major_version()) == hal_minor_version() else '_END_%d_%d' % (hal_major_version(),hal_minor_version())},
121
122       % endif
123     %endfor
124 };
125
126 /*
127  * Enumeration definitions for the various entries that need them
128  */
129 % for sec in find_all_sections(metadata):
130   % for entry in filter_has_enum_values_added_in_hal_version(remove_synthetic(find_unique_entries(sec)), hal_major_version(), hal_minor_version()):
131     % if entry.enum:
132
133 <%    isFirstValue = True %>\
134 <%    prevValue = None %>\
135       % for val in entry.enum.values:
136         % if val.hal_major_version == hal_major_version() and val.hal_minor_version == hal_minor_version():
137           % if isFirstValue:
138               % if prevValue is None:
139 /** ${entry.name} enumeration values
140               % else:
141 /** ${entry.name} enumeration values added since v${prevValue.hal_major_version}.${prevValue.hal_minor_version}
142               % endif
143  * @see ${entry.name | csym}
144  */
145 enum CameraMetadataEnum${entry.name | pascal_case} :${' uint32_t' if prevValue is None else '\n        @%d.%d::CameraMetadataEnum%s' % (prevValue.hal_major_version, prevValue.hal_minor_version, pascal_case(entry.name))} {
146           % endif
147           % if val.id is None:
148     ${entry.name | csym}_${val.name},
149           % else:
150     ${'%s_%s'%(csym(entry.name), val.name) | pad(65)} = ${val.id},
151           % endif
152 <%        isFirstValue = False %>\
153         % else:
154 <%        prevValue = val %>\
155         % endif
156       % endfor
157 };
158     % endif
159   % endfor
160 % endfor