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/*****************************************************************************/ 39d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 40d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_layer_1 { 415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 4248697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * compositionType is used to specify this layer's type and is set by either 4348697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * the hardware composer implementation, or by the caller (see below). 44d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * 4548697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * This field is always reset to HWC_BACKGROUND or HWC_FRAMEBUFFER 4648697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * before (*prepare)() is called when the HWC_GEOMETRY_CHANGED flag is 4748697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * also set, otherwise, this field is preserved between (*prepare)() 4848697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * calls. 49eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 50eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * HWC_BACKGROUND 5148697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * Always set by the caller before calling (*prepare)(), this value 5248697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * indicates this is a special "background" layer. The only valid field 5348697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * is backgroundColor. 5448697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT 5548697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * handle the background color. 5648697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 57d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * 58d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * HWC_FRAMEBUFFER_TARGET 5948697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * Always set by the caller before calling (*prepare)(), this value 6048697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * indicates this layer is the framebuffer surface used as the target of 61d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY 62d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and 636b01e2eaf7fb7f167730c0bde1b55ae7ac928060Jesse Hall * this layer should be ignored during set(). 64eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 65d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * This flag (and the framebuffer surface layer) will only be used if the 66d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, 67d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * the OpenGL ES target surface is communicated by the (dpy, sur) fields 68d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall * in hwc_compositor_device_1_t. 6948697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 7048697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * This value cannot be set by the HWC implementation. 7148697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 7248697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 7348697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * HWC_FRAMEBUFFER 7448697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * Set by the caller before calling (*prepare)() ONLY when the 7548697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * HWC_GEOMETRY_CHANGED flag is also set. 7648697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 7748697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * Set by the HWC implementation during (*prepare)(), this indicates 7848697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * that the layer will be drawn into the framebuffer using OpenGL ES. 7948697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * The HWC can toggle this value to HWC_OVERLAY to indicate it will 8048697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * handle the layer. 8148697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 8248697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 8348697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * HWC_OVERLAY 8448697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * Set by the HWC implementation during (*prepare)(), this indicates 8548697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * that the layer will be handled by the HWC (ie: it must not be 8648697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * composited with OpenGL ES). 8748697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 888c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * 898c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * HWC_SIDEBAND 908c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * Set by the caller before calling (*prepare)(), this value indicates 918c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * the contents of this layer come from a sideband video stream. 928c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * 938c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * The h/w composer is responsible for receiving new image buffers from 948c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * the stream at the appropriate time (e.g. synchronized to a separate 958c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * audio stream), compositing them with the current contents of other 968c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * layers, and displaying the resulting image. This happens 978c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * independently of the normal prepare/set cycle. The prepare/set calls 988c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * only happen when other layers change, or when properties of the 998c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * sideband layer such as position or size change. 1008c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * 1018c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * If the h/w composer can't handle the layer as a sideband stream for 1028c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * some reason (e.g. unsupported scaling/blending/rotation, or too many 1038c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * sideband layers) it can set compositionType to HWC_FRAMEBUFFER in 1048c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * (*prepare)(). However, doing so will result in the layer being shown 1058c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * as a solid color since the platform is not currently able to composite 1068c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * sideband layers with the GPU. This may be improved in future 1078c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * versions of the platform. 1084a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * 1094a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * 1104a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * HWC_CURSOR_OVERLAY 1114a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * Set by the HWC implementation during (*prepare)(), this value 1124a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * indicates the layer's composition will now be handled by the HWC. 1134a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * Additionally, the client can now asynchronously update the on-screen 1144a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * position of this layer using the setCursorPositionAsync() api. 1155d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 1165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian int32_t compositionType; 1175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 11848697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian /* 11948697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * hints is bit mask set by the HWC implementation during (*prepare)(). 12048697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * It is preserved between (*prepare)() calls, unless the 12148697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. 12248697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * 12348697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * see hwc_layer_t::hints 12448697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian */ 1255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t hints; 1265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 12748697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian /* see hwc_layer_t::flags */ 1285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t flags; 1295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 130eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian union { 131eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* color of the background. hwc_color_t.a is ignored */ 132eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_color_t backgroundColor; 133eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 134eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian struct { 1358c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall union { 1368c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall /* When compositionType is HWC_FRAMEBUFFER, HWC_OVERLAY, 1378c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * HWC_FRAMEBUFFER_TARGET, this is the handle of the buffer to 1388c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * compose. This handle is guaranteed to have been allocated 1398c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. 1408c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * If the layer's handle is unchanged across two consecutive 1418c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * prepare calls and the HWC_GEOMETRY_CHANGED flag is not set 1428c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * for the second call then the HWComposer implementation may 1438c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * assume that the contents of the buffer have not changed. */ 1448c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall buffer_handle_t handle; 1458c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall 1468c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall /* When compositionType is HWC_SIDEBAND, this is the handle 1478c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * of the sideband video stream to compose. */ 1488c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall const native_handle_t* sidebandStream; 1498c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall }; 150eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 151eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* transformation to apply to the buffer during composition */ 152eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian uint32_t transform; 153eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 154eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* blending to apply during composition */ 155eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian int32_t blending; 156eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 157eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* area of the source to consider, the origin is the top-left corner of 1583b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. 1593b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian * If the h/w can't support a non-integer source crop rectangle, it should 1603b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian * punt to OpenGL ES composition. 1613b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian */ 1623b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian union { 1633b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) 1643b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian hwc_rect_t sourceCropi; 1653b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian hwc_rect_t sourceCrop; // just for source compatibility 1663b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) 1673b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian hwc_frect_t sourceCropf; 1683b4732c9d5462daf52a2ee1a42410bb0220fd28fMathias Agopian }; 169eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 170eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* where to composite the sourceCrop onto the display. The sourceCrop 171eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * is scaled using linear filtering to the displayFrame. The origin is the 172eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * top-left corner of the screen. 173eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 174eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_rect_t displayFrame; 175eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 176eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* visible region in screen space. The origin is the 177eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * top-left corner of the screen. 178eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * The visible region INCLUDES areas overlapped by a translucent layer. 179eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 180eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian hwc_region_t visibleRegionScreen; 181d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 182d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall /* Sync fence object that will be signaled when the buffer's 183d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * contents are available. May be -1 if the contents are already 184d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * available. This field is only valid during set(), and should be 185d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * ignored during prepare(). The set() call must not wait for the 186d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * fence to be signaled before returning, but the HWC must wait for 187d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * all buffers to be signaled before reading from them. 188d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 1890a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * HWC_FRAMEBUFFER layers will never have an acquire fence, since 1900a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * reads from them are complete before the framebuffer is ready for 1910a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * display. 1920a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 1938c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * HWC_SIDEBAND layers will never have an acquire fence, since 1948c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * synchronization is handled through implementation-defined 1958c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * sideband mechanisms. 1968c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * 197d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * The HWC takes ownership of the acquireFenceFd and is responsible 198d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * for closing it when no longer needed. 199d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 200d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int acquireFenceFd; 201d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 202d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall /* During set() the HWC must set this field to a file descriptor for 203d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * a sync fence object that will signal after the HWC has finished 204d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * reading from the buffer. The field is ignored by prepare(). Each 205d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * layer should have a unique file descriptor, even if more than one 206d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * refer to the same underlying fence object; this allows each to be 207d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * closed independently. 208d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 209d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * If buffer reads can complete at significantly different times, 210d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * then using independent fences is preferred. For example, if the 211d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * HWC handles some layers with a blit engine and others with 212d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * overlays, then the blit layers can be reused immediately after 213d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * the blit completes, but the overlay layers can't be reused until 214d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * a subsequent frame has been displayed. 215d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * 2160a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't 2170a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * produce a release fence for them. The releaseFenceFd will be -1 2180a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * for these layers when set() is called. 2190a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 2208c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * Since HWC_SIDEBAND buffers don't pass through the HWC client, 2218c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * the HWC shouldn't produce a release fence for them. The 2228c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * releaseFenceFd will be -1 for these layers when set() is called. 2238c79c08578b51a1385759eddf25b0ec5f03e5198Jesse Hall * 224d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * The HWC client taks ownership of the releaseFenceFd and is 225d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * responsible for closing it when no longer needed. 226d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 227d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int releaseFenceFd; 228e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian 229e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian /* 230e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * Availability: HWC_DEVICE_API_VERSION_1_2 231e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 232e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * Alpha value applied to the whole layer. The effective 233e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * value of each pixel is computed as: 234e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 235e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * if (blending == HWC_BLENDING_PREMULT) 236e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * pixel.rgb = pixel.rgb * planeAlpha / 255 237e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * pixel.a = pixel.a * planeAlpha / 255 238e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 239e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * Then blending proceeds as usual according to the "blending" 240e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * field above. 241e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 242e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * NOTE: planeAlpha applies to YUV layers as well: 243e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 244e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * pixel.rgb = yuv_to_rgb(pixel.yuv) 245e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * if (blending == HWC_BLENDING_PREMULT) 246e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * pixel.rgb = pixel.rgb * planeAlpha / 255 247e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * pixel.a = planeAlpha 248e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 249e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 250e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * IMPLEMENTATION NOTE: 251e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 252e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * If the source image doesn't have an alpha channel, then 253e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * the h/w can use the HWC_BLENDING_COVERAGE equations instead of 254e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * HWC_BLENDING_PREMULT and simply set the alpha channel to 255e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * planeAlpha. 256e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 257e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * e.g.: 258e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 259e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * if (blending == HWC_BLENDING_PREMULT) 260e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * blending = HWC_BLENDING_COVERAGE; 261e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * pixel.a = planeAlpha; 262e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian * 263e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian */ 264e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian uint8_t planeAlpha; 265e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian 266811445a3f31023985b498312da3d9690dc20ca11Dan Stoza /* Pad to 32 bits */ 267e3e0a570a85ea40ce215e80679ba4ae1b014664fMathias Agopian uint8_t _pad[3]; 268811445a3f31023985b498312da3d9690dc20ca11Dan Stoza 269811445a3f31023985b498312da3d9690dc20ca11Dan Stoza /* 270811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * Availability: HWC_DEVICE_API_VERSION_1_5 271811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * 272811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * This defines the region of the source buffer that has been 273811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * modified since the last frame. 274811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * 275811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * If surfaceDamage.numRects > 0, then it may be assumed that any 276811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * portion of the source buffer not covered by one of the rects has 277811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * not been modified this frame. If surfaceDamage.numRects == 0, 278811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * then the whole source buffer must be treated as if it had been 279811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * modified. 280811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * 281811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * If the layer's contents are not modified relative to the prior 282811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * prepare/set cycle, surfaceDamage will contain exactly one empty 283811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * rect ([0, 0, 0, 0]). 284811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * 285811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * The damage rects are relative to the pre-transformed buffer, and 286811445a3f31023985b498312da3d9690dc20ca11Dan Stoza * their origin is the top-left corner. 287811445a3f31023985b498312da3d9690dc20ca11Dan Stoza */ 288811445a3f31023985b498312da3d9690dc20ca11Dan Stoza hwc_region_t surfaceDamage; 289eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian }; 290eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian }; 2915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 29291699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza#ifdef __LP64__ 29391699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza /* 29491699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza * For 64-bit mode, this struct is 120 bytes (and 8-byte aligned), and needs 29591699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza * to be padded as such to maintain binary compatibility. 29691699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza */ 297811445a3f31023985b498312da3d9690dc20ca11Dan Stoza uint8_t reserved[120 - 112]; 29891699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza#else 29991699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza /* 30091699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza * For 32-bit mode, this struct is 96 bytes, and needs to be padded as such 30191699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza * to maintain binary compatibility. 302d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */ 303811445a3f31023985b498312da3d9690dc20ca11Dan Stoza uint8_t reserved[96 - 84]; 30491699a82eb3cf382c78a6c5ba73405f86bc394c7Dan Stoza#endif 305d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 306d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_layer_1_t; 3075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 308f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall/* This represents a display, typically an EGLDisplay object */ 309f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef void* hwc_display_t; 310f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall 311f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall/* This represents a surface, typically an EGLSurface object */ 312f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef void* hwc_surface_t; 313f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall 3145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/* 315f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * hwc_display_contents_1_t::flags values 3165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 3175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum { 3185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 3195d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list 320d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * passed to (*prepare)() has changed by more than just the buffer handles 321d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * and acquire fences. 3225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 3235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_GEOMETRY_CHANGED = 0x00000001, 3245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}; 3255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 326871815b5f144048b63a18ef764f82e89394899faLouis Huemiller/* 327f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * Description of the contents to output on a display. 328f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * 329f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * This is the top-level structure passed to the prepare and set calls to 330f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * negotiate and commit the composition of a display image. 331871815b5f144048b63a18ef764f82e89394899faLouis Huemiller */ 332f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef struct hwc_display_contents_1 { 333f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall /* File descriptor referring to a Sync HAL fence object which will signal 3347cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * when this composition is retired. For a physical display, a composition 3357cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * is retired when it has been replaced on-screen by a subsequent set. For 3367cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * a virtual display, the composition is retired when the writes to 3377cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * outputBuffer are complete and can be read. The fence object is created 3387cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * and returned by the set call; this field will be -1 on entry to prepare 3397cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * and set. SurfaceFlinger will close the returned file descriptor. 340f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall */ 3417cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall int retireFenceFd; 342f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall 3437cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall union { 3447cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ 3457cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall struct { 3467cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES 3477cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to 3487cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * prepare. The set call should commit this surface atomically to 3497cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * the display along with any overlay layers. 3507cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall */ 3517cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall hwc_display_t dpy; 3527cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall hwc_surface_t sur; 3537cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall }; 3547cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall 3557ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall /* These fields are used for virtual displays when the h/w composer 3567ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * version is at least HWC_DEVICE_VERSION_1_3. */ 3577cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall struct { 3587cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* outbuf is the buffer that receives the composed image for 3597cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * virtual displays. Writes to the outbuf must wait until 3607cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * outbufAcquireFenceFd signals. A fence that will signal when 3617cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * writes to outbuf are complete should be returned in 3627cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * retireFenceFd. 3637cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * 3647ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * This field is set before prepare(), so properties of the buffer 3657ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * can be used to decide which layers can be handled by h/w 3667ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * composer. 367380f45dade4a917e6e72c4ce756a20f6242f14fdJesse Hall * 3687ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * If prepare() sets all layers to FRAMEBUFFER, then GLES 3697ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * composition will happen directly to the output buffer. In this 3707ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * case, both outbuf and the FRAMEBUFFER_TARGET layer's buffer will 3717ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * be the same, and set() has no work to do besides managing fences. 3727ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * 3737ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * If the TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS board config 3747ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * variable is defined (not the default), then this behavior is 3757ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * changed: if all layers are marked for FRAMEBUFFER, GLES 3767ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * composition will take place to a scratch framebuffer, and 3777ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * h/w composer must copy it to the output buffer. This allows the 3787ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * h/w composer to do format conversion if there are cases where 3797ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * that is more desirable than doing it in the GLES driver or at the 3807ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * virtual display consumer. 3817ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * 3827ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * If some or all layers are marked OVERLAY, then the framebuffer 3837ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * and output buffer will be different. As with physical displays, 3847ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * the framebuffer handle will not change between frames if all 3857ccf148f5066ceb1a161f0d7a7d66f75c6e8d420Jesse Hall * layers are marked for OVERLAY. 3867cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall */ 3877cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall buffer_handle_t outbuf; 3887cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall 3897cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall /* File descriptor for a fence that will signal when outbuf is 3907cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * ready to be written. The h/w composer is responsible for closing 3917cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * this when no longer needed. 3927cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * 3937cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * Will be -1 whenever outbuf is NULL, or when the outbuf can be 3947cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall * written immediately. 3957cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall */ 3967cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall int outbufAcquireFenceFd; 3977cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall }; 3987cb03d79b3040d9b43ffc81414e9853e8a57adb1Jesse Hall }; 399f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall 400f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall /* List of layers that will be composed on the display. The buffer handles 401ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * in the list will be unique. If numHwLayers is 0, all composition will be 402ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * performed by SurfaceFlinger. 403f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall */ 4045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian uint32_t flags; 4055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian size_t numHwLayers; 406d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_layer_1_t hwLayers[0]; 4075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 408f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall} hwc_display_contents_1_t; 4095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 410d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/* see hwc_composer_device::registerProcs() 4110a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * All of the callbacks are required and non-NULL unless otherwise noted. 412d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 413d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopiantypedef struct hwc_procs { 414d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian /* 415d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * (*invalidate)() triggers a screen refresh, in particular prepare and set 416d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * will be called shortly after this call is made. Note that there is 417d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * NO GUARANTEE that the screen refresh will happen after invalidate() 418d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * returns (in particular, it could happen before). 419d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and 420d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * it is safe to call invalidate() from any of hwc_composer_device 421d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * hooks, unless noted otherwise. 422d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */ 4230a0a41653d82552e601980c8793fcb07e3863044Jesse Hall void (*invalidate)(const struct hwc_procs* procs); 424b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian 425b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 426b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * (*vsync)() is called by the h/w composer HAL when a vsync event is 427f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * received and HWC_EVENT_VSYNC is enabled on a display 428f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * (see: hwc_event_control). 429b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 4302c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * the "disp" parameter indicates which display the vsync event is for. 4316b7adef0ef38f568099eab38d6865f402c92235bJamie Gennis * the "timestamp" parameter is the system monotonic clock timestamp in 4326b7adef0ef38f568099eab38d6865f402c92235bJamie Gennis * nanosecond of when the vsync event happened. 433b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 434b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. 435b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 436b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * It is expected that vsync() is called from a thread of at least 437eb67160b995a504dd70a8f29d228ec837341eb07Mathias Agopian * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, 438b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * typically less than 0.5 ms. 439b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian * 4406d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling 4416d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation 4426d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * can either stop or continue to process VSYNC events, but must not 4436d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian * crash or cause other problems. 444b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 4452c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); 4462c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall 4472c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall /* 4482c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * (*hotplug)() is called by the h/w composer HAL when a display is 4492c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * connected or disconnected. The PRIMARY display is always connected and 4502c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * the hotplug callback should not be called for it. 4512c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 4522c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * The disp parameter indicates which display type this event is for. 4532c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * The connected parameter indicates whether the display has just been 4542c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * connected (1) or disconnected (0). 4552c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 4562c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * The hotplug() callback may call back into the h/w composer on the same 4572c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * thread to query refresh rate and dpi for the display. Additionally, 4582c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * other threads may be calling into the h/w composer while the callback 4592c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * is in progress. 4602c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 461d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * The h/w composer must serialize calls to the hotplug callback; only 462d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * one thread may call it at a time. 463d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * 4642c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * This callback will be NULL if the h/w composer is using 4652c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * HWC_DEVICE_API_VERSION_1_0. 4662c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall */ 4672c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); 4682c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall 469d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian} hwc_procs_t; 470d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 471d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 472d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/*****************************************************************************/ 4735d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 4745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_module { 47584d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles /** 47684d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles * Common methods of the hardware composer module. This *must* be the first member of 47784d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles * hwc_module as users of this structure will cast a hw_module_t to 47884d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles * hwc_module pointer in contexts where it's known the hw_module_t references a 47984d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles * hwc_module. 48084d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles */ 4815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian struct hw_module_t common; 4825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_module_t; 4835d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 484d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_composer_device_1 { 48584d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles /** 48684d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles * Common methods of the hardware composer device. This *must* be the first member of 48784d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles * hwc_composer_device_1 as users of this structure will cast a hw_device_t to 48884d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles * hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a 48984d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles * hwc_composer_device_1. 49084d35492b145cebc000f8fd72818eb25b8e65c04Stewart Miles */ 4915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian struct hw_device_t common; 4925d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 4935d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 4945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() is called for each frame before composition and is used by 4955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * SurfaceFlinger to determine what composition steps the HWC can handle. 4965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 4975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() can be called more than once, the last call prevails. 4985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 499f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * The HWC responds by setting the compositionType field in each layer to 5004a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * either HWC_FRAMEBUFFER, HWC_OVERLAY, or HWC_CURSOR_OVERLAY. For the 5014a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * HWC_FRAMEBUFFER type, composition for the layer is handled by 5024a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * SurfaceFlinger with OpenGL ES. For the latter two overlay types, 5034a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * the HWC will have to handle the layer's composition. compositionType 5044a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * and hints are preserved between (*prepare)() calles unless the 5054a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * HWC_GEOMETRY_CHANGED flag is set. 5065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 5075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the 5085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * list's geometry has changed, that is, when more than just the buffer's 5095d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * handles have been updated. Typically this happens (but is not limited to) 51048697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * when a window is added, removed, resized or moved. In this case 51148697f6dc249d1238243677de77d3a0eb6a17b3fMathias Agopian * compositionType and hints are reset to their default value. 5125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 51343b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * For HWC 1.0, numDisplays will always be one, and displays[0] will be 51443b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * non-NULL. 51543b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * 516fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. 517fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * Entries for unsupported or disabled/disconnected display types will be 518fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * NULL. 51943b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * 520fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra 521fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * entries correspond to enabled virtual displays, and will be non-NULL. 522ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * 5235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returns: 0 on success. An negative error code on error. If an error is 5245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * returned, SurfaceFlinger will assume that none of the layer will be 5255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * handled by the HWC. 5265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 527d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*prepare)(struct hwc_composer_device_1 *dev, 528f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall size_t numDisplays, hwc_display_contents_1_t** displays); 5295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 5305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian /* 5315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * (*set)() is used in place of eglSwapBuffers(), and assumes the same 5325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * functionality, except it also commits the work list atomically with 5335d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * the actual eglSwapBuffers(). 5345d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 535f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * The layer lists are guaranteed to be the same as the ones returned from 536f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * the last call to (*prepare)(). 5375d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 538f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * When this call returns the caller assumes that the displays will be 539f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * updated in the near future with the content of their work lists, without 540f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * artifacts during the transition from the previous frame. 5415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 542ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * A display with zero layers indicates that the entire composition has 543ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() 544ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall * behaves just like eglSwapBuffers(). 5455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * 54643b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * For HWC 1.0, numDisplays will always be one, and displays[0] will be 54743b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * non-NULL. 54843b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * 549fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. 550fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * Entries for unsupported or disabled/disconnected display types will be 551fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * NULL. 55243b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall * 553fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra 554fc0ff2a8700eb11aef7a961b279d846c8a1c04c5Jesse Hall * entries correspond to enabled virtual displays, and will be non-NULL. 55571212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian * 556c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * IMPORTANT NOTE: There is an implicit layer containing opaque black 557f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * pixels behind all the layers in the list. It is the responsibility of 558f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * the hwcomposer module to make sure black pixels are output (or blended 559f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * from). 560fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian * 561c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * IMPORTANT NOTE: In the event of an error this call *MUST* still cause 562c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * any fences returned in the previous call to set to eventually become 563c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * signaled. The caller may have already issued wait commands on these 564c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * fences, and having set return without causing those fences to signal 565c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * will likely result in a deadlock. 566c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * 567c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * returns: 0 on success. A negative error code on error: 568c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only 569c7545189c8b260bbaf09653407450418a3d1860bJamie Gennis * allowed prior to HWComposer 1.1) 5705d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Another code for non EGL errors. 5715d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */ 572d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*set)(struct hwc_composer_device_1 *dev, 573f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall size_t numDisplays, hwc_display_contents_1_t** displays); 574d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall 575158549c89405186d9ecaefd3811cfae3949056eeErik Gilling /* 5760a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * eventControl(..., event, enabled) 5770a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Enables or disables h/w composer events for a display. 578158549c89405186d9ecaefd3811cfae3949056eeErik Gilling * 5790a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * eventControl can be called from any thread and takes effect 5800a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * immediately. 5810a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 5820a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Supported events are: 5830a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * HWC_EVENT_VSYNC 5840a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 5850a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * returns -EINVAL if the "event" parameter is not one of the value above 5860a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * or if the "enabled" parameter is not 0 or 1. 587158549c89405186d9ecaefd3811cfae3949056eeErik Gilling */ 5882c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall int (*eventControl)(struct hwc_composer_device_1* dev, int disp, 5890a0a41653d82552e601980c8793fcb07e3863044Jesse Hall int event, int enabled); 5905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 59102b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani union { 59202b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani /* 59302b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * For HWC 1.3 and earlier, the blank() interface is used. 59402b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 59502b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * blank(..., blank) 59602b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * Blanks or unblanks a display's screen. 59702b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 59802b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * Turns the screen off when blank is nonzero, on when blank is zero. 59902b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * Multiple sequential calls with the same blank value must be 60002b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * supported. 60102b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * The screen state transition must be be complete when the function 60202b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * returns. 60302b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 60402b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * returns 0 on success, negative on error. 60502b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani */ 60602b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); 60702b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani 60802b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani /* 60902b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * For HWC 1.4 and above, setPowerMode() will be used in place of 61002b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * blank(). 61102b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 61202b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * setPowerMode(..., mode) 61302b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * Sets the display screen's power state. 61402b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 615842b906dd44bf874e17334d0343ede76d3e87c50Jeff Brown * Refer to the documentation of the HWC_POWER_MODE_* constants 616842b906dd44bf874e17334d0343ede76d3e87c50Jeff Brown * for information about each power mode. 61702b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 61802b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * The functionality is similar to the blank() command in previous 61902b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * versions of HWC, but with support for more power states. 62002b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 62102b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * The display driver is expected to retain and restore the low power 62202b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * state of the display while entering and exiting from suspend. 62302b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 62402b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * Multiple sequential calls with the same mode value must be supported. 62502b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 62602b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * The screen state transition must be be complete when the function 62702b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * returns. 62802b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * 62902b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani * returns 0 on success, negative on error. 63002b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani */ 63102b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani int (*setPowerMode)(struct hwc_composer_device_1* dev, int disp, 63202b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani int mode); 63302b31986cba2cd1612155a1bb72d0fb17b55b219Prashant Malani }; 634d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian 635eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian /* 636eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * Used to retrieve information about the h/w composer 637eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * 638eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian * Returns 0 on success or -errno on error. 639eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian */ 640d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall int (*query)(struct hwc_composer_device_1* dev, int what, int* value); 641eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 642b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 6430a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * (*registerProcs)() registers callbacks that the h/w composer HAL can 6440a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * later use. It will be called immediately after the composer device is 6450a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks 6460a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * from within registerProcs(). registerProcs() must save the hwc_procs_t 6470a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * pointer which is needed when calling a registered callback. 648b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 6490a0a41653d82552e601980c8793fcb07e3863044Jesse Hall void (*registerProcs)(struct hwc_composer_device_1* dev, 6500a0a41653d82552e601980c8793fcb07e3863044Jesse Hall hwc_procs_t const* procs); 651eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian 652b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian /* 6530a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * This field is OPTIONAL and can be NULL. 6540a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * 6550a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * If non NULL it will be called by SurfaceFlinger on dumpsys 656b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian */ 6570a0a41653d82552e601980c8793fcb07e3863044Jesse Hall void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); 6580a0a41653d82552e601980c8793fcb07e3863044Jesse Hall 6590a0a41653d82552e601980c8793fcb07e3863044Jesse Hall /* 6602c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * (*getDisplayConfigs)() returns handles for the configurations available 6612c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * on the connected display. These handles must remain valid as long as the 6622c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * display is connected. 6632c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 6642c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * Configuration handles are written to configs. The number of entries 6652c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * allocated by the caller is passed in *numConfigs; getDisplayConfigs must 6662c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * not try to write more than this number of config handles. On return, the 6672c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * total number of configurations available for the display is returned in 6682c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. 6692c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 670e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * Hardware composers implementing HWC_DEVICE_API_VERSION_1_3 or prior 671e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * shall choose one configuration to activate and report it as the first 672e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * entry in the returned list. Reporting the inactive configurations is not 673e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * required. 674e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 675e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * HWC_DEVICE_API_VERSION_1_4 and later provide configuration management 676e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * through SurfaceFlinger, and hardware composers implementing these APIs 677e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * must also provide getActiveConfig and setActiveConfig. Hardware composers 678e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * implementing these API versions may choose not to activate any 679e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * configuration, leaving configuration selection to higher levels of the 680e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * framework. 681e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 682e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * Returns 0 on success or a negative error code on error. If disp is a 683e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * hotpluggable display type and no display is connected, an error shall be 684e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * returned. 6852c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 6862c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. 687e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * It shall be NULL for previous versions. 6882c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall */ 6892c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, 6902c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall uint32_t* configs, size_t* numConfigs); 6912c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall 6922c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall /* 6932c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * (*getDisplayAttributes)() returns attributes for a specific config of a 6942c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * connected display. The config parameter is one of the config handles 6952c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * returned by getDisplayConfigs. 6962c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 6972c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * The list of attributes to return is provided in the attributes 6982c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each 6992c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * requested attribute is written in order to the values array. The 7002c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values 7012c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * array will have one less value than the attributes array. 7022c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * 7032c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. 704e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * It shall be NULL for previous versions. 705d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * 706d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * If disp is a hotpluggable display type and no display is connected, 707d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall * or if config is not a valid configuration for the display, a negative 708e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * error code shall be returned. 7092c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall */ 710d91697ab8fee9b4c55170230f355f5a25eceefafJesse Hall int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, 7112c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall uint32_t config, const uint32_t* attributes, int32_t* values); 7122c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall 7132c13759c61dd111efc9509ddf37330f50f706f64Jesse Hall /* 714e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * (*getActiveConfig)() returns the index of the configuration that is 715e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * currently active on the connected display. The index is relative to 716e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * the list of configuration handles returned by getDisplayConfigs. If there 717e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * is no active configuration, -1 shall be returned. 718e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 719e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * Returns the configuration index on success or -1 on error. 720e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 721e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. 722e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * It shall be NULL for previous versions. 723e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza */ 724e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza int (*getActiveConfig)(struct hwc_composer_device_1* dev, int disp); 725e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza 726e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza /* 727e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * (*setActiveConfig)() instructs the hardware composer to switch to the 728e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * display configuration at the given index in the list of configuration 729e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * handles returned by getDisplayConfigs. 730e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 731e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * If this function returns without error, any subsequent calls to 732e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * getActiveConfig shall return the index set by this function until one 733e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * of the following occurs: 734e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 1) Another successful call of this function 735e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 2) The display is disconnected 736e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 737e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * Returns 0 on success or a negative error code on error. If disp is a 738e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * hotpluggable display type and no display is connected, or if index is 739e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * outside of the range of hardware configurations returned by 740e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * getDisplayConfigs, an error shall be returned. 741e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * 742e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. 743e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza * It shall be NULL for previous versions. 744e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza */ 745e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza int (*setActiveConfig)(struct hwc_composer_device_1* dev, int disp, 746e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza int index); 7474a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews /* 7484a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * Asynchronously update the location of the cursor layer. 7494a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * 7504a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * Within the standard prepare()/set() composition loop, the client 7514a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * (surfaceflinger) can request that a given layer uses dedicated cursor 7524a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * composition hardware by specifiying the HWC_IS_CURSOR_LAYER flag. Only 7534a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * one layer per display can have this flag set. If the layer is suitable 7544a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * for the platform's cursor hardware, hwcomposer will return from prepare() 7554a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * a composition type of HWC_CURSOR_OVERLAY for that layer. This indicates 7564a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * not only that the client is not responsible for compositing that layer, 7574a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * but also that the client can continue to update the position of that layer 7584a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * after a call to set(). This can reduce the visible latency of mouse 7594a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * movement to visible, on-screen cursor updates. Calls to 7604a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * setCursorPositionAsync() may be made from a different thread doing the 7614a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * prepare()/set() composition loop, but care must be taken to not interleave 7624a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * calls of setCursorPositionAsync() between calls of set()/prepare(). 7634a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * 7644a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * Notes: 7654a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * - Only one layer per display can be specified as a cursor layer with 7664a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * HWC_IS_CURSOR_LAYER. 7674a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * - hwcomposer will only return one layer per display as HWC_CURSOR_OVERLAY 7684a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * - This returns 0 on success or -errno on error. 7694a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * - This field is optional for HWC_DEVICE_API_VERSION_1_4 and later. It 7704a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews * should be null for previous versions. 7714a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews */ 7724a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews int (*setCursorPositionAsync)(struct hwc_composer_device_1 *dev, int disp, int x_pos, int y_pos); 773e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza 774e83d10c1fc61ac7921d58d8818a9ad4926a207adDan Stoza /* 7750a0a41653d82552e601980c8793fcb07e3863044Jesse Hall * Reserved for future use. Must be NULL. 7760a0a41653d82552e601980c8793fcb07e3863044Jesse Hall */ 7774a6788b02fb2bd174ac9e2386029785f084b7fddRiley Andrews void* reserved_proc[1]; 7785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 779d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_composer_device_1_t; 7805d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 7815d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** convenience API for opening and closing a device */ 7825d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 783d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstatic inline int hwc_open_1(const struct hw_module_t* module, 784d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall hwc_composer_device_1_t** device) { 7855d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian return module->methods->open(module, 7865d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); 7875d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} 7885d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 789d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstatic inline int hwc_close_1(hwc_composer_device_1_t* device) { 7905d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian return device->common.close(&device->common); 7915d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} 7925d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 7935d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/ 7945d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 7955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__END_DECLS 7965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian 7975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ 798