Camera: Allow direct selection of operating mode
Instead of a true/false switch for high-speed mode, use an integer
enum instead and define the two existing modes, plus the start
of a vendor mode space.
For all non-high-speed modes, use the normal configuration path,
but pass the operating mode to the HAL.
Test: New CTS test passes
Bug: 34853980
Change-Id: I9dc2b2a2164e9779f079a30e936c4117bcf96efe
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index 79e7ff0..4428f75 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -321,7 +321,7 @@
return binder::Status::ok();
}
-binder::Status CameraDeviceClient::endConfigure(bool isConstrainedHighSpeed) {
+binder::Status CameraDeviceClient::endConfigure(int operatingMode) {
ALOGV("%s: ending configure (%d input stream, %zu output surfaces)",
__FUNCTION__, mInputStream.configured ? 1 : 0,
mStreamMap.size());
@@ -335,7 +335,16 @@
return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
}
+ if (operatingMode < 0) {
+ String8 msg = String8::format(
+ "Camera %s: Invalid operating mode %d requested", mCameraIdStr.string(), operatingMode);
+ ALOGE("%s: %s", __FUNCTION__, msg.string());
+ return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT,
+ msg.string());
+ }
+
// Sanitize the high speed session against necessary capability bit.
+ bool isConstrainedHighSpeed = (operatingMode == ICameraDeviceUser::CONSTRAINED_HIGH_SPEED_MODE);
if (isConstrainedHighSpeed) {
CameraMetadata staticInfo = mDevice->info();
camera_metadata_entry_t entry = staticInfo.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
@@ -357,7 +366,7 @@
}
}
- status_t err = mDevice->configureStreams(isConstrainedHighSpeed);
+ status_t err = mDevice->configureStreams(operatingMode);
if (err == BAD_VALUE) {
String8 msg = String8::format("Camera %s: Unsupported set of inputs/outputs provided",
mCameraIdStr.string());
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.h b/services/camera/libcameraservice/api2/CameraDeviceClient.h
index 012beb4..2a95c88 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.h
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.h
@@ -70,70 +70,70 @@
const hardware::camera2::CaptureRequest& request,
bool streaming = false,
/*out*/
- hardware::camera2::utils::SubmitInfo *submitInfo = nullptr);
+ hardware::camera2::utils::SubmitInfo *submitInfo = nullptr) override;
// List of requests are copied.
virtual binder::Status submitRequestList(
const std::vector<hardware::camera2::CaptureRequest>& requests,
bool streaming = false,
/*out*/
- hardware::camera2::utils::SubmitInfo *submitInfo = nullptr);
+ hardware::camera2::utils::SubmitInfo *submitInfo = nullptr) override;
virtual binder::Status cancelRequest(int requestId,
/*out*/
- int64_t* lastFrameNumber = NULL);
+ int64_t* lastFrameNumber = NULL) override;
- virtual binder::Status beginConfigure();
+ virtual binder::Status beginConfigure() override;
- virtual binder::Status endConfigure(bool isConstrainedHighSpeed = false);
+ virtual binder::Status endConfigure(int operatingMode) override;
// Returns -EBUSY if device is not idle
- virtual binder::Status deleteStream(int streamId);
+ virtual binder::Status deleteStream(int streamId) override;
virtual binder::Status createStream(
const hardware::camera2::params::OutputConfiguration &outputConfiguration,
/*out*/
- int32_t* newStreamId = NULL);
+ int32_t* newStreamId = NULL) override;
// Create an input stream of width, height, and format.
virtual binder::Status createInputStream(int width, int height, int format,
/*out*/
- int32_t* newStreamId = NULL);
+ int32_t* newStreamId = NULL) override;
// Get the buffer producer of the input stream
virtual binder::Status getInputSurface(
/*out*/
- view::Surface *inputSurface);
+ view::Surface *inputSurface) override;
// Create a request object from a template.
virtual binder::Status createDefaultRequest(int templateId,
/*out*/
- hardware::camera2::impl::CameraMetadataNative* request);
+ hardware::camera2::impl::CameraMetadataNative* request) override;
// Get the static metadata for the camera
// -- Caller owns the newly allocated metadata
virtual binder::Status getCameraInfo(
/*out*/
- hardware::camera2::impl::CameraMetadataNative* cameraCharacteristics);
+ hardware::camera2::impl::CameraMetadataNative* cameraCharacteristics) override;
// Wait until all the submitted requests have finished processing
- virtual binder::Status waitUntilIdle();
+ virtual binder::Status waitUntilIdle() override;
// Flush all active and pending requests as fast as possible
virtual binder::Status flush(
/*out*/
- int64_t* lastFrameNumber = NULL);
+ int64_t* lastFrameNumber = NULL) override;
// Prepare stream by preallocating its buffers
- virtual binder::Status prepare(int32_t streamId);
+ virtual binder::Status prepare(int32_t streamId) override;
// Tear down stream resources by freeing its unused buffers
- virtual binder::Status tearDown(int32_t streamId);
+ virtual binder::Status tearDown(int32_t streamId) override;
// Prepare stream by preallocating up to maxCount of its buffers
- virtual binder::Status prepare2(int32_t maxCount, int32_t streamId);
+ virtual binder::Status prepare2(int32_t maxCount, int32_t streamId) override;
// Finalize the output configurations with surfaces not added before.
virtual binder::Status finalizeOutputConfigurations(int32_t streamId,
- const hardware::camera2::params::OutputConfiguration &outputConfiguration);
+ const hardware::camera2::params::OutputConfiguration &outputConfiguration) override;
/**
* Interface used by CameraService