1 /* 2 * Copyright (C) 2016 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 #ifndef ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_1_EVSDISPLAY_H 18 #define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_1_EVSDISPLAY_H 19 20 #include "GlWrapper.h" 21 22 #include <android/frameworks/automotive/display/1.0/IAutomotiveDisplayProxyService.h> 23 #include <android/hardware/automotive/evs/1.1/IEvsDisplay.h> 24 #include <ui/GraphicBuffer.h> 25 26 namespace android::hardware::automotive::evs::V1_1::implementation { 27 28 class EvsDisplay : public IEvsDisplay { 29 public: 30 // Methods from ::android::hardware::automotive::evs::V1_0::IEvsDisplay follow. 31 Return<void> getDisplayInfo(getDisplayInfo_cb _hidl_cb) override; 32 Return<V1_0::EvsResult> setDisplayState(V1_0::DisplayState state) override; 33 Return<V1_0::DisplayState> getDisplayState() override; 34 Return<void> getTargetBuffer(getTargetBuffer_cb _hidl_cb) override; 35 Return<V1_0::EvsResult> returnTargetBufferForDisplay(const V1_0::BufferDesc& buffer) override; 36 37 // Methods from ::android::hardware::automotive::evs::V1_1::IEvsDisplay follow. 38 Return<void> getDisplayInfo_1_1(getDisplayInfo_1_1_cb _info_cb) override; 39 40 // Implementation details 41 EvsDisplay(); 42 EvsDisplay( 43 sp<frameworks::automotive::display::V1_0::IAutomotiveDisplayProxyService> pDisplayProxy, 44 uint64_t displayId); 45 virtual ~EvsDisplay() override; 46 47 void forceShutdown(); // This gets called if another caller "steals" ownership of the display 48 Return<V1_0::EvsResult> returnTargetBufferForDisplayImpl(const uint32_t bufferId, 49 const buffer_handle_t memHandle); 50 51 private: 52 V1_0::DisplayDesc mInfo = {}; 53 V1_0::BufferDesc mBuffer = {}; // A graphics buffer into which we'll store images 54 V1_0::DisplayState mRequestedState = V1_0::DisplayState::NOT_VISIBLE; 55 bool mFrameBusy = false; // A flag telling us our buffer is in use 56 std::mutex mAccessLock; 57 sp<frameworks::automotive::display::V1_0::IAutomotiveDisplayProxyService> mDisplayProxy; 58 uint64_t mDisplayId; 59 std::unique_ptr<GlWrapper> mGlWrapper; 60 }; 61 62 } // namespace android::hardware::automotive::evs::V1_1::implementation 63 64 #endif // ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_1_EVSDISPLAY_H 65