OSDN Git Service

Add support to query supported Media format from DisplayPlane.
authorXiaosong Wei <xiaosong.wei@intel.com>
Mon, 2 Oct 2017 05:17:27 +0000 (22:17 -0700)
committerKalyan Kondapally <kalyan.kondapally@intel.com>
Tue, 3 Oct 2017 22:44:03 +0000 (15:44 -0700)
We want to fall back to a optimal packed/planar format, when
Display Plane is unable to handle a given Media buffer. This
information needs to be queried from DisplayPlane. We add
an API in DisplayPlane to query this information, this will
be used in followup patches to convert Media content to a
format which can be scanned out directly.

Jira: None.
Test: Build passes on Linux and Android.
Signed-off-by: Xiaosong Wei <xiaosong.wei@intel.com>
wsi/displayplane.h
wsi/drm/drmplane.cpp
wsi/drm/drmplane.h

index 1e075c6..a531d95 100644 (file)
@@ -40,6 +40,12 @@ class DisplayPlane {
 
   virtual uint32_t GetFormatForFrameBuffer(uint32_t format) = 0;
 
+  /**
+   * API for querying preferred Video format supported by this
+   * plane.
+   */
+  virtual uint32_t GetPreferredVideoFormat() const = 0;
+
   virtual void Dump() const = 0;
 };
 
index cbae313..29f2529 100644 (file)
@@ -63,6 +63,36 @@ DrmPlane::~DrmPlane() {
 bool DrmPlane::Initialize(uint32_t gpu_fd,
                           const std::vector<uint32_t>& formats) {
   supported_formats_ = formats;
+  uint32_t total_size = supported_formats_.size();
+  for (uint32_t j = 0; j < total_size; j++) {
+    uint32_t format = supported_formats_.at(j);
+    switch (format) {
+      case DRM_FORMAT_NV12:
+      case DRM_FORMAT_YVU420:  // YV12
+      case DRM_FORMAT_YUV420:  // I420
+      case DRM_FORMAT_YUV422:
+      case DRM_FORMAT_YUV444:
+      case DRM_FORMAT_YUYV:  // YUY2
+        prefered_video_format_ = format;
+        break;
+    }
+  }
+
+  if (prefered_video_format_ == 0) {
+    for (uint32_t j = 0; j < total_size; j++) {
+      uint32_t format = supported_formats_.at(j);
+      switch (format) {
+        case DRM_FORMAT_RGB888:
+        case DRM_FORMAT_XRGB8888:
+        case DRM_FORMAT_XBGR8888:
+        case DRM_FORMAT_RGBX8888:
+        case DRM_FORMAT_ABGR8888:
+        case DRM_FORMAT_RGBA8888:
+          prefered_video_format_ = format;
+          break;
+      }
+    }
+  }
 
   ScopedDrmObjectPropertyPtr plane_props(
       drmModeObjectGetProperties(gpu_fd, id_, DRM_MODE_OBJECT_PLANE));
@@ -332,6 +362,10 @@ uint32_t DrmPlane::GetFormatForFrameBuffer(uint32_t format) {
   return format;
 }
 
+uint32_t DrmPlane::GetPreferredVideoFormat() const {
+  return prefered_video_format_;
+}
+
 void DrmPlane::Dump() const {
   DUMPTRACE("Plane Information Starts. -------------");
   DUMPTRACE("Plane ID: %d", id_);
@@ -393,6 +427,8 @@ void DrmPlane::Dump() const {
   if (in_fence_fd_prop_.id != 0)
     DUMPTRACE("IN_FENCE_FD is supported.");
 
+  DUMPTRACE("Preferred Video Formar: %4.4s", (char*)&(prefered_video_format_));
+
   DUMPTRACE("Plane Information Ends. -------------");
 }
 
index ab45bf7..d6b0573 100644 (file)
@@ -65,6 +65,7 @@ class DrmPlane : public DisplayPlane {
   bool IsSupportedFormat(uint32_t format) override;
 
   uint32_t GetFormatForFrameBuffer(uint32_t format) override;
+  uint32_t GetPreferredVideoFormat() const override;
 
   void Dump() const override;
 
@@ -102,6 +103,7 @@ class DrmPlane : public DisplayPlane {
 
   std::vector<uint32_t> supported_formats_;
   int32_t kms_fence_ = 0;
+  uint32_t prefered_video_format_ = 0;
 };
 
 }  // namespace hwcomposer