OSDN Git Service

Added the Panorama dynamic turn on/off feature.
[android-x86/external-IA-Hardware-Composer.git] / os / android / iahwc2.h
index 6016eec..1062860 100644 (file)
 
 #include "hwcservice.h"
 
+/*we have two extend displays,the seconde one's take over virtual
+display ID slot.to simplify ID management,start the virtual display
+ID from 4(HWC_DISPLAY_VIRTUAL+VDS_OFFSET)*/
+#define VDS_OFFSET 2
+
 namespace hwcomposer {
 class GpuDevice;
 class NativeDisplay;
-}
+}  // namespace hwcomposer
 
 namespace android {
 class HwcService;
@@ -46,6 +51,29 @@ class IAHWC2 : public hwc2_device_t {
   hwcomposer::NativeDisplay *GetPrimaryDisplay();
   hwcomposer::NativeDisplay *GetExtendedDisplay(uint32_t);
 
+  void EnableHDCPSessionForDisplay(uint32_t connector,
+                                   EHwcsContentType content_type);
+
+  void EnableHDCPSessionForAllDisplays(EHwcsContentType content_type);
+
+  void DisableHDCPSessionForDisplay(uint32_t connector);
+
+  void DisableHDCPSessionForAllDisplays();
+#ifdef ENABLE_PANORAMA
+  void TriggerPanorama(uint32_t hotplug_simulation);
+  void ShutdownPanorama(uint32_t hotplug_simulation);
+#endif
+
+  void SetPAVPSessionStatus(bool enabled, uint32_t pavp_session_id,
+                            uint32_t pavp_instance_id);
+  void SetHDCPSRMForAllDisplays(const int8_t *SRM, uint32_t SRMLength);
+
+  void SetHDCPSRMForDisplay(uint32_t connector, const int8_t *SRM,
+                            uint32_t SRMLength);
+  uint32_t GetDisplayIDFromConnectorID(const uint32_t connector_id);
+
+  bool EnableDRMCommit(bool enable, uint32_t display_id);
+
  public:
   class Hwc2Layer {
    public:
@@ -78,6 +106,10 @@ class IAHWC2 : public hwc2_device_t {
       x_translation_ = x_translation;
     }
 
+    void YTranslateCoordinates(uint32_t y_translation) {
+      y_translation_ = y_translation;
+    }
+
     void set_acquire_fence(int acquire_fence) {
       if (acquire_fence > 0)
         hwc_layer_.SetAcquireFence(acquire_fence);
@@ -116,19 +148,21 @@ class IAHWC2 : public hwc2_device_t {
     hwcomposer::HwcLayer hwc_layer_;
     struct gralloc_handle native_handle_;
     uint32_t x_translation_ = 0;
+    uint32_t y_translation_ = 0;
   };
 
   class HwcDisplay {
    public:
     HwcDisplay();
     HwcDisplay(const HwcDisplay &) = delete;
+    HwcDisplay &operator=(const HwcDisplay &) = delete;
+
     HWC2::Error Init(hwcomposer::NativeDisplay *display, int display_index,
                      bool disable_explicit_sync, uint32_t scaling_mode);
     HWC2::Error InitVirtualDisplay(hwcomposer::NativeDisplay *display,
                                    uint32_t width, uint32_t height,
+                                   uint32_t display_index,
                                    bool disable_explicit_sync);
-    HWC2::Error InitNestedDisplay(hwcomposer::NativeDisplay *display,
-                                  bool disable_explicit_sync);
 
     HWC2::Error RegisterVsyncCallback(hwc2_callback_data_t data,
                                       hwc2_function_pointer_t func);
@@ -183,19 +217,18 @@ class IAHWC2 : public hwc2_device_t {
     hwcomposer::NativeDisplay *GetDisplay();
 
    private:
-    hwcomposer::NativeDisplay *display_ = NULL;
+    hwcomposer::NativeDisplay *display_;
     hwc2_display_t handle_;
     HWC2::DisplayType type_;
     std::map<hwc2_layer_t, Hwc2Layer> layers_;
     Hwc2Layer client_layer_;
-    int32_t color_mode_;
 
-    uint32_t frame_no_ = 0;
+    uint32_t frame_no_;
     // True after validateDisplay
-    bool checkValidateDisplay = false;
-    bool disable_explicit_sync_ = false;
-    bool enable_nested_display_compose_ = false;
-    uint32_t scaling_mode_ = 0;
+    bool check_validate_display_;
+    bool disable_explicit_sync_;
+    bool enable_nested_display_compose_;
+    uint32_t scaling_mode_;
   };
 
   static IAHWC2 *toIAHWC2(hwc2_device_t *dev) {
@@ -223,16 +256,16 @@ class IAHWC2 : public hwc2_device_t {
       return static_cast<int32_t>((display.*func)(std::forward<Args>(args)...));
     }
 
-    if (display_handle == HWC_DISPLAY_VIRTUAL) {
-      return static_cast<int32_t>(
-          (hwc->virtual_display_.*func)(std::forward<Args>(args)...));
-    }
-#ifdef NESTED_DISPLAY_SUPPORT
-    if (display_handle == HWC_DISPLAY_NESTED) {
+    if (display_handle >= (HWC_DISPLAY_VIRTUAL + VDS_OFFSET)) {
+      HwcDisplay *display =
+          hwc->virtual_displays_
+              .at(display_handle - HWC_DISPLAY_VIRTUAL - VDS_OFFSET)
+              .get();
+
       return static_cast<int32_t>(
-          (hwc->nested_display_.*func)(std::forward<Args>(args)...));
+          (display->*func)(std::forward<Args>(args)...));
     }
-#endif
+
     if (display_handle == HWC_DISPLAY_EXTERNAL) {
       HwcDisplay *display = hwc->extended_displays_.at(0).get();
       return static_cast<int32_t>(
@@ -253,16 +286,15 @@ class IAHWC2 : public hwc2_device_t {
       return static_cast<int32_t>((layer.*func)(std::forward<Args>(args)...));
     }
 
-    if (display_handle == HWC_DISPLAY_VIRTUAL) {
-      Hwc2Layer &layer = hwc->virtual_display_.get_layer(layer_handle);
-      return static_cast<int32_t>((layer.*func)(std::forward<Args>(args)...));
-    }
-#ifdef NESTED_DISPLAY_SUPPORT
-    if (display_handle == HWC_DISPLAY_NESTED) {
-      Hwc2Layer &layer = hwc->nested_display_.get_layer(layer_handle);
+    if (display_handle >= (HWC_DISPLAY_VIRTUAL + VDS_OFFSET)) {
+      HwcDisplay *display =
+          hwc->virtual_displays_
+              .at(display_handle - HWC_DISPLAY_VIRTUAL - VDS_OFFSET)
+              .get();
+      Hwc2Layer &layer = display->get_layer(layer_handle);
       return static_cast<int32_t>((layer.*func)(std::forward<Args>(args)...));
     }
-#endif
+
     if (display_handle == HWC_DISPLAY_EXTERNAL) {
       HwcDisplay *display = hwc->extended_displays_.at(0).get();
       Hwc2Layer &layer = display->get_layer(layer_handle);
@@ -290,11 +322,11 @@ class IAHWC2 : public hwc2_device_t {
   HWC2::Error RegisterCallback(int32_t descriptor, hwc2_callback_data_t data,
                                hwc2_function_pointer_t function);
 
-  hwcomposer::GpuDevice device_;
+  hwcomposer::GpuDevice &device_ = GpuDevice::getInstance();
   std::vector<std::unique_ptr<HwcDisplay>> extended_displays_;
   HwcDisplay primary_display_;
-  HwcDisplay virtual_display_;
-  HwcDisplay nested_display_;
+  std::map<uint32_t, std::unique_ptr<HwcDisplay>> virtual_displays_;
+  uint32_t virtual_display_index_ = 0;
 
   bool disable_explicit_sync_ = false;
   android::HwcService hwcService_;