OSDN Git Service

Add full color range support
[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 <algorithm>
28 #include <cstddef>
29 #include <cstring>
30
31 #include <libsync.h>
32
33 #include "platformcommondefines.h"
34
35 #define HAL_DATASPACE_RANGE_FULL 0x8000000
36
37 struct gbm_handle {
38   union {
39     // for GBM_BO_IMPORT_FD
40     struct gbm_import_fd_data fd_data;
41     // for GBM_BO_IMPORT_FD_MODIFIER
42     struct gbm_import_fd_modifier_data fd_modifier_data;
43   } import_data;
44   struct gbm_bo* bo = NULL;
45   struct gbm_bo* imported_bo = NULL;
46   HwcMeta meta_data_;
47   bool hwc_buffer_ = false;
48   void* pixel_memory_ = NULL;
49   uint32_t gbm_flags = 0;
50   uint32_t layer_type_ = hwcomposer::kLayerNormal;
51 };
52
53 typedef struct gbm_handle* HWCNativeHandle;
54
55 #ifdef _cplusplus
56 extern "C" {
57 #endif
58
59 #define VTRACE(fmt, ...) fprintf(stderr, "%s: \n" fmt, __func__, ##__VA_ARGS__)
60 #define DTRACE(fmt, ...) fprintf(stderr, "%s: \n" fmt, __func__, ##__VA_ARGS__)
61 #define ITRACE(fmt, ...) fprintf(stderr, "\n" fmt, ##__VA_ARGS__)
62 #define WTRACE(fmt, ...) fprintf(stderr, "%s: \n" fmt, __func__, ##__VA_ARGS__)
63 #define ETRACE(fmt, ...) fprintf(stderr, "%s: \n" fmt, __func__, ##__VA_ARGS__)
64 #define STRACE() ((void)0)
65
66 inline uint32_t GetNativeBuffer(uint32_t gpu_fd, HWCNativeHandle handle) {
67   uint32_t id = 0;
68   uint32_t prime_fd = -1;
69   if (!handle->meta_data_.fb_modifiers_[0]) {
70     prime_fd = handle->import_data.fd_data.fd;
71   } else {
72     prime_fd = handle->import_data.fd_modifier_data.fds[0];
73   }
74   if (drmPrimeFDToHandle(gpu_fd, prime_fd, &id)) {
75     ETRACE("Error generate handle from prime fd %d", prime_fd);
76   }
77   return id;
78 }
79
80 // _cplusplus
81 #ifdef _cplusplus
82 }
83 #endif
84
85 #endif  // OS_LINUX_PLATFORMDEFINES_H_