diff options
Diffstat (limited to 'services')
15 files changed, 137 insertions, 62 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index 7766b90..fd5a426 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -487,12 +487,12 @@ status_t CameraService::initializeShimMetadata(int cameraId) { } if (client == NULL) { needsNewClient = true; - ret = connectHelperLocked(/*cameraClient*/NULL, // Empty binder callbacks + ret = connectHelperLocked(/*out*/client, + /*cameraClient*/NULL, // Empty binder callbacks cameraId, internalPackageName, uid, - pid, - client); + pid); if (ret != OK) { // Error already logged by callee @@ -659,14 +659,17 @@ bool CameraService::canConnectUnsafe(int cameraId, return true; } -status_t CameraService::connectHelperLocked(const sp<ICameraClient>& cameraClient, - int cameraId, - const String16& clientPackageName, - int clientUid, - int callingPid, - /*out*/ - sp<Client>& client, - int halVersion) { +status_t CameraService::connectHelperLocked( + /*out*/ + sp<Client>& client, + /*in*/ + const sp<ICameraClient>& cameraClient, + int cameraId, + const String16& clientPackageName, + int clientUid, + int callingPid, + int halVersion, + bool legacyMode) { int facing = -1; int deviceVersion = getDeviceVersion(cameraId, &facing); @@ -678,7 +681,7 @@ status_t CameraService::connectHelperLocked(const sp<ICameraClient>& cameraClien case CAMERA_DEVICE_API_VERSION_1_0: client = new CameraClient(this, cameraClient, clientPackageName, cameraId, - facing, callingPid, clientUid, getpid()); + facing, callingPid, clientUid, getpid(), legacyMode); break; case CAMERA_DEVICE_API_VERSION_2_0: case CAMERA_DEVICE_API_VERSION_2_1: @@ -687,7 +690,7 @@ status_t CameraService::connectHelperLocked(const sp<ICameraClient>& cameraClien case CAMERA_DEVICE_API_VERSION_3_2: client = new Camera2Client(this, cameraClient, clientPackageName, cameraId, - facing, callingPid, clientUid, getpid()); + facing, callingPid, clientUid, getpid(), legacyMode); break; case -1: ALOGE("Invalid camera id %d", cameraId); @@ -704,7 +707,7 @@ status_t CameraService::connectHelperLocked(const sp<ICameraClient>& cameraClien // Only support higher HAL version device opened as HAL1.0 device. client = new CameraClient(this, cameraClient, clientPackageName, cameraId, - facing, callingPid, clientUid, getpid()); + facing, callingPid, clientUid, getpid(), legacyMode); } else { // Other combinations (e.g. HAL3.x open as HAL2.x) are not supported yet. ALOGE("Invalid camera HAL version %x: HAL %x device can only be" @@ -760,12 +763,12 @@ status_t CameraService::connect( return OK; } - status = connectHelperLocked(cameraClient, + status = connectHelperLocked(/*out*/client, + cameraClient, cameraId, clientPackageName, clientUid, - callingPid, - client); + callingPid); if (status != OK) { return status; } @@ -823,13 +826,14 @@ status_t CameraService::connectLegacy( return OK; } - status = connectHelperLocked(cameraClient, + status = connectHelperLocked(/*out*/client, + cameraClient, cameraId, clientPackageName, clientUid, callingPid, - client, - halVersion); + halVersion, + /*legacyMode*/true); if (status != OK) { return status; } diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index cb98c96..a7328cf 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -452,14 +452,17 @@ private: * * Returns OK on success, or a negative error code. */ - status_t connectHelperLocked(const sp<ICameraClient>& cameraClient, - int cameraId, - const String16& clientPackageName, - int clientUid, - int callingPid, - /*out*/ - sp<Client>& client, - int halVersion = CAMERA_HAL_API_VERSION_UNSPECIFIED); + status_t connectHelperLocked( + /*out*/ + sp<Client>& client, + /*in*/ + const sp<ICameraClient>& cameraClient, + int cameraId, + const String16& clientPackageName, + int clientUid, + int callingPid, + int halVersion = CAMERA_HAL_API_VERSION_UNSPECIFIED, + bool legacyMode = false); }; } // namespace android diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp index 5eb5181..bc40971 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.cpp +++ b/services/camera/libcameraservice/api1/Camera2Client.cpp @@ -53,7 +53,8 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService, int cameraFacing, int clientPid, uid_t clientUid, - int servicePid): + int servicePid, + bool legacyMode): Camera2ClientBase(cameraService, cameraClient, clientPackageName, cameraId, cameraFacing, clientPid, clientUid, servicePid), mParameters(cameraId, cameraFacing) @@ -62,6 +63,8 @@ Camera2Client::Camera2Client(const sp<CameraService>& cameraService, SharedParameters::Lock l(mParameters); l.mParameters.state = Parameters::DISCONNECTED; + + mLegacyMode = legacyMode; } status_t Camera2Client::initialize(camera_module_t *module) @@ -1449,6 +1452,13 @@ status_t Camera2Client::commandEnableShutterSoundL(bool enable) { return OK; } + // the camera2 api legacy mode can unconditionally disable the shutter sound + if (mLegacyMode) { + ALOGV("%s: Disable shutter sound in legacy mode", __FUNCTION__); + l.mParameters.playShutterSound = false; + return OK; + } + // Disabling shutter sound may not be allowed. In that case only // allow the mediaserver process to disable the sound. char value[PROPERTY_VALUE_MAX]; diff --git a/services/camera/libcameraservice/api1/Camera2Client.h b/services/camera/libcameraservice/api1/Camera2Client.h index 5ce757a..f5c3a30 100644 --- a/services/camera/libcameraservice/api1/Camera2Client.h +++ b/services/camera/libcameraservice/api1/Camera2Client.h @@ -89,7 +89,8 @@ public: int cameraFacing, int clientPid, uid_t clientUid, - int servicePid); + int servicePid, + bool legacyMode); virtual ~Camera2Client(); @@ -203,6 +204,7 @@ private: bool mAfInMotion; /** Utility members */ + bool mLegacyMode; // Wait until the camera device has received the latest control settings status_t syncWithDevice(); diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index fb6b678..abe1235 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -38,7 +38,7 @@ CameraClient::CameraClient(const sp<CameraService>& cameraService, const String16& clientPackageName, int cameraId, int cameraFacing, int clientPid, int clientUid, - int servicePid): + int servicePid, bool legacyMode): Client(cameraService, cameraClient, clientPackageName, cameraId, cameraFacing, clientPid, clientUid, servicePid) { @@ -54,6 +54,7 @@ CameraClient::CameraClient(const sp<CameraService>& cameraService, // Callback is disabled by default mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP; mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT); + mLegacyMode = legacyMode; mPlayShutterSound = true; LOG1("CameraClient::CameraClient X (pid %d, id %d)", callingPid, cameraId); } @@ -576,6 +577,13 @@ status_t CameraClient::enableShutterSound(bool enable) { return OK; } + // the camera2 api legacy mode can unconditionally disable the shutter sound + if (mLegacyMode) { + ALOGV("%s: Disable shutter sound in legacy mode", __FUNCTION__); + mPlayShutterSound = false; + return OK; + } + // Disabling shutter sound may not be allowed. In that case only // allow the mediaserver process to disable the sound. char value[PROPERTY_VALUE_MAX]; diff --git a/services/camera/libcameraservice/api1/CameraClient.h b/services/camera/libcameraservice/api1/CameraClient.h index 4b89564..6779f5e 100644 --- a/services/camera/libcameraservice/api1/CameraClient.h +++ b/services/camera/libcameraservice/api1/CameraClient.h @@ -64,7 +64,8 @@ public: int cameraFacing, int clientPid, int clientUid, - int servicePid); + int servicePid, + bool legacyMode = false); ~CameraClient(); status_t initialize(camera_module_t *module); @@ -129,6 +130,7 @@ private: int mPreviewCallbackFlag; int mOrientation; // Current display orientation bool mPlayShutterSound; + bool mLegacyMode; // camera2 api legacy mode? // Ensures atomicity among the public methods mutable Mutex mLock; diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp index 37de610..b388079 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp @@ -51,7 +51,8 @@ ZslProcessor3::ZslProcessor3( mZslStreamId(NO_STREAM), mFrameListHead(0), mZslQueueHead(0), - mZslQueueTail(0) { + mZslQueueTail(0), + mHasFocuser(false) { // Initialize buffer queue and frame list based on pipeline max depth. size_t pipelineMaxDepth = kDefaultMaxPipelineDepth; if (client != 0) { @@ -67,6 +68,11 @@ ZslProcessor3::ZslProcessor3( " use default pipeline max depth %zu", __FUNCTION__, kDefaultMaxPipelineDepth); } + + entry = device->info().find(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE); + if (entry.count > 0 && entry.data.f[0] != 0.) { + mHasFocuser = true; + } } } @@ -489,20 +495,23 @@ nsecs_t ZslProcessor3::getCandidateTimestampLocked(size_t* metadataIdx) const { continue; } - // Make sure the candidate frame has good focus. - entry = frame.find(ANDROID_CONTROL_AF_STATE); - if (entry.count == 0) { - ALOGW("%s: ZSL queue frame has no AF state field!", - __FUNCTION__); - continue; - } - uint8_t afState = entry.data.u8[0]; - if (afState != ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED && - afState != ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED && - afState != ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) { - ALOGW("%s: ZSL queue frame AF state is %d is not good for capture, skip it", - __FUNCTION__, afState); - continue; + // Check AF state if device has focuser + if (mHasFocuser) { + // Make sure the candidate frame has good focus. + entry = frame.find(ANDROID_CONTROL_AF_STATE); + if (entry.count == 0) { + ALOGW("%s: ZSL queue frame has no AF state field!", + __FUNCTION__); + continue; + } + uint8_t afState = entry.data.u8[0]; + if (afState != ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED && + afState != ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED && + afState != ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) { + ALOGW("%s: ZSL queue frame AF state is %d is not good for capture, skip it", + __FUNCTION__, afState); + continue; + } } minTimestamp = frameTimestamp; diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h index dfb1457..daa352b 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h @@ -121,6 +121,8 @@ class ZslProcessor3 : CameraMetadata mLatestCapturedRequest; + bool mHasFocuser; + virtual bool threadLoop(); status_t clearZslQueueLocked(); diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp index 86f82a3..80c797a 100644 --- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp @@ -254,9 +254,17 @@ status_t CameraDeviceClient::beginConfigure() { } status_t CameraDeviceClient::endConfigure() { - // TODO: Implement this. - ALOGE("%s: Not implemented yet.", __FUNCTION__); - return OK; + ALOGV("%s: ending configure (%zu streams)", + __FUNCTION__, mStreamMap.size()); + + status_t res; + if ( (res = checkPid(__FUNCTION__) ) != OK) return res; + + Mutex::Autolock icl(mBinderSerializationLock); + + if (!mDevice.get()) return DEAD_OBJECT; + + return mDevice->configureStreams(); } status_t CameraDeviceClient::deleteStream(int streamId) { diff --git a/services/camera/libcameraservice/common/CameraDeviceBase.h b/services/camera/libcameraservice/common/CameraDeviceBase.h index 9e124b0..d26e20c 100644 --- a/services/camera/libcameraservice/common/CameraDeviceBase.h +++ b/services/camera/libcameraservice/common/CameraDeviceBase.h @@ -141,6 +141,18 @@ class CameraDeviceBase : public virtual RefBase { virtual status_t deleteReprocessStream(int id) = 0; /** + * Take the currently-defined set of streams and configure the HAL to use + * them. This is a long-running operation (may be several hundered ms). + * + * The device must be idle (see waitUntilDrained) before calling this. + * + * Returns OK on success; otherwise on error: + * - BAD_VALUE if the set of streams was invalid (e.g. fmts or sizes) + * - INVALID_OPERATION if the device was in the wrong state + */ + virtual status_t configureStreams() = 0; + + /** * Create a metadata buffer with fields that the HAL device believes are * best for the given use case */ diff --git a/services/camera/libcameraservice/device2/Camera2Device.cpp b/services/camera/libcameraservice/device2/Camera2Device.cpp index d473a76..8caadd6 100644 --- a/services/camera/libcameraservice/device2/Camera2Device.cpp +++ b/services/camera/libcameraservice/device2/Camera2Device.cpp @@ -415,6 +415,19 @@ status_t Camera2Device::deleteReprocessStream(int id) { return OK; } +status_t Camera2Device::configureStreams() { + ATRACE_CALL(); + ALOGV("%s: E", __FUNCTION__); + + /** + * HAL2 devices do not need to configure streams; + * streams are created on the fly. + */ + ALOGW("%s: No-op for HAL2 devices", __FUNCTION__); + + return OK; +} + status_t Camera2Device::createDefaultRequest(int templateId, CameraMetadata *request) { diff --git a/services/camera/libcameraservice/device2/Camera2Device.h b/services/camera/libcameraservice/device2/Camera2Device.h index d0ca46e..2a3f1d9 100644 --- a/services/camera/libcameraservice/device2/Camera2Device.h +++ b/services/camera/libcameraservice/device2/Camera2Device.h @@ -64,6 +64,8 @@ class Camera2Device: public CameraDeviceBase { virtual status_t setStreamTransform(int id, int transform); virtual status_t deleteStream(int id); virtual status_t deleteReprocessStream(int id); + // No-op on HAL2 devices + virtual status_t configureStreams(); virtual status_t createDefaultRequest(int templateId, CameraMetadata *request); virtual status_t waitUntilDrained(); virtual status_t setNotifyCallback(NotificationListener *listener); diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index 0ca7f6d..0d33406 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -1000,6 +1000,15 @@ status_t Camera3Device::deleteReprocessStream(int id) { return INVALID_OPERATION; } +status_t Camera3Device::configureStreams() { + ATRACE_CALL(); + ALOGV("%s: E", __FUNCTION__); + + Mutex::Autolock il(mInterfaceLock); + Mutex::Autolock l(mLock); + + return configureStreamsLocked(); +} status_t Camera3Device::createDefaultRequest(int templateId, CameraMetadata *request) { diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h index 539d919..915c024 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.h +++ b/services/camera/libcameraservice/device3/Camera3Device.h @@ -114,6 +114,8 @@ class Camera3Device : virtual status_t deleteStream(int id); virtual status_t deleteReprocessStream(int id); + virtual status_t configureStreams(); + virtual status_t createDefaultRequest(int templateId, CameraMetadata *request); // Transitions to the idle state on success diff --git a/services/camera/libcameraservice/device3/Camera3Stream.cpp b/services/camera/libcameraservice/device3/Camera3Stream.cpp index d7b1871..3f6254f 100644 --- a/services/camera/libcameraservice/device3/Camera3Stream.cpp +++ b/services/camera/libcameraservice/device3/Camera3Stream.cpp @@ -381,18 +381,7 @@ status_t Camera3Stream::registerBuffersLocked(camera3_device *hal3Device) { if (hal3Device->common.version >= CAMERA_DEVICE_API_VERSION_3_2) { ALOGV("%s: register_stream_buffers unused as of HAL3.2", __FUNCTION__); - /** - * Skip the NULL check if camera.dev.register_stream is 1. - * - * For development-validation purposes only. - * - * TODO: Remove the property check before shipping L (b/13914251). - */ - char value[PROPERTY_VALUE_MAX] = { '\0', }; - property_get("camera.dev.register_stream", value, "0"); - int propInt = atoi(value); - - if (propInt == 0 && hal3Device->ops->register_stream_buffers != NULL) { + if (hal3Device->ops->register_stream_buffers != NULL) { ALOGE("%s: register_stream_buffers is deprecated in HAL3.2; " "must be set to NULL in camera3_device::ops", __FUNCTION__); return INVALID_OPERATION; |