Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4905d0e authored by Sunid Wilson's avatar Sunid Wilson Committed by Steve Kondik
Browse files

camera: Send proper preview window updates to HAL

During setPreviewWindow call camera_preview_window instance will
be passed to the HAL. camera_preview_window instance will never change when
ANativeWindow is updated. Hence HAL tries to use old preview window
handle not knowing that the preview window is updated. Added the
check in camera interface to reset the preview handle based on
whether ANativeWindow instance is changed or not.

CRs-Fixed: 341892
Change-Id: I6743f24cbd4467025d6fe21098c7ce6813017d5e

Frameworks: Allow CameraService to set window when preview is not running

Change-Id: Iab3f652ed3a7639c660e85c98a837215985a3296

 Camera: Enable metadata callback after snapshot

Change-Id: I734fc596b7549d4dcc00aee466e1c4be02e38c8d
CRs-fixed: 346728
parent 605f6411
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -115,6 +115,11 @@ public:
        LOGV("%s(%s) buf %p", __FUNCTION__, mName.string(), buf.get());

        if (mDevice->ops->set_preview_window) {
            LOGV("%s buf %p mPreviewWindow %p", __FUNCTION__, buf.get(), mPreviewWindow.get());
            if (mPreviewWindow.get() && (buf.get() != mPreviewWindow.get())) {
                 mDevice->ops->set_preview_window(mDevice, 0);
            }

            mPreviewWindow = buf;
            mHalPreviewWindow.user = this;
            LOGV("%s &mHalPreviewWindow %p mHalPreviewWindow.user %p", __FUNCTION__,
+28 −4
Original line number Diff line number Diff line
@@ -374,8 +374,11 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
                            (void *)cameraId);

    // Enable zoom, error, focus, and metadata messages by default
    enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS |
                  CAMERA_MSG_PREVIEW_METADATA);
    enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS
#ifndef QCOM_HARDWARE
                  | CAMERA_MSG_PREVIEW_METADATA
#endif
                  );

    // Callback is disabled by default
    mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
@@ -383,6 +386,9 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
    mPlayShutterSound = true;
    cameraService->setCameraBusy(cameraId);
    cameraService->loadSound();
#ifdef QCOM_HARDWARE
    mFaceDetection = false;
#endif
    LOG1("Client::Client X (pid %d)", callingPid);
}

@@ -522,9 +528,9 @@ void CameraService::Client::disconnect() {

    // Release the held ANativeWindow resources.
    if (mPreviewWindow != 0) {
        mHardware->setPreviewWindow(0);
        disconnectWindow(mPreviewWindow);
        mPreviewWindow = 0;
        mHardware->setPreviewWindow(mPreviewWindow);
    }
    mHardware.clear();

@@ -564,6 +570,8 @@ status_t CameraService::Client::setPreviewWindow(const sp<IBinder>& binder,
            native_window_set_buffers_transform(window.get(), mOrientation);
            result = mHardware->setPreviewWindow(window);
        }
    } else {
        result = mHardware->setPreviewWindow(window);
    }

    if (result == NO_ERROR) {
@@ -623,7 +631,10 @@ void CameraService::Client::setPreviewCallbackFlag(int callback_flag) {
// start preview mode
status_t CameraService::Client::startPreview() {
    LOG1("startPreview (pid %d)", getCallingPid());
#ifdef QCOM_HARDWARE
    if (mFaceDetection)
      enableMsgType(CAMERA_MSG_PREVIEW_METADATA);
#endif
    return startCameraMode(CAMERA_PREVIEW_MODE);
}

@@ -908,6 +919,14 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a
    }
    else if (cmd ==  CAMERA_CMD_HISTOGRAM_OFF) {
        disableMsgType(CAMERA_MSG_STATS_DATA);
#ifdef QCOM_HARDWARE
    } else if (cmd ==   CAMERA_CMD_START_FACE_DETECTION) {
      mFaceDetection = true;
      enableMsgType(CAMERA_MSG_PREVIEW_METADATA);
    } else if (cmd ==   CAMERA_CMD_STOP_FACE_DETECTION) {
      mFaceDetection = false;
      disableMsgType(CAMERA_MSG_PREVIEW_METADATA);
#endif
    }


@@ -1161,6 +1180,11 @@ void CameraService::Client::handleCompressedPicture(const sp<IMemory>& mem) {
    if (!mburstCnt) {
        LOG1("mburstCnt = %d", mburstCnt);
        disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE);
#ifdef QCOM_HARDWARE
        if (mFaceDetection) {
          enableMsgType(CAMERA_MSG_PREVIEW_METADATA);
        }
#endif
    }
    sp<ICameraClient> c = mCameraClient;
    mLock.unlock();
+3 −1
Original line number Diff line number Diff line
@@ -182,7 +182,9 @@ private:
        int                             mPreviewCallbackFlag;
        int                             mOrientation;     // Current display orientation
        bool                            mPlayShutterSound;

#ifdef QCOM_HARDWARE
        bool                            mFaceDetection;
#endif
        // Ensures atomicity among the public methods
        mutable Mutex                   mLock;
        // This is a binder of Surface or SurfaceTexture.