blob: 1145baa5f150ddfbc8d4e8b4bcfd883a9b942b6e [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>
Michael Stokes49ba82c2023-10-02 09:56:59 +000022#include "aidl/android/hardware/graphics/common/Smpte2086.h"
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080023
24namespace android {
25namespace hardware {
26namespace camera {
27namespace common {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080028namespace 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 Peevdda1eb72022-07-28 16:37:40 -070033using aidl::android::hardware::graphics::common::Smpte2086;
Michael Stokes49ba82c2023-10-02 09:56:59 +000034using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType;
35using MapperErrorV2 = android::hardware::graphics::mapper::V2_0::Error;
36using MapperErrorV3 = android::hardware::graphics::mapper::V3_0::Error;
37using MapperErrorV4 = android::hardware::graphics::mapper::V4_0::Error;
38using IMapperV3 = android::hardware::graphics::mapper::V3_0::IMapper;
39using IMapperV4 = android::hardware::graphics::mapper::V4_0::IMapper;
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080040
Yin-Chia Yeh519c1672017-04-21 14:59:31 -070041HandleImporter::HandleImporter() : mInitialized(false) {}
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080042
Yin-Chia Yeh519c1672017-04-21 14:59:31 -070043void HandleImporter::initializeLocked() {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080044 if (mInitialized) {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080045 return;
46 }
47
Michael Stokes49ba82c2023-10-02 09:56:59 +000048 mMapperV4 = IMapperV4::getService();
49 if (mMapperV4 != nullptr) {
50 mInitialized = true;
51 return;
52 }
53
54 mMapperV3 = IMapperV3::getService();
55 if (mMapperV3 != nullptr) {
56 mInitialized = true;
57 return;
58 }
59
60 mMapperV2 = IMapper::getService();
61 if (mMapperV2 == nullptr) {
62 ALOGE("%s: cannnot acccess graphics mapper HAL!", __FUNCTION__);
63 return;
64 }
65
Yin-Chia Yeh519c1672017-04-21 14:59:31 -070066 mInitialized = true;
67 return;
68}
69
70void HandleImporter::cleanup() {
Michael Stokes49ba82c2023-10-02 09:56:59 +000071 mMapperV4.clear();
72 mMapperV3.clear();
73 mMapperV2.clear();
Yin-Chia Yeh248ed702017-01-23 17:27:26 -080074 mInitialized = false;
75}
76
Michael Stokes49ba82c2023-10-02 09:56:59 +000077template <class M, class E>
78bool HandleImporter::importBufferInternal(const sp<M> mapper, buffer_handle_t& handle) {
79 E error;
Shuzhen Wang915115e2019-05-10 12:07:14 -070080 buffer_handle_t importedHandle;
Michael Stokes49ba82c2023-10-02 09:56:59 +000081 auto ret = mapper->importBuffer(
82 hidl_handle(handle), [&](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", __FUNCTION__, ret.description().c_str());
89 return false;
90 }
91
92 if (error != E::NONE) {
Shuzhen Wang915115e2019-05-10 12:07:14 -070093 return false;
94 }
95
96 handle = importedHandle;
97 return true;
98}
99
Michael Stokes49ba82c2023-10-02 09:56:59 +0000100template <class M, class E>
101YCbCrLayout HandleImporter::lockYCbCrInternal(const sp<M> mapper, buffer_handle_t& buf,
102 uint64_t cpuUsage,
103 const IMapper::Rect& accessRegion) {
104 hidl_handle acquireFenceHandle;
105 auto buffer = const_cast<native_handle_t*>(buf);
106 YCbCrLayout layout = {};
Shuzhen Wang915115e2019-05-10 12:07:14 -0700107
Michael Stokes49ba82c2023-10-02 09:56:59 +0000108 typename M::Rect accessRegionCopy = {accessRegion.left, accessRegion.top, accessRegion.width,
109 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
127bool isMetadataPesent(const sp<IMapperV4> mapper, const buffer_handle_t& buf,
128 MetadataType metadataType) {
129 auto buffer = const_cast<native_handle_t*>(buf);
130 bool ret = false;
131 hidl_vec<uint8_t> vec;
132 mapper->get(buffer, metadataType, [&](const auto& tmpError, const auto& tmpMetadata) {
133 if (tmpError == MapperErrorV4::NONE) {
134 vec = tmpMetadata;
135 } else {
136 ALOGE("%s: failed to get metadata %d!", __FUNCTION__, tmpError);
137 }
138 });
139
140 if (vec.size() > 0) {
141 if (metadataType == gralloc4::MetadataType_Smpte2086) {
142 std::optional<Smpte2086> realSmpte2086;
143 gralloc4::decodeSmpte2086(vec, &realSmpte2086);
144 ret = realSmpte2086.has_value();
145 } else if (metadataType == gralloc4::MetadataType_Smpte2094_10) {
146 std::optional<std::vector<uint8_t>> realSmpte2094_10;
147 gralloc4::decodeSmpte2094_10(vec, &realSmpte2094_10);
148 ret = realSmpte2094_10.has_value();
149 } else if (metadataType == gralloc4::MetadataType_Smpte2094_40) {
150 std::optional<std::vector<uint8_t>> realSmpte2094_40;
151 gralloc4::decodeSmpte2094_40(vec, &realSmpte2094_40);
152 ret = realSmpte2094_40.has_value();
153 } else {
154 ALOGE("%s: Unknown metadata type!", __FUNCTION__);
155 }
Devin Moore5e154092023-09-13 16:18:30 +0000156 }
Devin Moore5e154092023-09-13 16:18:30 +0000157
Michael Stokes49ba82c2023-10-02 09:56:59 +0000158 return ret;
159}
Devin Moore5e154092023-09-13 16:18:30 +0000160
Michael Stokes49ba82c2023-10-02 09:56:59 +0000161std::vector<PlaneLayout> getPlaneLayouts(const sp<IMapperV4> mapper, buffer_handle_t& buf) {
162 auto buffer = const_cast<native_handle_t*>(buf);
163 std::vector<PlaneLayout> planeLayouts;
164 hidl_vec<uint8_t> encodedPlaneLayouts;
165 mapper->get(buffer, gralloc4::MetadataType_PlaneLayouts,
166 [&](const auto& tmpError, const auto& tmpEncodedPlaneLayouts) {
167 if (tmpError == MapperErrorV4::NONE) {
168 encodedPlaneLayouts = tmpEncodedPlaneLayouts;
169 } else {
170 ALOGE("%s: failed to get plane layouts %d!", __FUNCTION__, tmpError);
171 }
172 });
173
174 gralloc4::decodePlaneLayouts(encodedPlaneLayouts, &planeLayouts);
175
176 return planeLayouts;
177}
178
179template <>
180YCbCrLayout HandleImporter::lockYCbCrInternal<IMapperV4, MapperErrorV4>(
181 const sp<IMapperV4> mapper, buffer_handle_t& buf, uint64_t cpuUsage,
182 const IMapper::Rect& accessRegion) {
183 hidl_handle acquireFenceHandle;
184 auto buffer = const_cast<native_handle_t*>(buf);
185 YCbCrLayout layout = {};
186 void* mapped = nullptr;
187
188 typename IMapperV4::Rect accessRegionV4 = {accessRegion.left, accessRegion.top,
189 accessRegion.width, accessRegion.height};
190 mapper->lock(buffer, cpuUsage, accessRegionV4, acquireFenceHandle,
191 [&](const auto& tmpError, const auto& tmpPtr) {
192 if (tmpError == MapperErrorV4::NONE) {
193 mapped = tmpPtr;
194 } else {
195 ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
196 }
197 });
198
199 if (mapped == nullptr) {
200 return layout;
201 }
202
203 std::vector<PlaneLayout> planeLayouts = getPlaneLayouts(mapper, buf);
204 for (const auto& planeLayout : planeLayouts) {
205 for (const auto& planeLayoutComponent : planeLayout.components) {
206 const auto& type = planeLayoutComponent.type;
207
208 if (!gralloc4::isStandardPlaneLayoutComponentType(type)) {
209 continue;
210 }
211
212 uint8_t* data = reinterpret_cast<uint8_t*>(mapped);
213 data += planeLayout.offsetInBytes;
214 data += planeLayoutComponent.offsetInBits / 8;
215
216 switch (static_cast<PlaneLayoutComponentType>(type.value)) {
217 case PlaneLayoutComponentType::Y:
218 layout.y = data;
219 layout.yStride = planeLayout.strideInBytes;
220 break;
221 case PlaneLayoutComponentType::CB:
222 layout.cb = data;
223 layout.cStride = planeLayout.strideInBytes;
224 layout.chromaStep = planeLayout.sampleIncrementInBits / 8;
225 break;
226 case PlaneLayoutComponentType::CR:
227 layout.cr = data;
228 layout.cStride = planeLayout.strideInBytes;
229 layout.chromaStep = planeLayout.sampleIncrementInBits / 8;
230 break;
231 default:
232 break;
233 }
234 }
Devin Moore5e154092023-09-13 16:18:30 +0000235 }
236
Shuzhen Wang915115e2019-05-10 12:07:14 -0700237 return layout;
238}
239
Michael Stokes49ba82c2023-10-02 09:56:59 +0000240template <class M, class E>
241int HandleImporter::unlockInternal(const sp<M> mapper, buffer_handle_t& buf) {
242 int releaseFence = -1;
243 auto buffer = const_cast<native_handle_t*>(buf);
Emilian Peev6a2572b2021-05-24 16:51:17 -0700244
Michael Stokes49ba82c2023-10-02 09:56:59 +0000245 mapper->unlock(buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) {
246 if (tmpError == E::NONE) {
247 auto fenceHandle = tmpReleaseFence.getNativeHandle();
248 if (fenceHandle) {
249 if (fenceHandle->numInts != 0 || fenceHandle->numFds != 1) {
250 ALOGE("%s: bad release fence numInts %d numFds %d", __FUNCTION__,
251 fenceHandle->numInts, fenceHandle->numFds);
252 return;
253 }
254 releaseFence = dup(fenceHandle->data[0]);
255 if (releaseFence < 0) {
256 ALOGE("%s: bad release fence FD %d", __FUNCTION__, releaseFence);
257 }
258 }
259 } else {
260 ALOGE("%s: failed to unlock error %d!", __FUNCTION__, tmpError);
261 }
262 });
263 return releaseFence;
Emilian Peev6a2572b2021-05-24 16:51:17 -0700264}
265
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800266// In IComposer, any buffer_handle_t is owned by the caller and we need to
267// make a clone for hwcomposer2. We also need to translate empty handle
268// to nullptr. This function does that, in-place.
269bool HandleImporter::importBuffer(buffer_handle_t& handle) {
270 if (!handle->numFds && !handle->numInts) {
271 handle = nullptr;
272 return true;
273 }
274
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700275 Mutex::Autolock lock(mLock);
276 if (!mInitialized) {
277 initializeLocked();
278 }
279
Michael Stokes49ba82c2023-10-02 09:56:59 +0000280 if (mMapperV4 != nullptr) {
281 return importBufferInternal<IMapperV4, MapperErrorV4>(mMapperV4, handle);
282 }
283
284 if (mMapperV3 != nullptr) {
285 return importBufferInternal<IMapperV3, MapperErrorV3>(mMapperV3, handle);
286 }
287
288 if (mMapperV2 != nullptr) {
289 return importBufferInternal<IMapper, MapperErrorV2>(mMapperV2, handle);
290 }
291
292 ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
293 return false;
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800294}
295
296void HandleImporter::freeBuffer(buffer_handle_t handle) {
297 if (!handle) {
298 return;
299 }
300
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700301 Mutex::Autolock lock(mLock);
Yin-Chia Yeh97978fb2020-01-25 18:15:00 -0800302 if (!mInitialized) {
303 initializeLocked();
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700304 }
305
Michael Stokes49ba82c2023-10-02 09:56:59 +0000306 if (mMapperV4 != nullptr) {
307 auto ret = mMapperV4->freeBuffer(const_cast<native_handle_t*>(handle));
308 if (!ret.isOk()) {
309 ALOGE("%s: mapper freeBuffer failed: %s", __FUNCTION__, ret.description().c_str());
310 }
311 } else if (mMapperV3 != nullptr) {
312 auto ret = mMapperV3->freeBuffer(const_cast<native_handle_t*>(handle));
313 if (!ret.isOk()) {
314 ALOGE("%s: mapper freeBuffer failed: %s", __FUNCTION__, ret.description().c_str());
315 }
316 } else {
317 auto ret = mMapperV2->freeBuffer(const_cast<native_handle_t*>(handle));
318 if (!ret.isOk()) {
319 ALOGE("%s: mapper freeBuffer failed: %s", __FUNCTION__, ret.description().c_str());
320 }
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700321 }
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800322}
323
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700324bool HandleImporter::importFence(const native_handle_t* handle, int& fd) const {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800325 if (handle == nullptr || handle->numFds == 0) {
326 fd = -1;
327 } else if (handle->numFds == 1) {
328 fd = dup(handle->data[0]);
329 if (fd < 0) {
330 ALOGE("failed to dup fence fd %d", handle->data[0]);
331 return false;
332 }
333 } else {
Avichal Rakesh0d2d8a42022-06-14 17:23:40 -0700334 ALOGE("invalid fence handle with %d file descriptors", handle->numFds);
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800335 return false;
336 }
337
338 return true;
339}
340
Yin-Chia Yeh519c1672017-04-21 14:59:31 -0700341void HandleImporter::closeFence(int fd) const {
Yin-Chia Yeh248ed702017-01-23 17:27:26 -0800342 if (fd >= 0) {
343 close(fd);
344 }
345}
346
Avichal Rakesh0d2d8a42022-06-14 17:23:40 -0700347void* HandleImporter::lock(buffer_handle_t& buf, uint64_t cpuUsage, size_t size) {
Michael Stokes49ba82c2023-10-02 09:56:59 +0000348 IMapper::Rect accessRegion{0, 0, static_cast<int>(size), 1};
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700349 return lock(buf, cpuUsage, accessRegion);
350}
351
352void* HandleImporter::lock(buffer_handle_t& buf, uint64_t cpuUsage,
Michael Stokes49ba82c2023-10-02 09:56:59 +0000353 const IMapper::Rect& accessRegion) {
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800354 Mutex::Autolock lock(mLock);
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800355
356 if (!mInitialized) {
357 initializeLocked();
358 }
359
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700360 void* ret = nullptr;
Michael Stokes49ba82c2023-10-02 09:56:59 +0000361
362 if (mMapperV4 == nullptr && mMapperV3 == nullptr && mMapperV2 == nullptr) {
363 ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
364 return ret;
365 }
366
367 hidl_handle acquireFenceHandle;
368 auto buffer = const_cast<native_handle_t*>(buf);
369 if (mMapperV4 != nullptr) {
370 IMapperV4::Rect accessRegionV4{accessRegion.left, accessRegion.top, accessRegion.width,
371 accessRegion.height};
372
373 mMapperV4->lock(buffer, cpuUsage, accessRegionV4, acquireFenceHandle,
374 [&](const auto& tmpError, const auto& tmpPtr) {
375 if (tmpError == MapperErrorV4::NONE) {
376 ret = tmpPtr;
377 } else {
378 ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
379 }
380 });
381 } else if (mMapperV3 != nullptr) {
382 IMapperV3::Rect accessRegionV3{accessRegion.left, accessRegion.top, accessRegion.width,
383 accessRegion.height};
384
385 mMapperV3->lock(buffer, cpuUsage, accessRegionV3, acquireFenceHandle,
386 [&](const auto& tmpError, const auto& tmpPtr, const auto& /*bytesPerPixel*/,
387 const auto& /*bytesPerStride*/) {
388 if (tmpError == MapperErrorV3::NONE) {
389 ret = tmpPtr;
390 } else {
391 ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
392 }
393 });
394 } else {
395 mMapperV2->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
396 [&](const auto& tmpError, const auto& tmpPtr) {
397 if (tmpError == MapperErrorV2::NONE) {
398 ret = tmpPtr;
399 } else {
400 ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
401 }
402 });
Shuzhen Wang915115e2019-05-10 12:07:14 -0700403 }
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800404
Jason Macnakf2c9ed12020-04-20 14:43:58 -0700405 ALOGV("%s: ptr %p accessRegion.top: %d accessRegion.left: %d accessRegion.width: %d "
406 "accessRegion.height: %d",
Michael Stokes49ba82c2023-10-02 09:56:59 +0000407 __FUNCTION__, ret, accessRegion.top, accessRegion.left, accessRegion.width,
408 accessRegion.height);
Yuriy Romanenkod0bd4f12018-01-19 16:00:00 -0800409 return ret;
410}
411
Michael Stokes49ba82c2023-10-02 09:56:59 +0000412YCbCrLayout HandleImporter::lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage,
413 const IMapper::Rect& accessRegion) {
414 Mutex::Autolock lock(mLock);
415
416 if (!mInitialized) {
417 initializeLocked();
418 }
419
420 if (mMapperV4 != nullptr) {
421 return lockYCbCrInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf, cpuUsage, accessRegion);
422 }
423
424 if (mMapperV3 != nullptr) {
425 return lockYCbCrInternal<IMapperV3, MapperErrorV3>(mMapperV3, buf, cpuUsage, accessRegion);
426 }
427
428 if (mMapperV2 != nullptr) {
429 return lockYCbCrInternal<IMapper, MapperErrorV2>(mMapperV2, buf, cpuUsage, accessRegion);
430 }
431
432 ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
433 return {};
434}
435
Avichal Rakesh0d2d8a42022-06-14 17:23:40 -0700436status_t HandleImporter::getMonoPlanarStrideBytes(buffer_handle_t& buf, uint32_t* stride /*out*/) {
Emilian Peev6a2572b2021-05-24 16:51:17 -0700437 if (stride == nullptr) {
438 return BAD_VALUE;
439 }
440
441 Mutex::Autolock lock(mLock);
442
443 if (!mInitialized) {
444 initializeLocked();
445 }
446
Michael Stokes49ba82c2023-10-02 09:56:59 +0000447 if (mMapperV4 != nullptr) {
448 std::vector<PlaneLayout> planeLayouts = getPlaneLayouts(mMapperV4, buf);
449 if (planeLayouts.size() != 1) {
450 ALOGE("%s: Unexpected number of planes %zu!", __FUNCTION__, planeLayouts.size());
451 return BAD_VALUE;
452 }
Emilian Peev6a2572b2021-05-24 16:51:17 -0700453
Michael Stokes49ba82c2023-10-02 09:56:59 +0000454 *stride = planeLayouts[0].strideInBytes;
455 } else {
456 ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
457 return NO_INIT;
458 }
Devin Moore5e154092023-09-13 16:18:30 +0000459
Emilian Peev6a2572b2021-05-24 16:51:17 -0700460 return OK;
461}
462
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700463int HandleImporter::unlock(buffer_handle_t& buf) {
Michael Stokes49ba82c2023-10-02 09:56:59 +0000464 if (mMapperV4 != nullptr) {
465 return unlockInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf);
466 }
467 if (mMapperV3 != nullptr) {
468 return unlockInternal<IMapperV3, MapperErrorV3>(mMapperV3, buf);
469 }
470 if (mMapperV2 != nullptr) {
471 return unlockInternal<IMapper, MapperErrorV2>(mMapperV2, buf);
Shuzhen Wang915115e2019-05-10 12:07:14 -0700472 }
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700473
Michael Stokes49ba82c2023-10-02 09:56:59 +0000474 ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
475 return -1;
Yin-Chia Yeh19030592017-10-19 17:30:11 -0700476}
477
Emilian Peevb5f634f2021-12-13 15:13:46 -0800478bool HandleImporter::isSmpte2086Present(const buffer_handle_t& buf) {
479 Mutex::Autolock lock(mLock);
480
481 if (!mInitialized) {
482 initializeLocked();
483 }
Michael Stokes49ba82c2023-10-02 09:56:59 +0000484
485 if (mMapperV4 != nullptr) {
486 return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2086);
487 } else {
488 ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
Emilian Peevb5f634f2021-12-13 15:13:46 -0800489 }
490
Michael Stokes49ba82c2023-10-02 09:56:59 +0000491 return false;
Emilian Peevb5f634f2021-12-13 15:13:46 -0800492}
493
494bool HandleImporter::isSmpte2094_10Present(const buffer_handle_t& buf) {
495 Mutex::Autolock lock(mLock);
496
497 if (!mInitialized) {
498 initializeLocked();
499 }
500
Michael Stokes49ba82c2023-10-02 09:56:59 +0000501 if (mMapperV4 != nullptr) {
502 return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2094_10);
503 } else {
504 ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
Emilian Peevb5f634f2021-12-13 15:13:46 -0800505 }
506
Michael Stokes49ba82c2023-10-02 09:56:59 +0000507 return false;
Emilian Peevb5f634f2021-12-13 15:13:46 -0800508}
509
510bool HandleImporter::isSmpte2094_40Present(const buffer_handle_t& buf) {
511 Mutex::Autolock lock(mLock);
512
513 if (!mInitialized) {
514 initializeLocked();
515 }
516
Michael Stokes49ba82c2023-10-02 09:56:59 +0000517 if (mMapperV4 != nullptr) {
518 return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2094_40);
519 } else {
520 ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
Emilian Peevb5f634f2021-12-13 15:13:46 -0800521 }
522
Michael Stokes49ba82c2023-10-02 09:56:59 +0000523 return false;
Emilian Peevb5f634f2021-12-13 15:13:46 -0800524}
525
Avichal Rakesh0d2d8a42022-06-14 17:23:40 -0700526} // namespace helper
527} // namespace common
528} // namespace camera
529} // namespace hardware
530} // namespace android