Camera: Add support for stream combination query
Camera devices 3.5 and later can optionally support
stream combination queries. These use the regular
'StreamConfiguration' structure however in contrast
to normal stream configuration, the query will be
much faster and will not cause any HW/SW side effects.
Additionally it will be possible to run stream
combination queries at any time after the camera
device is open.
Implement stream combination query for the external
camera provider.
Bug: 111593096
Test: vts-tradefed run commandAndExit vts --skip-all-system-status-check
--skip-preconditions --module VtsHalCameraProviderV2_4Target -l INFO
Change-Id: I59ec936d17dabc89ba49407a750df1cd2e61b145
diff --git a/camera/device/3.5/ICameraDevice.hal b/camera/device/3.5/ICameraDevice.hal
index a77380f..d9f2837 100644
--- a/camera/device/3.5/ICameraDevice.hal
+++ b/camera/device/3.5/ICameraDevice.hal
@@ -19,6 +19,7 @@
import android.hardware.camera.common@1.0::Status;
import @3.2::CameraMetadata;
import @3.2::ICameraDevice;
+import @3.4::StreamConfiguration;
/**
* Camera device interface
@@ -75,4 +76,41 @@
getPhysicalCameraCharacteristics(string physicalCameraId)
generates (Status status, CameraMetadata cameraCharacteristics);
+
+ /**
+ * isStreamCombinationSupported:
+ *
+ * Check for device support of specific camera stream combination.
+ *
+ * The streamList must contain at least one output-capable stream, and may
+ * not contain more than one input-capable stream.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Preconditions:
+ *
+ * The framework can call this method at any time before, during and
+ * after active session configuration. This means that calls must not
+ * impact the performance of pending camera requests in any way. In
+ * particular there must not be any glitches or delays during normal
+ * camera streaming.
+ *
+ * Performance requirements:
+ * This call is expected to be significantly faster than stream
+ * configuration. In general HW and SW camera settings must not be
+ * changed and there must not be a user-visible impact on camera performance.
+ *
+ * @return Status Status code for the operation, one of:
+ * OK:
+ * On successful stream combination query.
+ * METHOD_NOT_SUPPORTED:
+ * The camera device does not support stream combination query.
+ * INTERNAL_ERROR:
+ * The stream combination query cannot complete due to internal
+ * error.
+ * @return true in case the stream combination is supported, false otherwise.
+ *
+ */
+ isStreamCombinationSupported(@3.4::StreamConfiguration streams)
+ generates (Status status, bool queryStatus);
};
diff --git a/camera/device/3.5/default/CameraDevice.cpp b/camera/device/3.5/default/CameraDevice.cpp
index a6969af..cffda4e 100644
--- a/camera/device/3.5/default/CameraDevice.cpp
+++ b/camera/device/3.5/default/CameraDevice.cpp
@@ -95,6 +95,57 @@
return Void();
}
+Return<void> CameraDevice::isStreamCombinationSupported(const V3_4::StreamConfiguration& streams,
+ V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) {
+ Status status;
+ bool streamsSupported = false;
+
+ // Require module 2.5+ version.
+ if (mModule->getModuleApiVersion() < CAMERA_MODULE_API_VERSION_2_5) {
+ ALOGE("%s: is_stream_combination_supported must be called on camera module 2.5 or "\
+ "newer", __FUNCTION__);
+ status = Status::INTERNAL_ERROR;
+ } else {
+ camera_stream_combination_t streamComb{};
+ streamComb.operation_mode = static_cast<uint32_t> (streams.operationMode);
+ streamComb.num_streams = streams.streams.size();
+ camera_stream_t *streamBuffer = new camera_stream_t[streamComb.num_streams];
+
+ size_t i = 0;
+ for (const auto &it : streams.streams) {
+ streamBuffer[i].stream_type = static_cast<int> (it.v3_2.streamType);
+ streamBuffer[i].width = it.v3_2.width;
+ streamBuffer[i].height = it.v3_2.height;
+ streamBuffer[i].format = static_cast<int> (it.v3_2.format);
+ streamBuffer[i].data_space = static_cast<android_dataspace_t> (it.v3_2.dataSpace);
+ streamBuffer[i].usage = static_cast<uint32_t> (it.v3_2.usage);
+ streamBuffer[i].physical_camera_id = it.physicalCameraId.c_str();
+ streamBuffer[i++].rotation = static_cast<int> (it.v3_2.rotation);
+ }
+ streamComb.streams = streamBuffer;
+ auto res = mModule->isStreamCombinationSupported(mCameraIdInt, &streamComb);
+ switch (res) {
+ case NO_ERROR:
+ streamsSupported = true;
+ status = Status::OK;
+ break;
+ case BAD_VALUE:
+ status = Status::OK;
+ break;
+ case INVALID_OPERATION:
+ status = Status::METHOD_NOT_SUPPORTED;
+ break;
+ default:
+ ALOGE("%s: Unexpected error: %d", __FUNCTION__, res);
+ status = Status::INTERNAL_ERROR;
+ };
+ delete [] streamBuffer;
+ }
+
+ _hidl_cb(status, streamsSupported);
+ return Void();
+}
+
// End of methods from ::android::hardware::camera::device::V3_2::ICameraDevice.
} // namespace implementation
diff --git a/camera/device/3.5/default/ExternalCameraDevice.cpp b/camera/device/3.5/default/ExternalCameraDevice.cpp
index e8d14b5..6a0b51e 100644
--- a/camera/device/3.5/default/ExternalCameraDevice.cpp
+++ b/camera/device/3.5/default/ExternalCameraDevice.cpp
@@ -86,6 +86,27 @@
return OK;
}
+Return<void> ExternalCameraDevice::isStreamCombinationSupported(
+ const V3_4::StreamConfiguration& streams,
+ V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) {
+
+ if (isInitFailed()) {
+ ALOGE("%s: camera %s. camera init failed!", __FUNCTION__, mCameraId.c_str());
+ _hidl_cb(Status::INTERNAL_ERROR, false);
+ return Void();
+ }
+
+ hidl_vec<V3_2::Stream> streamsV3_2(streams.streams.size());
+ size_t i = 0;
+ for (const auto& it : streams.streams) {
+ streamsV3_2[i++] = it.v3_2;
+ }
+ V3_2::StreamConfiguration streamConfig = {streamsV3_2, streams.operationMode};
+ auto status = ExternalCameraDeviceSession::isStreamCombinationSupported(streamConfig,
+ mSupportedFormats);
+ _hidl_cb(Status::OK, Status::OK == status);
+ return Void();
+}
#undef UPDATE
} // namespace implementation
diff --git a/camera/device/3.5/default/include/device_v3_5_impl/CameraDevice_3_5.h b/camera/device/3.5/default/include/device_v3_5_impl/CameraDevice_3_5.h
index 6bdc60f..76c8cf8 100644
--- a/camera/device/3.5/default/include/device_v3_5_impl/CameraDevice_3_5.h
+++ b/camera/device/3.5/default/include/device_v3_5_impl/CameraDevice_3_5.h
@@ -64,6 +64,10 @@
Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb);
+ Return<void> isStreamCombinationSupported(
+ const V3_4::StreamConfiguration& streams,
+ V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb);
+
private:
struct TrampolineDeviceInterface_3_5 : public ICameraDevice {
TrampolineDeviceInterface_3_5(sp<CameraDevice> parent) :
@@ -96,6 +100,13 @@
V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) override {
return mParent->getPhysicalCameraCharacteristics(physicalCameraId, _hidl_cb);
}
+
+ virtual Return<void> isStreamCombinationSupported(
+ const V3_4::StreamConfiguration& streams,
+ V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) override {
+ return mParent->isStreamCombinationSupported(streams, _hidl_cb);
+ }
+
private:
sp<CameraDevice> mParent;
};
diff --git a/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDeviceSession.h b/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDeviceSession.h
index 4d2d6b7..aa119fc 100644
--- a/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDeviceSession.h
+++ b/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDeviceSession.h
@@ -90,6 +90,12 @@
return new TrampolineSessionInterface_3_5(this);
}
+ static Status isStreamCombinationSupported(const V3_2::StreamConfiguration& config,
+ const std::vector<SupportedV4L2Format>& supportedFormats) {
+ return V3_4::implementation::ExternalCameraDeviceSession::isStreamCombinationSupported(
+ config, supportedFormats);
+ }
+
protected:
// Methods from v3.4 and earlier will trampoline to inherited implementation
Return<void> configureStreams_3_5(
diff --git a/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDevice_3_5.h b/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDevice_3_5.h
index 7db86dc..b73490c 100644
--- a/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDevice_3_5.h
+++ b/camera/device/3.5/default/include/ext_device_v3_5_impl/ExternalCameraDevice_3_5.h
@@ -67,6 +67,10 @@
Return<void> getPhysicalCameraCharacteristics(const hidl_string& physicalCameraId,
V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb);
+ Return<void> isStreamCombinationSupported(
+ const V3_4::StreamConfiguration& streams,
+ V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb);
+
protected:
virtual sp<V3_4::implementation::ExternalCameraDeviceSession> createSession(
const sp<V3_2::ICameraDeviceCallback>&,
@@ -116,6 +120,13 @@
V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) override {
return mParent->getPhysicalCameraCharacteristics(physicalCameraId, _hidl_cb);
}
+
+ virtual Return<void> isStreamCombinationSupported(
+ const V3_4::StreamConfiguration& streams,
+ V3_5::ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) override {
+ return mParent->isStreamCombinationSupported(streams, _hidl_cb);
+ }
+
private:
sp<ExternalCameraDevice> mParent;
};