drm_hwcomposer: Reformat using clang-format-5.0

Run the new clang-format style over the codebase to make things
compatible.

Change-Id: I267d5070929aaa7965d58655da841402debdcb6c
Signed-off-by: Sean Paul <seanpaul@chromium.org>
diff --git a/autofd.h b/autofd.h
index 1edc9c5..9af6c22 100644
--- a/autofd.h
+++ b/autofd.h
@@ -101,6 +101,6 @@
  private:
   int *fd_ = NULL;
 };
-}
+}  // namespace android
 
 #endif
diff --git a/autolock.cpp b/autolock.cpp
index 795a8c2..4e9552a 100644
--- a/autolock.cpp
+++ b/autolock.cpp
@@ -53,4 +53,4 @@
   locked_ = false;
   return 0;
 }
-}
+}  // namespace android
diff --git a/autolock.h b/autolock.h
index 3b824e2..006406a 100644
--- a/autolock.h
+++ b/autolock.h
@@ -39,4 +39,4 @@
   bool locked_ = false;
   const char *const name_;
 };
-}
+}  // namespace android
diff --git a/drmconnector.cpp b/drmconnector.cpp
index bdf4811..756791f 100644
--- a/drmconnector.cpp
+++ b/drmconnector.cpp
@@ -93,7 +93,8 @@
 }
 
 bool DrmConnector::external() const {
-  return type_ == DRM_MODE_CONNECTOR_HDMIA || type_ == DRM_MODE_CONNECTOR_DisplayPort ||
+  return type_ == DRM_MODE_CONNECTOR_HDMIA ||
+         type_ == DRM_MODE_CONNECTOR_DisplayPort ||
          type_ == DRM_MODE_CONNECTOR_DVID || type_ == DRM_MODE_CONNECTOR_DVII ||
          type_ == DRM_MODE_CONNECTOR_VGA;
 }
@@ -189,4 +190,4 @@
 uint32_t DrmConnector::mm_height() const {
   return mm_height_;
 }
-}
+}  // namespace android
diff --git a/drmconnector.h b/drmconnector.h
index 3bafd62..4f7f6a8 100644
--- a/drmconnector.h
+++ b/drmconnector.h
@@ -22,8 +22,8 @@
 #include "drmproperty.h"
 
 #include <stdint.h>
-#include <vector>
 #include <xf86drmMode.h>
+#include <vector>
 
 namespace android {
 
@@ -98,6 +98,6 @@
 
   std::vector<DrmEncoder *> possible_encoders_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_PLANE_H_
diff --git a/drmcrtc.cpp b/drmcrtc.cpp
index a392a4d..b627291 100644
--- a/drmcrtc.cpp
+++ b/drmcrtc.cpp
@@ -82,4 +82,4 @@
 const DrmProperty &DrmCrtc::out_fence_ptr_property() const {
   return out_fence_ptr_property_;
 }
-}
+}  // namespace android
diff --git a/drmcrtc.h b/drmcrtc.h
index 3e17abd..3075f9b 100644
--- a/drmcrtc.h
+++ b/drmcrtc.h
@@ -60,6 +60,6 @@
   DrmProperty mode_property_;
   DrmProperty out_fence_ptr_property_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_CRTC_H_
diff --git a/drmdevice.cpp b/drmdevice.cpp
index 58f639e..2007fdd 100644
--- a/drmdevice.cpp
+++ b/drmdevice.cpp
@@ -16,22 +16,22 @@
 
 #define LOG_TAG "hwc-drm-device"
 
+#include "drmdevice.h"
 #include "drmconnector.h"
 #include "drmcrtc.h"
 #include "drmencoder.h"
 #include "drmeventlistener.h"
 #include "drmplane.h"
-#include "drmdevice.h"
 
-#include <cinttypes>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdint.h>
 #include <xf86drm.h>
 #include <xf86drmMode.h>
+#include <cinttypes>
 
-#include <log/log.h>
 #include <cutils/properties.h>
+#include <log/log.h>
 
 namespace android {
 
@@ -76,10 +76,10 @@
     return std::make_tuple(-ENODEV, 0);
   }
 
-  min_resolution_ =
-      std::pair<uint32_t, uint32_t>(res->min_width, res->min_height);
-  max_resolution_ =
-      std::pair<uint32_t, uint32_t>(res->max_width, res->max_height);
+  min_resolution_ = std::pair<uint32_t, uint32_t>(res->min_width,
+                                                  res->min_height);
+  max_resolution_ = std::pair<uint32_t, uint32_t>(res->max_width,
+                                                  res->max_height);
 
   // Assumes that the primary display will always be in the first
   // drm_device opened.
@@ -483,4 +483,4 @@
   return GetProperty(connector.id(), DRM_MODE_OBJECT_CONNECTOR, prop_name,
                      property);
 }
-}
+}  // namespace android
diff --git a/drmdevice.h b/drmdevice.h
index 491a9b0..da1b961 100644
--- a/drmdevice.h
+++ b/drmdevice.h
@@ -99,6 +99,6 @@
   std::pair<uint32_t, uint32_t> max_resolution_;
   std::map<int, int> displays_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_H_
diff --git a/drmdisplaycomposition.cpp b/drmdisplaycomposition.cpp
index 65d7cf1..b710fe1 100644
--- a/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
@@ -16,10 +16,10 @@
 
 #define LOG_TAG "hwc-drm-display-composition"
 
-#include "drmdevice.h"
 #include "drmdisplaycomposition.h"
-#include "drmdisplaycompositor.h"
 #include "drmcrtc.h"
+#include "drmdevice.h"
+#include "drmdisplaycompositor.h"
 #include "drmplane.h"
 #include "platform.h"
 
@@ -107,8 +107,10 @@
     to_composite.emplace(std::make_pair(i, &layers_[i]));
 
   int ret;
-  std::tie(ret, composition_planes_) = planner_->ProvisionPlanes(
-      to_composite, crtc_, primary_planes, overlay_planes);
+  std::tie(ret,
+           composition_planes_) = planner_->ProvisionPlanes(to_composite, crtc_,
+                                                            primary_planes,
+                                                            overlay_planes);
   if (ret) {
     ALOGE("Planner failed provisioning planes ret=%d", ret);
     return ret;
@@ -294,4 +296,4 @@
     *out << "\n";
   }
 }
-}
+}  // namespace android
diff --git a/drmdisplaycomposition.h b/drmdisplaycomposition.h
index 078bf9b..2a5b1a4 100644
--- a/drmdisplaycomposition.h
+++ b/drmdisplaycomposition.h
@@ -193,6 +193,6 @@
 
   uint64_t frame_no_ = 0;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_DISPLAY_COMPOSITION_H_
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index 7427729..f479f10 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -26,8 +26,8 @@
 #include <sstream>
 #include <vector>
 
-#include <log/log.h>
 #include <drm/drm_mode.h>
+#include <log/log.h>
 #include <sync/sync.h>
 #include <utils/Trace.h>
 
@@ -165,8 +165,8 @@
   }
 
   int ret;
-  std::vector<DrmCompositionPlane> &comp_planes =
-      display_comp->composition_planes();
+  std::vector<DrmCompositionPlane> &comp_planes = display_comp
+                                                      ->composition_planes();
   for (DrmCompositionPlane &comp_plane : comp_planes) {
     DrmPlane *plane = comp_plane.plane();
     ret = drmModeAtomicAddProperty(pset, plane->id(),
@@ -239,8 +239,8 @@
   int ret = 0;
 
   std::vector<DrmHwcLayer> &layers = display_comp->layers();
-  std::vector<DrmCompositionPlane> &comp_planes =
-      display_comp->composition_planes();
+  std::vector<DrmCompositionPlane> &comp_planes = display_comp
+                                                      ->composition_planes();
   DrmDevice *drm = resource_manager_->GetDrmDevice(display_);
   uint64_t out_fences[drm->crtcs().size()];
 
@@ -274,8 +274,9 @@
     }
   }
   if (crtc->out_fence_ptr_property().id() != 0) {
-    ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->out_fence_ptr_property().id(),
-                                   (uint64_t) &out_fences[crtc->pipe()]);
+    ret = drmModeAtomicAddProperty(pset, crtc->id(),
+                                   crtc->out_fence_ptr_property().id(),
+                                   (uint64_t)&out_fences[crtc->pipe()]);
     if (ret < 0) {
       ALOGE("Failed to add OUT_FENCE_PTR property to pset: %d", ret);
       drmModeAtomicFree(pset);
@@ -284,7 +285,8 @@
   }
 
   if (mode_.needs_modeset) {
-    ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->active_property().id(), 1);
+    ret = drmModeAtomicAddProperty(pset, crtc->id(),
+                                   crtc->active_property().id(), 1);
     if (ret < 0) {
       ALOGE("Failed to add crtc active to pset\n");
       drmModeAtomicFree(pset);
@@ -356,8 +358,8 @@
       if (fence_fd >= 0) {
         int prop_id = plane->in_fence_fd_property().id();
         if (prop_id == 0) {
-                ALOGE("Failed to get IN_FENCE_FD property id");
-                break;
+          ALOGE("Failed to get IN_FENCE_FD property id");
+          break;
         }
         ret = drmModeAtomicAddProperty(pset, plane->id(), prop_id, fence_fd);
         if (ret < 0) {
@@ -404,24 +406,28 @@
     ret |= drmModeAtomicAddProperty(pset, plane->id(),
                                     plane->crtc_y_property().id(),
                                     display_frame.top) < 0;
-    ret |= drmModeAtomicAddProperty(
-               pset, plane->id(), plane->crtc_w_property().id(),
-               display_frame.right - display_frame.left) < 0;
-    ret |= drmModeAtomicAddProperty(
-               pset, plane->id(), plane->crtc_h_property().id(),
-               display_frame.bottom - display_frame.top) < 0;
+    ret |= drmModeAtomicAddProperty(pset, plane->id(),
+                                    plane->crtc_w_property().id(),
+                                    display_frame.right - display_frame.left) <
+           0;
+    ret |= drmModeAtomicAddProperty(pset, plane->id(),
+                                    plane->crtc_h_property().id(),
+                                    display_frame.bottom - display_frame.top) <
+           0;
     ret |= drmModeAtomicAddProperty(pset, plane->id(),
                                     plane->src_x_property().id(),
                                     (int)(source_crop.left) << 16) < 0;
     ret |= drmModeAtomicAddProperty(pset, plane->id(),
                                     plane->src_y_property().id(),
                                     (int)(source_crop.top) << 16) < 0;
-    ret |= drmModeAtomicAddProperty(
-               pset, plane->id(), plane->src_w_property().id(),
-               (int)(source_crop.right - source_crop.left) << 16) < 0;
-    ret |= drmModeAtomicAddProperty(
-               pset, plane->id(), plane->src_h_property().id(),
-               (int)(source_crop.bottom - source_crop.top) << 16) < 0;
+    ret |= drmModeAtomicAddProperty(pset, plane->id(),
+                                    plane->src_w_property().id(),
+                                    (int)(source_crop.right - source_crop.left)
+                                        << 16) < 0;
+    ret |= drmModeAtomicAddProperty(pset, plane->id(),
+                                    plane->src_h_property().id(),
+                                    (int)(source_crop.bottom - source_crop.top)
+                                        << 16) < 0;
     if (ret) {
       ALOGE("Failed to add plane %d to set", plane->id());
       break;
@@ -440,8 +446,7 @@
 
     if (plane->alpha_property().id()) {
       ret = drmModeAtomicAddProperty(pset, plane->id(),
-                                     plane->alpha_property().id(),
-                                     alpha) < 0;
+                                     plane->alpha_property().id(), alpha) < 0;
       if (ret) {
         ALOGE("Failed to add alpha property %d to plane %d",
               plane->alpha_property().id(), plane->id());
@@ -488,7 +493,7 @@
   }
 
   if (crtc->out_fence_ptr_property().id()) {
-    display_comp->set_out_fence((int) out_fences[crtc->pipe()]);
+    display_comp->set_out_fence((int)out_fences[crtc->pipe()]);
   }
 
   return ret;
@@ -598,8 +603,8 @@
     case DRM_COMPOSITION_TYPE_MODESET:
       mode_.mode = composition->display_mode();
       if (mode_.blob_id)
-        resource_manager_->GetDrmDevice(display_)
-            ->DestroyPropertyBlob(mode_.blob_id);
+        resource_manager_->GetDrmDevice(display_)->DestroyPropertyBlob(
+            mode_.blob_id);
       std::tie(ret, mode_.blob_id) = CreateModeBlob(mode_.mode);
       if (ret) {
         ALOGE("Failed to create mode blob for display %d", display_);
@@ -731,8 +736,8 @@
   ALOGV("FlattenSerial by enabling writeback connector to the same crtc");
   // Flattened composition with only one layer that is obtained
   // using the writeback connector
-  std::unique_ptr<DrmDisplayComposition> writeback_comp =
-      CreateInitializedComposition();
+  std::unique_ptr<DrmDisplayComposition>
+      writeback_comp = CreateInitializedComposition();
   if (!writeback_comp)
     return -EINVAL;
 
@@ -835,12 +840,12 @@
   //    active_composition
   // 2) It will be committed on a crtc that might not be on the same
   //     dri node, so buffers need to be imported on the right node.
-  std::unique_ptr<DrmDisplayComposition> copy_comp =
-      drmdisplaycompositor.CreateInitializedComposition();
+  std::unique_ptr<DrmDisplayComposition>
+      copy_comp = drmdisplaycompositor.CreateInitializedComposition();
 
   // Writeback composition that will be committed to the display.
-  std::unique_ptr<DrmDisplayComposition> writeback_comp =
-      CreateInitializedComposition();
+  std::unique_ptr<DrmDisplayComposition>
+      writeback_comp = CreateInitializedComposition();
 
   if (!copy_comp || !writeback_comp)
     return -EINVAL;
@@ -857,9 +862,10 @@
   std::vector<DrmHwcLayer> copy_layers;
   for (DrmHwcLayer &src_layer : active_composition_->layers()) {
     DrmHwcLayer copy;
-    ret = copy.InitFromDrmHwcLayer(
-        &src_layer,
-        resource_manager_->GetImporter(writeback_conn->display()).get());
+    ret = copy.InitFromDrmHwcLayer(&src_layer,
+                                   resource_manager_
+                                       ->GetImporter(writeback_conn->display())
+                                       .get());
     if (ret) {
       ALOGE("Failed to import buffer ret = %d", ret);
       return -EINVAL;
@@ -915,8 +921,8 @@
 }
 
 int DrmDisplayCompositor::FlattenActiveComposition() {
-  DrmConnector *writeback_conn =
-      resource_manager_->AvailableWritebackConnector(display_);
+  DrmConnector *writeback_conn = resource_manager_->AvailableWritebackConnector(
+      display_);
   if (!active_composition_ || !writeback_conn) {
     ALOGV("No writeback connector available");
     return -EINVAL;
@@ -976,4 +982,4 @@
 
   pthread_mutex_unlock(&lock_);
 }
-}
+}  // namespace android
diff --git a/drmdisplaycompositor.h b/drmdisplaycompositor.h
index 7d46416..67f6334 100644
--- a/drmdisplaycompositor.h
+++ b/drmdisplaycompositor.h
@@ -17,9 +17,9 @@
 #ifndef ANDROID_DRM_DISPLAY_COMPOSITOR_H_
 #define ANDROID_DRM_DISPLAY_COMPOSITOR_H_
 
-#include "drmhwcomposer.h"
 #include "drmdisplaycomposition.h"
 #include "drmframebuffer.h"
+#include "drmhwcomposer.h"
 #include "resourcemanager.h"
 #include "vsyncworker.h"
 
@@ -122,6 +122,6 @@
   std::unique_ptr<Planner> planner_;
   int writeback_fence_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_DISPLAY_COMPOSITOR_H_
diff --git a/drmencoder.cpp b/drmencoder.cpp
index 277f9a4..c36fca1 100644
--- a/drmencoder.cpp
+++ b/drmencoder.cpp
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
+#include "drmencoder.h"
 #include "drmcrtc.h"
 #include "drmdevice.h"
-#include "drmencoder.h"
 
 #include <stdint.h>
 #include <xf86drmMode.h>
@@ -59,4 +59,4 @@
 bool DrmEncoder::can_bind(int display) const {
   return display_ == -1 || display_ == display;
 }
-}
+}  // namespace android
diff --git a/drmencoder.h b/drmencoder.h
index c99c36e..8a7f682 100644
--- a/drmencoder.h
+++ b/drmencoder.h
@@ -19,10 +19,10 @@
 
 #include "drmcrtc.h"
 
-#include <set>
 #include <stdint.h>
-#include <vector>
 #include <xf86drmMode.h>
+#include <set>
+#include <vector>
 
 namespace android {
 
@@ -54,6 +54,6 @@
   std::vector<DrmCrtc *> possible_crtcs_;
   std::set<DrmEncoder *> possible_clones_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_ENCODER_H_
diff --git a/drmeventlistener.cpp b/drmeventlistener.cpp
index aca02a9..6aab6fb 100644
--- a/drmeventlistener.cpp
+++ b/drmeventlistener.cpp
@@ -16,17 +16,17 @@
 
 #define LOG_TAG "hwc-drm-event-listener"
 
-#include "drmdevice.h"
 #include "drmeventlistener.h"
+#include "drmdevice.h"
 
 #include <assert.h>
 #include <errno.h>
 #include <linux/netlink.h>
 #include <sys/socket.h>
 
-#include <log/log.h>
 #include <hardware/hardware.h>
 #include <hardware/hwcomposer.h>
+#include <log/log.h>
 #include <xf86drm.h>
 
 namespace android {
@@ -125,14 +125,14 @@
   } while (ret == -1 && errno == EINTR);
 
   if (FD_ISSET(drm_->fd(), &fds_)) {
-    drmEventContext event_context = {
-        .version = 2,
-        .vblank_handler = NULL,
-        .page_flip_handler = DrmEventListener::FlipHandler};
+    drmEventContext event_context =
+        {.version = 2,
+         .vblank_handler = NULL,
+         .page_flip_handler = DrmEventListener::FlipHandler};
     drmHandleEvent(drm_->fd(), &event_context);
   }
 
   if (FD_ISSET(uevent_fd_.get(), &fds_))
     UEventHandler();
 }
-}
+}  // namespace android
diff --git a/drmeventlistener.h b/drmeventlistener.h
index 37adbdd..d8a61a5 100644
--- a/drmeventlistener.h
+++ b/drmeventlistener.h
@@ -60,6 +60,6 @@
   DrmDevice *drm_;
   DrmEventHandler *hotplug_handler_ = NULL;
 };
-}
+}  // namespace android
 
 #endif
diff --git a/drmframebuffer.h b/drmframebuffer.h
index d4d00bc..9032d3a 100644
--- a/drmframebuffer.h
+++ b/drmframebuffer.h
@@ -102,6 +102,6 @@
   sp<GraphicBuffer> buffer_;
   int release_fence_fd_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_FRAMEBUFFER_
diff --git a/drmhwcomposer.h b/drmhwcomposer.h
index a6a40fd..1d6da2f 100644
--- a/drmhwcomposer.h
+++ b/drmhwcomposer.h
@@ -161,6 +161,6 @@
   OutputFd retire_fence;
   std::vector<DrmHwcLayer> layers;
 };
-}
+}  // namespace android
 
 #endif
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index c81828f..c801f2e 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -17,19 +17,19 @@
 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
 #define LOG_TAG "hwc-drm-two"
 
+#include "drmhwctwo.h"
 #include "drmdisplaycomposition.h"
 #include "drmhwcomposer.h"
-#include "drmhwctwo.h"
 #include "platform.h"
 #include "vsyncworker.h"
 
 #include <inttypes.h>
 #include <string>
 
-#include <log/log.h>
 #include <cutils/properties.h>
 #include <hardware/hardware.h>
 #include <hardware/hwcomposer2.h>
+#include <log/log.h>
 
 namespace android {
 
@@ -65,17 +65,18 @@
   }
 
   DrmDevice *drm = resource_manager_.GetDrmDevice(HWC_DISPLAY_PRIMARY);
-  std::shared_ptr<Importer> importer =
-      resource_manager_.GetImporter(HWC_DISPLAY_PRIMARY);
+  std::shared_ptr<Importer> importer = resource_manager_.GetImporter(
+      HWC_DISPLAY_PRIMARY);
   if (!drm || !importer) {
     ALOGE("Failed to get a valid drmresource and importer");
     return HWC2::Error::NoResources;
   }
 
-  displays_.emplace(
-      std::piecewise_construct, std::forward_as_tuple(HWC_DISPLAY_PRIMARY),
-      std::forward_as_tuple(&resource_manager_, drm, importer,
-                            HWC_DISPLAY_PRIMARY, HWC2::DisplayType::Physical));
+  displays_.emplace(std::piecewise_construct,
+                    std::forward_as_tuple(HWC_DISPLAY_PRIMARY),
+                    std::forward_as_tuple(&resource_manager_, drm, importer,
+                                          HWC_DISPLAY_PRIMARY,
+                                          HWC2::DisplayType::Physical));
 
   DrmCrtc *crtc = drm->GetCrtcForDisplay(static_cast<int>(HWC_DISPLAY_PRIMARY));
   if (!crtc) {
@@ -321,9 +322,11 @@
                                                        int32_t attribute_in,
                                                        int32_t *value) {
   supported(__func__);
-  auto mode =
-      std::find_if(connector_->modes().begin(), connector_->modes().end(),
-                   [config](DrmMode const &m) { return m.id() == config; });
+  auto mode = std::find_if(connector_->modes().begin(),
+                           connector_->modes().end(),
+                           [config](DrmMode const &m) {
+                             return m.id() == config;
+                           });
   if (mode == connector_->modes().end()) {
     ALOGE("Could not find active mode for %d", config);
     return HWC2::Error::BadConfig;
@@ -432,8 +435,8 @@
 }
 
 HWC2::Error DrmHwcTwo::HwcDisplay::GetHdrCapabilities(
-    uint32_t *num_types, int32_t */*types*/, float */*max_luminance*/,
-    float */*max_average_luminance*/, float */*min_luminance*/) {
+    uint32_t *num_types, int32_t * /*types*/, float * /*max_luminance*/,
+    float * /*max_average_luminance*/, float * /*min_luminance*/) {
   supported(__func__);
   *num_types = 0;
   return HWC2::Error::None;
@@ -524,8 +527,8 @@
     map.layers.emplace_back(std::move(layer));
   }
 
-  std::unique_ptr<DrmDisplayComposition> composition =
-      compositor_.CreateComposition();
+  std::unique_ptr<DrmDisplayComposition> composition = compositor_
+                                                           .CreateComposition();
   composition->Init(drm_, crtc_, importer_.get(), planner_.get(), frame_no_);
 
   // TODO: Don't always assume geometry changed
@@ -591,16 +594,18 @@
 
 HWC2::Error DrmHwcTwo::HwcDisplay::SetActiveConfig(hwc2_config_t config) {
   supported(__func__);
-  auto mode =
-      std::find_if(connector_->modes().begin(), connector_->modes().end(),
-                   [config](DrmMode const &m) { return m.id() == config; });
+  auto mode = std::find_if(connector_->modes().begin(),
+                           connector_->modes().end(),
+                           [config](DrmMode const &m) {
+                             return m.id() == config;
+                           });
   if (mode == connector_->modes().end()) {
     ALOGE("Could not find active mode for %d", config);
     return HWC2::Error::BadConfig;
   }
 
-  std::unique_ptr<DrmDisplayComposition> composition =
-      compositor_.CreateComposition();
+  std::unique_ptr<DrmDisplayComposition> composition = compositor_
+                                                           .CreateComposition();
   composition->Init(drm_, crtc_, importer_.get(), planner_.get(), frame_no_);
   int ret = composition->SetDisplayMode(*mode);
   ret = compositor_.ApplyComposition(std::move(composition));
@@ -679,8 +684,8 @@
       return HWC2::Error::Unsupported;
   };
 
-  std::unique_ptr<DrmDisplayComposition> composition =
-      compositor_.CreateComposition();
+  std::unique_ptr<DrmDisplayComposition> composition = compositor_
+                                                           .CreateComposition();
   composition->Init(drm_, crtc_, importer_.get(), planner_.get(), frame_no_);
   composition->SetDpmsMode(dpms_value);
   int ret = compositor_.ApplyComposition(std::move(composition));
@@ -902,7 +907,7 @@
       return ToHook<HWC2_PFN_CREATE_VIRTUAL_DISPLAY>(
           DeviceHook<int32_t, decltype(&DrmHwcTwo::CreateVirtualDisplay),
                      &DrmHwcTwo::CreateVirtualDisplay, uint32_t, uint32_t,
-                     int32_t*, hwc2_display_t *>);
+                     int32_t *, hwc2_display_t *>);
     case HWC2::FunctionDescriptor::DestroyVirtualDisplay:
       return ToHook<HWC2_PFN_DESTROY_VIRTUAL_DISPLAY>(
           DeviceHook<int32_t, decltype(&DrmHwcTwo::DestroyVirtualDisplay),
@@ -953,13 +958,15 @@
           DisplayHook<decltype(&HwcDisplay::GetColorModes),
                       &HwcDisplay::GetColorModes, uint32_t *, int32_t *>);
     case HWC2::FunctionDescriptor::GetDisplayAttribute:
-      return ToHook<HWC2_PFN_GET_DISPLAY_ATTRIBUTE>(DisplayHook<
-          decltype(&HwcDisplay::GetDisplayAttribute),
-          &HwcDisplay::GetDisplayAttribute, hwc2_config_t, int32_t, int32_t *>);
+      return ToHook<HWC2_PFN_GET_DISPLAY_ATTRIBUTE>(
+          DisplayHook<decltype(&HwcDisplay::GetDisplayAttribute),
+                      &HwcDisplay::GetDisplayAttribute, hwc2_config_t, int32_t,
+                      int32_t *>);
     case HWC2::FunctionDescriptor::GetDisplayConfigs:
-      return ToHook<HWC2_PFN_GET_DISPLAY_CONFIGS>(DisplayHook<
-          decltype(&HwcDisplay::GetDisplayConfigs),
-          &HwcDisplay::GetDisplayConfigs, uint32_t *, hwc2_config_t *>);
+      return ToHook<HWC2_PFN_GET_DISPLAY_CONFIGS>(
+          DisplayHook<decltype(&HwcDisplay::GetDisplayConfigs),
+                      &HwcDisplay::GetDisplayConfigs, uint32_t *,
+                      hwc2_config_t *>);
     case HWC2::FunctionDescriptor::GetDisplayName:
       return ToHook<HWC2_PFN_GET_DISPLAY_NAME>(
           DisplayHook<decltype(&HwcDisplay::GetDisplayName),
@@ -996,9 +1003,10 @@
           DisplayHook<decltype(&HwcDisplay::SetActiveConfig),
                       &HwcDisplay::SetActiveConfig, hwc2_config_t>);
     case HWC2::FunctionDescriptor::SetClientTarget:
-      return ToHook<HWC2_PFN_SET_CLIENT_TARGET>(DisplayHook<
-          decltype(&HwcDisplay::SetClientTarget), &HwcDisplay::SetClientTarget,
-          buffer_handle_t, int32_t, int32_t, hwc_region_t>);
+      return ToHook<HWC2_PFN_SET_CLIENT_TARGET>(
+          DisplayHook<decltype(&HwcDisplay::SetClientTarget),
+                      &HwcDisplay::SetClientTarget, buffer_handle_t, int32_t,
+                      int32_t, hwc_region_t>);
     case HWC2::FunctionDescriptor::SetColorMode:
       return ToHook<HWC2_PFN_SET_COLOR_MODE>(
           DisplayHook<decltype(&HwcDisplay::SetColorMode),
@@ -1058,9 +1066,10 @@
           LayerHook<decltype(&HwcLayer::SetLayerPlaneAlpha),
                     &HwcLayer::SetLayerPlaneAlpha, float>);
     case HWC2::FunctionDescriptor::SetLayerSidebandStream:
-      return ToHook<HWC2_PFN_SET_LAYER_SIDEBAND_STREAM>(LayerHook<
-          decltype(&HwcLayer::SetLayerSidebandStream),
-          &HwcLayer::SetLayerSidebandStream, const native_handle_t *>);
+      return ToHook<HWC2_PFN_SET_LAYER_SIDEBAND_STREAM>(
+          LayerHook<decltype(&HwcLayer::SetLayerSidebandStream),
+                    &HwcLayer::SetLayerSidebandStream,
+                    const native_handle_t *>);
     case HWC2::FunctionDescriptor::SetLayerSourceCrop:
       return ToHook<HWC2_PFN_SET_LAYER_SOURCE_CROP>(
           LayerHook<decltype(&HwcLayer::SetLayerSourceCrop),
@@ -1113,7 +1122,7 @@
   ctx.release();
   return 0;
 }
-}
+}  // namespace android
 
 static struct hw_module_methods_t hwc2_module_methods = {
     .open = android::DrmHwcTwo::HookDevOpen,
diff --git a/drmhwctwo.h b/drmhwctwo.h
index d987065..fd14b1f 100644
--- a/drmhwctwo.h
+++ b/drmhwctwo.h
@@ -255,8 +255,7 @@
 
   // Device functions
   HWC2::Error CreateVirtualDisplay(uint32_t width, uint32_t height,
-                                   int32_t *format,
-                                   hwc2_display_t *display);
+                                   int32_t *format, hwc2_display_t *display);
   HWC2::Error DestroyVirtualDisplay(hwc2_display_t display);
   void Dump(uint32_t *size, char *buffer);
   uint32_t GetMaxVirtualDisplayCount();
@@ -267,4 +266,4 @@
   std::map<hwc2_display_t, HwcDisplay> displays_;
   std::map<HWC2::Callback, HwcCallback> callbacks_;
 };
-}
+}  // namespace android
diff --git a/drmmode.cpp b/drmmode.cpp
index ee47a8e..5f2e7c2 100644
--- a/drmmode.cpp
+++ b/drmmode.cpp
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-#include "drmdevice.h"
 #include "drmmode.h"
+#include "drmdevice.h"
 
 #include <stdint.h>
-#include <string>
 #include <xf86drmMode.h>
+#include <string>
 
 namespace android {
 
@@ -122,8 +122,8 @@
 }
 
 float DrmMode::v_refresh() const {
-  return v_refresh_ ? v_refresh_ * 1.0f :
-                      clock_ / (float)(v_total_ * h_total_) * 1000.0f;
+  return v_refresh_ ? v_refresh_ * 1.0f
+                    : clock_ / (float)(v_total_ * h_total_) * 1000.0f;
 }
 
 uint32_t DrmMode::flags() const {
@@ -137,4 +137,4 @@
 std::string DrmMode::name() const {
   return name_;
 }
-}
+}  // namespace android
diff --git a/drmmode.h b/drmmode.h
index b383168..4cc06b1 100644
--- a/drmmode.h
+++ b/drmmode.h
@@ -18,8 +18,8 @@
 #define ANDROID_DRM_MODE_H_
 
 #include <stdint.h>
-#include <string>
 #include <xf86drmMode.h>
+#include <string>
 
 namespace android {
 
@@ -77,6 +77,6 @@
 
   std::string name_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_MODE_H_
diff --git a/drmplane.cpp b/drmplane.cpp
index 051d591..2603e16 100644
--- a/drmplane.cpp
+++ b/drmplane.cpp
@@ -16,12 +16,12 @@
 
 #define LOG_TAG "hwc-drm-plane"
 
-#include "drmdevice.h"
 #include "drmplane.h"
+#include "drmdevice.h"
 
-#include <cinttypes>
 #include <errno.h>
 #include <stdint.h>
+#include <cinttypes>
 
 #include <log/log.h>
 #include <xf86drmMode.h>
@@ -196,4 +196,4 @@
 const DrmProperty &DrmPlane::in_fence_fd_property() const {
   return in_fence_fd_property_;
 }
-}
+}  // namespace android
diff --git a/drmplane.h b/drmplane.h
index a293afe..46dbc94 100644
--- a/drmplane.h
+++ b/drmplane.h
@@ -78,6 +78,6 @@
   DrmProperty alpha_property_;
   DrmProperty in_fence_fd_property_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_PLANE_H_
diff --git a/drmproperty.cpp b/drmproperty.cpp
index d7a06e3..e71c159 100644
--- a/drmproperty.cpp
+++ b/drmproperty.cpp
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#include "drmdevice.h"
 #include "drmproperty.h"
+#include "drmdevice.h"
 
 #include <errno.h>
 #include <stdint.h>
@@ -99,4 +99,4 @@
       return -EINVAL;
   }
 }
-}
+}  // namespace android
diff --git a/drmproperty.h b/drmproperty.h
index 648eda7..dc01c88 100644
--- a/drmproperty.h
+++ b/drmproperty.h
@@ -18,8 +18,8 @@
 #define ANDROID_DRM_PROPERTY_H_
 
 #include <stdint.h>
-#include <string>
 #include <xf86drmMode.h>
+#include <string>
 #include <vector>
 
 namespace android {
@@ -67,6 +67,6 @@
   std::vector<DrmPropertyEnum> enums_;
   std::vector<uint32_t> blob_ids_;
 };
-}
+}  // namespace android
 
 #endif  // ANDROID_DRM_PROPERTY_H_
diff --git a/hwcutils.cpp b/hwcutils.cpp
index 31b781a..b778b93 100644
--- a/hwcutils.cpp
+++ b/hwcutils.cpp
@@ -62,8 +62,8 @@
 int DrmHwcNativeHandle::CopyBufferHandle(buffer_handle_t handle) {
   native_handle_t *handle_copy;
   GraphicBufferMapper &gm(GraphicBufferMapper::get());
-  int ret =
-      gm.importBuffer(handle, const_cast<buffer_handle_t *>(&handle_copy));
+  int ret = gm.importBuffer(handle,
+                            const_cast<buffer_handle_t *>(&handle_copy));
   if (ret) {
     ALOGE("Failed to import buffer handle %d", ret);
     return ret;
@@ -144,4 +144,4 @@
       transform |= DrmHwcTransform::kRotate90;
   }
 }
-}
+}  // namespace android
diff --git a/platform.cpp b/platform.cpp
index 39761fa..af18124 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -16,8 +16,8 @@
 
 #define LOG_TAG "hwc-platform"
 
-#include "drmdevice.h"
 #include "platform.h"
+#include "drmdevice.h"
 
 #include <log/log.h>
 
@@ -41,8 +41,8 @@
     std::vector<DrmPlane *> *primary_planes,
     std::vector<DrmPlane *> *overlay_planes) {
   std::vector<DrmCompositionPlane> composition;
-  std::vector<DrmPlane *> planes =
-      GetUsablePlanes(crtc, primary_planes, overlay_planes);
+  std::vector<DrmPlane *> planes = GetUsablePlanes(crtc, primary_planes,
+                                                   overlay_planes);
   if (planes.empty()) {
     ALOGE("Display %d has no usable planes", crtc->display());
     return std::make_tuple(-ENODEV, std::vector<DrmCompositionPlane>());
@@ -101,4 +101,4 @@
 
   return 0;
 }
-}
+}  // namespace android
diff --git a/platform.h b/platform.h
index 32d0011..37c4647 100644
--- a/platform.h
+++ b/platform.h
@@ -136,5 +136,5 @@
                       std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
                       std::vector<DrmPlane *> *planes);
 };
-}
+}  // namespace android
 #endif
diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp
index a1198bf..b0cb130 100644
--- a/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -16,17 +16,17 @@
 
 #define LOG_TAG "hwc-platform-drm-generic"
 
+#include "platformdrmgeneric.h"
 #include "drmdevice.h"
 #include "platform.h"
-#include "platformdrmgeneric.h"
 
 #include <drm/drm_fourcc.h>
 #include <xf86drm.h>
 #include <xf86drmMode.h>
 
-#include <log/log.h>
 #include <gralloc_handle.h>
 #include <hardware/gralloc.h>
+#include <log/log.h>
 
 namespace android {
 
diff --git a/platformdrmgeneric.h b/platformdrmgeneric.h
index 8701329..ebe27b7 100644
--- a/platformdrmgeneric.h
+++ b/platformdrmgeneric.h
@@ -35,11 +35,12 @@
   int ReleaseBuffer(hwc_drm_bo_t *bo) override;
 
   uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
+
  private:
   DrmDevice *drm_;
 
   const gralloc_module_t *gralloc_;
 };
-}
+}  // namespace android
 
 #endif
diff --git a/platformhisi.cpp b/platformhisi.cpp
index 3ff355f..5a1ac1b 100644
--- a/platformhisi.cpp
+++ b/platformhisi.cpp
@@ -16,19 +16,18 @@
 
 #define LOG_TAG "hwc-platform-hisi"
 
+#include "platformhisi.h"
 #include "drmdevice.h"
 #include "platform.h"
-#include "platformhisi.h"
-
 
 #include <drm/drm_fourcc.h>
-#include <cinttypes>
 #include <stdatomic.h>
 #include <xf86drm.h>
 #include <xf86drmMode.h>
+#include <cinttypes>
 
-#include <log/log.h>
 #include <hardware/gralloc.h>
+#include <log/log.h>
 #include "gralloc_priv.h"
 
 #define MALI_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1))
@@ -72,8 +71,8 @@
 }
 
 int HisiImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
-  private_handle_t const *hnd =
-      reinterpret_cast<private_handle_t const *>(handle);
+  private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
+      handle);
   if (!hnd)
     return -EINVAL;
 
@@ -138,4 +137,4 @@
   planner->AddStage<PlanStageGreedy>();
   return planner;
 }
-}
+}  // namespace android
diff --git a/platformhisi.h b/platformhisi.h
index 4e6cc57..2b2d439 100644
--- a/platformhisi.h
+++ b/platformhisi.h
@@ -41,6 +41,6 @@
 
   const gralloc_module_t *gralloc_;
 };
-}
+}  // namespace android
 
 #endif
diff --git a/platformminigbm.cpp b/platformminigbm.cpp
index 8e3cc65..eb0b93f 100644
--- a/platformminigbm.cpp
+++ b/platformminigbm.cpp
@@ -16,16 +16,16 @@
 
 #define LOG_TAG "hwc-platform-drm-minigbm"
 
+#include "platformminigbm.h"
 #include "drmresources.h"
 #include "platform.h"
-#include "platformminigbm.h"
 
 #include <drm/drm_fourcc.h>
 #include <xf86drm.h>
 #include <xf86drmMode.h>
 
-#include <log/log.h>
 #include <hardware/gralloc.h>
+#include <log/log.h>
 
 #include "cros_gralloc_handle.h"
 
@@ -45,7 +45,8 @@
   return importer;
 }
 
-DrmMinigbmImporter::DrmMinigbmImporter(DrmResources *drm) : DrmGenericImporter(drm), drm_(drm) {
+DrmMinigbmImporter::DrmMinigbmImporter(DrmResources *drm)
+    : DrmGenericImporter(drm), drm_(drm) {
 }
 
 DrmMinigbmImporter::~DrmMinigbmImporter() {
@@ -103,4 +104,4 @@
   return planner;
 }
 
-}
+}  // namespace android
diff --git a/platformminigbm.h b/platformminigbm.h
index f25bf7b..f5807b9 100644
--- a/platformminigbm.h
+++ b/platformminigbm.h
@@ -40,6 +40,6 @@
   const gralloc_module_t *gralloc_;
 };
 
-}
+}  // namespace android
 
 #endif
diff --git a/resourcemanager.cpp b/resourcemanager.cpp
index 9566fda..6e23561 100644
--- a/resourcemanager.cpp
+++ b/resourcemanager.cpp
@@ -109,4 +109,4 @@
 const gralloc_module_t *ResourceManager::gralloc() {
   return gralloc_;
 }
-}
+}  // namespace android
diff --git a/resourcemanager.h b/resourcemanager.h
index 11b3c8a..463739b 100644
--- a/resourcemanager.h
+++ b/resourcemanager.h
@@ -43,6 +43,6 @@
   std::vector<std::shared_ptr<Importer>> importers_;
   const gralloc_module_t *gralloc_;
 };
-}
+}  // namespace android
 
 #endif  // RESOURCEMANAGER_H
diff --git a/vsyncworker.cpp b/vsyncworker.cpp
index e8a9332..d022887 100644
--- a/vsyncworker.cpp
+++ b/vsyncworker.cpp
@@ -16,18 +16,18 @@
 
 #define LOG_TAG "hwc-vsync-worker"
 
-#include "drmdevice.h"
 #include "vsyncworker.h"
+#include "drmdevice.h"
 #include "worker.h"
 
-#include <map>
 #include <stdlib.h>
 #include <time.h>
 #include <xf86drm.h>
 #include <xf86drmMode.h>
+#include <map>
 
-#include <log/log.h>
 #include <hardware/hardware.h>
+#include <log/log.h>
 
 namespace android {
 
@@ -99,8 +99,9 @@
     ALOGW("Vsync worker active with conn=%p refresh=%f\n", conn,
           conn ? conn->active_mode().v_refresh() : 0.0f);
 
-  int64_t phased_timestamp = GetPhasedVSync(
-      kOneSecondNs / refresh, vsync.tv_sec * kOneSecondNs + vsync.tv_nsec);
+  int64_t phased_timestamp = GetPhasedVSync(kOneSecondNs / refresh,
+                                            vsync.tv_sec * kOneSecondNs +
+                                                vsync.tv_nsec);
   vsync.tv_sec = phased_timestamp / kOneSecondNs;
   vsync.tv_nsec = phased_timestamp - (vsync.tv_sec * kOneSecondNs);
   do {
@@ -172,4 +173,4 @@
     callback->Callback(display, timestamp);
   last_timestamp_ = timestamp;
 }
-}
+}  // namespace android
diff --git a/vsyncworker.h b/vsyncworker.h
index 3d3a805..b2bca9d 100644
--- a/vsyncworker.h
+++ b/vsyncworker.h
@@ -20,8 +20,8 @@
 #include "drmdevice.h"
 #include "worker.h"
 
-#include <map>
 #include <stdint.h>
+#include <map>
 
 #include <hardware/hardware.h>
 #include <hardware/hwcomposer.h>
@@ -63,6 +63,6 @@
   bool enabled_;
   int64_t last_timestamp_;
 };
-}
+}  // namespace android
 
 #endif
diff --git a/worker.cpp b/worker.cpp
index da6c580..0dceb16 100644
--- a/worker.cpp
+++ b/worker.cpp
@@ -91,4 +91,4 @@
     Routine();
   }
 }
-}
+}  // namespace android
diff --git a/worker.h b/worker.h
index 8f6295b..7909038 100644
--- a/worker.h
+++ b/worker.h
@@ -77,5 +77,5 @@
   bool exit_;
   bool initialized_;
 };
-}
+}  // namespace android
 #endif