1 /*
2  * Copyright (C) 2019 The Android Open Source Project
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 _EXYNOSDEVICEDRMINTERFACE_H
18 #define _EXYNOSDEVICEDRMINTERFACE_H
19 
20 #include "resourcemanager.h"
21 #include "ExynosDeviceInterface.h"
22 
23 using namespace android;
24 
25 class ExynosDevice;
26 class ExynosDeviceDrmInterface : public ExynosDeviceInterface {
27     public:
28         ExynosDeviceDrmInterface(ExynosDevice *exynosDevice);
29         virtual ~ExynosDeviceDrmInterface();
30         virtual void init(ExynosDevice *exynosDevice) override;
31         virtual void postInit() override;
32         virtual int32_t initDisplayInterface(
33                 std::unique_ptr<ExynosDisplayInterface> &dispInterface) override;
34         virtual void updateRestrictions() override;
35         virtual int32_t registerSysfsEventHandler(
36                 std::shared_ptr<DrmSysfsEventHandler> handler) override;
37         virtual int32_t unregisterSysfsEventHandler(int sysfsFd) override;
38 
39     protected:
40         class ExynosDrmEventHandler : public DrmEventHandler,
41                                       public DrmHistogramEventHandler,
42                                       public DrmHistogramChannelEventHandler,
43                                       public DrmContextHistogramEventHandler,
44                                       public DrmTUIEventHandler,
45                                       public DrmPanelIdleEventHandler,
46                                       public DrmPropertyUpdateHandler {
47         public:
48             void handleEvent(uint64_t timestamp_us) override;
49             void handleHistogramEvent(uint32_t crtc_id, void *bin) override;
50             void handleHistogramChannelEvent(void *event) override;
51             void handleContextHistogramEvent(void* event) override;
52             void handleTUIEvent() override;
53             void handleIdleEnterEvent(char const *event) override;
54             void handleDrmPropertyUpdate(unsigned connector_id, unsigned prop_id) override;
55             void init(ExynosDevice *exynosDevice, DrmDevice *drmDevice);
56 
57         private:
58             ExynosDevice *mExynosDevice;
59             DrmDevice *mDrmDevice;
60         };
61         ResourceManager mDrmResourceManager;
62         DrmDevice *mDrmDevice;
63         std::shared_ptr<ExynosDrmEventHandler> mExynosDrmEventHandler;
64 };
65 
66 #endif //_EXYNOSDEVICEDRMINTERFACE_H
67