PhysicalDevice.h revision 3540d325335005c6761c3557679201ae29f7c1d0
1/*
2// Copyright (c) 2014 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#ifndef PHYSICAL_DEVICE_H
17#define PHYSICAL_DEVICE_H
18
19#include <DisplayPlane.h>
20#include <IVsyncControl.h>
21#include <IBlankControl.h>
22#include <common/observers/VsyncEventObserver.h>
23#include <common/base/HwcLayerList.h>
24#include <common/base/Drm.h>
25#include <IDisplayDevice.h>
26
27namespace android {
28namespace intel {
29
30class Hwcomposer;
31
32// Base class for primary and external devices
33class PhysicalDevice : public IDisplayDevice {
34public:
35    PhysicalDevice(uint32_t disp, uint32_t type, Hwcomposer& hwc, DisplayPlaneManager& dpm);
36    virtual ~PhysicalDevice();
37public:
38    virtual bool prePrepare(hwc_display_contents_1_t *display);
39    virtual bool prepare(hwc_display_contents_1_t *display);
40    virtual bool commit(hwc_display_contents_1_t *display, IDisplayContext *context);
41
42    virtual bool vsyncControl(bool enabled);
43    virtual bool blank(bool blank);
44    virtual bool getDisplaySize(int *width, int *height);
45    virtual bool getDisplayConfigs(uint32_t *configs,
46                                       size_t *numConfigs);
47    virtual bool getDisplayAttributes(uint32_t config,
48                                          const uint32_t *attributes,
49                                          int32_t *values);
50    virtual bool compositionComplete();
51
52    virtual bool setPowerMode(int mode);
53    virtual int  getActiveConfig();
54    virtual bool setActiveConfig(int index);
55
56    // display config operations
57    virtual void removeDisplayConfigs();
58    virtual bool detectDisplayConfigs();
59
60    // device related operations
61    virtual bool initCheck() const { return mInitialized; }
62    virtual bool initialize();
63    virtual void deinitialize();
64    virtual bool isConnected() const;
65    virtual const char* getName() const;
66    virtual int getType() const;
67
68    //events
69    virtual void onVsync(int64_t timestamp);
70
71    virtual void dump(Dump& d);
72
73protected:
74    void onGeometryChanged(hwc_display_contents_1_t *list);
75    bool updateDisplayConfigs();
76    virtual IVsyncControl* createVsyncControl() = 0;
77    virtual IBlankControl* createBlankControl() = 0;
78    friend class VsyncEventObserver;
79
80protected:
81    uint32_t mDisp;
82    uint32_t mType;
83    const char *mName;
84
85    Hwcomposer& mHwc;
86    DisplayPlaneManager& mDisplayPlaneManager;
87
88    // display configs
89    Vector<DisplayConfig*> mDisplayConfigs;
90    int mActiveDisplayConfig;
91
92
93    IBlankControl *mBlankControl;
94    VsyncEventObserver *mVsyncObserver;
95
96    // layer list
97    HwcLayerList *mLayerList;
98    bool mConnected;
99    bool mBlank;
100
101    // lock
102    Mutex mLock;
103
104    // DPMS on (1) or off (0)
105    int mDisplayState;
106    bool mInitialized;
107};
108
109}
110}
111
112#endif /* PHYSICAL_DEVICE_H */
113