Loading camera/device/aidl/android/hardware/camera/device/ShutterMsg.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ parcelable ShutterMsg { * as timestamp, and for a rolling shutter sensor, the value must be * timestamp + exposureTime + t_crop_top where t_crop_top is the exposure time * skew of the cropped lines on the top. * * If ANDROID_SENSOR_READOUT_TIMESTAMP is set to NOT_SUPPORTED, this field * will be ignored by the camera framework. */ long readoutTimestamp; } camera/provider/aidl/vts/camera_aidl_test.cpp +26 −9 Original line number Diff line number Diff line Loading @@ -456,6 +456,22 @@ Status CameraAidlTest::isLogicalMultiCamera(const camera_metadata_t* staticMeta) return ret; } bool CameraAidlTest::isReadoutTimestampSupported(const camera_metadata_t* staticMeta) { camera_metadata_ro_entry readoutTimestampEntry; int rc = find_camera_metadata_ro_entry(staticMeta, ANDROID_SENSOR_READOUT_TIMESTAMP, &readoutTimestampEntry); if (rc != 0) { ALOGI("%s: Failed to find ANDROID_SENSOR_READOUT_TIMESTAMP", __FUNCTION__); return true; } if (readoutTimestampEntry.count == 1 && !readoutTimestampEntry.data.u8[0]) { ALOGI("%s: readout timestamp not supported", __FUNCTION__); return false; } ALOGI("%s: readout timestamp supported", __FUNCTION__); return true; } void CameraAidlTest::verifyLogicalCameraResult(const camera_metadata_t* staticMetadata, const std::vector<uint8_t>& resultMetadata) { camera_metadata_t* metadata = (camera_metadata_t*)resultMetadata.data(); Loading Loading @@ -2380,13 +2396,13 @@ void CameraAidlTest::processCaptureRequestInternal(uint64_t bufferUsage, ASSERT_NE(inflightReq->resultOutputBuffers.size(), 0u); ASSERT_EQ(testStream.id, inflightReq->resultOutputBuffers[0].buffer.streamId); // shutterReadoutTimestamp must be available, and it must // shutterReadoutTimestamp, if supported, must // be >= shutterTimestamp + exposureTime, // and < shutterTimestamp + exposureTime + rollingShutterSkew / 2. ASSERT_TRUE(inflightReq->shutterReadoutTimestampValid); ASSERT_FALSE(inflightReq->collectedResult.isEmpty()); if (inflightReq->collectedResult.exists(ANDROID_SENSOR_EXPOSURE_TIME)) { if (mSupportReadoutTimestamp && inflightReq->collectedResult.exists(ANDROID_SENSOR_EXPOSURE_TIME)) { camera_metadata_entry_t exposureTimeResult = inflightReq->collectedResult.find(ANDROID_SENSOR_EXPOSURE_TIME); nsecs_t exposureToReadout = Loading Loading @@ -2901,13 +2917,14 @@ void CameraAidlTest::processPreviewStabilizationCaptureRequestInternal( ASSERT_FALSE(inflightReq->errorCodeValid); ASSERT_NE(inflightReq->resultOutputBuffers.size(), 0u); ASSERT_EQ(testStream.id, inflightReq->resultOutputBuffers[0].buffer.streamId); ASSERT_TRUE(inflightReq->shutterReadoutTimestampValid); nsecs_t readoutTimestamp = inflightReq->shutterReadoutTimestamp; nsecs_t captureTimestamp = mSupportReadoutTimestamp ? inflightReq->shutterReadoutTimestamp : inflightReq->shutterTimestamp; if (previewStabilizationOn) { // Here we collect the time difference between the buffer ready // timestamp - notify readout timestamp. // timeLag = buffer ready timestamp - notify readout timestamp. // timestamp - notify timestamp. // timeLag = buffer ready timestamp - notify timestamp. // timeLag(previewStabilization) must be <= // timeLag(stabilization off) + 1 frame duration. auto it = cameraDeviceToTimeLag.find(name); Loading @@ -2918,12 +2935,12 @@ void CameraAidlTest::processPreviewStabilizationCaptureRequestInternal( ASSERT_TRUE(it != cameraDeviceToTimeLag.end()); nsecs_t previewStabOnLagTime = inflightReq->resultOutputBuffers[0].timeStamp - readoutTimestamp; inflightReq->resultOutputBuffers[0].timeStamp - captureTimestamp; ASSERT_TRUE(previewStabOnLagTime <= (it->second + frameDuration)); } else { // Fill in the buffer ready timestamp - notify timestamp; cameraDeviceToTimeLag[std::string(name)] = inflightReq->resultOutputBuffers[0].timeStamp - readoutTimestamp; inflightReq->resultOutputBuffers[0].timeStamp - captureTimestamp; } } Loading camera/provider/aidl/vts/camera_aidl_test.h +4 −5 Original line number Diff line number Diff line Loading @@ -346,6 +346,8 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { static Status isOfflineSessionSupported(const camera_metadata_t* staticMeta); static bool isReadoutTimestampSupported(const camera_metadata_t* staticMeta); static Status getPhysicalCameraIds(const camera_metadata_t* staticMeta, std::unordered_set<std::string>* physicalIds /*out*/); Loading Loading @@ -456,8 +458,6 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { struct InFlightRequest { // Set by notify() SHUTTER call. nsecs_t shutterTimestamp; bool shutterReadoutTimestampValid; nsecs_t shutterReadoutTimestamp; bool errorCodeValid; Loading Loading @@ -523,7 +523,6 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { InFlightRequest() : shutterTimestamp(0), shutterReadoutTimestampValid(false), shutterReadoutTimestamp(0), errorCodeValid(false), errorCode(ErrorCode::ERROR_BUFFER), Loading @@ -541,7 +540,6 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { InFlightRequest(ssize_t numBuffers, bool hasInput, bool partialResults, int32_t partialCount, std::shared_ptr<ResultMetadataQueue> queue = nullptr) : shutterTimestamp(0), shutterReadoutTimestampValid(false), shutterReadoutTimestamp(0), errorCodeValid(false), errorCode(ErrorCode::ERROR_BUFFER), Loading @@ -561,7 +559,6 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { const std::unordered_set<std::string>& extraPhysicalResult, std::shared_ptr<ResultMetadataQueue> queue = nullptr) : shutterTimestamp(0), shutterReadoutTimestampValid(false), shutterReadoutTimestamp(0), errorCodeValid(false), errorCode(ErrorCode::ERROR_BUFFER), Loading Loading @@ -631,6 +628,8 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { HandleImporter mHandleImporter; bool mSupportReadoutTimestamp; friend class DeviceCb; friend class SimpleDeviceCb; friend class TorchProviderCb; Loading camera/provider/aidl/vts/device_cb.cpp +7 −8 Original line number Diff line number Diff line Loading @@ -32,10 +32,11 @@ const int64_t kBufferReturnTimeoutSec = 1; DeviceCb::DeviceCb(CameraAidlTest* parent, camera_metadata_t* staticMeta) : mParent(parent) { mStaticMetadata = staticMeta; parent->mSupportReadoutTimestamp = CameraAidlTest::isReadoutTimestampSupported(staticMeta); } ScopedAStatus DeviceCb::notify(const std::vector<NotifyMsg>& msgs) { std::vector<std::pair<bool, nsecs_t>> readoutTimestamps; std::vector<nsecs_t> readoutTimestamps; size_t count = msgs.size(); readoutTimestamps.resize(count); Loading @@ -44,11 +45,11 @@ ScopedAStatus DeviceCb::notify(const std::vector<NotifyMsg>& msgs) { const NotifyMsg& msg = msgs[i]; switch (msg.getTag()) { case NotifyMsg::Tag::error: readoutTimestamps[i] = {false, 0}; readoutTimestamps[i] = 0; break; case NotifyMsg::Tag::shutter: const auto& shutter = msg.get<NotifyMsg::Tag::shutter>(); readoutTimestamps[i] = {true, shutter.readoutTimestamp}; readoutTimestamps[i] = shutter.readoutTimestamp; break; } } Loading Loading @@ -446,9 +447,8 @@ bool DeviceCb::processCaptureResultLocked( return notify; } ScopedAStatus DeviceCb::notifyHelper( const std::vector<NotifyMsg>& msgs, const std::vector<std::pair<bool, nsecs_t>>& readoutTimestamps) { ScopedAStatus DeviceCb::notifyHelper(const std::vector<NotifyMsg>& msgs, const std::vector<nsecs_t>& readoutTimestamps) { std::lock_guard<std::mutex> l(mParent->mLock); for (size_t i = 0; i < msgs.size(); i++) { Loading Loading @@ -514,8 +514,7 @@ ScopedAStatus DeviceCb::notifyHelper( } auto& r = itr->second; r->shutterTimestamp = msg.get<NotifyMsg::Tag::shutter>().timestamp; r->shutterReadoutTimestampValid = readoutTimestamps[i].first; r->shutterReadoutTimestamp = readoutTimestamps[i].second; r->shutterReadoutTimestamp = readoutTimestamps[i]; break; } } Loading camera/provider/aidl/vts/device_cb.h +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class DeviceCb : public BnCameraDeviceCallback { bool processCaptureResultLocked(const CaptureResult& results, std::vector<PhysicalCameraMetadata> physicalCameraMetadata); ScopedAStatus notifyHelper(const std::vector<NotifyMsg>& msgs, const std::vector<std::pair<bool, nsecs_t>>& readoutTimestamps); const std::vector<nsecs_t>& readoutTimestamps); CameraAidlTest* mParent; // Parent object Loading Loading
camera/device/aidl/android/hardware/camera/device/ShutterMsg.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ parcelable ShutterMsg { * as timestamp, and for a rolling shutter sensor, the value must be * timestamp + exposureTime + t_crop_top where t_crop_top is the exposure time * skew of the cropped lines on the top. * * If ANDROID_SENSOR_READOUT_TIMESTAMP is set to NOT_SUPPORTED, this field * will be ignored by the camera framework. */ long readoutTimestamp; }
camera/provider/aidl/vts/camera_aidl_test.cpp +26 −9 Original line number Diff line number Diff line Loading @@ -456,6 +456,22 @@ Status CameraAidlTest::isLogicalMultiCamera(const camera_metadata_t* staticMeta) return ret; } bool CameraAidlTest::isReadoutTimestampSupported(const camera_metadata_t* staticMeta) { camera_metadata_ro_entry readoutTimestampEntry; int rc = find_camera_metadata_ro_entry(staticMeta, ANDROID_SENSOR_READOUT_TIMESTAMP, &readoutTimestampEntry); if (rc != 0) { ALOGI("%s: Failed to find ANDROID_SENSOR_READOUT_TIMESTAMP", __FUNCTION__); return true; } if (readoutTimestampEntry.count == 1 && !readoutTimestampEntry.data.u8[0]) { ALOGI("%s: readout timestamp not supported", __FUNCTION__); return false; } ALOGI("%s: readout timestamp supported", __FUNCTION__); return true; } void CameraAidlTest::verifyLogicalCameraResult(const camera_metadata_t* staticMetadata, const std::vector<uint8_t>& resultMetadata) { camera_metadata_t* metadata = (camera_metadata_t*)resultMetadata.data(); Loading Loading @@ -2380,13 +2396,13 @@ void CameraAidlTest::processCaptureRequestInternal(uint64_t bufferUsage, ASSERT_NE(inflightReq->resultOutputBuffers.size(), 0u); ASSERT_EQ(testStream.id, inflightReq->resultOutputBuffers[0].buffer.streamId); // shutterReadoutTimestamp must be available, and it must // shutterReadoutTimestamp, if supported, must // be >= shutterTimestamp + exposureTime, // and < shutterTimestamp + exposureTime + rollingShutterSkew / 2. ASSERT_TRUE(inflightReq->shutterReadoutTimestampValid); ASSERT_FALSE(inflightReq->collectedResult.isEmpty()); if (inflightReq->collectedResult.exists(ANDROID_SENSOR_EXPOSURE_TIME)) { if (mSupportReadoutTimestamp && inflightReq->collectedResult.exists(ANDROID_SENSOR_EXPOSURE_TIME)) { camera_metadata_entry_t exposureTimeResult = inflightReq->collectedResult.find(ANDROID_SENSOR_EXPOSURE_TIME); nsecs_t exposureToReadout = Loading Loading @@ -2901,13 +2917,14 @@ void CameraAidlTest::processPreviewStabilizationCaptureRequestInternal( ASSERT_FALSE(inflightReq->errorCodeValid); ASSERT_NE(inflightReq->resultOutputBuffers.size(), 0u); ASSERT_EQ(testStream.id, inflightReq->resultOutputBuffers[0].buffer.streamId); ASSERT_TRUE(inflightReq->shutterReadoutTimestampValid); nsecs_t readoutTimestamp = inflightReq->shutterReadoutTimestamp; nsecs_t captureTimestamp = mSupportReadoutTimestamp ? inflightReq->shutterReadoutTimestamp : inflightReq->shutterTimestamp; if (previewStabilizationOn) { // Here we collect the time difference between the buffer ready // timestamp - notify readout timestamp. // timeLag = buffer ready timestamp - notify readout timestamp. // timestamp - notify timestamp. // timeLag = buffer ready timestamp - notify timestamp. // timeLag(previewStabilization) must be <= // timeLag(stabilization off) + 1 frame duration. auto it = cameraDeviceToTimeLag.find(name); Loading @@ -2918,12 +2935,12 @@ void CameraAidlTest::processPreviewStabilizationCaptureRequestInternal( ASSERT_TRUE(it != cameraDeviceToTimeLag.end()); nsecs_t previewStabOnLagTime = inflightReq->resultOutputBuffers[0].timeStamp - readoutTimestamp; inflightReq->resultOutputBuffers[0].timeStamp - captureTimestamp; ASSERT_TRUE(previewStabOnLagTime <= (it->second + frameDuration)); } else { // Fill in the buffer ready timestamp - notify timestamp; cameraDeviceToTimeLag[std::string(name)] = inflightReq->resultOutputBuffers[0].timeStamp - readoutTimestamp; inflightReq->resultOutputBuffers[0].timeStamp - captureTimestamp; } } Loading
camera/provider/aidl/vts/camera_aidl_test.h +4 −5 Original line number Diff line number Diff line Loading @@ -346,6 +346,8 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { static Status isOfflineSessionSupported(const camera_metadata_t* staticMeta); static bool isReadoutTimestampSupported(const camera_metadata_t* staticMeta); static Status getPhysicalCameraIds(const camera_metadata_t* staticMeta, std::unordered_set<std::string>* physicalIds /*out*/); Loading Loading @@ -456,8 +458,6 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { struct InFlightRequest { // Set by notify() SHUTTER call. nsecs_t shutterTimestamp; bool shutterReadoutTimestampValid; nsecs_t shutterReadoutTimestamp; bool errorCodeValid; Loading Loading @@ -523,7 +523,6 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { InFlightRequest() : shutterTimestamp(0), shutterReadoutTimestampValid(false), shutterReadoutTimestamp(0), errorCodeValid(false), errorCode(ErrorCode::ERROR_BUFFER), Loading @@ -541,7 +540,6 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { InFlightRequest(ssize_t numBuffers, bool hasInput, bool partialResults, int32_t partialCount, std::shared_ptr<ResultMetadataQueue> queue = nullptr) : shutterTimestamp(0), shutterReadoutTimestampValid(false), shutterReadoutTimestamp(0), errorCodeValid(false), errorCode(ErrorCode::ERROR_BUFFER), Loading @@ -561,7 +559,6 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { const std::unordered_set<std::string>& extraPhysicalResult, std::shared_ptr<ResultMetadataQueue> queue = nullptr) : shutterTimestamp(0), shutterReadoutTimestampValid(false), shutterReadoutTimestamp(0), errorCodeValid(false), errorCode(ErrorCode::ERROR_BUFFER), Loading Loading @@ -631,6 +628,8 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> { HandleImporter mHandleImporter; bool mSupportReadoutTimestamp; friend class DeviceCb; friend class SimpleDeviceCb; friend class TorchProviderCb; Loading
camera/provider/aidl/vts/device_cb.cpp +7 −8 Original line number Diff line number Diff line Loading @@ -32,10 +32,11 @@ const int64_t kBufferReturnTimeoutSec = 1; DeviceCb::DeviceCb(CameraAidlTest* parent, camera_metadata_t* staticMeta) : mParent(parent) { mStaticMetadata = staticMeta; parent->mSupportReadoutTimestamp = CameraAidlTest::isReadoutTimestampSupported(staticMeta); } ScopedAStatus DeviceCb::notify(const std::vector<NotifyMsg>& msgs) { std::vector<std::pair<bool, nsecs_t>> readoutTimestamps; std::vector<nsecs_t> readoutTimestamps; size_t count = msgs.size(); readoutTimestamps.resize(count); Loading @@ -44,11 +45,11 @@ ScopedAStatus DeviceCb::notify(const std::vector<NotifyMsg>& msgs) { const NotifyMsg& msg = msgs[i]; switch (msg.getTag()) { case NotifyMsg::Tag::error: readoutTimestamps[i] = {false, 0}; readoutTimestamps[i] = 0; break; case NotifyMsg::Tag::shutter: const auto& shutter = msg.get<NotifyMsg::Tag::shutter>(); readoutTimestamps[i] = {true, shutter.readoutTimestamp}; readoutTimestamps[i] = shutter.readoutTimestamp; break; } } Loading Loading @@ -446,9 +447,8 @@ bool DeviceCb::processCaptureResultLocked( return notify; } ScopedAStatus DeviceCb::notifyHelper( const std::vector<NotifyMsg>& msgs, const std::vector<std::pair<bool, nsecs_t>>& readoutTimestamps) { ScopedAStatus DeviceCb::notifyHelper(const std::vector<NotifyMsg>& msgs, const std::vector<nsecs_t>& readoutTimestamps) { std::lock_guard<std::mutex> l(mParent->mLock); for (size_t i = 0; i < msgs.size(); i++) { Loading Loading @@ -514,8 +514,7 @@ ScopedAStatus DeviceCb::notifyHelper( } auto& r = itr->second; r->shutterTimestamp = msg.get<NotifyMsg::Tag::shutter>().timestamp; r->shutterReadoutTimestampValid = readoutTimestamps[i].first; r->shutterReadoutTimestamp = readoutTimestamps[i].second; r->shutterReadoutTimestamp = readoutTimestamps[i]; break; } } Loading
camera/provider/aidl/vts/device_cb.h +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class DeviceCb : public BnCameraDeviceCallback { bool processCaptureResultLocked(const CaptureResult& results, std::vector<PhysicalCameraMetadata> physicalCameraMetadata); ScopedAStatus notifyHelper(const std::vector<NotifyMsg>& msgs, const std::vector<std::pair<bool, nsecs_t>>& readoutTimestamps); const std::vector<nsecs_t>& readoutTimestamps); CameraAidlTest* mParent; // Parent object Loading