Clean up format of V4L2Camera and V4L2CameraHAL.

BUG: 30224839
TEST: unit tests pass
Change-Id: I0d41927fb6e56cf32f5e04a3fe98be1139e6c4a8
diff --git a/modules/camera/3_4/v4l2_camera.cpp b/modules/camera/3_4/v4l2_camera.cpp
index 9ebefeb..521f835 100644
--- a/modules/camera/3_4/v4l2_camera.cpp
+++ b/modules/camera/3_4/v4l2_camera.cpp
@@ -18,8 +18,8 @@
 
 #include <fcntl.h>
 #include <linux/videodev2.h>
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 
 #include <cstdlib>
 
@@ -36,8 +36,7 @@
 namespace v4l2_camera_hal {
 
 // Helper function for managing metadata.
-static std::vector<int32_t> getMetadataKeys(
-    const camera_metadata_t* metadata) {
+static std::vector<int32_t> getMetadataKeys(const camera_metadata_t* metadata) {
   std::vector<int32_t> keys;
   size_t num_entries = get_camera_metadata_entry_count(metadata);
   for (size_t i = 0; i < num_entries; ++i) {
@@ -67,7 +66,8 @@
   return new V4L2Camera(id, std::move(v4l2_wrapper), std::move(metadata));
 }
 
-V4L2Camera::V4L2Camera(int id, std::shared_ptr<V4L2Wrapper> v4l2_wrapper,
+V4L2Camera::V4L2Camera(int id,
+                       std::shared_ptr<V4L2Wrapper> v4l2_wrapper,
                        std::unique_ptr<Metadata> metadata)
     : default_camera_hal::Camera(id),
       device_(std::move(v4l2_wrapper)),
@@ -102,8 +102,8 @@
   // by disabling cameras that get disconnected and checking newly connected
   // cameras, so connect() is never called on an unsupported camera)
 
-  // TODO(b/29158098): Inform service of any flashes that are no longer available
-  // because this camera is in use.
+  // TODO(b/29158098): Inform service of any flashes that are no longer
+  // available because this camera is in use.
   return 0;
 }
 
@@ -126,14 +126,14 @@
   }
 
   // Extract max streams for use in verifying stream configs.
-  res = SingleTagValue(*out, ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS,
-                       &max_input_streams_);
+  res = SingleTagValue(
+      *out, ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, &max_input_streams_);
   if (res) {
     HAL_LOGE("Failed to get max num input streams from static metadata.");
     return res;
   }
-  res = SingleTagValue(*out, ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS,
-                       &max_output_streams_);
+  res = SingleTagValue(
+      *out, ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, &max_output_streams_);
   if (res) {
     HAL_LOGE("Failed to get max num output streams from static metadata.");
     return res;
@@ -231,7 +231,8 @@
 }
 
 bool V4L2Camera::isSupportedStreamSet(default_camera_hal::Stream** streams,
-                                      int count, uint32_t mode) {
+                                      int count,
+                                      uint32_t mode) {
   HAL_LOG_ENTER();
 
   if (mode != CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE) {
@@ -270,21 +271,28 @@
           break;
         case kFormatCategoryUnknown:  // Fall through.
         default:
-          HAL_LOGE("Unsupported format for stream %d: %d", i, stream->getFormat());
+          HAL_LOGE(
+              "Unsupported format for stream %d: %d", i, stream->getFormat());
           return false;
       }
     }
   }
 
-  if (num_input > max_input_streams_ ||
-      num_raw > max_output_streams_[0] ||
+  if (num_input > max_input_streams_ || num_raw > max_output_streams_[0] ||
       num_non_stalling > max_output_streams_[1] ||
       num_stalling > max_output_streams_[2]) {
-    HAL_LOGE("Invalid stream configuration: %d input, %d RAW, %d non-stalling, "
-             "%d stalling (max supported: %d input, %d RAW, %d non-stalling, "
-             "%d stalling)", max_input_streams_, max_output_streams_[0],
-             max_output_streams_[1], max_output_streams_[2], num_input,
-             num_raw, num_non_stalling, num_stalling);
+    HAL_LOGE(
+        "Invalid stream configuration: %d input, %d RAW, %d non-stalling, "
+        "%d stalling (max supported: %d input, %d RAW, %d non-stalling, "
+        "%d stalling)",
+        max_input_streams_,
+        max_output_streams_[0],
+        max_output_streams_[1],
+        max_output_streams_[2],
+        num_input,
+        num_raw,
+        num_non_stalling,
+        num_stalling);
     return false;
   }
 
@@ -301,11 +309,17 @@
     const default_camera_hal::Stream* stream = streams[i];
     if (stream->getFormat() != format || stream->getWidth() != width ||
         stream->getHeight() != height) {
-      HAL_LOGE("V4L2 only supports 1 stream configuration at a time "
-               "(stream 0 is format %d, width %u, height %u, "
-               "stream %d is format %d, width %u, height %u).",
-               format, width, height, i, stream->getFormat(),
-               stream->getWidth(), stream->getHeight());
+      HAL_LOGE(
+          "V4L2 only supports 1 stream configuration at a time "
+          "(stream 0 is format %d, width %u, height %u, "
+          "stream %d is format %d, width %u, height %u).",
+          format,
+          width,
+          height,
+          i,
+          stream->getFormat(),
+          stream->getWidth(),
+          stream->getHeight());
       return false;
     }
   }
@@ -342,7 +356,8 @@
   return 0;
 }
 
-bool V4L2Camera::isValidCaptureSettings(const android::CameraMetadata& settings) {
+bool V4L2Camera::isValidCaptureSettings(
+    const android::CameraMetadata& settings) {
   HAL_LOG_ENTER();
 
   return metadata_->IsValidRequest(settings);
diff --git a/modules/camera/3_4/v4l2_camera.h b/modules/camera/3_4/v4l2_camera.h
index d9af15d..804012b 100644
--- a/modules/camera/3_4/v4l2_camera.h
+++ b/modules/camera/3_4/v4l2_camera.h
@@ -35,16 +35,17 @@
 // while a specific camera device (e.g. V4L2Camera) holds all specific
 // metadata and logic about that device.
 class V4L2Camera : public default_camera_hal::Camera {
-public:
+ public:
   // Use this method to create V4L2Camera objects. Functionally equivalent
   // to "new V4L2Camera", except that it may return nullptr in case of failure.
   static V4L2Camera* NewV4L2Camera(int id, const std::string path);
   ~V4L2Camera();
 
-private:
+ private:
   // Constructor private to allow failing on bad input.
   // Use NewV4L2Camera instead.
-  V4L2Camera(int id, std::shared_ptr<V4L2Wrapper> v4l2_wrapper,
+  V4L2Camera(int id,
+             std::shared_ptr<V4L2Wrapper> v4l2_wrapper,
              std::unique_ptr<Metadata> metadata);
 
   // default_camera_hal::Camera virtual methods.
@@ -63,7 +64,8 @@
   int initDevice() override;
   // Verify stream configuration is device-compatible.
   bool isSupportedStreamSet(default_camera_hal::Stream** streams,
-                            int count, uint32_t mode) override;
+                            int count,
+                            uint32_t mode) override;
   // Set up the device for a stream, and get the maximum number of
   // buffers that stream can handle (max_buffers is an output parameter).
   int setupStream(default_camera_hal::Stream* stream,
@@ -71,8 +73,7 @@
   // Verify settings are valid for a capture with this device.
   bool isValidCaptureSettings(const android::CameraMetadata& settings) override;
   // Set settings for a capture.
-  int setSettings(
-            const android::CameraMetadata& new_settings) override;
+  int setSettings(const android::CameraMetadata& new_settings) override;
   // Enqueue a buffer to receive data from the camera.
   int enqueueBuffer(const camera3_stream_buffer_t* camera_buffer) override;
   // Get the shutter time and updated settings for the most recent frame.
diff --git a/modules/camera/3_4/v4l2_camera_hal.cpp b/modules/camera/3_4/v4l2_camera_hal.cpp
index 7996da9..bfc8712 100644
--- a/modules/camera/3_4/v4l2_camera_hal.cpp
+++ b/modules/camera/3_4/v4l2_camera_hal.cpp
@@ -22,8 +22,8 @@
 #include <fcntl.h>
 #include <linux/videodev2.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
 
 #include <algorithm>
@@ -86,8 +86,8 @@
     }
     // Read V4L2 capabilities.
     if (TEMP_FAILURE_RETRY(ioctl(fd, VIDIOC_QUERYCAP, &cap)) != 0) {
-      HAL_LOGE("VIDIOC_QUERYCAP on %s fail: %s.", node.c_str(),
-               strerror(errno));
+      HAL_LOGE(
+          "VIDIOC_QUERYCAP on %s fail: %s.", node.c_str(), strerror(errno));
     } else if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
       HAL_LOGE("%s is not a V4L2 video capture device.", node.c_str());
     } else {
@@ -137,8 +137,10 @@
   // "leave ops unchanged if no vendor tags are defined."
 }
 
-int V4L2CameraHAL::openLegacy(const hw_module_t* module, const char* id,
-                              uint32_t halVersion, hw_device_t** device) {
+int V4L2CameraHAL::openLegacy(const hw_module_t* module,
+                              const char* id,
+                              uint32_t halVersion,
+                              hw_device_t** device) {
   HAL_LOG_ENTER();
   // Not supported.
   return -ENOSYS;
@@ -151,13 +153,14 @@
   return -ENOSYS;
 }
 
-int V4L2CameraHAL::openDevice(const hw_module_t* module, const char* name,
+int V4L2CameraHAL::openDevice(const hw_module_t* module,
+                              const char* name,
                               hw_device_t** device) {
   HAL_LOG_ENTER();
 
   if (module != &HAL_MODULE_INFO_SYM.common) {
-    HAL_LOGE("Invalid module %p expected %p", module,
-             &HAL_MODULE_INFO_SYM.common);
+    HAL_LOGE(
+        "Invalid module %p expected %p", module, &HAL_MODULE_INFO_SYM.common);
     return -EINVAL;
   }
 
@@ -182,7 +185,7 @@
   return gCameraHAL.getCameraInfo(id, info);
 }
 
-static int set_callbacks(const camera_module_callbacks_t *callbacks) {
+static int set_callbacks(const camera_module_callbacks_t* callbacks) {
   return gCameraHAL.setCallbacks(callbacks);
 }
 
@@ -190,8 +193,10 @@
   return gCameraHAL.getVendorTagOps(ops);
 }
 
-static int open_legacy(const hw_module_t* module, const char* id,
-                       uint32_t halVersion, hw_device_t** device) {
+static int open_legacy(const hw_module_t* module,
+                       const char* id,
+                       uint32_t halVersion,
+                       hw_device_t** device) {
   return gCameraHAL.openLegacy(module, id, halVersion, device);
 }
 
@@ -199,7 +204,8 @@
   return gCameraHAL.setTorchMode(camera_id, enabled);
 }
 
-static int open_dev(const hw_module_t* module, const char* name,
+static int open_dev(const hw_module_t* module,
+                    const char* name,
                     hw_device_t** device) {
   return gCameraHAL.openDevice(module, name, device);
 }
@@ -207,27 +213,26 @@
 }  // namespace v4l2_camera_hal
 
 static hw_module_methods_t v4l2_module_methods = {
-  .open = v4l2_camera_hal::open_dev
-};
+    .open = v4l2_camera_hal::open_dev};
 
-camera_module_t HAL_MODULE_INFO_SYM __attribute__ ((visibility("default"))) = {
-  .common = {
-    .tag =                 HARDWARE_MODULE_TAG,
-    .module_api_version =  CAMERA_MODULE_API_VERSION_2_4,
-    .hal_api_version =     HARDWARE_HAL_API_VERSION,
-    .id =                  CAMERA_HARDWARE_MODULE_ID,
-    .name =                "V4L2 Camera HAL v3",
-    .author =              "The Android Open Source Project",
-    .methods =             &v4l2_module_methods,
-    .dso =                 nullptr,
-    .reserved =            {0},
-  },
-  .get_number_of_cameras =  v4l2_camera_hal::get_number_of_cameras,
-  .get_camera_info =        v4l2_camera_hal::get_camera_info,
-  .set_callbacks =          v4l2_camera_hal::set_callbacks,
-  .get_vendor_tag_ops =     v4l2_camera_hal::get_vendor_tag_ops,
-  .open_legacy =            v4l2_camera_hal::open_legacy,
-  .set_torch_mode =         v4l2_camera_hal::set_torch_mode,
-  .init =                   nullptr,
-  .reserved =               {nullptr, nullptr, nullptr, nullptr, nullptr}
-};
+camera_module_t HAL_MODULE_INFO_SYM __attribute__((visibility("default"))) = {
+    .common =
+        {
+            .tag = HARDWARE_MODULE_TAG,
+            .module_api_version = CAMERA_MODULE_API_VERSION_2_4,
+            .hal_api_version = HARDWARE_HAL_API_VERSION,
+            .id = CAMERA_HARDWARE_MODULE_ID,
+            .name = "V4L2 Camera HAL v3",
+            .author = "The Android Open Source Project",
+            .methods = &v4l2_module_methods,
+            .dso = nullptr,
+            .reserved = {0},
+        },
+    .get_number_of_cameras = v4l2_camera_hal::get_number_of_cameras,
+    .get_camera_info = v4l2_camera_hal::get_camera_info,
+    .set_callbacks = v4l2_camera_hal::set_callbacks,
+    .get_vendor_tag_ops = v4l2_camera_hal::get_vendor_tag_ops,
+    .open_legacy = v4l2_camera_hal::open_legacy,
+    .set_torch_mode = v4l2_camera_hal::set_torch_mode,
+    .init = nullptr,
+    .reserved = {nullptr, nullptr, nullptr, nullptr, nullptr}};
diff --git a/modules/camera/3_4/v4l2_camera_hal.h b/modules/camera/3_4/v4l2_camera_hal.h
index 91983b0..1b4ef0f 100644
--- a/modules/camera/3_4/v4l2_camera_hal.h
+++ b/modules/camera/3_4/v4l2_camera_hal.h
@@ -34,7 +34,7 @@
  * default CameraHAL from /hardware/libhardware/modules/camera.
  */
 class V4L2CameraHAL {
-public:
+ public:
   V4L2CameraHAL();
   ~V4L2CameraHAL();
 
@@ -43,23 +43,25 @@
   int getCameraInfo(int camera_id, camera_info_t* info);
   int setCallbacks(const camera_module_callbacks_t* callbacks);
   void getVendorTagOps(vendor_tag_ops_t* ops);
-  int openLegacy(const hw_module_t* module, const char* id,
-                 uint32_t halVersion, hw_device_t** device);
+  int openLegacy(const hw_module_t* module,
+                 const char* id,
+                 uint32_t halVersion,
+                 hw_device_t** device);
   int setTorchMode(const char* camera_id, bool enabled);
 
   // Hardware Module Interface (see <hardware/hardware.h>).
   int openDevice(const hw_module_t* mod, const char* name, hw_device_t** dev);
 
-private:
+ private:
   // Vector of cameras.
   std::vector<std::unique_ptr<default_camera_hal::Camera>> mCameras;
   // Callback handle.
-  const camera_module_callbacks_t *mCallbacks;
+  const camera_module_callbacks_t* mCallbacks;
 
   DISALLOW_COPY_AND_ASSIGN(V4L2CameraHAL);
 };
 
-} // namespace v4l2_camera_hal
+}  // namespace v4l2_camera_hal
 
 extern camera_module_t HAL_MODULE_INFO_SYM;