Path: blob/21.2-virgl/include/android_stub/hardware/fb.h
7160 views
/*1* Copyright (C) 2008 The Android Open Source Project2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/151617#ifndef ANDROID_FB_INTERFACE_H18#define ANDROID_FB_INTERFACE_H1920#include <stdint.h>21#include <sys/cdefs.h>22#include <sys/types.h>2324#include <cutils/native_handle.h>2526#include <hardware/hardware.h>2728__BEGIN_DECLS2930#define GRALLOC_HARDWARE_FB0 "fb0"3132/*****************************************************************************/333435/*****************************************************************************/3637typedef struct framebuffer_device_t {38/**39* Common methods of the framebuffer device. This *must* be the first member of40* framebuffer_device_t as users of this structure will cast a hw_device_t to41* framebuffer_device_t pointer in contexts where it's known the hw_device_t references a42* framebuffer_device_t.43*/44struct hw_device_t common;4546/* flags describing some attributes of the framebuffer */47const uint32_t flags;4849/* dimensions of the framebuffer in pixels */50const uint32_t width;51const uint32_t height;5253/* frambuffer stride in pixels */54const int stride;5556/* framebuffer pixel format */57const int format;5859/* resolution of the framebuffer's display panel in pixel per inch*/60const float xdpi;61const float ydpi;6263/* framebuffer's display panel refresh rate in frames per second */64const float fps;6566/* min swap interval supported by this framebuffer */67const int minSwapInterval;6869/* max swap interval supported by this framebuffer */70const int maxSwapInterval;7172/* Number of framebuffers supported*/73const int numFramebuffers;7475int reserved[7];7677/*78* requests a specific swap-interval (same definition than EGL)79*80* Returns 0 on success or -errno on error.81*/82int (*setSwapInterval)(struct framebuffer_device_t* window,83int interval);8485/*86* This hook is OPTIONAL.87*88* It is non NULL If the framebuffer driver supports "update-on-demand"89* and the given rectangle is the area of the screen that gets90* updated during (*post)().91*92* This is useful on devices that are able to DMA only a portion of93* the screen to the display panel, upon demand -- as opposed to94* constantly refreshing the panel 60 times per second, for instance.95*96* Only the area defined by this rectangle is guaranteed to be valid, that97* is, the driver is not allowed to post anything outside of this98* rectangle.99*100* The rectangle evaluated during (*post)() and specifies which area101* of the buffer passed in (*post)() shall to be posted.102*103* return -EINVAL if width or height <=0, or if left or top < 0104*/105int (*setUpdateRect)(struct framebuffer_device_t* window,106int left, int top, int width, int height);107108/*109* Post <buffer> to the display (display it on the screen)110* The buffer must have been allocated with the111* GRALLOC_USAGE_HW_FB usage flag.112* buffer must be the same width and height as the display and must NOT113* be locked.114*115* The buffer is shown during the next VSYNC.116*117* If the same buffer is posted again (possibly after some other buffer),118* post() will block until the the first post is completed.119*120* Internally, post() is expected to lock the buffer so that a121* subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or122* USAGE_*_WRITE will block until it is safe; that is typically once this123* buffer is shown and another buffer has been posted.124*125* Returns 0 on success or -errno on error.126*/127int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer);128129130/*131* The (*compositionComplete)() method must be called after the132* compositor has finished issuing GL commands for client buffers.133*/134135int (*compositionComplete)(struct framebuffer_device_t* dev);136137/*138* This hook is OPTIONAL.139*140* If non NULL it will be caused by SurfaceFlinger on dumpsys141*/142void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len);143144/*145* (*enableScreen)() is used to either blank (enable=0) or146* unblank (enable=1) the screen this framebuffer is attached to.147*148* Returns 0 on success or -errno on error.149*/150int (*enableScreen)(struct framebuffer_device_t* dev, int enable);151152void* reserved_proc[6];153154} framebuffer_device_t;155156157/** convenience API for opening and closing a supported device */158159static inline int framebuffer_open(const struct hw_module_t* module,160struct framebuffer_device_t** device) {161return module->methods->open(module,162GRALLOC_HARDWARE_FB0, TO_HW_DEVICE_T_OPEN(device));163}164165static inline int framebuffer_close(struct framebuffer_device_t* device) {166return device->common.close(&device->common);167}168169170__END_DECLS171172#endif // ANDROID_FB_INTERFACE_H173174175