2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef GRALLOC_PRIV_H_
18 #define GRALLOC_PRIV_H_
22 #include <sys/cdefs.h>
23 #include <hardware/gralloc.h>
28 #include <cutils/native_handle.h>
32 /*****************************************************************************/
34 struct private_module_t;
35 struct private_handle_t;
37 struct private_module_t {
38 gralloc_module_t base;
40 private_handle_t* framebuffer;
45 buffer_handle_t currentBuffer;
47 void* pmem_master_base;
49 struct fb_var_screeninfo info;
50 struct fb_fix_screeninfo finfo;
56 /*****************************************************************************/
59 struct private_handle_t : public native_handle {
61 struct private_handle_t {
62 struct native_handle nativeHandle;
66 PRIV_FLAGS_FRAMEBUFFER = 0x00000001
77 // FIXME: the attributes below should be out-of-line
82 static const int sNumInts = 6;
83 static const int sNumFds = 1;
84 static const int sMagic = 0x3141592;
86 private_handle_t(int fd, int size, int flags) :
87 fd(fd), magic(sMagic), flags(flags), size(size), offset(0),
88 base(0), pid(getpid())
90 version = sizeof(native_handle);
98 static int validate(const native_handle* h) {
99 const private_handle_t* hnd = (const private_handle_t*)h;
100 if (!h || h->version != sizeof(native_handle) ||
101 h->numInts != sNumInts || h->numFds != sNumFds ||
102 hnd->magic != sMagic)
104 LOGE("invalid gralloc handle (at %p)", h);
112 #endif /* GRALLOC_PRIV_H_ */