blob: fbe8686766a2ab0c319d2244859f2da1cb55ed14 [file] [log] [blame]
Yin-Chia Yeh248ed702017-01-23 17:27:26 -08001/*
2 * Copyright (C) 2017 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 "HandleImporter"
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080018#include "HandleImporter.h"
Jason Macnakeda6dca2020-04-15 15:20:59 -070019
20#include <gralloctypes/Gralloc4.h>
Steven Moreland4e7a3072017-04-06 12:15:23 -070021#include <log/log.h>
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080022
23namespace android {
24namespace hardware {
25namespace camera {
26namespace common {
27namespace V1_0 {
28namespace helper {
29
Jason Macnakeda6dca2020-04-15 15:20:59 -070030using aidl::android::hardware::graphics::common::PlaneLayout;
31using aidl::android::hardware::graphics::common::PlaneLayoutComponent;
32using aidl::android::hardware::graphics::common::PlaneLayoutComponentType;
Emilian Peevb5f634f2021-12-13 15:13:46 -080033using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType;
Shuzhen Wang915115e2019-05-10 12:07:14 -070034using MapperErrorV2 = android::hardware::graphics::mapper::V2_0::Error;
35using MapperErrorV3 = android::hardware::graphics::mapper::V3_0::Error;
Marissa Walla51eb932019-06-21 09:13:35 -070036using MapperErrorV4 = android::hardware::graphics::mapper::V4_0::Error;
Shuzhen Wang915115e2019-05-10 12:07:14 -070037using IMapperV3 = android::hardware::graphics::mapper::V3_0::IMapper;
Marissa Walla51eb932019-06-21 09:13:35 -070038using IMapperV4 = android::hardware::graphics::mapper::V4_0::IMapper;
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080039
Yin-Chia Yeh519c1672017-04-21 14:59:31 -070040HandleImporter::HandleImporter() : mInitialized(false) {}
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080041
Yin-Chia Yeh519c1672017-04-21 14:59:31 -070042void HandleImporter::initializeLocked() {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080043 if (mInitialized) {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080044 return;
45 }
46
Marissa Walla51eb932019-06-21 09:13:35 -070047 mMapperV4 = IMapperV4::getService();
48 if (mMapperV4 != nullptr) {
49 mInitialized = true;
50 return;
51 }
52
Shuzhen Wang915115e2019-05-10 12:07:14 -070053 mMapperV3 = IMapperV3::getService();
54 if (mMapperV3 != nullptr) {
55 mInitialized = true;
56 return;
57 }
58
59 mMapperV2 = IMapper::getService();
60 if (mMapperV2 == nullptr) {
Yin-Chia Yeh519c1672017-04-21 14:59:31 -070061 ALOGE("%s: cannnot acccess graphics mapper HAL!", __FUNCTION__);
62 return;
63 }
64
65 mInitialized = true;
66 return;
67}
68
69void HandleImporter::cleanup() {
Marissa Walla51eb932019-06-21 09:13:35 -070070 mMapperV4.clear();
Shuzhen Wang915115e2019-05-10 12:07:14 -070071 mMapperV3.clear();
72 mMapperV2.clear();
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080073 mInitialized = false;
74}
75
Shuzhen Wang915115e2019-05-10 12:07:14 -070076template<class M, class E>
77bool HandleImporter::importBufferInternal(const sp<M> mapper, buffer_handle_t& handle) {
78 E error;
79 buffer_handle_t importedHandle;
80 auto ret = mapper->importBuffer(
81 hidl_handle(handle),
82 [&](const auto& tmpError, const auto& tmpBufferHandle) {
83 error = tmpError;
84 importedHandle = static_cast<buffer_handle_t>(tmpBufferHandle);
85 });
86
87 if (!ret.isOk()) {
88 ALOGE("%s: mapper importBuffer failed: %s",
89 __FUNCTION__, ret.description().c_str());
90 return false;
91 }
92
93 if (error != E::NONE) {
94 return false;
95 }
96
97 handle = importedHandle;
98 return true;
99}
100
101template<class M, class E>
102YCbCrLayout HandleImporter::lockYCbCrInternal(const sp<M> mapper, buffer_handle_t& buf,
103 uint64_t cpuUsage, const IMapper::Rect& accessRegion) {
104 hidl_handle acquireFenceHandle;
105 auto buffer = const_cast<native_handle_t*>(buf);
106 YCbCrLayout layout = {};
107
108 typename M::Rect accessRegionCopy = {accessRegion.left, accessRegion.top,
109 accessRegion.width, accessRegion.height};
110 mapper->lockYCbCr(buffer, cpuUsage, accessRegionCopy, acquireFenceHandle,
111 [&](const auto& tmpError, const auto& tmpLayout) {
112 if (tmpError == E::NONE) {
113 // Member by member copy from different versions of YCbCrLayout.
114 layout.y = tmpLayout.y;
115 layout.cb = tmpLayout.cb;
116 layout.cr = tmpLayout.cr;
117 layout.yStride = tmpLayout.yStride;
118 layout.cStride = tmpLayout.cStride;
119 layout.chromaStep = tmpLayout.chromaStep;
120 } else {
121 ALOGE("%s: failed to lockYCbCr error %d!", __FUNCTION__, tmpError);
122 }
123 });
124 return layout;
125}
126
Emilian Peevb5f634f2021-12-13 15:13:46 -0800127bool isMetadataPesent(const sp<IMapperV4> mapper, const buffer_handle_t& buf,
128 MetadataType metadataType) {
129 auto buffer = const_cast<native_handle_t*>(buf);
130 mapper->get(buffer, metadataType, [] (const auto& tmpError,
131 const auto& tmpMetadata) {
132 if (tmpError == MapperErrorV4::NONE) {
133 return tmpMetadata.size() > 0;
134 } else {
135 ALOGE("%s: failed to get metadata %d!", __FUNCTION__, tmpError);
136 return false;
137 }});
138
139 return false;
140}
141
Emilian Peev6a2572b2021-05-24 16:51:17 -0700142std::vector<PlaneLayout> getPlaneLayouts(const sp<IMapperV4> mapper, buffer_handle_t& buf) {
143 auto buffer = const_cast<native_handle_t*>(buf);
144 std::vector<PlaneLayout> planeLayouts;
145 hidl_vec<uint8_t> encodedPlaneLayouts;
146 mapper->get(buffer, gralloc4::MetadataType_PlaneLayouts,
147 [&](const auto& tmpError, const auto& tmpEncodedPlaneLayouts) {
148 if (tmpError == MapperErrorV4::NONE) {
149 encodedPlaneLayouts = tmpEncodedPlaneLayouts;
150 } else {
151 ALOGE("%s: failed to get plane layouts %d!", __FUNCTION__, tmpError);
152 }
153 });
154
155 gralloc4::decodePlaneLayouts(encodedPlaneLayouts, &planeLayouts);
156
157 return planeLayouts;
158}
159
Jason Macnakeda6dca2020-04-15 15:20:59 -0700160template <>
161YCbCrLayout HandleImporter::lockYCbCrInternal<IMapperV4, MapperErrorV4>(
162 const sp<IMapperV4> mapper, buffer_handle_t& buf, uint64_t cpuUsage,
163 const IMapper::Rect& accessRegion) {
164 hidl_handle acquireFenceHandle;
165 auto buffer = const_cast<native_handle_t*>(buf);
166 YCbCrLayout layout = {};
167 void* mapped = nullptr;
168
169 typename IMapperV4::Rect accessRegionV4 = {accessRegion.left, accessRegion.top,
170 accessRegion.width, accessRegion.height};
171 mapper->lock(buffer, cpuUsage, accessRegionV4, acquireFenceHandle,
172 [&](const auto& tmpError, const auto& tmpPtr) {
173 if (tmpError == MapperErrorV4::NONE) {
174 mapped = tmpPtr;
175 } else {
176 ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
177 }
178 });
179
180 if (mapped == nullptr) {
181 return layout;
182 }
183
Emilian Peev6a2572b2021-05-24 16:51:17 -0700184 std::vector<PlaneLayout> planeLayouts = getPlaneLayouts(mapper, buf);
Jason Macnakeda6dca2020-04-15 15:20:59 -0700185 for (const auto& planeLayout : planeLayouts) {
186 for (const auto& planeLayoutComponent : planeLayout.components) {
187 const auto& type = planeLayoutComponent.type;
188
189 if (!gralloc4::isStandardPlaneLayoutComponentType(type)) {
190 continue;
191 }
192
193 uint8_t* data = reinterpret_cast<uint8_t*>(mapped);
194 data += planeLayout.offsetInBytes;
195 data += planeLayoutComponent.offsetInBits / 8;
196
197 switch (static_cast<PlaneLayoutComponentType>(type.value)) {
198 case PlaneLayoutComponentType::Y:
199 layout.y = data;
200 layout.yStride = planeLayout.strideInBytes;
201 break;
202 case PlaneLayoutComponentType::CB:
203 layout.cb = data;
204 layout.cStride = planeLayout.strideInBytes;
205 layout.chromaStep = planeLayout.sampleIncrementInBits / 8;
206 break;
207 case PlaneLayoutComponentType::CR:
208 layout.cr = data;
209 layout.cStride = planeLayout.strideInBytes;
210 layout.chromaStep = planeLayout.sampleIncrementInBits / 8;
211 break;
212 default:
213 break;
214 }
215 }
216 }
217
218 return layout;
219}
220
Shuzhen Wang915115e2019-05-10 12:07:14 -0700221template<class M, class E>
222int HandleImporter::unlockInternal(const sp<M> mapper, buffer_handle_t& buf) {
223 int releaseFence = -1;
224 auto buffer = const_cast<native_handle_t*>(buf);
225
226 mapper->unlock(
227 buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) {
228 if (tmpError == E::NONE) {
229 auto fenceHandle = tmpReleaseFence.getNativeHandle();
230 if (fenceHandle) {
231 if (fenceHandle->numInts != 0 || fenceHandle->numFds != 1) {
232 ALOGE("%s: bad release fence numInts %d numFds %d",
233 __FUNCTION__, fenceHandle->numInts, fenceHandle->numFds);
234 return;
235 }
236 releaseFence = dup(fenceHandle->data[0]);
237 if (releaseFence < 0) {
238 ALOGE("%s: bad release fence FD %d",
239 __FUNCTION__, releaseFence);
240 }
241 }
242 } else {
243 ALOGE("%s: failed to unlock error %d!", __FUNCTION__, tmpError);
244 }
245 });
246 return releaseFence;
247}
248
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800249// In IComposer, any buffer_handle_t is owned by the caller and we need to
250// make a clone for hwcomposer2. We also need to translate empty handle
251// to nullptr. This function does that, in-place.
252bool HandleImporter::importBuffer(buffer_handle_t& handle) {
253 if (!handle->numFds && !handle->numInts) {
254 handle = nullptr;
255 return true;
256 }
257
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700258 Mutex::Autolock lock(mLock);
259 if (!mInitialized) {
260 initializeLocked();
261 }
262
Marissa Walla51eb932019-06-21 09:13:35 -0700263 if (mMapperV4 != nullptr) {
264 return importBufferInternal<IMapperV4, MapperErrorV4>(mMapperV4, handle);
265 }
266
Shuzhen Wang915115e2019-05-10 12:07:14 -0700267 if (mMapperV3 != nullptr) {
268 return importBufferInternal<IMapperV3, MapperErrorV3>(mMapperV3, handle);
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800269 }
270
Shuzhen Wang915115e2019-05-10 12:07:14 -0700271 if (mMapperV2 != nullptr) {
272 return importBufferInternal<IMapper, MapperErrorV2>(mMapperV2, handle);
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700273 }
274
Marissa Walla51eb932019-06-21 09:13:35 -0700275 ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
Shuzhen Wang915115e2019-05-10 12:07:14 -0700276 return false;
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800277}
278
279void HandleImporter::freeBuffer(buffer_handle_t handle) {
280 if (!handle) {
281 return;
282 }
283
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700284 Mutex::Autolock lock(mLock);
Yin-Chia Yeh97978fb2020-01-25 18:15:00 -0800285 if (!mInitialized) {
286 initializeLocked();
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700287 }
288
Marissa Walla51eb932019-06-21 09:13:35 -0700289 if (mMapperV4 != nullptr) {
290 auto ret = mMapperV4->freeBuffer(const_cast<native_handle_t*>(handle));
291 if (!ret.isOk()) {
292 ALOGE("%s: mapper freeBuffer failed: %s", __FUNCTION__, ret.description().c_str());
293 }
294 } else if (mMapperV3 != nullptr) {
Shuzhen Wang915115e2019-05-10 12:07:14 -0700295 auto ret = mMapperV3->freeBuffer(const_cast<native_handle_t*>(handle));
296 if (!ret.isOk()) {
297 ALOGE("%s: mapper freeBuffer failed: %s",
298 __FUNCTION__, ret.description().c_str());
299 }
300 } else {
301 auto ret = mMapperV2->freeBuffer(const_cast<native_handle_t*>(handle));
302 if (!ret.isOk()) {
303 ALOGE("%s: mapper freeBuffer failed: %s",
304 __FUNCTION__, ret.description().c_str());
305 }
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700306 }
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800307}
308
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700309bool HandleImporter::importFence(const native_handle_t* handle, int& fd) const {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800310 if (handle == nullptr || handle->numFds == 0) {
311 fd = -1;
312 } else if (handle->numFds == 1) {
313 fd = dup(handle->data[0]);
314 if (fd < 0) {
315 ALOGE("failed to dup fence fd %d", handle->data[0]);
316 return false;
317 }
318 } else {
319 ALOGE("invalid fence handle with %d file descriptors",
320 handle->numFds);
321 return false;
322 }
323
324 return true;
325}
326
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700327void HandleImporter::closeFence(int fd) const {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800328 if (fd >= 0) {
329 close(fd);
330 }
331}
332
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800333void* HandleImporter::lock(
334 buffer_handle_t& buf, uint64_t cpuUsage, size_t size) {
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700335 IMapper::Rect accessRegion{0, 0, static_cast<int>(size), 1};
336 return lock(buf, cpuUsage, accessRegion);
337}
338
339void* HandleImporter::lock(buffer_handle_t& buf, uint64_t cpuUsage,
340 const IMapper::Rect& accessRegion) {
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800341 Mutex::Autolock lock(mLock);
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800342
343 if (!mInitialized) {
344 initializeLocked();
345 }
346
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700347 void* ret = nullptr;
348
Marissa Walla51eb932019-06-21 09:13:35 -0700349 if (mMapperV4 == nullptr && mMapperV3 == nullptr && mMapperV2 == nullptr) {
350 ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800351 return ret;
352 }
353
354 hidl_handle acquireFenceHandle;
355 auto buffer = const_cast<native_handle_t*>(buf);
Marissa Walla51eb932019-06-21 09:13:35 -0700356 if (mMapperV4 != nullptr) {
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700357 IMapperV4::Rect accessRegionV4{accessRegion.left, accessRegion.top, accessRegion.width,
358 accessRegion.height};
359
360 mMapperV4->lock(buffer, cpuUsage, accessRegionV4, acquireFenceHandle,
Marissa Wall9c5ebfc2019-11-05 14:59:27 -0800361 [&](const auto& tmpError, const auto& tmpPtr) {
Marissa Walla51eb932019-06-21 09:13:35 -0700362 if (tmpError == MapperErrorV4::NONE) {
363 ret = tmpPtr;
364 } else {
365 ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
366 }
367 });
368 } else if (mMapperV3 != nullptr) {
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700369 IMapperV3::Rect accessRegionV3{accessRegion.left, accessRegion.top, accessRegion.width,
370 accessRegion.height};
371
372 mMapperV3->lock(buffer, cpuUsage, accessRegionV3, acquireFenceHandle,
373 [&](const auto& tmpError, const auto& tmpPtr, const auto& /*bytesPerPixel*/,
374 const auto& /*bytesPerStride*/) {
375 if (tmpError == MapperErrorV3::NONE) {
376 ret = tmpPtr;
377 } else {
378 ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
379 }
380 });
Shuzhen Wang915115e2019-05-10 12:07:14 -0700381 } else {
Shuzhen Wang915115e2019-05-10 12:07:14 -0700382 mMapperV2->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
383 [&](const auto& tmpError, const auto& tmpPtr) {
384 if (tmpError == MapperErrorV2::NONE) {
385 ret = tmpPtr;
386 } else {
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700387 ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
Shuzhen Wang915115e2019-05-10 12:07:14 -0700388 }
389 });
390 }
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800391
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700392 ALOGV("%s: ptr %p accessRegion.top: %d accessRegion.left: %d accessRegion.width: %d "
393 "accessRegion.height: %d",
394 __FUNCTION__, ret, accessRegion.top, accessRegion.left, accessRegion.width,
395 accessRegion.height);
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800396 return ret;
397}
398
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700399YCbCrLayout HandleImporter::lockYCbCr(
400 buffer_handle_t& buf, uint64_t cpuUsage,
401 const IMapper::Rect& accessRegion) {
402 Mutex::Autolock lock(mLock);
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700403
404 if (!mInitialized) {
405 initializeLocked();
406 }
407
Marissa Walla51eb932019-06-21 09:13:35 -0700408 if (mMapperV4 != nullptr) {
Jason Macnakeda6dca2020-04-15 15:20:59 -0700409 return lockYCbCrInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf, cpuUsage, accessRegion);
Marissa Walla51eb932019-06-21 09:13:35 -0700410 }
411
Shuzhen Wang915115e2019-05-10 12:07:14 -0700412 if (mMapperV3 != nullptr) {
413 return lockYCbCrInternal<IMapperV3, MapperErrorV3>(
414 mMapperV3, buf, cpuUsage, accessRegion);
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700415 }
416
Shuzhen Wang915115e2019-05-10 12:07:14 -0700417 if (mMapperV2 != nullptr) {
418 return lockYCbCrInternal<IMapper, MapperErrorV2>(
419 mMapperV2, buf, cpuUsage, accessRegion);
420 }
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700421
Marissa Walla51eb932019-06-21 09:13:35 -0700422 ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
Shuzhen Wang915115e2019-05-10 12:07:14 -0700423 return {};
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700424}
425
Emilian Peev6a2572b2021-05-24 16:51:17 -0700426status_t HandleImporter::getMonoPlanarStrideBytes(buffer_handle_t &buf, uint32_t *stride /*out*/) {
427 if (stride == nullptr) {
428 return BAD_VALUE;
429 }
430
431 Mutex::Autolock lock(mLock);
432
433 if (!mInitialized) {
434 initializeLocked();
435 }
436
437 if (mMapperV4 != nullptr) {
438 std::vector<PlaneLayout> planeLayouts = getPlaneLayouts(mMapperV4, buf);
439 if (planeLayouts.size() != 1) {
440 ALOGE("%s: Unexpected number of planes %zu!", __FUNCTION__, planeLayouts.size());
441 return BAD_VALUE;
442 }
443
444 *stride = planeLayouts[0].strideInBytes;
445 } else {
446 ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
447 return NO_INIT;
448 }
449
450 return OK;
451}
452
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700453int HandleImporter::unlock(buffer_handle_t& buf) {
Marissa Walla51eb932019-06-21 09:13:35 -0700454 if (mMapperV4 != nullptr) {
455 return unlockInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf);
456 }
Shuzhen Wang915115e2019-05-10 12:07:14 -0700457 if (mMapperV3 != nullptr) {
458 return unlockInternal<IMapperV3, MapperErrorV3>(mMapperV3, buf);
459 }
460 if (mMapperV2 != nullptr) {
461 return unlockInternal<IMapper, MapperErrorV2>(mMapperV2, buf);
462 }
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700463
Marissa Walla51eb932019-06-21 09:13:35 -0700464 ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
Shuzhen Wang915115e2019-05-10 12:07:14 -0700465 return -1;
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700466}
467
Emilian Peevb5f634f2021-12-13 15:13:46 -0800468bool HandleImporter::isSmpte2086Present(const buffer_handle_t& buf) {
469 Mutex::Autolock lock(mLock);
470
471 if (!mInitialized) {
472 initializeLocked();
473 }
474
475 if (mMapperV4 != nullptr) {
476 return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2086);
477 } else {
478 ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
479 }
480
481 return false;
482}
483
484bool HandleImporter::isSmpte2094_10Present(const buffer_handle_t& buf) {
485 Mutex::Autolock lock(mLock);
486
487 if (!mInitialized) {
488 initializeLocked();
489 }
490
491 if (mMapperV4 != nullptr) {
492 return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2094_10);
493 } else {
494 ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
495 }
496
497 return false;
498}
499
500bool HandleImporter::isSmpte2094_40Present(const buffer_handle_t& buf) {
501 Mutex::Autolock lock(mLock);
502
503 if (!mInitialized) {
504 initializeLocked();
505 }
506
507 if (mMapperV4 != nullptr) {
508 return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2094_40);
509 } else {
510 ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
511 }
512
513 return false;
514}
515
516
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800517} // namespace helper
518} // namespace V1_0
519} // namespace common
520} // namespace camera
521} // namespace hardware
522} // namespace android