1 /*
2  * Copyright 2017 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_GRALLOCUSAGE_GRALLOC_USAGE_CONVERSION_H
18 #define ANDROID_GRALLOCUSAGE_GRALLOC_USAGE_CONVERSION_H 1
19 
20 #include <stdint.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 // Conversion functions are out-of-line so that users don't have to be exposed to
27 // android/hardware/graphics/allocator/2.0/types.h and link against
28 // android.hardware.graphics.allocator@2.0 to get that in their search path.
29 
30 // Convert a 32-bit gralloc0 usage mask to a producer/consumer pair of 64-bit usage masks as used
31 // by android.hardware.graphics.allocator@2.0 (and gralloc1). This conversion properly handles the
32 // mismatch between a.h.g.allocator@2.0's CPU_{READ,WRITE}_OFTEN and gralloc0's
33 // SW_{READ,WRITE}_OFTEN.
34 void android_convertGralloc0To1Usage(int32_t usage, uint64_t* producerUsage,
35                                      uint64_t* consumerUsage);
36 
37 // Convert a producer/consumer pair of 64-bit usage masks as used by
38 // android.hardware.graphics.allocator@2.0 (and gralloc1) to a 32-bit gralloc0 usage mask. This
39 // conversion properly handles the mismatch between a.h.g.allocator@2.0's CPU_{READ,WRITE}_OFTEN
40 // and gralloc0's SW_{READ,WRITE}_OFTEN.
41 int32_t android_convertGralloc1To0Usage(uint64_t producerUsage, uint64_t consumerUsage);
42 
43 #ifdef __cplusplus
44 }
45 #endif
46 
47 #endif  // ANDROID_GRALLOCUSAGE_GRALLOC_USAGE_CONVERSION_H
48