blob: c3f72b25115a5a2e37e3745a5fc28a438d3c4562 [file] [log] [blame]
Changyeon Jocd5e3fb2019-03-22 15:12:22 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
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
17#include <log/log.h>
18#include "HalDisplay.h"
19
20namespace android {
21namespace automotive {
22namespace evs {
23namespace V1_0 {
24namespace implementation {
25
26HalDisplay::HalDisplay(sp<IEvsDisplay>& display) :
27 mHwDisplay(display) {
28 // nothing to do.
29}
30
31HalDisplay::~HalDisplay() {
32 shutdown();
33}
34
35void HalDisplay::shutdown() {
36 // simply release a strong pointer to remote display object.
37 mHwDisplay = nullptr;
38}
39
40/**
41 * Returns a strong pointer to remote display object.
42 */
43sp<IEvsDisplay> HalDisplay::getHwDisplay() {
44 return mHwDisplay;
45}
46
47/**
48 * Gets basic display information from a hardware display object
49 * and returns.
50 */
51Return<void> HalDisplay::getDisplayInfo(getDisplayInfo_cb _hidl_cb) {
52 if (mHwDisplay) {
53 mHwDisplay->getDisplayInfo(_hidl_cb);
54 }
55
56 return Void();
57}
58
59/**
60 * Sets the display state as what the clients wants.
61 */
62Return<EvsResult> HalDisplay::setDisplayState(DisplayState state) {
63 if (mHwDisplay) {
64 return mHwDisplay->setDisplayState(state);
65 } else {
66 return EvsResult::UNDERLYING_SERVICE_ERROR;
67 }
68}
69
70/**
71 * Gets current display state from a hardware display object and return.
72 */
73Return<DisplayState> HalDisplay::getDisplayState() {
74 if (mHwDisplay) {
75 return mHwDisplay->getDisplayState();
76 } else {
77 return DisplayState::DEAD;
78 }
79}
80
81/**
82 * Returns a handle to a frame buffer associated with the display.
83 */
84Return<void> HalDisplay::getTargetBuffer(getTargetBuffer_cb _hidl_cb) {
85 if (mHwDisplay) {
86 mHwDisplay->getTargetBuffer(_hidl_cb);
87 }
88
89 return Void();
90}
91
92/**
93 * Notifies the display that the buffer is ready to be used.
94 */
95Return<EvsResult> HalDisplay::returnTargetBufferForDisplay(const BufferDesc& buffer) {
96 if (mHwDisplay) {
97 return mHwDisplay->returnTargetBufferForDisplay(buffer);
98 } else {
99 return EvsResult::OWNERSHIP_LOST;
100 }
101}
102
103} // namespace implementation
104} // namespace V1_0
105} // namespace evs
106} // namespace automotive
107} // namespace android