summaryrefslogtreecommitdiff
path: root/hwc2/common/devices/PrimaryDevice.cpp (plain)
blob: eca89578ea5333345ac8f064e07d0ab4ce0baab8
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
24namespace android {
25namespace amlogic {
26
27PrimaryDevice::PrimaryDevice(Hwcomposer& hwc, DeviceControlFactory* controlFactory)
28 : PhysicalDevice(DEVICE_PRIMARY, hwc, controlFactory)
29{
30 CTRACE();
31}
32
33PrimaryDevice::~PrimaryDevice()
34{
35 CTRACE();
36}
37
38bool 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
57void PrimaryDevice::deinitialize()
58{
59 PhysicalDevice::deinitialize();
60}
61
62void PrimaryDevice::hotplugEventListener(void *data, bool status)
63{
64 PrimaryDevice *pThis = (PrimaryDevice*)data;
65 if (pThis) {
66 pThis->hotplugListener(status);
67 }
68}
69
70void PrimaryDevice::hotplugListener(bool connected)
71{
72 CTRACE();
73
74 ETRACE("hotpug event: %d", connected);
75
76 updateHotplugState(connected);
77 // update display configs
78 if (connected) {
79 if (!updateDisplayConfigs()) {
80 ETRACE("failed to update display config");
81 return;
82 }
83
84 if (getDisplayId() == HWC_DISPLAY_EXTERNAL) {
85 getDevice().hotplug(getDisplayId(), connected);
86 }
87 }
88}
89
90} // namespace amlogic
91} // namespace android
92