camera3: Update vendor tag spec for HAL 3.2.

- Deprecates vendor tag specification in camera3 device.
- Moves vendor tag ops declaration to camera metadata library and
  cleans up definitions.
- Updates the example HAL.

Change-Id: Ifb16bb0d4bbc896bc32d33dd150e7e174af57dad
diff --git a/include/hardware/camera3.h b/include/hardware/camera3.h
index 6009706..f93c066 100644
--- a/include/hardware/camera3.h
+++ b/include/hardware/camera3.h
@@ -21,19 +21,25 @@
 #include "camera_common.h"
 
 /**
- * Camera device HAL 3.1 [ CAMERA_DEVICE_API_VERSION_3_1 ]
+ * Camera device HAL 3.2 [ CAMERA_DEVICE_API_VERSION_3_2 ]
  *
  * EXPERIMENTAL.
  *
  * Supports the android.hardware.Camera API.
  *
  * Camera devices that support this version of the HAL must return
- * CAMERA_DEVICE_API_VERSION_3_1 in camera_device_t.common.version and in
+ * CAMERA_DEVICE_API_VERSION_3_2 in camera_device_t.common.version and in
  * camera_info_t.device_version (from camera_module_t.get_camera_info).
  *
- * Camera modules that may contain version 3.1 devices must implement at least
- * version 2.0 of the camera module interface (as defined by
- * camera_module_t.common.module_api_version).
+ * CAMERA_DEVICE_API_VERSION_3_2:
+ *    Camera modules that may contain version 3.2 devices must implement at
+ *    least version 2.2 of the camera module interface (as defined by
+ *    camera_module_t.common.module_api_version).
+ *
+ * <= CAMERA_DEVICE_API_VERSION_3_1:
+ *    Camera modules that may contain version 3.1 (or 3.0) devices must
+ *    implement at least version 2.0 of the camera module interface
+ *    (as defined by camera_module_t.common.module_api_version).
  *
  * See camera_common.h for more versioning details.
  *
@@ -88,6 +94,11 @@
  *   - configure_streams passes consumer usage flags to the HAL.
  *
  *   - flush call to drop all in-flight requests/buffers as fast as possible.
+ *
+ * 3.2: Minor revision of expanded-capability HAL:
+ *
+ *   - Deprecates get_metadata_vendor_tag_ops.  Please use get_vendor_tag_ops
+ *     in camera_common.h instead.
  */
 
 /**
@@ -2081,6 +2092,10 @@
      * The definition of vendor_tag_query_ops_t can be found in
      * system/media/camera/include/system/camera_metadata.h.
      *
+     * >= CAMERA_DEVICE_API_VERSION_3_2:
+     *    DEPRECATED. This function has been deprecated and should be set to
+     *    NULL by the HAL.  Please implement get_vendor_tag_ops in camera_common.h
+     *    instead.
      */
     void (*get_metadata_vendor_tag_ops)(const struct camera3_device*,
             vendor_tag_query_ops_t* ops);
diff --git a/include/hardware/camera_common.h b/include/hardware/camera_common.h
index 3a1233f..2508022 100644
--- a/include/hardware/camera_common.h
+++ b/include/hardware/camera_common.h
@@ -24,6 +24,7 @@
 #include <sys/types.h>
 #include <cutils/native_handle.h>
 #include <system/camera.h>
+#include <system/camera_vendor_tags.h>
 #include <hardware/hardware.h>
 #include <hardware/gralloc.h>
 
@@ -100,8 +101,9 @@
 #define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1)
 #define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)
 #define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1)
+#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2)
 
-// Device version 2.x is outdated; device version 3.0 is experimental
+// Device version 2.x is outdated; device version 3.x is experimental
 #define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_1_0
 
 /**
@@ -251,65 +253,6 @@
 
 } camera_module_callbacks_t;
 
-/**
- * Set up vendor-specific tag query methods. These are needed to properly query
- * entries with vendor-specified tags, potentially returned by get_camera_info.
- *
- * This should be used in place of vendor_tag_query_ops, which are deprecated.
- */
-typedef struct vendor_tag_ops vendor_tag_ops_t;
-struct vendor_tag_ops {
-    /**
-     * Get the number of vendor tags supported on this platform. Used to
-     * calculate the size of buffer needed for holding the array of all tags
-     * returned by get_all_tags().
-     */
-    int (*get_tag_count)(const vendor_tag_ops_t *v);
-
-    /**
-     * Fill an array with all the supported vendor tags on this platform.
-     * get_tag_count() returns the number of tags supported, and
-     * tag_array will be allocated with enough space to hold all of the tags.
-     */
-    void (*get_all_tags)(const vendor_tag_ops_t *v, uint32_t *tag_array);
-
-    /**
-     * Get vendor section name for a vendor-specified entry tag. Only called for
-     * vendor-defined tags. The section name must start with the name of the
-     * vendor in the Java package style. For example, CameraZoom Inc. must
-     * prefix their sections with "com.camerazoom." Must return NULL if the tag
-     * is outside the bounds of vendor-defined sections.
-     *
-     * There may be different vendor-defined tag sections, for example the
-     * phone maker, the chipset maker, and the camera module maker may each
-     * have their own "com.vendor."-prefixed section.
-     *
-     * The memory pointed to by the return value must remain valid for the
-     * lifetime that the module is loaded, and is owned by the module.
-     */
-    const char *(*get_section_name)(const vendor_tag_ops_t *v, uint32_t tag);
-
-    /**
-     * Get tag name for a vendor-specified entry tag. Only called for
-     * vendor-defined tags. Must return NULL if the it is not a vendor-defined
-     * tag.
-     *
-     * The memory pointed to by the return value must remain valid for the
-     * lifetime that the module is loaded, and is owned by the module.
-     */
-    const char *(*get_tag_name)(const vendor_tag_ops_t *v, uint32_t tag);
-
-    /**
-     * Get tag type for a vendor-specified entry tag. Only called for tags >=
-     * 0x80000000. Must return -1 if the tag is outside the bounds of
-     * vendor-defined sections.
-     */
-    int (*get_tag_type)(const vendor_tag_ops_t *v, uint32_t tag);
-
-    /* reserved for future use */
-    void* reserved[8];
-};
-
 typedef struct camera_module {
     hw_module_t common;
 
@@ -365,6 +308,9 @@
      * HAL should fill in all the vendor tag operation methods, or leave ops
      * unchanged if no vendor tags are defined.
      *
+     * The vendor_tag_ops structure used here is defined in:
+     * system/media/camera/include/system/vendor_tags.h
+     *
      * Version information (based on camera_module_t.common.module_api_version):
      *
      *  CAMERA_MODULE_API_VERSION_1_x/2_0/2_1:
diff --git a/modules/camera/Camera.cpp b/modules/camera/Camera.cpp
index 57cdb47..0ddf001 100644
--- a/modules/camera/Camera.cpp
+++ b/modules/camera/Camera.cpp
@@ -467,12 +467,6 @@
     mCallbackOps->notify(mCallbackOps, &m);
 }
 
-void Camera::getMetadataVendorTagOps(vendor_tag_query_ops_t *ops)
-{
-    ALOGV("%s:%d: ops=%p", __func__, mId, ops);
-    // TODO: return vendor tag ops
-}
-
 void Camera::dump(int fd)
 {
     ALOGV("%s:%d: Dumping to fd %d", __func__, mId, fd);
@@ -571,12 +565,6 @@
     return camdev_to_camera(dev)->processCaptureRequest(request);
 }
 
-static void get_metadata_vendor_tag_ops(const camera3_device_t *dev,
-        vendor_tag_query_ops_t *ops)
-{
-    camdev_to_camera(dev)->getMetadataVendorTagOps(ops);
-}
-
 static void dump(const camera3_device_t *dev, int fd)
 {
     camdev_to_camera(dev)->dump(fd);
@@ -590,8 +578,7 @@
     .construct_default_request_settings =
             default_camera_hal::construct_default_request_settings,
     .process_capture_request = default_camera_hal::process_capture_request,
-    .get_metadata_vendor_tag_ops =
-            default_camera_hal::get_metadata_vendor_tag_ops,
+    .get_metadata_vendor_tag_ops = NULL,
     .dump                    = default_camera_hal::dump
 };
 
diff --git a/modules/camera/Camera.h b/modules/camera/Camera.h
index f1f33b1..0ceaf25 100644
--- a/modules/camera/Camera.h
+++ b/modules/camera/Camera.h
@@ -48,7 +48,6 @@
         int registerStreamBuffers(const camera3_stream_buffer_set_t *buf_set);
         const camera_metadata_t *constructDefaultRequestSettings(int type);
         int processCaptureRequest(camera3_capture_request_t *request);
-        void getMetadataVendorTagOps(vendor_tag_query_ops_t *ops);
         void dump(int fd);
 
 
diff --git a/modules/camera/CameraHAL.h b/modules/camera/CameraHAL.h
index a5edc85..cb0ec8b 100644
--- a/modules/camera/CameraHAL.h
+++ b/modules/camera/CameraHAL.h
@@ -20,6 +20,7 @@
 #include <cutils/bitops.h>
 #include <hardware/hardware.h>
 #include <hardware/camera_common.h>
+#include <system/vendor_tags.h>
 #include "Camera.h"
 #include "VendorTags.h"