Home | History | Annotate | Download | only in hardware
      1 /*
      2  * Copyright (C) 2010 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 #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H
     18 #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H
     19 
     20 #include <stdint.h>
     21 #include <sys/cdefs.h>
     22 
     23 #include <hardware/gralloc.h>
     24 #include <hardware/hardware.h>
     25 #include <cutils/native_handle.h>
     26 
     27 __BEGIN_DECLS
     28 
     29 /*****************************************************************************/
     30 
     31 #define HWC_HEADER_VERSION          1
     32 
     33 #define HWC_MODULE_API_VERSION_0_1  HARDWARE_MODULE_API_VERSION(0, 1)
     34 
     35 #define HWC_DEVICE_API_VERSION_1_0  HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION)
     36 #define HWC_DEVICE_API_VERSION_1_1  HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION)
     37 #define HWC_DEVICE_API_VERSION_1_2  HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION)
     38 #define HWC_DEVICE_API_VERSION_1_3  HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION)
     39 #define HWC_DEVICE_API_VERSION_1_4  HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION)
     40 #define HWC_DEVICE_API_VERSION_1_5  HARDWARE_DEVICE_API_VERSION_2(1, 5, HWC_HEADER_VERSION)
     41 
     42 enum {
     43     /* hwc_composer_device_t::set failed in EGL */
     44     HWC_EGL_ERROR = -1
     45 };
     46 
     47 /*
     48  * hwc_layer_t::hints values
     49  * Hints are set by the HAL and read by SurfaceFlinger
     50  */
     51 enum {
     52     /*
     53      * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger
     54      * that it should triple buffer this layer. Typically HWC does this when
     55      * the layer will be unavailable for use for an extended period of time,
     56      * e.g. if the display will be fetching data directly from the layer and
     57      * the layer can not be modified until after the next set().
     58      */
     59     HWC_HINT_TRIPLE_BUFFER  = 0x00000001,
     60 
     61     /*
     62      * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the
     63      * framebuffer with transparent pixels where this layer would be.
     64      * SurfaceFlinger will only honor this flag when the layer has no blending
     65      *
     66      */
     67     HWC_HINT_CLEAR_FB       = 0x00000002
     68 };
     69 
     70 /*
     71  * hwc_layer_t::flags values
     72  * Flags are set by SurfaceFlinger and read by the HAL
     73  */
     74 enum {
     75     /*
     76      * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL
     77      * shall not consider this layer for composition as it will be handled
     78      * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY).
     79      */
     80     HWC_SKIP_LAYER = 0x00000001,
     81 
     82     /*
     83      * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this
     84      * layer is being used as a cursor on this particular display, and that
     85      * surfaceflinger can potentially perform asynchronous position updates for
     86      * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the
     87      * composition type of this layer, then the hwcomposer will allow async
     88      * position updates to this layer via setCursorPositionAsync().
     89      */
     90     HWC_IS_CURSOR_LAYER = 0x00000002
     91 };
     92 
     93 /*
     94  * hwc_layer_t::compositionType values
     95  */
     96 enum {
     97     /* this layer is to be drawn into the framebuffer by SurfaceFlinger */
     98     HWC_FRAMEBUFFER = 0,
     99 
    100     /* this layer will be handled in the HWC */
    101     HWC_OVERLAY = 1,
    102 
    103     /* this is the background layer. it's used to set the background color.
    104      * there is only a single background layer */
    105     HWC_BACKGROUND = 2,
    106 
    107     /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers.
    108      * Added in HWC_DEVICE_API_VERSION_1_1. */
    109     HWC_FRAMEBUFFER_TARGET = 3,
    110 
    111     /* this layer's contents are taken from a sideband buffer stream.
    112      * Added in HWC_DEVICE_API_VERSION_1_4. */
    113     HWC_SIDEBAND = 4,
    114 
    115     /* this layer's composition will be handled by hwcomposer by dedicated
    116        cursor overlay hardware. hwcomposer will also all async position updates
    117        of this layer outside of the normal prepare()/set() loop. Added in
    118        HWC_DEVICE_API_VERSION_1_4. */
    119     HWC_CURSOR_OVERLAY =  5
    120  };
    121 /*
    122  * hwc_layer_t::blending values
    123  */
    124 enum {
    125     /* no blending */
    126     HWC_BLENDING_NONE     = 0x0100,
    127 
    128     /* ONE / ONE_MINUS_SRC_ALPHA */
    129     HWC_BLENDING_PREMULT  = 0x0105,
    130 
    131     /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */
    132     HWC_BLENDING_COVERAGE = 0x0405
    133 };
    134 
    135 /*
    136  * hwc_layer_t::transform values
    137  */
    138 enum {
    139     /* flip source image horizontally */
    140     HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H,
    141     /* flip source image vertically */
    142     HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
    143     /* rotate source image 90 degrees clock-wise */
    144     HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
    145     /* rotate source image 180 degrees */
    146     HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
    147     /* rotate source image 270 degrees clock-wise */
    148     HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
    149 };
    150 
    151 /* attributes queriable with query() */
    152 enum {
    153     /*
    154      * Must return 1 if the background layer is supported, 0 otherwise.
    155      */
    156     HWC_BACKGROUND_LAYER_SUPPORTED      = 0,
    157 
    158     /*
    159      * Returns the vsync period in nanoseconds.
    160      *
    161      * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later.
    162      * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used.
    163      */
    164     HWC_VSYNC_PERIOD                    = 1,
    165 
    166     /*
    167      * Availability: HWC_DEVICE_API_VERSION_1_1
    168      * Returns a mask of supported display types.
    169      */
    170     HWC_DISPLAY_TYPES_SUPPORTED         = 2,
    171 };
    172 
    173 /* display attributes returned by getDisplayAttributes() */
    174 enum {
    175     /* Indicates the end of an attribute list */
    176     HWC_DISPLAY_NO_ATTRIBUTE                = 0,
    177 
    178     /* The vsync period in nanoseconds */
    179     HWC_DISPLAY_VSYNC_PERIOD                = 1,
    180 
    181     /* The number of pixels in the horizontal and vertical directions. */
    182     HWC_DISPLAY_WIDTH                       = 2,
    183     HWC_DISPLAY_HEIGHT                      = 3,
    184 
    185     /* The number of pixels per thousand inches of this configuration.
    186      *
    187      * Scaling DPI by 1000 allows it to be stored in an int without losing
    188      * too much precision.
    189      *
    190      * If the DPI for a configuration is unavailable or the HWC implementation
    191      * considers it unreliable, it should set these attributes to zero.
    192      */
    193     HWC_DISPLAY_DPI_X                       = 4,
    194     HWC_DISPLAY_DPI_Y                       = 5,
    195 };
    196 
    197 /* Allowed events for hwc_methods::eventControl() */
    198 enum {
    199     HWC_EVENT_VSYNC     = 0
    200 };
    201 
    202 /* Display types and associated mask bits. */
    203 enum {
    204     HWC_DISPLAY_PRIMARY     = 0,
    205     HWC_DISPLAY_EXTERNAL    = 1,    // HDMI, DP, etc.
    206     HWC_DISPLAY_VIRTUAL     = 2,
    207 
    208     HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2,
    209     HWC_NUM_DISPLAY_TYPES          = 3,
    210 };
    211 
    212 enum {
    213     HWC_DISPLAY_PRIMARY_BIT     = 1 << HWC_DISPLAY_PRIMARY,
    214     HWC_DISPLAY_EXTERNAL_BIT    = 1 << HWC_DISPLAY_EXTERNAL,
    215     HWC_DISPLAY_VIRTUAL_BIT     = 1 << HWC_DISPLAY_VIRTUAL,
    216 };
    217 
    218 /* Display power modes */
    219 enum {
    220     /* The display is turned off (blanked). */
    221     HWC_POWER_MODE_OFF      = 0,
    222     /* The display is turned on and configured in a low power state
    223      * that is suitable for presenting ambient information to the user,
    224      * possibly with lower fidelity than normal but greater efficiency. */
    225     HWC_POWER_MODE_DOZE     = 1,
    226     /* The display is turned on normally. */
    227     HWC_POWER_MODE_NORMAL   = 2,
    228     /* The display is configured as in HWC_POWER_MODE_DOZE but may
    229      * stop applying frame buffer updates from the graphics subsystem.
    230      * This power mode is effectively a hint from the doze dream to
    231      * tell the hardware that it is done drawing to the display for the
    232      * time being and that the display should remain on in a low power
    233      * state and continue showing its current contents indefinitely
    234      * until the mode changes.
    235      *
    236      * This mode may also be used as a signal to enable hardware-based doze
    237      * functionality.  In this case, the doze dream is effectively
    238      * indicating that the hardware is free to take over the display
    239      * and manage it autonomously to implement low power always-on display
    240      * functionality. */
    241     HWC_POWER_MODE_DOZE_SUSPEND  = 3,
    242 };
    243 
    244 /*****************************************************************************/
    245 
    246 __END_DECLS
    247 
    248 #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */
    249