hwcomposer.h revision 81c323dd54d5f0ea1e75ab392187608049b2326c
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 3181c323dd54d5f0ea1e75ab392187608049b2326cMathias Agopian#define HWC_DEVICE_API_VERSION HARDWARE_DEVICE_API_VERSION(0, 2) 3281c323dd54d5f0ea1e75ab392187608049b2326cMathias Agopian#define HWC_MODULE_API_VERSION HARDWARE_MODULE_API_VERSION(0, 1) 3381c323dd54d5f0ea1e75ab392187608049b2326cMathias Agopian// for compatibility 3481c323dd54d5f0ea1e75ab392187608049b2326cMathias Agopian#define HWC_API_VERSION HWC_DEVICE_API_VERSION 35e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling 365d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** 375d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * The id of this module 385d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define HWC_HARDWARE_MODULE_ID "hwcomposer" 405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** 425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Name of the sensors device to open 435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define HWC_HARDWARE_COMPOSER "composer" 455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* hwc_composer_device_t::set failed in EGL */ 495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_EGL_ERROR = -1 505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 515d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 525d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::hints values 545d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Hints are set by the HAL and read by SurfaceFlinger 555d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 565d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 58cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger 595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * that it should triple buffer this layer. Typically HWC does this when 605d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * the layer will be unavailable for use for an extended period of time, 615d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * e.g. if the display will be fetching data directly from the layer and 625d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * the layer can not be modified until after the next set(). 635d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 64cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian HWC_HINT_TRIPLE_BUFFER = 0x00000001, 65cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian 66cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian /* 67cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the 68cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian * framebuffer with transparent pixels where this layer would be. 69cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian * SurfaceFlinger will only honor this flag when the layer has no blending 70cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian * 71cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian */ 72cdd44a0db36749af5036e903e4867b279ef420dfMathias Agopian HWC_HINT_CLEAR_FB = 0x00000002 735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 765d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::flags values 775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Flags are set by SurfaceFlinger and read by the HAL 785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 805d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL 825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * shall not consider this layer for composition as it will be handled 835d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY). 845d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_SKIP_LAYER = 0x00000001, 865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 895d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::compositionType values 905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 925d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ 935d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_FRAMEBUFFER = 0, 945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* this layer will be handled in the HWC */ 965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_OVERLAY = 1, 97eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 98eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* this is the background layer. it's used to set the background color. 99eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * there is only a single background layer */ 100eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian HWC_BACKGROUND = 2, 1015d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 1025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 1045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::blending values 1055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 1065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 1075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* no blending */ 1085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_BLENDING_NONE = 0x0100, 1095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* ONE / ONE_MINUS_SRC_ALPHA */ 1115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_BLENDING_PREMULT = 0x0105, 1125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ 1145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_BLENDING_COVERAGE = 0x0405 1155d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 1165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 1185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_t::transform values 1195d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 1205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 1215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* flip source image horizontally */ 1225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, 1235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* flip source image vertically */ 1245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, 1255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* rotate source image 90 degrees clock-wise */ 1265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, 1275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* rotate source image 180 degrees */ 1285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, 1295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* rotate source image 270 degrees clock-wise */ 1305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, 1315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 1325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 133eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian/* attributes queriable with query() */ 134eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopianenum { 135eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* must return 1 if the background layer is supported, 0 otherwise */ 136eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian HWC_BACKGROUND_LAYER_SUPPORTED = 0, 137eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian}; 138eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 1395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_rect { 1405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int left; 1415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int top; 1425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int right; 1435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int bottom; 1445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_rect_t; 1455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_region { 1475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian size_t numRects; 1485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_rect_t const* rects; 1495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_region_t; 1505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 151eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopiantypedef struct hwc_color { 152eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t r; 153eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t g; 154eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t b; 155eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t a; 156eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian} hwc_color_t; 157eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 1585d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_layer { 1595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 160eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * initially set to HWC_FRAMEBUFFER or HWC_BACKGROUND. 161eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_FRAMEBUFFER 162eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * indicates the layer will be drawn into the framebuffer 163eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * using OpenGL ES. 164eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * The HWC can toggle this value to HWC_OVERLAY, to indicate 165eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * it will handle the layer. 166eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 167eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_BACKGROUND 168eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * indicates this is a special "background" layer. The only valid 169eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * field is backgroundColor. HWC_BACKGROUND can only be used with 170eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_API_VERSION >= 0.2 171eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * The HWC can toggle this value to HWC_FRAMEBUFFER, to indicate 172eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * it CANNOT handle the background color 173eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 1745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 1755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int32_t compositionType; 1765d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* see hwc_layer_t::hints above */ 1785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t hints; 1795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1805d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* see hwc_layer_t::flags above */ 1815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t flags; 1825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 183eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian union { 184eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* color of the background. hwc_color_t.a is ignored */ 185eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_color_t backgroundColor; 186eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 187eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian struct { 188eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 189eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* handle of buffer to compose. This handle is guaranteed to have been 190eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * allocated from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. If 191eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the layer's handle is unchanged across two consecutive prepare calls and 192eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the HWC_GEOMETRY_CHANGED flag is not set for the second call then the 193eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWComposer implementation may assume that the contents of the buffer have 194eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * not changed. */ 195eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian buffer_handle_t handle; 196eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 197eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* transformation to apply to the buffer during composition */ 198eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint32_t transform; 199eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 200eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* blending to apply during composition */ 201eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian int32_t blending; 202eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 203eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* area of the source to consider, the origin is the top-left corner of 204eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the buffer */ 205eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_rect_t sourceCrop; 206eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 207eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* where to composite the sourceCrop onto the display. The sourceCrop 208eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * is scaled using linear filtering to the displayFrame. The origin is the 209eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * top-left corner of the screen. 210eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 211eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_rect_t displayFrame; 212eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 213eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* visible region in screen space. The origin is the 214eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * top-left corner of the screen. 215eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * The visible region INCLUDES areas overlapped by a translucent layer. 216eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 217eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_region_t visibleRegionScreen; 218eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian }; 219eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian }; 2205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_layer_t; 2215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 2245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_list_t::flags values 2255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 2265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 2275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 2285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list 2295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * passed to (*prepare)() has changed by more than just the buffer handles. 2305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 2315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_GEOMETRY_CHANGED = 0x00000001, 2325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 2335d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 234871815b5f144048b63a18ef764f82e89394899faLouis Huemiller/* 235871815b5f144048b63a18ef764f82e89394899faLouis Huemiller * List of layers. 236871815b5f144048b63a18ef764f82e89394899faLouis Huemiller * The handle members of hwLayers elements must be unique. 237871815b5f144048b63a18ef764f82e89394899faLouis Huemiller */ 2385d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_layer_list { 2395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t flags; 2405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian size_t numHwLayers; 2415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_layer_t hwLayers[0]; 2425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_layer_list_t; 2435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* This represents a display, typically an EGLDisplay object */ 2455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef void* hwc_display_t; 2465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* This represents a surface, typically an EGLSurface object */ 2485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef void* hwc_surface_t; 2495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 251d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/* see hwc_composer_device::registerProcs() 252d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * Any of the callbacks can be NULL, in which case the corresponding 253d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * functionality is not supported. 254d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 255d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopiantypedef struct hwc_procs { 256d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian /* 257d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * (*invalidate)() triggers a screen refresh, in particular prepare and set 258d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * will be called shortly after this call is made. Note that there is 259d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * NO GUARANTEE that the screen refresh will happen after invalidate() 260d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * returns (in particular, it could happen before). 261d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and 262d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * it is safe to call invalidate() from any of hwc_composer_device 263d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * hooks, unless noted otherwise. 264d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 265d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian void (*invalidate)(struct hwc_procs* procs); 266d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian} hwc_procs_t; 267d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 268d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 269d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/*****************************************************************************/ 2705d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2715d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_module { 2725d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian struct hw_module_t common; 2735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_module_t; 2745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2765d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_composer_device { 2775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian struct hw_device_t common; 2785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 2805d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() is called for each frame before composition and is used by 2815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * SurfaceFlinger to determine what composition steps the HWC can handle. 2825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2835d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() can be called more than once, the last call prevails. 2845d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * The HWC responds by setting the compositionType field to either 2865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the composition for 2875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * this layer is handled by SurfaceFlinger with OpenGL ES, in the later 2885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * case, the HWC will have to handle this layer's composition. 2895d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the 2915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * list's geometry has changed, that is, when more than just the buffer's 2925d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * handles have been updated. Typically this happens (but is not limited to) 2935d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * when a window is added, removed, resized or moved. 2945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * a NULL list parameter or a numHwLayers of zero indicates that the 2965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * entire composition will be handled by SurfaceFlinger with OpenGL ES. 2975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returns: 0 on success. An negative error code on error. If an error is 2995d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returned, SurfaceFlinger will assume that none of the layer will be 3005d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * handled by the HWC. 3015d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 3025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int (*prepare)(struct hwc_composer_device *dev, hwc_layer_list_t* list); 3035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 3065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*set)() is used in place of eglSwapBuffers(), and assumes the same 3075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * functionality, except it also commits the work list atomically with 3085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * the actual eglSwapBuffers(). 3095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * The list parameter is guaranteed to be the same as the one returned 3115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * from the last call to (*prepare)(). 3125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * When this call returns the caller assumes that: 3145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3155d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * - the display will be updated in the near future with the content 3165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * of the work list, without artifacts during the transition from the 3175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * previous frame. 3185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3195d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * - all objects are available for immediate access or destruction, in 3205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * particular, hwc_region_t::rects data and hwc_layer_t::layer's buffer. 3215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Note that this means that immediately accessing (potentially from a 3225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * different process) a buffer used in this call will not result in 3235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * screen corruption, the driver must apply proper synchronization or 3245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * scheduling (eg: block the caller, such as gralloc_module_t::lock(), 3255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * OpenGL ES, Camera, Codecs, etc..., or schedule the caller's work 3265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * after the buffer is freed from the actual composition). 3275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * a NULL list parameter or a numHwLayers of zero indicates that the 3295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * entire composition has been handled by SurfaceFlinger with OpenGL ES. 3305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * In this case, (*set)() behaves just like eglSwapBuffers(). 3315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 33271212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * dpy, sur, and list are set to NULL to indicate that the screen is 33371212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * turning off. This happens WITHOUT prepare() being called first. 33471212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * This is a good time to free h/w resources and/or power 33571212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * the relevant h/w blocks down. 33671212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * 337fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * IMPORTANT NOTE: there is an implicit layer containing opaque black 338fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * pixels behind all the layers in the list. 339fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * It is the responsibility of the hwcomposer module to make 340fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * sure black pixels are output (or blended from). 341fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * 3425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returns: 0 on success. An negative error code on error: 3435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_EGL_ERROR: eglGetError() will provide the proper error code 3445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Another code for non EGL errors. 3455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 3475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int (*set)(struct hwc_composer_device *dev, 3485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_display_t dpy, 3495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_surface_t sur, 3505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_layer_list_t* list); 351158549c89405186d9ecaefd3811cfae3949056eeErik Gilling /* 352158549c89405186d9ecaefd3811cfae3949056eeErik Gilling * This hook is OPTIONAL. 353158549c89405186d9ecaefd3811cfae3949056eeErik Gilling * 354d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * If non NULL it will be called by SurfaceFlinger on dumpsys 355158549c89405186d9ecaefd3811cfae3949056eeErik Gilling */ 356158549c89405186d9ecaefd3811cfae3949056eeErik Gilling void (*dump)(struct hwc_composer_device* dev, char *buff, int buff_len); 3575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 358d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian /* 359d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * This hook is OPTIONAL. 360d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * 361d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * (*registerProcs)() registers a set of callbacks the h/w composer HAL 362d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * can later use. It is FORBIDDEN to call any of the callbacks from 363d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * within registerProcs(). registerProcs() must save the hwc_procs_t pointer 364d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * which is needed when calling a registered callback. 365d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * Each call to registerProcs replaces the previous set of callbacks. 366d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * registerProcs is called with NULL to unregister all callbacks. 367d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * 368d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * Any of the callbacks can be NULL, in which case the corresponding 369d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * functionality is not supported. 370d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 371d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian void (*registerProcs)(struct hwc_composer_device* dev, 372d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian hwc_procs_t const* procs); 373d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 374eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* 375eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * This hook is OPTIONAL. 376eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 377eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * Used to retrieve information about the h/w composer 378eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 379eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * Returns 0 on success or -errno on error. 380eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 381eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian int (*query)(struct hwc_composer_device* dev, int what, int* value); 382eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 383eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 384eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian void* reserved_proc[5]; 385e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling 3865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_composer_device_t; 3875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3895d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** convenience API for opening and closing a device */ 3905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianstatic inline int hwc_open(const struct hw_module_t* module, 3925d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_composer_device_t** device) { 3935d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian return module->methods->open(module, 3945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); 3955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} 3965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianstatic inline int hwc_close(hwc_composer_device_t* device) { 3985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian return device->common.close(&device->common); 3995d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} 4005d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 4015d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 4025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/ 4035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 4045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__END_DECLS 4055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 4065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ 407