OSDN Git Service

HDCP: Add GetDisplayIDFromConnectorID
[android-x86/external-IA-Hardware-Composer.git] / public / gpudevice.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef PUBLIC_GPUDEVICE_H_
18 #define PUBLIC_GPUDEVICE_H_
19
20 #include <stdint.h>
21 #include <fstream>
22 #include <sstream>
23 #include <string>
24
25 #include "displaymanager.h"
26 #include "hwcthread.h"
27 #include "logicaldisplaymanager.h"
28 #include "nativedisplay.h"
29
30 namespace hwcomposer {
31
32 class NativeDisplay;
33
34 class GpuDevice : public HWCThread {
35  public:
36   GpuDevice();
37
38   virtual ~GpuDevice();
39
40   // Open device.
41   bool Initialize();
42
43   uint32_t GetFD() const;
44
45   NativeDisplay* GetDisplay(uint32_t display);
46
47   NativeDisplay* CreateVirtualDisplay(uint32_t display_index);
48   void DestroyVirtualDisplay(uint32_t display_index);
49
50   // This display can be a client preparing
51   // content which will eventually shown by
52   // another parent display.
53
54   void GetConnectedPhysicalDisplays(std::vector<NativeDisplay*>& displays);
55
56   const std::vector<NativeDisplay*>& GetAllDisplays();
57
58   void RegisterHotPlugEventCallback(
59       std::shared_ptr<DisplayHotPlugEventCallback> callback);
60
61   // Enables the usage of HDCP for all planes supporting this feature
62   // on display. Some displays can support latest HDCP specification and also
63   // have ability to fallback to older specifications i.e. HDCP 2.2 and 1.4
64   // in case latest speicification cannot be supported for some reason.
65   // Content type is defined by content_type.
66   void EnableHDCPSessionForDisplay(uint32_t display,
67                                    HWCContentType content_type);
68
69   // Enables the usage of HDCP for all planes supporting this feature
70   // on all connected displays. Some displays can support latest HDCP
71   // specification and also have ability to fallback to older
72   // specifications i.e. HDCP 2.2 and 1.4 in case latest speicification
73   // cannot be supported for some reason. Content type is defined by
74   // content_type.
75   void EnableHDCPSessionForAllDisplays(HWCContentType content_type);
76
77   // The control disables the usage of HDCP for all planes supporting this
78   // feature on display.
79   void DisableHDCPSessionForDisplay(uint32_t display);
80
81   // The control disables the usage of HDCP for all planes supporting this
82   // feature on all connected displays.
83   void DisableHDCPSessionForAllDisplays();
84
85   void SetPAVPSessionStatus(bool enabled, uint32_t pavp_session_id,
86                             uint32_t pavp_instance_id);
87   void SetHDCPSRMForAllDisplays(const int8_t* SRM, uint32_t SRMLength);
88   void SetHDCPSRMForDisplay(uint32_t display, const int8_t* SRM,
89                             uint32_t SRMLength);
90   uint32_t GetDisplayIDFromConnectorID(const uint32_t connector_id);
91
92  private:
93   enum InitializationType {
94     kUnInitialized = 0,    // Nothing Initialized.
95     kInitialized = 1 << 1  // Everything Initialized
96   };
97
98   void HandleHWCSettings();
99   void DisableWatch();
100   void HandleRoutine() override;
101   void HandleWait() override;
102   std::unique_ptr<DisplayManager> display_manager_;
103   std::vector<std::unique_ptr<LogicalDisplayManager>> logical_display_manager_;
104   std::vector<std::unique_ptr<NativeDisplay>> mosaic_displays_;
105   std::vector<NativeDisplay*> total_displays_;
106   uint32_t initialization_state_ = kUnInitialized;
107   SpinLock initialization_state_lock_;
108   int lock_fd_ = -1;
109   friend class DrmDisplayManager;
110 };
111
112 }  // namespace hwcomposer
113 #endif  // PUBLIC_GPUDEVICE_H_