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
|
/*
* 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 __MULTIDISPLAY_OBSERVER_H
#define __MULTIDISPLAY_OBSERVER_H
#ifdef TARGET_HAS_MULTIPLE_DISPLAY
#include <display/MultiDisplayService.h>
#include <SimpleThread.h>
#else
#include <utils/Errors.h>
#endif
namespace android {
namespace intel {
struct VideoSourceInfo {
int width;
int height;
int frameRate;
};
#ifdef TARGET_HAS_MULTIPLE_DISPLAY
class MultiDisplayObserver;
class MultiDisplayCallback : public BnMultiDisplayCallback {
public:
MultiDisplayCallback(MultiDisplayObserver *observer);
virtual ~MultiDisplayCallback();
status_t blankSecondaryDisplay(bool blank);
status_t updateVideoState(int sessionId, MDS_VIDEO_STATE state);
status_t setHdmiTiming(const MDSHdmiTiming& timing);
status_t setHdmiScalingType(MDS_SCALING_TYPE type);
status_t setHdmiOverscan(int hValue, int vValue);
status_t updateInputState(bool state);
private:
MultiDisplayObserver *mDispObserver;
MDS_VIDEO_STATE mVideoState;
};
class MultiDisplayObserver {
public:
MultiDisplayObserver();
virtual ~MultiDisplayObserver();
public:
bool initialize();
void deinitialize();
status_t notifyHotPlug(bool connected);
status_t getVideoSourceInfo(int sessionID, VideoSourceInfo* info);
int getVideoSessionNumber();
bool isExternalDeviceTimingFixed() const;
status_t notifyWidiConnectionStatus(bool connected);
private:
bool isMDSRunning();
bool initMDSClient();
bool initMDSClientAsync();
void deinitMDSClient();
status_t blankSecondaryDisplay(bool blank);
status_t updateVideoState(int sessionId, MDS_VIDEO_STATE state);
status_t setHdmiTiming(const MDSHdmiTiming& timing);
status_t updateInputState(bool active);
friend class MultiDisplayCallback;
private:
enum {
THREAD_LOOP_DELAY = 10, // 10 ms
THREAD_LOOP_BOUND = 2000, // 20s
};
private:
sp<IMultiDisplayCallbackRegistrar> mMDSCbRegistrar;
sp<IMultiDisplayInfoProvider> mMDSInfoProvider;
sp<IMultiDisplayConnectionObserver> mMDSConnObserver;
sp<MultiDisplayCallback> mMDSCallback;
mutable Mutex mLock;
Condition mCondition;
int mThreadLoopCount;
bool mDeviceConnected;
// indicate external devices's timing is set
bool mExternalHdmiTiming;
bool mInitialized;
private:
DECLARE_THREAD(MDSClientInitThread, MultiDisplayObserver);
};
#else
// dummy declaration and implementation of MultiDisplayObserver
class MultiDisplayObserver {
public:
MultiDisplayObserver() {}
virtual ~MultiDisplayObserver() {}
bool initialize() { return true; }
void deinitialize() {}
status_t notifyHotPlug(bool connected) { return NO_ERROR; }
status_t getVideoSourceInfo(int sessionID, VideoSourceInfo* info) { return INVALID_OPERATION; }
int getVideoSessionNumber() { return 0; }
bool isExternalDeviceTimingFixed() const { return false; }
status_t notifyWidiConnectionStatus(bool connected) { return NO_ERROR; }
};
#endif //TARGET_HAS_MULTIPLE_DISPLAY
} // namespace intel
} // namespace android
#endif /* __MULTIMultiDisplayObserver_H_ */
|