drm_hwcomposer: Move CreateModeBlob to DrmMode class

CreateModeBlob doesn't architecturally belongs to DrmDisplayCompositor.
+ align DrmMode internal types with libdrm types to avoid compilation errors.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/compositor/DrmDisplayCompositor.cpp b/compositor/DrmDisplayCompositor.cpp
index 9d3e56d..bb6a33b 100644
--- a/compositor/DrmDisplayCompositor.cpp
+++ b/compositor/DrmDisplayCompositor.cpp
@@ -205,16 +205,6 @@
   return ret;
 }
 
-auto DrmDisplayCompositor::CreateModeBlob(const DrmMode &mode)
-    -> DrmModeUserPropertyBlobUnique {
-  struct drm_mode_modeinfo drm_mode {};
-  mode.ToDrmModeModeInfo(&drm_mode);
-
-  DrmDevice *drm = resource_manager_->GetDrmDevice(display_);
-  return drm->RegisterUserPropertyBlob(&drm_mode,
-                                       sizeof(struct drm_mode_modeinfo));
-}
-
 void DrmDisplayCompositor::ClearDisplay() {
   if (!active_composition_)
     return;
@@ -250,7 +240,7 @@
 
 auto DrmDisplayCompositor::SetDisplayMode(const DrmMode &display_mode) -> bool {
   mode_.mode = display_mode;
-  mode_.blob = CreateModeBlob(mode_.mode);
+  mode_.blob = mode_.mode.CreateModeBlob(*resource_manager_->GetDrmDevice(display_));
   return !!mode_.blob;
 }
 
diff --git a/compositor/DrmDisplayCompositor.h b/compositor/DrmDisplayCompositor.h
index 17dc701..434668f 100644
--- a/compositor/DrmDisplayCompositor.h
+++ b/compositor/DrmDisplayCompositor.h
@@ -70,8 +70,6 @@
   int CommitFrame(DrmDisplayComposition *display_comp, bool test_only);
   int DisablePlanes(DrmDisplayComposition *display_comp);
 
-  auto CreateModeBlob(const DrmMode &mode) -> DrmModeUserPropertyBlobUnique;
-
   ResourceManager *resource_manager_;
   int display_;
 
diff --git a/drm/DrmMode.cpp b/drm/DrmMode.cpp
index c714458..971c327 100644
--- a/drm/DrmMode.cpp
+++ b/drm/DrmMode.cpp
@@ -49,24 +49,6 @@
          v_scan_ == m.vscan && flags_ == m.flags && type_ == m.type;
 }
 
-void DrmMode::ToDrmModeModeInfo(drm_mode_modeinfo *m) const {
-  m->clock = clock_;
-  m->hdisplay = h_display_;
-  m->hsync_start = h_sync_start_;
-  m->hsync_end = h_sync_end_;
-  m->htotal = h_total_;
-  m->hskew = h_skew_;
-  m->vdisplay = v_display_;
-  m->vsync_start = v_sync_start_;
-  m->vsync_end = v_sync_end_;
-  m->vtotal = v_total_;
-  m->vscan = v_scan_;
-  m->vrefresh = v_refresh_;
-  m->flags = flags_;
-  m->type = type_;
-  strncpy(m->name, name_.c_str(), DRM_DISPLAY_MODE_LEN);
-}
-
 uint32_t DrmMode::id() const {
   return id_;
 }
@@ -79,43 +61,43 @@
   return clock_;
 }
 
-uint32_t DrmMode::h_display() const {
+uint16_t DrmMode::h_display() const {
   return h_display_;
 }
 
-uint32_t DrmMode::h_sync_start() const {
+uint16_t DrmMode::h_sync_start() const {
   return h_sync_start_;
 }
 
-uint32_t DrmMode::h_sync_end() const {
+uint16_t DrmMode::h_sync_end() const {
   return h_sync_end_;
 }
 
-uint32_t DrmMode::h_total() const {
+uint16_t DrmMode::h_total() const {
   return h_total_;
 }
 
-uint32_t DrmMode::h_skew() const {
+uint16_t DrmMode::h_skew() const {
   return h_skew_;
 }
 
-uint32_t DrmMode::v_display() const {
+uint16_t DrmMode::v_display() const {
   return v_display_;
 }
 
-uint32_t DrmMode::v_sync_start() const {
+uint16_t DrmMode::v_sync_start() const {
   return v_sync_start_;
 }
 
-uint32_t DrmMode::v_sync_end() const {
+uint16_t DrmMode::v_sync_end() const {
   return v_sync_end_;
 }
 
-uint32_t DrmMode::v_total() const {
+uint16_t DrmMode::v_total() const {
   return v_total_;
 }
 
-uint32_t DrmMode::v_scan() const {
+uint16_t DrmMode::v_scan() const {
   return v_scan_;
 }
 
@@ -135,4 +117,29 @@
 std::string DrmMode::name() const {
   return name_;
 }
+
+auto DrmMode::CreateModeBlob(const DrmDevice &drm)
+    -> DrmModeUserPropertyBlobUnique {
+  struct drm_mode_modeinfo drm_mode = {
+      .clock = clock_,
+      .hdisplay = h_display_,
+      .hsync_start = h_sync_start_,
+      .hsync_end = h_sync_end_,
+      .htotal = h_total_,
+      .hskew = h_skew_,
+      .vdisplay = v_display_,
+      .vsync_start = v_sync_start_,
+      .vsync_end = v_sync_end_,
+      .vtotal = v_total_,
+      .vscan = v_scan_,
+      .vrefresh = v_refresh_,
+      .flags = flags_,
+      .type = type_,
+  };
+  strncpy(drm_mode.name, name_.c_str(), DRM_DISPLAY_MODE_LEN);
+
+  return drm.RegisterUserPropertyBlob(&drm_mode,
+                                       sizeof(struct drm_mode_modeinfo));
+}
+
 }  // namespace android
diff --git a/drm/DrmMode.h b/drm/DrmMode.h
index 313a8ea..0974b5a 100644
--- a/drm/DrmMode.h
+++ b/drm/DrmMode.h
@@ -22,32 +22,35 @@
 
 #include <string>
 
+#include "DrmUnique.h"
+
 namespace android {
 
+class DrmDevice;
+
 class DrmMode {
  public:
   DrmMode() = default;
   DrmMode(drmModeModeInfoPtr m);
 
   bool operator==(const drmModeModeInfo &m) const;
-  void ToDrmModeModeInfo(drm_mode_modeinfo *m) const;
 
   uint32_t id() const;
   void set_id(uint32_t id);
 
   uint32_t clock() const;
 
-  uint32_t h_display() const;
-  uint32_t h_sync_start() const;
-  uint32_t h_sync_end() const;
-  uint32_t h_total() const;
-  uint32_t h_skew() const;
+  uint16_t h_display() const;
+  uint16_t h_sync_start() const;
+  uint16_t h_sync_end() const;
+  uint16_t h_total() const;
+  uint16_t h_skew() const;
 
-  uint32_t v_display() const;
-  uint32_t v_sync_start() const;
-  uint32_t v_sync_end() const;
-  uint32_t v_total() const;
-  uint32_t v_scan() const;
+  uint16_t v_display() const;
+  uint16_t v_sync_start() const;
+  uint16_t v_sync_end() const;
+  uint16_t v_total() const;
+  uint16_t v_scan() const;
   float v_refresh() const;
 
   uint32_t flags() const;
@@ -55,23 +58,25 @@
 
   std::string name() const;
 
+  auto CreateModeBlob(const DrmDevice &drm) -> DrmModeUserPropertyBlobUnique;
+
  private:
   uint32_t id_ = 0;
 
   uint32_t clock_ = 0;
 
-  uint32_t h_display_ = 0;
-  uint32_t h_sync_start_ = 0;
-  uint32_t h_sync_end_ = 0;
-  uint32_t h_total_ = 0;
-  uint32_t h_skew_ = 0;
+  uint16_t h_display_ = 0;
+  uint16_t h_sync_start_ = 0;
+  uint16_t h_sync_end_ = 0;
+  uint16_t h_total_ = 0;
+  uint16_t h_skew_ = 0;
 
-  uint32_t v_display_ = 0;
-  uint32_t v_sync_start_ = 0;
-  uint32_t v_sync_end_ = 0;
-  uint32_t v_total_ = 0;
-  uint32_t v_scan_ = 0;
-  uint32_t v_refresh_ = 0;
+  uint16_t v_display_ = 0;
+  uint16_t v_sync_start_ = 0;
+  uint16_t v_sync_end_ = 0;
+  uint16_t v_total_ = 0;
+  uint16_t v_scan_ = 0;
+  uint16_t v_refresh_ = 0;
 
   uint32_t flags_ = 0;
   uint32_t type_ = 0;