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 625d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_rect { 635d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int left; 645d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int top; 655d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int right; 665d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int bottom; 675d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_rect_t; 685d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 695d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_region { 705d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian size_t numRects; 715d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian hwc_rect_t const* rects; 725d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_region_t; 735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 74eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopiantypedef struct hwc_color { 75eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t r; 76eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t g; 77eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t b; 78eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint8_t a; 79eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian} hwc_color_t; 80eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 81d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_layer_1 { 825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 83d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * Initially set to HWC_FRAMEBUFFER, HWC_BACKGROUND, or 84d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * HWC_FRAMEBUFFER_TARGET. 85d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * 86eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_FRAMEBUFFER 87d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * Indicates the layer will be drawn into the framebuffer 88d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * using OpenGL ES. The HWC can toggle this value to HWC_OVERLAY to 89d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * indicate it will handle the layer. 90eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 91eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_BACKGROUND 92d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * Indicates this is a special "background" layer. The only valid field 93d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * is backgroundColor. The HWC can toggle this value to HWC_FRAMEBUFFER 94d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * to indicate it CANNOT handle the background color. 95d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * 96d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * HWC_FRAMEBUFFER_TARGET 97d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * Indicates this layer is the framebuffer surface used as the target of 98d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY 99d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and 1006b01e2eaf7fb7f167730c0bde1b55ae7ac928060Jesse Hall * this layer should be ignored during set(). 101eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 102d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * This flag (and the framebuffer surface layer) will only be used if the 103d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, 104d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * the OpenGL ES target surface is communicated by the (dpy, sur) fields 105d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * in hwc_compositor_device_1_t. 1065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 1075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int32_t compositionType; 1085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* see hwc_layer_t::hints above */ 1105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t hints; 1115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 1125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* see hwc_layer_t::flags above */ 1135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t flags; 1145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 115eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian union { 116eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* color of the background. hwc_color_t.a is ignored */ 117eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_color_t backgroundColor; 118eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 119eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian struct { 120eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* handle of buffer to compose. This handle is guaranteed to have been 121eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * allocated from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. If 122eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the layer's handle is unchanged across two consecutive prepare calls and 123eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the HWC_GEOMETRY_CHANGED flag is not set for the second call then the 124eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWComposer implementation may assume that the contents of the buffer have 125eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * not changed. */ 126eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian buffer_handle_t handle; 127eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 128eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* transformation to apply to the buffer during composition */ 129eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint32_t transform; 130eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 131eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* blending to apply during composition */ 132eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian int32_t blending; 133eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 134eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* area of the source to consider, the origin is the top-left corner of 135eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * the buffer */ 136eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_rect_t sourceCrop; 137eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 138eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* where to composite the sourceCrop onto the display. The sourceCrop 139eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * is scaled using linear filtering to the displayFrame. The origin is the 140eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * top-left corner of the screen. 141eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 142eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_rect_t displayFrame; 143eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 144eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* visible region in screen space. The origin is the 145eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * top-left corner of the screen. 146eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * The visible region INCLUDES areas overlapped by a translucent layer. 147eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 148eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_region_t visibleRegionScreen; 149d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 150d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall /* Sync fence object that will be signaled when the buffer's 151d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * contents are available. May be -1 if the contents are already 152d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * available. This field is only valid during set(), and should be 153d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * ignored during prepare(). The set() call must not wait for the 154d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * fence to be signaled before returning, but the HWC must wait for 155d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * all buffers to be signaled before reading from them. 156d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 1570a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * HWC_FRAMEBUFFER layers will never have an acquire fence, since 1580a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * reads from them are complete before the framebuffer is ready for 1590a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * display. 1600a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 161d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * The HWC takes ownership of the acquireFenceFd and is responsible 162d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * for closing it when no longer needed. 163d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 164d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int acquireFenceFd; 165d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 166d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall /* During set() the HWC must set this field to a file descriptor for 167d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * a sync fence object that will signal after the HWC has finished 168d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * reading from the buffer. The field is ignored by prepare(). Each 169d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * layer should have a unique file descriptor, even if more than one 170d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * refer to the same underlying fence object; this allows each to be 171d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * closed independently. 172d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 173d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * If buffer reads can complete at significantly different times, 174d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * then using independent fences is preferred. For example, if the 175d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * HWC handles some layers with a blit engine and others with 176d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * overlays, then the blit layers can be reused immediately after 177d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * the blit completes, but the overlay layers can't be reused until 178d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * a subsequent frame has been displayed. 179d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 1800a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't 1810a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * produce a release fence for them. The releaseFenceFd will be -1 1820a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * for these layers when set() is called. 1830a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 184d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * The HWC client taks ownership of the releaseFenceFd and is 185d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * responsible for closing it when no longer needed. 186d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 187d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int releaseFenceFd; 188eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian }; 189eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian }; 1905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 191d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall /* Allow for expansion w/o breaking binary compatibility. 192d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * Pad layer to 96 bytes, assuming 32-bit pointers. 193d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 194d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int32_t reserved[24 - 18]; 195d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 196d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_layer_1_t; 1975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 198f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall/* This represents a display, typically an EGLDisplay object */ 199f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef void* hwc_display_t; 200f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall 201f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall/* This represents a surface, typically an EGLSurface object */ 202f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef void* hwc_surface_t; 203f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall 2045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 205f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * hwc_display_contents_1_t::flags values 2065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 2075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 2085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 2095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list 210d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * passed to (*prepare)() has changed by more than just the buffer handles 211d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * and acquire fences. 2125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 2135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_GEOMETRY_CHANGED = 0x00000001, 2145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 2155d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 216871815b5f144048b63a18ef764f82e89394899faLouis Huemiller/* 217f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * Description of the contents to output on a display. 218f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * 219f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * This is the top-level structure passed to the prepare and set calls to 220f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * negotiate and commit the composition of a display image. 221871815b5f144048b63a18ef764f82e89394899faLouis Huemiller */ 222f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef struct hwc_display_contents_1 { 223f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall /* File descriptor referring to a Sync HAL fence object which will signal 2247cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * when this composition is retired. For a physical display, a composition 2257cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * is retired when it has been replaced on-screen by a subsequent set. For 2267cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * a virtual display, the composition is retired when the writes to 2277cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * outputBuffer are complete and can be read. The fence object is created 2287cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * and returned by the set call; this field will be -1 on entry to prepare 2297cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * and set. SurfaceFlinger will close the returned file descriptor. 230f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall */ 2317cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall int retireFenceFd; 232f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall 2337cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall union { 2347cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ 2357cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall struct { 2367cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES 2377cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to 2387cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * prepare. The set call should commit this surface atomically to 2397cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * the display along with any overlay layers. 2407cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall */ 2417cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall hwc_display_t dpy; 2427cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall hwc_surface_t sur; 2437cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall }; 2447cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall 2457cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* Fields only relevant for HWC_DEVICE_VERSION_1_2 and later. */ 2467cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall struct { 2477cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* outbuf is the buffer that receives the composed image for 2487cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * virtual displays. Writes to the outbuf must wait until 2497cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * outbufAcquireFenceFd signals. A fence that will signal when 2507cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * writes to outbuf are complete should be returned in 2517cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * retireFenceFd. 2527cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * 2537cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * For physical displays, outbuf will be NULL. 2547cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall */ 2557cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall buffer_handle_t outbuf; 2567cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall 2577cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* File descriptor for a fence that will signal when outbuf is 2587cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * ready to be written. The h/w composer is responsible for closing 2597cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * this when no longer needed. 2607cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * 2617cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * Will be -1 whenever outbuf is NULL, or when the outbuf can be 2627cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * written immediately. 2637cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall */ 2647cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall int outbufAcquireFenceFd; 2657cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall }; 2667cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall }; 267f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall 268f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall /* List of layers that will be composed on the display. The buffer handles 269ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * in the list will be unique. If numHwLayers is 0, all composition will be 270ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * performed by SurfaceFlinger. 271f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall */ 2725d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t flags; 2735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian size_t numHwLayers; 274d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_layer_1_t hwLayers[0]; 2755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 276f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall} hwc_display_contents_1_t; 2775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 278d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/* see hwc_composer_device::registerProcs() 2790a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * All of the callbacks are required and non-NULL unless otherwise noted. 280d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 281d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopiantypedef struct hwc_procs { 282d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian /* 283d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * (*invalidate)() triggers a screen refresh, in particular prepare and set 284d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * will be called shortly after this call is made. Note that there is 285d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * NO GUARANTEE that the screen refresh will happen after invalidate() 286d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * returns (in particular, it could happen before). 287d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and 288d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * it is safe to call invalidate() from any of hwc_composer_device 289d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * hooks, unless noted otherwise. 290d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 2910a0a41653d82552e601980c8793fcb07e3863044Jesse Hall void (*invalidate)(const struct hwc_procs* procs); 292b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian 293b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 294b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * (*vsync)() is called by the h/w composer HAL when a vsync event is 295f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * received and HWC_EVENT_VSYNC is enabled on a display 296f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * (see: hwc_event_control). 297b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 2982c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * the "disp" parameter indicates which display the vsync event is for. 2996b7adef0ef38f568099eab38d6865f402c92235bJamie Gennis * the "timestamp" parameter is the system monotonic clock timestamp in 3006b7adef0ef38f568099eab38d6865f402c92235bJamie Gennis * nanosecond of when the vsync event happened. 301b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 302b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. 303b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 304b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * It is expected that vsync() is called from a thread of at least 305eb67160b995a504dd70a8f29d228ec837341eb07Mathias Agopian * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, 306b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * typically less than 0.5 ms. 307b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 3086d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling 3096d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation 3106d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * can either stop or continue to process VSYNC events, but must not 3116d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * crash or cause other problems. 312b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 3132c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); 3142c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall 3152c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall /* 3162c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * (*hotplug)() is called by the h/w composer HAL when a display is 3172c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * connected or disconnected. The PRIMARY display is always connected and 3182c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * the hotplug callback should not be called for it. 3192c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 3202c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * The disp parameter indicates which display type this event is for. 3212c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * The connected parameter indicates whether the display has just been 3222c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * connected (1) or disconnected (0). 3232c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 3242c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * The hotplug() callback may call back into the h/w composer on the same 3252c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * thread to query refresh rate and dpi for the display. Additionally, 3262c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * other threads may be calling into the h/w composer while the callback 3272c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * is in progress. 3282c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 329d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * The h/w composer must serialize calls to the hotplug callback; only 330d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * one thread may call it at a time. 331d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * 3322c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * This callback will be NULL if the h/w composer is using 3332c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * HWC_DEVICE_API_VERSION_1_0. 3342c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall */ 3352c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); 3362c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall 337d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian} hwc_procs_t; 338d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 339d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 340d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/*****************************************************************************/ 3415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_module { 3435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian struct hw_module_t common; 3445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_module_t; 3455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 346d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_composer_device_1 { 3475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian struct hw_device_t common; 3485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 3505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() is called for each frame before composition and is used by 3515d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * SurfaceFlinger to determine what composition steps the HWC can handle. 3525d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() can be called more than once, the last call prevails. 3545d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 355f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * The HWC responds by setting the compositionType field in each layer to 356f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * either HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the 357f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * composition for the layer is handled by SurfaceFlinger with OpenGL ES, 358f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * in the later case, the HWC will have to handle the layer's composition. 3595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 3605d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the 3615d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * list's geometry has changed, that is, when more than just the buffer's 3625d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * handles have been updated. Typically this happens (but is not limited to) 3635d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * when a window is added, removed, resized or moved. 3645d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 36543b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * For HWC 1.0, numDisplays will always be one, and displays[0] will be 36643b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * non-NULL. 36743b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * 36843b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries 36943b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * for unsupported or disabled/disconnected display types will be NULL. 37043b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * 37143b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more. 37243b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * The extra entries correspond to enabled virtual displays, and will be 37343b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * non-NULL. In HWC 1.2, support for one virtual display is required, and 37443b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * no more than one will be used. Future HWC versions might require more. 375ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * 3765d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returns: 0 on success. An negative error code on error. If an error is 3775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returned, SurfaceFlinger will assume that none of the layer will be 3785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * handled by the HWC. 3795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 380d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*prepare)(struct hwc_composer_device_1 *dev, 381f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall size_t numDisplays, hwc_display_contents_1_t** displays); 3825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 3835d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 3845d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*set)() is used in place of eglSwapBuffers(), and assumes the same 3855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * functionality, except it also commits the work list atomically with 3865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * the actual eglSwapBuffers(). 3875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 388f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * The layer lists are guaranteed to be the same as the ones returned from 389f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * the last call to (*prepare)(). 3905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 391f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * When this call returns the caller assumes that the displays will be 392f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * updated in the near future with the content of their work lists, without 393f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * artifacts during the transition from the previous frame. 3945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 395ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * A display with zero layers indicates that the entire composition has 396ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() 397ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * behaves just like eglSwapBuffers(). 3985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 39943b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * For HWC 1.0, numDisplays will always be one, and displays[0] will be 40043b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * non-NULL. 40143b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * 40243b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries 40343b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * for unsupported or disabled/disconnected display types will be NULL. 40443b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * 40543b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more. 40643b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * The extra entries correspond to enabled virtual displays, and will be 40743b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * non-NULL. In HWC 1.2, support for one virtual display is required, and 40843b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * no more than one will be used. Future HWC versions might require more. 40971212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * 410c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * IMPORTANT NOTE: There is an implicit layer containing opaque black 411f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * pixels behind all the layers in the list. It is the responsibility of 412f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * the hwcomposer module to make sure black pixels are output (or blended 413f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * from). 414fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * 415c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * IMPORTANT NOTE: In the event of an error this call *MUST* still cause 416c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * any fences returned in the previous call to set to eventually become 417c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * signaled. The caller may have already issued wait commands on these 418c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * fences, and having set return without causing those fences to signal 419c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * will likely result in a deadlock. 420c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * 421c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * returns: 0 on success. A negative error code on error: 422c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only 423c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * allowed prior to HWComposer 1.1) 4245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Another code for non EGL errors. 4255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 426d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*set)(struct hwc_composer_device_1 *dev, 427f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall size_t numDisplays, hwc_display_contents_1_t** displays); 428d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 429158549c89405186d9ecaefd3811cfae3949056eeErik Gilling /* 4300a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * eventControl(..., event, enabled) 4310a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Enables or disables h/w composer events for a display. 432158549c89405186d9ecaefd3811cfae3949056eeErik Gilling * 4330a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * eventControl can be called from any thread and takes effect 4340a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * immediately. 4350a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 4360a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Supported events are: 4370a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * HWC_EVENT_VSYNC 4380a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 4390a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * returns -EINVAL if the "event" parameter is not one of the value above 4400a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * or if the "enabled" parameter is not 0 or 1. 441158549c89405186d9ecaefd3811cfae3949056eeErik Gilling */ 4422c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall int (*eventControl)(struct hwc_composer_device_1* dev, int disp, 4430a0a41653d82552e601980c8793fcb07e3863044Jesse Hall int event, int enabled); 4445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 445d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian /* 4460a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * blank(..., blank) 4470a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Blanks or unblanks a display's screen. 448d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * 4490a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Turns the screen off when blank is nonzero, on when blank is zero. 4500a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Multiple sequential calls with the same blank value must be supported. 4510a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * The screen state transition must be be complete when the function 4520a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * returns. 453d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * 4540a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * returns 0 on success, negative on error. 455d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 4562c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); 457d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 458eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* 459eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * Used to retrieve information about the h/w composer 460eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 461eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * Returns 0 on success or -errno on error. 462eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 463d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*query)(struct hwc_composer_device_1* dev, int what, int* value); 464eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 465b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 4660a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * (*registerProcs)() registers callbacks that the h/w composer HAL can 4670a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * later use. It will be called immediately after the composer device is 4680a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks 4690a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * from within registerProcs(). registerProcs() must save the hwc_procs_t 4700a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * pointer which is needed when calling a registered callback. 471b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 4720a0a41653d82552e601980c8793fcb07e3863044Jesse Hall void (*registerProcs)(struct hwc_composer_device_1* dev, 4730a0a41653d82552e601980c8793fcb07e3863044Jesse Hall hwc_procs_t const* procs); 474eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 475b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 4760a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * This field is OPTIONAL and can be NULL. 4770a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 4780a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * If non NULL it will be called by SurfaceFlinger on dumpsys 479b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 4800a0a41653d82552e601980c8793fcb07e3863044Jesse Hall void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); 4810a0a41653d82552e601980c8793fcb07e3863044Jesse Hall 4820a0a41653d82552e601980c8793fcb07e3863044Jesse Hall /* 4832c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * (*getDisplayConfigs)() returns handles for the configurations available 4842c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * on the connected display. These handles must remain valid as long as the 4852c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * display is connected. 4862c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 4872c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * Configuration handles are written to configs. The number of entries 4882c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * allocated by the caller is passed in *numConfigs; getDisplayConfigs must 4892c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * not try to write more than this number of config handles. On return, the 4902c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * total number of configurations available for the display is returned in 4912c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. 4922c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 4932c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * HWC_DEVICE_API_VERSION_1_1 does not provide a way to choose a config. 4942c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * For displays that support multiple configurations, the h/w composer 4952c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * implementation should choose one and report it as the first config in 4962c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * the list. Reporting the not-chosen configs is not required. 4972c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 498d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * Returns 0 on success or -errno on error. If disp is a hotpluggable 499d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * display type and no display is connected, an error should be returned. 5002c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 5012c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. 5022c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * It should be NULL for previous versions. 5032c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall */ 5042c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, 5052c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall uint32_t* configs, size_t* numConfigs); 5062c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall 5072c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall /* 5082c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * (*getDisplayAttributes)() returns attributes for a specific config of a 5092c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * connected display. The config parameter is one of the config handles 5102c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * returned by getDisplayConfigs. 5112c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 5122c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * The list of attributes to return is provided in the attributes 5132c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each 5142c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * requested attribute is written in order to the values array. The 5152c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values 5162c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * array will have one less value than the attributes array. 5172c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 5182c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. 5192c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * It should be NULL for previous versions. 520d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * 521d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * If disp is a hotpluggable display type and no display is connected, 522d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * or if config is not a valid configuration for the display, a negative 523d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * value should be returned. 5242c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall */ 525d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, 5262c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall uint32_t config, const uint32_t* attributes, int32_t* values); 5272c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall 5282c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall /* 5290a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Reserved for future use. Must be NULL. 5300a0a41653d82552e601980c8793fcb07e3863044Jesse Hall */ 5310a0a41653d82552e601980c8793fcb07e3863044Jesse Hall void* reserved_proc[4]; 5325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 533d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_composer_device_1_t; 5345d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 5355d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** convenience API for opening and closing a device */ 5365d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 537d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstatic inline int hwc_open_1(const struct hw_module_t* module, 538d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_composer_device_1_t** device) { 5395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian return module->methods->open(module, 5405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); 5415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} 5425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 543d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstatic inline int hwc_close_1(hwc_composer_device_1_t* device) { 5445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian return device->common.close(&device->common); 5455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} 5465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 5475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/ 5485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 549d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#if !HWC_REMOVE_DEPRECATED_VERSIONS 550d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#include <hardware/hwcomposer_v0.h> 551d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#endif 552d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 5535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__END_DECLS 5545d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 5555d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ 556