1 /* 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 20 namespace android { 21 namespace automotive { 22 namespace evs { 23 namespace V1_0 { 24 namespace implementation { 25 HalDisplay(sp<IEvsDisplay> & display)26HalDisplay::HalDisplay(sp<IEvsDisplay>& display) : 27 mHwDisplay(display) { 28 // nothing to do. 29 } 30 ~HalDisplay()31HalDisplay::~HalDisplay() { 32 shutdown(); 33 } 34 shutdown()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 */ getHwDisplay()43sp<IEvsDisplay> HalDisplay::getHwDisplay() { 44 return mHwDisplay; 45 } 46 47 /** 48 * Gets basic display information from a hardware display object 49 * and returns. 50 */ getDisplayInfo(getDisplayInfo_cb _hidl_cb)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 */ setDisplayState(DisplayState state)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 */ getDisplayState()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 */ getTargetBuffer(getTargetBuffer_cb _hidl_cb)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 */ returnTargetBufferForDisplay(const BufferDesc & buffer)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 108