diff options
Diffstat (limited to 'camera/device/3.4/default/ExternalCameraDeviceSession.cpp')
-rw-r--r-- | camera/device/3.4/default/ExternalCameraDeviceSession.cpp | 79 |
1 files changed, 47 insertions, 32 deletions
diff --git a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp index 66b17db955..32da9681bf 100644 --- a/camera/device/3.4/default/ExternalCameraDeviceSession.cpp +++ b/camera/device/3.4/default/ExternalCameraDeviceSession.cpp @@ -1819,7 +1819,7 @@ bool ExternalCameraDeviceSession::OutputThread::threadLoop() { 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 @@ bool ExternalCameraDeviceSession::OutputThread::threadLoop() { } // 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 (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 (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__); + } + signalRequestDone(); + return true; } - signalRequestDone(); - return true; } ATRACE_BEGIN("Wait for BufferRequest done"); @@ -1910,6 +1907,16 @@ bool ExternalCameraDeviceSession::OutputThread::threadLoop() { __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 @@ void ExternalCameraDeviceSession::updateBufferCaches(const hidl_vec<BufferCache> } 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 @@ bool ExternalCameraDeviceSession::isSupported(const Stream& stream, 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 @@ bool ExternalCameraDeviceSession::isSupported(const Stream& stream, // 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 @@ void ExternalCameraDeviceSession::enqueueV4l2Frame(const sp<V4L2Frame>& frame) { 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 @@ Status ExternalCameraDeviceSession::isStreamCombinationSupported( 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 @@ Status ExternalCameraDeviceSession::configureStreams( 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 @@ Status ExternalCameraDeviceSession::configureStreams( 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; |