diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/hardware/hwcomposer.h | 168 | ||||
-rw-r--r-- | include/hardware/hwcomposer_defs.h | 23 |
2 files changed, 117 insertions, 74 deletions
diff --git a/include/hardware/hwcomposer.h b/include/hardware/hwcomposer.h index 895c695..29ea54c 100644 --- a/include/hardware/hwcomposer.h +++ b/include/hardware/hwcomposer.h @@ -59,39 +59,6 @@ __BEGIN_DECLS */ #define HWC_HARDWARE_COMPOSER "composer" -struct hwc_composer_device_1; -typedef struct hwc_methods_1 { - - /* - * eventControl(..., event, enabled) - * Enables or disables h/w composer events for a display. - * - * eventControl can be called from any thread and takes effect - * immediately. - * - * Supported events are: - * HWC_EVENT_VSYNC - * - * returns -EINVAL if the "event" parameter is not one of the value above - * or if the "enabled" parameter is not 0 or 1. - */ - int (*eventControl)( - struct hwc_composer_device_1* dev, int dpy, - int event, int enabled); - - /* - * blank(..., blank) - * Blanks or unblanks a display's screen. - * - * Turns the screen off when blank is nonzero, on when blank is zero. - * Multiple sequential calls with the same blank value must be supported. - * - * returns 0 on success, negative on error. - */ - int (*blank)(struct hwc_composer_device_1* dev, int dpy, int blank); - -} hwc_methods_1_t; - typedef struct hwc_rect { int left; int top; @@ -113,20 +80,30 @@ typedef struct hwc_color { typedef struct hwc_layer_1 { /* - * initially set to HWC_FRAMEBUFFER or HWC_BACKGROUND. + * Initially set to HWC_FRAMEBUFFER, HWC_BACKGROUND, or + * HWC_FRAMEBUFFER_TARGET. + * * HWC_FRAMEBUFFER - * indicates the layer will be drawn into the framebuffer - * using OpenGL ES. - * The HWC can toggle this value to HWC_OVERLAY, to indicate - * it will handle the layer. + * Indicates the layer will be drawn into the framebuffer + * using OpenGL ES. The HWC can toggle this value to HWC_OVERLAY to + * indicate it will handle the layer. * * HWC_BACKGROUND - * indicates this is a special "background" layer. The only valid - * field is backgroundColor. HWC_BACKGROUND can only be used with - * HWC_API_VERSION >= 0.2 - * The HWC can toggle this value to HWC_FRAMEBUFFER, to indicate - * it CANNOT handle the background color + * Indicates this is a special "background" layer. The only valid field + * is backgroundColor. The HWC can toggle this value to HWC_FRAMEBUFFER + * to indicate it CANNOT handle the background color. * + * HWC_FRAMEBUFFER_TARGET + * Indicates this layer is the framebuffer surface used as the target of + * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY + * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and + * this layer should be ignored during set(); the HWC_SKIP_LAYER flag + * will indicate this case. + * + * This flag (and the framebuffer surface layer) will only be used if the + * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, + * the OpenGL ES target surface is communicated by the (dpy, sur) fields + * in hwc_compositor_device_1_t. */ int32_t compositionType; @@ -178,6 +155,10 @@ typedef struct hwc_layer_1 { * fence to be signaled before returning, but the HWC must wait for * all buffers to be signaled before reading from them. * + * HWC_FRAMEBUFFER layers will never have an acquire fence, since + * reads from them are complete before the framebuffer is ready for + * display. + * * The HWC takes ownership of the acquireFenceFd and is responsible * for closing it when no longer needed. */ @@ -197,6 +178,10 @@ typedef struct hwc_layer_1 { * the blit completes, but the overlay layers can't be reused until * a subsequent frame has been displayed. * + * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't + * produce a release fence for them. The releaseFenceFd will be -1 + * for these layers when set() is called. + * * The HWC client taks ownership of the releaseFenceFd and is * responsible for closing it when no longer needed. */ @@ -244,9 +229,13 @@ typedef struct hwc_display_contents_1 { */ int flipFenceFd; - /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES composition. - * They aren't relevant to prepare. The set call should commit this surface - * atomically to the display along with any overlay layers. + /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES composition for + * HWC versions before HWC_DEVICE_VERSION_1_1. They aren't relevant to + * prepare. The set call should commit this surface atomically to the + * display along with any overlay layers. + * + * For HWC_DEVICE_VERSION_1_1 and later, these will always be set to + * EGL_NO_DISPLAY and EGL_NO_SURFACE. */ hwc_display_t dpy; hwc_surface_t sur; @@ -262,8 +251,7 @@ typedef struct hwc_display_contents_1 { } hwc_display_contents_1_t; /* see hwc_composer_device::registerProcs() - * Any of the callbacks can be NULL, in which case the corresponding - * functionality is not supported. + * All of the callbacks are required and non-NULL unless otherwise noted. */ typedef struct hwc_procs { /* @@ -275,7 +263,7 @@ typedef struct hwc_procs { * it is safe to call invalidate() from any of hwc_composer_device * hooks, unless noted otherwise. */ - void (*invalidate)(struct hwc_procs* procs); + void (*invalidate)(const struct hwc_procs* procs); /* * (*vsync)() is called by the h/w composer HAL when a vsync event is @@ -297,7 +285,7 @@ typedef struct hwc_procs { * can either stop or continue to process VSYNC events, but must not * crash or cause other problems. */ - void (*vsync)(struct hwc_procs* procs, int dpy, int64_t timestamp); + void (*vsync)(const struct hwc_procs* procs, int dpy, int64_t timestamp); } hwc_procs_t; @@ -326,8 +314,16 @@ typedef struct hwc_composer_device_1 { * handles have been updated. Typically this happens (but is not limited to) * when a window is added, removed, resized or moved. * - * The numDisplays parameter will always be greater than zero, displays - * will be non-NULL, and the array entries will be non-NULL. + * For HWC 1.0, numDisplays will always be one, and displays[0] will be + * non-NULL. + * + * For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries + * for unsupported or disabled/disconnected display types will be NULL. + * + * For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more. + * The extra entries correspond to enabled virtual displays, and will be + * non-NULL. In HWC 1.2, support for one virtual display is required, and + * no more than one will be used. Future HWC versions might require more. * * returns: 0 on success. An negative error code on error. If an error is * returned, SurfaceFlinger will assume that none of the layer will be @@ -352,8 +348,16 @@ typedef struct hwc_composer_device_1 { * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() * behaves just like eglSwapBuffers(). * - * The numDisplays parameter will always be greater than zero, displays - * will be non-NULL, and the array entries will be non-NULL. + * For HWC 1.0, numDisplays will always be one, and displays[0] will be + * non-NULL. + * + * For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries + * for unsupported or disabled/disconnected display types will be NULL. + * + * For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more. + * The extra entries correspond to enabled virtual displays, and will be + * non-NULL. In HWC 1.2, support for one virtual display is required, and + * no more than one will be used. Future HWC versions might require more. * * IMPORTANT NOTE: there is an implicit layer containing opaque black * pixels behind all the layers in the list. It is the responsibility of @@ -368,31 +372,35 @@ typedef struct hwc_composer_device_1 { size_t numDisplays, hwc_display_contents_1_t** displays); /* - * This field is OPTIONAL and can be NULL. + * eventControl(..., event, enabled) + * Enables or disables h/w composer events for a display. * - * If non NULL it will be called by SurfaceFlinger on dumpsys + * eventControl can be called from any thread and takes effect + * immediately. + * + * Supported events are: + * HWC_EVENT_VSYNC + * + * returns -EINVAL if the "event" parameter is not one of the value above + * or if the "enabled" parameter is not 0 or 1. */ - void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); + int (*eventControl)(struct hwc_composer_device_1* dev, int dpy, + int event, int enabled); /* - * This field is OPTIONAL and can be NULL. + * blank(..., blank) + * Blanks or unblanks a display's screen. * - * (*registerProcs)() registers a set of callbacks the h/w composer HAL - * can later use. It is FORBIDDEN to call any of the callbacks from - * within registerProcs(). registerProcs() must save the hwc_procs_t pointer - * which is needed when calling a registered callback. - * Each call to registerProcs replaces the previous set of callbacks. - * registerProcs is called with NULL to unregister all callbacks. + * Turns the screen off when blank is nonzero, on when blank is zero. + * Multiple sequential calls with the same blank value must be supported. + * The screen state transition must be be complete when the function + * returns. * - * Any of the callbacks can be NULL, in which case the corresponding - * functionality is not supported. + * returns 0 on success, negative on error. */ - void (*registerProcs)(struct hwc_composer_device_1* dev, - hwc_procs_t const* procs); + int (*blank)(struct hwc_composer_device_1* dev, int dpy, int blank); /* - * This field is OPTIONAL and can be NULL. - * * Used to retrieve information about the h/w composer * * Returns 0 on success or -errno on error. @@ -400,14 +408,26 @@ typedef struct hwc_composer_device_1 { int (*query)(struct hwc_composer_device_1* dev, int what, int* value); /* - * Reserved for future use. Must be NULL. + * (*registerProcs)() registers callbacks that the h/w composer HAL can + * later use. It will be called immediately after the composer device is + * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks + * from within registerProcs(). registerProcs() must save the hwc_procs_t + * pointer which is needed when calling a registered callback. */ - void* reserved_proc[4]; + void (*registerProcs)(struct hwc_composer_device_1* dev, + hwc_procs_t const* procs); /* - * This field is REQUIRED and must not be NULL. + * This field is OPTIONAL and can be NULL. + * + * If non NULL it will be called by SurfaceFlinger on dumpsys */ - hwc_methods_1_t const *methods; + void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); + + /* + * Reserved for future use. Must be NULL. + */ + void* reserved_proc[4]; } hwc_composer_device_1_t; diff --git a/include/hardware/hwcomposer_defs.h b/include/hardware/hwcomposer_defs.h index 02b8e50..f0f97fc 100644 --- a/include/hardware/hwcomposer_defs.h +++ b/include/hardware/hwcomposer_defs.h @@ -34,6 +34,7 @@ __BEGIN_DECLS #define HWC_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION(0, 2) #define HWC_DEVICE_API_VERSION_0_3 HARDWARE_DEVICE_API_VERSION(0, 3) #define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) +#define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1) enum { /* hwc_composer_device_t::set failed in EGL */ @@ -89,6 +90,10 @@ enum { /* this is the background layer. it's used to set the background color. * there is only a single background layer */ HWC_BACKGROUND = 2, + + /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. + * Added in HWC_DEVICE_API_VERSION_1_1. */ + HWC_FRAMEBUFFER_TARGET = 3, }; /* @@ -134,6 +139,12 @@ enum { * returns the vsync period in nanosecond */ HWC_VSYNC_PERIOD = 1, + + /* + * availability: HWC_DEVICE_API_VERSION_1_1 + * returns a mask of supported display types + */ + HWC_DISPLAY_TYPES_SUPPORTED = 2, }; /* Allowed events for hwc_methods::eventControl() */ @@ -141,6 +152,18 @@ enum { HWC_EVENT_VSYNC = 0 }; +/* Display types and associated mask bits. */ +enum { + HWC_DISPLAY_PRIMARY = 0, + HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. + HWC_NUM_DISPLAY_TYPES +}; + +enum { + HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, + HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, +}; + /*****************************************************************************/ __END_DECLS |