hwc: implement dump() with last configuration accepted by fb driver
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos5.git] / include / gralloc_priv.h
CommitLineData
6198e543 1/*
6198e543
DZ
2 * Copyright (C) 2008 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 GRALLOC_PRIV_H_
18#define GRALLOC_PRIV_H_
19
20#include <stdint.h>
a8b0b07d
RSZ
21#include <limits.h>
22#include <sys/cdefs.h>
23#include <hardware/gralloc.h>
6198e543
DZ
24#include <pthread.h>
25#include <errno.h>
a8b0b07d 26#include <unistd.h>
6198e543 27
6198e543
DZ
28#include <cutils/native_handle.h>
29
a8b0b07d 30#include <linux/fb.h>
6198e543 31
a8b0b07d 32/*****************************************************************************/
6198e543 33
a8b0b07d 34struct private_module_t;
6198e543
DZ
35struct private_handle_t;
36
a8b0b07d 37struct private_module_t {
6198e543
DZ
38 gralloc_module_t base;
39
a8b0b07d
RSZ
40 private_handle_t* framebuffer;
41 uint32_t flags;
42 uint32_t numBuffers;
43 uint32_t bufferMask;
6198e543 44 pthread_mutex_t lock;
a8b0b07d
RSZ
45 buffer_handle_t currentBuffer;
46 int ionfd;
6198e543 47
d37bc2b2
GH
48 int xres;
49 int yres;
50 int line_length;
6198e543
DZ
51 float xdpi;
52 float ydpi;
53 float fps;
dd557381
GH
54 void *queue;
55 pthread_mutex_t queue_lock;
6198e543 56
6198e543
DZ
57};
58
a8b0b07d
RSZ
59/*****************************************************************************/
60
6198e543 61#ifdef __cplusplus
a8b0b07d 62struct private_handle_t : public native_handle {
6198e543 63#else
a8b0b07d 64struct private_handle_t {
6198e543
DZ
65 struct native_handle nativeHandle;
66#endif
67
68 enum {
69 PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
70 PRIV_FLAGS_USES_UMP = 0x00000002,
80b3e6c2 71 PRIV_FLAGS_USES_ION = 0x00000020
6198e543
DZ
72 };
73
a8b0b07d 74 // file-descriptors
6198e543 75 int fd;
a8b0b07d
RSZ
76 int fd1;
77 int fd2;
78 // ints
6198e543
DZ
79 int magic;
80 int flags;
81 int size;
6198e543 82 int offset;
6198e543
DZ
83
84 int format;
6198e543
DZ
85 int width;
86 int height;
6198e543 87 int stride;
70212e56 88 int vstride;
6198e543 89
a8b0b07d
RSZ
90 // FIXME: the attributes below should be out-of-line
91 void *base;
6198e543
DZ
92
93#ifdef __cplusplus
471812b7 94 static const int sNumFds = 3;
70212e56 95 static const int sNumInts = 10;
6198e543 96 static const int sMagic = 0x3141592;
06062cd9 97
a8b0b07d
RSZ
98
99 private_handle_t(int fd, int size, int flags, int w,
70212e56 100 int h, int format, int stride, int vstride) :
a8b0b07d 101 fd(fd), magic(sMagic), flags(flags), size(size),
70212e56
RSZ
102 offset(0), format(format), width(w), height(h), stride(stride),
103 vstride(vstride), base(0)
6198e543
DZ
104 {
105 version = sizeof(native_handle);
6198e543 106 numInts = sNumInts;
a8b0b07d
RSZ
107 numFds = sNumFds;
108 fd1 = 0;
109 fd2 = 0;
6198e543
DZ
110 }
111
a8b0b07d 112 private_handle_t(int fd, int fd1, int fd2, int size, int flags, int w,
70212e56 113 int h, int format, int stride, int vstride) :
a8b0b07d 114 fd(fd), fd1(fd1), fd2(fd2), magic(sMagic), flags(flags), size(size),
70212e56
RSZ
115 offset(0), format(format), width(w), height(h), stride(stride),
116 vstride(vstride), base(0)
6198e543
DZ
117 {
118 version = sizeof(native_handle);
6198e543 119 numInts = sNumInts;
a8b0b07d 120 numFds = sNumFds;
6198e543 121 }
a8b0b07d 122 ~private_handle_t() {
6198e543
DZ
123 magic = 0;
124 }
125
a8b0b07d 126 static int validate(const native_handle* h) {
6198e543 127 const private_handle_t* hnd = (const private_handle_t*)h;
6198e543 128 if (!h || h->version != sizeof(native_handle) ||
a8b0b07d
RSZ
129 h->numInts != sNumInts || h->numFds != sNumFds ||
130 hnd->magic != sMagic)
131 {
132 ALOGE("invalid gralloc handle (at %p)", reinterpret_cast<void *>(const_cast<native_handle *>(h)));
6198e543 133 return -EINVAL;
a8b0b07d 134 }
6198e543
DZ
135 return 0;
136 }
137
138 static private_handle_t* dynamicCast(const native_handle* in)
139 {
140 if (validate(in) == 0)
141 return (private_handle_t*) in;
142
143 return NULL;
144 }
a8b0b07d 145
6198e543
DZ
146#endif
147};
148
149#endif /* GRALLOC_PRIV_H_ */