Y16 format enablement for external provider
added Y16 (depth) support for the external provider.
refactored initOutputCharsKeys to support both depth and color metadata according to the connected camera.
the VTS changes will be pushed to pie-vts-dev
Test: tested on intel depth camera D415 manually in addition to the VTS tests.
Change-Id: I358686e7c4330bb180dec4a9cce3bc1cf5475260
Signed-off-by: Emil Jahshan <emil.jahshan@intel.com>
diff --git a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
index 66b17db..32da968 100644
--- a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
+++ b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
@@ -1819,7 +1819,7 @@
return false;
};
- if (req->frameIn->mFourcc != V4L2_PIX_FMT_MJPEG) {
+ if (req->frameIn->mFourcc != V4L2_PIX_FMT_MJPEG && req->frameIn->mFourcc != V4L2_PIX_FMT_Z16) {
return onDeviceError("%s: do not support V4L2 format %c%c%c%c", __FUNCTION__,
req->frameIn->mFourcc & 0xFF,
(req->frameIn->mFourcc >> 8) & 0xFF,
@@ -1844,29 +1844,26 @@
}
// TODO: in some special case maybe we can decode jpg directly to gralloc output?
- ATRACE_BEGIN("MJPGtoI420");
- res = libyuv::MJPGToI420(
- inData, inDataSize,
- static_cast<uint8_t*>(mYu12FrameLayout.y),
- mYu12FrameLayout.yStride,
- static_cast<uint8_t*>(mYu12FrameLayout.cb),
- mYu12FrameLayout.cStride,
- static_cast<uint8_t*>(mYu12FrameLayout.cr),
- mYu12FrameLayout.cStride,
- mYu12Frame->mWidth, mYu12Frame->mHeight,
- mYu12Frame->mWidth, mYu12Frame->mHeight);
- ATRACE_END();
+ if (req->frameIn->mFourcc == V4L2_PIX_FMT_MJPEG) {
+ ATRACE_BEGIN("MJPGtoI420");
+ int res = libyuv::MJPGToI420(
+ inData, inDataSize, static_cast<uint8_t*>(mYu12FrameLayout.y), mYu12FrameLayout.yStride,
+ static_cast<uint8_t*>(mYu12FrameLayout.cb), mYu12FrameLayout.cStride,
+ static_cast<uint8_t*>(mYu12FrameLayout.cr), mYu12FrameLayout.cStride,
+ mYu12Frame->mWidth, mYu12Frame->mHeight, mYu12Frame->mWidth, mYu12Frame->mHeight);
+ ATRACE_END();
- if (res != 0) {
- // For some webcam, the first few V4L2 frames might be malformed...
- ALOGE("%s: Convert V4L2 frame to YU12 failed! res %d", __FUNCTION__, res);
- lk.unlock();
- Status st = parent->processCaptureRequestError(req);
- if (st != Status::OK) {
- return onDeviceError("%s: failed to process capture request error!", __FUNCTION__);
+ if (res != 0) {
+ // For some webcam, the first few V4L2 frames might be malformed...
+ ALOGE("%s: Convert V4L2 frame to YU12 failed! res %d", __FUNCTION__, res);
+ lk.unlock();
+ Status st = parent->processCaptureRequestError(req);
+ if (st != Status::OK) {
+ return onDeviceError("%s: failed to process capture request error!", __FUNCTION__);
+ }
+ signalRequestDone();
+ return true;
}
- signalRequestDone();
- return true;
}
ATRACE_BEGIN("Wait for BufferRequest done");
@@ -1910,6 +1907,16 @@
__FUNCTION__, ret);
}
} break;
+ case PixelFormat::Y16: {
+ void* outLayout = sHandleImporter.lock(*(halBuf.bufPtr), halBuf.usage, inDataSize);
+
+ std::memcpy(outLayout, inData, inDataSize);
+
+ int relFence = sHandleImporter.unlock(*(halBuf.bufPtr));
+ if (relFence >= 0) {
+ halBuf.acquireFence = relFence;
+ }
+ } break;
case PixelFormat::YCBCR_420_888:
case PixelFormat::YV12: {
IMapper::Rect outRect {0, 0,
@@ -2164,7 +2171,8 @@
}
bool ExternalCameraDeviceSession::isSupported(const Stream& stream,
- const std::vector<SupportedV4L2Format>& supportedFormats) {
+ const std::vector<SupportedV4L2Format>& supportedFormats,
+ const ExternalCameraConfig& devCfg) {
int32_t ds = static_cast<int32_t>(stream.dataSpace);
PixelFormat fmt = stream.format;
uint32_t width = stream.width;
@@ -2181,11 +2189,6 @@
return false;
}
- if (ds & Dataspace::DEPTH) {
- ALOGI("%s: does not support depth output", __FUNCTION__);
- return false;
- }
-
switch (fmt) {
case PixelFormat::BLOB:
if (ds != static_cast<int32_t>(Dataspace::V0_JFIF)) {
@@ -2199,6 +2202,16 @@
// TODO: check what dataspace we can support here.
// intentional no-ops.
break;
+ case PixelFormat::Y16:
+ if (!devCfg.depthEnabled) {
+ ALOGI("%s: Depth is not Enabled", __FUNCTION__);
+ return false;
+ }
+ if (!(ds & Dataspace::DEPTH)) {
+ ALOGI("%s: Y16 supports only dataSpace DEPTH", __FUNCTION__);
+ return false;
+ }
+ break;
default:
ALOGI("%s: does not support format %x", __FUNCTION__, fmt);
return false;
@@ -2544,7 +2557,8 @@
Status ExternalCameraDeviceSession::isStreamCombinationSupported(
const V3_2::StreamConfiguration& config,
- const std::vector<SupportedV4L2Format>& supportedFormats) {
+ const std::vector<SupportedV4L2Format>& supportedFormats,
+ const ExternalCameraConfig& devCfg) {
if (config.operationMode != StreamConfigurationMode::NORMAL_MODE) {
ALOGE("%s: unsupported operation mode: %d", __FUNCTION__, config.operationMode);
return Status::ILLEGAL_ARGUMENT;
@@ -2559,7 +2573,7 @@
int numStallStream = 0;
for (const auto& stream : config.streams) {
// Check if the format/width/height combo is supported
- if (!isSupported(stream, supportedFormats)) {
+ if (!isSupported(stream, supportedFormats, devCfg)) {
return Status::ILLEGAL_ARGUMENT;
}
if (stream.format == PixelFormat::BLOB) {
@@ -2590,7 +2604,7 @@
uint32_t blobBufferSize) {
ATRACE_CALL();
- Status status = isStreamCombinationSupported(config, mSupportedFormats);
+ Status status = isStreamCombinationSupported(config, mSupportedFormats, mCfg);
if (status != Status::OK) {
return status;
}
@@ -2744,6 +2758,7 @@
case PixelFormat::BLOB:
case PixelFormat::YCBCR_420_888:
case PixelFormat::YV12: // Used by SurfaceTexture
+ case PixelFormat::Y16:
// No override
out->streams[i].v3_2.overrideFormat = config.streams[i].format;
break;