hwcomposer.h revision fb410365ca67d36d4c81d7826712c6a05437612f
15d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
25d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Copyright (C) 2010 The Android Open Source Project
35d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian *
45d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
55d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * you may not use this file except in compliance with the License.
65d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * You may obtain a copy of the License at
75d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian *
85d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
95d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian *
105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Unless required by applicable law or agreed to in writing, software
115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * See the License for the specific language governing permissions and
145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * limitations under the License.
155d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H
185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H
195d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#include <stdint.h>
215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#include <sys/cdefs.h>
225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2345e2371cb954a8f8e0aee16d1ee8bec7eae9b897Louis Huemiller#include <hardware/gralloc.h>
245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#include <hardware/hardware.h>
255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#include <cutils/native_handle.h>
265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__BEGIN_DECLS
285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/
30e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling
31e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling#define HWC_API_VERSION 1
32e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling
335d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/**
345d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * The id of this module
355d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
365d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define HWC_HARDWARE_MODULE_ID "hwcomposer"
375d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
385d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/**
395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Name of the sensors device to open
405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define HWC_HARDWARE_COMPOSER   "composer"
425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum {
455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* hwc_composer_device_t::set failed in EGL */
465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_EGL_ERROR = -1
475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian};
485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::hints values
515d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Hints are set by the HAL and read by SurfaceFlinger
525d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum {
545d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
55cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian     * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger
565d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * that it should triple buffer this layer. Typically HWC does this when
575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * the layer will be unavailable for use for an extended period of time,
585d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * e.g. if the display will be fetching data directly from the layer and
595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * the layer can not be modified until after the next set().
605d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
61cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian    HWC_HINT_TRIPLE_BUFFER  = 0x00000001,
62cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian
63cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian    /*
64cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian     * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the
65cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian     * framebuffer with transparent pixels where this layer would be.
66cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian     * SurfaceFlinger will only honor this flag when the layer has no blending
67cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian     *
68cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian     */
69cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian    HWC_HINT_CLEAR_FB       = 0x00000002
705d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian};
715d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
725d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::flags values
745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Flags are set by SurfaceFlinger and read by the HAL
755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
765d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum {
775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL
795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * shall not consider this layer for composition as it will be handled
805d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY).
815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_SKIP_LAYER = 0x00000001,
835d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian};
845d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::compositionType values
875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum {
895d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* this layer is to be drawn into the framebuffer by SurfaceFlinger */
905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_FRAMEBUFFER = 0,
915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
925d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* this layer will be handled in the HWC */
935d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_OVERLAY = 1,
945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian};
955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::blending values
985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
995d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum {
1005d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* no blending */
1015d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_BLENDING_NONE     = 0x0100,
1025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* ONE / ONE_MINUS_SRC_ALPHA */
1045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_BLENDING_PREMULT  = 0x0105,
1055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */
1075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_BLENDING_COVERAGE = 0x0405
1085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian};
1095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
1115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::transform values
1125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
1135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum {
1145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* flip source image horizontally */
1155d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H,
1165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* flip source image vertically */
1175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
1185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* rotate source image 90 degrees clock-wise */
1195d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
1205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* rotate source image 180 degrees */
1215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
1225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* rotate source image 270 degrees clock-wise */
1235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
1245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian};
1255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_rect {
1275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int left;
1285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int top;
1295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int right;
1305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int bottom;
1315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_rect_t;
1325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1335d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_region {
1345d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    size_t numRects;
1355d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    hwc_rect_t const* rects;
1365d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_region_t;
1375d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1385d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_layer {
1395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
1405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * initially set to HWC_FRAMEBUFFER, indicates the layer will
1415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * be drawn into the framebuffer using OpenGL ES.
1425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * The HWC can toggle this value to HWC_OVERLAY, to indicate
1435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * it will handle the layer.
1445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
1455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int32_t compositionType;
1465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* see hwc_layer_t::hints above */
1485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    uint32_t hints;
1495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* see hwc_layer_t::flags above */
1515d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    uint32_t flags;
1525d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* handle of buffer to compose. this handle is guaranteed to have been
1545d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * allocated with gralloc */
15545e2371cb954a8f8e0aee16d1ee8bec7eae9b897Louis Huemiller    buffer_handle_t handle;
1565d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* transformation to apply to the buffer during composition */
1585d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    uint32_t transform;
1595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1605d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* blending to apply during composition */
1615d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int32_t blending;
1625d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1635d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* area of the source to consider, the origin is the top-left corner of
1645d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * the buffer */
1655d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    hwc_rect_t sourceCrop;
1665d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1675d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* where to composite the sourceCrop onto the display. The sourceCrop
1685d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * is scaled using linear filtering to the displayFrame. The origin is the
1695d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * top-left corner of the screen.
1705d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
1715d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    hwc_rect_t displayFrame;
1725d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* visible region in screen space. The origin is the
1745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * top-left corner of the screen.
1755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * The visible region INCLUDES areas overlapped by a translucent layer.
1765d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
1775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    hwc_region_t visibleRegionScreen;
1785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_layer_t;
1795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1805d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
1825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_list_t::flags values
1835d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
1845d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum {
1855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
1865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list
1875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * passed to (*prepare)() has changed by more than just the buffer handles.
1885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
1895d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_GEOMETRY_CHANGED = 0x00000001,
1905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian};
1915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
192871815b5f144048b63a18ef764f82e89394899faLouis Huemiller/*
193871815b5f144048b63a18ef764f82e89394899faLouis Huemiller * List of layers.
194871815b5f144048b63a18ef764f82e89394899faLouis Huemiller * The handle members of hwLayers elements must be unique.
195871815b5f144048b63a18ef764f82e89394899faLouis Huemiller */
1965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_layer_list {
1975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    uint32_t flags;
1985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    size_t numHwLayers;
1995d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    hwc_layer_t hwLayers[0];
2005d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_layer_list_t;
2015d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* This represents a display, typically an EGLDisplay object */
2035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef void* hwc_display_t;
2045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* This represents a surface, typically an EGLSurface object  */
2065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef void* hwc_surface_t;
2075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
209d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/* see hwc_composer_device::registerProcs()
210d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * Any of the callbacks can be NULL, in which case the corresponding
211d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * functionality is not supported.
212d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */
213d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopiantypedef struct hwc_procs {
214d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian    /*
215d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * (*invalidate)() triggers a screen refresh, in particular prepare and set
216d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * will be called shortly after this call is made. Note that there is
217d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * NO GUARANTEE that the screen refresh will happen after invalidate()
218d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * returns (in particular, it could happen before).
219d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and
220d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * it is safe to call invalidate() from any of hwc_composer_device
221d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * hooks, unless noted otherwise.
222d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     */
223d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian    void (*invalidate)(struct hwc_procs* procs);
224d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian} hwc_procs_t;
225d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian
226d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian
227d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/*****************************************************************************/
2285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_module {
2305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    struct hw_module_t common;
2315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_module_t;
2325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2335d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2345d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_composer_device {
2355d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    struct hw_device_t common;
2365d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2375d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
2385d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * (*prepare)() is called for each frame before composition and is used by
2395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * SurfaceFlinger to determine what composition steps the HWC can handle.
2405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * (*prepare)() can be called more than once, the last call prevails.
2425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * The HWC responds by setting the compositionType field to either
2445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the composition for
2455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * this layer is handled by SurfaceFlinger with OpenGL ES, in the later
2465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * case, the HWC will have to handle this layer's composition.
2475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the
2495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * list's geometry has changed, that is, when more than just the buffer's
2505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * handles have been updated. Typically this happens (but is not limited to)
2515d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * when a window is added, removed, resized or moved.
2525d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * a NULL list parameter or a numHwLayers of zero indicates that the
2545d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * entire composition will be handled by SurfaceFlinger with OpenGL ES.
2555d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2565d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * returns: 0 on success. An negative error code on error. If an error is
2575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * returned, SurfaceFlinger will assume that none of the layer will be
2585d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * handled by the HWC.
2595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
2605d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int (*prepare)(struct hwc_composer_device *dev, hwc_layer_list_t* list);
2615d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2625d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2635d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
2645d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * (*set)() is used in place of eglSwapBuffers(), and assumes the same
2655d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * functionality, except it also commits the work list atomically with
2665d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * the actual eglSwapBuffers().
2675d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2685d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * The list parameter is guaranteed to be the same as the one returned
2695d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * from the last call to (*prepare)().
2705d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2715d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * When this call returns the caller assumes that:
2725d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * - the display will be updated in the near future with the content
2745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   of the work list, without artifacts during the transition from the
2755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   previous frame.
2765d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * - all objects are available for immediate access or destruction, in
2785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   particular, hwc_region_t::rects data and hwc_layer_t::layer's buffer.
2795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   Note that this means that immediately accessing (potentially from a
2805d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   different process) a buffer used in this call will not result in
2815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   screen corruption, the driver must apply proper synchronization or
2825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   scheduling (eg: block the caller, such as gralloc_module_t::lock(),
2835d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   OpenGL ES, Camera, Codecs, etc..., or schedule the caller's work
2845d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *   after the buffer is freed from the actual composition).
2855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * a NULL list parameter or a numHwLayers of zero indicates that the
2875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * entire composition has been handled by SurfaceFlinger with OpenGL ES.
2885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * In this case, (*set)() behaves just like eglSwapBuffers().
2895d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
290fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian     * IMPORTANT NOTE: there is an implicit layer containing opaque black
291fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian     * pixels behind all the layers in the list.
292fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian     * It is the responsibility of the hwcomposer module to make
293fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian     * sure black pixels are output (or blended from).
294fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian     *
2955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * returns: 0 on success. An negative error code on error:
2965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *    HWC_EGL_ERROR: eglGetError() will provide the proper error code
2975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *    Another code for non EGL errors.
2985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
2995d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
3005d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int (*set)(struct hwc_composer_device *dev,
3015d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian                hwc_display_t dpy,
3025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian                hwc_surface_t sur,
3035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian                hwc_layer_list_t* list);
304158549c89405186d9ecaefd3811cfae3949056eeErik Gilling    /*
305158549c89405186d9ecaefd3811cfae3949056eeErik Gilling     * This hook is OPTIONAL.
306158549c89405186d9ecaefd3811cfae3949056eeErik Gilling     *
307d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * If non NULL it will be called by SurfaceFlinger on dumpsys
308158549c89405186d9ecaefd3811cfae3949056eeErik Gilling     */
309158549c89405186d9ecaefd3811cfae3949056eeErik Gilling    void (*dump)(struct hwc_composer_device* dev, char *buff, int buff_len);
3105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
311d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian    /*
312d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * This hook is OPTIONAL.
313d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     *
314d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * (*registerProcs)() registers a set of callbacks the h/w composer HAL
315d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * can later use. It is FORBIDDEN to call any of the callbacks from
316d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * within registerProcs(). registerProcs() must save the hwc_procs_t pointer
317d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * which is needed when calling a registered callback.
318d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * Each call to registerProcs replaces the previous set of callbacks.
319d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * registerProcs is called with NULL to unregister all callbacks.
320d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     *
321d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * Any of the callbacks can be NULL, in which case the corresponding
322d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * functionality is not supported.
323d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     */
324d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian    void (*registerProcs)(struct hwc_composer_device* dev,
325d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian            hwc_procs_t const* procs);
326d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian
327d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian    void* reserved_proc[6];
328e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling
3295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_composer_device_t;
3305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** convenience API for opening and closing a device */
3335d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3345d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianstatic inline int hwc_open(const struct hw_module_t* module,
3355d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian        hwc_composer_device_t** device) {
3365d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    return module->methods->open(module,
3375d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian            HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device);
3385d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}
3395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianstatic inline int hwc_close(hwc_composer_device_t* device) {
3415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    return device->common.close(&device->common);
3425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}
3435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/
3465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__END_DECLS
3485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */
350