Merge "Implement lockYCbCr stub for Mapper 4.0" into rvc-dev am: 2540a38771

Change-Id: Ibc26e18659cb3bfd7b4b0ac0a2ae797f90fafc7e
This commit is contained in:
Jason Macnak 2020-05-14 21:38:30 +00:00 committed by Automerger Merge Worker
commit 6313157f6b
8 changed files with 117 additions and 34 deletions

View file

@ -8,7 +8,7 @@ cc_library_static {
"CameraParameters.cpp",
"VendorTagDescriptor.cpp",
"HandleImporter.cpp",
"Exif.cpp"
"Exif.cpp",
],
cflags: [
"-Werror",
@ -17,6 +17,7 @@ cc_library_static {
],
shared_libs: [
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
"android.hardware.graphics.mapper@2.0",
@ -25,6 +26,5 @@ cc_library_static {
"libexif",
],
include_dirs: ["system/media/private/camera/include"],
export_include_dirs : ["include"]
export_include_dirs: ["include"],
}

View file

@ -16,6 +16,8 @@
#define LOG_TAG "HandleImporter"
#include "HandleImporter.h"
#include <gralloctypes/Gralloc4.h>
#include <log/log.h>
namespace android {
@ -25,6 +27,9 @@ namespace common {
namespace V1_0 {
namespace helper {
using aidl::android::hardware::graphics::common::PlaneLayout;
using aidl::android::hardware::graphics::common::PlaneLayoutComponent;
using aidl::android::hardware::graphics::common::PlaneLayoutComponentType;
using MapperErrorV2 = android::hardware::graphics::mapper::V2_0::Error;
using MapperErrorV3 = android::hardware::graphics::mapper::V3_0::Error;
using MapperErrorV4 = android::hardware::graphics::mapper::V4_0::Error;
@ -118,6 +123,79 @@ YCbCrLayout HandleImporter::lockYCbCrInternal(const sp<M> mapper, buffer_handle_
return layout;
}
template <>
YCbCrLayout HandleImporter::lockYCbCrInternal<IMapperV4, MapperErrorV4>(
const sp<IMapperV4> mapper, buffer_handle_t& buf, uint64_t cpuUsage,
const IMapper::Rect& accessRegion) {
hidl_handle acquireFenceHandle;
auto buffer = const_cast<native_handle_t*>(buf);
YCbCrLayout layout = {};
void* mapped = nullptr;
typename IMapperV4::Rect accessRegionV4 = {accessRegion.left, accessRegion.top,
accessRegion.width, accessRegion.height};
mapper->lock(buffer, cpuUsage, accessRegionV4, acquireFenceHandle,
[&](const auto& tmpError, const auto& tmpPtr) {
if (tmpError == MapperErrorV4::NONE) {
mapped = tmpPtr;
} else {
ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError);
}
});
if (mapped == nullptr) {
return layout;
}
hidl_vec<uint8_t> encodedPlaneLayouts;
mapper->get(buffer, gralloc4::MetadataType_PlaneLayouts,
[&](const auto& tmpError, const auto& tmpEncodedPlaneLayouts) {
if (tmpError == MapperErrorV4::NONE) {
encodedPlaneLayouts = tmpEncodedPlaneLayouts;
} else {
ALOGE("%s: failed to get plane layouts %d!", __FUNCTION__, tmpError);
}
});
std::vector<PlaneLayout> planeLayouts;
gralloc4::decodePlaneLayouts(encodedPlaneLayouts, &planeLayouts);
for (const auto& planeLayout : planeLayouts) {
for (const auto& planeLayoutComponent : planeLayout.components) {
const auto& type = planeLayoutComponent.type;
if (!gralloc4::isStandardPlaneLayoutComponentType(type)) {
continue;
}
uint8_t* data = reinterpret_cast<uint8_t*>(mapped);
data += planeLayout.offsetInBytes;
data += planeLayoutComponent.offsetInBits / 8;
switch (static_cast<PlaneLayoutComponentType>(type.value)) {
case PlaneLayoutComponentType::Y:
layout.y = data;
layout.yStride = planeLayout.strideInBytes;
break;
case PlaneLayoutComponentType::CB:
layout.cb = data;
layout.cStride = planeLayout.strideInBytes;
layout.chromaStep = planeLayout.sampleIncrementInBits / 8;
break;
case PlaneLayoutComponentType::CR:
layout.cr = data;
layout.cStride = planeLayout.strideInBytes;
layout.chromaStep = planeLayout.sampleIncrementInBits / 8;
break;
default:
break;
}
}
}
return layout;
}
template<class M, class E>
int HandleImporter::unlockInternal(const sp<M> mapper, buffer_handle_t& buf) {
int releaseFence = -1;
@ -306,13 +384,7 @@ YCbCrLayout HandleImporter::lockYCbCr(
}
if (mMapperV4 != nullptr) {
// No device currently supports IMapper 4.0 so it is safe to just return an error code here.
//
// This will be supported by a combination of lock and BufferMetadata getters. We are going
// to refactor all the IAllocator/IMapper versioning code into a shared library. We will
// then add the IMapper 4.0 lockYCbCr support then.
ALOGE("%s: MapperV4 doesn't support lockYCbCr directly!", __FUNCTION__);
return {};
return lockYCbCrInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf, cpuUsage, accessRegion);
}
if (mMapperV3 != nullptr) {

View file

@ -20,15 +20,15 @@ cc_library_shared {
"android.hidl.memory@1.0",
"libcutils",
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
],
static_libs: [
"android.hardware.camera.common@1.0-helper"
"android.hardware.camera.common@1.0-helper",
],
header_libs: [
"media_plugin_headers",
],
export_include_dirs: ["."]
export_include_dirs: ["."],
}

View file

@ -2,9 +2,11 @@ cc_library_shared {
name: "camera.device@3.2-impl",
defaults: ["hidl_defaults"],
proprietary: true,
srcs: ["CameraDevice.cpp",
"CameraDeviceSession.cpp",
"convert.cpp"],
srcs: [
"CameraDevice.cpp",
"CameraDeviceSession.cpp",
"convert.cpp",
],
shared_libs: [
"libhidlbase",
"libutils",
@ -15,15 +17,16 @@ cc_library_shared {
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
"libfmq"
"libfmq",
],
static_libs: [
"android.hardware.camera.common@1.0-helper"
"android.hardware.camera.common@1.0-helper",
],
export_include_dirs: ["."],
export_shared_lib_headers: [
"libfmq",
]
],
}

View file

@ -2,9 +2,11 @@ cc_library_shared {
name: "camera.device@3.3-impl",
defaults: ["hidl_defaults"],
proprietary: true,
srcs: ["CameraDevice.cpp",
"CameraDeviceSession.cpp",
"convert.cpp"],
srcs: [
"CameraDevice.cpp",
"CameraDeviceSession.cpp",
"convert.cpp",
],
shared_libs: [
"libhidlbase",
"libutils",
@ -17,15 +19,16 @@ cc_library_shared {
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
"libfmq"
"libfmq",
],
static_libs: [
"android.hardware.camera.common@1.0-helper"
"android.hardware.camera.common@1.0-helper",
],
export_include_dirs: ["."],
export_shared_lib_headers: [
"libfmq",
]
],
}

View file

@ -17,13 +17,13 @@
cc_library_headers {
name: "camera.device@3.4-impl_headers",
vendor: true,
export_include_dirs: ["include/device_v3_4_impl"]
export_include_dirs: ["include/device_v3_4_impl"],
}
cc_library_headers {
name: "camera.device@3.4-external-impl_headers",
vendor: true,
export_include_dirs: ["include/ext_device_v3_4_impl"]
export_include_dirs: ["include/ext_device_v3_4_impl"],
}
cc_library_shared {
@ -34,7 +34,7 @@ cc_library_shared {
srcs: [
"CameraDevice.cpp",
"CameraDeviceSession.cpp",
"convert.cpp"
"convert.cpp",
],
shared_libs: [
"libhidlbase",
@ -50,6 +50,7 @@ cc_library_shared {
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
"libfmq",
@ -87,6 +88,7 @@ cc_library_shared {
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
"libfmq",
@ -94,7 +96,7 @@ cc_library_shared {
"libyuv",
"libjpeg",
"libexif",
"libtinyxml2"
"libtinyxml2",
],
static_libs: [
"android.hardware.camera.common@1.0-helper",

View file

@ -17,13 +17,13 @@
cc_library_headers {
name: "camera.device@3.5-impl_headers",
vendor: true,
export_include_dirs: ["include/device_v3_5_impl"]
export_include_dirs: ["include/device_v3_5_impl"],
}
cc_library_headers {
name: "camera.device@3.5-external-impl_headers",
vendor: true,
export_include_dirs: ["include/ext_device_v3_5_impl"]
export_include_dirs: ["include/ext_device_v3_5_impl"],
}
cc_library_shared {
@ -51,6 +51,7 @@ cc_library_shared {
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
],
@ -85,6 +86,7 @@ cc_library_shared {
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
"libfmq",
@ -92,7 +94,7 @@ cc_library_shared {
"libyuv",
"libjpeg",
"libexif",
"libtinyxml2"
"libtinyxml2",
],
static_libs: [
"android.hardware.camera.common@1.0-helper",

View file

@ -17,7 +17,7 @@
cc_library_headers {
name: "camera.device@3.6-external-impl_headers",
vendor: true,
export_include_dirs: ["include/ext_device_v3_6_impl"]
export_include_dirs: ["include/ext_device_v3_6_impl"],
}
cc_library_shared {
@ -48,6 +48,7 @@ cc_library_shared {
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"liblog",
"libgralloctypes",
"libhardware",
"libcamera_metadata",
"libfmq",
@ -55,7 +56,7 @@ cc_library_shared {
"libyuv",
"libjpeg",
"libexif",
"libtinyxml2"
"libtinyxml2",
],
static_libs: [
"android.hardware.camera.common@1.0-helper",