OSDN Git Service

Track GemHandles and FB separately.
[android-x86/external-IA-Hardware-Composer.git] / os / platformcommondefines.h
1 /*
2 // Copyright (c) 2017 Intel Corporation
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 OS_LINUX_PLATFORMCOMMONDEFINES_H_
18 #define OS_LINUX_PLATFORMCOMMONDEFINES_H_
19
20 #ifdef USE_VK
21 #include <vulkan/vulkan.h>
22
23 VkFormat NativeToVkFormat(int native_format);
24 #endif
25
26 #include <hwcbuffer.h>
27
28 #include <xf86drm.h>
29 #include <xf86drmMode.h>
30
31 #define DRM_FORMAT_NONE fourcc_code('0', '0', '0', '0')
32
33 #define DRM_FORMAT_NV12_Y_TILED_INTEL fourcc_code('9', '9', '9', '6')
34 // minigbm specific DRM_FORMAT_YVU420_ANDROID enum
35 #define DRM_FORMAT_YVU420_ANDROID fourcc_code('9', '9', '9', '7')
36
37 #define HWC_UNUSED(x) ((void)&(x))
38
39 inline void hash_combine_hwc(size_t& seed, size_t value) {
40   seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2);
41 }
42
43 typedef struct FBKey {
44   uint32_t gem_handles_[4];
45   uint32_t num_planes_;
46
47   FBKey(const uint32_t &num_planes, const uint32_t (&igem_handles)[4]) {
48     for (uint32_t i = 0; i < 4; i++) {
49       gem_handles_[i] = igem_handles[i];
50     }
51     num_planes_ = num_planes;
52   }
53 } FBKey;
54
55 int CreateFrameBuffer(const uint32_t &iwidth, const uint32_t &iheight,
56                       const uint32_t &iframe_buffer_format,
57                       const uint32_t (&igem_handles)[4],
58                       const uint32_t (&ipitches)[4],
59                       const uint32_t (&ioffsets)[4], uint32_t gpu_fd,
60                       uint32_t *fb_id);
61
62 int ReleaseFrameBuffer(const FBKey &key, uint32_t fd, uint32_t gpu_fd);
63
64 #endif  // OS_LINUX_PLATFORMCOMMONDEFINES_H_