drm_hwcomposer: Add SIZE_HINTS property to DrmPlane

This change reads and parses the SIZE_HINTS drm plane property. Once
parsed successfully, the size hints indicate recommended sizes to
use with cursor planes, in order of preference [1]. The property is
not populated on planes which do not have DRM_PLANE_TYPE_CURSOR.

[1] https://drmdb.emersion.fr/properties/4008636142/SIZE_HINTS

Change-Id: Ia98a45ab5f279573f61394a357eccc90952528c5
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
diff --git a/drm/DrmPlane.cpp b/drm/DrmPlane.cpp
index 68887dd..235f59d 100644
--- a/drm/DrmPlane.cpp
+++ b/drm/DrmPlane.cpp
@@ -132,6 +132,12 @@
     }
   }
 
+  if (type_ == DRM_PLANE_TYPE_CURSOR &&
+      GetPlaneProperty("SIZE_HINTS", size_hints_property_,
+                       Presence::kOptional)) {
+    size_hints_property_.GetBlobData(size_hints_);
+  }
+
   return 0;
 }
 
diff --git a/drm/DrmPlane.h b/drm/DrmPlane.h
index 81306d9..b744b2d 100644
--- a/drm/DrmPlane.h
+++ b/drm/DrmPlane.h
@@ -30,6 +30,12 @@
 class DrmDevice;
 struct LayerData;
 
+// NOLINTNEXTLINE(readability-identifier-naming)
+struct drm_plane_size_hint_local {
+  __u16 width;
+  __u16 height;
+};
+
 class DrmPlane : public PipelineBindable<DrmPlane> {
  public:
   DrmPlane(const DrmPlane &) = delete;
@@ -92,10 +98,12 @@
   DrmProperty in_fence_fd_property_;
   DrmProperty color_encoding_property_;
   DrmProperty color_range_property_;
+  DrmProperty size_hints_property_;
 
   std::map<BufferBlendMode, uint64_t> blending_enum_map_;
   std::map<BufferColorSpace, uint64_t> color_encoding_enum_map_;
   std::map<BufferSampleRange, uint64_t> color_range_enum_map_;
   uint64_t transform_enum_mask_ = DRM_MODE_ROTATE_0;
+  std::vector<drm_plane_size_hint_local> size_hints_;
 };
 }  // namespace android