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 IDISPLAY_DEVICE_H
17#define IDISPLAY_DEVICE_H
18
19#include <common/utils/Dump.h>
20#include <IDisplayContext.h>
21#include <DisplayPlane.h>
22
23namespace android {
24namespace intel {
25
26// display config
27class DisplayConfig {
28public:
29    DisplayConfig(int rr, int w, int h, int dpix, int dpiy)
30        : mRefreshRate(rr),
31          mWidth(w),
32          mHeight(h),
33          mDpiX(dpix),
34          mDpiY(dpiy)
35    {}
36public:
37    int getRefreshRate() const { return mRefreshRate; }
38    int getWidth() const { return mWidth; }
39    int getHeight() const { return mHeight; }
40    int getDpiX() const { return mDpiX; }
41    int getDpiY() const { return mDpiY; }
42private:
43    int mRefreshRate;
44    int mWidth;
45    int mHeight;
46    int mDpiX;
47    int mDpiY;
48};
49
50
51//  display device interface
52class IDisplayDevice {
53public:
54    // display device type
55    enum {
56        DEVICE_PRIMARY = HWC_DISPLAY_PRIMARY,
57        DEVICE_EXTERNAL = HWC_DISPLAY_EXTERNAL,
58        DEVICE_VIRTUAL = HWC_DISPLAY_VIRTUAL,
59        DEVICE_COUNT,
60    };
61    enum {
62        DEVICE_DISCONNECTED = 0,
63        DEVICE_CONNECTED,
64    };
65    enum {
66        DEVICE_DISPLAY_OFF = 0,
67        DEVICE_DISPLAY_ON,
68        DEVICE_DISPLAY_STANDBY,
69    };
70public:
71    IDisplayDevice() {}
72    virtual ~IDisplayDevice() {}
73public:
74    virtual bool prePrepare(hwc_display_contents_1_t *display) = 0;
75    virtual bool prepare(hwc_display_contents_1_t *display) = 0;
76    virtual bool commit(hwc_display_contents_1_t *display,
77                          IDisplayContext *context) = 0;
78
79    virtual bool vsyncControl(bool enabled) = 0;
80    virtual bool blank(bool blank) = 0;
81    virtual bool getDisplaySize(int *width, int *height) = 0;
82    virtual bool getDisplayConfigs(uint32_t *configs,
83                                       size_t *numConfigs) = 0;
84    virtual bool getDisplayAttributes(uint32_t config,
85                                          const uint32_t *attributes,
86                                          int32_t *values) = 0;
87    virtual bool compositionComplete() = 0;
88
89    virtual bool setPowerMode(int mode) = 0;
90    virtual int  getActiveConfig() = 0;
91    virtual bool setActiveConfig(int index) = 0;
92
93    virtual bool initialize() = 0;
94    virtual void deinitialize() = 0;
95    virtual bool isConnected() const = 0;
96    virtual const char* getName() const = 0;
97    virtual int getType() const = 0;
98    virtual void onVsync(int64_t timestamp) = 0;
99    virtual void dump(Dump& d) = 0;
100};
101
102}
103}
104
105#endif /* IDISPLAY_DEVICE_H */
106