Drew Davenport | ade6965 | 2024-07-16 15:54:33 -0600 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2024 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 "DrmHwcThree.h" |
| 18 | |
| 19 | #include <cinttypes> |
| 20 | |
| 21 | namespace aidl::android::hardware::graphics::composer3::impl { |
| 22 | |
| 23 | void DrmHwcThree::Init(std::shared_ptr<IComposerCallback> callback) { |
| 24 | composer_callback_ = std::move(callback); |
| 25 | GetResMan().Init(); |
| 26 | } |
| 27 | |
| 28 | void DrmHwcThree::SendVsyncPeriodTimingChangedEventToClient( |
| 29 | uint64_t display_id, int64_t timestamp) const { |
| 30 | VsyncPeriodChangeTimeline timeline; |
| 31 | timeline.newVsyncAppliedTimeNanos = timestamp; |
| 32 | timeline.refreshRequired = false; |
| 33 | timeline.refreshTimeNanos = 0; |
| 34 | |
| 35 | composer_callback_->onVsyncPeriodTimingChanged(static_cast<int64_t>( |
| 36 | display_id), |
| 37 | timeline); |
| 38 | } |
| 39 | |
| 40 | void DrmHwcThree::SendRefreshEventToClient(uint64_t display_id) { |
| 41 | composer_callback_->onRefresh(static_cast<int64_t>(display_id)); |
| 42 | } |
| 43 | |
| 44 | void DrmHwcThree::SendVsyncEventToClient(uint64_t display_id, int64_t timestamp, |
| 45 | uint32_t vsync_period) const { |
| 46 | composer_callback_->onVsync(static_cast<int64_t>(display_id), timestamp, |
| 47 | static_cast<int32_t>(vsync_period)); |
| 48 | } |
| 49 | |
| 50 | void DrmHwcThree::SendHotplugEventToClient(hwc2_display_t display_id, |
| 51 | bool connected) { |
| 52 | composer_callback_->onHotplug(static_cast<int64_t>(display_id), connected); |
| 53 | } |
| 54 | |
| 55 | } // namespace aidl::android::hardware::graphics::composer3::impl |