diff options
author | Alex Ray <aray@google.com> | 2013-06-04 12:38:07 -0700 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2013-07-09 12:19:04 -0700 |
commit | 764e442baf0b53284a986b7ed91578fdab42142f (patch) | |
tree | c223b1e08e0a8dec9a87f0b819c2c1ab00272410 | |
parent | ef079d59d1c3e1c4bfc9e994715838c4eae92bac (diff) | |
download | hardware_libhardware-764e442baf0b53284a986b7ed91578fdab42142f.zip hardware_libhardware-764e442baf0b53284a986b7ed91578fdab42142f.tar.gz hardware_libhardware-764e442baf0b53284a986b7ed91578fdab42142f.tar.bz2 |
modules: camera: Shutter notify message support
The shutter callback timestamp should originate from the sensor itself,
since it knows exactly when the first line of the frame started
exposing. However, as a fallback (or in the CPU-painting case) query
CLOCK_BOOTTIME instead.
Change-Id: Id57c05525e9c575d009b9deb96a69557fccac16b
-rw-r--r-- | modules/camera/Camera.cpp | 26 | ||||
-rw-r--r-- | modules/camera/Camera.h | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/modules/camera/Camera.cpp b/modules/camera/Camera.cpp index 10464cb..1c307de 100644 --- a/modules/camera/Camera.cpp +++ b/modules/camera/Camera.cpp @@ -544,6 +544,7 @@ int Camera::processCaptureRequest(camera3_capture_request_t *request) // TODO: return actual captured/reprocessed settings result.result = request->settings; // TODO: asynchronously return results + notifyShutter(request->frame_number, 0); mCallbackOps->process_capture_result(mCallbackOps, &result); return 0; @@ -606,6 +607,31 @@ int Camera::processCaptureBuffer(const camera3_stream_buffer_t *in, return 0; } +void Camera::notifyShutter(uint32_t frame_number, uint64_t timestamp) +{ + int res; + struct timespec ts; + + // If timestamp is 0, get timestamp from right now instead + if (timestamp == 0) { + ALOGW("%s:%d: No timestamp provided, using CLOCK_BOOTTIME", + __func__, mId); + res = clock_gettime(CLOCK_BOOTTIME, &ts); + if (res == 0) { + timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec; + } else { + ALOGE("%s:%d: No timestamp and failed to get CLOCK_BOOTTIME %s(%d)", + __func__, mId, strerror(errno), errno); + } + } + camera3_notify_msg_t m; + memset(&m, 0, sizeof(m)); + m.type = CAMERA3_MSG_SHUTTER; + m.message.shutter.frame_number = frame_number; + m.message.shutter.timestamp = timestamp; + mCallbackOps->notify(mCallbackOps, &m); +} + void Camera::getMetadataVendorTagOps(vendor_tag_query_ops_t *ops) { ALOGV("%s:%d: ops=%p", __func__, mId, ops); diff --git a/modules/camera/Camera.h b/modules/camera/Camera.h index c7ee52d..16e1439 100644 --- a/modules/camera/Camera.h +++ b/modules/camera/Camera.h @@ -72,6 +72,8 @@ class Camera { // Process an output buffer int processCaptureBuffer(const camera3_stream_buffer_t *in, camera3_stream_buffer_t *out); + // Send a shutter notify message with start of exposure time + void notifyShutter(uint32_t frame_number, uint64_t timestamp); // Identifier used by framework to distinguish cameras const int mId; |