1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/*
* Copyright © 2012 Intel Corporation
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Jackie Li <yaodong.li@intel.com>
*
*/
#ifndef DISPLAY_ANALYZER_H
#define DISPLAY_ANALYZER_H
#include <utils/threads.h>
#include <utils/Vector.h>
namespace android {
namespace intel {
class DisplayAnalyzer {
public:
DisplayAnalyzer();
virtual ~DisplayAnalyzer();
public:
bool initialize();
void deinitialize();
void analyzeContents(size_t numDisplays, hwc_display_contents_1_t** displays);
bool isVideoExtModeActive();
bool isVideoExtModeEnabled();
bool isVideoLayer(hwc_layer_1_t &layer);
bool isVideoFullScreen(int device, hwc_layer_1_t &layer);
bool isOverlayAllowed();
int getVideoInstances();
void postHotplugEvent(bool connected);
void postVideoEvent(int instanceID, int state);
void postInputEvent(bool active);
void postVideoEvent(int instances, int instanceID, bool preparing, bool playing);
void postBlankEvent(bool blank);
void postIdleEntryEvent();
bool isPresentationLayer(hwc_layer_1_t &layer);
bool isProtectedLayer(hwc_layer_1_t &layer);
bool ignoreVideoSkipFlag();
int getFirstVideoInstanceSessionID();
private:
enum DisplayEventType {
HOTPLUG_EVENT,
BLANK_EVENT,
VIDEO_EVENT,
TIMING_EVENT,
INPUT_EVENT,
DPMS_EVENT,
IDLE_ENTRY_EVENT,
IDLE_EXIT_EVENT,
VIDEO_CHECK_EVENT,
};
struct Event {
int type;
struct VideoEvent {
int instanceID;
int state;
};
union {
bool bValue;
int nValue;
VideoEvent videoEvent;
};
};
inline void postEvent(Event& e);
inline bool getEvent(Event& e);
void handlePendingEvents();
void handleHotplugEvent(bool connected);
void handleBlankEvent(bool blank);
void handleVideoEvent(int instanceID, int state);
void handleTimingEvent();
void handleInputEvent(bool active);
void handleDpmsEvent(int delayCount);
void handleIdleEntryEvent(int count);
void handleIdleExitEvent();
void handleVideoCheckEvent();
void blankSecondaryDevice();
void handleVideoExtMode();
void checkVideoExtMode();
void enterVideoExtMode();
void exitVideoExtMode();
bool hasProtectedLayer();
inline void setCompositionType(hwc_display_contents_1_t *content, int type);
inline void setCompositionType(int device, int type, bool reset);
private:
// Video playback state, must match defintion in Multi Display Service
enum
{
VIDEO_PLAYBACK_IDLE,
VIDEO_PLAYBACK_STARTING,
VIDEO_PLAYBACK_STARTED,
VIDEO_PLAYBACK_STOPPING,
VIDEO_PLAYBACK_STOPPED,
};
enum
{
// number of idle flips before display can enter idle mode
// we can set maxfifo even with more than one plane is active,
// display controller will check whether condition is met to
// enter into maxfifo, so no need to delay.
DELAY_BEFORE_IDLE_ENTRY = 0,
// number of flips before display can be powered off in video extended mode
DELAY_BEFORE_DPMS_OFF = 0,
};
private:
bool mInitialized;
bool mVideoExtModeEnabled;
bool mVideoExtModeEligible;
bool mVideoExtModeActive;
bool mBlankDevice;
bool mOverlayAllowed;
bool mActiveInputState;
// workaround HWC_SKIP_LAYER set during rotation for extended video mode
// by default if layer has HWC_SKIP_LAYER flag it should not be processed by HWC
bool mIgnoreVideoSkipFlag;
bool mProtectedVideoSession;
// map video instance ID to video state
KeyedVector<int, int> mVideoStateMap;
int mCachedNumDisplays;
hwc_display_contents_1_t** mCachedDisplays;
Vector<Event> mPendingEvents;
Mutex mEventMutex;
Condition mEventHandledCondition;
};
} // namespace intel
} // namespace android
#endif /* DISPLAY_ANALYZER_H */
|