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 #ifndef HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_BUFFER_ALLOCATOR_HWL_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_BUFFER_ALLOCATOR_HWL_H_
19 
20 #include <utils/Errors.h>
21 
22 #include "hwl_types.h"
23 
24 namespace android {
25 namespace google_camera_hal {
26 
27 // HAL internal stream ids start from (1 << 16).
28 constexpr int32_t kHalInternalStreamStart = (1 << 16);
29 
30 // HWL internal stream ids start from (1 << 24). This is reserved for HWL
31 // for vendor-specific usages.
32 constexpr int32_t kImplementationDefinedInternalStreamStart = (1 << 24);
33 
34 // CameraBufferAllocatorHwl provides methods to register, allocate and
35 // free buffers
36 class CameraBufferAllocatorHwl {
37  public:
38   virtual ~CameraBufferAllocatorHwl() = default;
39 
40   // Allocate HWL buffers
41   virtual status_t AllocateBuffers(const HalBufferDescriptor& buffer_descriptor,
42                                    std::vector<buffer_handle_t>* buffers) = 0;
43 
44   // Free HWL buffers
45   virtual status_t FreeBuffers(std::vector<buffer_handle_t>* buffers) = 0;
46 
47   // Check if buffer is allocated by HWL allocator
48   virtual bool IsHwlAllocatedBuffer(buffer_handle_t buffer) = 0;
49 };
50 
51 }  // namespace google_camera_hal
52 }  // namespace android
53 
54 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_HWL_INTERFACE_CAMERA_BUFFER_ALLOCATOR_HWL_H_
55