OSDN Git Service

Format check in the getclienttargetsupport API
authorPoornima <poornima.y.n@intel.com>
Thu, 23 Mar 2017 05:07:59 +0000 (10:37 +0530)
committerKalyan Kondapally <kalyan.kondapally@intel.com>
Fri, 24 Mar 2017 13:08:18 +0000 (06:08 -0700)
Querying whether the client target format can be supported by
device.

Jira: https://01.org/jira/browse/IAHWC-12
Test: No regression observed on Android.

Signed-off-by: Poornima <poornima.y.n@intel.com>
common/display/display.cpp
common/display/display.h
common/display/displayplanemanager.cpp
common/display/displayplanemanager.h
common/display/displayqueue.cpp
common/display/displayqueue.h
common/display/headless.cpp
common/display/headless.h
os/android/drmhwctwo.cpp
os/android/drmutils.h [new file with mode: 0644]
public/nativedisplay.h

index 1dded21..130f3cb 100644 (file)
@@ -220,4 +220,8 @@ void Display::VSyncControl(bool enabled) {
   flip_handler_->VSyncControl(enabled);
 }
 
+bool Display::CheckPlaneFormat(uint32_t format) {
+  return display_queue_->CheckPlaneFormat(format);
+}
+
 }  // namespace hwcomposer
index 26c998e..ef82d89 100644 (file)
@@ -55,11 +55,11 @@ class Display : public NativeDisplay {
     return pipe_;
   }
 
-  int32_t Width() const override {
+  uint32_t Width() const override {
     return width_;
   }
 
-  int32_t Height() const override {
+  uint32_t Height() const override {
     return height_;
   }
 
@@ -87,6 +87,7 @@ class Display : public NativeDisplay {
                             uint32_t display_id) override;
 
   void VSyncControl(bool enabled) override;
+  bool CheckPlaneFormat(uint32_t format) override;
 
  protected:
   uint32_t CrtcId() const override {
index c4b86b5..527bd6d 100644 (file)
@@ -509,4 +509,8 @@ std::unique_ptr<DisplayPlane> DisplayPlaneManager::CreatePlane(
       new DisplayPlane(plane_id, possible_crtcs));
 }
 
+bool DisplayPlaneManager::CheckPlaneFormat(uint32_t format) {
+  return primary_plane_->IsSupportedFormat(format);
+}
+
 }  // namespace hwcomposer
index e93c2e2..fbf4013 100644 (file)
@@ -62,6 +62,7 @@ class DisplayPlaneManager {
   void DisablePipe(drmModeAtomicReqPtr property_set);
 
   void EndFrameUpdate();
+  bool CheckPlaneFormat(uint32_t format);
 
  protected:
   struct OverlayPlane {
index c681fe9..f86ffe6 100644 (file)
@@ -317,4 +317,8 @@ void DisplayQueue::GetDrmObjectProperty(const char* name,
     ETRACE("Could not find property %s", name);
 }
 
+bool DisplayQueue::CheckPlaneFormat(uint32_t format) {
+  return display_plane_manager_->CheckPlaneFormat(format);
+}
+
 }  // namespace hwcomposer
index dd56f94..e8181a5 100644 (file)
@@ -52,6 +52,7 @@ class DisplayQueue {
 
   bool QueueUpdate(std::vector<HwcLayer*>& source_layers);
   bool SetPowerMode(uint32_t power_mode);
+  bool CheckPlaneFormat(uint32_t format);
 
   void HandleExit();
 
index 4fca20d..67a62b7 100644 (file)
@@ -129,4 +129,9 @@ int Headless::RegisterVsyncCallback(std::shared_ptr<VsyncCallback> /*callback*/,
 void Headless::VSyncControl(bool /*enabled*/) {
 }
 
+bool Headless::CheckPlaneFormat(uint32_t /*format*/) {
+  // assuming that virtual display supports the format
+  return true;
+}
+
 }  // namespace hwcomposer
index 3d8e223..05807d0 100644 (file)
@@ -41,11 +41,11 @@ class Headless : public NativeDisplay {
     return 0;
   }
 
-  int32_t Width() const override {
+  uint32_t Width() const override {
     return 1;
   }
 
-  int32_t Height() const override {
+  uint32_t Height() const override {
     return 1;
   }
 
@@ -73,6 +73,7 @@ class Headless : public NativeDisplay {
                             uint32_t display_id) override;
 
   void VSyncControl(bool enabled) override;
+  bool CheckPlaneFormat(uint32_t format) override;
 
  protected:
   uint32_t CrtcId() const override {
index 26084a2..913763b 100644 (file)
@@ -18,6 +18,7 @@
 #define LOG_TAG "hwc-drm-two"
 
 #include "drmhwctwo.h"
+#include "drmutils.h"
 
 #include <xf86drmMode.h>
 
@@ -264,16 +265,28 @@ HWC2::Error DrmHwcTwo::HwcDisplay::GetChangedCompositionTypes(
   return HWC2::Error::None;
 }
 
-HWC2::Error DrmHwcTwo::HwcDisplay::GetClientTargetSupport(uint32_t /*width*/,
-                                                          uint32_t /*height*/,
-                                                          int32_t /*format*/,
+HWC2::Error DrmHwcTwo::HwcDisplay::GetClientTargetSupport(uint32_t width,
+                                                          uint32_t height,
+                                                          int32_t format,
                                                           int32_t dataspace) {
-  if (dataspace != HAL_DATASPACE_UNKNOWN &&
-      dataspace != HAL_DATASPACE_STANDARD_UNSPECIFIED)
+  if (width != display_->Width() || height != display_->Height()) {
     return HWC2::Error::Unsupported;
+  }
 
-  // TODO: Validate format can be handled by either GL or planes
-  return HWC2::Error::None;
+  if (format == HAL_PIXEL_FORMAT_RGBA_8888 &&
+      (dataspace == HAL_DATASPACE_UNKNOWN ||
+       dataspace == HAL_DATASPACE_STANDARD_UNSPECIFIED)) {
+    return HWC2::Error::None;
+  } else {
+    // Convert HAL to fourcc-based DRM formats
+    uint32_t drm_format = GetDrmFormat(format);
+    if (display_->CheckPlaneFormat(drm_format) &&
+        (dataspace == HAL_DATASPACE_UNKNOWN ||
+         dataspace == HAL_DATASPACE_STANDARD_UNSPECIFIED))
+      return HWC2::Error::None;
+  }
+
+  return HWC2::Error::Unsupported;
 }
 
 HWC2::Error DrmHwcTwo::HwcDisplay::GetColorModes(uint32_t *num_modes,
diff --git a/os/android/drmutils.h b/os/android/drmutils.h
new file mode 100644 (file)
index 0000000..865600b
--- /dev/null
@@ -0,0 +1,56 @@
+
+/*
+// Copyright (c) 2017 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#ifndef OS_ANDROID_DRMUTILS_H_
+#define OS_ANDROID_DRMUTILS_H_
+
+#include <stdint.h>
+#include <drm_fourcc.h>
+#include <system/graphics.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DRM_FORMAT_NONE fourcc_code('0', '0', '0', '0')
+
+// Conversion from HAL to fourcc-based DRM formats
+uint32_t GetDrmFormat(int format) {
+  switch (format) {
+    case HAL_PIXEL_FORMAT_RGBA_8888:
+      return DRM_FORMAT_BGRA8888;
+    case HAL_PIXEL_FORMAT_RGBX_8888:
+      return DRM_FORMAT_BGRX8888;
+    case HAL_PIXEL_FORMAT_RGB_888:
+      return DRM_FORMAT_BGR888;
+    case HAL_PIXEL_FORMAT_RGB_565:
+      return DRM_FORMAT_BGR565;
+    case HAL_PIXEL_FORMAT_BGRA_8888:
+      return DRM_FORMAT_ARGB8888;
+    case HAL_PIXEL_FORMAT_YV12:
+      return DRM_FORMAT_YVU420;
+    default:
+      break;
+  }
+
+  return DRM_FORMAT_NONE;
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
index 4944763..4d411be 100644 (file)
@@ -51,9 +51,9 @@ class NativeDisplay {
 
   virtual uint32_t Pipe() const = 0;
 
-  virtual int32_t Width() const = 0;
+  virtual uint32_t Width() const = 0;
 
-  virtual int32_t Height() const = 0;
+  virtual uint32_t Height() const = 0;
 
   virtual int32_t GetRefreshRate() const = 0;
 
@@ -82,6 +82,11 @@ class NativeDisplay {
   virtual void SetOutputBuffer(HWCNativeHandle /*buffer*/,
                                int32_t /*acquire_fence*/) {
   }
+  /**
+  * API to check the format support on the device
+  * @param format valid DRM formats found in drm_fourcc.h.
+  */
+  virtual bool CheckPlaneFormat(uint32_t format) = 0;
 
  protected:
   virtual uint32_t CrtcId() const = 0;