michael@0: /* michael@0: * Copyright (C) 2008 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: michael@0: #ifndef ANDROID_FB_INTERFACE_H michael@0: #define ANDROID_FB_INTERFACE_H michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include michael@0: michael@0: #include michael@0: michael@0: __BEGIN_DECLS michael@0: michael@0: #define GRALLOC_HARDWARE_FB0 "fb0" michael@0: michael@0: /*****************************************************************************/ michael@0: michael@0: michael@0: /*****************************************************************************/ michael@0: michael@0: typedef struct framebuffer_device_t { michael@0: struct hw_device_t common; michael@0: michael@0: /* flags describing some attributes of the framebuffer */ michael@0: const uint32_t flags; michael@0: michael@0: /* dimensions of the framebuffer in pixels */ michael@0: const uint32_t width; michael@0: const uint32_t height; michael@0: michael@0: /* frambuffer stride in pixels */ michael@0: const int stride; michael@0: michael@0: /* framebuffer pixel format */ michael@0: const int format; michael@0: michael@0: /* resolution of the framebuffer's display panel in pixel per inch*/ michael@0: const float xdpi; michael@0: const float ydpi; michael@0: michael@0: /* framebuffer's display panel refresh rate in frames per second */ michael@0: const float fps; michael@0: michael@0: /* min swap interval supported by this framebuffer */ michael@0: const int minSwapInterval; michael@0: michael@0: /* max swap interval supported by this framebuffer */ michael@0: const int maxSwapInterval; michael@0: michael@0: int reserved[8]; michael@0: michael@0: /* michael@0: * requests a specific swap-interval (same definition than EGL) michael@0: * michael@0: * Returns 0 on success or -errno on error. michael@0: */ michael@0: int (*setSwapInterval)(struct framebuffer_device_t* window, michael@0: int interval); michael@0: michael@0: /* michael@0: * This hook is OPTIONAL. michael@0: * michael@0: * It is non NULL If the framebuffer driver supports "update-on-demand" michael@0: * and the given rectangle is the area of the screen that gets michael@0: * updated during (*post)(). michael@0: * michael@0: * This is useful on devices that are able to DMA only a portion of michael@0: * the screen to the display panel, upon demand -- as opposed to michael@0: * constantly refreshing the panel 60 times per second, for instance. michael@0: * michael@0: * Only the area defined by this rectangle is guaranteed to be valid, that michael@0: * is, the driver is not allowed to post anything outside of this michael@0: * rectangle. michael@0: * michael@0: * The rectangle evaluated during (*post)() and specifies which area michael@0: * of the buffer passed in (*post)() shall to be posted. michael@0: * michael@0: * return -EINVAL if width or height <=0, or if left or top < 0 michael@0: */ michael@0: int (*setUpdateRect)(struct framebuffer_device_t* window, michael@0: int left, int top, int width, int height); michael@0: michael@0: /* michael@0: * Post to the display (display it on the screen) michael@0: * The buffer must have been allocated with the michael@0: * GRALLOC_USAGE_HW_FB usage flag. michael@0: * buffer must be the same width and height as the display and must NOT michael@0: * be locked. michael@0: * michael@0: * The buffer is shown during the next VSYNC. michael@0: * michael@0: * If the same buffer is posted again (possibly after some other buffer), michael@0: * post() will block until the the first post is completed. michael@0: * michael@0: * Internally, post() is expected to lock the buffer so that a michael@0: * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or michael@0: * USAGE_*_WRITE will block until it is safe; that is typically once this michael@0: * buffer is shown and another buffer has been posted. michael@0: * michael@0: * Returns 0 on success or -errno on error. michael@0: */ michael@0: int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer); michael@0: michael@0: michael@0: /* michael@0: * The (*compositionComplete)() method must be called after the michael@0: * compositor has finished issuing GL commands for client buffers. michael@0: */ michael@0: michael@0: int (*compositionComplete)(struct framebuffer_device_t* dev); michael@0: michael@0: /* michael@0: * This hook is OPTIONAL. michael@0: * michael@0: * If non NULL it will be caused by SurfaceFlinger on dumpsys michael@0: */ michael@0: void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len); michael@0: michael@0: /* michael@0: * (*enableScreen)() is used to either blank (enable=0) or michael@0: * unblank (enable=1) the screen this framebuffer is attached to. michael@0: * michael@0: * Returns 0 on success or -errno on error. michael@0: */ michael@0: int (*enableScreen)(struct framebuffer_device_t* dev, int enable); michael@0: michael@0: void* reserved_proc[6]; michael@0: michael@0: } framebuffer_device_t; michael@0: michael@0: michael@0: /** convenience API for opening and closing a supported device */ michael@0: michael@0: static inline int framebuffer_open(const struct hw_module_t* module, michael@0: struct framebuffer_device_t** device) { michael@0: return module->methods->open(module, michael@0: GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device); michael@0: } michael@0: michael@0: static inline int framebuffer_close(struct framebuffer_device_t* device) { michael@0: return device->common.close(&device->common); michael@0: } michael@0: michael@0: michael@0: __END_DECLS michael@0: michael@0: #endif // ANDROID_FB_INTERFACE_H