OSDN Git Service

Camera3: Provide consumer usage flags to HAL for each stream
authorEino-Ville Talvala <etalvala@google.com>
Tue, 30 Jul 2013 21:36:03 +0000 (14:36 -0700)
committerEino-Ville Talvala <etalvala@google.com>
Mon, 5 Aug 2013 20:56:43 +0000 (13:56 -0700)
At stream configure time, pass on the stream's consumer usage flags
to the HAL, to speed up final hardware configuration.

Bug: 9592202
Change-Id: Ie467be053be36a09e482f5f05cad65df42d66476

services/camera/libcameraservice/device3/Camera3IOStreamBase.h
services/camera/libcameraservice/device3/Camera3InputStream.cpp
services/camera/libcameraservice/device3/Camera3InputStream.h
services/camera/libcameraservice/device3/Camera3OutputStream.cpp
services/camera/libcameraservice/device3/Camera3OutputStream.h
services/camera/libcameraservice/device3/Camera3Stream.cpp
services/camera/libcameraservice/device3/Camera3Stream.h

index 74c4484..9432a59 100644 (file)
@@ -77,6 +77,8 @@ class Camera3IOStreamBase :
 
     virtual size_t   getBufferCountLocked();
 
+    virtual status_t getEndpointUsage(uint32_t *usage) = 0;
+
     status_t getBufferPreconditionCheckLocked() const;
     status_t returnBufferPreconditionCheckLocked() const;
 
index e9a9c2b..1889a11 100644 (file)
@@ -234,6 +234,12 @@ status_t Camera3InputStream::configureQueueLocked() {
     return OK;
 }
 
+status_t Camera3InputStream::getEndpointUsage(uint32_t *usage) {
+    // Per HAL3 spec, input streams have 0 for their initial usage field.
+    *usage = 0;
+    return OK;
+}
+
 }; // namespace camera3
 
 }; // namespace android
index 8adda88..91d6f16 100644 (file)
@@ -79,6 +79,8 @@ class Camera3InputStream : public Camera3IOStreamBase {
 
     virtual status_t configureQueueLocked();
 
+    virtual status_t getEndpointUsage(uint32_t *usage);
+
 }; // class Camera3InputStream
 
 }; // namespace camera3
index 0ec2b05..35cb5ba 100644 (file)
@@ -364,6 +364,17 @@ status_t Camera3OutputStream::disconnectLocked() {
     return OK;
 }
 
+status_t Camera3OutputStream::getEndpointUsage(uint32_t *usage) {
+
+    status_t res;
+    int32_t u = 0;
+    res = mConsumer->query(mConsumer.get(),
+            NATIVE_WINDOW_CONSUMER_USAGE_BITS, &u);
+    *usage = u;
+
+    return res;
+}
+
 }; // namespace camera3
 
 }; // namespace android
index 774fbdd..6cbb9f4 100644 (file)
@@ -92,6 +92,9 @@ class Camera3OutputStream :
 
     virtual status_t configureQueueLocked();
     virtual status_t disconnectLocked();
+
+    virtual status_t getEndpointUsage(uint32_t *usage);
+
 }; // class Camera3OutputStream
 
 } // namespace camera3
index ab563df..a6872aa 100644 (file)
@@ -77,7 +77,9 @@ int Camera3Stream::getFormat() const {
 }
 
 camera3_stream* Camera3Stream::startConfiguration() {
+    ATRACE_CALL();
     Mutex::Autolock l(mLock);
+    status_t res;
 
     switch (mState) {
         case STATE_ERROR:
@@ -107,8 +109,15 @@ camera3_stream* Camera3Stream::startConfiguration() {
             return NULL;
     }
 
-    oldUsage = usage;
-    oldMaxBuffers = max_buffers;
+    oldUsage = camera3_stream::usage;
+    oldMaxBuffers = camera3_stream::max_buffers;
+
+    res = getEndpointUsage(&(camera3_stream::usage));
+    if (res != OK) {
+        ALOGE("%s: Cannot query consumer endpoint usage!",
+                __FUNCTION__);
+        return NULL;
+    }
 
     if (mState == STATE_CONSTRUCTED) {
         mState = STATE_IN_CONFIG;
@@ -125,6 +134,7 @@ bool Camera3Stream::isConfiguring() const {
 }
 
 status_t Camera3Stream::finishConfiguration(camera3_device *hal3Device) {
+    ATRACE_CALL();
     Mutex::Autolock l(mLock);
     switch (mState) {
         case STATE_ERROR:
@@ -147,8 +157,8 @@ status_t Camera3Stream::finishConfiguration(camera3_device *hal3Device) {
     // Check if the stream configuration is unchanged, and skip reallocation if
     // so. As documented in hardware/camera3.h:configure_streams().
     if (mState == STATE_IN_RECONFIG &&
-            oldUsage == usage &&
-            oldMaxBuffers == max_buffers) {
+            oldUsage == camera3_stream::usage &&
+            oldMaxBuffers == camera3_stream::max_buffers) {
         mState = STATE_CONFIGURED;
         return OK;
     }
index 69d81e4..b64fd86 100644 (file)
@@ -263,6 +263,10 @@ class Camera3Stream :
     // Get the total number of buffers in the queue
     virtual size_t   getBufferCountLocked() = 0;
 
+    // Get the usage flags for the other endpoint, or return
+    // INVALID_OPERATION if they cannot be obtained.
+    virtual status_t getEndpointUsage(uint32_t *usage) = 0;
+
   private:
     uint32_t oldUsage;
     uint32_t oldMaxBuffers;