Merge "camera: Map between legacy gralloc0 usage, and HIDL gralloc1 usages" into oc-dev
This commit is contained in:
commit
4cea813a35
10 changed files with 56 additions and 18 deletions
|
@ -17,7 +17,6 @@
|
|||
package android.hardware.camera.device@1.0;
|
||||
|
||||
import android.hardware.camera.common@1.0::types;
|
||||
import android.hardware.graphics.allocator@2.0::types;
|
||||
import android.hardware.graphics.common@1.0::types;
|
||||
|
||||
/**
|
||||
|
@ -89,7 +88,7 @@ interface ICameraDevicePreviewCallback {
|
|||
*
|
||||
* @return Status The status code for this operation.
|
||||
*/
|
||||
setUsage(ProducerUsage usage) generates (Status status);
|
||||
setUsage(ProducerUsageFlags usage) generates (Status status);
|
||||
|
||||
/**
|
||||
* Set the expected buffering mode for the preview output.
|
||||
|
|
|
@ -22,8 +22,8 @@ cc_library_shared {
|
|||
"libbinder",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.camera.common@1.0-helper"
|
||||
"android.hardware.camera.common@1.0-helper",
|
||||
"libgrallocusage"
|
||||
],
|
||||
export_include_dirs: ["."]
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <hardware/gralloc1.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
#include <grallocusage/GrallocUsageConversion.h>
|
||||
|
||||
#include "CameraDevice_1_0.h"
|
||||
|
||||
namespace android {
|
||||
|
@ -29,7 +31,6 @@ namespace device {
|
|||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::graphics::allocator::V2_0::ProducerUsage;
|
||||
using ::android::hardware::graphics::common::V1_0::PixelFormat;
|
||||
|
||||
HandleImporter& CameraDevice::sHandleImporter = HandleImporter::getInstance();
|
||||
|
@ -252,7 +253,10 @@ int CameraDevice::sSetUsage(struct preview_stream_ops* w, int usage) {
|
|||
}
|
||||
|
||||
object->cleanUpCirculatingBuffers();
|
||||
return getStatusT(object->mPreviewCallback->setUsage((ProducerUsage) usage));
|
||||
ProducerUsageFlags producerUsage;
|
||||
uint64_t consumerUsage;
|
||||
::android_convertGralloc0To1Usage(usage, &producerUsage, &consumerUsage);
|
||||
return getStatusT(object->mPreviewCallback->setUsage(producerUsage));
|
||||
}
|
||||
|
||||
int CameraDevice::sSetSwapInterval(struct preview_stream_ops *w, int interval) {
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
|
||||
package android.hardware.camera.device@1.0;
|
||||
|
||||
import android.hardware.graphics.allocator@2.0::types;
|
||||
|
||||
typedef bitfield<ProducerUsage> ProducerUsageFlags;
|
||||
|
||||
enum CameraFacing : uint32_t {
|
||||
/** The facing of the camera is opposite to that of the screen. */
|
||||
BACK = 0,
|
||||
|
|
|
@ -17,7 +17,8 @@ cc_library_shared {
|
|||
"libcamera_metadata"
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.camera.common@1.0-helper"
|
||||
"android.hardware.camera.common@1.0-helper",
|
||||
"libgrallocusage"
|
||||
],
|
||||
export_include_dirs: ["."]
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ Return<void> CameraDeviceSession::configureStreams(
|
|||
return Void();
|
||||
}
|
||||
mStreamMap[id].rotation = (int) requestedConfiguration.streams[i].rotation;
|
||||
mStreamMap[id].usage = (uint32_t) requestedConfiguration.streams[i].usage;
|
||||
mStreamMap[id].usage = convertFromHidlUsage(requestedConfiguration.streams[i].usage);
|
||||
}
|
||||
streams[i] = &mStreamMap[id];
|
||||
}
|
||||
|
|
|
@ -15,8 +15,12 @@
|
|||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.camera.device@3.2-convert-impl"
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include <grallocusage/GrallocUsageConversion.h>
|
||||
|
||||
#include "include/convert.h"
|
||||
|
||||
namespace android {
|
||||
|
@ -28,6 +32,7 @@ namespace implementation {
|
|||
|
||||
using ::android::hardware::graphics::common::V1_0::Dataspace;
|
||||
using ::android::hardware::graphics::common::V1_0::PixelFormat;
|
||||
using ::android::hardware::graphics::allocator::V2_0::ConsumerUsage;
|
||||
using ::android::hardware::camera::device::V3_2::ConsumerUsageFlags;
|
||||
using ::android::hardware::camera::device::V3_2::ProducerUsageFlags;
|
||||
|
||||
|
@ -66,23 +71,37 @@ void convertFromHidl(const Stream &src, Camera3Stream* dst) {
|
|||
dst->format = (int) src.format;
|
||||
dst->data_space = (android_dataspace_t) src.dataSpace;
|
||||
dst->rotation = (int) src.rotation;
|
||||
dst->usage = (uint32_t) src.usage;
|
||||
dst->usage = convertFromHidlUsage(src.usage);
|
||||
// Fields to be filled by HAL (max_buffers, priv) are initialized to 0
|
||||
dst->max_buffers = 0;
|
||||
dst->priv = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t convertFromHidlUsage(ConsumerUsageFlags usage) {
|
||||
uint32_t dstUsage = 0;
|
||||
dstUsage = ::android_convertGralloc1To0Usage(/*producerUsage*/ 0, usage);
|
||||
// Compatibility workaround - add HW_CAMERA_ZSL when ConsumerUsage.CAMERA is set, to
|
||||
// match pre-HIDL expected usage flags
|
||||
if ( (usage & ConsumerUsage::CAMERA) == static_cast<uint64_t>(ConsumerUsage::CAMERA)) {
|
||||
dstUsage |= GRALLOC_USAGE_HW_CAMERA_ZSL;
|
||||
}
|
||||
return dstUsage;
|
||||
}
|
||||
|
||||
void convertToHidl(const Camera3Stream* src, HalStream* dst) {
|
||||
dst->id = src->mId;
|
||||
dst->overrideFormat = (PixelFormat) src->format;
|
||||
dst->maxBuffers = src->max_buffers;
|
||||
ConsumerUsageFlags consumerUsage;
|
||||
ProducerUsageFlags producerUsage;
|
||||
::android_convertGralloc0To1Usage(src->usage, &producerUsage, &consumerUsage);
|
||||
if (src->stream_type == CAMERA3_STREAM_OUTPUT) {
|
||||
dst->consumerUsage = (ConsumerUsageFlags) 0;
|
||||
dst->producerUsage = (ProducerUsageFlags) src->usage;
|
||||
dst->producerUsage = producerUsage;
|
||||
} else if (src->stream_type == CAMERA3_STREAM_INPUT) {
|
||||
dst->producerUsage = (ProducerUsageFlags) 0;
|
||||
dst->consumerUsage = (ConsumerUsageFlags) src->usage;
|
||||
dst->consumerUsage = consumerUsage;
|
||||
} else {
|
||||
//Should not reach here per current HIDL spec, but we might end up adding
|
||||
// bi-directional stream to HIDL.
|
||||
|
|
|
@ -45,6 +45,8 @@ void convertToHidl(const camera_metadata_t* src, CameraMetadata* dst);
|
|||
void convertFromHidl(const Stream &src, Camera3Stream* dst);
|
||||
void convertToHidl(const Camera3Stream* src, HalStream* dst);
|
||||
|
||||
uint32_t convertFromHidlUsage(ConsumerUsageFlags usage);
|
||||
|
||||
void convertFromHidl(
|
||||
buffer_handle_t*, BufferStatus, camera3_stream_t*, int acquireFence, // inputs
|
||||
camera3_stream_buffer_t* dst);
|
||||
|
|
|
@ -33,7 +33,10 @@ cc_test {
|
|||
"libgui",
|
||||
"libui"
|
||||
],
|
||||
static_libs: ["VtsHalHidlTargetTestBase"],
|
||||
static_libs: [
|
||||
"VtsHalHidlTargetTestBase",
|
||||
"libgrallocusage"
|
||||
],
|
||||
cflags: [
|
||||
"-O0",
|
||||
"-g",
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "CameraParameters.h"
|
||||
#include <system/camera.h>
|
||||
#include <android/log.h>
|
||||
#include <grallocusage/GrallocUsageConversion.h>
|
||||
#include <ui/GraphicBuffer.h>
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <gui/BufferQueue.h>
|
||||
|
@ -53,6 +54,7 @@ using ::android::BufferItemConsumer;
|
|||
using ::android::Surface;
|
||||
using ::android::CameraParameters;
|
||||
using ::android::hardware::graphics::common::V1_0::PixelFormat;
|
||||
using ::android::hardware::graphics::allocator::V2_0::ConsumerUsage;
|
||||
using ::android::hardware::graphics::allocator::V2_0::ProducerUsage;
|
||||
using ::android::hardware::camera::common::V1_0::Status;
|
||||
using ::android::hardware::camera::common::V1_0::CameraDeviceStatus;
|
||||
|
@ -60,6 +62,8 @@ using ::android::hardware::camera::common::V1_0::TorchMode;
|
|||
using ::android::hardware::camera::common::V1_0::TorchModeStatus;
|
||||
using ::android::hardware::camera::provider::V2_4::ICameraProvider;
|
||||
using ::android::hardware::camera::provider::V2_4::ICameraProviderCallback;
|
||||
using ::android::hardware::camera::device::V3_2::ProducerUsageFlags;
|
||||
using ::android::hardware::camera::device::V3_2::ConsumerUsageFlags;
|
||||
using ::android::hardware::camera::device::V3_2::ICameraDevice;
|
||||
using ::android::hardware::camera::device::V3_2::CaptureRequest;
|
||||
using ::android::hardware::camera::device::V3_2::CaptureResult;
|
||||
|
@ -79,6 +83,7 @@ using ::android::hardware::camera::device::V3_2::StreamBuffer;
|
|||
using ::android::hardware::camera::device::V3_2::MsgType;
|
||||
using ::android::hardware::camera::device::V3_2::ErrorMsg;
|
||||
using ::android::hardware::camera::device::V3_2::ErrorCode;
|
||||
using ::android::hardware::camera::device::V1_0::ProducerUsageFlags;
|
||||
using ::android::hardware::camera::device::V1_0::CameraFacing;
|
||||
using ::android::hardware::camera::device::V1_0::NotifyCallbackMsg;
|
||||
using ::android::hardware::camera::device::V1_0::CommandType;
|
||||
|
@ -232,7 +237,7 @@ struct PreviewWindowCb : public ICameraDevicePreviewCallback {
|
|||
Return<Status> setCrop(int32_t left, int32_t top,
|
||||
int32_t right, int32_t bottom) override;
|
||||
|
||||
Return<Status> setUsage(ProducerUsage usage) override;
|
||||
Return<Status> setUsage(ProducerUsageFlags usage) override;
|
||||
|
||||
Return<Status> setSwapInterval(int32_t interval) override;
|
||||
|
||||
|
@ -407,10 +412,11 @@ Return<Status> PreviewWindowCb::setCrop(int32_t left, int32_t top,
|
|||
return mapToStatus(rc);
|
||||
}
|
||||
|
||||
Return<Status> PreviewWindowCb::setUsage(ProducerUsage usage) {
|
||||
auto rc = native_window_set_usage(mAnw.get(), static_cast<int>(usage));
|
||||
Return<Status> PreviewWindowCb::setUsage(ProducerUsageFlags usage) {
|
||||
int dstUsage = ::android_convertGralloc1To0Usage(usage, /*consumerUsage*/ 0);
|
||||
auto rc = native_window_set_usage(mAnw.get(), dstUsage);
|
||||
if (rc == ::android::OK) {
|
||||
mPreviewUsage = static_cast<int>(usage);
|
||||
mPreviewUsage = dstUsage;
|
||||
}
|
||||
return mapToStatus(rc);
|
||||
}
|
||||
|
@ -2198,7 +2204,7 @@ TEST_F(CameraHidlTest, configureStreamsZSLInputOutputs) {
|
|||
static_cast<uint32_t> (input.width),
|
||||
static_cast<uint32_t> (input.height),
|
||||
static_cast<PixelFormat> (input.format),
|
||||
GRALLOC_USAGE_HW_CAMERA_ZSL, 0,
|
||||
static_cast<ConsumerUsageFlags>(ConsumerUsage::CAMERA), 0,
|
||||
StreamRotation::ROTATION_0};
|
||||
Stream inputStream = {streamId++, StreamType::INPUT,
|
||||
static_cast<uint32_t> (input.width),
|
||||
|
@ -2430,7 +2436,7 @@ TEST_F(CameraHidlTest, configureStreamsVideoStillOutputs) {
|
|||
static_cast<uint32_t> (blobIter.width),
|
||||
static_cast<uint32_t> (blobIter.height),
|
||||
static_cast<PixelFormat> (blobIter.format),
|
||||
GRALLOC_USAGE_HW_VIDEO_ENCODER, 0,
|
||||
static_cast<ConsumerUsageFlags>(ConsumerUsage::VIDEO_ENCODER), 0,
|
||||
StreamRotation::ROTATION_0};
|
||||
::android::hardware::hidl_vec<Stream> streams = {
|
||||
videoStream, blobStream};
|
||||
|
|
Loading…
Reference in a new issue