hwcomposer.h revision d479ad22a0254fa0b5358fe82fa404e3e96c631a
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 27e291f71e0a25ac9bb39fb754c599b710ab8f59d5Mathias Agopian#include <hardware/hwcomposer_defs.h> 28e291f71e0a25ac9bb39fb754c599b710ab8f59d5Mathias Agopian 295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__BEGIN_DECLS 305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/ 32e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling 33d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall/* for compatibility */ 34b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian#define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 35b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian#define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 3681c323dd54d5f0ea1e75ab392187608049b2326cMathias Agopian#define HWC_API_VERSION HWC_DEVICE_API_VERSION 37e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling 38d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall/* Users of this header can define HWC_REMOVE_DEPRECATED_VERSIONS to test that 39d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * they still work with just the current version declared, before the 40d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * deprecated versions are actually removed. 41d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 42d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * To find code that still depends on the old versions, set the #define to 1 43d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * here. Code that explicitly sets it to zero (rather than simply not defining 44d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * it) will still see the old versions. 45d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 46d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#if !defined(HWC_REMOVE_DEPRECATED_VERSIONS) 47d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#define HWC_REMOVE_DEPRECATED_VERSIONS 0 48d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#endif 49d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 50d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall/*****************************************************************************/ 51d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 525d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** 535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * The id of this module 545d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 555d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define HWC_HARDWARE_MODULE_ID "hwcomposer" 565d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** 585d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Name of the sensors device to open 595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 605d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define HWC_HARDWARE_COMPOSER "composer" 615d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 62d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstruct hwc_composer_device_1; 63d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_methods_1 { 64b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian 65b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 66b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * eventControl(..., event, enabled) 67b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * Enables or disables h/w composer events. 68b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 69b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * eventControl can be called from any thread and takes effect 70b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * immediately. 71b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 72b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * Supported events are: 73b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * HWC_EVENT_VSYNC 74b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 75b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * returns -EINVAL if the "event" parameter is not one of the value above 76b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * or if the "enabled" parameter is not 0 or 1. 77b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 78b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian 79b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian int (*eventControl)( 80d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall struct hwc_composer_device_1* dev, int event, int enabled); 81b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian 82d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_methods_1_t; 83b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian 845d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_rect { 855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int left; 865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int top; 875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int right; 885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int bottom; 895d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_rect_t; 905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_region { 925d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian size_t numRects; 935d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_rect_t const* rects; 945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_region_t; 955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 96eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopiantypedef struct hwc_color { 97eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t r; 98eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t g; 99eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t b; 100eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t a; 101eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian} hwc_color_t; 102eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 103d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_layer_1 { 1045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 105eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * initially set to HWC_FRAMEBUFFER or HWC_BACKGROUND. 106eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_FRAMEBUFFER 107eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * indicates the layer will be drawn into the framebuffer 108eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * using OpenGL ES. 109eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * The HWC can toggle this value to HWC_OVERLAY, to indicate 110eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * it will handle the layer. 111eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 112eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_BACKGROUND 113eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * indicates this is a special "background" layer. The only valid 114eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * field is backgroundColor. HWC_BACKGROUND can only be used with 115eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_API_VERSION >= 0.2 116eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * The HWC can toggle this value to HWC_FRAMEBUFFER, to indicate 117eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * it CANNOT handle the background color 118eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 1195d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 1205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int32_t compositionType; 1215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* see hwc_layer_t::hints above */ 1235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t hints; 1245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* see hwc_layer_t::flags above */ 1265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t flags; 1275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 128eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian union { 129eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* color of the background. hwc_color_t.a is ignored */ 130eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_color_t backgroundColor; 131eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 132eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian struct { 133eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* handle of buffer to compose. This handle is guaranteed to have been 134eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * allocated from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. If 135eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the layer's handle is unchanged across two consecutive prepare calls and 136eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the HWC_GEOMETRY_CHANGED flag is not set for the second call then the 137eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWComposer implementation may assume that the contents of the buffer have 138eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * not changed. */ 139eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian buffer_handle_t handle; 140eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 141eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* transformation to apply to the buffer during composition */ 142eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint32_t transform; 143eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 144eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* blending to apply during composition */ 145eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian int32_t blending; 146eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 147eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* area of the source to consider, the origin is the top-left corner of 148eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the buffer */ 149eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_rect_t sourceCrop; 150eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 151eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* where to composite the sourceCrop onto the display. The sourceCrop 152eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * is scaled using linear filtering to the displayFrame. The origin is the 153eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * top-left corner of the screen. 154eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 155eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_rect_t displayFrame; 156eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 157eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* visible region in screen space. The origin is the 158eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * top-left corner of the screen. 159eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * The visible region INCLUDES areas overlapped by a translucent layer. 160eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 161eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_region_t visibleRegionScreen; 162d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 163d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall /* Sync fence object that will be signaled when the buffer's 164d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * contents are available. May be -1 if the contents are already 165d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * available. This field is only valid during set(), and should be 166d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * ignored during prepare(). The set() call must not wait for the 167d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * fence to be signaled before returning, but the HWC must wait for 168d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * all buffers to be signaled before reading from them. 169d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 170d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * The HWC takes ownership of the acquireFenceFd and is responsible 171d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * for closing it when no longer needed. 172d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 173d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int acquireFenceFd; 174d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 175d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall /* During set() the HWC must set this field to a file descriptor for 176d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * a sync fence object that will signal after the HWC has finished 177d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * reading from the buffer. The field is ignored by prepare(). Each 178d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * layer should have a unique file descriptor, even if more than one 179d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * refer to the same underlying fence object; this allows each to be 180d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * closed independently. 181d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 182d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * If buffer reads can complete at significantly different times, 183d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * then using independent fences is preferred. For example, if the 184d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * HWC handles some layers with a blit engine and others with 185d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * overlays, then the blit layers can be reused immediately after 186d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * the blit completes, but the overlay layers can't be reused until 187d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * a subsequent frame has been displayed. 188d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 189d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * The HWC client taks ownership of the releaseFenceFd and is 190d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * responsible for closing it when no longer needed. 191d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 192d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int releaseFenceFd; 193eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian }; 194eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian }; 1955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 196d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall /* Allow for expansion w/o breaking binary compatibility. 197d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * Pad layer to 96 bytes, assuming 32-bit pointers. 198d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 199d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int32_t reserved[24 - 18]; 200d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 201d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_layer_1_t; 2025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 2045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * hwc_layer_list_t::flags values 2055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 2065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 2075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 2085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list 209d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * passed to (*prepare)() has changed by more than just the buffer handles 210d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * and acquire fences. 2115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 2125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_GEOMETRY_CHANGED = 0x00000001, 2135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 2145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 215871815b5f144048b63a18ef764f82e89394899faLouis Huemiller/* 216871815b5f144048b63a18ef764f82e89394899faLouis Huemiller * List of layers. 217871815b5f144048b63a18ef764f82e89394899faLouis Huemiller * The handle members of hwLayers elements must be unique. 218871815b5f144048b63a18ef764f82e89394899faLouis Huemiller */ 219d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_layer_list_1 { 2205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t flags; 2215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian size_t numHwLayers; 222d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_layer_1_t hwLayers[0]; 223d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_layer_list_1_t; 2245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* This represents a display, typically an EGLDisplay object */ 2265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef void* hwc_display_t; 2275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* This represents a surface, typically an EGLSurface object */ 2295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef void* hwc_surface_t; 2305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 232d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/* see hwc_composer_device::registerProcs() 233d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * Any of the callbacks can be NULL, in which case the corresponding 234d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * functionality is not supported. 235d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 236d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopiantypedef struct hwc_procs { 237d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian /* 238d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * (*invalidate)() triggers a screen refresh, in particular prepare and set 239d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * will be called shortly after this call is made. Note that there is 240d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * NO GUARANTEE that the screen refresh will happen after invalidate() 241d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * returns (in particular, it could happen before). 242d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and 243d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * it is safe to call invalidate() from any of hwc_composer_device 244d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * hooks, unless noted otherwise. 245d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 246d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian void (*invalidate)(struct hwc_procs* procs); 247b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian 248b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 249b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * (*vsync)() is called by the h/w composer HAL when a vsync event is 250b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * received and HWC_EVENT_VSYNC is enabled (see: hwc_event_control). 251b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 252b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * the "zero" parameter must always be 0. 2536b7adef0ef38f568099eab38d6865f402c92235bJamie Gennis * the "timestamp" parameter is the system monotonic clock timestamp in 2546b7adef0ef38f568099eab38d6865f402c92235bJamie Gennis * nanosecond of when the vsync event happened. 255b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 256b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. 257b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 258b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * It is expected that vsync() is called from a thread of at least 259eb67160b995a504dd70a8f29d228ec837341eb07Mathias Agopian * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, 260b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * typically less than 0.5 ms. 261b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 2626d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling 2636d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation 2646d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * can either stop or continue to process VSYNC events, but must not 2656d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * crash or cause other problems. 2666d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * 267b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 268b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian void (*vsync)(struct hwc_procs* procs, int zero, int64_t timestamp); 269d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian} hwc_procs_t; 270d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 271d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 272d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/*****************************************************************************/ 2735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_module { 2755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian struct hw_module_t common; 2765d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_module_t; 2775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 278d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_composer_device_1 { 2795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian struct hw_device_t common; 2805d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 2815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 2825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() is called for each frame before composition and is used by 2835d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * SurfaceFlinger to determine what composition steps the HWC can handle. 2845d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() can be called more than once, the last call prevails. 2865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * The HWC responds by setting the compositionType field to either 2885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the composition for 2895d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * this layer is handled by SurfaceFlinger with OpenGL ES, in the later 2905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * case, the HWC will have to handle this layer's composition. 2915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2925d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the 2935d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * list's geometry has changed, that is, when more than just the buffer's 2945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * handles have been updated. Typically this happens (but is not limited to) 2955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * when a window is added, removed, resized or moved. 2965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 2975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * a NULL list parameter or a numHwLayers of zero indicates that the 2985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * entire composition will be handled by SurfaceFlinger with OpenGL ES. 2995d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3005d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returns: 0 on success. An negative error code on error. If an error is 3015d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returned, SurfaceFlinger will assume that none of the layer will be 3025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * handled by the HWC. 3035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 304d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*prepare)(struct hwc_composer_device_1 *dev, 305d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_layer_list_1_t* list); 3065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 3085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*set)() is used in place of eglSwapBuffers(), and assumes the same 3095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * functionality, except it also commits the work list atomically with 3105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * the actual eglSwapBuffers(). 3115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * The list parameter is guaranteed to be the same as the one returned 3135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * from the last call to (*prepare)(). 3145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3155d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * When this call returns the caller assumes that: 3165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * - the display will be updated in the near future with the content 3185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * of the work list, without artifacts during the transition from the 3195d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * previous frame. 3205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * - all objects are available for immediate access or destruction, in 3225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * particular, hwc_region_t::rects data and hwc_layer_t::layer's buffer. 3235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Note that this means that immediately accessing (potentially from a 3245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * different process) a buffer used in this call will not result in 3255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * screen corruption, the driver must apply proper synchronization or 3265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * scheduling (eg: block the caller, such as gralloc_module_t::lock(), 3275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * OpenGL ES, Camera, Codecs, etc..., or schedule the caller's work 3285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * after the buffer is freed from the actual composition). 3295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * a NULL list parameter or a numHwLayers of zero indicates that the 3315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * entire composition has been handled by SurfaceFlinger with OpenGL ES. 3325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * In this case, (*set)() behaves just like eglSwapBuffers(). 3335d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 33471212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * dpy, sur, and list are set to NULL to indicate that the screen is 33571212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * turning off. This happens WITHOUT prepare() being called first. 33671212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * This is a good time to free h/w resources and/or power 33771212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * the relevant h/w blocks down. 33871212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * 339fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * IMPORTANT NOTE: there is an implicit layer containing opaque black 340fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * pixels behind all the layers in the list. 341fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * It is the responsibility of the hwcomposer module to make 342fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * sure black pixels are output (or blended from). 343fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * 3445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returns: 0 on success. An negative error code on error: 3455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_EGL_ERROR: eglGetError() will provide the proper error code 3465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Another code for non EGL errors. 3475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 349d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*set)(struct hwc_composer_device_1 *dev, 3505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_display_t dpy, 3515d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_surface_t sur, 352d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_layer_list_1_t* list); 353d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 354158549c89405186d9ecaefd3811cfae3949056eeErik Gilling /* 355b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * This field is OPTIONAL and can be NULL. 356158549c89405186d9ecaefd3811cfae3949056eeErik Gilling * 357d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * If non NULL it will be called by SurfaceFlinger on dumpsys 358158549c89405186d9ecaefd3811cfae3949056eeErik Gilling */ 359d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); 3605d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 361d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian /* 362b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * This field is OPTIONAL and can be NULL. 363d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * 364d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * (*registerProcs)() registers a set of callbacks the h/w composer HAL 365d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * can later use. It is FORBIDDEN to call any of the callbacks from 366d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * within registerProcs(). registerProcs() must save the hwc_procs_t pointer 367d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * which is needed when calling a registered callback. 368d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * Each call to registerProcs replaces the previous set of callbacks. 369d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * registerProcs is called with NULL to unregister all callbacks. 370d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * 371d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * Any of the callbacks can be NULL, in which case the corresponding 372d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * functionality is not supported. 373d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 374d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall void (*registerProcs)(struct hwc_composer_device_1* dev, 375d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian hwc_procs_t const* procs); 376d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 377eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* 378b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * This field is OPTIONAL and can be NULL. 379eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 380eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * Used to retrieve information about the h/w composer 381eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 382eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * Returns 0 on success or -errno on error. 383eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 384d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*query)(struct hwc_composer_device_1* dev, int what, int* value); 385eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 386b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 387b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * Reserved for future use. Must be NULL. 388b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 389b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian void* reserved_proc[4]; 390eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 391b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 392b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * This field is OPTIONAL and can be NULL. 393b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 394d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_methods_1_t const *methods; 3955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 396d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_composer_device_1_t; 3975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** convenience API for opening and closing a device */ 3995d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 400d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstatic inline int hwc_open_1(const struct hw_module_t* module, 401d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_composer_device_1_t** device) { 4025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian return module->methods->open(module, 4035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); 4045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} 4055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 406d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstatic inline int hwc_close_1(hwc_composer_device_1_t* device) { 4075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian return device->common.close(&device->common); 4085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} 4095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 4105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/ 4115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 412d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#if !HWC_REMOVE_DEPRECATED_VERSIONS 413d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#include <hardware/hwcomposer_v0.h> 414d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#endif 415d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 4165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__END_DECLS 4175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 4185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ 419