blob: ba2f286d07c0f09dd1326831a0210f6e0eb9f9d3 [file] [log] [blame]
Mathias Agopian5337b102011-04-28 18:56:10 -07001/*
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
18#ifndef ANDROID_FB_INTERFACE_H
19#define ANDROID_FB_INTERFACE_H
20
21#include <stdint.h>
22#include <sys/cdefs.h>
23#include <sys/types.h>
24
25#include <cutils/native_handle.h>
26
27#include <hardware/hardware.h>
28
29__BEGIN_DECLS
30
31#define GRALLOC_HARDWARE_FB0 "fb0"
32
33/*****************************************************************************/
34
35
36/*****************************************************************************/
37
38typedef struct framebuffer_device_t {
39 struct hw_device_t common;
40
41 /* flags describing some attributes of the framebuffer */
42 const uint32_t flags;
43
44 /* dimensions of the framebuffer in pixels */
45 const uint32_t width;
46 const uint32_t height;
47
48 /* frambuffer stride in pixels */
49 const int stride;
50
51 /* framebuffer pixel format */
52 const int format;
53
54 /* resolution of the framebuffer's display panel in pixel per inch*/
55 const float xdpi;
56 const float ydpi;
57
58 /* framebuffer's display panel refresh rate in frames per second */
59 const float fps;
60
61 /* min swap interval supported by this framebuffer */
62 const int minSwapInterval;
63
64 /* max swap interval supported by this framebuffer */
65 const int maxSwapInterval;
66
67 int reserved[8];
68
69 /*
70 * requests a specific swap-interval (same definition than EGL)
71 *
72 * Returns 0 on success or -errno on error.
73 */
74 int (*setSwapInterval)(struct framebuffer_device_t* window,
75 int interval);
76
77 /*
78 * This hook is OPTIONAL.
79 *
80 * It is non NULL If the framebuffer driver supports "update-on-demand"
81 * and the given rectangle is the area of the screen that gets
82 * updated during (*post)().
83 *
84 * This is useful on devices that are able to DMA only a portion of
85 * the screen to the display panel, upon demand -- as opposed to
86 * constantly refreshing the panel 60 times per second, for instance.
87 *
88 * Only the area defined by this rectangle is guaranteed to be valid, that
89 * is, the driver is not allowed to post anything outside of this
90 * rectangle.
91 *
92 * The rectangle evaluated during (*post)() and specifies which area
93 * of the buffer passed in (*post)() shall to be posted.
94 *
95 * return -EINVAL if width or height <=0, or if left or top < 0
96 */
97 int (*setUpdateRect)(struct framebuffer_device_t* window,
98 int left, int top, int width, int height);
99
100 /*
101 * Post <buffer> to the display (display it on the screen)
102 * The buffer must have been allocated with the
103 * GRALLOC_USAGE_HW_FB usage flag.
104 * buffer must be the same width and height as the display and must NOT
105 * be locked.
106 *
107 * The buffer is shown during the next VSYNC.
108 *
109 * If the same buffer is posted again (possibly after some other buffer),
110 * post() will block until the the first post is completed.
111 *
112 * Internally, post() is expected to lock the buffer so that a
113 * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or
114 * USAGE_*_WRITE will block until it is safe; that is typically once this
115 * buffer is shown and another buffer has been posted.
116 *
117 * Returns 0 on success or -errno on error.
118 */
119 int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer);
120
121
122 /*
123 * The (*compositionComplete)() method must be called after the
124 * compositor has finished issuing GL commands for client buffers.
125 */
126
127 int (*compositionComplete)(struct framebuffer_device_t* dev);
128
129 /*
130 * This hook is OPTIONAL.
131 *
132 * If non NULL it will be caused by SurfaceFlinger on dumpsys
133 */
134 void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len);
135
136 /*
137 * (*enableScreen)() is used to either blank (enable=0) or
138 * unblank (enable=1) the screen this framebuffer is attached to.
139 *
140 * Returns 0 on success or -errno on error.
141 */
142 int (*enableScreen)(struct framebuffer_device_t* dev, int enable);
143
144 void* reserved_proc[6];
145
146} framebuffer_device_t;
147
148
149/** convenience API for opening and closing a supported device */
150
151static inline int framebuffer_open(const struct hw_module_t* module,
152 struct framebuffer_device_t** device) {
153 return module->methods->open(module,
154 GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device);
155}
156
157static inline int framebuffer_close(struct framebuffer_device_t* device) {
158 return device->common.close(&device->common);
159}
160
161
162__END_DECLS
163
164#endif // ANDROID_FB_INTERFACE_H