Home | History | Annotate | Download | only in 2.0
      1 /*
      2  * Copyright 2018 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 #pragma once
     18 
     19 #include <android-base/unique_fd.h>
     20 #include <android/hardware/graphics/mapper/2.0/IMapper.h>
     21 
     22 namespace android {
     23 namespace hardware {
     24 namespace graphics {
     25 namespace mapper {
     26 namespace V2_0 {
     27 namespace hal {
     28 
     29 class MapperHal {
     30    public:
     31     virtual ~MapperHal() = default;
     32 
     33     // create a BufferDescriptor
     34     virtual Error createDescriptor(const IMapper::BufferDescriptorInfo& descriptorInfo,
     35                                    BufferDescriptor* outDescriptor) = 0;
     36 
     37     // import a raw handle owned by the caller
     38     virtual Error importBuffer(const native_handle_t* rawHandle,
     39                                native_handle_t** outBufferHandle) = 0;
     40 
     41     // free an imported buffer handle
     42     virtual Error freeBuffer(native_handle_t* bufferHandle) = 0;
     43 
     44     // lock a buffer
     45     virtual Error lock(const native_handle_t* bufferHandle, uint64_t cpuUsage,
     46                        const IMapper::Rect& accessRegion, base::unique_fd fenceFd,
     47                        void** outData) = 0;
     48 
     49     // lock a YCbCr buffer
     50     virtual Error lockYCbCr(const native_handle_t* bufferHandle, uint64_t cpuUsage,
     51                             const IMapper::Rect& accessRegion, base::unique_fd fenceFd,
     52                             YCbCrLayout* outLayout) = 0;
     53 
     54     // unlock a buffer
     55     virtual Error unlock(const native_handle_t* bufferHandle, base::unique_fd* outFenceFd) = 0;
     56 };
     57 
     58 }  // namespace hal
     59 }  // namespace V2_0
     60 }  // namespace mapper
     61 }  // namespace graphics
     62 }  // namespace hardware
     63 }  // namespace android
     64