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.
18 #ifndef ANDROID_FB_INTERFACE_H
19 #define ANDROID_FB_INTERFACE_H
22 #include <sys/cdefs.h>
23 #include <sys/types.h>
25 #include <cutils/native_handle.h>
27 #include <hardware/hardware.h>
31 #define GRALLOC_HARDWARE_FB0 "fb0"
33 /*****************************************************************************/
36 /*****************************************************************************/
38 typedef struct framebuffer_device_t
{
39 struct hw_device_t common
;
41 /* flags describing some attributes of the framebuffer */
44 /* dimensions of the framebuffer in pixels */
46 const uint32_t height
;
48 /* frambuffer stride in pixels */
51 /* framebuffer pixel format */
54 /* resolution of the framebuffer's display panel in pixel per inch*/
58 /* framebuffer's display panel refresh rate in frames per second */
61 /* min swap interval supported by this framebuffer */
62 const int minSwapInterval
;
64 /* max swap interval supported by this framebuffer */
65 const int maxSwapInterval
;
67 /* Number of framebuffers supported*/
68 const int numFramebuffers
;
73 * requests a specific swap-interval (same definition than EGL)
75 * Returns 0 on success or -errno on error.
77 int (*setSwapInterval
)(struct framebuffer_device_t
* window
,
81 * This hook is OPTIONAL.
83 * It is non NULL If the framebuffer driver supports "update-on-demand"
84 * and the given rectangle is the area of the screen that gets
85 * updated during (*post)().
87 * This is useful on devices that are able to DMA only a portion of
88 * the screen to the display panel, upon demand -- as opposed to
89 * constantly refreshing the panel 60 times per second, for instance.
91 * Only the area defined by this rectangle is guaranteed to be valid, that
92 * is, the driver is not allowed to post anything outside of this
95 * The rectangle evaluated during (*post)() and specifies which area
96 * of the buffer passed in (*post)() shall to be posted.
98 * return -EINVAL if width or height <=0, or if left or top < 0
100 int (*setUpdateRect
)(struct framebuffer_device_t
* window
,
101 int left
, int top
, int width
, int height
);
104 * Post <buffer> to the display (display it on the screen)
105 * The buffer must have been allocated with the
106 * GRALLOC_USAGE_HW_FB usage flag.
107 * buffer must be the same width and height as the display and must NOT
110 * The buffer is shown during the next VSYNC.
112 * If the same buffer is posted again (possibly after some other buffer),
113 * post() will block until the the first post is completed.
115 * Internally, post() is expected to lock the buffer so that a
116 * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or
117 * USAGE_*_WRITE will block until it is safe; that is typically once this
118 * buffer is shown and another buffer has been posted.
120 * Returns 0 on success or -errno on error.
122 int (*post
)(struct framebuffer_device_t
* dev
, buffer_handle_t buffer
);
126 * The (*compositionComplete)() method must be called after the
127 * compositor has finished issuing GL commands for client buffers.
130 int (*compositionComplete
)(struct framebuffer_device_t
* dev
);
133 * This hook is OPTIONAL.
135 * If non NULL it will be caused by SurfaceFlinger on dumpsys
137 void (*dump
)(struct framebuffer_device_t
* dev
, char *buff
, int buff_len
);
140 * (*enableScreen)() is used to either blank (enable=0) or
141 * unblank (enable=1) the screen this framebuffer is attached to.
143 * Returns 0 on success or -errno on error.
145 int (*enableScreen
)(struct framebuffer_device_t
* dev
, int enable
);
147 void* reserved_proc
[6];
149 } framebuffer_device_t
;
152 /** convenience API for opening and closing a supported device */
154 static inline int framebuffer_open(const struct hw_module_t
* module
,
155 struct framebuffer_device_t
** device
) {
156 return module
->methods
->open(module
,
157 GRALLOC_HARDWARE_FB0
, (struct hw_device_t
**)device
);
160 static inline int framebuffer_close(struct framebuffer_device_t
* device
) {
161 return device
->common
.close(&device
->common
);
167 #endif // ANDROID_FB_INTERFACE_H