mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 20:24:19 +00:00
Merge "Adds a lock method to HandleImporter w/ access region" into rvc-dev am: 26b2e0b708 am: ae7d2186e8
Change-Id: I2ffe034e964e86e8ae666c093ae2278ee3d5c33d
This commit is contained in:
@@ -232,13 +232,20 @@ void HandleImporter::closeFence(int fd) const {
|
|||||||
|
|
||||||
void* HandleImporter::lock(
|
void* HandleImporter::lock(
|
||||||
buffer_handle_t& buf, uint64_t cpuUsage, size_t size) {
|
buffer_handle_t& buf, uint64_t cpuUsage, size_t size) {
|
||||||
|
IMapper::Rect accessRegion{0, 0, static_cast<int>(size), 1};
|
||||||
|
return lock(buf, cpuUsage, accessRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* HandleImporter::lock(buffer_handle_t& buf, uint64_t cpuUsage,
|
||||||
|
const IMapper::Rect& accessRegion) {
|
||||||
Mutex::Autolock lock(mLock);
|
Mutex::Autolock lock(mLock);
|
||||||
void *ret = 0;
|
|
||||||
|
|
||||||
if (!mInitialized) {
|
if (!mInitialized) {
|
||||||
initializeLocked();
|
initializeLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* ret = nullptr;
|
||||||
|
|
||||||
if (mMapperV4 == nullptr && mMapperV3 == nullptr && mMapperV2 == nullptr) {
|
if (mMapperV4 == nullptr && mMapperV3 == nullptr && mMapperV2 == nullptr) {
|
||||||
ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
|
ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -247,10 +254,10 @@ void* HandleImporter::lock(
|
|||||||
hidl_handle acquireFenceHandle;
|
hidl_handle acquireFenceHandle;
|
||||||
auto buffer = const_cast<native_handle_t*>(buf);
|
auto buffer = const_cast<native_handle_t*>(buf);
|
||||||
if (mMapperV4 != nullptr) {
|
if (mMapperV4 != nullptr) {
|
||||||
IMapperV4::Rect accessRegion{0, 0, static_cast<int>(size), 1};
|
IMapperV4::Rect accessRegionV4{accessRegion.left, accessRegion.top, accessRegion.width,
|
||||||
// No need to use bytesPerPixel and bytesPerStride because we are using
|
accessRegion.height};
|
||||||
// an 1-D buffer and accressRegion.
|
|
||||||
mMapperV4->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
|
mMapperV4->lock(buffer, cpuUsage, accessRegionV4, acquireFenceHandle,
|
||||||
[&](const auto& tmpError, const auto& tmpPtr) {
|
[&](const auto& tmpError, const auto& tmpPtr) {
|
||||||
if (tmpError == MapperErrorV4::NONE) {
|
if (tmpError == MapperErrorV4::NONE) {
|
||||||
ret = tmpPtr;
|
ret = tmpPtr;
|
||||||
@@ -259,33 +266,33 @@ void* HandleImporter::lock(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (mMapperV3 != nullptr) {
|
} else if (mMapperV3 != nullptr) {
|
||||||
IMapperV3::Rect accessRegion { 0, 0, static_cast<int>(size), 1 };
|
IMapperV3::Rect accessRegionV3{accessRegion.left, accessRegion.top, accessRegion.width,
|
||||||
// No need to use bytesPerPixel and bytesPerStride because we are using
|
accessRegion.height};
|
||||||
// an 1-D buffer and accressRegion.
|
|
||||||
mMapperV3->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
|
mMapperV3->lock(buffer, cpuUsage, accessRegionV3, acquireFenceHandle,
|
||||||
[&](const auto& tmpError, const auto& tmpPtr, const auto& /*bytesPerPixel*/,
|
[&](const auto& tmpError, const auto& tmpPtr, const auto& /*bytesPerPixel*/,
|
||||||
const auto& /*bytesPerStride*/) {
|
const auto& /*bytesPerStride*/) {
|
||||||
if (tmpError == MapperErrorV3::NONE) {
|
if (tmpError == MapperErrorV3::NONE) {
|
||||||
ret = tmpPtr;
|
ret = tmpPtr;
|
||||||
} else {
|
} else {
|
||||||
ALOGE("%s: failed to lock error %d!",
|
ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
|
||||||
__FUNCTION__, tmpError);
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
IMapper::Rect accessRegion { 0, 0, static_cast<int>(size), 1 };
|
|
||||||
mMapperV2->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
|
mMapperV2->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle,
|
||||||
[&](const auto& tmpError, const auto& tmpPtr) {
|
[&](const auto& tmpError, const auto& tmpPtr) {
|
||||||
if (tmpError == MapperErrorV2::NONE) {
|
if (tmpError == MapperErrorV2::NONE) {
|
||||||
ret = tmpPtr;
|
ret = tmpPtr;
|
||||||
} else {
|
} else {
|
||||||
ALOGE("%s: failed to lock error %d!",
|
ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
|
||||||
__FUNCTION__, tmpError);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ALOGV("%s: ptr %p size: %zu", __FUNCTION__, ret, size);
|
ALOGV("%s: ptr %p accessRegion.top: %d accessRegion.left: %d accessRegion.width: %d "
|
||||||
|
"accessRegion.height: %d",
|
||||||
|
__FUNCTION__, ret, accessRegion.top, accessRegion.left, accessRegion.width,
|
||||||
|
accessRegion.height);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,13 @@ public:
|
|||||||
bool importFence(const native_handle_t* handle, int& fd) const;
|
bool importFence(const native_handle_t* handle, int& fd) const;
|
||||||
void closeFence(int fd) const;
|
void closeFence(int fd) const;
|
||||||
|
|
||||||
// Assume caller has done waiting for acquire fences
|
// Locks 1-D buffer. Assumes caller has waited for acquire fences.
|
||||||
void* lock(buffer_handle_t& buf, uint64_t cpuUsage, size_t size);
|
void* lock(buffer_handle_t& buf, uint64_t cpuUsage, size_t size);
|
||||||
|
|
||||||
// Assume caller has done waiting for acquire fences
|
// Locks 2-D buffer. Assumes caller has waited for acquire fences.
|
||||||
|
void* lock(buffer_handle_t& buf, uint64_t cpuUsage, const IMapper::Rect& accessRegion);
|
||||||
|
|
||||||
|
// Assumes caller has waited for acquire fences.
|
||||||
YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage,
|
YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage,
|
||||||
const IMapper::Rect& accessRegion);
|
const IMapper::Rect& accessRegion);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user