blob: c6a82e25370a8b94235d1058a60423fcec53989f
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 | // This file is modified by Amlogic, Inc. 2017.01.17. |
17 | */ |
18 | |
19 | #include <HwcTrace.h> |
20 | #include <Hwcomposer.h> |
21 | #include <PrimaryDevice.h> |
22 | #include <Utils.h> |
23 | |
24 | namespace android { |
25 | namespace amlogic { |
26 | |
27 | PrimaryDevice::PrimaryDevice(Hwcomposer& hwc, IComposeDeviceFactory * controlFactory) |
28 | : PhysicalDevice(DEVICE_PRIMARY, hwc, controlFactory) |
29 | { |
30 | CTRACE(); |
31 | } |
32 | |
33 | PrimaryDevice::~PrimaryDevice() |
34 | { |
35 | CTRACE(); |
36 | } |
37 | |
38 | bool PrimaryDevice::initialize() |
39 | { |
40 | if (!PhysicalDevice::initialize()) { |
41 | DEINIT_AND_RETURN_FALSE("failed to initialize physical device"); |
42 | } |
43 | |
44 | UeventObserver *observer = Hwcomposer::getInstance().getUeventObserver(); |
45 | if (observer) { |
46 | observer->registerListener( |
47 | Utils::getHotplugUeventEnvelope(), |
48 | hotplugEventListener, |
49 | this); |
50 | } else { |
51 | ETRACE("Uevent observer is NULL"); |
52 | } |
53 | |
54 | return true; |
55 | } |
56 | |
57 | void PrimaryDevice::deinitialize() |
58 | { |
59 | PhysicalDevice::deinitialize(); |
60 | } |
61 | |
62 | void PrimaryDevice::hotplugEventListener(void *data, bool status) |
63 | { |
64 | PrimaryDevice *pThis = (PrimaryDevice*)data; |
65 | if (pThis) { |
66 | pThis->hotplugListener(status); |
67 | } |
68 | } |
69 | |
70 | void PrimaryDevice::hotplugListener(bool connected) |
71 | { |
72 | CTRACE(); |
73 | ETRACE("hotpug event: %d", connected); |
74 | |
75 | updateHotplugState(connected); |
76 | |
77 | // update display configs |
78 | onHotplug(getDisplayId(), connected); |
79 | } |
80 | |
81 | } // namespace amlogic |
82 | } // namespace android |
83 |