1*0a9764feSAndroid Build Coastguard Worker /* 2*0a9764feSAndroid Build Coastguard Worker * Copyright (C) 2024 The Android Open Source Project 3*0a9764feSAndroid Build Coastguard Worker * 4*0a9764feSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*0a9764feSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*0a9764feSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*0a9764feSAndroid Build Coastguard Worker * 8*0a9764feSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*0a9764feSAndroid Build Coastguard Worker * 10*0a9764feSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*0a9764feSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*0a9764feSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*0a9764feSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*0a9764feSAndroid Build Coastguard Worker * limitations under the License. 15*0a9764feSAndroid Build Coastguard Worker */ 16*0a9764feSAndroid Build Coastguard Worker 17*0a9764feSAndroid Build Coastguard Worker #pragma once 18*0a9764feSAndroid Build Coastguard Worker 19*0a9764feSAndroid Build Coastguard Worker #include <memory> 20*0a9764feSAndroid Build Coastguard Worker 21*0a9764feSAndroid Build Coastguard Worker #include "aidl/android/hardware/graphics/composer3/IComposerClient.h" 22*0a9764feSAndroid Build Coastguard Worker #include "composer-resources/2.2/ComposerResources.h" 23*0a9764feSAndroid Build Coastguard Worker #include "cutils/native_handle.h" 24*0a9764feSAndroid Build Coastguard Worker #include "hwc3/Utils.h" 25*0a9764feSAndroid Build Coastguard Worker 26*0a9764feSAndroid Build Coastguard Worker namespace aidl::android::hardware::graphics::composer3::impl { 27*0a9764feSAndroid Build Coastguard Worker 28*0a9764feSAndroid Build Coastguard Worker class ComposerResourceReleaser { 29*0a9764feSAndroid Build Coastguard Worker public: ComposerResourceReleaser(bool is_buffer)30*0a9764feSAndroid Build Coastguard Worker explicit ComposerResourceReleaser(bool is_buffer) 31*0a9764feSAndroid Build Coastguard Worker : replaced_handle_(is_buffer) { 32*0a9764feSAndroid Build Coastguard Worker } 33*0a9764feSAndroid Build Coastguard Worker virtual ~ComposerResourceReleaser() = default; 34*0a9764feSAndroid Build Coastguard Worker 35*0a9764feSAndroid Build Coastguard Worker ::android::hardware::graphics::composer::V2_2::hal::ComposerResources:: 36*0a9764feSAndroid Build Coastguard Worker ReplacedHandle* GetReplacedHandle()37*0a9764feSAndroid Build Coastguard Worker GetReplacedHandle() { 38*0a9764feSAndroid Build Coastguard Worker return &replaced_handle_; 39*0a9764feSAndroid Build Coastguard Worker } 40*0a9764feSAndroid Build Coastguard Worker 41*0a9764feSAndroid Build Coastguard Worker private: 42*0a9764feSAndroid Build Coastguard Worker ::android::hardware::graphics::composer::V2_2::hal::ComposerResources:: 43*0a9764feSAndroid Build Coastguard Worker ReplacedHandle replaced_handle_; 44*0a9764feSAndroid Build Coastguard Worker }; 45*0a9764feSAndroid Build Coastguard Worker 46*0a9764feSAndroid Build Coastguard Worker class ComposerResources { 47*0a9764feSAndroid Build Coastguard Worker public: 48*0a9764feSAndroid Build Coastguard Worker static std::unique_ptr<ComposerResources> Create(); 49*0a9764feSAndroid Build Coastguard Worker ~ComposerResources() = default; 50*0a9764feSAndroid Build Coastguard Worker 51*0a9764feSAndroid Build Coastguard Worker hwc3::Error GetLayerBuffer(uint64_t display_id, int64_t layer_id, 52*0a9764feSAndroid Build Coastguard Worker const Buffer& buffer, 53*0a9764feSAndroid Build Coastguard Worker buffer_handle_t* out_buffer_handle, 54*0a9764feSAndroid Build Coastguard Worker ComposerResourceReleaser* releaser); 55*0a9764feSAndroid Build Coastguard Worker hwc3::Error GetLayerSidebandStream( 56*0a9764feSAndroid Build Coastguard Worker uint64_t display_id, int64_t layer_id, 57*0a9764feSAndroid Build Coastguard Worker const aidl::android::hardware::common::NativeHandle& handle, 58*0a9764feSAndroid Build Coastguard Worker buffer_handle_t* out_handle, ComposerResourceReleaser* releaser); 59*0a9764feSAndroid Build Coastguard Worker 60*0a9764feSAndroid Build Coastguard Worker hwc3::Error AddLayer(uint64_t display, int64_t layer, 61*0a9764feSAndroid Build Coastguard Worker uint32_t buffer_cache_size); 62*0a9764feSAndroid Build Coastguard Worker hwc3::Error RemoveLayer(uint64_t display, int64_t layer); 63*0a9764feSAndroid Build Coastguard Worker 64*0a9764feSAndroid Build Coastguard Worker bool HasDisplay(uint64_t display); 65*0a9764feSAndroid Build Coastguard Worker hwc3::Error AddPhysicalDisplay(uint64_t display); 66*0a9764feSAndroid Build Coastguard Worker hwc3::Error AddVirtualDisplay(uint64_t display, 67*0a9764feSAndroid Build Coastguard Worker uint32_t output_buffer_cache_size); 68*0a9764feSAndroid Build Coastguard Worker hwc3::Error RemoveDisplay(uint64_t display); 69*0a9764feSAndroid Build Coastguard Worker 70*0a9764feSAndroid Build Coastguard Worker void SetDisplayMustValidateState(uint64_t display_id, bool must_validate); 71*0a9764feSAndroid Build Coastguard Worker bool MustValidateDisplay(uint64_t display_id); 72*0a9764feSAndroid Build Coastguard Worker 73*0a9764feSAndroid Build Coastguard Worker hwc3::Error GetDisplayClientTarget(uint64_t display_id, const Buffer& buffer, 74*0a9764feSAndroid Build Coastguard Worker buffer_handle_t* out_handle, 75*0a9764feSAndroid Build Coastguard Worker ComposerResourceReleaser* releaser); 76*0a9764feSAndroid Build Coastguard Worker 77*0a9764feSAndroid Build Coastguard Worker hwc3::Error SetDisplayClientTargetCacheSize( 78*0a9764feSAndroid Build Coastguard Worker uint64_t display_id, uint32_t client_target_cache_size); 79*0a9764feSAndroid Build Coastguard Worker hwc3::Error GetDisplayClientTargetCacheSize(uint64_t display_id, 80*0a9764feSAndroid Build Coastguard Worker size_t* out_cache_size); 81*0a9764feSAndroid Build Coastguard Worker hwc3::Error GetDisplayOutputBufferCacheSize(uint64_t display, 82*0a9764feSAndroid Build Coastguard Worker size_t* out_cache_size); 83*0a9764feSAndroid Build Coastguard Worker hwc3::Error GetDisplayOutputBuffer(uint64_t display_id, const Buffer& buffer, 84*0a9764feSAndroid Build Coastguard Worker buffer_handle_t* out_handle, 85*0a9764feSAndroid Build Coastguard Worker ComposerResourceReleaser* releaser); 86*0a9764feSAndroid Build Coastguard Worker 87*0a9764feSAndroid Build Coastguard Worker static std::unique_ptr<ComposerResourceReleaser> CreateResourceReleaser( 88*0a9764feSAndroid Build Coastguard Worker bool is_buffer); 89*0a9764feSAndroid Build Coastguard Worker 90*0a9764feSAndroid Build Coastguard Worker private: 91*0a9764feSAndroid Build Coastguard Worker ComposerResources() = default; 92*0a9764feSAndroid Build Coastguard Worker 93*0a9764feSAndroid Build Coastguard Worker std::unique_ptr< 94*0a9764feSAndroid Build Coastguard Worker ::android::hardware::graphics::composer::V2_2::hal::ComposerResources> 95*0a9764feSAndroid Build Coastguard Worker resources_ = ::android::hardware::graphics::composer::V2_2::hal:: 96*0a9764feSAndroid Build Coastguard Worker ComposerResources::create(); 97*0a9764feSAndroid Build Coastguard Worker }; 98*0a9764feSAndroid Build Coastguard Worker 99*0a9764feSAndroid Build Coastguard Worker } // namespace aidl::android::hardware::graphics::composer3::impl