summaryrefslogtreecommitdiffstats
path: root/modules/camera
diff options
context:
space:
mode:
authorAlex Ray <aray@google.com>2013-06-04 12:38:07 -0700
committerAlex Ray <aray@google.com>2013-07-09 12:19:04 -0700
commit764e442baf0b53284a986b7ed91578fdab42142f (patch)
treec223b1e08e0a8dec9a87f0b819c2c1ab00272410 /modules/camera
parentef079d59d1c3e1c4bfc9e994715838c4eae92bac (diff)
downloadhardware_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
Diffstat (limited to 'modules/camera')
-rw-r--r--modules/camera/Camera.cpp26
-rw-r--r--modules/camera/Camera.h2
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;