summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice
diff options
context:
space:
mode:
Diffstat (limited to 'services/camera/libcameraservice')
-rw-r--r--services/camera/libcameraservice/Camera2Client.cpp2
-rw-r--r--services/camera/libcameraservice/camera2/CaptureSequencer.cpp13
-rw-r--r--services/camera/libcameraservice/camera2/FrameProcessor.cpp11
-rw-r--r--services/camera/libcameraservice/camera2/Parameters.cpp15
-rw-r--r--services/camera/libcameraservice/camera2/ZslProcessor.cpp78
-rw-r--r--services/camera/libcameraservice/camera2/ZslProcessor.h2
6 files changed, 99 insertions, 22 deletions
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
index eb72412..4fad83e 100644
--- a/services/camera/libcameraservice/Camera2Client.cpp
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -345,6 +345,8 @@ status_t Camera2Client::dump(int fd, const Vector<String16>& args) {
mFrameProcessor->dump(fd, args);
+ mZslProcessor->dump(fd, args);
+
result = " Device dump:\n";
write(fd, result.string(), result.size());
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
index 678f114..eb9eb5b 100644
--- a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
@@ -274,8 +274,14 @@ CaptureSequencer::CaptureState CaptureSequencer::manageZslStart(
// TODO: Actually select the right thing here.
res = processor->pushToReprocess(mCaptureId);
if (res != OK) {
- ALOGW("%s: Camera %d: Failed to use ZSL queue, falling back to standard capture",
- __FUNCTION__, client->getCameraId());
+ if (res == NOT_ENOUGH_DATA) {
+ ALOGV("%s: Camera %d: ZSL queue doesn't have good frame, "
+ "falling back to normal capture", __FUNCTION__,
+ client->getCameraId());
+ } else {
+ ALOGE("%s: Camera %d: Error in ZSL queue: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ }
return STANDARD_START;
}
@@ -410,7 +416,8 @@ CaptureSequencer::CaptureState CaptureSequencer::manageStandardCapture(
return DONE;
}
- if (l.mParameters.playShutterSound) {
+ if (l.mParameters.playShutterSound &&
+ l.mParameters.state == Parameters::STILL_CAPTURE) {
client->getCameraService()->playSound(CameraService::SOUND_SHUTTER);
}
diff --git a/services/camera/libcameraservice/camera2/FrameProcessor.cpp b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
index e24db0b..a7d19aa 100644
--- a/services/camera/libcameraservice/camera2/FrameProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
@@ -174,8 +174,7 @@ status_t FrameProcessor::processFaceDetect(const CameraMetadata &frame,
SharedParameters::Lock l(client->getParameters());
entry = frame.find(ANDROID_STATS_FACE_RECTANGLES);
if (entry.count == 0) {
- ALOGE("%s: Camera %d: Unable to read face rectangles",
- __FUNCTION__, client->getCameraId());
+ // No faces this frame
return res;
}
metadata.number_of_faces = entry.count / 4;
@@ -220,7 +219,13 @@ status_t FrameProcessor::processFaceDetect(const CameraMetadata &frame,
faces.setCapacity(metadata.number_of_faces);
- for (int i = 0; i < metadata.number_of_faces; i++) {
+ size_t maxFaces = metadata.number_of_faces;
+ for (size_t i = 0; i < maxFaces; i++) {
+ if (faceScores[i] == 0) {
+ metadata.number_of_faces--;
+ continue;
+ }
+
camera_face_t face;
face.rect[0] = l.mParameters.arrayXToNormalized(faceRects[i*4 + 0]);
diff --git a/services/camera/libcameraservice/camera2/Parameters.cpp b/services/camera/libcameraservice/camera2/Parameters.cpp
index c07a6ac..0a72c5f 100644
--- a/services/camera/libcameraservice/camera2/Parameters.cpp
+++ b/services/camera/libcameraservice/camera2/Parameters.cpp
@@ -750,12 +750,12 @@ status_t Parameters::initialize(const CameraMetadata *info) {
previewCallbackFlags = 0;
char value[PROPERTY_VALUE_MAX];
- property_get("camera.zsl_mode", value, "0");
+ property_get("camera.disable_zsl_mode", value, "0");
if (!strcmp(value,"1")) {
- ALOGI("Camera %d: Enabling ZSL mode", cameraId);
- zslMode = true;
- } else {
+ ALOGI("Camera %d: Disabling ZSL mode", cameraId);
zslMode = false;
+ } else {
+ zslMode = true;
}
lightFx = LIGHTFX_NONE;
@@ -1380,8 +1380,11 @@ status_t Parameters::updateRequest(CameraMetadata *request) const {
&reqControlMode, 1);
if (res != OK) return res;
- uint8_t reqSceneMode = enableFaceDetect ?
- (uint8_t)ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY : sceneMode;
+ uint8_t reqSceneMode =
+ (sceneMode !=
+ (uint8_t)ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED) ? sceneMode :
+ enableFaceDetect ? (uint8_t)ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY :
+ (uint8_t)ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
res = request->update(ANDROID_CONTROL_SCENE_MODE,
&reqSceneMode, 1);
if (res != OK) return res;
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.cpp b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
index f17b5d3..8906cd7 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
@@ -87,12 +87,14 @@ void ZslProcessor::onFrameAvailable(int32_t frameId, CameraMetadata &frame) {
void ZslProcessor::onBufferReleased(buffer_handle_t *handle) {
Mutex::Autolock l(mInputMutex);
- buffer_handle_t *expectedHandle =
- &(mZslQueue[mZslQueueTail].buffer.mGraphicBuffer->handle);
-
- if (handle != expectedHandle) {
- ALOGE("%s: Expected buffer %p, got buffer %p",
- __FUNCTION__, expectedHandle, handle);
+ // Verify that the buffer is in our queue
+ size_t i = 0;
+ for (; i < mZslQueue.size(); i++) {
+ if (&(mZslQueue[i].buffer.mGraphicBuffer->handle) == handle) break;
+ }
+ if (i == mZslQueue.size()) {
+ ALOGW("%s: Released buffer %p not found in queue",
+ __FUNCTION__, handle);
}
mState = RUNNING;
@@ -232,7 +234,12 @@ status_t ZslProcessor::pushToReprocess(int32_t requestId) {
status_t res;
sp<Camera2Client> client = mClient.promote();
- if (client == 0) return false;
+ if (client == 0) return INVALID_OPERATION;
+
+ IF_ALOGV() {
+ dumpZslQueue(-1);
+ }
+
if (mZslQueueTail != mZslQueueHead) {
CameraMetadata request;
@@ -242,9 +249,26 @@ status_t ZslProcessor::pushToReprocess(int32_t requestId) {
index = (index + 1) % kZslBufferDepth;
}
if (request.isEmpty()) {
- ALOGE("No request in ZSL queue to send!");
+ ALOGV("%s: ZSL queue has no valid frames to send yet.",
+ __FUNCTION__);
+ return NOT_ENOUGH_DATA;
+ }
+ // Verify that the frame is reasonable for reprocessing
+
+ camera_metadata_entry_t entry;
+ entry = request.find(ANDROID_CONTROL_AE_STATE);
+ if (entry.count == 0) {
+ ALOGE("%s: ZSL queue frame has no AE state field!",
+ __FUNCTION__);
return BAD_VALUE;
}
+ if (entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_CONVERGED &&
+ entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_LOCKED) {
+ ALOGV("%s: ZSL queue frame AE state is %d, need full capture",
+ __FUNCTION__, entry.data.u8[0]);
+ return NOT_ENOUGH_DATA;
+ }
+
buffer_handle_t *handle =
&(mZslQueue[index].buffer.mGraphicBuffer->handle);
@@ -282,13 +306,15 @@ status_t ZslProcessor::pushToReprocess(int32_t requestId) {
mState = LOCKED;
} else {
- ALOGE("%s: Nothing to push", __FUNCTION__);
- return BAD_VALUE;
+ ALOGV("%s: No ZSL buffers yet", __FUNCTION__);
+ return NOT_ENOUGH_DATA;
}
return OK;
}
void ZslProcessor::dump(int fd, const Vector<String16>& args) const {
+ Mutex::Autolock l(mInputMutex);
+ dumpZslQueue(fd);
}
bool ZslProcessor::threadLoop() {
@@ -413,5 +439,37 @@ void ZslProcessor::findMatchesLocked() {
}
}
+void ZslProcessor::dumpZslQueue(int fd) const {
+ String8 header("ZSL queue contents:");
+ String8 indent(" ");
+ ALOGV("%s", header.string());
+ if (fd != -1) {
+ header = indent + header + "\n";
+ write(fd, header.string(), header.size());
+ }
+ for (size_t i = 0; i < mZslQueue.size(); i++) {
+ const ZslPair &queueEntry = mZslQueue[i];
+ nsecs_t bufferTimestamp = queueEntry.buffer.mTimestamp;
+ camera_metadata_ro_entry_t entry;
+ nsecs_t frameTimestamp = 0;
+ int frameAeState = -1;
+ if (!queueEntry.frame.isEmpty()) {
+ entry = queueEntry.frame.find(ANDROID_SENSOR_TIMESTAMP);
+ if (entry.count > 0) frameTimestamp = entry.data.i64[0];
+ entry = queueEntry.frame.find(ANDROID_CONTROL_AE_STATE);
+ if (entry.count > 0) frameAeState = entry.data.u8[0];
+ }
+ String8 result =
+ String8::format(" %d: b: %lld\tf: %lld, AE state: %d", i,
+ bufferTimestamp, frameTimestamp, frameAeState);
+ ALOGV("%s", result.string());
+ if (fd != -1) {
+ result = indent + result + "\n";
+ write(fd, result.string(), result.size());
+ }
+
+ }
+}
+
}; // namespace camera2
}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.h b/services/camera/libcameraservice/camera2/ZslProcessor.h
index b60f61b..268f4f5 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.h
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.h
@@ -110,6 +110,8 @@ class ZslProcessor:
// Match up entries from frame list to buffers in ZSL queue
void findMatchesLocked();
+
+ void dumpZslQueue(int id) const;
};