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 #ifndef HARDWARE_GOOGLE_CAMERA_HAL_CAMERA_VENDOR_TAG_DEFS_H
18 #define HARDWARE_GOOGLE_CAMERA_HAL_CAMERA_VENDOR_TAG_DEFS_H
19 
20 #include <vector>
21 
22 #include "hal_types.h"
23 
24 namespace android {
25 namespace google_camera_hal {
26 
27 // TODO(b/127998029): it is more suitable to reserve a section before
28 // VENDOR_SECTION_START in the framework for private use and update this range.
29 //
30 // Android vendor tags start at 0x80000000 according to VENDOR_SECTION_START.
31 // Reserve the upper range of that for HAL. The vendor HWL cannot have any tags
32 // overlapping with this range up
33 constexpr uint32_t kHalVendorTagSectionStart = 0x84000000;
34 
35 // Camera HAL vendor tag IDs. Items should not be removed or rearranged
36 enum VendorTagIds : uint32_t {
37   kLogicalCamDefaultPhysicalId = kHalVendorTagSectionStart,
38   kHybridAeEnabled,
39   kHdrPlusDisabled,
40   kHdrplusPayloadFrames,
41   kProcessingMode,
42   kThermalThrottling,
43   kOutputIntent,
44   kAvailableNonWarpedYuvSizes,
45   kNonWarpedYuvStreamId,
46   kSensorModeFullFov,
47   kNonWarpedCropRegion,
48   kHdrUsageMode,
49   // This should not be used as a vendor tag ID on its own, but as a placeholder
50   // to indicate the end of currently defined vendor tag IDs
51   kEndMarker
52 };
53 
54 // Logical camera vendor tags
55 static const std::vector<VendorTag> kLogicalCameraVendorTags = {
56     // Logical camera default physical camera ID
57     //
58     // Indicates the camera ID for the physical camera that should be streamed on
59     // as the default camera of a logical camera device
60     //
61     // Present in: Characteristics
62     // Payload: framework camera ID
63     {.tag_id = VendorTagIds::kLogicalCamDefaultPhysicalId,
64      .tag_name = "DefaultPhysicalCamId",
65      .tag_type = CameraMetadataType::kInt32},
66 };
67 
68 // Experimental 2016 API tags
69 static const std::vector<VendorTag> kExperimental2016Tags = {
70     // Hybrid AE enabled toggle
71     //
72     // Indicates whether Hybrid AE should be enabled in HAL or not
73     //
74     // Present in: request, and result keys
75     // Payload: integer treated as a boolean toggle flag
76     {.tag_id = VendorTagIds::kHybridAeEnabled,
77      .tag_name = "3a.hybrid_ae_enable",
78      .tag_type = CameraMetadataType::kInt32},
79 };
80 
81 // Experimental 2017 API tags
82 static const std::vector<VendorTag> kExperimental2017Tags = {
83     // HDR+ disabled toggle
84     //
85     // Indicates whether HDR+ should be disabled in HAL or not
86     //
87     // Present in: request, result, and session keys
88     // Payload: 1 byte boolean flag
89     {.tag_id = VendorTagIds::kHdrPlusDisabled,
90      .tag_name = "request.disable_hdrplus",
91      .tag_type = CameraMetadataType::kByte},
92 };
93 
94 // Experimental 2019 API tags
95 static const std::vector<VendorTag> kExperimental2019Tags = {
96     // Select sensor mode which has Full FOV
97     //
98     // Indicates whether full FOV sensor mode is requested
99     //
100     // Present in: request, result, and session keys
101     // Payload: 1 byte boolean flag
102     {.tag_id = VendorTagIds::kSensorModeFullFov,
103      .tag_name = "SensorModeFullFov",
104      .tag_type = CameraMetadataType::kByte},
105 };
106 
107 // Internal vendor tags
108 static const std::vector<VendorTag> kInternalVendorTags = {
109     // Hdrplus playload frames
110     //
111     // Indicates the number of HDR+ input buffers
112     //
113     // Present in: Characteristics
114     // Payload: integer for HDR+ input buffers
115     {.tag_id = VendorTagIds::kHdrplusPayloadFrames,
116      .tag_name = "hdrplus.PayloadFrames",
117      .tag_type = CameraMetadataType::kInt32},
118     // Capture request processing mode
119     //
120     // Indicates whether the capture request is intended for intermediate
121     // processing, or if it's the final capture request to be sent back to
122     // the camera framework. Absense of this tag should imply final processing.
123     // When indermediate processing is specified, HAL will need to explicitly
124     // filter HWL's private metadata by calling
125     //   CameraDeviceSessionHwl::FilterResultMetadata()
126     //
127     // Present in: request
128     // Payload: ProcessingMode
129     {.tag_id = VendorTagIds::kProcessingMode,
130      .tag_name = "ProcessingMode",
131      .tag_type = CameraMetadataType::kByte},
132     // Thermal throttled
133     //
134     // Indicates whether thermal throttling is triggered.
135     //
136     // Present in: request
137     // Payload: 1 byte boolean flag
138     {.tag_id = VendorTagIds::kThermalThrottling,
139      .tag_name = "thermal_throttling",
140      .tag_type = CameraMetadataType::kByte},
141     // Capture request output intent
142     //
143     // Indicates whether the capture request is intended for preview, snapshot,
144     // video, zsl, or video snapshot, etc. This information can be used to
145     // indicate different tuning usecases.
146     //
147     // Present in: request
148     // Payload: OutputIntent
149     {.tag_id = VendorTagIds::kOutputIntent,
150      .tag_name = "OutputIntent",
151      .tag_type = CameraMetadataType::kByte},
152     // Supported stream sizes for non-warped yuv
153     //
154     // List supported dimensions if HAL request non-warped YUV_420_888.
155     //
156     // Present in: Characteristics
157     // Payload: n * 2 integers for supported dimensions(w*h)
158     {.tag_id = VendorTagIds::kAvailableNonWarpedYuvSizes,
159      .tag_name = "AvailableNonWarpedYuvSizes",
160      .tag_type = CameraMetadataType::kInt32},
161     // Non-warped YUV stream id
162     //
163     // Used by GCH to specify one YUV stream through its stream id to which no
164     // warping should be applied except for certain level of cropping. The
165     // cropping should be specified in VendorTagIds::kNonWarpedCropRegion.
166     // Present in: session parameter
167     // Payload: one int32_t
168     {.tag_id = VendorTagIds::kNonWarpedYuvStreamId,
169      .tag_name = "NonWarpedYuvStreamId",
170      .tag_type = CameraMetadataType::kInt32},
171     // Non-warped crop region
172     //
173     // This specifies how the NonWarpedYuvStream is cropped relative to
174     // android.sensor.info.preCorrectionActiveArraySize.
175     //
176     // Present in: request and result parameter
177     // Payload: Four int32_t in the order of [left, right, width, height]
178     {.tag_id = VendorTagIds::kNonWarpedCropRegion,
179      .tag_name = "NonWarpedCropRegion",
180      .tag_type = CameraMetadataType::kInt32},
181     // Hdrplus usage mode
182     //
183     // Indicates the usage mode of hdrplus
184     //
185     // Present in: Characteristics
186     // Payload: HdrUsageMode
187     {.tag_id = VendorTagIds::kHdrUsageMode,
188      .tag_name = "hdr.UsageMode",
189      .tag_type = CameraMetadataType::kByte},
190 };
191 
192 // Google Camera HAL vendor tag sections
193 static const std::vector<VendorTagSection> kHalVendorTagSections = {
194     {.section_name = "com.google.hal.logicalcamera",
195      .tags = kLogicalCameraVendorTags},
196     {.section_name = "com.google.pixel.experimental2016",
197      .tags = kExperimental2016Tags},
198     {.section_name = "com.google.pixel.experimental2017",
199      .tags = kExperimental2017Tags},
200     {.section_name = "com.google.pixel.experimental2019",
201      .tags = kExperimental2019Tags},
202     {.section_name = "com.google.internal", .tags = kInternalVendorTags},
203 };
204 
205 }  // namespace google_camera_hal
206 }  // namespace android
207 
208 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_CAMERA_VENDOR_TAG_DEFS_H
209