OSDN Git Service

Add Render Buffer Compression support in HWComposer.
[android-x86/external-IA-Hardware-Composer.git] / os / linux / platformdefines.h
1 /*
2 // Copyright (c) 2016 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_PLATFORMDEFINES_H_
18 #define OS_LINUX_PLATFORMDEFINES_H_
19
20 #include <gbm.h>
21 #include <stddef.h>
22 #include <stdio.h>
23 #include <cmath>
24
25 #include <va/va_drm.h>
26
27 #include <cstring>
28 #include <algorithm>
29 #include <cstddef>
30
31 #include <libsync.h>
32
33 #include "platformcommondefines.h"
34
35 struct gbm_handle {
36 #ifdef USE_MINIGBM
37   struct gbm_import_fd_planar_data import_data;
38 #else
39   union {
40     // for GBM_BO_IMPORT_FD
41     struct gbm_import_fd_data fd_data;
42     // for GBM_BO_IMPORT_FD_MODIFIER
43     struct gbm_import_fd_modifier_data fd_modifier_data;
44   } import_data;
45 #endif
46   struct gbm_bo* bo = NULL;
47   struct gbm_bo* imported_bo = NULL;
48   uint32_t total_planes = 0;
49   HwcBuffer meta_data_;
50   bool hwc_buffer_ = false;
51   // In case this is true, we expect meta_data_
52   // to be filled with correct width, height and
53   // format.
54   void* pixel_memory_ = NULL;
55   uint32_t gbm_flags = 0;
56   uint32_t layer_type_ = hwcomposer::kLayerNormal;
57   uint64_t modifier = 0;
58 };
59
60 typedef struct gbm_handle* HWCNativeHandle;
61
62 #ifdef _cplusplus
63 extern "C" {
64 #endif
65
66 #define VTRACE(fmt, ...) fprintf(stderr, "%s: \n" fmt, __func__, ##__VA_ARGS__)
67 #define DTRACE(fmt, ...) fprintf(stderr, "%s: \n" fmt, __func__, ##__VA_ARGS__)
68 #define ITRACE(fmt, ...) fprintf(stderr, "\n" fmt, ##__VA_ARGS__)
69 #define WTRACE(fmt, ...) fprintf(stderr, "%s: \n" fmt, __func__, ##__VA_ARGS__)
70 #define ETRACE(fmt, ...) fprintf(stderr, "%s: \n" fmt, __func__, ##__VA_ARGS__)
71 #define STRACE() ((void)0)
72
73 #ifdef USE_MINIGBM
74 inline uint32_t GetNativeBuffer(uint32_t gpu_fd, HWCNativeHandle handle) {
75   uint32_t id = 0;
76   uint32_t prime_fd = handle->import_data.fds[0];
77   if (drmPrimeFDToHandle(gpu_fd, prime_fd, &id)) {
78     ETRACE("Error generate handle from prime fd %d", prime_fd);
79   }
80   return id;
81 }
82 #else
83 inline uint32_t GetNativeBuffer(uint32_t gpu_fd, HWCNativeHandle handle) {
84   uint32_t id = 0;
85   uint32_t prime_fd = handle->import_data.fd;
86   if (drmPrimeFDToHandle(gpu_fd, prime_fd, &id)) {
87     ETRACE("Error generate handle from prime fd %d", prime_fd);
88   }
89   return id;
90 }
91 #endif
92
93 // _cplusplus
94 #ifdef _cplusplus
95 }
96 #endif
97
98 #endif  // OS_LINUX_PLATFORMDEFINES_H_